Skip to content

Commit 0f744c8

Browse files
Merge branch 'main' into dev-ip-build-sep
2 parents 50d9833 + cad1f75 commit 0f744c8

File tree

19 files changed

+1065
-443
lines changed

19 files changed

+1065
-443
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
@@ -1563,6 +1564,7 @@ x
15631564
xaxiemacif
15641565
XCOL
15651566
xemac
1567+
XEMACMAP
15661568
xemacps
15671569
XEMACPS
15681570
xemacpsp

source/FreeRTOS_ARP.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@
900900
if( pxEndPoint != NULL )
901901
{
902902
/* For multi-cast, use the first IPv4 end-point. */
903-
memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) );
903+
( void ) memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) );
904904
*( ppxEndPoint ) = pxEndPoint;
905905
eReturn = eResolutionCacheHit;
906906
}

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
@@ -1025,7 +1025,7 @@ BaseType_t FreeRTOS_IPInit_Multi( void )
10251025
{
10261026
static StaticTask_t xIPTaskBuffer;
10271027
static StackType_t xIPTaskStack[ ipconfigIP_TASK_STACK_SIZE_WORDS ];
1028-
xIPTaskHandle = xTaskCreateStatic( prvIPTask,
1028+
xIPTaskHandle = xTaskCreateStatic( &prvIPTask,
10291029
"IP-Task",
10301030
ipconfigIP_TASK_STACK_SIZE_WORDS,
10311031
NULL,
@@ -1040,7 +1040,7 @@ BaseType_t FreeRTOS_IPInit_Multi( void )
10401040
}
10411041
#else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
10421042
{
1043-
xReturn = xTaskCreate( prvIPTask,
1043+
xReturn = xTaskCreate( &prvIPTask,
10441044
"IP-task",
10451045
ipconfigIP_TASK_STACK_SIZE_WORDS,
10461046
NULL,

source/FreeRTOS_TCP_State_Handling.c

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

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

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

621629
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/Zynq/NetworkInterface.c

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -254,42 +254,56 @@ static BaseType_t xZynqNetworkInterfaceInitialise( NetworkInterface_t * pxInterf
254254
/* Initialize the mac and set the MAC address at position 1. */
255255
XEmacPs_SetMacAddress( pxEMAC_PS, ( void * ) pxEndPoint->xMACAddress.ucBytes, 1 );
256256

257-
#if ( ipconfigUSE_LLMNR == 1 )
257+
#if ( ipconfigIS_ENABLED( ipconfigUSE_LLMNR ) )
258258
{
259-
/* Also add LLMNR multicast MAC address. */
260-
#if ( ipconfigUSE_IPv6 == 0 )
259+
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) )
261260
{
262261
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAddress.ucBytes );
263262
}
264-
#else
263+
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) */
264+
265+
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) )
265266
{
266-
NetworkEndPoint_t * pxEndPoint;
267-
NetworkInterface_t * pxInterface = pxMyInterfaces[ xEMACIndex ];
267+
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAddressIPv6.ucBytes );
268+
}
269+
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) ) */
270+
}
271+
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_LLMNR ) ) */
268272

269-
for( pxEndPoint = FreeRTOS_FirstEndPoint( pxInterface );
270-
pxEndPoint != NULL;
271-
pxEndPoint = FreeRTOS_NextEndPoint( pxInterface, pxEndPoint ) )
272-
{
273-
if( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED )
274-
{
275-
unsigned char ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 };
276-
ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ];
277-
ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ];
278-
ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ];
279-
XEmacPs_SetHash( pxEMAC_PS, ( void * ) ucMACAddress );
280-
}
281-
}
273+
#if ( ipconfigIS_ENABLED( ipconfigUSE_MDNS ) )
274+
{
275+
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) )
276+
{
277+
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddress.ucBytes );
278+
}
279+
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) */
282280

283-
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAddressIPv6.ucBytes );
281+
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) )
282+
{
283+
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddressIPv6.ucBytes );
284284
}
285-
#endif /* if ( ipconfigUSE_IPv6 == 0 ) */
285+
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) ) */
286286
}
287-
#endif /* ipconfigUSE_LLMNR == 1 */
287+
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_MDNS) ) */
288288

289-
#if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) )
290-
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddress.ucBytes );
291-
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddressIPv6.ucBytes );
292-
#endif
289+
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) )
290+
{
291+
/* set the solicited-node multicast address */
292+
for( NetworkEndPoint_t * pxEndPointIter = FreeRTOS_FirstEndPoint( pxInterface );
293+
pxEndPointIter != NULL;
294+
pxEndPointIter = FreeRTOS_NextEndPoint( pxInterface, pxEndPointIter ) )
295+
{
296+
if( pxEndPointIter->bits.bIPv6 != pdFALSE_UNSIGNED )
297+
{
298+
unsigned char ucSsolicitedNodeMAC[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 };
299+
ucSsolicitedNodeMAC[ 3 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 13 ];
300+
ucSsolicitedNodeMAC[ 4 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 14 ];
301+
ucSsolicitedNodeMAC[ 5 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 15 ];
302+
XEmacPs_SetHash( pxEMAC_PS, ( void * ) ucSsolicitedNodeMAC );
303+
}
304+
}
305+
}
306+
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) ) */
293307

294308
pxEndPoint = FreeRTOS_NextEndPoint( pxInterface, pxEndPoint );
295309

@@ -378,7 +392,8 @@ static BaseType_t xZynqNetworkInterfaceOutput( NetworkInterface_t * pxInterface,
378392
* the protocol checksum to have a value of zero. */
379393
pxPacket = ( ProtocolPacket_t * ) ( pxBuffer->pucEthernetBuffer );
380394

381-
#if ( ipconfigUSE_IPv6 != 0 )
395+
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) )
396+
{
382397
ICMPPacket_IPv6_t * pxICMPPacket = ( ICMPPacket_IPv6_t * ) pxBuffer->pucEthernetBuffer;
383398

384399
if( ( pxPacket->xICMPPacket.xEthernetHeader.usFrameType == ipIPv6_FRAME_TYPE ) &&
@@ -389,16 +404,21 @@ static BaseType_t xZynqNetworkInterfaceOutput( NetworkInterface_t * pxInterface,
389404
* so for ICMP and other protocols it must be done manually. */
390405
usGenerateProtocolChecksum( pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength, pdTRUE );
391406
}
392-
#endif
407+
}
408+
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) ) */
393409

394-
if( ( pxPacket->xICMPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) &&
395-
( pxPacket->xICMPPacket.xIPHeader.ucProtocol == ipPROTOCOL_ICMP ) )
410+
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) )
396411
{
397-
/* The EMAC will calculate the checksum of the IP-header.
398-
* It can only calculate protocol checksums of UDP and TCP,
399-
* so for ICMP and other protocols it must be done manually. */
400-
usGenerateProtocolChecksum( pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength, pdTRUE );
412+
if( ( pxPacket->xICMPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) &&
413+
( pxPacket->xICMPPacket.xIPHeader.ucProtocol == ipPROTOCOL_ICMP ) )
414+
{
415+
/* The EMAC will calculate the checksum of the IP-header.
416+
* It can only calculate protocol checksums of UDP and TCP,
417+
* so for ICMP and other protocols it must be done manually. */
418+
usGenerateProtocolChecksum( pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength, pdTRUE );
419+
}
401420
}
421+
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) ) */
402422
}
403423
#endif /* ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM */
404424

0 commit comments

Comments
 (0)