Skip to content

Commit 3e948ae

Browse files
Merge branch 'main' into main
2 parents 3e63765 + 875bfd2 commit 3e948ae

File tree

10 files changed

+164
-26
lines changed

10 files changed

+164
-26
lines changed

source/FreeRTOS_ARP.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress,
962962
MACAddress_t * const pxMACAddress,
963963
struct xNetworkEndPoint ** ppxEndPoint )
964964
{
965-
eARPLookupResult_t eReturn;
965+
eARPLookupResult_t eReturn = eCantSendPacket;
966966
uint32_t ulAddressToLookup;
967967
NetworkEndPoint_t * pxEndPoint = NULL;
968968

@@ -974,12 +974,21 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress,
974974
ulAddressToLookup = *pulIPAddress;
975975
pxEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( ulAddressToLookup );
976976

977-
if( xIsIPv4Multicast( ulAddressToLookup ) != 0 )
977+
if( xIsIPv4Loopback( ulAddressToLookup ) != 0 )
978+
{
979+
if( pxEndPoint != NULL )
980+
{
981+
/* For multi-cast, use the first IPv4 end-point. */
982+
memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) );
983+
*( ppxEndPoint ) = pxEndPoint;
984+
eReturn = eARPCacheHit;
985+
}
986+
}
987+
else if( xIsIPv4Multicast( ulAddressToLookup ) != 0 )
978988
{
979989
/* Get the lowest 23 bits of the IP-address. */
980990
vSetMultiCastIPv4MacAddress( ulAddressToLookup, pxMACAddress );
981991

982-
eReturn = eCantSendPacket;
983992
pxEndPoint = FreeRTOS_FirstEndPoint( NULL );
984993

985994
for( ;

source/FreeRTOS_DNS_Callback.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
BaseType_t xMatching;
7777
DNSCallback_t * pxCallback = ( ( DNSCallback_t * ) listGET_LIST_ITEM_OWNER( pxIterator ) );
7878
#if ( ipconfigUSE_MDNS == 1 )
79-
/* mDNS port 5353. */
80-
if( pxSet->usPortNumber == FreeRTOS_htons( ipMDNS_PORT ) )
79+
/* mDNS port 5353. Host byte order comparison. */
80+
if( pxSet->usPortNumber == ipMDNS_PORT )
8181
{
8282
/* In mDNS, the query ID field is ignored and the
8383
* hostname will be compared with outstanding requests. */

source/FreeRTOS_Sockets.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,17 +2356,25 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket )
23562356
uint32_t ulNewValue;
23572357
BaseType_t xReturn;
23582358

2359+
if( ( FreeRTOS_issocketconnected( pxSocket ) == pdTRUE ) )
2360+
{
2361+
/* If this socket is the child of a listening socket, the remote client may or may not have already sent
2362+
* us data. If data was already sent, then pxSocket->u.xTCP.rxStream != NULL and this call will fail.
2363+
* Warn the user about this inconsistent behavior. */
2364+
FreeRTOS_printf( ( "Warning: Changing buffer/window properties on a connected socket may fail." ) );
2365+
}
2366+
23592367
if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP )
23602368
{
2361-
FreeRTOS_debug_printf( ( "Set SO_%sBUF: wrong socket type\n",
2362-
( lOptionName == FREERTOS_SO_SNDBUF ) ? "SND" : "RCV" ) );
2369+
FreeRTOS_printf( ( "Set SO_%sBUF: wrong socket type\n",
2370+
( lOptionName == FREERTOS_SO_SNDBUF ) ? "SND" : "RCV" ) );
23632371
xReturn = -pdFREERTOS_ERRNO_EINVAL;
23642372
}
23652373
else if( ( ( lOptionName == FREERTOS_SO_SNDBUF ) && ( pxSocket->u.xTCP.txStream != NULL ) ) ||
23662374
( ( lOptionName == FREERTOS_SO_RCVBUF ) && ( pxSocket->u.xTCP.rxStream != NULL ) ) )
23672375
{
2368-
FreeRTOS_debug_printf( ( "Set SO_%sBUF: buffer already created\n",
2369-
( lOptionName == FREERTOS_SO_SNDBUF ) ? "SND" : "RCV" ) );
2376+
FreeRTOS_printf( ( "Set SO_%sBUF: buffer already created\n",
2377+
( lOptionName == FREERTOS_SO_SNDBUF ) ? "SND" : "RCV" ) );
23702378
xReturn = -pdFREERTOS_ERRNO_EINVAL;
23712379
}
23722380
else

source/portable/NetworkInterface/ATSAM4E/NetworkInterface.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@
8888
static BaseType_t xGMACWaitLS( TickType_t xMaxTime );
8989

9090
#if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 1 ) && ( ipconfigHAS_TX_CRC_OFFLOADING == 0 )
91-
void vGMACGenerateChecksum( uint8_t * apBuffer );
91+
void vGMACGenerateChecksum( uint8_t * pucBuffer,
92+
size_t uxLength );
9293
#endif
9394

9495
/*
@@ -405,9 +406,10 @@ static BaseType_t xGMACWaitLS( TickType_t xMaxTime )
405406

406407
/*#if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 1 ) && ( ipconfigHAS_TX_CRC_OFFLOADING == 0 ) */
407408

408-
void vGMACGenerateChecksum( uint8_t * apBuffer )
409+
void vGMACGenerateChecksum( uint8_t * pucBuffer,
410+
size_t uxLength )
409411
{
410-
ProtocolPacket_t * xProtPacket = ( ProtocolPacket_t * ) apBuffer;
412+
ProtocolPacket_t * xProtPacket = ( ProtocolPacket_t * ) pucBuffer;
411413

412414
if( xProtPacket->xTCPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE )
413415
{
@@ -419,7 +421,7 @@ void vGMACGenerateChecksum( uint8_t * apBuffer )
419421
pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum );
420422

421423
/* Calculate the TCP checksum for an outgoing packet. */
422-
usGenerateProtocolChecksum( ( uint8_t * ) apBuffer, pdTRUE );
424+
usGenerateProtocolChecksum( ( uint8_t * ) pucBuffer, uxLength, pdTRUE );
423425
}
424426
}
425427

