Skip to content

Commit

Permalink
Check user related headers can be included independently. (FreeRTOS#982)
Browse files Browse the repository at this point in the history
* Header fix part 1

* IP_Private

* TEST_HEADER_INC_ONLY_IPv4

* NetworkBufferManagement and NetworkInterface

* Add CI flow to check user related headers can be included independently

* Revert some redundant change

* Add CI flow and fix formatting

* Use -include compile option to test header self contain.

---------

Co-authored-by: Monika Singh <[email protected]>
  • Loading branch information
ActoryOu and moninom1 authored Jul 31, 2023
1 parent 9b903bd commit df5aed9
Show file tree
Hide file tree
Showing 18 changed files with 639 additions and 15 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ jobs:
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
- name: Build checks (Header Self Contain)
run: |
cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=HEADER_SELF_CONTAIN
cmake --build build --target clean
cmake --build build --target freertos_plus_tcp_build_test_FreeRTOS_DHCP
cmake --build build --target freertos_plus_tcp_build_test_FreeRTOS_DNS
cmake --build build --target freertos_plus_tcp_build_test_FreeRTOS_IP
cmake --build build --target freertos_plus_tcp_build_test_FreeRTOS_ND
cmake --build build --target freertos_plus_tcp_build_test_FreeRTOS_Routing
cmake --build build --target freertos_plus_tcp_build_test_FreeRTOS_Sockets
cmake --build build --target freertos_plus_tcp_build_test_NetworkBufferManagement
cmake --build build --target freertos_plus_tcp_build_test_NetworkInterface
complexity:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ set(FREERTOS_PLUS_TCP_TEST_CONFIGURATION_LIST
ENABLE_ALL_IPV6_TCP # Enable all configuration settings IPv6 TCP
ENABLE_ALL_IPV4_IPV6 # Enable all configuration settings IPv4 IPv6 UDP
DISABLE_ALL # Disable all configuration settings
HEADER_SELF_CONTAIN # Enable header self contain test
DEFAULT_CONF # Default (typical) configuration
)
if(NOT FREERTOS_PLUS_TCP_TEST_CONFIGURATION IN_LIST FREERTOS_PLUS_TCP_TEST_CONFIGURATION_LIST)
Expand Down
3 changes: 3 additions & 0 deletions source/include/FreeRTOS_ARP.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@
#include "FreeRTOSIPConfigDefaults.h"
#include "IPTraceMacroDefaults.h"

#include "FreeRTOS_IP.h"

/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-ON* */

/*-----------------------------------------------------------*/
/* Miscellaneous structure and definitions. */
/*-----------------------------------------------------------*/
Expand Down
5 changes: 3 additions & 2 deletions source/include/FreeRTOS_DHCP.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@
#ifndef FREERTOS_DHCP_H
#define FREERTOS_DHCP_H

#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_Routing.h"
#include "FreeRTOS.h"

/* Application level configuration options. */
#include "FreeRTOSIPConfig.h"
#include "IPTraceMacroDefaults.h"

#include "FreeRTOS_Sockets.h"

/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 2 additions & 0 deletions source/include/FreeRTOS_DNS.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#ifndef FREERTOS_DNS_H
#define FREERTOS_DNS_H

#include "FreeRTOS.h"

/* Application level configuration options. */
#include "FreeRTOS_DNS_Globals.h"
#include "FreeRTOS_DNS_Callback.h"
Expand Down
2 changes: 2 additions & 0 deletions source/include/FreeRTOS_DNS_Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "FreeRTOSIPConfigDefaults.h"
#include "IPTraceMacroDefaults.h"

#include "FreeRTOS_Sockets.h"

#define dnsPARSE_ERROR 0UL

#if ( ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN )
Expand Down
5 changes: 4 additions & 1 deletion source/include/FreeRTOS_IP_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
#define ipFOREVER() 1
#endif

typedef enum
/* Forward declaration of 'NetworkEndPoint_t'. */
typedef struct xNetworkEndPoint NetworkEndPoint_t;

typedef enum eFrameProcessingResult
{
eReleaseBuffer = 0, /* Processing the frame did not find anything to do - just release the buffer. */
eProcessBuffer, /* An Ethernet frame has a valid address - continue process its contents. */
Expand Down
3 changes: 3 additions & 0 deletions source/include/FreeRTOS_IP_Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
#endif
/* *INDENT-ON* */

/* Forward declaration of 'NetworkInterface_t'. */
typedef struct xNetworkInterface NetworkInterface_t;

#if ( ipconfigUSE_DHCP != 0 )

/**
Expand Down
9 changes: 5 additions & 4 deletions source/include/FreeRTOS_IPv4.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#include "FreeRTOS.h"
#include "task.h"
#include "FreeRTOS_IP.h"

/* Application level configuration options. */
#include "FreeRTOSIPConfig.h"
Expand All @@ -43,14 +42,16 @@
#endif
/* *INDENT-ON* */

/* Forward declarations. */
typedef struct xNETWORK_BUFFER NetworkBufferDescriptor_t;
typedef enum eFrameProcessingResult eFrameProcessingResult_t;
typedef struct xIP_PACKET IPPacket_t;

#define ipSIZE_OF_IPv4_HEADER 20U
#define ipSIZE_OF_IPv4_ADDRESS 4U
#define ipSIZE_OF_ICMPv4_HEADER 8U
#define ipTYPE_IPv4 ( 0x40U )

/* The number of octets in the IP addresses respectively. */
#define ipIP_ADDRESS_LENGTH_BYTES ( 4U )

#define ipFIRST_LOOPBACK_IPv4 0x7F000000UL /**< Lowest IPv4 loopback address (including). */
#define ipLAST_LOOPBACK_IPv4 0x80000000UL /**< Highest IPv4 loopback address (excluding). */

Expand Down
2 changes: 0 additions & 2 deletions source/include/FreeRTOS_IPv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "task.h"
#include "FreeRTOS_IP.h"
#include "FreeRTOS_IP_Common.h"
#include "FreeRTOS_IPv6_Private.h"

/* *INDENT-OFF* */
#ifdef __cplusplus
Expand Down Expand Up @@ -89,7 +88,6 @@ eFrameProcessingResult_t prvAllowIPPacketIPv6( const IPHeader_IPv6_t * const pxI
const NetworkBufferDescriptor_t * const pxNetworkBuffer,
UBaseType_t uxHeaderLength );


/** @brief Handle the IPv6 extension headers. */
eFrameProcessingResult_t eHandleIPv6ExtensionHeaders( NetworkBufferDescriptor_t * const pxNetworkBuffer,
BaseType_t xDoRemove );
Expand Down
2 changes: 2 additions & 0 deletions source/include/FreeRTOS_ND.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#ifndef FREERTOS_ND_H
#define FREERTOS_ND_H

#include "FreeRTOS.h"

/* Application level configuration options. */
#include "FreeRTOSIPConfig.h"
#include "FreeRTOSIPConfigDefaults.h"
Expand Down
6 changes: 3 additions & 3 deletions source/include/FreeRTOS_Routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#ifndef FREERTOS_ROUTING_H
#define FREERTOS_ROUTING_H

#include "FreeRTOS.h"
#include "FreeRTOS_IP.h"

#if ( ipconfigUSE_DHCP != 0 )
#include "FreeRTOS_DHCP.h"
#endif
Expand All @@ -40,9 +43,6 @@

/* Every NetworkInterface needs a set of access functions: */

/* Forward declaration of 'struct xNetworkInterface'. */
struct xNetworkInterface;

/* Initialise the interface. */
typedef BaseType_t ( * NetworkInterfaceInitialiseFunction_t ) ( struct xNetworkInterface * pxDescriptor );

Expand Down
2 changes: 2 additions & 0 deletions source/include/NetworkBufferManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#endif
/* *INDENT-ON* */

#include "FreeRTOS_IP.h"

/* _HT_ Two macro's needed while debugging/testing, please ignore. */

#define BUFFER_FROM_WHERE_DECL
Expand Down
2 changes: 2 additions & 0 deletions source/include/NetworkInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#endif
/* *INDENT-ON* */

#include "FreeRTOS_IP.h"

/* INTERNAL API FUNCTIONS. */

/* Since there are multiple interfaces, there are multiple versions
Expand Down
15 changes: 12 additions & 3 deletions test/build-combination/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ add_library( freertos_plus_tcp_config_all_enable_ipv6_tcp INTERFACE)
target_include_directories(freertos_plus_tcp_config_all_enable_ipv6_tcp INTERFACE Enable_IPv6_TCP)
target_link_libraries(freertos_plus_tcp_config_all_enable_ipv6_tcp INTERFACE freertos_plus_tcp_config_common)

# -------------------------------------------------------------------
add_library( freertos_plus_tcp_config_header_self_contain INTERFACE)
target_include_directories(freertos_plus_tcp_config_header_self_contain INTERFACE Header_Self_Contain)
target_link_libraries(freertos_plus_tcp_config_header_self_contain INTERFACE freertos_plus_tcp_config_common)

# -------------------------------------------------------------------
add_library( freertos_plus_tcp_config_default INTERFACE)
target_include_directories(freertos_plus_tcp_config_default INTERFACE DefaultConf)
Expand All @@ -62,19 +67,23 @@ elseif(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "ENABLE_ALL_IPV6_TCP" )
add_library( freertos_config ALIAS freertos_plus_tcp_config_all_enable_ipv6_tcp)
elseif(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "ENABLE_ALL_IPV4_IPV6" )
add_library( freertos_config ALIAS freertos_plus_tcp_config_all_enable_ipv4_ipv6)
elseif(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "HEADER_SELF_CONTAIN" )
add_library( freertos_config ALIAS freertos_plus_tcp_config_header_self_contain)
include( Header_Self_Contain/headerSelfContain.cmake )
else()
add_library( freertos_config ALIAS freertos_plus_tcp_config_default)
endif()

# Common build combination test.
add_executable(freertos_plus_tcp_build_test EXCLUDE_FROM_ALL)

target_sources(freertos_plus_tcp_build_test
PRIVATE
PRIVATE
Common/main.c
)

target_compile_options(freertos_plus_tcp_build_test
PRIVATE
PRIVATE
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-cast-qual>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-format-nonliteral>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-implicit-function-declaration>
Expand All @@ -90,7 +99,7 @@ target_compile_options(freertos_plus_tcp_build_test
)

target_link_libraries(freertos_plus_tcp_build_test
PRIVATE
PRIVATE
freertos_plus_tcp
freertos_kernel
)
Loading

0 comments on commit df5aed9

Please sign in to comment.