Skip to content

Commit 9a82d35

Browse files
Merge branch 'main' into cbmc-v6
2 parents a73ab0d + cad1f75 commit 9a82d35

26 files changed

+1116
-466
lines changed

.github/.cSpellWords.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ DIVIDEBY
247247
DIVIDEDBY
248248
DLPSTATE
249249
DMAARBITRATION
250+
DMAB
250251
DMABD
251252
DMABMR
252253
DMAC
@@ -1562,6 +1563,7 @@ x
15621563
xaxiemacif
15631564
XCOL
15641565
xemac
1566+
XEMACMAP
15651567
xemacps
15661568
XEMACPS
15671569
xemacpsp

source/FreeRTOS_ARP.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress,
979979
if( pxEndPoint != NULL )
980980
{
981981
/* For multi-cast, use the first IPv4 end-point. */
982-
memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) );
982+
( void ) memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) );
983983
*( ppxEndPoint ) = pxEndPoint;
984984
eReturn = eARPCacheHit;
985985
}

source/FreeRTOS_DNS.c

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,41 +63,45 @@ const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc }
6363
/** @brief The IPv6 link-scope multicast MAC address */
6464
const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x03 } };
6565

66+
#if ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
6667
/** @brief The IPv6 link-scope multicast address */
67-
const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6 =
68-
{
69-
{ /* ff02::1:3 */
70-
0xff, 0x02,
71-
0x00, 0x00,
72-
0x00, 0x00,
73-
0x00, 0x00,
74-
0x00, 0x00,
75-
0x00, 0x00,
76-
0x00, 0x01,
77-
0x00, 0x03,
78-
}
79-
};
68+
const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6 =
69+
{
70+
{ /* ff02::1:3 */
71+
0xff, 0x02,
72+
0x00, 0x00,
73+
0x00, 0x00,
74+
0x00, 0x00,
75+
0x00, 0x00,
76+
0x00, 0x00,
77+
0x00, 0x01,
78+
0x00, 0x03,
79+
}
80+
};
81+
#endif /* ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */
8082

8183
/** @brief The MAC address used for MDNS. */
8284
const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } };
8385

8486
/** @brief The IPv6 multicast DNS MAC address. */
8587
const MACAddress_t xMDNS_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } };
8688

89+
#if ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
8790
/** @brief multicast DNS IPv6 address */
88-
const IPv6_Address_t ipMDNS_IP_ADDR_IPv6 =
89-
{
90-
{ /* ff02::fb */
91-
0xff, 0x02,
92-
0x00, 0x00,
93-
0x00, 0x00,
94-
0x00, 0x00,
95-
0x00, 0x00,
96-
0x00, 0x00,
97-
0x00, 0x00,
98-
0x00, 0xfb,
99-
}
100-
};
91+
const IPv6_Address_t ipMDNS_IP_ADDR_IPv6 =
92+
{
93+
{ /* ff02::fb */
94+
0xff, 0x02,
95+
0x00, 0x00,
96+
0x00, 0x00,
97+
0x00, 0x00,
98+
0x00, 0x00,
99+
0x00, 0x00,
100+
0x00, 0x00,
101+
0x00, 0xfb,
102+
}
103+
};
104+
#endif /* ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */
101105

102106
/* Exclude the entire file if DNS is not enabled. */
103107
#if ( ipconfigUSE_DNS != 0 )

