Skip to content

Commit

Permalink
Merge branch 'FreeRTOS:main' into updateWordList
Browse files Browse the repository at this point in the history
  • Loading branch information
Skptak authored Jan 5, 2024
2 parents 30c2dff + fcd2de0 commit 06dffe6
Show file tree
Hide file tree
Showing 23 changed files with 187 additions and 126 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ jobs:
uses: FreeRTOS/CI-CD-Github-Actions/coverage-cop@main
with:
coverage-file: ./test/unit-test/build/coverage.info
branch-coverage-min: 100
line-coverage-min: 100

spell-check:
runs-on: ubuntu-latest
Expand Down
20 changes: 10 additions & 10 deletions source/FreeRTOS_ARP.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@ static TickType_t xLastGratuitousARPTime = 0U;
traceARP_PACKET_RECEIVED();

/* Some extra logging while still testing. */
#if ( ipconfigHAS_PRINTF != 0 )
#if ( ipconfigHAS_DEBUG_PRINTF != 0 )
if( pxARPHeader->usOperation == ( uint16_t ) ipARP_REPLY )
{
FreeRTOS_printf( ( "ipARP_REPLY from %xip to %xip end-point %xip\n",
( unsigned ) FreeRTOS_ntohl( ulSenderProtocolAddress ),
( unsigned ) FreeRTOS_ntohl( ulTargetProtocolAddress ),
( unsigned ) FreeRTOS_ntohl( ( pxTargetEndPoint != NULL ) ? pxTargetEndPoint->ipv4_settings.ulIPAddress : 0U ) ) );
FreeRTOS_debug_printf( ( "ipARP_REPLY from %xip to %xip end-point %xip\n",
( unsigned ) FreeRTOS_ntohl( ulSenderProtocolAddress ),
( unsigned ) FreeRTOS_ntohl( ulTargetProtocolAddress ),
( unsigned ) FreeRTOS_ntohl( ( pxTargetEndPoint != NULL ) ? pxTargetEndPoint->ipv4_settings.ulIPAddress : 0U ) ) );
}
#endif /* ( ipconfigHAS_DEBUG_PRINTF != 0 ) */

Expand Down Expand Up @@ -294,8 +294,8 @@ static TickType_t xLastGratuitousARPTime = 0U;

