Skip to content

Commit 86da319

Browse files
committed
Merge branch 'main' into dev-bufalloc
2 parents 05180f1 + 631fd05 commit 86da319

File tree

64 files changed

+544
-637
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+544
-637
lines changed

.github/.cSpellWords.txt

Lines changed: 98 additions & 19 deletions
Large diffs are not rendered by default.

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ add_compile_options(
193193
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wall>
194194
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wextra>
195195
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Werror>
196-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wpedantic>
196+
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wpedantic>
197197
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wconversion>
198198
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wunused-variable>
199199
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Weverything>
@@ -209,6 +209,9 @@ add_compile_options(
209209
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-extra-semi-stmt>
210210
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-missing-noreturn>
211211
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-cast-align>
212+
213+
# Suppressions required to build clean with GCC.
214+
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-declaration-after-statement>
212215
)
213216

214217
########################################################################

source/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ target_include_directories( freertos_plus_tcp SYSTEM
9595
include
9696
)
9797

98+
# Suppressions required to build clean with GCC
99+
if(CMAKE_C_COMPILER_ID STREQUAL GNU)
100+
set_source_files_properties(FreeRTOS_Sockets.c PROPERTIES COMPILE_FLAGS -Wno-pedantic)
101+
endif()
102+
98103
target_link_libraries( freertos_plus_tcp
99104
PUBLIC
100105
freertos_config

source/FreeRTOS_ARP.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static TickType_t xLastGratuitousARPTime = 0U;
279279
( unsigned ) FreeRTOS_ntohl( ulTargetProtocolAddress ),
280280
( unsigned ) ( FreeRTOS_ntohl( ( pxTargetEndPoint != NULL ) ? pxTargetEndPoint->ipv4_settings.ulIPAddress : 0U ) ) ) );
281281
}
282-
#endif /* ( ipconfigHAS_PRINTF != 0 ) */
282+
#endif /* ( ipconfigHAS_DEBUG_PRINTF != 0 ) */
283283

284284
/* ulTargetProtocolAddress won't be used unless logging is enabled. */
285285
( void ) ulTargetProtocolAddress;
@@ -294,8 +294,8 @@ static TickType_t xLastGratuitousARPTime = 0U;
294294