source/portable/NetworkInterface/ATSAM4E/gmac.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,8 @@ uint32_t gmac_dev_read( gmac_device_t * p_gmac_dev,
642642
}
643643

644644

645-
extern void vGMACGenerateChecksum( uint8_t * apBuffer );
645+
extern void vGMACGenerateChecksum( uint8_t * pucBuffer,
646+
size_t uxLength );
646647

647648
/**
648649
* \brief Send ulLength bytes from pcFrom. This copies the buffer to one of the
@@ -715,7 +716,7 @@ uint32_t gmac_dev_write( gmac_device_t * p_gmac_dev,
715716
memcpy( ( void * ) p_tx_td->addr, p_buffer, ul_size );
716717
}
717718
#endif /* ipconfigZERO_COPY_TX_DRIVER */
718-
vGMACGenerateChecksum( ( uint8_t * ) p_tx_td->addr );
719+
vGMACGenerateChecksum( ( uint8_t * ) p_tx_td->addr, ( size_t ) ul_size );
719720
}
720721

721722
#if ( GMAC_USES_TX_CALLBACK != 0 )

source/portable/NetworkInterface/DriverSAM/NetworkInterface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static BaseType_t xPHY_Write( BaseType_t xAddress,
161161
uint32_t ulValue );
162162