if( ulTargetProtocolAddress == pxTargetEndPoint->ipv4_settings.ulIPAddress )
{
if( memcmp( ( void * ) pxTargetEndPoint->xMACAddress.ucBytes,
( pxARPHeader->xSenderHardwareAddress.ucBytes ),
if( memcmp( pxTargetEndPoint->xMACAddress.ucBytes,
pxARPHeader->xSenderHardwareAddress.ucBytes,
ipMAC_ADDRESS_LENGTH_BYTES ) != 0 )
{
vARPProcessPacketRequest( pxARPFrame, pxTargetEndPoint, ulSenderProtocolAddress );
Expand All @@ -310,9 +310,9 @@ static TickType_t xLastGratuitousARPTime = 0U;

/* Make sure target MAC address is either ff:ff:ff:ff:ff:ff or 00:00:00:00:00:00 and senders MAC
* address is not matching with the endpoint MAC address. */
if( ( ( memcmp( ( const void * ) pxARPHeader->xTargetHardwareAddress.ucBytes, xBroadcastMACAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) ||
( ( memcmp( ( const void * ) pxARPHeader->xTargetHardwareAddress.ucBytes, xGARPTargetAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) ) ) &&
( memcmp( ( void * ) pxTargetEndPoint->xMACAddress.ucBytes, ( pxARPHeader->xSenderHardwareAddress.ucBytes ), ipMAC_ADDRESS_LENGTH_BYTES ) != 0 ) )
if( ( ( memcmp( pxARPHeader->xTargetHardwareAddress.ucBytes, xBroadcastMACAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) ||
( ( memcmp( pxARPHeader->xTargetHardwareAddress.ucBytes, xGARPTargetAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) ) ) &&
( memcmp( pxTargetEndPoint->xMACAddress.ucBytes, pxARPHeader->xSenderHardwareAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) != 0 ) )
{
MACAddress_t xHardwareAddress;
NetworkEndPoint_t * pxCachedEndPoint;
Expand Down
4 changes: 2 additions & 2 deletions source/FreeRTOS_DHCP.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@
* using it.
* @param[in] pxEndPoint The end-point that stops using the socket.
*/
void prvCloseDHCPSocket( NetworkEndPoint_t * pxEndPoint )
static void prvCloseDHCPSocket( NetworkEndPoint_t * pxEndPoint )
{
if( ( EP_DHCPData.xDHCPSocket == NULL ) || ( EP_DHCPData.xDHCPSocket != xDHCPv4Socket ) )
{
Expand Down Expand Up @@ -905,7 +905,7 @@
( void ) FreeRTOS_setsockopt( xDHCPv4Socket, 0, FREERTOS_SO_RCVTIMEO, &( xTimeoutTime ), sizeof( TickType_t ) );
( void ) FreeRTOS_setsockopt( xDHCPv4Socket, 0, FREERTOS_SO_SNDTIMEO, &( xTimeoutTime ), sizeof( TickType_t ) );

memset( &xAddress, 0, sizeof( xAddress ) );
( void ) memset( &xAddress, 0, sizeof( xAddress ) );
xAddress.sin_family = FREERTOS_AF_INET4;
xAddress.sin_len = ( uint8_t ) sizeof( xAddress );
/* Bind to the standard DHCP client port. */
Expand Down
7 changes: 3 additions & 4 deletions source/FreeRTOS_DNS.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@

( void ) memset( pxAddrInfo, 0, sizeof( *pxAddrInfo ) );
pxAddrInfo->ai_canonname = pxAddrInfo->xPrivateStorage.ucName;
( void ) strncpy( pxAddrInfo->xPrivateStorage.ucName, pcName, sizeof( pxAddrInfo->xPrivateStorage.ucName ) );
( void ) strncpy( pxAddrInfo->xPrivateStorage.ucName, pcName, sizeof( pxAddrInfo->xPrivateStorage.ucName ) - 1 );
pxAddrInfo->xPrivateStorage.ucName[ sizeof( pxAddrInfo->xPrivateStorage.ucName ) - 1 ] = '\0';

pxAddrInfo->ai_addr = ( ( struct freertos_sockaddr * ) &( pxAddrInfo->xPrivateStorage.sockaddr ) );

Expand Down Expand Up @@ -1081,9 +1082,7 @@
/* MISRA Ref 11.3.1 [Misaligned access] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
/* coverity[misra_c_2012_rule_11_3_violation] */
const DNSMessage_t * pxDNSMessageHeader =
( ( const DNSMessage_t * )
pxReceiveBuffer->pucPayloadBuffer );
const DNSMessage_t * pxDNSMessageHeader = ( const DNSMessage_t * ) pxReceiveBuffer->pucPayloadBuffer;

#if ( ipconfigUSE_MDNS == 1 )
/* _HT_ changed 'pxReceiveBuffer->sin_port' to 'usPort' */
Expand Down
34 changes: 22 additions & 12 deletions source/FreeRTOS_IP_Utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,18 +983,28 @@ void vPreCheckConfigs( void )

#if ( configASSERT_DEFINED == 1 )
{
volatile size_t uxSize = sizeof( uintptr_t );

if( uxSize == 8U )
{
/* This is a 64-bit platform, make sure there is enough space in
* pucEthernetBuffer to store a pointer and also make sure that the value of
* ipconfigBUFFER_PADDING is such that (ipconfigBUFFER_PADDING + ipSIZE_OF_ETH_HEADER) is a
* 32 bit (4 byte) aligned value, so that when incrementing the ethernet buffer with
* (ipconfigBUFFER_PADDING + ipSIZE_OF_ETH_HEADER) bytes it lands in a 32 bit aligned address
* which lets us efficiently access 32 bit values later in the packet. */
configASSERT( ( ipconfigBUFFER_PADDING >= 14 ) && ( ( ( ( ipconfigBUFFER_PADDING ) + ( ipSIZE_OF_ETH_HEADER ) ) % 4 ) == 0 ) );
}
size_t uxSize;

/* Check if ipBUFFER_PADDING has a minimum size, depending on the platform.
* See FreeRTOS_IP.h for more details. */
#if ( UINTPTR_MAX > 0xFFFFFFFFU )

/*
* This is a 64-bit platform, make sure there is enough space in
* pucEthernetBuffer to store a pointer.
*/
configASSERT( ipBUFFER_PADDING >= 14U );
#else
/* This is a 32-bit platform. */
configASSERT( ipBUFFER_PADDING >= 10U );
#endif /* UINTPTR_MAX > 0xFFFFFFFFU */

/*
* The size of the Ethernet header (14) plus ipBUFFER_PADDING should be a
* multiple of 32 bits, in order to get aligned access to all uint32_t
* fields in the protocol headers.
*/
configASSERT( ( ( ( ipSIZE_OF_ETH_HEADER ) + ( ipBUFFER_PADDING ) ) % 4U ) == 0U );

/* LCOV_EXCL_BR_START */
uxSize = ipconfigNETWORK_MTU;
Expand Down
3 changes: 3 additions & 0 deletions source/FreeRTOS_IPv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ const struct xIPv6_Address FreeRTOS_in6addr_any = { 0 };
/**
* This variable is initialized by the system to contain the loopback IPv6 address.
*/
/* MISRA Ref 8.9.1 [File scoped variables] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-89 */
/* coverity[misra_c_2012_rule_8_9_violation] */
const struct xIPv6_Address FreeRTOS_in6addr_loopback = { { 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U } };

#if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 1 )
Expand Down
4 changes: 4 additions & 0 deletions source/FreeRTOS_RA.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
/* coverity[misra_c_2012_rule_11_3_violation] */
pxICMPPacket = ( ( ICMPPacket_IPv6_t * ) pxDescriptor->pucEthernetBuffer );

/* MISRA Ref 11.3.1 [Misaligned access] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
/* coverity[misra_c_2012_rule_11_3_violation] */
xRASolicitationRequest = ( ( ICMPRouterSolicitation_IPv6_t * ) &( pxICMPPacket->xICMPHeaderIPv6 ) );

pxDescriptor->xDataLength = uxNeededSize;
Expand Down
17 changes: 13 additions & 4 deletions source/FreeRTOS_Sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ static NetworkBufferDescriptor_t * prvRecvFromWaitForPacket( FreeRTOS_Socket_t c

if( lPacketCount > 0 )
{
taskENTER_CRITICAL();
vTaskSuspendAll();
{
/* The owner of the list item is the network buffer. */
pxNetworkBuffer = ( ( NetworkBufferDescriptor_t * ) listGET_OWNER_OF_HEAD_ENTRY( &( pxSocket->u.xUDP.xWaitingPacketsList ) ) );
Expand All @@ -1183,7 +1183,7 @@ static NetworkBufferDescriptor_t * prvRecvFromWaitForPacket( FreeRTOS_Socket_t c
( void ) uxListRemove( &( pxNetworkBuffer->xBufferListItem ) );
}
}
taskEXIT_CRITICAL();
( void ) xTaskResumeAll();
}

*pxEventBits = xEventBits;
Expand Down Expand Up @@ -1926,8 +1926,17 @@ BaseType_t vSocketBind( FreeRTOS_Socket_t * pxSocket,
if( pxAddress == NULL )
{
pxAddress = &xAddress;
/* Put the port to zero to be assigned later. */
pxAddress->sin_port = 0U;
/* Clear the address: */
( void ) memset( pxAddress, 0, sizeof( struct freertos_sockaddr ) );

if( pxSocket->bits.bIsIPv6 != pdFALSE_UNSIGNED )
{
pxAddress->sin_family = FREERTOS_AF_INET6;
}
else
{
pxAddress->sin_family = FREERTOS_AF_INET;
}
}
}
#endif /* ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND == 1 */
Expand Down
1 change: 1 addition & 0 deletions source/FreeRTOS_TCP_IP_IPv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ BaseType_t xProcessReceivedTCPPacket_IPV6( NetworkBufferDescriptor_t * pxDescrip
/* coverity[misra_c_2012_rule_11_3_violation] */
const IPHeader_IPv6_t * pxIPHeader_IPv6 = ( ( IPHeader_IPv6_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER ] ) );
( void ) memcpy( xRemoteIP.xIPAddress.xIP_IPv6.ucBytes, pxIPHeader_IPv6->xSourceAddress.ucBytes, sizeof( IPv6_Address_t ) );
xRemoteIP.xIs_IPv6 = pdTRUE;

/* Find the destination socket, and if not found: return a socket listing to
* the destination PORT. */
Expand Down
7 changes: 0 additions & 7 deletions source/FreeRTOS_TCP_WIN.c
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,6 @@
pxWindow->usOurPortNumber,
( unsigned ) ( ulSequenceNumber - pxWindow->rx.ulFirstSequenceNumber ),
( unsigned ) listCURRENT_LIST_LENGTH( &pxWindow->xRxSegments ) ) );
FreeRTOS_flush_logging();
}

/* Return a positive value. The packet may be accepted
Expand Down Expand Up @@ -1391,7 +1390,6 @@
( int ) pxSegment->lDataLength,
( unsigned ) ( pxWindow->ulNextTxSequenceNumber - pxWindow->tx.ulFirstSequenceNumber ),
( int ) pxSegment->lStreamPos ) );
FreeRTOS_flush_logging();
}

return lToWrite;
Expand Down Expand Up @@ -1703,7 +1701,6 @@
( int ) pxSegment->lDataLength,
( unsigned ) ( pxSegment->ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber ),
( unsigned ) pxSegment->ulSequenceNumber ) );
FreeRTOS_flush_logging();
}
}
else
Expand Down Expand Up @@ -1776,7 +1773,6 @@
( int ) pxSegment->lDataLength,
( unsigned ) ( pxSegment->ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber ),
( unsigned ) ulWindowSize ) );
FreeRTOS_flush_logging();
}
}

Expand Down Expand Up @@ -1823,7 +1819,6 @@
( int ) pxSegment->lDataLength,
( unsigned ) ( pxSegment->ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber ),
( unsigned ) ulWindowSize ) );
FreeRTOS_flush_logging();
}
}
else
Expand Down Expand Up @@ -2137,7 +2132,6 @@
FreeRTOS_debug_printf( ( "prvTCPWindowFastRetransmit: Requeue sequence number %u < %u\n",
( unsigned ) ( pxSegment->ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber ),
( unsigned ) ( ulFirst - pxWindow->tx.ulFirstSequenceNumber ) ) );
FreeRTOS_flush_logging();
}

/* Remove it from xWaitQueue. */
Expand Down Expand Up @@ -2222,7 +2216,6 @@
( unsigned ) ( ulFirst - pxWindow->tx.ulFirstSequenceNumber ),
( unsigned ) ( ulLast - pxWindow->tx.ulFirstSequenceNumber ),
( unsigned ) ( pxWindow->tx.ulCurrentSequenceNumber - pxWindow->tx.ulFirstSequenceNumber ) ) );
FreeRTOS_flush_logging();
}

return ulAckCount;
Expand Down
10 changes: 3 additions & 7 deletions source/FreeRTOS_UDP_IPv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,9 @@ BaseType_t xProcessReceivedUDPPacket_IPv4( NetworkBufferDescriptor_t * pxNetwork
{
vTaskSuspendAll();
{
taskENTER_CRITICAL();
{
/* Add the network packet to the list of packets to be
* processed by the socket. */
vListInsertEnd( &( pxSocket->u.xUDP.xWaitingPacketsList ), &( pxNetworkBuffer->xBufferListItem ) );
}
taskEXIT_CRITICAL();
/* Add the network packet to the list of packets to be
* processed by the socket. */
vListInsertEnd( &( pxSocket->u.xUDP.xWaitingPacketsList ), &( pxNetworkBuffer->xBufferListItem ) );
}
( void ) xTaskResumeAll();

Expand Down
10 changes: 3 additions & 7 deletions source/FreeRTOS_UDP_IPv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,9 @@ BaseType_t xProcessReceivedUDPPacket_IPv6( NetworkBufferDescriptor_t * pxNetwork
{
vTaskSuspendAll();
{
taskENTER_CRITICAL();
{
/* Add the network packet to the list of packets to be
* processed by the socket. */
vListInsertEnd( &( pxSocket->u.xUDP.xWaitingPacketsList ), &( pxNetworkBuffer->xBufferListItem ) );
}
taskEXIT_CRITICAL();
/* Add the network packet to the list of packets to be
* processed by the socket. */
vListInsertEnd( &( pxSocket->u.xUDP.xWaitingPacketsList ), &( pxNetworkBuffer->xBufferListItem ) );
}
( void ) xTaskResumeAll();

Expand Down
27 changes: 7 additions & 20 deletions source/include/FreeRTOSIPConfigDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
*/

#ifndef _static
/* suppressing the use of _static as it is used for other tools like cbmc */
/* coverity[misra_c_2012_rule_21_1_violation] */
/* coverity[misra_c_2012_rule_21_2_violation] */
#define _static static
#endif

Expand Down Expand Up @@ -3063,8 +3066,8 @@
#endif

#ifndef FreeRTOS_debug_printf
#ifdef configPRINTF
#define FreeRTOS_debug_printf( MSG ) if( ipconfigHAS_DEBUG_PRINTF ) configPRINTF( MSG )
#if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) && defined( configPRINTF ) )
#define FreeRTOS_debug_printf( MSG ) do { configPRINTF( MSG ); } while( ipFALSE_BOOL )
#else
#define FreeRTOS_debug_printf( MSG ) do {} while( ipFALSE_BOOL )
#endif
Expand Down Expand Up @@ -3099,31 +3102,15 @@
#endif

#ifndef FreeRTOS_printf
#ifdef configPRINTF
#define FreeRTOS_printf( MSG ) if( ipconfigHAS_PRINTF ) configPRINTF( MSG )
#if ( ( ipconfigHAS_PRINTF == 1 ) && defined( configPRINTF ) )
#define FreeRTOS_printf( MSG ) do { configPRINTF( MSG ); } while( ipFALSE_BOOL )
#else
#define FreeRTOS_printf( MSG ) do {} while( ipFALSE_BOOL )
#endif
#endif

/*---------------------------------------------------------------------------*/

/*
* FreeRTOS_flush_logging
*
* Type: Macro Function
*
* Macro that is called in cases where a lot of logging is produced.
*
* This gives the logging module a chance to flush the data.
*/

#ifndef FreeRTOS_flush_logging
#define FreeRTOS_flush_logging() if( ipconfigHAS_PRINTF || ipconfigHAS_DEBUG_PRINTF ) do {} while( ipFALSE_BOOL )
#endif

/*---------------------------------------------------------------------------*/

/*
* ipconfigTCP_IP_SANITY
*
Expand Down
28 changes: 18 additions & 10 deletions source/include/FreeRTOS_IP.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,30 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
* pointer back to the network buffer. Should be a multiple of 8 to ensure 8 byte
* alignment is maintained on architectures that require it.
*
* In order to get a 32-bit alignment of network packets, an offset of 2 bytes
* would be desirable, as defined by ipconfigPACKET_FILLER_SIZE. So the malloc'd
* In order to get a 32-bit or 64-bit alignment of network packets, an offset of 2 bytes
* is ideal as defined by ipconfigPACKET_FILLER_SIZE. So the malloc'd
* buffer will have the following contents:
* uint32_t pointer; // word-aligned
* uchar_8 filler[6];
* << ETH-header >> // half-word-aligned
* uchar_8 dest[6]; // start of pucEthernetBuffer
* uchar_8 dest[6];
* uchar16_t type;
* << IP-header >> // word-aligned
*
* +---------+-----------+---------+
* | Offset | Alignment | Length |
* | 32 | 64 | 32 | 64 | 32 | 64 |
* |----|----|-----|-----|----|----|
* | 0 | 0 | 4 | 8 | 4 | 8 | uchar_8 * pointer; // Points to the 'NetworkBufferDescriptor_t'.
* | 4 | 8 | 4 | 8 | 6 | 6 | uchar_8 filler[6]; // To give the +2 byte offset.
* |-------------------------------|
* | 10 | 14 | 4+2 | 8+2 | 6 | 6 | uchar_8 dest_mac[6]; // Destination address.
* | 16 | 20 | 4 | 8 | 6 | 6 | uchar_8 src_mac[6]; // Source address.
* | 22 | 26 | 4+2 | 4+2 | 2 | 2 | uchar16_t ethertype;
* | 24 | 28 | 4 | 4 | ~ | ~ | << IP-header >> // word-aligned, either 4 or 8 bytes.
* uint8_t ucVersionHeaderLength;
* etc
*/

#if ( ipconfigBUFFER_PADDING != 0 )
/* Use setting from FreeRTOS if defined and non-zero */
#if defined( ipconfigBUFFER_PADDING ) && ( ipconfigBUFFER_PADDING != 0 )
#define ipBUFFER_PADDING ipconfigBUFFER_PADDING
#elif ( UINTPTR_MAX > 0xFFFFFFFF )
#define ipBUFFER_PADDING ( 12U + ipconfigPACKET_FILLER_SIZE )
#else
#define ipBUFFER_PADDING ( 8U + ipconfigPACKET_FILLER_SIZE )
#endif
Expand Down
Loading

0 comments on commit 06dffe6

Please sign in to comment.