Skip to content

Commit ced2fd6

Browse files
Merge branch 'main' into cbmc-v6
2 parents 6799e41 + 8aebab7 commit ced2fd6

File tree

10 files changed

+173
-49
lines changed

10 files changed

+173
-49
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/FreeRTOS_Stream_Buffer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ size_t uxStreamBufferAdd( StreamBuffer_t * const pxBuffer,
307307

308308
/* The below update to the stream buffer members must happen
309309
* atomically. */
310-
vTaskSuspendAll();
310+
taskENTER_CRITICAL();
311311
{
312312
if( uxOffset == 0U )
313313
{
@@ -328,7 +328,7 @@ size_t uxStreamBufferAdd( StreamBuffer_t * const pxBuffer,
328328
pxBuffer->uxFront = uxNextHead;
329329
}
330330
}
331-
( void ) xTaskResumeAll();
331+
taskEXIT_CRITICAL();
332332
}
333333

334334
return uxCount;

source/portable/NetworkInterface/RX/NetworkInterface.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ void prvLinkStatusChange( BaseType_t xStatus );
101101

102102
/*-----------------------------------------------------------*/
103103

104-
NetworkInterface_t * pxRX_FillInterfaceDescriptor( BaseType_t xEMACIndex,
105-
NetworkInterface_t * pxInterface );
104+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE != 0 )
105+
NetworkInterface_t * pxRX_FillInterfaceDescriptor( BaseType_t xEMACIndex,
106+
NetworkInterface_t * pxInterface );
107+
#endif
106108

107109
/* Function to initialise the network interface */
108110
BaseType_t xRX_NetworkInterfaceInitialise( NetworkInterface_t * pxInterface );
@@ -136,6 +138,14 @@ NetworkInterface_t * pxRX_FillInterfaceDescriptor( BaseType_t xEMACIndex,
136138
return pxInterface;
137139
}
138140

141+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE != 0 )
142+
NetworkInterface_t * pxFillInterfaceDescriptor( BaseType_t xEMACIndex,
143+
NetworkInterface_t * pxInterface )
144+
{
145+
return pxRX_FillInterfaceDescriptor( xEMACIndex, pxInterface );
146+
}
147+
#endif
148+
139149
/***********************************************************************************************************************
140150
* Function Name: xRX_NetworkInterfaceInitialise ()
141151
* Description : Initialization of Ethernet driver.

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)