163163
#if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 1 ) && ( ipconfigHAS_TX_CRC_OFFLOADING == 0 )
164-
void vGMACGenerateChecksum( uint8_t * apBuffer,
164+
void vGMACGenerateChecksum( uint8_t * pucBuffer,
165165
size_t uxLength );
166166
#endif
167167

source/portable/NetworkInterface/DriverSAM/gmac_SAM.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,7 @@
15391539

15401540
/* The SAM4E has problems offloading checksums for transmission.
15411541
* The SAME70 does not set the CRC for ICMP packets (ping). */
1542-
extern void vGMACGenerateChecksum( uint8_t * apBuffer,
1542+
extern void vGMACGenerateChecksum( uint8_t * pucBuffer,
15431543
size_t uxLength );
15441544

15451545
/*/ @cond 0 */

source/portable/NetworkInterface/loopback/loopbackNetworkInterface.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,23 @@ static BaseType_t prvLoopback_Output( NetworkInterface_t * pxInterface,
134134
}
135135

136136
{
137-
MACAddress_t xMACAddress;
137+
const MACAddress_t * pxMACAddress = &( pxDescriptor->pxEndPoint->xMACAddress );
138138

139139
if( pxDescriptor->pxEndPoint->bits.bIPv6 != 0 )
140140
{
141141
#if ( ipconfigUSE_IPv6 != 0 )
142-
if( xIsIPv6Loopback( &( pxDescriptor->xIPAddress ) ) != pdFALSE )
142+
if( xIsIPv6Loopback( &( pxDescriptor->xIPAddress.xIP_IPv6 ) ) != pdFALSE )
143143
{
144-
vNDRefreshCacheEntry( &xMACAddress, &( pxDescriptor->xIPAddress.xIP_IPv6 ), pxDescriptor->pxEndPoint );
144+
vNDRefreshCacheEntry( pxMACAddress, &( pxDescriptor->xIPAddress.xIP_IPv6 ), pxDescriptor->pxEndPoint );
145145
}
146146
#endif
147147
}
148148
else
149149
{
150150
#if ( ipconfigUSE_IPv4 != 0 )
151-
if( xIsIPv4Loopback( pxDescriptor->xIPAddress.ulIP_IPv4 ) )
151+
if( xIsIPv4Loopback( pxDescriptor->xIPAddress.ulIP_IPv4 ) != pdFALSE )
152152
{
153-
vARPRefreshCacheEntry( &xMACAddress, pxDescriptor->xIPAddress.ulIP_IPv4, pxDescriptor->pxEndPoint );
153+
vARPRefreshCacheEntry( pxMACAddress, pxDescriptor->xIPAddress.ulIP_IPv4, pxDescriptor->pxEndPoint );
154154
}
155155
#endif
156156
}
@@ -170,11 +170,21 @@ static BaseType_t prvLoopback_Output( NetworkInterface_t * pxInterface,
170170
xRxEvent.eEventType = eNetworkRxEvent;
171171
xRxEvent.pvData = ( void * ) pxDescriptor;
172172

173-
if( xSendEventStructToIPTask( &xRxEvent, 0u ) != pdTRUE )
173+
pxDescriptor->pxInterface = xLoopbackInterface;
174+
pxDescriptor->pxEndPoint = FreeRTOS_MatchingEndpoint( xLoopbackInterface, pxDescriptor->pucEthernetBuffer );
175+
176+
if( pxDescriptor->pxEndPoint == NULL )
177+
{
178+
vReleaseNetworkBufferAndDescriptor( pxDescriptor );
179+
iptraceETHERNET_RX_EVENT_LOST();
180+
FreeRTOS_printf( ( "prvLoopback_Output: Can not find a proper endpoint\n" ) );
181+
}
182+
else if( xSendEventStructToIPTask( &xRxEvent, 0u ) != pdTRUE )
174183
{
184+
/* Sending failed, release the descriptor. */
175185
vReleaseNetworkBufferAndDescriptor( pxDescriptor );
176186
iptraceETHERNET_RX_EVENT_LOST();
177-
FreeRTOS_printf( ( "prvEMACRxPoll: Can not queue return packet!\n" ) );
187+
FreeRTOS_printf( ( "prvLoopback_Output: Can not queue return packet!\n" ) );
178188
}
179189
}
180190

0 commit comments

Comments
 (0)