From 990c0f8474e36a8ddb40305762be92fc02b716ff Mon Sep 17 00:00:00 2001 From: phelter Date: Thu, 23 Feb 2023 19:09:25 -0800 Subject: [PATCH 01/28] 556 Initial Cmake Module definition. #557 --- .github/workflows/ci.yml | 24 +- CMakeLists.txt | 236 ++++++++++++++++++ README.md | 35 ++- cmake_modules/FindPCAP.cmake | 75 ++++++ source/CMakeLists.txt | 93 +++++++ source/FreeRTOS_IP.c | 3 + source/FreeRTOS_Sockets.c | 4 + source/portable/CMakeLists.txt | 36 +++ .../NetworkInterface/ATSAM4E/CMakeLists.txt | 26 ++ .../NetworkInterface/ATSAME5x/CMakeLists.txt | 20 ++ .../portable/NetworkInterface/CMakeLists.txt | 54 ++++ .../NetworkInterface/DriverSAM/CMakeLists.txt | 22 ++ .../NetworkInterface/LPC17xx/CMakeLists.txt | 28 +++ .../NetworkInterface/LPC18xx/CMakeLists.txt | 28 +++ .../NetworkInterface/LPC54018/CMakeLists.txt | 28 +++ .../NetworkInterface/M487/CMakeLists.txt | 22 ++ .../MPS2_AN385/CMakeLists.txt | 29 +++ .../NetworkInterface/RX/CMakeLists.txt | 22 ++ .../NetworkInterface/SH2A/CMakeLists.txt | 25 ++ .../NetworkInterface/STM32Fxx/CMakeLists.txt | 25 ++ .../NetworkInterface/STM32Hxx/CMakeLists.txt | 23 ++ .../NetworkInterface/TM4C/CMakeLists.txt | 20 ++ .../ThirdParty/MSP432/CMakeLists.txt | 23 ++ .../NetworkInterface/WinPCap/CMakeLists.txt | 25 ++ .../NetworkInterface/Zynq/CMakeLists.txt | 73 ++++++ .../board_family/CMakeLists.txt | 20 ++ .../NetworkInterface/esp32/CMakeLists.txt | 28 +++ .../ksz8851snl/CMakeLists.txt | 23 ++ .../NetworkInterface/libslirp/CMakeLists.txt | 29 +++ .../NetworkInterface/linux/CMakeLists.txt | 39 +++ .../NetworkInterface/linux/NetworkInterface.c | 8 +- .../NetworkInterface/mw300_rd/CMakeLists.txt | 20 ++ .../NetworkInterface/pic32mzef/CMakeLists.txt | 23 ++ .../xilinx_ultrascale/CMakeLists.txt | 70 ++++++ test/CMakeLists.txt | 8 + test/build-combination/CMakeLists.txt | 144 +++++------ .../build-combination/Common/FreeRTOSConfig.h | 9 +- test/build-combination/Common/main.c | 44 +++- .../DefaultConf/FreeRTOSIPConfig.h | 8 +- test/build-combination/README.md | 18 +- tools/CMakeLists.txt | 37 +++ 41 files changed, 1400 insertions(+), 127 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 cmake_modules/FindPCAP.cmake create mode 100644 source/CMakeLists.txt create mode 100644 source/portable/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/ATSAM4E/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/ATSAME5x/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/DriverSAM/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/LPC17xx/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/LPC18xx/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/LPC54018/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/M487/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/MPS2_AN385/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/RX/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/SH2A/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/STM32Fxx/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/STM32Hxx/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/TM4C/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/ThirdParty/MSP432/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/WinPCap/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/Zynq/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/board_family/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/esp32/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/ksz8851snl/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/libslirp/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/linux/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/mw300_rd/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/pic32mzef/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/xilinx_ultrascale/CMakeLists.txt create mode 100644 test/CMakeLists.txt create mode 100644 tools/CMakeLists.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e649345d3c..a6e9808391 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: - name: Clone This Repo uses: actions/checkout@v2 with: - path: ./tcp + path: ./tcp - name: Install spell run: | sudo apt-get install spell @@ -111,23 +111,23 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Update submodules - run: git submodule update --init --checkout + - name: Build Install Dependencies + run: | + sudo apt-get install -y libpcap-dev - name: Build checks (Enable all functionalities) run: | - cmake -S test/build-combination -B test/build-combination/build/ \ - -DTEST_CONFIGURATION=ENABLE_ALL - make -C test/build-combination/build/ + cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL + cmake --build build --target freertos_plus_tcp_build_test - name: Build checks (Disable all functionalities) run: | - cmake -S test/build-combination -B test/build-combination/build/ \ - -DTEST_CONFIGURATION=DISABLE_ALL - make -C test/build-combination/build/ + cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=DISABLE_ALL + cmake --build build --target clean + cmake --build build --target freertos_plus_tcp_build_test - name: Build checks (Default configuration) run: | - cmake -S test/build-combination -B test/build-combination/build/ \ - -DTEST_CONFIGURATION=DEFAULT_CONF - make -C test/build-combination/build/ + cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=DEFAULT_CONF + cmake --build build --target clean + cmake --build build --target freertos_plus_tcp_build_test complexity: runs-on: ubuntu-latest diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..71d0b56d0b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,236 @@ + +cmake_minimum_required(VERSION 3.15) +cmake_policy(SET CMP0048 NEW) # project version +cmake_policy(SET CMP0076 NEW) # full paths + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules") + +######################################################################## +# Project Details +project(FreeRTOS-Plus-TCP + VERSION 3.1.0 + DESCRIPTION "FreeRTOS TCP/UDP Network Layer" + HOMEPAGE_URL https://freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/index.html + LANGUAGES C) + +# Do not allow in-source build. +if( ${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR} ) +message( FATAL_ERROR "In-source build is not allowed. Please build in a separate directory, such as ${PROJECT_SOURCE_DIR}/build." ) +endif() + +# Options +option(FREERTOS_PLUS_TCP_BUILD_TEST "Build the test for FreeRTOS Plus TCP" OFF) + +# Configuration +# Override these at project level with: +# Optional: set(FREERTOS_PLUS_TCP_BUFFER_ALLOCATION "1" CACHE STRING "" FORCE) +# Optional: set(FREERTOS_PLUS_TCP_COMPILER "" CACHE STRING "" FORCE) +# Required: set(FREERTOS_PLUS_TCP_NETWORK_IF "POSIX" CACHE STRING "" FORCE) + +# Select the appropriate buffer allocaiton method. +# See: https://freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Ethernet_Buffer_Management.html +if (NOT FREERTOS_PLUS_TCP_BUFFER_ALLOCATION) + message(STATUS "Using default FREERTOS_PLUS_TCP_BUFFER_ALLOCATION = 2") + set(FREERTOS_PLUS_TCP_BUFFER_ALLOCATION "2" CACHE STRING "FreeRTOS buffer allocation model number. 1 .. 2.") +endif() + +# Select the Compiler - if left blank will detect using CMake +# Note relies on CMake to detect over any setting here. +# Valid options are: +# FREERTOS_PLUS_TCP_COMPILER | Detected | CMake +# ------------------------------------------------- +# CCS | No | ?TBD? +# GCC | Yes | GNU +# IAR | Yes | IAR +# Keil | Yes | ARMCC +# MSVC | Yes | MSVC # Note only for MinGW +# Renesas | No | ?TBD? +# Will always a attempt to detect and if detectable double checks that the compiler is set correctly. +set(FREERTOS_PLUS_TCP_COMPILER "" CACHE STRING "FreeRTOS Plus TCP Compiler Selection") + + +# Select the appropriate network interface +# This will fail the CMake preparation step if not set to one of those values. +set(FREERTOS_PLUS_TCP_NETWORK_IF "" CACHE STRING "FreeRTOS Plus TCP Network Interface selection") +set(FREERTOS_PLUS_TCP_NETWORK_IF_LIST + A_CUSTOM_NETWORK_IF + ATSAM43 ATSAME5x # AT + DRIVER_SAM + ESP32 + KSZ8851SNL + LPC17xx LPC18xx LPC54018 + M487 + MPS2_AN385 + MW300_RD + PIC32MZEF_ETH PIC32MZEF_WIFI + POSIX WIN_PCAP # Native Linux & Windows respectively + RX + SH2A + STM32FXX STM32HXX # ST Micro + MSP432 + TM4C + XILINX_ULTRASCALE ZYNQ # AMD/Xilinx +) +if(NOT FREERTOS_PLUS_TCP_NETWORK_IF) + # Attempt to detect the system. + if(UNIX) + message(STATUS "Detected UNIX/Posix system setting FREERTOS_PLUS_TCP_NETWORK_IF = POSIX") + set(FREERTOS_PLUS_TCP_NETWORK_IF POSIX) + elseif(MINGW) + message(STATUS "Detected Windows MinGW system setting FREERTOS_PLUS_TCP_NETWORK_IF = WIN_PCAP") + set(FREERTOS_PLUS_TCP_NETWORK_IF WIN_PCAP) + endif() +endif() + +if(NOT FREERTOS_PLUS_TCP_NETWORK_IF IN_LIST FREERTOS_PLUS_TCP_NETWORK_IF_LIST ) + message(FATAL_ERROR " FREERTOS_PLUS_TCP_NETWORK_IF is '${FREERTOS_PLUS_TCP_NETWORK_IF}'.\n" + " Please specify it from top-level CMake file (example):\n" + " set(FREERTOS_PLUS_TCP_NETWORK_IF POSIX CACHE STRING \"\")\n" + " or from CMake command line option:\n" + " -DFREERTOS_PLUS_TCP_NETWORK_IF=POSIX\n" + " \n" + " Available port options: (Tested means compiled with that variant)\n" + " A_CUSTOM_NETWORK_IF Target: User Defined\n" + " ATSAM4E Target: ATSAM4E Tested: TODO\n" + " ATSAME5x Target: ATSAME5x Tested: TODO\n" + " DRIVER_SAM Target: Driver SAM Tested: TODO\n" + " ESP32 Target: ESP-32 Tested: TODO\n" + " KSZ8851SNL Target: ksz8851snl Tested: TODO\n" + " POSIX Target: linux/Posix\n" + " LPC17xx Target: LPC17xx Tested: TODO\n" + " LPC18xx Target: LPC18xx Tested: TODO\n" + " LPC54018 Target: LPC54018 Tested: TODO\n" + " M487 Target: M487 Tested: TODO\n" + " MPS2_AN385 Target: MPS2_AN385 Tested: TODO\n" + " MW300_RD Target: mw300_rd Tested: TODO\n" + " PIC32MZEF_ETH Target: pic32mzef ethernet Tested: TODO\n" + " PIC32MZEF_WIFI Target: pic32mzef Wifi Tested: TODO\n" + " RX Target: RX Tested: TODO\n" + " SH2A Target: SH2A Tested: TODO\n" + " STM32FXX Target: STM32Fxx Tested: TODO\n" + " STM32HXX Target: STM32Hxx Tested: TODO\n" + " MSP432 Target: MSP432 Tested: TODO\n" + " TM4C Target: TM4C Tested: TODO\n" + " WIN_PCAP Target: Windows Tested: TODO\n" + " XILINX_ULTRASCALE Target: Xilinx Ultrascale Tested: TODO\n" + " ZYNQ Target: Xilinx Zynq") +elseif((FREERTOS_PORT STREQUAL "A_CUSTOM_PORT") AND (NOT TARGET freertos_kernel_port) ) + message(FATAL_ERROR " FREERTOS_PLUS_TCP_NETWORK_IF is set to A_CUSTOM_NETWORK_IF.\n" + " Please specify the custom network interface target with all necessary files.\n" + " For example, assuming a directory of:\n" + " FreeRTOSCustomNetworkInterface/\n" + " CMakeLists.txt\n" + " NetworkInterface.c\n\n" + " Where FreeRTOSCustomNetworkInterface/CMakeLists.txt is a modified version of:\n" + " add_library(freertos_plus_tcp_network_if STATIC)\n\n" + " target_sources(freertos_plus_tcp_network_if\n" + " PRIVATE\n" + " NetworkInterface.c)\n\n" + " target_include_directories(freertos_plus_tcp_network_if\n" + " PUBLIC\n" + " .)\n\n" + " taget_link_libraries(freertos_plus_tcp_network_if\n" + " PUBLIC\n" + " freertos_plus_tcp_port\n" + " freertos_plus_tcp_network_if_common\n" + " PRIVATE\n" + " freertos_kernel)") +endif() + +# There is also the need to add a target - typically an interface library that describes the +# Configuration for FreeRTOS-Kernel and FreeRTOS-Plus-TCP. +# This is called freertos_config +# If not defined will be default compile with one of the test build combinations AllEnable. + +# Select the appropriate Build Test configuration +# This is only used when freertos_config is not defined, otherwise the build test will be performed +# on the config defined in the freertos_config +set(FREERTOS_PLUS_TCP_TEST_CONFIGURATION "CUSTOM" CACHE STRING "FreeRTOS Plus TCP Build Test configuration") +set(FREERTOS_PLUS_TCP_TEST_CONFIGURATION_LIST + CUSTOM # Custom (external) configuration -eg from a top-level project + ENABLE_ALL # Enable all configuration settings + DISABLE_ALL # Disable all configuration settings + DEFAULT_CONF # Default (typical) configuration +) +if(NOT FREERTOS_PLUS_TCP_TEST_CONFIGURATION IN_LIST FREERTOS_PLUS_TCP_TEST_CONFIGURATION_LIST) + message(FATAL_ERROR "Invalid FREERTOS_PLUS_TCP_TEST_CONFIGURATION value '${FREERTOS_PLUS_TCP_TEST_CONFIGURATION}' should be one of: ${FREERTOS_PLUS_TCP_TEST_CONFIGURATION_LIST}") +else() + message(STATUS "Using FreeRTOS-Plus-TCP Test Configuration : ${FREERTOS_PLUS_TCP_TEST_CONFIGURATION}") + if (NOT FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "CUSTOM") + message(WARNING "FreeRTOS-Kernel configuration settings are configured by FreeRTOS-Plus-TCP") + endif() +endif() + +######################################################################## +# Requirements +set(CMAKE_C_STANDARD 90) # Note FreeRTOS-Kernel uses C99 constructs. +set(CMAKE_C_STANDARD_REQUIRED ON) + +######################################################################## +# Overall Compile Options +# Note the compile option strategy is to error on everything and then +# Per library opt-out of things that are warnings/errors. +# This ensures that no matter what strategy for compilation you take, the +# builds will still occur. +# +# Only tested with GNU and Clang. +# Other options are https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID +# Naming of compilers translation map: +# For the ?TBD? - Suggest trying GNU-based and adding the appropriate toolchain file. +# For Toolchain examples see _deps/cmake-src/toolchain/arm-none-eabil-gcc.toolchain.cmake +# +# FreeRTOS | CMake +# ------------------- +# CCS | ?TBD? +# GCC | GNU, Clang, *Clang Others? +# IAR | IAR +# Keil | ARMCC +# MSVC | MSVC # Note only for MinGW? +# Renesas | ?TBD? + +add_compile_options( + ### Gnu/Clang C Options + $<$:-fdiagnostics-color=always> + $<$:-fcolor-diagnostics> + + $<$:-Wall> + $<$:-Wextra> + $<$:-Wpedantic> + $<$:-Werror> + $<$:-Weverything> + + # TODO: Add in other Compilers here. +) + +######################################################################## +# External Dependencies +# Note: For backwards compatibility - still have .gitmodules defining submodules +# To support fetching content in a higher level project see +# README.md `Consume with CMake` +# This will allow you to upgrade submodules and have one common submodule for +# all your builds despite multiple submodules having different versions. +include(FetchContent) + +FetchContent_Declare( freertos_kernel + GIT_REPOSITORY https://github.com/phelter/FreeRTOS-Kernel.git #https://github.com/FreeRTOS/FreeRTOS-Kernel.git + GIT_TAG feature/fixing-clang-gnu-compiler-warnings #master +) + +FetchContent_Declare( cmock + GIT_REPOSITORY https://github.com/ThrowTheSwitch/CMock + GIT_TAG v2.5.3 +) + +add_subdirectory(source) +add_subdirectory(tools) +add_subdirectory(test) + +FetchContent_MakeAvailable(freertos_kernel cmock) + +# Note following are can be removed once FreeRTOS-Kernel v10.5.0 + fixes their issues. +# To ignore header specific issues - change all of the headers to SYSTEM +set(_freertos_kernel_targets freertos_kernel freertos_kernel_port) +# foreach (_target ${_freertos_kernel_targets} ) +# get_target_property( interface_directories ${_target} INTERFACE_INCLUDE_DIRECTORIES ) +# set_target_properties(${_target} PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${interface_directories}" ) +# endforeach() diff --git a/README.md b/README.md index f7ebd7a7f4..b38c902665 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,40 @@ Once python is downloaded and installed, you can verify the version from your te To run the script, you should switch to the FreeRTOS-Plus-TCP directory that was created using the [Cloning this repository](#cloning-this-repository) step above. And then run `python /GenerateOriginalFiles.py`. -## Cloning this repository +## To consume FreeRTOS+TCP + +### Consume with CMake +If using CMake, it is recommended to use this repository using FetchContent. +Add the following into your project's main or a subdirectory's `CMakeLists.txt`: + +- Define the source and version/tag you want to use: + +```cmake +FetchContent_Declare( freertos_plus_tcp + GIT_REPOSITORY https://github.com/FreeRTOS/FreeRTOS-Plus-TCP.git + GIT_TAG master #Note: Best practice to use specific git-hash or tagged version + GIT_SUBMODULES "" # Don't grab any submodules since not latest +) +``` + +- Configure the FreeRTOS-Kernel and make it available + - this particular example supports a native and cross-compiled build option. + +```cmake +set( FREERTOS_PLUS_FAT_DEV_SUPPORT OFF CACHE BOOL "" FORCE) +# Select the native compile PORT +set( FREERTOS_PLUS_FAT_PORT "POSIX" CACHE STRING "" FORCE) +# Select the cross-compile PORT +if (CMAKE_CROSSCOMPILING) + # Eg. Zynq 2019_3 version of port + set(FREERTOS_PLUS_FAT_PORT "ZYNQ_2019_3" CACHE STRING "" FORCE) +endif() + +FetchContent_MakeAvailable(freertos_plus_tcp) +``` + +### Consuming stand-alone + This repository uses [Git Submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) to bring in dependent components. Note: If you download the ZIP file provided by GitHub UI, you will not get the contents of the submodules. (The ZIP file is also not a valid Git repository) diff --git a/cmake_modules/FindPCAP.cmake b/cmake_modules/FindPCAP.cmake new file mode 100644 index 0000000000..4f3c7b6412 --- /dev/null +++ b/cmake_modules/FindPCAP.cmake @@ -0,0 +1,75 @@ +# - Try to find libpcap include dirs and libraries +# +# Usage of this module as follows: +# +# find_package(PCAP) +# +# Variables used by this module, they can change the default behaviour and need +# to be set before calling find_package: +# +# PCAP_ROOT_DIR Set this variable to the root installation of +# libpcap if the module has problems finding the +# proper installation path. +# +# Variables defined by this module: +# +# PCAP_FOUND System has libpcap, include and library dirs found +# PCAP_INCLUDE_DIR The libpcap include directories. +# PCAP_LIBRARY The libpcap library (possibly includes a thread +# library e.g. required by pf_ring's libpcap) +# HAVE_PF_RING If a found version of libpcap supports PF_RING + +find_path(PCAP_ROOT_DIR + NAMES include/pcap.h +) + +find_path(PCAP_INCLUDE_DIR + NAMES pcap.h + HINTS ${PCAP_ROOT_DIR}/include +) + +find_library(PCAP_LIBRARY + NAMES pcap + HINTS ${PCAP_ROOT_DIR}/lib +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PCAP DEFAULT_MSG + PCAP_LIBRARY + PCAP_INCLUDE_DIR +) + +include(CheckCSourceCompiles) +set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY}) +check_c_source_compiles("int main() { return 0; }" PCAP_LINKS_SOLO) +set(CMAKE_REQUIRED_LIBRARIES) + +# check if linking against libpcap also needs to link against a thread library +if (NOT PCAP_LINKS_SOLO) + find_package(Threads) + if (THREADS_FOUND) + set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) + check_c_source_compiles("int main() { return 0; }" PCAP_NEEDS_THREADS) + set(CMAKE_REQUIRED_LIBRARIES) + endif () + if (THREADS_FOUND AND PCAP_NEEDS_THREADS) + set(_tmp ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) + list(REMOVE_DUPLICATES _tmp) + set(PCAP_LIBRARY ${_tmp} + CACHE STRING "Libraries needed to link against libpcap" FORCE) + else () + message(FATAL_ERROR "Couldn't determine how to link against libpcap") + endif () +endif () + +include(CheckFunctionExists) +set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY}) +check_function_exists(pcap_get_pfring_id HAVE_PF_RING) +check_function_exists(pcap_dump_open_append HAVE_PCAP_DUMP_OPEN_APPEND) +set(CMAKE_REQUIRED_LIBRARIES) + +mark_as_advanced( + PCAP_ROOT_DIR + PCAP_INCLUDE_DIR + PCAP_LIBRARY +) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt new file mode 100644 index 0000000000..a990fe9478 --- /dev/null +++ b/source/CMakeLists.txt @@ -0,0 +1,93 @@ +add_library( freertos_plus_tcp STATIC ) + +target_sources( freertos_plus_tcp + PRIVATE + include/FreeRTOS_ARP.h + include/FreeRTOS_DHCP.h + include/FreeRTOS_DNS_Cache.h + include/FreeRTOS_DNS_Callback.h + include/FreeRTOS_DNS_Globals.h + include/FreeRTOS_DNS_Networking.h + include/FreeRTOS_DNS_Parser.h + include/FreeRTOS_DNS.h + include/FreeRTOS_errno_TCP.h + include/FreeRTOS_ICMP.h + include/FreeRTOS_IP_Private.h + include/FreeRTOS_IP_Timers.h + include/FreeRTOS_IP_Utils.h + include/FreeRTOS_IP.h + include/FreeRTOS_Sockets.h + include/FreeRTOS_Stream_Buffer.h + include/FreeRTOS_TCP_IP.h + include/FreeRTOS_TCP_Reception.h + include/FreeRTOS_TCP_State_Handling.h + include/FreeRTOS_TCP_Transmission.h + include/FreeRTOS_TCP_Utils.h + include/FreeRTOS_TCP_WIN.h + include/FreeRTOS_UDP_IP.h + include/FreeRTOSIPConfigDefaults.h + include/IPTraceMacroDefaults.h + include/NetworkBufferManagement.h + include/NetworkInterface.h + + FreeRTOS_ARP.c + FreeRTOS_DHCP.c + FreeRTOS_DNS_Cache.c + FreeRTOS_DNS_Callback.c + FreeRTOS_DNS_Networking.c + FreeRTOS_DNS_Parser.c + FreeRTOS_DNS.c + FreeRTOS_ICMP.c + FreeRTOS_IP_Timers.c + FreeRTOS_IP_Utils.c + FreeRTOS_IP.c + FreeRTOS_Sockets.c + FreeRTOS_Stream_Buffer.c + FreeRTOS_TCP_IP.c + FreeRTOS_TCP_Reception.c + FreeRTOS_TCP_State_Handling.c + FreeRTOS_TCP_Transmission.c + FreeRTOS_TCP_Utils.c + FreeRTOS_TCP_WIN.c + FreeRTOS_Tiny_TCP.c + FreeRTOS_UDP_IP.c +) + +# Note: Have to make system due to compiler warnings in header files. +target_include_directories( freertos_plus_tcp SYSTEM + PUBLIC + include +) + +#TODO(phelter): Investigate and fix in freertos_plus_tcp if not already fixed. +target_compile_options( freertos_plus_tcp + PRIVATE + $<$:-Wno-bad-function-cast> + $<$:-Wno-cast-qual> + $<$:-Wno-conditional-uninitialized> + $<$:-Wno-covered-switch-default> + $<$:-Wno-documentation> + $<$:-Wno-extra-semi-stmt> + $<$:-Wno-implicit-int-conversion> + $<$:-Wno-missing-noreturn> + $<$:-Wno-reserved-identifier> + $<$:-Wno-shorten-64-to-32> + $<$:-Wno-sign-conversion> + $<$:-Wno-unused-macros> + $<$:-Wno-unused-but-set-variable> + $<$:-Wno-unused-parameter> + $<$:-Wno-unused-variable> + $<$:-Wno-pedantic> +) + +target_link_libraries( freertos_plus_tcp + PUBLIC + freertos_config + freertos_plus_tcp_port # for pack_struct_start.h + PRIVATE + freertos_kernel + freertos_plus_tcp_network_if + freertos_plus_tcp_utilities +) + +add_subdirectory(portable) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 33eb2b67da..0cdebe7763 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -64,6 +64,9 @@ #ifndef ipINITIALISATION_RETRY_DELAY #define ipINITIALISATION_RETRY_DELAY ( pdMS_TO_TICKS( 3000U ) ) #endif +#if ( ipconfigUSE_TCP_MEM_STATS != 0 ) + #include "tcp_mem_stats.h" +#endif /** @brief Maximum time to wait for an ARP resolution while holding a packet. */ #ifndef ipARP_RESOLUTION_MAX_DELAY diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index ec17f4552e..a4f24f5227 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -53,6 +53,10 @@ #include "NetworkBufferManagement.h" #include "FreeRTOS_Routing.h" +#if ( ipconfigUSE_TCP_MEM_STATS != 0 ) + #include "tcp_mem_stats.h" +#endif + /* The ItemValue of the sockets xBoundSocketListItem member holds the socket's * port number. */ /** @brief Set the port number for the socket in the xBoundSocketListItem. */ diff --git a/source/portable/CMakeLists.txt b/source/portable/CMakeLists.txt new file mode 100644 index 0000000000..c3aede2013 --- /dev/null +++ b/source/portable/CMakeLists.txt @@ -0,0 +1,36 @@ +add_library( freertos_plus_tcp_port STATIC ) + +target_sources( freertos_plus_tcp_port + PRIVATE + BufferManagement/BufferAllocation_${FREERTOS_PLUS_TCP_BUFFER_ALLOCATION}.c + # TODO: There's NetworkInterface/pic32mzef that has it's own BufferAllocation_2.c +) + +target_include_directories( freertos_plus_tcp_port + PUBLIC + # Using Cmake to detect except for unknown compilers. + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/CCS> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/CCS> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/GCC> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/IAR> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/Keil> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/MSVC> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/Renesas> +) + +target_compile_options( freertos_plus_tcp_port + PRIVATE + $<$:-Wno-cast-align> + $<$:-Wno-extra-semi-stmt> + $<$:-Wno-pedantic> # Strange definition for STATIC_ASSERT +) + +target_link_libraries( freertos_plus_tcp_port + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_plus_tcp_network_if +) + +#------------------------------------------------------------------------------ +add_subdirectory(NetworkInterface) diff --git a/source/portable/NetworkInterface/ATSAM4E/CMakeLists.txt b/source/portable/NetworkInterface/ATSAM4E/CMakeLists.txt new file mode 100644 index 0000000000..22bacf3789 --- /dev/null +++ b/source/portable/NetworkInterface/ATSAM4E/CMakeLists.txt @@ -0,0 +1,26 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "ATSAM4E") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + component/gmac.h + instance/gmac.h + ethernet_phy.c + ethernet_phy.h + gmac.c + gmac.h + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/ATSAME5x/CMakeLists.txt b/source/portable/NetworkInterface/ATSAME5x/CMakeLists.txt new file mode 100644 index 0000000000..7fe7b5dd01 --- /dev/null +++ b/source/portable/NetworkInterface/ATSAME5x/CMakeLists.txt @@ -0,0 +1,20 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "ATSAME5x") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/CMakeLists.txt b/source/portable/NetworkInterface/CMakeLists.txt new file mode 100644 index 0000000000..dcf98604dd --- /dev/null +++ b/source/portable/NetworkInterface/CMakeLists.txt @@ -0,0 +1,54 @@ +add_library( freertos_plus_tcp_network_if_common STATIC ) + +target_sources( freertos_plus_tcp_network_if_common + PRIVATE + Common/phyHandling.c + include/phyHandling.h +) + +target_include_directories( freertos_plus_tcp_network_if_common + PUBLIC + include +) + +target_compile_options( freertos_plus_tcp_network_if_common + PRIVATE + $<$:-Wno-conditional-uninitialized> + $<$:-Wno-implicit-int-conversion> + $<$:-Wno-padded> + $<$:-Wno-uninitialized> + $<$:-Wno-unused-but-set-variable> + $<$:-Wno-unused-macros> +) + +target_link_libraries( freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) + +#------------------------------------------------------------------------------ +add_subdirectory(ATSAM4E) +add_subdirectory(ATSAME5x) +#add_subdirectory(board_family) - This is only an example. +add_subdirectory(DriverSAM) +add_subdirectory(esp32) +add_subdirectory(ksz8851snl) +add_subdirectory(libslirp) +add_subdirectory(linux) +add_subdirectory(LPC17xx) +add_subdirectory(LPC18xx) +add_subdirectory(LPC54018) +add_subdirectory(M487) +add_subdirectory(MPS2_AN385) +add_subdirectory(mw300_rd) +add_subdirectory(pic32mzef) +add_subdirectory(RX) +add_subdirectory(SH2A) +add_subdirectory(STM32Fxx) +add_subdirectory(STM32Hxx) +add_subdirectory(ThirdParty/MSP432) +add_subdirectory(TM4C) +add_subdirectory(WinPCap) +add_subdirectory(xilinx_ultrascale) +add_subdirectory(Zynq) diff --git a/source/portable/NetworkInterface/DriverSAM/CMakeLists.txt b/source/portable/NetworkInterface/DriverSAM/CMakeLists.txt new file mode 100644 index 0000000000..d142a9cd05 --- /dev/null +++ b/source/portable/NetworkInterface/DriverSAM/CMakeLists.txt @@ -0,0 +1,22 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "DRIVER_SAM") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + gmac_SAM.c + gmac_SAM.h + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/LPC17xx/CMakeLists.txt b/source/portable/NetworkInterface/LPC17xx/CMakeLists.txt new file mode 100644 index 0000000000..1e6ca4f1b2 --- /dev/null +++ b/source/portable/NetworkInterface/LPC17xx/CMakeLists.txt @@ -0,0 +1,28 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "LPC17xx") ) + return() +endif() + +if(NOT TARGET lpc17xx_driver) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=LPC17xx must have a target for the lpc17xx_driver") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries(freertos_plus_tcp_network_if + PRIVATE + lpc17xx_driver # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/LPC18xx/CMakeLists.txt b/source/portable/NetworkInterface/LPC18xx/CMakeLists.txt new file mode 100644 index 0000000000..480acf5725 --- /dev/null +++ b/source/portable/NetworkInterface/LPC18xx/CMakeLists.txt @@ -0,0 +1,28 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "LPC18xx") ) + return() +endif() + +if(NOT TARGET lpc17xx_driver) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=LPC18xx must have a target for the lpc18xx_driver") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries(freertos_plus_tcp_network_if + PRIVATE + lpc18xx_driver # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/LPC54018/CMakeLists.txt b/source/portable/NetworkInterface/LPC54018/CMakeLists.txt new file mode 100644 index 0000000000..6d444220ed --- /dev/null +++ b/source/portable/NetworkInterface/LPC54018/CMakeLists.txt @@ -0,0 +1,28 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "LPC54018") ) + return() +endif() + +if(NOT TARGET fsl_enet_driver) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=LPC54018 must have a target for the fsl_enet_driver") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries(freertos_plus_tcp_network_if + PRIVATE + lpc54018_driver # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/M487/CMakeLists.txt b/source/portable/NetworkInterface/M487/CMakeLists.txt new file mode 100644 index 0000000000..8400bc6bb8 --- /dev/null +++ b/source/portable/NetworkInterface/M487/CMakeLists.txt @@ -0,0 +1,22 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "M487") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + m480_eth.c + m480_eth.h + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/MPS2_AN385/CMakeLists.txt b/source/portable/NetworkInterface/MPS2_AN385/CMakeLists.txt new file mode 100644 index 0000000000..231b4aaada --- /dev/null +++ b/source/portable/NetworkInterface/MPS2_AN385/CMakeLists.txt @@ -0,0 +1,29 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "MPS2_AN385") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + ether_lan9118/SMM_MPS2.h + ether_lan9118/smsc9220_emac_config.h + ether_lan9118/smsc9220_eth_drv.c + ether_lan9118/smsc9220_eth_drv.h + NetworkInterface.c +) + +target_include_directories( freertos_plus_tcp_network_if + PRIVATE + ether_lan9118 +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/RX/CMakeLists.txt b/source/portable/NetworkInterface/RX/CMakeLists.txt new file mode 100644 index 0000000000..9fed7027f0 --- /dev/null +++ b/source/portable/NetworkInterface/RX/CMakeLists.txt @@ -0,0 +1,22 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "RX") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +# TODO What about BufferAllocation_2.c here? +target_sources( freertos_plus_tcp_network_if + PRIVATE + ether_callback.c + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/SH2A/CMakeLists.txt b/source/portable/NetworkInterface/SH2A/CMakeLists.txt new file mode 100644 index 0000000000..54f704c0de --- /dev/null +++ b/source/portable/NetworkInterface/SH2A/CMakeLists.txt @@ -0,0 +1,25 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "SH2A") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +# target_link_libraries( freertos_plus_tcp_network_if +# PRIVATE +# hwEthernetLib # Todo where is hwEthernet.h? +# ) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/STM32Fxx/CMakeLists.txt b/source/portable/NetworkInterface/STM32Fxx/CMakeLists.txt new file mode 100644 index 0000000000..cfe8f1c1f1 --- /dev/null +++ b/source/portable/NetworkInterface/STM32Fxx/CMakeLists.txt @@ -0,0 +1,25 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "STM32FXX") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + # stm32f2xx_hal_eth.h + # stm32f4xx_hal_eth.h + stm32f7xx_hal_eth.h #TODO: Only one of these ? + stm32fxx_hal_eth.c + stm32fxx_hal_eth.h +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/STM32Hxx/CMakeLists.txt b/source/portable/NetworkInterface/STM32Hxx/CMakeLists.txt new file mode 100644 index 0000000000..016f1b927c --- /dev/null +++ b/source/portable/NetworkInterface/STM32Hxx/CMakeLists.txt @@ -0,0 +1,23 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "STM32HXX") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + stm32h7xx_hal_eth.h + stm32hxx_hal_eth.c + stm32hxx_hal_eth.h +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/TM4C/CMakeLists.txt b/source/portable/NetworkInterface/TM4C/CMakeLists.txt new file mode 100644 index 0000000000..b019e71a4c --- /dev/null +++ b/source/portable/NetworkInterface/TM4C/CMakeLists.txt @@ -0,0 +1,20 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "TM4C") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/ThirdParty/MSP432/CMakeLists.txt b/source/portable/NetworkInterface/ThirdParty/MSP432/CMakeLists.txt new file mode 100644 index 0000000000..fdbcc425b2 --- /dev/null +++ b/source/portable/NetworkInterface/ThirdParty/MSP432/CMakeLists.txt @@ -0,0 +1,23 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "MSP432") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + NetworkInterface.h + NetworkMiddleware.c + NetworkMiddleware.h +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/WinPCap/CMakeLists.txt b/source/portable/NetworkInterface/WinPCap/CMakeLists.txt new file mode 100644 index 0000000000..eb5f37573a --- /dev/null +++ b/source/portable/NetworkInterface/WinPCap/CMakeLists.txt @@ -0,0 +1,25 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "WIN_PCAP") ) ) + return() +endif() + +find_package(PCAP REQUIRED) + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + FaultInjection.c + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp + ${PCAP_LIBRARY} +) + diff --git a/source/portable/NetworkInterface/Zynq/CMakeLists.txt b/source/portable/NetworkInterface/Zynq/CMakeLists.txt new file mode 100644 index 0000000000..2f27c5125e --- /dev/null +++ b/source/portable/NetworkInterface/Zynq/CMakeLists.txt @@ -0,0 +1,73 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "ZYNQ") ) + return() +endif() + +if(NOT TARGET xil_bsp) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=ZYNQ must have a target for the xil_bsp") +endif() + +# ZYNQ port shares uncached_memory.c and .h with FreeRTOS-Plus-FAT. +# Separating out so it can potentially be included there as well. +#------------------------------------------------------------------------------ +add_library(freertos_xil_uncached_memory STATIC) + +target_sources(freertos_xil_uncached_memory + PRIVATE + uncached_memory.c + uncached_memory.h +) + +target_include_directories(freertos_xil_uncached_memory + PUBLIC + . + PRIVATE + .. +) + +target_link_libraries(freertos_xil_uncached_memory + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_plus_tcp_network_if + xil_bsp +) + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) +set_property(TARGET freertos_plus_tcp_network_if PROPERTY C_STANDARD 99) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + x_emacpsif_dma.c + x_emacpsif_hw.c + x_emacpsif_hw.h + x_emacpsif_physpeed.c + x_emacpsif.h + x_topology.h +) + +target_include_directories( freertos_plus_tcp_network_if + PRIVATE + .. +) + +target_compile_options( freertos_plus_tcp_network_if + PRIVATE + $<$:-Wno-cast-align> + $<$:-Wno-declaration-after-statement> + $<$:-Wno-padded> + $<$:-Wno-pedantic> + $<$:-Wno-unused-parameter> +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_xil_uncached_memory + xil_bsp +) diff --git a/source/portable/NetworkInterface/board_family/CMakeLists.txt b/source/portable/NetworkInterface/board_family/CMakeLists.txt new file mode 100644 index 0000000000..03f46e4051 --- /dev/null +++ b/source/portable/NetworkInterface/board_family/CMakeLists.txt @@ -0,0 +1,20 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/esp32/CMakeLists.txt b/source/portable/NetworkInterface/esp32/CMakeLists.txt new file mode 100644 index 0000000000..899f711cca --- /dev/null +++ b/source/portable/NetworkInterface/esp32/CMakeLists.txt @@ -0,0 +1,28 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "ESP32") ) + return() +endif() + +if(NOT TARGET esp32_lib) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=ESP32 must have a target for the esp32_lib") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PRIVATE + esp32_lib # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/ksz8851snl/CMakeLists.txt b/source/portable/NetworkInterface/ksz8851snl/CMakeLists.txt new file mode 100644 index 0000000000..0ab28dfa81 --- /dev/null +++ b/source/portable/NetworkInterface/ksz8851snl/CMakeLists.txt @@ -0,0 +1,23 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "KSZ8851SNL") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + ksz8851snl_reg.h + ksz8851snl.c + ksz8851snl.h + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/libslirp/CMakeLists.txt b/source/portable/NetworkInterface/libslirp/CMakeLists.txt new file mode 100644 index 0000000000..3c4a94dbf6 --- /dev/null +++ b/source/portable/NetworkInterface/libslirp/CMakeLists.txt @@ -0,0 +1,29 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "LIBSLIRP") ) + return() +endif() + +if(NOT TARGET slirp) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=LIBSLIRP must have a target for the slirp") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + MBuffNetifBackendLibslirp.c + MBuffNetworkInterface.c +) + +target_link_libraries(freertos_plus_tcp_network_if + PRIVATE + slirp # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/linux/CMakeLists.txt b/source/portable/NetworkInterface/linux/CMakeLists.txt new file mode 100644 index 0000000000..0b2e44cbd6 --- /dev/null +++ b/source/portable/NetworkInterface/linux/CMakeLists.txt @@ -0,0 +1,39 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "POSIX") ) + return() +endif() + +find_package(PCAP REQUIRED) +set(THREADS_PREFER_PTHREAD_FLAG TRUE) +find_package(Threads) + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_compile_options( freertos_plus_tcp_network_if + PRIVATE + $<$:-Wno-cast-align> + $<$:-Wno-declaration-after-statement> + $<$:-Wno-documentation> + $<$:-Wno-missing-noreturn> + $<$:-Wno-padded> + $<$:-Wno-shorten-64-to-32> + $<$:-Wno-undef> + $<$:-Wno-unused-macros> + $<$:-Wno-unused-parameter> +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp + ${PCAP_LIBRARY} + Threads::Threads +) diff --git a/source/portable/NetworkInterface/linux/NetworkInterface.c b/source/portable/NetworkInterface/linux/NetworkInterface.c index 4fe801293c..3921809e56 100644 --- a/source/portable/NetworkInterface/linux/NetworkInterface.c +++ b/source/portable/NetworkInterface/linux/NetworkInterface.c @@ -784,14 +784,14 @@ static void * prvLinuxPcapRecvThread( void * pvParam ) { int ret; - ( void ) pvParam; - /* Disable signals to this thread since this is a Linux pthread to be able to * printf and other blocking operations without being interrupted and put in * suspension mode by the linux port signals */ sigset_t set; + ( void ) pvParam; + sigfillset( &set ); pthread_sigmask( SIG_SETMASK, &set, NULL ); @@ -823,12 +823,12 @@ static void * prvLinuxPcapSendThread( void * pvParam ) uint8_t ucBuffer[ ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER ]; const time_t xMaxMSToWait = 1000; - ( void ) pvParam; - /* disable signals to avoid treating this thread as a FreeRTOS task and putting * it to sleep by the scheduler */ sigset_t set; + ( void ) pvParam; + sigfillset( &set ); pthread_sigmask( SIG_SETMASK, &set, NULL ); diff --git a/source/portable/NetworkInterface/mw300_rd/CMakeLists.txt b/source/portable/NetworkInterface/mw300_rd/CMakeLists.txt new file mode 100644 index 0000000000..974008c93e --- /dev/null +++ b/source/portable/NetworkInterface/mw300_rd/CMakeLists.txt @@ -0,0 +1,20 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "MW300_RD") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/pic32mzef/CMakeLists.txt b/source/portable/NetworkInterface/pic32mzef/CMakeLists.txt new file mode 100644 index 0000000000..31f5ff6ea3 --- /dev/null +++ b/source/portable/NetworkInterface/pic32mzef/CMakeLists.txt @@ -0,0 +1,23 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "PIC32MZEF_ETH") OR + (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "PIC32MZEF_WIFI") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +# TODO What about BufferAllocation_2.c here? +target_sources( freertos_plus_tcp_network_if + PRIVATE + $<$:NetworkInterface_eth.c> + $<$:NetworkInterface_wifi.c> +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/CMakeLists.txt b/source/portable/NetworkInterface/xilinx_ultrascale/CMakeLists.txt new file mode 100644 index 0000000000..674a1dc506 --- /dev/null +++ b/source/portable/NetworkInterface/xilinx_ultrascale/CMakeLists.txt @@ -0,0 +1,70 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "XILINX_ULTRASCALE") ) + return() +endif() + +if(NOT TARGET xil_bsp) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=XILINX_ULTRASCALE must have a target for the xil_bsp") +endif() + +# XILINX_ULTRASCALE port shares uncached_memory.c and .h with FreeRTOS-Plus-FAT. +# Separating out so it can potentially be included there as well. +#------------------------------------------------------------------------------ +add_library(freertos_xil_uncached_memory STATIC) + +target_sources(freertos_xil_uncached_memory + PRIVATE + uncached_memory.c + uncached_memory.h +) + +target_include_directories(freertos_xil_uncached_memory + PUBLIC + . + PRIVATE + .. +) + +target_link_libraries(freertos_xil_uncached_memory + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_plus_tcp_network_if + xil_bsp +) + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + x_emacpsif_dma.c + x_emacpsif_hw.c + x_emacpsif_hw.h + x_emacpsif_physpeed.c + x_emacpsif.h + x_topology.h +) + +target_include_directories( freertos_plus_tcp_network_if + PRIVATE + .. +) + +target_compile_options( freertos_plus_tcp_network_if + PRIVATE + $<$:-Wno-cast-align> + $<$:-Wno-declaration-after-statement> + $<$:-Wno-padded> +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_xil_uncached_memory + xil_bsp +) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000000..97d4459107 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,8 @@ +add_subdirectory(build-combination) + +if(FREERTOS_PLUS_TCP_BUILD_TEST) + add_subdirectory(cbmc) + add_subdirectory(Coverity) + add_subdirectory(unit-test) +endif() + diff --git a/test/build-combination/CMakeLists.txt b/test/build-combination/CMakeLists.txt index c695073309..9c77788cb3 100644 --- a/test/build-combination/CMakeLists.txt +++ b/test/build-combination/CMakeLists.txt @@ -1,89 +1,61 @@ -cmake_minimum_required ( VERSION 3.13.0 ) -project ( "FreeRTOS-Plus-TCP Build Combination" - VERSION 1.0.0 - LANGUAGES C ) - -# Allow the project to be organized into folders. -set_property( GLOBAL PROPERTY USE_FOLDERS ON ) - -# Use C90. -set( CMAKE_C_STANDARD 90 ) -set( CMAKE_C_STANDARD_REQUIRED ON ) - -# Do not allow in-source build. -if( ${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR} ) - message( FATAL_ERROR "In-source build is not allowed. Please build in a separate directory, such as ${PROJECT_SOURCE_DIR}/build." ) -endif() - -# Set global path variables. -get_filename_component(__MODULE_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE) -set(MODULE_ROOT_DIR ${__MODULE_ROOT_DIR} CACHE INTERNAL "FreeRTOS-Plus-TCP repository root.") - -# Configure options to always show in CMake GUI. -option( BUILD_CLONE_SUBMODULES - "Set this to ON to automatically clone any required Git submodules. When OFF, submodules must be manually cloned." - ON ) - - -option(TEST_CONFIGURATION "Configuration All Enable/Disable or default" ENABLE_ALL) - -message( STATUS "Argument: ${TEST_CONFIGURATION}") - -# Set output directories. -set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) -set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) - - -set( FREERTOS_KERNEL_DIR ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel ) -set( TEST_DIR ${MODULE_ROOT_DIR}/test/build-combination ) - -include_directories( ${MODULE_ROOT_DIR}/source/include ) -include_directories( ${MODULE_ROOT_DIR}/source/portable/Compiler/MSVC ) -include_directories( ${FREERTOS_KERNEL_DIR}/include ) -# Add the correct portable directory to include search paths. -if (WIN32) - include_directories( ${FREERTOS_KERNEL_DIR}/portable/MSVC-MingW ) -else() - include_directories( ${FREERTOS_KERNEL_DIR}/portable/ThirdParty/GCC/Posix ) -endif() -include_directories( ${TEST_DIR}/Common ) - -if( ${TEST_CONFIGURATION} STREQUAL "ENABLE_ALL" ) - include_directories( ${TEST_DIR}/AllEnable ) -elseif( ${TEST_CONFIGURATION} STREQUAL "DISABLE_ALL" ) - include_directories( ${TEST_DIR}/AllDisable ) -else() - include_directories( ${TEST_DIR}/DefaultConf ) -endif() - -# Pick the correct kernel port files for the platform. -if (WIN32) - file(GLOB KERNEL_SOURCES "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/*.c" - "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/MSVC-MingW/*.c") +add_library( freertos_plus_tcp_config_common INTERFACE ) +target_include_directories(freertos_plus_tcp_config_common INTERFACE Common ) + +# ------------------------------------------------------------------- +add_library( freertos_plus_tcp_config_all_disable INTERFACE) +target_include_directories(freertos_plus_tcp_config_all_disable INTERFACE AllDisable) +target_link_libraries(freertos_plus_tcp_config_all_disable INTERFACE freertos_plus_tcp_config_common) + +# ------------------------------------------------------------------- +add_library( freertos_plus_tcp_config_all_enable INTERFACE) +target_include_directories(freertos_plus_tcp_config_all_enable INTERFACE AllEnable) +target_link_libraries(freertos_plus_tcp_config_all_enable INTERFACE freertos_plus_tcp_config_common) + +# ------------------------------------------------------------------- +add_library( freertos_plus_tcp_config_default INTERFACE) +target_include_directories(freertos_plus_tcp_config_default INTERFACE DefaultConf) +target_link_libraries(freertos_plus_tcp_config_default INTERFACE freertos_plus_tcp_config_common) + +# ------------------------------------------------------------------- +# Configuration for FreeRTOS-Kernel +if(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "CUSTOM" ) + # Check Config target is available. And then do nothing. + if(NOT TARGET freertos_config ) + message(FATAL_ERROR "FREERTOS_PLUS_TCP_TEST_CONFIGURATION = CUSTOM, but no freertos_config target defined.") + endif() +elseif(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "DISABLE_ALL" ) + add_library( freertos_config ALIAS freertos_plus_tcp_config_all_disable) +elseif(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "ENABLE_ALL" ) + add_library( freertos_config ALIAS freertos_plus_tcp_config_all_enable) else() - file(GLOB KERNEL_SOURCES "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/*.c" - "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/ThirdParty/GCC/Posix/*.c" - "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/ThirdParty/GCC/Posix/utils/*.c") + add_library( freertos_config ALIAS freertos_plus_tcp_config_default) endif() -file(GLOB TCP_SOURCES "${MODULE_ROOT_DIR}/source/*.c" ) - -message(STATUS "${KERNEL_SOURCES}") -message(STATUS "${TCP_SOURCES}") - -add_executable(project ${KERNEL_SOURCES} - ${TCP_SOURCES} - ${FREERTOS_KERNEL_DIR}/portable/MemMang/heap_4.c - ${MODULE_ROOT_DIR}/source/portable/BufferManagement/BufferAllocation_2.c - ${TEST_DIR}/Common/main.c ) - -if (WIN32) - # Add preprocessor definitions to suppress warnings. - target_compile_definitions( project PRIVATE - _CRT_SECURE_NO_WARNINGS ) -else() - # Link pthread which is needed for POSIX port. - find_package( Threads REQUIRED ) - target_link_libraries( project Threads::Threads ) -endif() +add_executable(freertos_plus_tcp_build_test EXCLUDE_FROM_ALL) + +target_sources(freertos_plus_tcp_build_test + PRIVATE + Common/main.c +) + +target_compile_options(freertos_plus_tcp_build_test + PRIVATE + $<$:-Wno-cast-qual> + $<$:-Wno-format-nonliteral> + $<$:-Wno-implicit-function-declaration> + $<$:-Wno-missing-noreturn> + $<$:-Wno-missing-prototypes> + $<$:-Wno-missing-variable-declarations> + $<$:-Wno-reserved-identifier> + $<$:-Wno-shorten-64-to-32> + $<$:-Wno-sign-conversion> + $<$:-Wno-unused-parameter> + $<$:-Wno-unused-macros> + $<$:-Wno-unused-variable> +) + +target_link_libraries(freertos_plus_tcp_build_test + PRIVATE + freertos_plus_tcp + freertos_kernel +) diff --git a/test/build-combination/Common/FreeRTOSConfig.h b/test/build-combination/Common/FreeRTOSConfig.h index 7d5de97dc4..a7f7d86bad 100644 --- a/test/build-combination/Common/FreeRTOSConfig.h +++ b/test/build-combination/Common/FreeRTOSConfig.h @@ -114,18 +114,11 @@ * functions. */ #define configUSE_STATS_FORMATTING_FUNCTIONS 1 -/* Assert call defined for debug builds. */ -void vAssertCalled( const char * pcFile, - uint32_t ulLine ); - -#define configASSERT( x ) - /* The function that implements FreeRTOS printf style output, and the macro * that maps the configPRINTF() macros to that function. */ #define configPRINTF( X ) /* Non-format version thread-safe print. */ -extern void vLoggingPrint( const char * pcMessage ); #define configPRINT( X ) /* Non-format version thread-safe print. */ @@ -219,7 +212,7 @@ extern void vLoggingPrint( const char * pcMessage ); #define configPROFILING ( 0 ) /* Pseudo random number generator used by some tasks. */ -extern uint32_t ulRand(); +extern uint32_t ulRand( void ); #define configRAND32() ulRand() /* The platform that FreeRTOS is running on. */ diff --git a/test/build-combination/Common/main.c b/test/build-combination/Common/main.c index b6f7a31216..488a955666 100644 --- a/test/build-combination/Common/main.c +++ b/test/build-combination/Common/main.c @@ -39,8 +39,17 @@ #include "FreeRTOS_Sockets.h" #include "FreeRTOS_DHCP.h" -#define mainHOST_NAME "Build Combination" +#include +#include +#define mainHOST_NAME "Build Combination" +#define mainDEVICE_NICK_NAME "Build_Combination" + +#if defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) + #define local_stricmp _stricmp +#else + #define local_stricmp strcasecmp +#endif /*-----------------------------------------------------------*/ /* Notes if the trace is running or not. */ @@ -168,11 +177,11 @@ int main( void ) /* Determine if a name lookup is for this node. Two names are given * to this node: that returned by pcApplicationHostnameHook() and that set * by mainDEVICE_NICK_NAME. */ - if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 ) + if( local_stricmp( pcName, pcApplicationHostnameHook() ) == 0 ) { xReturn = pdPASS; } - else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 ) + else if( local_stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 ) { xReturn = pdPASS; } @@ -201,9 +210,8 @@ void vApplicationIdleHook( void ) /* Exit. Just a stub. */ } /*-----------------------------------------------------------*/ - void vAssertCalled( const char * pcFile, - uint32_t ulLine ) + unsigned long ulLine ) { const uint32_t ulLongSleep = 1000UL; volatile uint32_t ulBlockVariable = 0UL; @@ -223,6 +231,17 @@ void vAssertCalled( const char * pcFile, } /*-----------------------------------------------------------*/ +void vLoggingPrintf( const char * pcFormat, + ... ) +{ + va_list arg; + + va_start( arg, pcFormat ); + vprintf( pcFormat, arg ); + va_end( arg ); +} +/*-----------------------------------------------------------*/ + void getUserCmd( char * pucUserCmd ) { /* Provide a stub for this function. */ @@ -246,6 +265,8 @@ BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber ) return pdTRUE; } +/*-----------------------------------------------------------*/ + void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t * pulIdleTaskStackSize ) @@ -253,6 +274,19 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, /* Provide a stub for this function. */ } +/*-----------------------------------------------------------*/ + +void vApplicationTickHook( void ) +{ + /* Provide a stub for this function. */ +} + +/*-----------------------------------------------------------*/ + +void vApplicationDaemonTaskStartupHook( void ) +{ + /* Provide a stub for this function. */ +} /* * Callback that provides the inputs necessary to generate a randomized TCP diff --git a/test/build-combination/DefaultConf/FreeRTOSIPConfig.h b/test/build-combination/DefaultConf/FreeRTOSIPConfig.h index c908f0fcd3..313c401e6e 100644 --- a/test/build-combination/DefaultConf/FreeRTOSIPConfig.h +++ b/test/build-combination/DefaultConf/FreeRTOSIPConfig.h @@ -38,6 +38,10 @@ /* It is not sensible for this macro to have a default value as it is hardware * dependent. */ -#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN +#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN -#endif +/* The windows simulator cannot really simulate MAC interrupts, and needs to + * block occasionally to allow other tasks to run. */ +#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS ) + +#endif /* ifndef FREERTOS_IP_CONFIG_H */ diff --git a/test/build-combination/README.md b/test/build-combination/README.md index 0bbcba87d3..8d7aca4957 100644 --- a/test/build-combination/README.md +++ b/test/build-combination/README.md @@ -9,20 +9,20 @@ All the CMake commands are to be run from the root of the repository. * Build checks (Enable all functionalities) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=ENABLE_ALL -make -C test/build-combination/build/ +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL +cmake --build build --target freertos_plus_tcp_build_test ``` * Build checks (Disable all functionalities) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=DISABLE_ALL -make -C test/build-combination/build/ +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=DISABLE_ALL +cmake --build build --target freertos_plus_tcp_build_test ``` * Build checks (Default configuration) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=DEFAULT_CONF -make -C test/build-combination/build/ +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=DEFAULT_CONF +cmake --build build --target freertos_plus_tcp_build_test ``` ## Windows @@ -31,21 +31,21 @@ All the CMake commands are to be run from the root of the repository. * Build checks (Enable all functionalities) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 ``` Open the generated Visual Studio Solution file `test\build-combination\build\FreeRTOS-Plus-TCP Build Combination.sln` in Visual Studio and click `Build --> Build Solution`. * Build checks (Disable all functionalities) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 ``` Open the generated Visual Studio Solution file `test\build-combination\build\FreeRTOS-Plus-TCP Build Combination.sln` in Visual Studio and click `Build --> Build Solution`. * Build checks (Default configuration) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 ``` Open the generated Visual Studio Solution file `test\build-combination\build\FreeRTOS-Plus-TCP Build Combination.sln` in Visual Studio and click `Build --> Build Solution`. diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 0000000000..dfbbdc5b8a --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1,37 @@ +add_library( freertos_plus_tcp_utilities STATIC ) + +target_sources( freertos_plus_tcp_utilities + PRIVATE + tcp_utilities/include/tcp_dump_packets.h + tcp_utilities/include/tcp_mem_stats.h + tcp_utilities/include/tcp_netstat.h + + tcp_utilities/tcp_dump_packets.c + tcp_utilities/tcp_mem_stats.c + tcp_utilities/tcp_netstat.c +) + +# Note: Have to make system due to compiler warnings in header files. +target_include_directories( freertos_plus_tcp_utilities SYSTEM + PUBLIC + tcp_utilities/include +) + +#TODO(phelter): Investigate and fix in freertos_plus_tcp if not already fixed. +target_compile_options( freertos_plus_tcp_utilities + PRIVATE + $<$:-Wno-extra-semi-stmt> + $<$:-Wno-format> + $<$:-Wno-missing-variable-declarations> + $<$:-Wno-padded> + $<$:-Wno-unused-but-set-variable> + $<$:-Wno-unused-function> + $<$:-Wno-unused-macros> + $<$:-Wno-unused-variable> +) + +target_link_libraries( freertos_plus_tcp_utilities + PRIVATE + freertos_kernel + freertos_plus_tcp +) From 5bf02aa72ddaf142505d62d3d0101f7fa171068b Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Thu, 16 Mar 2023 16:07:52 +0530 Subject: [PATCH 02/28] renaming variables that have conflicting names with MSC and *nix headers --- source/FreeRTOS_IPv6.c | 4 ++-- source/FreeRTOS_Routing.c | 2 +- source/include/FreeRTOS_IPv6.h | 16 ++-------------- tools/tcp_utilities/NTPDemo.c | 2 +- tools/tcp_utilities/plus_tcp_demo_cli.c | 2 +- 5 files changed, 7 insertions(+), 19 deletions(-) diff --git a/source/FreeRTOS_IPv6.c b/source/FreeRTOS_IPv6.c index 4ea2dc607d..8ddf0315fc 100644 --- a/source/FreeRTOS_IPv6.c +++ b/source/FreeRTOS_IPv6.c @@ -48,12 +48,12 @@ /** * This variable is initialized by the system to contain the wildcard IPv6 address. */ -const struct xIPv6_Address in6addr_any = { 0 }; +const struct xIPv6_Address FreeRTOS_in6addr_any = { 0 }; /** * This variable is initialized by the system to contain the loopback IPv6 address. */ -const struct xIPv6_Address in6addr_loopback = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 } }; +const struct xIPv6_Address FreeRTOS_in6addr_loopback = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 } }; /** * @brief Check whether this IPv6 address is a multicast address or not. diff --git a/source/FreeRTOS_Routing.c b/source/FreeRTOS_Routing.c index 51bab8b4bf..30eab5ec18 100644 --- a/source/FreeRTOS_Routing.c +++ b/source/FreeRTOS_Routing.c @@ -960,7 +960,7 @@ void FreeRTOS_FillEndPoint( NetworkInterface_t * pxNetworkInterface, if( ( xIPType == ( BaseType_t ) ipTYPE_IPv6 ) && ( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED ) ) { /* Check if the IP-address is non-zero. */ - if( memcmp( in6addr_any.ucBytes, pxEndPoint->ipv6_settings.xGatewayAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ) != 0 ) + if( memcmp( FreeRTOS_in6addr_any.ucBytes, pxEndPoint->ipv6_settings.xGatewayAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ) != 0 ) { break; } diff --git a/source/include/FreeRTOS_IPv6.h b/source/include/FreeRTOS_IPv6.h index 11bd8ac373..7d5bb55286 100644 --- a/source/include/FreeRTOS_IPv6.h +++ b/source/include/FreeRTOS_IPv6.h @@ -70,20 +70,8 @@ /* Destination options may follow here in case there are no routing options. */ #define ipIPv6_EXT_HEADER_MOBILITY_HEADER 135U -#ifndef _MSC_VER - extern const struct xIPv6_Address in6addr_any; - extern const struct xIPv6_Address in6addr_loopback; -#else - -/* Microsoft visual C already has these objects defined. - * Name them slightly different. */ - extern const struct xIPv6_Address FreeRTOS_in6addr_any; - extern const struct xIPv6_Address FreeRTOS_in6addr_loopback; - #define in6addr_any FreeRTOS_in6addr_any - #define in6addr_loopback FreeRTOS_in6addr_loopback - -#endif - +extern const struct xIPv6_Address FreeRTOS_in6addr_any; +extern const struct xIPv6_Address FreeRTOS_in6addr_loopback; /* IPv6 multicast MAC address starts with 33-33-. */ #define ipMULTICAST_MAC_ADDRESS_IPv6_0 0x33U diff --git a/tools/tcp_utilities/NTPDemo.c b/tools/tcp_utilities/NTPDemo.c index 6c6174764c..a6695af5af 100644 --- a/tools/tcp_utilities/NTPDemo.c +++ b/tools/tcp_utilities/NTPDemo.c @@ -613,7 +613,7 @@ static void prvNTPTask( void * pvParameters ) prvNTPPacketInit(); uxSendTime = xTaskGetTickCount(); #if ( ipconfigUSE_IPv6 != 0 ) - if( memcmp( xIPAddressFound.sin_addr6.ucBytes, in6addr_any.ucBytes, ipSIZE_OF_IPv6_ADDRESS ) != 0 ) + if( memcmp( xIPAddressFound.sin_addr6.ucBytes, FreeRTOS_in6addr_any.ucBytes, ipSIZE_OF_IPv6_ADDRESS ) != 0 ) { FreeRTOS_printf( ( "Sending UDP message to %pip port %u\n", xIPAddressFound.sin_addr6.ucBytes, diff --git a/tools/tcp_utilities/plus_tcp_demo_cli.c b/tools/tcp_utilities/plus_tcp_demo_cli.c index 3e19e93b4f..baf57faeb7 100644 --- a/tools/tcp_utilities/plus_tcp_demo_cli.c +++ b/tools/tcp_utilities/plus_tcp_demo_cli.c @@ -907,7 +907,7 @@ static void handle_help( char * pcBuffer ) #if ( ipconfigUSE_IPv6 != 0 ) if( pxEndPoint->bits.bIPv6 ) { - if( memcmp( pxEndPoint->ipv6_settings.xGatewayAddress.ucBytes, in6addr_any.ucBytes, ipSIZE_OF_IPv6_ADDRESS ) != 0 ) + if( memcmp( pxEndPoint->ipv6_settings.xGatewayAddress.ucBytes, FreeRTOS_in6addr_any.ucBytes, ipSIZE_OF_IPv6_ADDRESS ) != 0 ) { FreeRTOS_printf( ( "IPv6: %pip on '%s'\n", pxEndPoint->ipv6_settings.xGatewayAddress.ucBytes, pxEndPoint->pxNetworkInterface->pcName ) ); } From 6ae951951c323808b72fd6f0c7f7dd04fd35adaa Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 17 Mar 2023 10:07:34 +0530 Subject: [PATCH 03/28] fix build issue for posix port --- CMakeLists.txt | 2 +- source/CMakeLists.txt | 46 ++++++++++++++++--- source/include/FreeRTOS_Sockets.h | 3 ++ .../NetworkInterface/linux/CMakeLists.txt | 5 ++ 4 files changed, 49 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 71d0b56d0b..1ef2be7a88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,7 +196,7 @@ add_compile_options( $<$:-Wall> $<$:-Wextra> $<$:-Wpedantic> - $<$:-Werror> + ##$<$:-Werror> $<$:-Weverything> # TODO: Add in other Compilers here. diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index a990fe9478..5e096d5f85 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -2,20 +2,33 @@ add_library( freertos_plus_tcp STATIC ) target_sources( freertos_plus_tcp PRIVATE + include/FreeRTOSIPConfigDefaults.h include/FreeRTOS_ARP.h + include/FreeRTOS_BitConfig.h include/FreeRTOS_DHCP.h + include/FreeRTOS_DHCPv6.h + include/FreeRTOS_DNS.h include/FreeRTOS_DNS_Cache.h include/FreeRTOS_DNS_Callback.h include/FreeRTOS_DNS_Globals.h include/FreeRTOS_DNS_Networking.h include/FreeRTOS_DNS_Parser.h - include/FreeRTOS_DNS.h - include/FreeRTOS_errno_TCP.h include/FreeRTOS_ICMP.h + include/FreeRTOS_IP.h + include/FreeRTOS_IP_Common.h include/FreeRTOS_IP_Private.h include/FreeRTOS_IP_Timers.h include/FreeRTOS_IP_Utils.h - include/FreeRTOS_IP.h + include/FreeRTOS_IPv4.h + include/FreeRTOS_IPv4_Private.h + include/FreeRTOS_IPv4_Sockets.h + include/FreeRTOS_IPv4_Utils.h + include/FreeRTOS_IPv6.h + include/FreeRTOS_IPv6_Private.h + include/FreeRTOS_IPv6_Sockets.h + include/FreeRTOS_IPv6_Utils.h + include/FreeRTOS_ND.h + include/FreeRTOS_Routing.h include/FreeRTOS_Sockets.h include/FreeRTOS_Stream_Buffer.h include/FreeRTOS_TCP_IP.h @@ -25,32 +38,53 @@ target_sources( freertos_plus_tcp include/FreeRTOS_TCP_Utils.h include/FreeRTOS_TCP_WIN.h include/FreeRTOS_UDP_IP.h - include/FreeRTOSIPConfigDefaults.h + include/FreeRTOS_errno_TCP.h include/IPTraceMacroDefaults.h include/NetworkBufferManagement.h include/NetworkInterface.h FreeRTOS_ARP.c + FreeRTOS_BitConfig.c FreeRTOS_DHCP.c + FreeRTOS_DHCPv6.c + FreeRTOS_DNS.c FreeRTOS_DNS_Cache.c FreeRTOS_DNS_Callback.c FreeRTOS_DNS_Networking.c FreeRTOS_DNS_Parser.c - FreeRTOS_DNS.c FreeRTOS_ICMP.c + FreeRTOS_IP.c FreeRTOS_IP_Timers.c FreeRTOS_IP_Utils.c - FreeRTOS_IP.c + FreeRTOS_IPv4.c + FreeRTOS_IPv4_Sockets.c + FreeRTOS_IPv4_Utils.c + FreeRTOS_IPv6.c + FreeRTOS_IPv6_Sockets.c + FreeRTOS_IPv6_Utils.c + FreeRTOS_ND.c + FreeRTOS_RA.c + FreeRTOS_Routing.c FreeRTOS_Sockets.c FreeRTOS_Stream_Buffer.c FreeRTOS_TCP_IP.c + FreeRTOS_TCP_IP_IPV4.c + FreeRTOS_TCP_IP_IPV6.c FreeRTOS_TCP_Reception.c FreeRTOS_TCP_State_Handling.c + FreeRTOS_TCP_State_Handling_IPV4.c + FreeRTOS_TCP_State_Handling_IPV6.c FreeRTOS_TCP_Transmission.c + FreeRTOS_TCP_Transmission_IPV4.c + FreeRTOS_TCP_Transmission_IPV6.c FreeRTOS_TCP_Utils.c + FreeRTOS_TCP_Utils_IPV4.c + FreeRTOS_TCP_Utils_IPV6.c FreeRTOS_TCP_WIN.c FreeRTOS_Tiny_TCP.c FreeRTOS_UDP_IP.c + FreeRTOS_UDP_IPv4.c + FreeRTOS_UDP_IPv6.c ) # Note: Have to make system due to compiler warnings in header files. diff --git a/source/include/FreeRTOS_Sockets.h b/source/include/FreeRTOS_Sockets.h index 7bcada9960..a0d6f459a5 100644 --- a/source/include/FreeRTOS_Sockets.h +++ b/source/include/FreeRTOS_Sockets.h @@ -179,7 +179,10 @@ uint32_t sin_flowinfo; /**< IPv6 flow information, not used in this library. */ IP_Address_t sin_address; /**< The IPv4/IPv6 address. */ }; + +#ifndef sin_addr #define sin_addr sin_address.ulIP_IPv4 +#endif #define sin_addr4 sin_address.ulIP_IPv4 #define sin_addr6 sin_address.xIP_IPv6 #define sin_addrv4 sin_address.ulIP_IPv4 diff --git a/source/portable/NetworkInterface/linux/CMakeLists.txt b/source/portable/NetworkInterface/linux/CMakeLists.txt index 0b2e44cbd6..5c5180a3f5 100644 --- a/source/portable/NetworkInterface/linux/CMakeLists.txt +++ b/source/portable/NetworkInterface/linux/CMakeLists.txt @@ -27,6 +27,11 @@ target_compile_options( freertos_plus_tcp_network_if $<$:-Wno-unused-parameter> ) +target_compile_definitions( freertos_plus_tcp_network_if + PRIVATE + "sin_addr=sin_addr" +) + target_link_libraries( freertos_plus_tcp_network_if PUBLIC freertos_plus_tcp_port From 21018cc63775b82bf50c5e850a5c404a08e92f4d Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Mon, 20 Mar 2023 10:13:44 +0530 Subject: [PATCH 04/28] Fix warning: -Waddress-of-packed-member when calculating checksum directly from network packets --- source/FreeRTOS_IP_Utils.c | 74 ++++++++++++++++++++++++---- source/FreeRTOS_IPv6_Utils.c | 1 - source/include/FreeRTOS_IP_Private.h | 1 - 3 files changed, 65 insertions(+), 11 deletions(-) diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index 74b98b3d3c..4c1ef69ebe 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -127,8 +127,67 @@ static void prvChecksumProtocolCalculate( BaseType_t xOutgoingPacket, static void prvChecksumProtocolSetChecksum( BaseType_t xOutgoingPacket, const uint8_t * pucEthernetBuffer, size_t uxBufferLength, - const struct xPacketSummary * pxSet ); + struct xPacketSummary * pxSet ); +static void prvSetChecksumInPacket( struct xPacketSummary * pxSet, uint16_t usChecksum ); + +static uint16_t prvGetChecksumFromPacket( const struct xPacketSummary * pxSet ); + +static void prvSetChecksumInPacket( struct xPacketSummary * pxSet, uint16_t usChecksum ) +{ + if( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) + { + pxSet->pxProtocolHeaders->xUDPHeader.usChecksum = usChecksum; + } + else if( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_TCP ) + { + pxSet->pxProtocolHeaders->xTCPHeader.usChecksum = usChecksum; + } + else if( ( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) || + ( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_IGMP ) ) + { + pxSet->pxProtocolHeaders->xICMPHeader.usChecksum = usChecksum; + } + else if( ( pxSet->xIsIPv6 != pdFALSE ) && ( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP_IPv6 ) ) + { + pxSet->pxProtocolHeaders->xICMPHeaderIPv6.usChecksum = usChecksum; + } + else + { + /* Unhandled protocol. */ + } +} + +static uint16_t prvGetChecksumFromPacket( const struct xPacketSummary * pxSet ) +{ + + uint16_t usChecksum; + + if( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) + { + usChecksum = pxSet->pxProtocolHeaders->xUDPHeader.usChecksum; + } + else if( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_TCP ) + { + usChecksum = pxSet->pxProtocolHeaders->xTCPHeader.usChecksum; + } + else if( ( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) || + ( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_IGMP ) ) + { + usChecksum = pxSet->pxProtocolHeaders->xICMPHeader.usChecksum; + } + else if( ( pxSet->xIsIPv6 != pdFALSE ) && ( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP_IPv6 ) ) + { + usChecksum = pxSet->pxProtocolHeaders->xICMPHeaderIPv6.usChecksum; + } + else + { + /* Unhandled protocol. */ + usChecksum = ipUNHANDLED_PROTOCOL; + } + + return usChecksum; +} #if ( ipconfigUSE_DHCPv6 == 1 ) || ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) @@ -320,7 +379,6 @@ static BaseType_t prvChecksumProtocolChecks( size_t uxBufferLength, if( xReturn == 0 ) { - pxSet->pusChecksum = ( uint16_t * ) ( &( pxSet->pxProtocolHeaders->xUDPHeader.usChecksum ) ); pxSet->uxProtocolHeaderLength = sizeof( pxSet->pxProtocolHeaders->xUDPHeader ); #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) { @@ -342,7 +400,6 @@ static BaseType_t prvChecksumProtocolChecks( size_t uxBufferLength, { uint8_t ucLength = ( ( ( pxSet->pxProtocolHeaders->xTCPHeader.ucTCPOffset >> 4U ) - 5U ) << 2U ); size_t uxOptionsLength = ( size_t ) ucLength; - pxSet->pusChecksum = ( uint16_t * ) ( &( pxSet->pxProtocolHeaders->xTCPHeader.usChecksum ) ); pxSet->uxProtocolHeaderLength = ipSIZE_OF_TCP_HEADER + uxOptionsLength; #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) { @@ -364,7 +421,6 @@ static BaseType_t prvChecksumProtocolChecks( size_t uxBufferLength, if( xReturn == 0 ) { pxSet->uxProtocolHeaderLength = sizeof( pxSet->pxProtocolHeaders->xICMPHeader ); - pxSet->pusChecksum = ( uint16_t * ) ( &( pxSet->pxProtocolHeaders->xICMPHeader.usChecksum ) ); #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) { @@ -547,18 +603,18 @@ static void prvChecksumProtocolCalculate( BaseType_t xOutgoingPacket, static void prvChecksumProtocolSetChecksum( BaseType_t xOutgoingPacket, const uint8_t * pucEthernetBuffer, size_t uxBufferLength, - const struct xPacketSummary * pxSet ) + struct xPacketSummary * pxSet ) { if( xOutgoingPacket != pdFALSE ) { - *( pxSet->pusChecksum ) = pxSet->usChecksum; + prvSetChecksumInPacket( pxSet, pxSet->usChecksum ); } #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) else if( ( xOutgoingPacket == pdFALSE ) && ( pxSet->usChecksum != ipCORRECT_CRC ) ) { uint16_t usGot; - usGot = *pxSet->pusChecksum; + usGot = prvGetChecksumFromPacket( pxSet ); FreeRTOS_debug_printf( ( "usGenerateProtocolChecksum[%s]: len %d ID %04X: from %xip to %xip cal %04X got %04X\n", pxSet->pcType, pxSet->usProtocolBytes, @@ -955,9 +1011,9 @@ uint16_t usGenerateProtocolChecksum( uint8_t * pucEthernetBuffer, { /* This is an outgoing packet. Before calculating the checksum, set it * to zero. */ - *( xSet.pusChecksum ) = 0U; + prvSetChecksumInPacket( &( xSet ), 0 ); } - else if( ( *( xSet.pusChecksum ) == 0U ) && ( xSet.ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) ) + else if( ( prvGetChecksumFromPacket( &( xSet ) ) == 0U ) && ( xSet.ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) ) { #if ( ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS == 0 ) { diff --git a/source/FreeRTOS_IPv6_Utils.c b/source/FreeRTOS_IPv6_Utils.c index bbea333112..a0be6f872e 100644 --- a/source/FreeRTOS_IPv6_Utils.c +++ b/source/FreeRTOS_IPv6_Utils.c @@ -149,7 +149,6 @@ BaseType_t prvChecksumICMPv6Checks( size_t uxBufferLength, if( xReturn == 0 ) { - pxSet->pusChecksum = ( uint16_t * ) ( &( pxSet->pxProtocolHeaders->xICMPHeader.usChecksum ) ); pxSet->uxProtocolHeaderLength = xICMPLength; #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) { diff --git a/source/include/FreeRTOS_IP_Private.h b/source/include/FreeRTOS_IP_Private.h index 959525fcca..c5ddbea1f4 100644 --- a/source/include/FreeRTOS_IP_Private.h +++ b/source/include/FreeRTOS_IP_Private.h @@ -256,7 +256,6 @@ struct xPacketSummary ProtocolHeaders_t * pxProtocolHeaders; /**< Points to first byte after IP-header */ uint16_t usPayloadLength; /**< Property of IP-header (for IPv4: length of IP-header included) */ uint16_t usProtocolBytes; /**< The total length of the protocol data. */ - uint16_t * pusChecksum; /**< A pointer to the location where the protocol checksum is stored. */ }; #define ipBROADCAST_IP_ADDRESS 0xffffffffU From 28b91b76b921d1074b2b2a39417261871ebf2aa4 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Mon, 20 Mar 2023 13:43:18 +0530 Subject: [PATCH 05/28] fix warnings with prvInitialiseTCPFields declaration --- source/FreeRTOS_Sockets.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index a4f24f5227..df822587cb 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -323,10 +323,12 @@ static void prvSetOptionTimeout( FreeRTOS_Socket_t * pxSocket, */ static BaseType_t prvSetOptionReuseListenSocket( FreeRTOS_Socket_t * pxSocket, const void * pvOptionValue ); + + static void prvInitialiseTCPFields( FreeRTOS_Socket_t * pxSocket, + size_t uxSocketSize ); #endif /* ipconfigUSE_TCP == 1 */ -static void prvInitialiseTCPFields( FreeRTOS_Socket_t * pxSocket, - size_t uxSocketSize ); + static int32_t prvRecvFrom_CopyPacket( uint8_t * pucEthernetBuffer, void * pvBuffer, From c9305daf860e10879cd5a56767e33c0b6f4ca3a7 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Mon, 20 Mar 2023 14:13:59 +0530 Subject: [PATCH 06/28] removing macros that hides the structure fields --- source/FreeRTOS_DHCPv6.c | 2 +- source/FreeRTOS_DNS.c | 12 ++++---- source/FreeRTOS_DNS_Cache.c | 2 +- source/FreeRTOS_IP.c | 4 +-- source/FreeRTOS_Sockets.c | 30 +++++++++---------- source/FreeRTOS_TCP_State_Handling.c | 2 +- source/FreeRTOS_UDP_IPv4.c | 4 +-- source/FreeRTOS_UDP_IPv6.c | 4 +-- source/include/FreeRTOS_DNS_Globals.h | 2 +- source/include/FreeRTOS_Sockets.h | 9 ++---- .../NetworkInterface/linux/CMakeLists.txt | 5 ---- .../NetworkInterface/linux/NetworkInterface.c | 12 ++++---- 12 files changed, 40 insertions(+), 48 deletions(-) diff --git a/source/FreeRTOS_DHCPv6.c b/source/FreeRTOS_DHCPv6.c index 07a9a4dda0..0b0b25e467 100644 --- a/source/FreeRTOS_DHCPv6.c +++ b/source/FreeRTOS_DHCPv6.c @@ -1028,7 +1028,7 @@ static void prvSendDHCPMessage( NetworkEndPoint_t * pxEndPoint ) } ( void ) memset( &( xAddress ), 0, sizeof xAddress ); - ( void ) FreeRTOS_inet_pton6( "ff02::1:2", xAddress.sin_addr6.ucBytes ); + ( void ) FreeRTOS_inet_pton6( "ff02::1:2", xAddress.sin_address.xIP_IPv6.ucBytes ); xAddress.sin_len = ( uint8_t ) sizeof xAddress; /* length of this structure. */ xAddress.sin_family = FREERTOS_AF_INET6; xAddress.sin_port = FreeRTOS_htons( DHCPv6_SERVER_PORT ); diff --git a/source/FreeRTOS_DNS.c b/source/FreeRTOS_DNS.c index bb1b16567a..70d6f14115 100644 --- a/source/FreeRTOS_DNS.c +++ b/source/FreeRTOS_DNS.c @@ -308,7 +308,7 @@ /* ulChar2u32 reads from big-endian to host-endian. */ uint32_t ulIPAddress = ulChar2u32( pucAddress ); /* Translate to network-endian. */ - pxAddrInfo->ai_addr->sin_addr = FreeRTOS_htonl( ulIPAddress ); + pxAddrInfo->ai_addr->sin_address.ulIP_IPv4 = FreeRTOS_htonl( ulIPAddress ); pxAddrInfo->ai_family = FREERTOS_AF_INET4; pxAddrInfo->ai_addrlen = ipSIZE_OF_IPv4_ADDRESS; } @@ -870,7 +870,7 @@ { /* Looking up a name like "mydevice.local". * Use mDNS addresses. */ - pxAddress->sin_addr = ipMDNS_IP_ADDRESS; /* Is in network byte order. */ + pxAddress->sin_address.ulIP_IPv4 = ipMDNS_IP_ADDRESS; /* Is in network byte order. */ pxAddress->sin_port = ipMDNS_PORT; pxAddress->sin_port = FreeRTOS_ntohs( pxAddress->sin_port ); xNeed_Endpoint = pdTRUE; @@ -892,7 +892,7 @@ if( bHasDot == pdFALSE ) { /* Use LLMNR addressing. */ - pxAddress->sin_addr = ipLLMNR_IP_ADDR; /* Is in network byte order. */ + pxAddress->sin_address.ulIP_IPv4 = ipLLMNR_IP_ADDR; /* Is in network byte order. */ pxAddress->sin_port = ipLLMNR_PORT; pxAddress->sin_port = FreeRTOS_ntohs( pxAddress->sin_port ); xNeed_Endpoint = pdTRUE; @@ -958,7 +958,7 @@ { pxAddress->sin_family = FREERTOS_AF_INET6; pxAddress->sin_len = ( uint8_t ) sizeof( struct freertos_sockaddr ); - ( void ) memcpy( pxAddress->sin_addr6.ucBytes, + ( void ) memcpy( pxAddress->sin_address.xIP_IPv6.ucBytes, pxEndPoint->ipv6_settings.xDNSServerAddresses[ ucIndex ].ucBytes, ipSIZE_OF_IPv6_ADDRESS ); break; @@ -975,7 +975,7 @@ { pxAddress->sin_family = FREERTOS_AF_INET; pxAddress->sin_len = ( uint8_t ) sizeof( struct freertos_sockaddr ); - pxAddress->sin_addr = ulIPAddress; + pxAddress->sin_address.ulIP_IPv4 = ulIPAddress; break; } } @@ -1134,7 +1134,7 @@ uxHostType ); /* ipLLMNR_IP_ADDR is in network byte order. */ - if( ( pxAddress->sin_addr == ipLLMNR_IP_ADDR ) || ( pxAddress->sin_addr == ipMDNS_IP_ADDRESS ) ) + if( ( pxAddress->sin_address.ulIP_IPv4 == ipLLMNR_IP_ADDR ) || ( pxAddress->sin_address.ulIP_IPv4 == ipMDNS_IP_ADDRESS ) ) { /* Use LLMNR addressing. */ /* MISRA Ref 11.3.1 [Misaligned access] */ diff --git a/source/FreeRTOS_DNS_Cache.c b/source/FreeRTOS_DNS_Cache.c index 6f47c4401c..a0b013a9a2 100644 --- a/source/FreeRTOS_DNS_Cache.c +++ b/source/FreeRTOS_DNS_Cache.c @@ -585,7 +585,7 @@ { const struct freertos_sockaddr * sockaddr = ( *( ppxAddressInfo ) )->ai_addr; - ulIPAddress = sockaddr->sin_addr; + ulIPAddress = sockaddr->sin_address.ulIP_IPv4; } } else diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 0cdebe7763..6f2f41e41e 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -335,14 +335,14 @@ static void prvProcessIPEventsAndTimers( void ) if( pxSocket->bits.bIsIPv6 != pdFALSE_UNSIGNED ) { xAddress.sin_family = FREERTOS_AF_INET6; - ( void ) memcpy( xAddress.sin_addr6.ucBytes, pxSocket->xLocalAddress.xIP_IPv6.ucBytes, sizeof( xAddress.sin_addr6.ucBytes ) ); + ( void ) memcpy( xAddress.sin_address.xIP_IPv6.ucBytes, pxSocket->xLocalAddress.xIP_IPv6.ucBytes, sizeof( xAddress.sin_address.xIP_IPv6.ucBytes ) ); /* 'ulLocalAddress' will be set again by vSocketBind(). */ ( void ) memset( pxSocket->xLocalAddress.xIP_IPv6.ucBytes, 0, sizeof( pxSocket->xLocalAddress.xIP_IPv6.ucBytes ) ); } else { xAddress.sin_family = FREERTOS_AF_INET; - xAddress.sin_addr = FreeRTOS_htonl( pxSocket->xLocalAddress.ulIP_IPv4 ); + xAddress.sin_address.ulIP_IPv4 = FreeRTOS_htonl( pxSocket->xLocalAddress.ulIP_IPv4 ); /* 'ulLocalAddress' will be set again by vSocketBind(). */ pxSocket->xLocalAddress.ulIP_IPv4 = 0; } diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index df822587cb..b1be46a121 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -1607,12 +1607,12 @@ BaseType_t FreeRTOS_bind( Socket_t xSocket, { if( pxAddress->sin_family == ( uint8_t ) FREERTOS_AF_INET6 ) { - ( void ) memcpy( pxSocket->xLocalAddress.xIP_IPv6.ucBytes, pxAddress->sin_addr6.ucBytes, sizeof( pxSocket->xLocalAddress.xIP_IPv6.ucBytes ) ); + ( void ) memcpy( pxSocket->xLocalAddress.xIP_IPv6.ucBytes, pxAddress->sin_address.xIP_IPv6.ucBytes, sizeof( pxSocket->xLocalAddress.xIP_IPv6.ucBytes ) ); pxSocket->bits.bIsIPv6 = pdTRUE_UNSIGNED; } else { - pxSocket->xLocalAddress.ulIP_IPv4 = FreeRTOS_ntohl( pxAddress->sin_addr ); + pxSocket->xLocalAddress.ulIP_IPv4 = FreeRTOS_ntohl( pxAddress->sin_address.ulIP_IPv4 ); pxSocket->bits.bIsIPv6 = pdFALSE_UNSIGNED; } @@ -1691,11 +1691,11 @@ static BaseType_t prvSocketBindAdd( FreeRTOS_Socket_t * pxSocket, if( pxAddress->sin_family == ( uint8_t ) FREERTOS_AF_INET6 ) { pxSocket->xLocalAddress.ulIP_IPv4 = 0U; - ( void ) memcpy( pxSocket->xLocalAddress.xIP_IPv6.ucBytes, pxAddress->sin_addr6.ucBytes, sizeof( pxSocket->xLocalAddress.xIP_IPv6.ucBytes ) ); + ( void ) memcpy( pxSocket->xLocalAddress.xIP_IPv6.ucBytes, pxAddress->sin_address.xIP_IPv6.ucBytes, sizeof( pxSocket->xLocalAddress.xIP_IPv6.ucBytes ) ); } - else if( pxAddress->sin_addr != FREERTOS_INADDR_ANY ) + else if( pxAddress->sin_address.ulIP_IPv4 != FREERTOS_INADDR_ANY ) { - pxSocket->pxEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( pxAddress->sin_addr, 7 ); + pxSocket->pxEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( pxAddress->sin_address.ulIP_IPv4, 7 ); } else { @@ -3320,7 +3320,7 @@ size_t FreeRTOS_GetLocalAddress( ConstSocket_t xSocket, { pxAddress->sin_family = FREERTOS_AF_INET6; /* IP address of local machine. */ - ( void ) memcpy( pxAddress->sin_addr6.ucBytes, pxSocket->xLocalAddress.xIP_IPv6.ucBytes, sizeof( pxAddress->sin_addr6.ucBytes ) ); + ( void ) memcpy( pxAddress->sin_address.xIP_IPv6.ucBytes, pxSocket->xLocalAddress.xIP_IPv6.ucBytes, sizeof( pxAddress->sin_address.xIP_IPv6.ucBytes ) ); /* Local port on this machine. */ pxAddress->sin_port = FreeRTOS_htons( pxSocket->usLocalPort ); } @@ -3329,7 +3329,7 @@ size_t FreeRTOS_GetLocalAddress( ConstSocket_t xSocket, pxAddress->sin_family = FREERTOS_AF_INET; pxAddress->sin_len = ( uint8_t ) sizeof( *pxAddress ); /* IP address of local machine. */ - pxAddress->sin_addr = FreeRTOS_htonl( pxSocket->xLocalAddress.ulIP_IPv4 ); + pxAddress->sin_address.ulIP_IPv4 = FreeRTOS_htonl( pxSocket->xLocalAddress.ulIP_IPv4 ); /* Local port on this machine. */ pxAddress->sin_port = FreeRTOS_htons( pxSocket->usLocalPort ); @@ -3531,15 +3531,15 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) { pxSocket->bits.bIsIPv6 = pdTRUE_UNSIGNED; FreeRTOS_printf( ( "FreeRTOS_connect: %u to %pip port %u\n", - pxSocket->usLocalPort, pxAddress->sin_addr6.ucBytes, FreeRTOS_ntohs( pxAddress->sin_port ) ) ); - ( void ) memcpy( pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, pxAddress->sin_addr6.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); + pxSocket->usLocalPort, pxAddress->sin_address.xIP_IPv6.ucBytes, FreeRTOS_ntohs( pxAddress->sin_port ) ) ); + ( void ) memcpy( pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, pxAddress->sin_address.xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); } else { pxSocket->bits.bIsIPv6 = pdFALSE_UNSIGNED; FreeRTOS_printf( ( "FreeRTOS_connect: %u to %lxip:%u\n", - pxSocket->usLocalPort, FreeRTOS_ntohl( pxAddress->sin_addr ), FreeRTOS_ntohs( pxAddress->sin_port ) ) ); - pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4 = FreeRTOS_ntohl( pxAddress->sin_addr ); + pxSocket->usLocalPort, FreeRTOS_ntohl( pxAddress->sin_address.ulIP_IPv4 ), FreeRTOS_ntohs( pxAddress->sin_port ) ) ); + pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4 = FreeRTOS_ntohl( pxAddress->sin_address.ulIP_IPv4 ); } /* Port on remote machine. */ @@ -3723,7 +3723,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) { pxAddress->sin_family = FREERTOS_AF_INET6; /* Copy IP-address and port number. */ - ( void ) memcpy( pxAddress->sin_addr6.ucBytes, pxClientSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); + ( void ) memcpy( pxAddress->sin_address.xIP_IPv6.ucBytes, pxClientSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); pxAddress->sin_port = FreeRTOS_ntohs( pxClientSocket->u.xTCP.usRemotePort ); } } @@ -3733,7 +3733,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) { pxAddress->sin_family = FREERTOS_AF_INET4; /* Copy IP-address and port number. */ - pxAddress->sin_addr = FreeRTOS_ntohl( pxClientSocket->u.xTCP.xRemoteIP.ulIP_IPv4 ); + pxAddress->sin_address.ulIP_IPv4 = FreeRTOS_ntohl( pxClientSocket->u.xTCP.xRemoteIP.ulIP_IPv4 ); pxAddress->sin_port = FreeRTOS_ntohs( pxClientSocket->u.xTCP.usRemotePort ); } } @@ -5086,7 +5086,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) pxAddress->sin_family = FREERTOS_AF_INET6; /* IP address of remote machine. */ - ( void ) memcpy( pxAddress->sin_addr6.ucBytes, pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, sizeof( pxAddress->sin_addr6.ucBytes ) ); + ( void ) memcpy( pxAddress->sin_address.xIP_IPv6.ucBytes, pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, sizeof( pxAddress->sin_address.xIP_IPv6.ucBytes ) ); /* Port of remote machine. */ pxAddress->sin_port = FreeRTOS_htons( pxSocket->u.xTCP.usRemotePort ); @@ -5097,7 +5097,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) pxAddress->sin_family = FREERTOS_AF_INET; /* IP address of remote machine. */ - pxAddress->sin_addr = FreeRTOS_htonl( pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4 ); + pxAddress->sin_address.ulIP_IPv4 = FreeRTOS_htonl( pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4 ); /* Port on remote machine. */ pxAddress->sin_port = FreeRTOS_htons( pxSocket->u.xTCP.usRemotePort ); diff --git a/source/FreeRTOS_TCP_State_Handling.c b/source/FreeRTOS_TCP_State_Handling.c index 43f700e6f3..2b045b1aa8 100644 --- a/source/FreeRTOS_TCP_State_Handling.c +++ b/source/FreeRTOS_TCP_State_Handling.c @@ -979,7 +979,7 @@ #endif /* ipconfigSUPPORT_SELECT_FUNCTION */ /* And bind it to the same local port as its parent. */ - /*TODO xAddress.sin_addr = *ipLOCAL_IP_ADDRESS_POINTER; */ + /*TODO xAddress.sin_address.ulIP_IPv4 = *ipLOCAL_IP_ADDRESS_POINTER; */ xAddress.sin_port = FreeRTOS_htons( pxSocket->usLocalPort ); #if ( ipconfigTCP_HANG_PROTECTION == 1 ) diff --git a/source/FreeRTOS_UDP_IPv4.c b/source/FreeRTOS_UDP_IPv4.c index da41e71b4f..d5d2e0c432 100644 --- a/source/FreeRTOS_UDP_IPv4.c +++ b/source/FreeRTOS_UDP_IPv4.c @@ -394,9 +394,9 @@ BaseType_t xProcessReceivedUDPPacket_IPv4( NetworkBufferDescriptor_t * pxNetwork void * pcData = &( pxNetworkBuffer->pucEthernetBuffer[ ipUDP_PAYLOAD_OFFSET_IPv4 ] ); FOnUDPReceive_t xHandler = ( FOnUDPReceive_t ) pxSocket->u.xUDP.pxHandleReceive; xSourceAddress.sin_port = pxNetworkBuffer->usPort; - xSourceAddress.sin_addr4 = pxNetworkBuffer->xIPAddress.ulIP_IPv4; + xSourceAddress.sin_address.ulIP_IPv4 = pxNetworkBuffer->xIPAddress.ulIP_IPv4; destinationAddress.sin_port = usPort; - destinationAddress.sin_addr4 = pxUDPPacket->xIPHeader.ulDestinationIPAddress; + destinationAddress.sin_address.ulIP_IPv4 = pxUDPPacket->xIPHeader.ulDestinationIPAddress; /* The value of 'xDataLength' was proven to be at least the size of a UDP packet in prvProcessIPPacket(). */ if( xHandler( ( Socket_t ) pxSocket, diff --git a/source/FreeRTOS_UDP_IPv6.c b/source/FreeRTOS_UDP_IPv6.c index c46bb7d5b6..1cad2818f8 100644 --- a/source/FreeRTOS_UDP_IPv6.c +++ b/source/FreeRTOS_UDP_IPv6.c @@ -477,8 +477,8 @@ BaseType_t xProcessReceivedUDPPacket_IPv6( NetworkBufferDescriptor_t * pxNetwork xSourceAddress.sin_port = pxNetworkBuffer->usPort; destinationAddress.sin_port = usPort; - ( void ) memcpy( xSourceAddress.sin_addr6.ucBytes, pxUDPPacket_IPv6->xIPHeader.xSourceAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); - ( void ) memcpy( destinationAddress.sin_addr6.ucBytes, pxUDPPacket_IPv6->xIPHeader.xDestinationAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); + ( void ) memcpy( xSourceAddress.sin_address.xIP_IPv6.ucBytes, pxUDPPacket_IPv6->xIPHeader.xSourceAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); + ( void ) memcpy( destinationAddress.sin_address.xIP_IPv6.ucBytes, pxUDPPacket_IPv6->xIPHeader.xDestinationAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); xSourceAddress.sin_family = ( uint8_t ) FREERTOS_AF_INET6; destinationAddress.sin_family = ( uint8_t ) FREERTOS_AF_INET6; xSourceAddress.sin_len = ( uint8_t ) sizeof( xSourceAddress ); diff --git a/source/include/FreeRTOS_DNS_Globals.h b/source/include/FreeRTOS_DNS_Globals.h index 9abb8ceb30..1b0a16351b 100644 --- a/source/include/FreeRTOS_DNS_Globals.h +++ b/source/include/FreeRTOS_DNS_Globals.h @@ -145,7 +145,7 @@ BaseType_t ai_socktype; /**< n.a. */ BaseType_t ai_protocol; /**< n.a. */ socklen_t ai_addrlen; /**< The length of the address, either ipSIZE_OF_IPv4_ADDRESS or ipSIZE_OF_IPv6_ADDRESS. */ - struct freertos_sockaddr * ai_addr; /**< The IP-address. Can be mapped onto 'freertos_sockaddr6' in case of IPv6. */ + struct freertos_sockaddr * ai_addr; /**< The IP-address. Can be mapped onto 'sin_address.xIP_IPv6' in case of IPv6. */ char * ai_canonname; /**< The name of the host. */ struct freertos_addrinfo * ai_next; /**< A pointer to the next find result, or NULL. */ struct diff --git a/source/include/FreeRTOS_Sockets.h b/source/include/FreeRTOS_Sockets.h index a0d6f459a5..3e5abe3f46 100644 --- a/source/include/FreeRTOS_Sockets.h +++ b/source/include/FreeRTOS_Sockets.h @@ -180,14 +180,11 @@ IP_Address_t sin_address; /**< The IPv4/IPv6 address. */ }; -#ifndef sin_addr +#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) + #define sin_addr sin_address.ulIP_IPv4 + #endif - #define sin_addr4 sin_address.ulIP_IPv4 - #define sin_addr6 sin_address.xIP_IPv6 - #define sin_addrv4 sin_address.ulIP_IPv4 - #define sin_addrv6 sin_address.xIP_IPv6 - #define freertos_sockaddr6 freertos_sockaddr /** Introduce a short name to make casting easier. */ typedef struct freertos_sockaddr xFreertosSocAddr; diff --git a/source/portable/NetworkInterface/linux/CMakeLists.txt b/source/portable/NetworkInterface/linux/CMakeLists.txt index 5c5180a3f5..0b2e44cbd6 100644 --- a/source/portable/NetworkInterface/linux/CMakeLists.txt +++ b/source/portable/NetworkInterface/linux/CMakeLists.txt @@ -27,11 +27,6 @@ target_compile_options( freertos_plus_tcp_network_if $<$:-Wno-unused-parameter> ) -target_compile_definitions( freertos_plus_tcp_network_if - PRIVATE - "sin_addr=sin_addr" -) - target_link_libraries( freertos_plus_tcp_network_if PUBLIC freertos_plus_tcp_port diff --git a/source/portable/NetworkInterface/linux/NetworkInterface.c b/source/portable/NetworkInterface/linux/NetworkInterface.c index 3921809e56..e62439dcad 100644 --- a/source/portable/NetworkInterface/linux/NetworkInterface.c +++ b/source/portable/NetworkInterface/linux/NetworkInterface.c @@ -31,12 +31,6 @@ #include "task.h" #include "semphr.h" -/* ========================= FreeRTOS+TCP includes ========================== */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_IP_Private.h" -#include "NetworkBufferManagement.h" -#include "FreeRTOS_Stream_Buffer.h" - /* ======================== Standard Library includes ======================== */ #include #include @@ -49,6 +43,12 @@ #include #include +/* ========================= FreeRTOS+TCP includes ========================== */ +#include "FreeRTOS_IP.h" +#include "FreeRTOS_IP_Private.h" +#include "NetworkBufferManagement.h" +#include "FreeRTOS_Stream_Buffer.h" + /* ========================== Local includes =================================*/ #include From 602003612fb5eb68d2d6cda8444d62a3da3dfcae Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Mon, 20 Mar 2023 15:58:14 +0530 Subject: [PATCH 07/28] Updating build check enable all config to enable all config macros --- source/FreeRTOS_DHCPv6.c | 4 ++-- source/FreeRTOS_DNS.c | 1 - source/FreeRTOS_DNS_Parser.c | 2 +- source/FreeRTOS_ND.c | 4 ++-- .../AllEnable/FreeRTOSIPConfig.h | 23 +++++++++++++++++++ test/build-combination/Common/main.c | 20 ++++++++++++++++ 6 files changed, 48 insertions(+), 6 deletions(-) diff --git a/source/FreeRTOS_DHCPv6.c b/source/FreeRTOS_DHCPv6.c index 0b0b25e467..296fed52c9 100644 --- a/source/FreeRTOS_DHCPv6.c +++ b/source/FreeRTOS_DHCPv6.c @@ -177,7 +177,7 @@ static void prvCreateDHCPv6Socket( NetworkEndPoint_t * pxEndPoint ); static void prvCloseDHCPv6Socket( NetworkEndPoint_t * pxEndPoint ); #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - static const char * prvStateName( eDHCPState_t eState ); + const char * prvStateName( eDHCPState_t eState ); #endif static BaseType_t xDHCPv6Process_PassReplyToEndPoint( struct xNetworkEndPoint * pxEndPoint ); @@ -1386,7 +1386,7 @@ static BaseType_t prvDHCPv6Analyse( const uint8_t * pucAnswer, * @return A descriptive string. */ #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - static const char * prvStateName( eDHCPState_t eState ) + const char * prvStateName( eDHCPState_t eState ) { const char * pcName; diff --git a/source/FreeRTOS_DNS.c b/source/FreeRTOS_DNS.c index 70d6f14115..448f3c56df 100644 --- a/source/FreeRTOS_DNS.c +++ b/source/FreeRTOS_DNS.c @@ -127,7 +127,6 @@ /** * @brief The IPv6 link-scope multicast MAC address */ - const const MACAddress_t xLLMNR_MacAdressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x03 } }; #endif /* ipconfigUSE_LLMNR && ipconfigUSE_IPv6 */ diff --git a/source/FreeRTOS_DNS_Parser.c b/source/FreeRTOS_DNS_Parser.c index 9e391de736..4b9737ce40 100644 --- a/source/FreeRTOS_DNS_Parser.c +++ b/source/FreeRTOS_DNS_Parser.c @@ -1144,7 +1144,7 @@ #endif #if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) - if( xApplicationDNSQueryHook( xSet.pcName ) != pdFALSE ) + if( xApplicationDNSQueryHook( ( const char * ) ucNBNSName ) != pdFALSE ) #else if( xApplicationDNSQueryHook_Multi( &( xEndPoint ), ( const char * ) ucNBNSName ) != pdFALSE ) #endif /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */ diff --git a/source/FreeRTOS_ND.c b/source/FreeRTOS_ND.c index a68b41a6d1..20421f89ec 100644 --- a/source/FreeRTOS_ND.c +++ b/source/FreeRTOS_ND.c @@ -92,7 +92,7 @@ NetworkEndPoint_t ** ppxEndPoint ); #if ( ipconfigHAS_PRINTF == 1 ) - static const char * pcMessageType( BaseType_t xType ); + const char * pcMessageType( BaseType_t xType ); #endif /** @brief Find the first end-point of type IPv6. */ @@ -820,7 +820,7 @@ * * @return A null-terminated string that represents the type the kind of message. */ - static const char * pcMessageType( BaseType_t xType ) + const char * pcMessageType( BaseType_t xType ) { const char * pcReturn; diff --git a/test/build-combination/AllEnable/FreeRTOSIPConfig.h b/test/build-combination/AllEnable/FreeRTOSIPConfig.h index b497b33232..b97ad55925 100644 --- a/test/build-combination/AllEnable/FreeRTOSIPConfig.h +++ b/test/build-combination/AllEnable/FreeRTOSIPConfig.h @@ -34,6 +34,29 @@ #ifndef FREERTOS_IP_CONFIG_H #define FREERTOS_IP_CONFIG_H +#define ipconfigUSE_DHCPv6 1 +#define ipconfigIPv4_BACKWARD_COMPATIBLE 1 +#define ipconfigUSE_ARP_REVERSED_LOOKUP 1 +#define ipconfigUSE_ARP_REMOVE_ENTRY 1 +#define ipconfigARP_STORES_REMOTE_ADDRESSES 1 +#define ipconfigUSE_LINKED_RX_MESSAGES 1 +#define ipconfigFORCE_IP_DONT_FRAGMENT 1 +#define ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS 1 +#define ipconfigDHCP_FALL_BACK_AUTO_IP 1 +#define ipconfigARP_USE_CLASH_DETECTION 1 +#define ipconfigUSE_LLMNR 1 +#define ipconfigUSE_NBNS 1 +#define ipconfigUSE_MDNS 1 +#define ipconfigSUPPORT_OUTGOING_PINGS 1 +#define ipconfigETHERNET_DRIVER_FILTERS_PACKETS 1 +#define ipconfigZERO_COPY_TX_DRIVER 1 +#define ipconfigZERO_COPY_RX_DRIVER 1 +#define ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM 1 +#define ipconfigSOCKET_HAS_USER_SEMAPHORE 1 +#define ipconfigSELECT_USES_NOTIFY 1 +#define ipconfigSUPPORT_SIGNALS 1 +#define ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES 1 + /* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to * 1 then FreeRTOS_debug_printf should be defined to the function used to print * out the debugging messages. */ diff --git a/test/build-combination/Common/main.c b/test/build-combination/Common/main.c index 488a955666..f982af8d4f 100644 --- a/test/build-combination/Common/main.c +++ b/test/build-combination/Common/main.c @@ -41,6 +41,7 @@ #include #include +#include #define mainHOST_NAME "Build Combination" #define mainDEVICE_NICK_NAME "Build_Combination" @@ -348,6 +349,25 @@ struct xNetworkInterface * pxFillInterfaceDescriptor( BaseType_t xEMACIndex, } #endif +#if ( ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES != 0) + +/* + * The stack will call this user hook for all Ethernet frames that it + * does not support, i.e. other than IPv4, IPv6 and ARP ( for the moment ) + * If this hook returns eReleaseBuffer or eProcessBuffer, the stack will + * release and reuse the network buffer. If this hook returns + * eReturnEthernetFrame, that means user code has reused the network buffer + * to generate a response and the stack will send that response out. + * If this hook returns eFrameConsumed, the user code has ownership of the + * network buffer and has to release it when it's done. + */ + eFrameProcessingResult_t eApplicationProcessCustomFrameHook( NetworkBufferDescriptor_t * const pxNetworkBuffer ) + { + (void) (pxNetworkBuffer); + return eNetworkDownEvent; + } + +#endif void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifier ) { From 12256f034f24043c75c2f0cc4a8acedd71492c60 Mon Sep 17 00:00:00 2001 From: Nikhil Kamath <110539926+amazonKamath@users.noreply.github.com> Date: Sun, 26 Feb 2023 23:36:00 +0530 Subject: [PATCH 08/28] CMake: Fix GIT_REPOSITORY and GIT_TAG (#742) --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ef2be7a88..ab5a80fee2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,8 +212,8 @@ add_compile_options( include(FetchContent) FetchContent_Declare( freertos_kernel - GIT_REPOSITORY https://github.com/phelter/FreeRTOS-Kernel.git #https://github.com/FreeRTOS/FreeRTOS-Kernel.git - GIT_TAG feature/fixing-clang-gnu-compiler-warnings #master + GIT_REPOSITORY https://github.com/FreeRTOS/FreeRTOS-Kernel.git + GIT_TAG main ) FetchContent_Declare( cmock From 26cc247e02590cb381dec067d751f9de9467a948 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Mon, 20 Mar 2023 16:46:06 +0530 Subject: [PATCH 09/28] moving ipTRUE_BOOL and ipFALSE_BOOL out of #ifndef pdTRUE_SIGNED check as they are not defined in kernel --- source/include/FreeRTOS_IP.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/include/FreeRTOS_IP.h b/source/include/FreeRTOS_IP.h index 31449aefbb..b790c1a0d0 100644 --- a/source/include/FreeRTOS_IP.h +++ b/source/include/FreeRTOS_IP.h @@ -282,10 +282,11 @@ uint32_t FreeRTOS_round_down( uint32_t a, #define pdFALSE_SIGNED pdFALSE #define pdTRUE_UNSIGNED ( 1U ) #define pdFALSE_UNSIGNED ( 0U ) - #define ipTRUE_BOOL ( 1 == 1 ) - #define ipFALSE_BOOL ( 1 == 2 ) #endif +#define ipTRUE_BOOL ( 1 == 1 ) +#define ipFALSE_BOOL ( 1 == 2 ) + /* * FULL, UP-TO-DATE AND MAINTAINED REFERENCE DOCUMENTATION FOR ALL THESE * FUNCTIONS IS AVAILABLE ON THE FOLLOWING URL: From 4f2344dbaf78ef116119d9a7a4e4dc245cf68eb6 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Mon, 20 Mar 2023 16:52:31 +0530 Subject: [PATCH 10/28] minor fix to the cmake files and main file --- CMakeLists.txt | 2 +- test/build-combination/Common/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab5a80fee2..5e4ee7e8d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,7 +196,7 @@ add_compile_options( $<$:-Wall> $<$:-Wextra> $<$:-Wpedantic> - ##$<$:-Werror> + $<$:-Werror> $<$:-Weverything> # TODO: Add in other Compilers here. diff --git a/test/build-combination/Common/main.c b/test/build-combination/Common/main.c index f982af8d4f..201b6eb0a1 100644 --- a/test/build-combination/Common/main.c +++ b/test/build-combination/Common/main.c @@ -364,7 +364,7 @@ struct xNetworkInterface * pxFillInterfaceDescriptor( BaseType_t xEMACIndex, eFrameProcessingResult_t eApplicationProcessCustomFrameHook( NetworkBufferDescriptor_t * const pxNetworkBuffer ) { (void) (pxNetworkBuffer); - return eNetworkDownEvent; + return eProcessBuffer; } #endif From 702d44af81ccefc0245b85e95e031a337fa28bdd Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 20 Mar 2023 11:37:17 +0000 Subject: [PATCH 11/28] Uncrustify: triggered by comment. --- source/FreeRTOS_IP_Utils.c | 7 +-- source/include/FreeRTOS_Sockets.h | 6 +-- .../AllEnable/FreeRTOSIPConfig.h | 46 +++++++++---------- test/build-combination/Common/main.c | 4 +- 4 files changed, 32 insertions(+), 31 deletions(-) diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index 4c1ef69ebe..289c59fb2d 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -129,11 +129,13 @@ static void prvChecksumProtocolSetChecksum( BaseType_t xOutgoingPacket, size_t uxBufferLength, struct xPacketSummary * pxSet ); -static void prvSetChecksumInPacket( struct xPacketSummary * pxSet, uint16_t usChecksum ); +static void prvSetChecksumInPacket( struct xPacketSummary * pxSet, + uint16_t usChecksum ); static uint16_t prvGetChecksumFromPacket( const struct xPacketSummary * pxSet ); -static void prvSetChecksumInPacket( struct xPacketSummary * pxSet, uint16_t usChecksum ) +static void prvSetChecksumInPacket( struct xPacketSummary * pxSet, + uint16_t usChecksum ) { if( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) { @@ -160,7 +162,6 @@ static void prvSetChecksumInPacket( struct xPacketSummary * pxSet, uint16_t usCh static uint16_t prvGetChecksumFromPacket( const struct xPacketSummary * pxSet ) { - uint16_t usChecksum; if( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) diff --git a/source/include/FreeRTOS_Sockets.h b/source/include/FreeRTOS_Sockets.h index 3e5abe3f46..fcfac4930e 100644 --- a/source/include/FreeRTOS_Sockets.h +++ b/source/include/FreeRTOS_Sockets.h @@ -180,11 +180,11 @@ IP_Address_t sin_address; /**< The IPv4/IPv6 address. */ }; -#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) + #if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) - #define sin_addr sin_address.ulIP_IPv4 + #define sin_addr sin_address.ulIP_IPv4 -#endif + #endif /** Introduce a short name to make casting easier. */ typedef struct freertos_sockaddr xFreertosSocAddr; diff --git a/test/build-combination/AllEnable/FreeRTOSIPConfig.h b/test/build-combination/AllEnable/FreeRTOSIPConfig.h index b97ad55925..561c789927 100644 --- a/test/build-combination/AllEnable/FreeRTOSIPConfig.h +++ b/test/build-combination/AllEnable/FreeRTOSIPConfig.h @@ -34,33 +34,33 @@ #ifndef FREERTOS_IP_CONFIG_H #define FREERTOS_IP_CONFIG_H -#define ipconfigUSE_DHCPv6 1 -#define ipconfigIPv4_BACKWARD_COMPATIBLE 1 -#define ipconfigUSE_ARP_REVERSED_LOOKUP 1 -#define ipconfigUSE_ARP_REMOVE_ENTRY 1 -#define ipconfigARP_STORES_REMOTE_ADDRESSES 1 -#define ipconfigUSE_LINKED_RX_MESSAGES 1 -#define ipconfigFORCE_IP_DONT_FRAGMENT 1 -#define ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS 1 -#define ipconfigDHCP_FALL_BACK_AUTO_IP 1 -#define ipconfigARP_USE_CLASH_DETECTION 1 -#define ipconfigUSE_LLMNR 1 -#define ipconfigUSE_NBNS 1 -#define ipconfigUSE_MDNS 1 -#define ipconfigSUPPORT_OUTGOING_PINGS 1 -#define ipconfigETHERNET_DRIVER_FILTERS_PACKETS 1 -#define ipconfigZERO_COPY_TX_DRIVER 1 -#define ipconfigZERO_COPY_RX_DRIVER 1 -#define ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM 1 -#define ipconfigSOCKET_HAS_USER_SEMAPHORE 1 -#define ipconfigSELECT_USES_NOTIFY 1 -#define ipconfigSUPPORT_SIGNALS 1 -#define ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES 1 +#define ipconfigUSE_DHCPv6 1 +#define ipconfigIPv4_BACKWARD_COMPATIBLE 1 +#define ipconfigUSE_ARP_REVERSED_LOOKUP 1 +#define ipconfigUSE_ARP_REMOVE_ENTRY 1 +#define ipconfigARP_STORES_REMOTE_ADDRESSES 1 +#define ipconfigUSE_LINKED_RX_MESSAGES 1 +#define ipconfigFORCE_IP_DONT_FRAGMENT 1 +#define ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS 1 +#define ipconfigDHCP_FALL_BACK_AUTO_IP 1 +#define ipconfigARP_USE_CLASH_DETECTION 1 +#define ipconfigUSE_LLMNR 1 +#define ipconfigUSE_NBNS 1 +#define ipconfigUSE_MDNS 1 +#define ipconfigSUPPORT_OUTGOING_PINGS 1 +#define ipconfigETHERNET_DRIVER_FILTERS_PACKETS 1 +#define ipconfigZERO_COPY_TX_DRIVER 1 +#define ipconfigZERO_COPY_RX_DRIVER 1 +#define ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM 1 +#define ipconfigSOCKET_HAS_USER_SEMAPHORE 1 +#define ipconfigSELECT_USES_NOTIFY 1 +#define ipconfigSUPPORT_SIGNALS 1 +#define ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES 1 /* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to * 1 then FreeRTOS_debug_printf should be defined to the function used to print * out the debugging messages. */ -#define ipconfigHAS_DEBUG_PRINTF 1 +#define ipconfigHAS_DEBUG_PRINTF 1 #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) #define FreeRTOS_debug_printf( X ) configPRINTF( X ) #endif diff --git a/test/build-combination/Common/main.c b/test/build-combination/Common/main.c index 201b6eb0a1..caaa03e922 100644 --- a/test/build-combination/Common/main.c +++ b/test/build-combination/Common/main.c @@ -349,7 +349,7 @@ struct xNetworkInterface * pxFillInterfaceDescriptor( BaseType_t xEMACIndex, } #endif -#if ( ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES != 0) +#if ( ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES != 0 ) /* * The stack will call this user hook for all Ethernet frames that it @@ -363,7 +363,7 @@ struct xNetworkInterface * pxFillInterfaceDescriptor( BaseType_t xEMACIndex, */ eFrameProcessingResult_t eApplicationProcessCustomFrameHook( NetworkBufferDescriptor_t * const pxNetworkBuffer ) { - (void) (pxNetworkBuffer); + ( void ) ( pxNetworkBuffer ); return eProcessBuffer; } From 58c18fa0c5d83fd011700bcd276de47920c74caa Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Mon, 20 Mar 2023 17:15:44 +0530 Subject: [PATCH 12/28] adding doxygen comments to new functions --- source/FreeRTOS_IP_Utils.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index 289c59fb2d..5433bf1e20 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -134,6 +134,14 @@ static void prvSetChecksumInPacket( struct xPacketSummary * pxSet, static uint16_t prvGetChecksumFromPacket( const struct xPacketSummary * pxSet ); +/** + * @brief Set checksum in the packet + * + * @param pxSet: Pointer to the packet summary that describes the packet, + * to which the checksum will be set. + * + * @param usChecksum: Checksum value to be set. + */ static void prvSetChecksumInPacket( struct xPacketSummary * pxSet, uint16_t usChecksum ) { @@ -160,6 +168,14 @@ static void prvSetChecksumInPacket( struct xPacketSummary * pxSet, } } +/** + * @brief Get checksum from the packet summary + * + * @param pxSet: Pointer to the packet summary that describes the packet, + * from which the checksum will be retrieved. + * + * @return Checksum value that is retrieved from pxSet. + */ static uint16_t prvGetChecksumFromPacket( const struct xPacketSummary * pxSet ) { uint16_t usChecksum; From edec1c93392cabe71b50e2c895a3e6f96213adc2 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 20 Mar 2023 11:55:58 +0000 Subject: [PATCH 13/28] Uncrustify: triggered by comment --- source/FreeRTOS_IP_Utils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index 5433bf1e20..d2cea8dd7f 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -136,10 +136,10 @@ static uint16_t prvGetChecksumFromPacket( const struct xPacketSummary * pxSet ); /** * @brief Set checksum in the packet - * + * * @param pxSet: Pointer to the packet summary that describes the packet, * to which the checksum will be set. - * + * * @param usChecksum: Checksum value to be set. */ static void prvSetChecksumInPacket( struct xPacketSummary * pxSet, @@ -170,10 +170,10 @@ static void prvSetChecksumInPacket( struct xPacketSummary * pxSet, /** * @brief Get checksum from the packet summary - * + * * @param pxSet: Pointer to the packet summary that describes the packet, * from which the checksum will be retrieved. - * + * * @return Checksum value that is retrieved from pxSet. */ static uint16_t prvGetChecksumFromPacket( const struct xPacketSummary * pxSet ) From a98682b2cac97656bf50be4443dc42266ada1be4 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Mon, 20 Mar 2023 20:44:03 +0530 Subject: [PATCH 14/28] Add more warnings check and fix warnings --- CMakeLists.txt | 1 + source/FreeRTOS_DNS_Parser.c | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e4ee7e8d5..af76aa226c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,6 +197,7 @@ add_compile_options( $<$:-Wextra> $<$:-Wpedantic> $<$:-Werror> + $<$:-Wunused-variable> $<$:-Weverything> # TODO: Add in other Compilers here. diff --git a/source/FreeRTOS_DNS_Parser.c b/source/FreeRTOS_DNS_Parser.c index 4b9737ce40..79969f341b 100644 --- a/source/FreeRTOS_DNS_Parser.c +++ b/source/FreeRTOS_DNS_Parser.c @@ -313,10 +313,9 @@ xSet.usPortNumber = usPort; xSet.ppxLastAddress = &( xSet.pxLastAddress ); - #if ( ipconfigUSE_LLMNR == 1 ) - uint16_t usType = 0U; - uint16_t usClass = 0U; - #endif + uint16_t usType = 0U; + uint16_t usClass = 0U; + #if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 ) xSet.xDoStore = xExpected; #endif @@ -629,6 +628,10 @@ /* The IP-address found will be returned. */ } + + ( void ) usType; + ( void ) usClass; + return ulIPAddress; } From 65d71214814f5c44880e2836ed343111a0e135cd Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 20 Mar 2023 15:30:33 +0000 Subject: [PATCH 15/28] Uncrustify: triggered by comment --- source/FreeRTOS_DNS_Parser.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/FreeRTOS_DNS_Parser.c b/source/FreeRTOS_DNS_Parser.c index 79969f341b..ccf6cb6681 100644 --- a/source/FreeRTOS_DNS_Parser.c +++ b/source/FreeRTOS_DNS_Parser.c @@ -628,7 +628,6 @@ /* The IP-address found will be returned. */ } - ( void ) usType; ( void ) usClass; From 9fa03fdd8829d7d5dd67de6a993220c303db3950 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Wed, 22 Mar 2023 11:02:14 +0530 Subject: [PATCH 16/28] fix review feedback and more debug printf warnings fix --- source/FreeRTOS_DHCP.c | 2 +- source/FreeRTOS_DHCPv6.c | 18 +++++++++--------- source/FreeRTOS_DNS.c | 2 +- source/FreeRTOS_DNS_Parser.c | 4 ++-- source/FreeRTOS_IP.c | 2 +- source/FreeRTOS_IPv6.c | 2 +- source/FreeRTOS_ND.c | 4 ++-- source/FreeRTOS_RA.c | 8 ++++---- source/FreeRTOS_Routing.c | 4 ++-- source/FreeRTOS_Sockets.c | 6 +++--- source/FreeRTOS_TCP_Transmission.c | 14 +++++++------- source/FreeRTOS_TCP_Utils_IPV6.c | 15 +++++++++++++-- .../NetworkInterface/Common/phyHandling.c | 16 ++++++++-------- .../AllEnable/FreeRTOSIPConfig.h | 4 ++-- 14 files changed, 56 insertions(+), 45 deletions(-) diff --git a/source/FreeRTOS_DHCP.c b/source/FreeRTOS_DHCP.c index c86b7452d5..ba849e6dc2 100644 --- a/source/FreeRTOS_DHCP.c +++ b/source/FreeRTOS_DHCP.c @@ -486,7 +486,7 @@ } else if( prvProcessDHCPReplies( dhcpMESSAGE_TYPE_ACK, pxEndPoint ) == pdPASS ) { - FreeRTOS_debug_printf( ( "vDHCPProcess: acked %lxip\n", FreeRTOS_ntohl( EP_DHCPData.ulOfferedIPAddress ) ) ); + FreeRTOS_debug_printf( ( "vDHCPProcess: acked %xip\n", ( unsigned int ) FreeRTOS_ntohl( EP_DHCPData.ulOfferedIPAddress ) ) ); /* DHCP completed. The IP address can now be used, and the * timer set to the lease timeout time. */ diff --git a/source/FreeRTOS_DHCPv6.c b/source/FreeRTOS_DHCPv6.c index 296fed52c9..6b9ee8c61f 100644 --- a/source/FreeRTOS_DHCPv6.c +++ b/source/FreeRTOS_DHCPv6.c @@ -177,7 +177,7 @@ static void prvCreateDHCPv6Socket( NetworkEndPoint_t * pxEndPoint ); static void prvCloseDHCPv6Socket( NetworkEndPoint_t * pxEndPoint ); #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - const char * prvStateName( eDHCPState_t eState ); + static const char * prvStateName( eDHCPState_t eState ); #endif static BaseType_t xDHCPv6Process_PassReplyToEndPoint( struct xNetworkEndPoint * pxEndPoint ); @@ -248,9 +248,9 @@ static BaseType_t xDHCPv6Process_PassReplyToEndPoint( struct xNetworkEndPoint * { if( ( pxIterator->bits.bIPv6 != pdFALSE_UNSIGNED ) && ( pxIterator->bits.bWantDHCP != pdFALSE_UNSIGNED ) ) { - FreeRTOS_printf( ( "vDHCPProcess: 0x%06lX == 0x%06lX ?\n", - xDHCPMessage.ulTransactionID, - pxIterator->xDHCPData.ulTransactionId ) ); + FreeRTOS_printf( ( "vDHCPProcess: 0x%06X == 0x%06X ?\n", + ( unsigned int ) xDHCPMessage.ulTransactionID, + ( unsigned int ) pxIterator->xDHCPData.ulTransactionId ) ); if( ( xDHCPMessage.ulTransactionID == pxIterator->xDHCPData.ulTransactionId ) && ( pxIterator->xDHCPData.eDHCPState != eLeasedAddress ) ) @@ -325,7 +325,7 @@ void vDHCPv6Process( BaseType_t xReset, } else { - FreeRTOS_printf( ( "vDHCPv6Process: malloc failed %u byt4es\n", sizeof( *pxEndPoint->pxDHCPMessage ) ) ); + FreeRTOS_printf( ( "vDHCPv6Process: malloc failed %lu byt4es\n", sizeof( *pxEndPoint->pxDHCPMessage ) ) ); } } } @@ -386,7 +386,7 @@ void vDHCPv6Process( BaseType_t xReset, static void vDHCPv6ProcessEndPoint_HandleReply( NetworkEndPoint_t * pxEndPoint, DHCPMessage_IPv6_t * pxDHCPMessage ) { - FreeRTOS_printf( ( "vDHCPProcess: acked %lxip\n", FreeRTOS_ntohl( EP_DHCPData.ulOfferedIPAddress ) ) ); + FreeRTOS_printf( ( "vDHCPProcess: acked %x ip\n", ( unsigned int ) FreeRTOS_ntohl( EP_DHCPData.ulOfferedIPAddress ) ) ); /* DHCP completed. The IP address can now be used, and the * timer set to the lease timeout time. */ @@ -923,7 +923,7 @@ static void prvSendDHCPMessage( NetworkEndPoint_t * pxEndPoint ) pxDHCPMessage->ucTransactionID[ 1 ] = ( uint8_t ) ( ( ulTransactionID >> 8 ) & 0xffU ); pxDHCPMessage->ucTransactionID[ 2 ] = ( uint8_t ) ( ulTransactionID & 0xffU ); pxEndPoint->xDHCPData.ulTransactionId = ulTransactionID; - FreeRTOS_debug_printf( ( "Created transaction ID : 0x%06lX\n", ulTransactionID ) ); + FreeRTOS_debug_printf( ( "Created transaction ID : 0x%06X\n", ( unsigned int ) ulTransactionID ) ); } if( ( xRandomOk == pdPASS ) && ( EP_DHCPData.xDHCPSocket != NULL ) ) @@ -1365,7 +1365,7 @@ static BaseType_t prvDHCPv6Analyse( const uint8_t * pucAnswer, if( ulOptionsReceived != dhcpMANDATORY_OPTIONS ) { xResult = pdFAIL; - FreeRTOS_printf( ( "prvDHCPv6Analyse: Missing options: %lX not equal to %lX\n", ulOptionsReceived, dhcpMANDATORY_OPTIONS ) ); + FreeRTOS_printf( ( "prvDHCPv6Analyse: Missing options: %X not equal to %X\n", ( unsigned int ) ulOptionsReceived, ( unsigned int ) dhcpMANDATORY_OPTIONS ) ); } } } /* if( xBitConfig_init() ) */ @@ -1386,7 +1386,7 @@ static BaseType_t prvDHCPv6Analyse( const uint8_t * pucAnswer, * @return A descriptive string. */ #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - const char * prvStateName( eDHCPState_t eState ) + static const char * prvStateName( eDHCPState_t eState ) { const char * pcName; diff --git a/source/FreeRTOS_DNS.c b/source/FreeRTOS_DNS.c index 448f3c56df..931fa88ad2 100644 --- a/source/FreeRTOS_DNS.c +++ b/source/FreeRTOS_DNS.c @@ -607,7 +607,7 @@ } else { - FreeRTOS_printf( ( "prvPrepareLookup: name is too long ( %lu > %lu )\n", + FreeRTOS_printf( ( "prvPrepareLookup: name is too long ( %u > %u )\n", ( unsigned ) uxLength, ( unsigned ) ipconfigDNS_CACHE_NAME_LENGTH ) ); } diff --git a/source/FreeRTOS_DNS_Parser.c b/source/FreeRTOS_DNS_Parser.c index ccf6cb6681..1d5368f0ce 100644 --- a/source/FreeRTOS_DNS_Parser.c +++ b/source/FreeRTOS_DNS_Parser.c @@ -461,8 +461,8 @@ * but in case this has not be done, set it here. */ pxNetworkBuffer->pxEndPoint = prvFindEndPointOnNetMask( pxNetworkBuffer ); - FreeRTOS_printf( ( "prvParseDNS_HandleLLMNRRequest: No pxEndPoint yet? Using %lxip\n", - FreeRTOS_ntohl( pxNetworkBuffer->pxEndPoint ? pxNetworkBuffer->pxEndPoint->ipv4_settings.ulIPAddress : 0U ) ) ); + FreeRTOS_printf( ( "prvParseDNS_HandleLLMNRRequest: No pxEndPoint yet? Using %x ip\n", + ( unsigned int ) FreeRTOS_ntohl( pxNetworkBuffer->pxEndPoint ? pxNetworkBuffer->pxEndPoint->ipv4_settings.ulIPAddress : 0U ) ) ); if( pxNetworkBuffer->pxEndPoint == NULL ) { diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 6f2f41e41e..8599a79bb5 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -2131,7 +2131,7 @@ void vReturnEthernetFrame( NetworkBufferDescriptor_t * pxNetworkBuffer, if( pxNetworkBuffer->pxEndPoint == NULL ) { /* _HT_ I wonder if this ad-hoc search of an end-point it necessary. */ - FreeRTOS_printf( ( "vReturnEthernetFrame: No pxEndPoint yet for %lxip?\n", FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulDestinationIPAddress ) ) ); + FreeRTOS_printf( ( "vReturnEthernetFrame: No pxEndPoint yet for %x ip?\n", ( unsigned int ) FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulDestinationIPAddress ) ) ); /* MISRA Ref 11.3.1 [Misaligned access] */ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ diff --git a/source/FreeRTOS_IPv6.c b/source/FreeRTOS_IPv6.c index 8ddf0315fc..a8276bc316 100644 --- a/source/FreeRTOS_IPv6.c +++ b/source/FreeRTOS_IPv6.c @@ -421,7 +421,7 @@ eFrameProcessingResult_t eHandleIPv6ExtensionHeaders( NetworkBufferDescriptor_t } } - FreeRTOS_printf( ( "Extension headers : %s Truncated %u bytes. Removed %u, Payload %u xDataLength now %u\n", + FreeRTOS_printf( ( "Extension headers : %s Truncated %lu bytes. Removed %lu, Payload %u xDataLength now %lu\n", ( eResult == eProcessBuffer ) ? "good" : "bad", xMoveLen, uxRemovedBytes, diff --git a/source/FreeRTOS_ND.c b/source/FreeRTOS_ND.c index 20421f89ec..a68b41a6d1 100644 --- a/source/FreeRTOS_ND.c +++ b/source/FreeRTOS_ND.c @@ -92,7 +92,7 @@ NetworkEndPoint_t ** ppxEndPoint ); #if ( ipconfigHAS_PRINTF == 1 ) - const char * pcMessageType( BaseType_t xType ); + static const char * pcMessageType( BaseType_t xType ); #endif /** @brief Find the first end-point of type IPv6. */ @@ -820,7 +820,7 @@ * * @return A null-terminated string that represents the type the kind of message. */ - const char * pcMessageType( BaseType_t xType ) + static const char * pcMessageType( BaseType_t xType ) { const char * pcReturn; diff --git a/source/FreeRTOS_RA.c b/source/FreeRTOS_RA.c index c1a05b0ceb..e342991a61 100644 --- a/source/FreeRTOS_RA.c +++ b/source/FreeRTOS_RA.c @@ -270,7 +270,7 @@ if( uxLast < ( uxIndex + uxLength ) ) { - FreeRTOS_printf( ( "RA: Not enough bytes ( %u > %u )\n", ( unsigned ) uxIndex + uxLength, ( unsigned ) uxLast ) ); + FreeRTOS_printf( ( "RA: Not enough bytes ( %lu > %lu )\n", uxIndex + uxLength, uxLast ) ); break; } @@ -295,11 +295,11 @@ /* coverity[misra_c_2012_rule_11_3_violation] */ pxPrefixOption = ( ( ICMPPrefixOption_IPv6_t * ) &( pucBytes[ uxIndex ] ) ); - FreeRTOS_printf( ( "RA: Prefix len %d Life %lu, %lu (%pip)\n", + FreeRTOS_printf( ( "RA: Prefix len %d Life %u, %u (%pip)\n", pxPrefixOption->ucPrefixLength, FreeRTOS_ntohl( pxPrefixOption->ulValidLifeTime ), FreeRTOS_ntohl( pxPrefixOption->ulPreferredLifeTime ), - pxPrefixOption->ucPrefix ) ); + ( void * ) pxPrefixOption->ucPrefix ) ); break; case ndICMP_REDIRECTED_HEADER: /* 4 */ @@ -311,7 +311,7 @@ /* ulChar2u32 returns host-endian numbers. */ ulMTU = ulChar2u32( &( pucBytes[ uxIndex + 4U ] ) ); - FreeRTOS_printf( ( "RA: MTU = %lu\n", ulMTU ) ); + FreeRTOS_printf( ( "RA: MTU = %u\n", ( unsigned int ) ulMTU ) ); } break; diff --git a/source/FreeRTOS_Routing.c b/source/FreeRTOS_Routing.c index 30eab5ec18..a0e83dd728 100644 --- a/source/FreeRTOS_Routing.c +++ b/source/FreeRTOS_Routing.c @@ -291,10 +291,10 @@ void FreeRTOS_FillEndPoint( NetworkInterface_t * pxNetworkInterface, else #endif { - FreeRTOS_printf( ( "FreeRTOS_AddEndPoint: MAC: %02x-%02x IPv4: %lxip\n", + FreeRTOS_printf( ( "FreeRTOS_AddEndPoint: MAC: %02x-%02x IPv4: %xip\n", pxEndPoint->xMACAddress.ucBytes[ 4 ], pxEndPoint->xMACAddress.ucBytes[ 5 ], - FreeRTOS_ntohl( pxEndPoint->ipv4_defaults.ulIPAddress ) ) ); + ( unsigned int ) FreeRTOS_ntohl( pxEndPoint->ipv4_defaults.ulIPAddress ) ) ); } return pxEndPoint; diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index b1be46a121..f2d3384ec6 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -3537,8 +3537,8 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) else { pxSocket->bits.bIsIPv6 = pdFALSE_UNSIGNED; - FreeRTOS_printf( ( "FreeRTOS_connect: %u to %lxip:%u\n", - pxSocket->usLocalPort, FreeRTOS_ntohl( pxAddress->sin_address.ulIP_IPv4 ), FreeRTOS_ntohs( pxAddress->sin_port ) ) ); + FreeRTOS_printf( ( "FreeRTOS_connect: %u to %xip:%u\n", + pxSocket->usLocalPort, ( unsigned int ) FreeRTOS_ntohl( pxAddress->sin_address.ulIP_IPv4 ), FreeRTOS_ntohs( pxAddress->sin_port ) ) ); pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4 = FreeRTOS_ntohl( pxAddress->sin_address.ulIP_IPv4 ); } @@ -5568,7 +5568,7 @@ void * pvSocketGetSocketID( const ConstSocket_t xSocket ) ( void ) snprintf( pcRemoteIp, sizeof( pcRemoteIp ), "%xip", ( unsigned ) pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4 ); } - FreeRTOS_printf( ( "TCP %5d %-*s:%5d %d/%d %-13.13s %6lu %6u%s\n", + FreeRTOS_printf( ( "TCP %5d %-*s:%5d %d/%d %-13.13s %6u %6u%s\n", pxSocket->usLocalPort, /* Local port on this machine */ xIPWidth, pcRemoteIp, /* IP address of remote machine */ diff --git a/source/FreeRTOS_TCP_Transmission.c b/source/FreeRTOS_TCP_Transmission.c index a5c78f66c4..2139e79510 100644 --- a/source/FreeRTOS_TCP_Transmission.c +++ b/source/FreeRTOS_TCP_Transmission.c @@ -414,10 +414,10 @@ if( ( pxTCPWindow->ulOurSequenceNumber + ulDataLen ) != pxTCPWindow->tx.ulFINSequenceNumber ) { pxProtocolHeaders->xTCPHeader.ucTCPFlags &= ( ( uint8_t ) ~tcpTCP_FLAG_FIN ); - FreeRTOS_debug_printf( ( "Suppress FIN for %lu + %lu < %lu\n", - pxTCPWindow->ulOurSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber, - ulDataLen, - pxTCPWindow->tx.ulFINSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber ) ); + FreeRTOS_debug_printf( ( "Suppress FIN for %u + %u < %u\n", + ( unsigned int ) ( pxTCPWindow->ulOurSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber ), + ( unsigned int ) ulDataLen, + ( unsigned int ) ( pxTCPWindow->tx.ulFINSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber ) ) ); } } } @@ -746,9 +746,9 @@ if( pxNetworkBuffer->pxEndPoint == NULL ) { - FreeRTOS_printf( ( "prvTCPReturnPacket: no such end-point %lxip => %lxip\n", - FreeRTOS_ntohl( pxIPHeader->ulSourceIPAddress ), - FreeRTOS_ntohl( pxIPHeader->ulDestinationIPAddress ) ) ); + FreeRTOS_printf( ( "prvTCPReturnPacket: no such end-point %xip => %xip\n", + ( unsigned int ) FreeRTOS_ntohl( pxIPHeader->ulSourceIPAddress ), + ( unsigned int ) FreeRTOS_ntohl( pxIPHeader->ulDestinationIPAddress ) ) ); } } diff --git a/source/FreeRTOS_TCP_Utils_IPV6.c b/source/FreeRTOS_TCP_Utils_IPV6.c index 42b2775558..712f9d4226 100644 --- a/source/FreeRTOS_TCP_Utils_IPV6.c +++ b/source/FreeRTOS_TCP_Utils_IPV6.c @@ -56,6 +56,11 @@ void prvSocketSetMSS_IPV6( FreeRTOS_Socket_t * pxSocket ) { uint32_t ulMSS = ipconfigTCP_MSS; + + #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) + char cBuffer[ 40 ]; + #endif + const NetworkEndPoint_t * pxEndPoint = pxSocket->pxEndPoint; if( pxEndPoint != NULL ) @@ -83,9 +88,15 @@ * smaller. */ ulMSS = FreeRTOS_min_uint32( ( uint32_t ) tcpREDUCED_MSS_THROUGH_INTERNET, ulMSS ); } - } - FreeRTOS_debug_printf( ( "prvSocketSetMSS: %u bytes for %pip port %u\n", ( unsigned ) ulMSS, ( unsigned ) pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, pxSocket->u.xTCP.usRemotePort ) ); + } + + #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) + { + ( void ) FreeRTOS_inet_ntop( FREERTOS_AF_INET6, ( const void * ) pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, cBuffer, sizeof( cBuffer ) ); + FreeRTOS_debug_printf( ( "prvSocketSetMSS: %u bytes for %s ip port %u\n", ( unsigned ) ulMSS, cBuffer, pxSocket->u.xTCP.usRemotePort ) ); + } + #endif pxSocket->u.xTCP.usMSS = ( uint16_t ) ulMSS; } diff --git a/source/portable/NetworkInterface/Common/phyHandling.c b/source/portable/NetworkInterface/Common/phyHandling.c index 50e879fcea..9b55ab3e6e 100644 --- a/source/portable/NetworkInterface/Common/phyHandling.c +++ b/source/portable/NetworkInterface/Common/phyHandling.c @@ -253,7 +253,7 @@ BaseType_t xPhyDiscover( EthernetPhy_t * pxPhyObject ) if( pxPhyObject->xPortCount > 0 ) { - FreeRTOS_printf( ( "PHY ID %lX\n", pxPhyObject->ulPhyIDs[ 0 ] ) ); + FreeRTOS_printf( ( "PHY ID %X\n", ( unsigned int ) pxPhyObject->ulPhyIDs[ 0 ] ) ); } return pxPhyObject->xPortCount; @@ -308,7 +308,7 @@ static uint32_t xPhyReset( EthernetPhy_t * pxPhyObject, if( xTaskCheckForTimeOut( &xTimer, &xRemainingTime ) != pdFALSE ) { - FreeRTOS_printf( ( "xPhyReset: phyBMCR_RESET timed out ( done 0x%02lX )\n", ulDoneMask ) ); + FreeRTOS_printf( ( "xPhyReset: phyBMCR_RESET timed out ( done 0x%02X )\n", ( unsigned int ) ulDoneMask ) ); break; } @@ -487,7 +487,7 @@ BaseType_t xPhyConfigure( EthernetPhy_t * pxPhyObject, pxPhyObject->fnPhyWrite( xPhyAddress, phyREG_19_PHYCR, ulPhyControl ); } - FreeRTOS_printf( ( "+TCP: advertise: %04lX config %04lX\n", ulAdvertise, ulConfig ) ); + FreeRTOS_printf( ( "+TCP: advertise: %04X config %04X\n", ( unsigned int ) ulAdvertise, ( unsigned int ) ulConfig ) ); } /* Keep these values for later use. */ @@ -597,7 +597,7 @@ BaseType_t xPhyStartAutoNegotiation( EthernetPhy_t * pxPhyObject, if( xTaskCheckForTimeOut( &xTimer, &xRemainingTime ) != pdFALSE ) { - FreeRTOS_printf( ( "xPhyStartAutoNegotiation: phyBMSR_AN_COMPLETE timed out ( done 0x%02lX )\n", ulDoneMask ) ); + FreeRTOS_printf( ( "xPhyStartAutoNegotiation: phyBMSR_AN_COMPLETE timed out ( done 0x%02X )\n", ( unsigned int ) ulDoneMask ) ); break; } @@ -726,8 +726,8 @@ BaseType_t xPhyStartAutoNegotiation( EthernetPhy_t * pxPhyObject, pxPhyObject->fnPhyRead( xPhyAddress, PHYREG_10_PHYSTS, &ulRegValue ); } - FreeRTOS_printf( ( "Autonego ready: %08lx: %s duplex %u mbit %s status\n", - ulRegValue, + FreeRTOS_printf( ( "Autonego ready: %08x: %s duplex %u mbit %s status\n", + ( unsigned int ) ulRegValue, ( ulRegValue & phyPHYSTS_DUPLEX_STATUS ) ? "full" : "half", ( ulRegValue & phyPHYSTS_SPEED_STATUS ) ? 10 : 100, ( ( ulPHYLinkStatus |= phyBMSR_LINK_STATUS ) != 0 ) ? "high" : "low" ) ); @@ -775,7 +775,7 @@ BaseType_t xPhyCheckLinkStatus( EthernetPhy_t * pxPhyObject, if( ( pxPhyObject->ulLinkStatusMask & ulBitMask ) == 0UL ) { pxPhyObject->ulLinkStatusMask |= ulBitMask; - FreeRTOS_printf( ( "xPhyCheckLinkStatus: PHY LS now %02lX\n", pxPhyObject->ulLinkStatusMask ) ); + FreeRTOS_printf( ( "xPhyCheckLinkStatus: PHY LS now %02X\n", ( unsigned int ) pxPhyObject->ulLinkStatusMask ) ); xNeedCheck = pdTRUE; } } @@ -802,7 +802,7 @@ BaseType_t xPhyCheckLinkStatus( EthernetPhy_t * pxPhyObject, pxPhyObject->ulLinkStatusMask &= ~( ulBitMask ); } - FreeRTOS_printf( ( "xPhyCheckLinkStatus: PHY LS now %02lX\n", pxPhyObject->ulLinkStatusMask ) ); + FreeRTOS_printf( ( "xPhyCheckLinkStatus: PHY LS now %02X\n", ( unsigned int ) pxPhyObject->ulLinkStatusMask ) ); xNeedCheck = pdTRUE; } } diff --git a/test/build-combination/AllEnable/FreeRTOSIPConfig.h b/test/build-combination/AllEnable/FreeRTOSIPConfig.h index 561c789927..f6c988b63a 100644 --- a/test/build-combination/AllEnable/FreeRTOSIPConfig.h +++ b/test/build-combination/AllEnable/FreeRTOSIPConfig.h @@ -62,7 +62,7 @@ * out the debugging messages. */ #define ipconfigHAS_DEBUG_PRINTF 1 #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - #define FreeRTOS_debug_printf( X ) configPRINTF( X ) + #define FreeRTOS_debug_printf( X ) printf X #endif /* Set to 1 to print out non debugging messages, for example the output of the @@ -71,7 +71,7 @@ * messages. */ #define ipconfigHAS_PRINTF 1 #if ( ipconfigHAS_PRINTF == 1 ) - #define FreeRTOS_printf( X ) configPRINTF( X ) + #define FreeRTOS_printf( X ) printf X #endif /* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing From de51dc47b06b56462aa977b0fc156d85be5b6368 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Wed, 22 Mar 2023 11:41:07 +0530 Subject: [PATCH 17/28] more warnings fix --- source/FreeRTOS_IP_Utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index d2cea8dd7f..1bc295b88f 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -1469,7 +1469,7 @@ const char * FreeRTOS_strerror_r( BaseType_t xErrnum, /* MISRA Ref 21.6.1 [snprintf and logging] */ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-216 */ /* coverity[misra_c_2012_rule_21_6_violation] */ - ( void ) snprintf( pcBuffer, uxLength, "Errno %u", ( uint32_t ) xErrnum ); + ( void ) snprintf( pcBuffer, uxLength, "Errno %d", ( int ) xErrnum ); pcName = NULL; break; } From 958e3d4e8ef030c22d62274445aecd6af3a2b714 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Wed, 22 Mar 2023 11:52:51 +0530 Subject: [PATCH 18/28] fix misra issues --- source/FreeRTOS_IP_Utils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index 1bc295b88f..05599deaa2 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -127,9 +127,9 @@ static void prvChecksumProtocolCalculate( BaseType_t xOutgoingPacket, static void prvChecksumProtocolSetChecksum( BaseType_t xOutgoingPacket, const uint8_t * pucEthernetBuffer, size_t uxBufferLength, - struct xPacketSummary * pxSet ); + const struct xPacketSummary * pxSet ); -static void prvSetChecksumInPacket( struct xPacketSummary * pxSet, +static void prvSetChecksumInPacket( const struct xPacketSummary * pxSet, uint16_t usChecksum ); static uint16_t prvGetChecksumFromPacket( const struct xPacketSummary * pxSet ); @@ -142,7 +142,7 @@ static uint16_t prvGetChecksumFromPacket( const struct xPacketSummary * pxSet ); * * @param usChecksum: Checksum value to be set. */ -static void prvSetChecksumInPacket( struct xPacketSummary * pxSet, +static void prvSetChecksumInPacket( const struct xPacketSummary * pxSet, uint16_t usChecksum ) { if( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) @@ -620,7 +620,7 @@ static void prvChecksumProtocolCalculate( BaseType_t xOutgoingPacket, static void prvChecksumProtocolSetChecksum( BaseType_t xOutgoingPacket, const uint8_t * pucEthernetBuffer, size_t uxBufferLength, - struct xPacketSummary * pxSet ) + const struct xPacketSummary * pxSet ) { if( xOutgoingPacket != pdFALSE ) { From e0b9162cf0e6e28e66fbefa83ff9a42c11fb295a Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 22 Mar 2023 06:36:34 +0000 Subject: [PATCH 19/28] Uncrustify: triggered by comment --- source/FreeRTOS_TCP_Transmission.c | 6 +++--- source/FreeRTOS_TCP_Utils_IPV6.c | 13 ++++++------- test/build-combination/AllEnable/FreeRTOSIPConfig.h | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/source/FreeRTOS_TCP_Transmission.c b/source/FreeRTOS_TCP_Transmission.c index 2139e79510..82c3bbf854 100644 --- a/source/FreeRTOS_TCP_Transmission.c +++ b/source/FreeRTOS_TCP_Transmission.c @@ -415,9 +415,9 @@ { pxProtocolHeaders->xTCPHeader.ucTCPFlags &= ( ( uint8_t ) ~tcpTCP_FLAG_FIN ); FreeRTOS_debug_printf( ( "Suppress FIN for %u + %u < %u\n", - ( unsigned int ) ( pxTCPWindow->ulOurSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber ), - ( unsigned int ) ulDataLen, - ( unsigned int ) ( pxTCPWindow->tx.ulFINSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber ) ) ); + ( unsigned int ) ( pxTCPWindow->ulOurSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber ), + ( unsigned int ) ulDataLen, + ( unsigned int ) ( pxTCPWindow->tx.ulFINSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber ) ) ); } } } diff --git a/source/FreeRTOS_TCP_Utils_IPV6.c b/source/FreeRTOS_TCP_Utils_IPV6.c index 712f9d4226..4ee108a960 100644 --- a/source/FreeRTOS_TCP_Utils_IPV6.c +++ b/source/FreeRTOS_TCP_Utils_IPV6.c @@ -56,7 +56,7 @@ void prvSocketSetMSS_IPV6( FreeRTOS_Socket_t * pxSocket ) { uint32_t ulMSS = ipconfigTCP_MSS; - + #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) char cBuffer[ 40 ]; #endif @@ -88,14 +88,13 @@ * smaller. */ ulMSS = FreeRTOS_min_uint32( ( uint32_t ) tcpREDUCED_MSS_THROUGH_INTERNET, ulMSS ); } - } - + #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - { - ( void ) FreeRTOS_inet_ntop( FREERTOS_AF_INET6, ( const void * ) pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, cBuffer, sizeof( cBuffer ) ); - FreeRTOS_debug_printf( ( "prvSocketSetMSS: %u bytes for %s ip port %u\n", ( unsigned ) ulMSS, cBuffer, pxSocket->u.xTCP.usRemotePort ) ); - } + { + ( void ) FreeRTOS_inet_ntop( FREERTOS_AF_INET6, ( const void * ) pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, cBuffer, sizeof( cBuffer ) ); + FreeRTOS_debug_printf( ( "prvSocketSetMSS: %u bytes for %s ip port %u\n", ( unsigned ) ulMSS, cBuffer, pxSocket->u.xTCP.usRemotePort ) ); + } #endif pxSocket->u.xTCP.usMSS = ( uint16_t ) ulMSS; diff --git a/test/build-combination/AllEnable/FreeRTOSIPConfig.h b/test/build-combination/AllEnable/FreeRTOSIPConfig.h index f6c988b63a..4e7833bca9 100644 --- a/test/build-combination/AllEnable/FreeRTOSIPConfig.h +++ b/test/build-combination/AllEnable/FreeRTOSIPConfig.h @@ -62,7 +62,7 @@ * out the debugging messages. */ #define ipconfigHAS_DEBUG_PRINTF 1 #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - #define FreeRTOS_debug_printf( X ) printf X + #define FreeRTOS_debug_printf( X ) printf X #endif /* Set to 1 to print out non debugging messages, for example the output of the @@ -71,7 +71,7 @@ * messages. */ #define ipconfigHAS_PRINTF 1 #if ( ipconfigHAS_PRINTF == 1 ) - #define FreeRTOS_printf( X ) printf X + #define FreeRTOS_printf( X ) printf X #endif /* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing From d44c84609ced0d083f3eafe05f44bb1f0b1742bc Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Thu, 23 Mar 2023 12:05:31 +0530 Subject: [PATCH 20/28] replace sin_addr with sin_address.ulIP_IPv4 in +TCP demos --- tools/tcp_utilities/NTPDemo.c | 8 ++++---- tools/tcp_utilities/http_client_test.c | 14 +++++++------- tools/tcp_utilities/plus_tcp_demo_cli.c | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/tcp_utilities/NTPDemo.c b/tools/tcp_utilities/NTPDemo.c index a6695af5af..945383af79 100644 --- a/tools/tcp_utilities/NTPDemo.c +++ b/tools/tcp_utilities/NTPDemo.c @@ -230,7 +230,7 @@ void vStartNTPTask( uint16_t usTaskStackSize, BaseType_t xReceiveTimeOut = pdMS_TO_TICKS( 5000 ); #endif - xAddress.sin_addr = 0ul; + xAddress.sin_address.ulIP_IPv4 = 0ul; xAddress.sin_port = FreeRTOS_htons( NTP_PORT ); FreeRTOS_bind( xNTP_UDPSocket, &xAddress, sizeof( xAddress ) ); @@ -268,7 +268,7 @@ void vStartNTPTask( uint16_t usTaskStackSize, char pcBuf[ 16 ]; /* The DNS lookup has a result, or it has reached the time-out. */ - ulIPAddressFound = pxAddress->ai_addr->sin_addr; + ulIPAddressFound = pxAddress->ai_addr->sin_address.ulIP_IPv4; FreeRTOS_inet_ntoa( ulIPAddressFound, pcBuf ); FreeRTOS_printf( ( "vDNS_callback: IP address of '%s' found: %s\n", pcName, pcBuf ) ); @@ -628,11 +628,11 @@ static void prvNTPTask( void * pvParameters ) else #endif /* ( ipconfigUSE_IPv6 != 0 ) */ { - xAddress.sin_addr = ulIPAddressFound; + xAddress.sin_address.ulIP_IPv4 = ulIPAddressFound; xAddress.sin_port = FreeRTOS_htons( NTP_PORT ); FreeRTOS_printf( ( "Sending UDP message to %xip port %u\n", - ( unsigned ) FreeRTOS_ntohl( xAddress.sin_addr ), + ( unsigned ) FreeRTOS_ntohl( xAddress.sin_address.ulIP_IPv4 ), ( unsigned ) FreeRTOS_ntohs( xAddress.sin_port ) ) ); FreeRTOS_sendto( xNTP_UDPSocket, diff --git a/tools/tcp_utilities/http_client_test.c b/tools/tcp_utilities/http_client_test.c index a364d57f5c..2564b5c499 100644 --- a/tools/tcp_utilities/http_client_test.c +++ b/tools/tcp_utilities/http_client_test.c @@ -331,8 +331,8 @@ if( pxResult->ai_family == FREERTOS_AF_INET4 ) { -/* ulIPAddress = ( ( struct freertos_sockaddr * ) pxResult->ai_addr )->sin_addr; */ - ulIPAddress = pxResult->ai_addr->sin_addr; +/* ulIPAddress = ( ( struct freertos_sockaddr * ) pxResult->ai_addr )->sin_address.ulIP_IPv4; */ + ulIPAddress = pxResult->ai_addr->sin_address.ulIP_IPv4; } #if ( ipconfigUSE_IPv6 != 0 ) @@ -368,7 +368,7 @@ pxAddress->sin_len = sizeof( struct freertos_sockaddr ); pxAddress->sin_family = FREERTOS_AF_INET; pxAddress->sin_port = FreeRTOS_htons( usUsePortNumber ); - pxAddress->sin_addr = ulIPAddress; + pxAddress->sin_address.ulIP_IPv4 = ulIPAddress; } else { @@ -400,11 +400,11 @@ else #endif /* if ( ipconfigUSE_IPv6 != 0 ) */ { - pxEndPoint = FreeRTOS_FindEndPointOnNetMask( pxAddress->sin_addr, 9999 ); + pxEndPoint = FreeRTOS_FindEndPointOnNetMask( pxAddress->sin_address.ulIP_IPv4, 9999 ); if( pxEndPoint != NULL ) { - xBindAddress.sin_addr = pxEndPoint->ipv4_settings.ulIPAddress; + xBindAddress.sin_address.ulIP_IPv4 = pxEndPoint->ipv4_settings.ulIPAddress; } } #endif /* if ( ipconfigMULTI_INTERFACE != 0 ) */ @@ -450,9 +450,9 @@ #endif { FreeRTOS_printf( ( "httpTest: FreeRTOS_connect from %lxip port %u to %lxip port %u: rc %d\n", - FreeRTOS_ntohl( pxLocalAddress->sin_addr ), + FreeRTOS_ntohl( pxLocalAddress->sin_address.ulIP_IPv4 ), FreeRTOS_ntohs( pxLocalAddress->sin_port ), - FreeRTOS_ntohl( pxAddress->sin_addr ), + FreeRTOS_ntohl( pxAddress->sin_address.ulIP_IPv4 ), FreeRTOS_ntohs( pxAddress->sin_port ), rc ) ); } diff --git a/tools/tcp_utilities/plus_tcp_demo_cli.c b/tools/tcp_utilities/plus_tcp_demo_cli.c index baf57faeb7..3beb05ba65 100644 --- a/tools/tcp_utilities/plus_tcp_demo_cli.c +++ b/tools/tcp_utilities/plus_tcp_demo_cli.c @@ -1001,12 +1001,12 @@ static void handle_help( char * pcBuffer ) else #endif /* if ( ipconfigUSE_IPv6 != 0 ) */ { - FreeRTOS_printf( ( "ping4 to '%s' (%xip)\n", pcHostname, ( unsigned ) FreeRTOS_ntohl( pxDNSResult->ai_addr->sin_addr ) ) ); + FreeRTOS_printf( ( "ping4 to '%s' (%xip)\n", pcHostname, ( unsigned ) FreeRTOS_ntohl( pxDNSResult->ai_addr->sin_address.ulIP_IPv4 ) ) ); xPing4Count = 0; #if ( ipconfigUSE_IPv6 != 0 ) xPing6Count = -1; #endif - ulPingIPAddress = pxDNSResult->ai_addr->sin_addr; + ulPingIPAddress = pxDNSResult->ai_addr->sin_address.ulIP_IPv4; xARPWaitResolution( ulPingIPAddress, pdMS_TO_TICKS( 5000U ) ); FreeRTOS_SendPingRequest( ulPingIPAddress, uxPingSize, PING_TIMEOUT ); uxPingTimes[ 0 ] = ( TickType_t ) ullGetHighResolutionTime(); @@ -1351,7 +1351,7 @@ void xHandleTesting() else #endif /* ipconfigUSE_IPv6 */ { - uint32_t luIPAddress = pxResult->ai_addr->sin_addr; + uint32_t luIPAddress = pxResult->ai_addr->sin_address.ulIP_IPv4; FreeRTOS_printf( ( "dns query%d: '%s' = %lxip rc = %d\n", ( int ) xIPVersion, pcHost, FreeRTOS_ntohl( luIPAddress ), ( int ) rc ) ); } } @@ -1413,7 +1413,7 @@ void xHandleTesting() #if ( ipconfigUSE_DNS_CACHE != 0 ) ulIpAddress = FreeRTOS_dnslookup( pcHost ); FreeRTOS_printf( ( "Lookup4 '%s' = %lxip\n", pcHost, FreeRTOS_ntohl( ulIpAddress ) ) ); - pxResult->ai_addr->sin_addr = ulIpAddress; + pxResult->ai_addr->sin_address.ulIP_IPv4 = ulIpAddress; pxResult->ai_family = FREERTOS_AF_INET4; pxResult->ai_addrlen = ipSIZE_OF_IPv4_ADDRESS; #endif From 0180c4b8e1d0f511c81bae8fe28f7c2ff4df0002 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Thu, 23 Mar 2023 12:08:02 +0530 Subject: [PATCH 21/28] replace sin_addr6 with sin_address.xIP_IPv6 in +TCP demos --- tools/tcp_utilities/NTPDemo.c | 10 +++++----- tools/tcp_utilities/http_client_test.c | 10 +++++----- tools/tcp_utilities/plus_tcp_demo_cli.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/tcp_utilities/NTPDemo.c b/tools/tcp_utilities/NTPDemo.c index 945383af79..16266740c7 100644 --- a/tools/tcp_utilities/NTPDemo.c +++ b/tools/tcp_utilities/NTPDemo.c @@ -274,7 +274,7 @@ void vStartNTPTask( uint16_t usTaskStackSize, if( ulIPAddressFound != 0U ) { - memset( xIPAddressFound.sin_addr6.ucBytes, 0, ipSIZE_OF_IPv6_ADDRESS ); + memset( xIPAddressFound.sin_address.xIP_IPv6.ucBytes, 0, ipSIZE_OF_IPv6_ADDRESS ); xHasIPAddress = pdTRUE; xStatus = EStatusAsking; } @@ -288,9 +288,9 @@ void vStartNTPTask( uint16_t usTaskStackSize, xIPAddressFound.sin_family = FREERTOS_AF_INET6; /* Set to FREERTOS_AF_INET6. */ xIPAddressFound.sin_port = FreeRTOS_htons( NTP_PORT ); xIPAddressFound.sin_flowinfo = 0; /* IPv6 flow information. */ - memcpy( xIPAddressFound.sin_addr6.ucBytes, sockaddr6->sin_addr6.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); + memcpy( xIPAddressFound.sin_address.xIP_IPv6.ucBytes, sockaddr6->sin_address.xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); - FreeRTOS_printf( ( "vDNS_callback: using address %pip\n", xIPAddressFound.sin_addr6.ucBytes ) ); + FreeRTOS_printf( ( "vDNS_callback: using address %pip\n", xIPAddressFound.sin_address.xIP_IPv6.ucBytes ) ); ulIPAddressFound = 0U; xHasIPAddress = pdTRUE; xStatus = EStatusAsking; @@ -613,10 +613,10 @@ static void prvNTPTask( void * pvParameters ) prvNTPPacketInit(); uxSendTime = xTaskGetTickCount(); #if ( ipconfigUSE_IPv6 != 0 ) - if( memcmp( xIPAddressFound.sin_addr6.ucBytes, FreeRTOS_in6addr_any.ucBytes, ipSIZE_OF_IPv6_ADDRESS ) != 0 ) + if( memcmp( xIPAddressFound.sin_address.xIP_IPv6.ucBytes, FreeRTOS_in6addr_any.ucBytes, ipSIZE_OF_IPv6_ADDRESS ) != 0 ) { FreeRTOS_printf( ( "Sending UDP message to %pip port %u\n", - xIPAddressFound.sin_addr6.ucBytes, + xIPAddressFound.sin_address.xIP_IPv6.ucBytes, FreeRTOS_ntohs( xIPAddressFound.sin_port ) ) ); FreeRTOS_sendto( xNTP_UDPSocket, diff --git a/tools/tcp_utilities/http_client_test.c b/tools/tcp_utilities/http_client_test.c index 2564b5c499..063a9790ff 100644 --- a/tools/tcp_utilities/http_client_test.c +++ b/tools/tcp_utilities/http_client_test.c @@ -341,7 +341,7 @@ struct freertos_sockaddr6 * pxAddr6; pxAddr6 = ( struct freertos_sockaddr6 * ) pxResult->ai_addr; - memcpy( xIPAddress_IPv6.ucBytes, pxAddr6->sin_addr6.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); + memcpy( xIPAddress_IPv6.ucBytes, pxAddr6->sin_address.xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); xHasIPv6Address = pdTRUE; } #endif @@ -358,7 +358,7 @@ xEchoServerAddress.sin_len = sizeof( struct freertos_sockaddr6 ); xEchoServerAddress.sin_family = FREERTOS_AF_INET6; xEchoServerAddress.sin_port = FreeRTOS_htons( usUsePortNumber ); - memcpy( xEchoServerAddress.sin_addr6.ucBytes, xIPAddress_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); + memcpy( xEchoServerAddress.sin_address.xIP_IPv6.ucBytes, xIPAddress_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); } else #endif @@ -385,7 +385,7 @@ #if ( ipconfigUSE_IPv6 != 0 ) if( xEchoServerAddress.sin_family == FREERTOS_AF_INET6 ) { - pxEndPoint = FreeRTOS_FindEndPointOnNetMask_IPv6( &( xEchoServerAddress.sin_addr6 ) ); + pxEndPoint = FreeRTOS_FindEndPointOnNetMask_IPv6( &( xEchoServerAddress.sin_address.xIP_IPv6 ) ); if( pxEndPoint == NULL ) { @@ -394,7 +394,7 @@ if( pxEndPoint != NULL ) { - /*memcpy( xEchoServerAddress.sin_addr6.ucBytes, pxEndPoint->ipv6.xIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); */ + /*memcpy( xEchoServerAddress.sin_address.xIP_IPv6.ucBytes, pxEndPoint->ipv6.xIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); */ } } else @@ -442,7 +442,7 @@ if( pxAddress->sin_family == FREERTOS_AF_INET6 ) { FreeRTOS_printf( ( "httpTest: FreeRTOS_connect to %pip port %u: rc %d\n", - xEchoServerAddress.sin_addr6.ucBytes, + xEchoServerAddress.sin_address.xIP_IPv6.ucBytes, FreeRTOS_ntohs( pxAddress->sin_port ), rc ) ); } diff --git a/tools/tcp_utilities/plus_tcp_demo_cli.c b/tools/tcp_utilities/plus_tcp_demo_cli.c index 3beb05ba65..8c6553c169 100644 --- a/tools/tcp_utilities/plus_tcp_demo_cli.c +++ b/tools/tcp_utilities/plus_tcp_demo_cli.c @@ -1346,7 +1346,7 @@ void xHandleTesting() struct freertos_sockaddr * pxAddr6; pxAddr6 = ( struct freertos_sockaddr * ) pxResult->ai_addr; - FreeRTOS_printf( ( "dns query%d: '%s' = %pip rc = %d\n", ( int ) xIPVersion, pcHost, pxAddr6->sin_addr6.ucBytes, ( int ) rc ) ); + FreeRTOS_printf( ( "dns query%d: '%s' = %pip rc = %d\n", ( int ) xIPVersion, pcHost, pxAddr6->sin_address.xIP_IPv6.ucBytes, ( int ) rc ) ); } else #endif /* ipconfigUSE_IPv6 */ From fb91aa5b0b52abcdcef97fedebe9e4eabee929fe Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Thu, 23 Mar 2023 12:14:49 +0530 Subject: [PATCH 22/28] replace freertos_sockaddr6 with freertos_sockaddr in +TCP demos --- tools/tcp_utilities/NTPDemo.c | 6 ++---- tools/tcp_utilities/http_client_test.c | 16 +++++----------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/tools/tcp_utilities/NTPDemo.c b/tools/tcp_utilities/NTPDemo.c index 16266740c7..bd48e251c8 100644 --- a/tools/tcp_utilities/NTPDemo.c +++ b/tools/tcp_utilities/NTPDemo.c @@ -109,9 +109,7 @@ static const char * pcTimeServers[] = static SemaphoreHandle_t xNTPWakeupSem = NULL; static uint32_t ulIPAddressFound; -#if ( ipconfigUSE_IPv6 != 0 ) - static struct freertos_sockaddr6 xIPAddressFound; -#endif +static struct freertos_sockaddr xIPAddressFound; static BaseType_t xHasIPAddress = pdFALSE; static Socket_t xNTP_UDPSocket = NULL; @@ -282,7 +280,7 @@ void vStartNTPTask( uint16_t usTaskStackSize, else if( pxAddress->ai_family == FREERTOS_AF_INET6 ) { /* struct freertos_sockaddr * ai_addr */ - struct freertos_sockaddr6 * sockaddr6 = ( struct freertos_sockaddr6 * ) pxAddress->ai_addr; + struct freertos_sockaddr * sockaddr6 = ( struct freertos_sockaddr * ) pxAddress->ai_addr; xIPAddressFound.sin_len = sizeof( xIPAddressFound ); /* Ignored, still present for backward compatibility. */ xIPAddressFound.sin_family = FREERTOS_AF_INET6; /* Set to FREERTOS_AF_INET6. */ diff --git a/tools/tcp_utilities/http_client_test.c b/tools/tcp_utilities/http_client_test.c index 063a9790ff..e1009e8bce 100644 --- a/tools/tcp_utilities/http_client_test.c +++ b/tools/tcp_utilities/http_client_test.c @@ -208,11 +208,7 @@ { Socket_t xSocket = NULL; - #if ( ipconfigUSE_IPv6 != 0 ) - struct freertos_sockaddr6 xEchoServerAddress; - #else - struct freertos_sockaddr xEchoServerAddress; - #endif + struct freertos_sockaddr xEchoServerAddress; size_t uxInstance; int32_t xReturned, xReceivedBytes; @@ -265,10 +261,8 @@ TickType_t xSendTimeOut = pdMS_TO_TICKS( 2000U ); #if ( ipconfigUSE_IPv6 != 0 ) IPv6_Address_t xIPAddress_IPv6; - struct freertos_sockaddr6 xLocalAddress; - #else - struct freertos_sockaddr xLocalAddress; #endif + struct freertos_sockaddr xLocalAddress; #if ( ipconfigMULTI_INTERFACE != 0 ) struct freertos_addrinfo * pxResult = NULL; struct freertos_addrinfo xHints; @@ -338,9 +332,9 @@ #if ( ipconfigUSE_IPv6 != 0 ) else if( pxResult->ai_family == FREERTOS_AF_INET6 ) { - struct freertos_sockaddr6 * pxAddr6; + struct freertos_sockaddr * pxAddr6; - pxAddr6 = ( struct freertos_sockaddr6 * ) pxResult->ai_addr; + pxAddr6 = ( struct freertos_sockaddr * ) pxResult->ai_addr; memcpy( xIPAddress_IPv6.ucBytes, pxAddr6->sin_address.xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); xHasIPv6Address = pdTRUE; } @@ -355,7 +349,7 @@ #if ( ipconfigUSE_IPv6 != 0 ) if( xHasIPv6Address != 0 ) { - xEchoServerAddress.sin_len = sizeof( struct freertos_sockaddr6 ); + xEchoServerAddress.sin_len = sizeof( struct freertos_sockaddr ); xEchoServerAddress.sin_family = FREERTOS_AF_INET6; xEchoServerAddress.sin_port = FreeRTOS_htons( usUsePortNumber ); memcpy( xEchoServerAddress.sin_address.xIP_IPv6.ucBytes, xIPAddress_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); From 68b1dc2f31da9e1d52c7f1a5d2ce1bee090b55ef Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Thu, 23 Mar 2023 17:59:45 +0530 Subject: [PATCH 23/28] review feedback changes --- source/FreeRTOS_DHCPv6.c | 4 ++-- source/FreeRTOS_IPv6.c | 8 ++++---- source/FreeRTOS_RA.c | 4 ++-- source/FreeRTOS_Routing.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/FreeRTOS_DHCPv6.c b/source/FreeRTOS_DHCPv6.c index 6b9ee8c61f..7cd0875fae 100644 --- a/source/FreeRTOS_DHCPv6.c +++ b/source/FreeRTOS_DHCPv6.c @@ -325,7 +325,7 @@ void vDHCPv6Process( BaseType_t xReset, } else { - FreeRTOS_printf( ( "vDHCPv6Process: malloc failed %lu byt4es\n", sizeof( *pxEndPoint->pxDHCPMessage ) ) ); + FreeRTOS_printf( ( "vDHCPv6Process: malloc failed %u bytes\n", ( unsigned ) sizeof( *pxEndPoint->pxDHCPMessage ) ) ); } } } @@ -386,7 +386,7 @@ void vDHCPv6Process( BaseType_t xReset, static void vDHCPv6ProcessEndPoint_HandleReply( NetworkEndPoint_t * pxEndPoint, DHCPMessage_IPv6_t * pxDHCPMessage ) { - FreeRTOS_printf( ( "vDHCPProcess: acked %x ip\n", ( unsigned int ) FreeRTOS_ntohl( EP_DHCPData.ulOfferedIPAddress ) ) ); + FreeRTOS_printf( ( "vDHCPProcess: acked %xip\n", ( unsigned int ) FreeRTOS_ntohl( EP_DHCPData.ulOfferedIPAddress ) ) ); /* DHCP completed. The IP address can now be used, and the * timer set to the lease timeout time. */ diff --git a/source/FreeRTOS_IPv6.c b/source/FreeRTOS_IPv6.c index a8276bc316..74c3481d3e 100644 --- a/source/FreeRTOS_IPv6.c +++ b/source/FreeRTOS_IPv6.c @@ -421,12 +421,12 @@ eFrameProcessingResult_t eHandleIPv6ExtensionHeaders( NetworkBufferDescriptor_t } } - FreeRTOS_printf( ( "Extension headers : %s Truncated %lu bytes. Removed %lu, Payload %u xDataLength now %lu\n", + FreeRTOS_printf( ( "Extension headers : %s Truncated %u bytes. Removed %u, Payload %u xDataLength now %u\n", ( eResult == eProcessBuffer ) ? "good" : "bad", - xMoveLen, - uxRemovedBytes, + ( unsigned ) xMoveLen, + ( unsigned ) uxRemovedBytes, FreeRTOS_ntohs( pxIPPacket_IPv6->xIPHeader.usPayloadLength ), - pxNetworkBuffer->xDataLength ) ); + ( unsigned ) pxNetworkBuffer->xDataLength ) ); return eResult; } diff --git a/source/FreeRTOS_RA.c b/source/FreeRTOS_RA.c index e342991a61..427c5b7d26 100644 --- a/source/FreeRTOS_RA.c +++ b/source/FreeRTOS_RA.c @@ -270,7 +270,7 @@ if( uxLast < ( uxIndex + uxLength ) ) { - FreeRTOS_printf( ( "RA: Not enough bytes ( %lu > %lu )\n", uxIndex + uxLength, uxLast ) ); + FreeRTOS_printf( ( "RA: Not enough bytes ( %u > %u )\n", ( unsigned ) ( uxIndex + uxLength ), ( unsigned ) uxLast ) ); break; } @@ -299,7 +299,7 @@ pxPrefixOption->ucPrefixLength, FreeRTOS_ntohl( pxPrefixOption->ulValidLifeTime ), FreeRTOS_ntohl( pxPrefixOption->ulPreferredLifeTime ), - ( void * ) pxPrefixOption->ucPrefix ) ); + pxPrefixOption->ucPrefix ) ); break; case ndICMP_REDIRECTED_HEADER: /* 4 */ diff --git a/source/FreeRTOS_Routing.c b/source/FreeRTOS_Routing.c index a0e83dd728..de32a2ae36 100644 --- a/source/FreeRTOS_Routing.c +++ b/source/FreeRTOS_Routing.c @@ -294,7 +294,7 @@ void FreeRTOS_FillEndPoint( NetworkInterface_t * pxNetworkInterface, FreeRTOS_printf( ( "FreeRTOS_AddEndPoint: MAC: %02x-%02x IPv4: %xip\n", pxEndPoint->xMACAddress.ucBytes[ 4 ], pxEndPoint->xMACAddress.ucBytes[ 5 ], - ( unsigned int ) FreeRTOS_ntohl( pxEndPoint->ipv4_defaults.ulIPAddress ) ) ); + ( unsigned ) FreeRTOS_ntohl( pxEndPoint->ipv4_defaults.ulIPAddress ) ) ); } return pxEndPoint; From f34c139854b28ca1810c903ae6a8a8ca3f0b2f5a Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 24 Mar 2023 09:16:41 +0530 Subject: [PATCH 24/28] removing duplicate def for prvStreamBufferAdd from winpcap --- .../WinPCap/NetworkInterface.c | 52 ------------------- 1 file changed, 52 deletions(-) diff --git a/source/portable/NetworkInterface/WinPCap/NetworkInterface.c b/source/portable/NetworkInterface/WinPCap/NetworkInterface.c index cf0fdd8df2..4398aedaa0 100644 --- a/source/portable/NetworkInterface/WinPCap/NetworkInterface.c +++ b/source/portable/NetworkInterface/WinPCap/NetworkInterface.c @@ -288,58 +288,6 @@ static size_t prvStreamBufferAdd( StreamBuffer_t * pxBuffer, /*-----------------------------------------------------------*/ -static size_t prvStreamBufferAdd( StreamBuffer_t * pxBuffer, - const uint8_t * pucData, - size_t uxByteCount ) -{ - size_t uxSpace, uxNextHead, uxFirst; - size_t uxCount = uxByteCount; - - uxSpace = uxStreamBufferGetSpace( pxBuffer ); - - /* The number of bytes that can be written is the minimum of the number of - * bytes requested and the number available. */ - uxCount = FreeRTOS_min_size_t( uxSpace, uxCount ); - - if( uxCount != 0U ) - { - uxNextHead = pxBuffer->uxHead; - - if( pucData != NULL ) - { - /* Calculate the number of bytes that can be added in the first - * write - which may be less than the total number of bytes that need - * to be added if the buffer will wrap back to the beginning. */ - uxFirst = FreeRTOS_min_size_t( pxBuffer->LENGTH - uxNextHead, uxCount ); - - /* Write as many bytes as can be written in the first write. */ - ( void ) memcpy( &( pxBuffer->ucArray[ uxNextHead ] ), pucData, uxFirst ); - - /* If the number of bytes written was less than the number that - * could be written in the first write... */ - if( uxCount > uxFirst ) - { - /* ...then write the remaining bytes to the start of the - * buffer. */ - ( void ) memcpy( pxBuffer->ucArray, &( pucData[ uxFirst ] ), uxCount - uxFirst ); - } - } - - uxNextHead += uxCount; - - if( uxNextHead >= pxBuffer->LENGTH ) - { - uxNextHead -= pxBuffer->LENGTH; - } - - pxBuffer->uxHead = uxNextHead; - } - - return uxCount; -} - -/*-----------------------------------------------------------*/ - static BaseType_t xWinPcap_NetworkInterfaceOutput( NetworkInterface_t * pxInterface, NetworkBufferDescriptor_t * const pxNetworkBuffer, BaseType_t bReleaseAfterSend ) From 38ad56c4411b5b1c291624e8f94d19e8a722428e Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 24 Mar 2023 14:34:13 +0530 Subject: [PATCH 25/28] fix more warnings from MSVC --- source/FreeRTOS_DNS_Parser.c | 7 ++++++- source/FreeRTOS_IP_Utils.c | 8 ++++---- source/FreeRTOS_TCP_State_Handling_IPV6.c | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/FreeRTOS_DNS_Parser.c b/source/FreeRTOS_DNS_Parser.c index 1d5368f0ce..3c5a3be331 100644 --- a/source/FreeRTOS_DNS_Parser.c +++ b/source/FreeRTOS_DNS_Parser.c @@ -582,7 +582,7 @@ ( void ) memcpy( &( pxAnswer->ulIPAddress ), xEndPoint.ipv6_settings.xIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); uxDistance = ( size_t ) ( xSet.pucByte - pucNewBuffer ); /* An extra 12 bytes will be sent compared to an A-record. */ - usLength = ( int16_t ) sizeof( *pxAnswer ) + uxDistance + ipSIZE_OF_IPv6_ADDRESS - sizeof( pxAnswer->ulIPAddress ); + usLength = ( int16_t ) ( sizeof( *pxAnswer ) + uxDistance + ipSIZE_OF_IPv6_ADDRESS - sizeof( pxAnswer->ulIPAddress ) ); } else { @@ -1045,6 +1045,11 @@ NetworkEndPoint_t xEndPoint; BaseType_t xMustReply = pdFALSE; + /* Not used for now */ + ( void ) uxBufferLength; + ( void ) uxBytesNeeded; + ( void ) xMustReply; + /* Read the request flags in host endianness. */ usFlags = usChar2u16( &( pucUDPPayloadBuffer[ offsetof( NBNSRequest_t, usFlags ) ] ) ); diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index 05599deaa2..70a9a27bb1 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -645,11 +645,11 @@ static void prvChecksumProtocolSetChecksum( BaseType_t xOutgoingPacket, { /* This is an incoming packet and it doesn't need debug logging. */ } - #else /* if ( ipconfigHAS_DEBUG_PRINTF != 0 ) */ - /* Mention parameters that are not used by the function. */ - ( void ) uxBufferLength; - ( void ) pucEthernetBuffer; #endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ + + /* Mention parameters that are not used by the function. */ + ( void ) uxBufferLength; + ( void ) pucEthernetBuffer; } /*-----------------------------------------------------------*/ diff --git a/source/FreeRTOS_TCP_State_Handling_IPV6.c b/source/FreeRTOS_TCP_State_Handling_IPV6.c index 76ab55d7e8..706653de7f 100644 --- a/source/FreeRTOS_TCP_State_Handling_IPV6.c +++ b/source/FreeRTOS_TCP_State_Handling_IPV6.c @@ -84,7 +84,7 @@ /* coverity[misra_c_2012_rule_11_3_violation] */ const TCPPacket_IPv6_t * pxTCPPacket = ( ( const TCPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer ); FreeRTOS_Socket_t * pxReturn = NULL; - uint32_t ulInitialSequenceNumber; + uint32_t ulInitialSequenceNumber = 0; BaseType_t xHasSequence = pdFALSE; configASSERT( pxNetworkBuffer->pxEndPoint != NULL ); From c5dc60da543fb293406341021cadd49f2cf9bf8c Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 24 Mar 2023 09:06:58 +0000 Subject: [PATCH 26/28] Uncrustify: triggered by comment --- source/FreeRTOS_DNS_Parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/FreeRTOS_DNS_Parser.c b/source/FreeRTOS_DNS_Parser.c index 3c5a3be331..73bc1416f8 100644 --- a/source/FreeRTOS_DNS_Parser.c +++ b/source/FreeRTOS_DNS_Parser.c @@ -1049,7 +1049,7 @@ ( void ) uxBufferLength; ( void ) uxBytesNeeded; ( void ) xMustReply; - + /* Read the request flags in host endianness. */ usFlags = usChar2u16( &( pucUDPPayloadBuffer[ offsetof( NBNSRequest_t, usFlags ) ] ) ); From ce536620d0ce25c34a15cfd116ed1238b383419b Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Sun, 26 Mar 2023 14:18:52 +0530 Subject: [PATCH 27/28] review feedback changes --- source/FreeRTOS_DHCPv6.c | 2 +- source/FreeRTOS_DNS_Parser.c | 23 ++++++++++----------- source/FreeRTOS_TCP_Utils_IPV6.c | 6 +++--- test/build-combination/Common/main.c | 30 ---------------------------- 4 files changed, 15 insertions(+), 46 deletions(-) diff --git a/source/FreeRTOS_DHCPv6.c b/source/FreeRTOS_DHCPv6.c index 7cd0875fae..d2c7fc37d0 100644 --- a/source/FreeRTOS_DHCPv6.c +++ b/source/FreeRTOS_DHCPv6.c @@ -325,7 +325,7 @@ void vDHCPv6Process( BaseType_t xReset, } else { - FreeRTOS_printf( ( "vDHCPv6Process: malloc failed %u bytes\n", ( unsigned ) sizeof( *pxEndPoint->pxDHCPMessage ) ) ); + FreeRTOS_printf( ( "vDHCPv6Process: malloc failed %u bytes\n", ( unsigned int ) sizeof( *pxEndPoint->pxDHCPMessage ) ) ); } } } diff --git a/source/FreeRTOS_DNS_Parser.c b/source/FreeRTOS_DNS_Parser.c index 73bc1416f8..b5bc384dc8 100644 --- a/source/FreeRTOS_DNS_Parser.c +++ b/source/FreeRTOS_DNS_Parser.c @@ -313,8 +313,10 @@ xSet.usPortNumber = usPort; xSet.ppxLastAddress = &( xSet.pxLastAddress ); - uint16_t usType = 0U; - uint16_t usClass = 0U; + #if ( ipconfigUSE_LLMNR == 1 ) + uint16_t usType = 0U; + uint16_t usClass = 0U; + #endif /* ipconfigUSE_LLMNR */ #if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 ) xSet.xDoStore = xExpected; @@ -568,9 +570,13 @@ pxAnswer->ucNameOffset = ( uint8_t ) ( xSet.pcRequestedName - ( char * ) pucNewBuffer ); #ifndef _lint - vSetField16( pxAnswer, LLMNRAnswer_t, usType, xSet.usType ); /* Type A or AAAA: host */ - vSetField16( pxAnswer, LLMNRAnswer_t, usClass, dnsCLASS_IN ); /* 1: Class IN */ - vSetField32( pxAnswer, LLMNRAnswer_t, ulTTL, dnsLLMNR_TTL_VALUE ); + #if ( ipconfigUSE_LLMNR == 1 ) + { + vSetField16( pxAnswer, LLMNRAnswer_t, usType, xSet.usType ); /* Type A or AAAA: host */ + vSetField16( pxAnswer, LLMNRAnswer_t, usClass, dnsCLASS_IN ); /* 1: Class IN */ + vSetField32( pxAnswer, LLMNRAnswer_t, ulTTL, dnsLLMNR_TTL_VALUE ); + } + #endif /* ipconfigUSE_LLMNR */ #endif /* lint */ usLength = ( int16_t ) ( sizeof( *pxAnswer ) + ( size_t ) ( xSet.pucByte - pucNewBuffer ) ); @@ -628,9 +634,6 @@ /* The IP-address found will be returned. */ } - ( void ) usType; - ( void ) usClass; - return ulIPAddress; } @@ -1041,14 +1044,10 @@ uint8_t ucNBNSName[ 17 ]; uint8_t * pucUDPPayloadBuffer = pucPayload; NetworkBufferDescriptor_t * pxNetworkBuffer; - size_t uxBytesNeeded = sizeof( UDPPacket_t ) + sizeof( NBNSRequest_t ); NetworkEndPoint_t xEndPoint; - BaseType_t xMustReply = pdFALSE; /* Not used for now */ ( void ) uxBufferLength; - ( void ) uxBytesNeeded; - ( void ) xMustReply; /* Read the request flags in host endianness. */ usFlags = usChar2u16( &( pucUDPPayloadBuffer[ offsetof( NBNSRequest_t, usFlags ) ] ) ); diff --git a/source/FreeRTOS_TCP_Utils_IPV6.c b/source/FreeRTOS_TCP_Utils_IPV6.c index 4ee108a960..e73f15c040 100644 --- a/source/FreeRTOS_TCP_Utils_IPV6.c +++ b/source/FreeRTOS_TCP_Utils_IPV6.c @@ -58,7 +58,7 @@ uint32_t ulMSS = ipconfigTCP_MSS; #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - char cBuffer[ 40 ]; + char cIPv6Address [ 40 ]; #endif const NetworkEndPoint_t * pxEndPoint = pxSocket->pxEndPoint; @@ -92,8 +92,8 @@ #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) { - ( void ) FreeRTOS_inet_ntop( FREERTOS_AF_INET6, ( const void * ) pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, cBuffer, sizeof( cBuffer ) ); - FreeRTOS_debug_printf( ( "prvSocketSetMSS: %u bytes for %s ip port %u\n", ( unsigned ) ulMSS, cBuffer, pxSocket->u.xTCP.usRemotePort ) ); + ( void ) FreeRTOS_inet_ntop( FREERTOS_AF_INET6, ( const void * ) pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, cIPv6Address , sizeof( cIPv6Address ) ); + FreeRTOS_debug_printf( ( "prvSocketSetMSS: %u bytes for %s ip port %u\n", ( unsigned ) ulMSS, cIPv6Address , pxSocket->u.xTCP.usRemotePort ) ); } #endif diff --git a/test/build-combination/Common/main.c b/test/build-combination/Common/main.c index caaa03e922..9ca386ddf6 100644 --- a/test/build-combination/Common/main.c +++ b/test/build-combination/Common/main.c @@ -210,37 +210,7 @@ void vApplicationIdleHook( void ) /* Exit. Just a stub. */ } -/*-----------------------------------------------------------*/ -void vAssertCalled( const char * pcFile, - unsigned long ulLine ) -{ - const uint32_t ulLongSleep = 1000UL; - volatile uint32_t ulBlockVariable = 0UL; - volatile char * pcFileName = ( volatile char * ) pcFile; - volatile uint32_t ulLineNumber = ulLine; - ( void ) pcFileName; - ( void ) ulLineNumber; - - taskDISABLE_INTERRUPTS(); - { - while( 1 ) - { - } - } - taskENABLE_INTERRUPTS(); -} -/*-----------------------------------------------------------*/ - -void vLoggingPrintf( const char * pcFormat, - ... ) -{ - va_list arg; - - va_start( arg, pcFormat ); - vprintf( pcFormat, arg ); - va_end( arg ); -} /*-----------------------------------------------------------*/ void getUserCmd( char * pucUserCmd ) From 6e056eee76fc570461a8777b232f277f426ca47f Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 26 Mar 2023 08:54:40 +0000 Subject: [PATCH 28/28] Uncrustify: triggered by comment --- source/FreeRTOS_DNS_Parser.c | 10 +++++----- source/FreeRTOS_TCP_Utils_IPV6.c | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/FreeRTOS_DNS_Parser.c b/source/FreeRTOS_DNS_Parser.c index b5bc384dc8..8da7ab3b7b 100644 --- a/source/FreeRTOS_DNS_Parser.c +++ b/source/FreeRTOS_DNS_Parser.c @@ -571,11 +571,11 @@ #ifndef _lint #if ( ipconfigUSE_LLMNR == 1 ) - { - vSetField16( pxAnswer, LLMNRAnswer_t, usType, xSet.usType ); /* Type A or AAAA: host */ - vSetField16( pxAnswer, LLMNRAnswer_t, usClass, dnsCLASS_IN ); /* 1: Class IN */ - vSetField32( pxAnswer, LLMNRAnswer_t, ulTTL, dnsLLMNR_TTL_VALUE ); - } + { + vSetField16( pxAnswer, LLMNRAnswer_t, usType, xSet.usType ); /* Type A or AAAA: host */ + vSetField16( pxAnswer, LLMNRAnswer_t, usClass, dnsCLASS_IN ); /* 1: Class IN */ + vSetField32( pxAnswer, LLMNRAnswer_t, ulTTL, dnsLLMNR_TTL_VALUE ); + } #endif /* ipconfigUSE_LLMNR */ #endif /* lint */ diff --git a/source/FreeRTOS_TCP_Utils_IPV6.c b/source/FreeRTOS_TCP_Utils_IPV6.c index e73f15c040..5faa9e2f07 100644 --- a/source/FreeRTOS_TCP_Utils_IPV6.c +++ b/source/FreeRTOS_TCP_Utils_IPV6.c @@ -58,7 +58,7 @@ uint32_t ulMSS = ipconfigTCP_MSS; #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - char cIPv6Address [ 40 ]; + char cIPv6Address[ 40 ]; #endif const NetworkEndPoint_t * pxEndPoint = pxSocket->pxEndPoint; @@ -92,8 +92,8 @@ #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) { - ( void ) FreeRTOS_inet_ntop( FREERTOS_AF_INET6, ( const void * ) pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, cIPv6Address , sizeof( cIPv6Address ) ); - FreeRTOS_debug_printf( ( "prvSocketSetMSS: %u bytes for %s ip port %u\n", ( unsigned ) ulMSS, cIPv6Address , pxSocket->u.xTCP.usRemotePort ) ); + ( void ) FreeRTOS_inet_ntop( FREERTOS_AF_INET6, ( const void * ) pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, cIPv6Address, sizeof( cIPv6Address ) ); + FreeRTOS_debug_printf( ( "prvSocketSetMSS: %u bytes for %s ip port %u\n", ( unsigned ) ulMSS, cIPv6Address, pxSocket->u.xTCP.usRemotePort ) ); } #endif