source/FreeRTOS_IP.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ BaseType_t FreeRTOS_IPInit_Multi( void )
982982
{
983983
static StaticTask_t xIPTaskBuffer;
984984
static StackType_t xIPTaskStack[ ipconfigIP_TASK_STACK_SIZE_WORDS ];
985-
xIPTaskHandle = xTaskCreateStatic( prvIPTask,
985+
xIPTaskHandle = xTaskCreateStatic( &prvIPTask,
986986
"IP-Task",
987987
ipconfigIP_TASK_STACK_SIZE_WORDS,
988988
NULL,
@@ -997,7 +997,7 @@ BaseType_t FreeRTOS_IPInit_Multi( void )
997997
}
998998
#else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
999999
{
1000-
xReturn = xTaskCreate( prvIPTask,
1000+
xReturn = xTaskCreate( &prvIPTask,
10011001
"IP-task",
10021002
ipconfigIP_TASK_STACK_SIZE_WORDS,
10031003
NULL,

source/FreeRTOS_IPv4.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,7 @@ enum eFrameProcessingResult prvAllowIPPacketIPv4( const struct xIP_PACKET * cons
321321
( FreeRTOS_FindEndPointOnIP_IPv4( ulDestinationIPAddress ) == NULL ) &&
322322
/* Is it an IPv4 broadcast address x.x.x.255 ? */
323323
( ( FreeRTOS_ntohl( ulDestinationIPAddress ) & 0xffU ) != 0xffU ) &&
324-
( xIsIPv4Multicast( ulDestinationIPAddress ) == pdFALSE ) &&
325-
/* Or (during DHCP negotiation) we have no IP-address yet? */
326-
( FreeRTOS_IsNetworkUp() != pdFALSE ) )
324+
( xIsIPv4Multicast( ulDestinationIPAddress ) == pdFALSE ) )
327325
{
328326
/* Packet is not for this node, release it */
329327
eReturn = eReleaseBuffer;

source/FreeRTOS_Routing.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ struct xIPv6_Couple
388388
#endif
389389
{
390390
if( ( ulIPAddress == 0U ) ||
391-
( pxEndPoint->ipv4_settings.ulIPAddress == 0U ) ||
392391
( pxEndPoint->ipv4_settings.ulIPAddress == ulIPAddress ) )
393392
{
394393
break;

source/FreeRTOS_TCP_State_Handling.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,8 @@
584584
{
585585
/* Peer is requesting to stop, see if we're really finished. */
586586
xMayClose = pdTRUE;
587+
ulIntermediateResult = ulSequenceNumber + ulReceiveLength - pxTCPWindow->rx.ulCurrentSequenceNumber;
588+
lDistance = ( int32_t ) ulIntermediateResult;
587589

588590
/* Checks are only necessary if we haven't sent a FIN yet. */
589591
if( pxSocket->u.xTCP.bits.bFinSent == pdFALSE_UNSIGNED )
@@ -601,22 +603,28 @@
601603
( int ) bRxComplete,
602604
( int ) bTxDone ) );
603605
xMayClose = pdFALSE;
604-
}
605-
else
606-
{
607-
ulIntermediateResult = ulSequenceNumber + ulReceiveLength - pxTCPWindow->rx.ulCurrentSequenceNumber;
608-
lDistance = ( int32_t ) ulIntermediateResult;
609606

610-
if( lDistance > 1 )
607+
/* This action is necessary to ensure proper handling of any subsequent packets that
608+
* may arrive after the refused FIN packet. Note that we only update it when the sequence
609+
* of FIN packet is correct. Otherwise, we wait for re-transmission. */
610+
if( lDistance <= 1 )
611611
{
612-
FreeRTOS_debug_printf( ( "Refusing FIN: Rx not complete %d (cur %u high %u)\n",
613-
( int ) lDistance,
614-
( unsigned ) ( pxTCPWindow->rx.ulCurrentSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber ),
615-
( unsigned ) ( pxTCPWindow->rx.ulHighestSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber ) ) );
616-
617-
xMayClose = pdFALSE;
612+
pxTCPWindow->rx.ulCurrentSequenceNumber = pxTCPWindow->rx.ulFINSequenceNumber + 1U;
618613
}
619614
}
615+
else if( lDistance > 1 )
616+
{
617+
FreeRTOS_debug_printf( ( "Refusing FIN: Rx not complete %d (cur %u high %u)\n",
618+
( int ) lDistance,
619+
( unsigned ) ( pxTCPWindow->rx.ulCurrentSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber ),
620+
( unsigned ) ( pxTCPWindow->rx.ulHighestSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber ) ) );
621+
622+
xMayClose = pdFALSE;
623+
}
624+
else
625+
{
626+
/* Empty else marker. */
627+
}
620628
}
621629

622630
if( xTCPWindowLoggingLevel > 0 )

source/include/FreeRTOS_DNS.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ extern const MACAddress_t xLLMNR_MacAddress;
4747
/* The LLMNR IPv6 MAC address is 33:33:00:01:00:03 */
4848
extern const MACAddress_t xLLMNR_MacAddressIPv6;
4949

50+
#if ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
5051
/* The LLMNR IPv6 address is ff02::1:3 */
51-
extern const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6;
52+
extern const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6;
53+
#endif /* ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */
5254

5355
/* The MDNS MAC address is 01:00:5e:00:00:fc */
5456
extern const MACAddress_t xMDNS_MacAddress;
@@ -61,8 +63,10 @@ extern const MACAddress_t xMDNS_MacAddressIPv6;
6163
/* Guarantee backward compatibility. */
6264
#define xMDNS_MACAddressIPv6 xMDNS_MacAddressIPv6
6365

66+
#if ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
6467
/* The MDNS IPv6 address is ff02::1:3 */
65-
extern const IPv6_Address_t ipMDNS_IP_ADDR_IPv6;
68+
extern const IPv6_Address_t ipMDNS_IP_ADDR_IPv6;
69+
#endif /* ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */
6670

6771
/** @brief While doing integration tests, it is necessary to influence the choice
6872
* between DNS/IPv4 and DNS/IPv4. Depending on this, a DNS server will be

source/portable/NetworkInterface/ATSAME5x/NetworkInterface.c

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@
9090
static uint8_t ucLLMNR_MAC_address[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0xFC };
9191
#endif
9292

93+
/* Check if the raw Ethernet frame is ICMP */
94+
static BaseType_t isICMP( const NetworkBufferDescriptor_t * pxDescriptor );
95+
9396
/* Receive task refresh time */
9497
#define RECEIVE_BLOCK_TIME_MS 100
9598

@@ -272,14 +275,41 @@ BaseType_t xATSAM5x_NetworkInterfaceInitialise( NetworkInterface_t * pxInterface
272275
return xATSAM5x_PHYGetLinkStatus( NULL );
273276
}
274277

278+
/* Check if the raw Ethernet frame is ICMP */
279+
static BaseType_t isICMP( const NetworkBufferDescriptor_t * pxDescriptor )
280+
{
281+
BaseType_t xReturn = pdFALSE;
282+
283+
const IPPacket_t * pkt = ( const IPPacket_t * ) pxDescriptor->pucEthernetBuffer;
284+
285+
if( pkt->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE )
286+
{
287+
if( pkt->xIPHeader.ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP )
288+
{
289+
xReturn = pdTRUE;
290+
}
291+
}
292+
293+
#if ipconfigUSE_IPv6 != 0
294+
else if( pkt->xEthernetHeader.usFrameType == ipIPv6_FRAME_TYPE )
295+
{
296+
ICMPPacket_IPv6_t * icmp6 = ( ICMPPacket_IPv6_t * ) pxDescriptor->pucEthernetBuffer;
297+
298+
if( icmp6->xIPHeader.ucNextHeader == ipPROTOCOL_ICMP_IPv6 )
299+
{
300+
xReturn = pdTRUE;
301+
}
302+
}
303+
#endif
304+
return xReturn;
305+
}
275306

276307
static void prvEMACDeferredInterruptHandlerTask( void * pvParameters )
277308
{
278309
NetworkBufferDescriptor_t * pxBufferDescriptor;
279310
size_t xBytesReceived = 0, xBytesRead = 0;
280311

281312
uint16_t xICMPChecksumResult = ipCORRECT_CRC;
282-
const IPPacket_t * pxIPPacket;
283313

284314

285315
/* Used to indicate that xSendEventStructToIPTask() is being called because
@@ -336,15 +366,13 @@ static void prvEMACDeferredInterruptHandlerTask( void * pvParameters )
336366
{
337367
/* the Atmel SAM GMAC peripheral does not support hardware CRC offloading for ICMP packets.
338368
* It must therefore be implemented in software. */
339-
pxIPPacket = ( IPPacket_t const * ) pxBufferDescriptor->pucEthernetBuffer;
340-
341-
if( pxIPPacket->xIPHeader.ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP )
369+
if( isICMP( pxBufferDescriptor ) == pdTRUE )
342370
{
343371
xICMPChecksumResult = usGenerateProtocolChecksum( pxBufferDescriptor->pucEthernetBuffer, pxBufferDescriptor->xDataLength, pdFALSE );
344372
}
345373
else
346374
{
347-
xICMPChecksumResult = ipCORRECT_CRC; /* Reset the result value in case this is not an ICMP packet. */
375+
xICMPChecksumResult = ipCORRECT_CRC; /* Checksum already verified by GMAC */
348376
}
349377
}
350378
#endif /* if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 1 ) */
@@ -440,9 +468,7 @@ BaseType_t xATSAM5x_NetworkInterfaceOutput( NetworkInterface_t * pxInterface,
440468
{
441469
/* the Atmel SAM GMAC peripheral does not support hardware CRC offloading for ICMP packets.
442470
* It must therefore be implemented in software. */
443-
const IPPacket_t * pxIPPacket = ( IPPacket_t const * ) pxDescriptor->pucEthernetBuffer;
444-
445-
if( pxIPPacket->xIPHeader.ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP )
471+
if( isICMP( pxDescriptor ) == pdTRUE )
446472
{
447473
( void ) usGenerateProtocolChecksum( pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength, pdTRUE );
448474
}

source/portable/NetworkInterface/RX/NetworkInterface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of
1313
* this software. By using this software, you agree to the additional terms and conditions found by accessing the
1414
* following link:
15-
* http://www.renesas.com/disclaimer
15+
* https://www.renesas.com/en/document/oth/disclaimer8
1616
*
1717
* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved.
1818
***********************************************************************************************************************/

0 commit comments

Comments
 (0)