295295
if( ulTargetProtocolAddress == pxTargetEndPoint->ipv4_settings.ulIPAddress )
296296
{
297-
if( memcmp( ( void * ) pxTargetEndPoint->xMACAddress.ucBytes,
298-
( pxARPHeader->xSenderHardwareAddress.ucBytes ),
297+
if( memcmp( pxTargetEndPoint->xMACAddress.ucBytes,
298+
pxARPHeader->xSenderHardwareAddress.ucBytes,
299299
ipMAC_ADDRESS_LENGTH_BYTES ) != 0 )
300300
{
301301
vARPProcessPacketRequest( pxARPFrame, pxTargetEndPoint, ulSenderProtocolAddress );
@@ -310,9 +310,9 @@ static TickType_t xLastGratuitousARPTime = 0U;
310310

311311
/* Make sure target MAC address is either ff:ff:ff:ff:ff:ff or 00:00:00:00:00:00 and senders MAC
312312
* address is not matching with the endpoint MAC address. */
313-
if( ( ( memcmp( ( const void * ) pxARPHeader->xTargetHardwareAddress.ucBytes, xBroadcastMACAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) ||
314-
( ( memcmp( ( const void * ) pxARPHeader->xTargetHardwareAddress.ucBytes, xGARPTargetAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) ) ) &&
315-
( memcmp( ( void * ) pxTargetEndPoint->xMACAddress.ucBytes, ( pxARPHeader->xSenderHardwareAddress.ucBytes ), ipMAC_ADDRESS_LENGTH_BYTES ) != 0 ) )
313+
if( ( ( memcmp( pxARPHeader->xTargetHardwareAddress.ucBytes, xBroadcastMACAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) ||
314+
( ( memcmp( pxARPHeader->xTargetHardwareAddress.ucBytes, xGARPTargetAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) ) ) &&
315+
( memcmp( pxTargetEndPoint->xMACAddress.ucBytes, pxARPHeader->xSenderHardwareAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) != 0 ) )
316316
{
317317
MACAddress_t xHardwareAddress;
318318
NetworkEndPoint_t * pxCachedEndPoint;

source/FreeRTOS_DHCP.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@
843843
* using it.
844844
* @param[in] pxEndPoint The end-point that stops using the socket.
845845
*/
846-
void prvCloseDHCPSocket( NetworkEndPoint_t * pxEndPoint )
846+
static void prvCloseDHCPSocket( NetworkEndPoint_t * pxEndPoint )
847847
{
848848
if( ( EP_DHCPData.xDHCPSocket == NULL ) || ( EP_DHCPData.xDHCPSocket != xDHCPv4Socket ) )
849849
{
@@ -905,7 +905,7 @@
905905
( void ) FreeRTOS_setsockopt( xDHCPv4Socket, 0, FREERTOS_SO_RCVTIMEO, &( xTimeoutTime ), sizeof( TickType_t ) );
906906
( void ) FreeRTOS_setsockopt( xDHCPv4Socket, 0, FREERTOS_SO_SNDTIMEO, &( xTimeoutTime ), sizeof( TickType_t ) );
907907

908-
memset( &xAddress, 0, sizeof( xAddress ) );
908+
( void ) memset( &xAddress, 0, sizeof( xAddress ) );
909909
xAddress.sin_family = FREERTOS_AF_INET4;
910910
xAddress.sin_len = ( uint8_t ) sizeof( xAddress );
911911
/* Bind to the standard DHCP client port. */

source/FreeRTOS_DNS.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,9 +1082,7 @@
10821082
/* MISRA Ref 11.3.1 [Misaligned access] */
10831083
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
10841084
/* coverity[misra_c_2012_rule_11_3_violation] */
1085-
const DNSMessage_t * pxDNSMessageHeader =
1086-
( ( const DNSMessage_t * )
1087-
pxReceiveBuffer->pucPayloadBuffer );
1085+
const DNSMessage_t * pxDNSMessageHeader = ( const DNSMessage_t * ) pxReceiveBuffer->pucPayloadBuffer;
10881086

10891087
#if ( ipconfigUSE_MDNS == 1 )
10901088
/* _HT_ changed 'pxReceiveBuffer->sin_port' to 'usPort' */

source/FreeRTOS_DNS_Parser.c

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -47,47 +47,6 @@
4747

4848
#if ( ipconfigUSE_DNS != 0 )
4949

50-
/** @brief The list of all callback structures. */
51-
52-
53-
#if ( ( ipconfigUSE_NBNS == 1 ) || ( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_MDNS == 1 ) )
54-
55-
/**
56-
* @brief Find the best matching end-point given a reply that was received.
57-
* @param[in] pxNetworkBuffer The Ethernet packet that was received.
58-
* @return An end-point.
59-
*/
60-
static NetworkEndPoint_t * prvFindEndPointOnNetMask( NetworkBufferDescriptor_t * pxNetworkBuffer )
61-
{
62-
NetworkEndPoint_t * pxEndPoint = NULL;
63-
64-
#if ( ipconfigUSE_IPv6 != 0 )
65-
IPPacket_IPv6_t * xIPPacket_IPv6 = ( ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer );
66-
67-
if( xIPPacket_IPv6->xEthernetHeader.usFrameType == ipIPv6_FRAME_TYPE )
68-
{
69-
pxEndPoint = FreeRTOS_FindEndPointOnNetMask_IPv6( &xIPPacket_IPv6->xIPHeader.xSourceAddress );
70-
}
71-
else
72-
#endif /* ( ipconfigUSE_IPv6 != 0 ) */
73-
74-
#if ( ipconfigUSE_IPv4 != 0 )
75-
{
76-
IPPacket_t * xIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer );
77-
78-
pxEndPoint = FreeRTOS_FindEndPointOnNetMask( xIPPacket->xIPHeader.ulSourceIPAddress, 6 );
79-
}
80-
#endif /* ( ipconfigUSE_IPv4 != 0 ) */
81-
82-
if( pxEndPoint != NULL )
83-
{
84-
pxNetworkBuffer->pxEndPoint = pxEndPoint;
85-
}
86-
87-
return pxEndPoint;
88-
}
89-
#endif /* ( ( ipconfigUSE_NBNS == 1 ) || ( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_MDNS == 1 ) ) */
90-
/*-----------------------------------------------------------*/
9150

9251
/**
9352
* @brief Read the Name field out of a DNS response packet.
@@ -912,9 +871,10 @@
912871
IPHeader_t * pxIPHeader;
913872
UDPHeader_t * pxUDPHeader;
914873
size_t uxDataLength;
915-
NetworkEndPoint_t * pxEndPoint = prvFindEndPointOnNetMask( pxNetworkBuffer );
874+
NetworkEndPoint_t * pxEndPoint = pxNetworkBuffer->pxEndPoint;
916875
const size_t uxIPHeaderLength = uxIPHeaderSizePacket( pxNetworkBuffer );
917876

877+
configASSERT( pxEndPoint != NULL );
918878
pxUDPPacket = ( ( UDPPacket_t * )
919879
pxNetworkBuffer->pucEthernetBuffer );
920880
pxIPHeader = &pxUDPPacket->xIPHeader;
@@ -960,7 +920,7 @@
960920
pxIPHeader->ucTimeToLive = ipconfigUDP_TIME_TO_LIVE;
961921
}
962922

963-
pxIPHeader->ulSourceIPAddress = ( pxEndPoint != NULL ) ? pxEndPoint->ipv4_settings.ulIPAddress : 0U;
923+
pxIPHeader->ulSourceIPAddress = pxEndPoint->ipv4_settings.ulIPAddress;
964924
pxIPHeader->usIdentification = FreeRTOS_htons( usPacketIdentifier );
965925

966926
/* The stack doesn't support fragments, so the fragment offset field must always be zero.
@@ -1149,7 +1109,7 @@
11491109
xEndPoint.bits.bIPv6 = pdFALSE_UNSIGNED;
11501110
xEndPoint.usDNSType = dnsTYPE_A_HOST;
11511111

1152-
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
1112+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
11531113
xDNSHookReturn = xApplicationDNSQueryHook( ( const char * ) ucNBNSName );
11541114
#else
11551115
xDNSHookReturn = xApplicationDNSQueryHook_Multi( &( xEndPoint ), ( const char * ) ucNBNSName );

source/FreeRTOS_IP_Utils.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ void prvProcessNetworkDownEvent( struct xNetworkInterface * pxInterface )
839839
{
840840
if( pxEndPoint->bits.bCallDownHook != pdFALSE_UNSIGNED )
841841
{
842-
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
842+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
843843
{
844844
vApplicationIPNetworkEventHook( eNetworkDown );
845845
}
@@ -983,18 +983,28 @@ void vPreCheckConfigs( void )
983983

984984
#if ( configASSERT_DEFINED == 1 )
985985
{
986-
volatile size_t uxSize = sizeof( uintptr_t );
987-
988-
if( uxSize == 8U )
989-
{
990-
/* This is a 64-bit platform, make sure there is enough space in
991-
* pucEthernetBuffer to store a pointer and also make sure that the value of
992-
* ipconfigBUFFER_PADDING is such that (ipconfigBUFFER_PADDING + ipSIZE_OF_ETH_HEADER) is a
993-
* 32 bit (4 byte) aligned value, so that when incrementing the ethernet buffer with
994-
* (ipconfigBUFFER_PADDING + ipSIZE_OF_ETH_HEADER) bytes it lands in a 32 bit aligned address
995-
* which lets us efficiently access 32 bit values later in the packet. */
996-
configASSERT( ( ipconfigBUFFER_PADDING >= 14 ) && ( ( ( ( ipconfigBUFFER_PADDING ) + ( ipSIZE_OF_ETH_HEADER ) ) % 4 ) == 0 ) );
997-
}
986+
size_t uxSize;
987+
988+
/* Check if ipBUFFER_PADDING has a minimum size, depending on the platform.
989+
* See FreeRTOS_IP.h for more details. */
990+
#if ( UINTPTR_MAX > 0xFFFFFFFFU )
991+
992+
/*
993+
* This is a 64-bit platform, make sure there is enough space in
994+
* pucEthernetBuffer to store a pointer.
995+
*/
996+
configASSERT( ipBUFFER_PADDING >= 14U );
997+
#else
998+
/* This is a 32-bit platform. */
999+
configASSERT( ipBUFFER_PADDING >= 10U );
1000+
#endif /* UINTPTR_MAX > 0xFFFFFFFFU */
1001+
1002+
/*
1003+
* The size of the Ethernet header (14) plus ipBUFFER_PADDING should be a
1004+
* multiple of 32 bits, in order to get aligned access to all uint32_t
1005+
* fields in the protocol headers.
1006+
*/
1007+
configASSERT( ( ( ( ipSIZE_OF_ETH_HEADER ) + ( ipBUFFER_PADDING ) ) % 4U ) == 0U );
9981008

9991009
/* LCOV_EXCL_BR_START */
10001010
uxSize = ipconfigNETWORK_MTU;

source/FreeRTOS_IPv4.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,19 +221,13 @@ BaseType_t xIsIPv4Multicast( uint32_t ulIPAddress )
221221
BaseType_t xBadIPv4Loopback( const IPHeader_t * const pxIPHeader )
222222
{
223223
BaseType_t xReturn = pdFALSE;
224-
const NetworkEndPoint_t * pxEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( pxIPHeader->ulSourceIPAddress, 3 );
224+
BaseType_t x1 = ( xIsIPv4Loopback( pxIPHeader->ulDestinationIPAddress ) != 0 ) ? pdTRUE : pdFALSE;
225+
BaseType_t x2 = ( xIsIPv4Loopback( pxIPHeader->ulSourceIPAddress ) != 0 ) ? pdTRUE : pdFALSE;
225226

226-
/* Allow loopback packets from this node itself only. */
227-
if( pxEndPoint != NULL )
227+
if( x1 != x2 )
228228
{
229-
BaseType_t x1 = ( xIsIPv4Loopback( pxIPHeader->ulDestinationIPAddress ) != 0 ) ? pdTRUE : pdFALSE;
230-
BaseType_t x2 = ( xIsIPv4Loopback( pxIPHeader->ulSourceIPAddress ) != 0 ) ? pdTRUE : pdFALSE;
231-
232-
if( x1 != x2 )
233-
{
234-
/* Either the source or the destination address is an IPv4 loopback address. */
235-
xReturn = pdTRUE;
236-
}
229+
/* Either the source or the destination address is an IPv4 loopback address. */
230+
xReturn = pdTRUE;
237231
}
238232

239233
return xReturn;

source/FreeRTOS_IPv6.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ const struct xIPv6_Address FreeRTOS_in6addr_any = { 0 };
6262
/**
6363
* This variable is initialized by the system to contain the loopback IPv6 address.
6464
*/
65+
/* MISRA Ref 8.9.1 [File scoped variables] */
66+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-89 */
67+
/* coverity[misra_c_2012_rule_8_9_violation] */
6568
const struct xIPv6_Address FreeRTOS_in6addr_loopback = { { 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U } };
6669

6770
#if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 1 )

0 commit comments

Comments
 (0)