Skip to content

Commit

Permalink
Merge branch 'main' into cbmc-v6
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-josi-aws authored Sep 18, 2024
2 parents 6799e41 + 8aebab7 commit ced2fd6
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 49 deletions.
15 changes: 12 additions & 3 deletions source/FreeRTOS_ARP.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress,
MACAddress_t * const pxMACAddress,
struct xNetworkEndPoint ** ppxEndPoint )
{
eARPLookupResult_t eReturn;
eARPLookupResult_t eReturn = eCantSendPacket;
uint32_t ulAddressToLookup;
NetworkEndPoint_t * pxEndPoint = NULL;

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

if( xIsIPv4Multicast( ulAddressToLookup ) != 0 )
if( xIsIPv4Loopback( ulAddressToLookup ) != 0 )
{
if( pxEndPoint != NULL )
{
/* For multi-cast, use the first IPv4 end-point. */
memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) );
*( ppxEndPoint ) = pxEndPoint;
eReturn = eARPCacheHit;
}
}
else if( xIsIPv4Multicast( ulAddressToLookup ) != 0 )
{
/* Get the lowest 23 bits of the IP-address. */
vSetMultiCastIPv4MacAddress( ulAddressToLookup, pxMACAddress );

eReturn = eCantSendPacket;
pxEndPoint = FreeRTOS_FirstEndPoint( NULL );

for( ;
Expand Down
4 changes: 2 additions & 2 deletions source/FreeRTOS_DNS_Callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
BaseType_t xMatching;
DNSCallback_t * pxCallback = ( ( DNSCallback_t * ) listGET_LIST_ITEM_OWNER( pxIterator ) );
#if ( ipconfigUSE_MDNS == 1 )
/* mDNS port 5353. */
if( pxSet->usPortNumber == FreeRTOS_htons( ipMDNS_PORT ) )
/* mDNS port 5353. Host byte order comparison. */
if( pxSet->usPortNumber == ipMDNS_PORT )
{
/* In mDNS, the query ID field is ignored and the
* hostname will be compared with outstanding requests. */
Expand Down
16 changes: 12 additions & 4 deletions source/FreeRTOS_Sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -2356,17 +2356,25 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket )
uint32_t ulNewValue;
BaseType_t xReturn;

if( ( FreeRTOS_issocketconnected( pxSocket ) == pdTRUE ) )
{
/* If this socket is the child of a listening socket, the remote client may or may not have already sent
* us data. If data was already sent, then pxSocket->u.xTCP.rxStream != NULL and this call will fail.
* Warn the user about this inconsistent behavior. */
FreeRTOS_printf( ( "Warning: Changing buffer/window properties on a connected socket may fail." ) );
}

if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP )
{
FreeRTOS_debug_printf( ( "Set SO_%sBUF: wrong socket type\n",
( lOptionName == FREERTOS_SO_SNDBUF ) ? "SND" : "RCV" ) );
FreeRTOS_printf( ( "Set SO_%sBUF: wrong socket type\n",
( lOptionName == FREERTOS_SO_SNDBUF ) ? "SND" : "RCV" ) );
xReturn = -pdFREERTOS_ERRNO_EINVAL;
}
else if( ( ( lOptionName == FREERTOS_SO_SNDBUF ) && ( pxSocket->u.xTCP.txStream != NULL ) ) ||
( ( lOptionName == FREERTOS_SO_RCVBUF ) && ( pxSocket->u.xTCP.rxStream != NULL ) ) )
{
FreeRTOS_debug_printf( ( "Set SO_%sBUF: buffer already created\n",
( lOptionName == FREERTOS_SO_SNDBUF ) ? "SND" : "RCV" ) );
FreeRTOS_printf( ( "Set SO_%sBUF: buffer already created\n",
( lOptionName == FREERTOS_SO_SNDBUF ) ? "SND" : "RCV" ) );
xReturn = -pdFREERTOS_ERRNO_EINVAL;
}
else
Expand Down
4 changes: 2 additions & 2 deletions source/FreeRTOS_Stream_Buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ size_t uxStreamBufferAdd( StreamBuffer_t * const pxBuffer,

/* The below update to the stream buffer members must happen
* atomically. */
vTaskSuspendAll();
taskENTER_CRITICAL();
{
if( uxOffset == 0U )
{
Expand All @@ -328,7 +328,7 @@ size_t uxStreamBufferAdd( StreamBuffer_t * const pxBuffer,
pxBuffer->uxFront = uxNextHead;
}
}
( void ) xTaskResumeAll();
taskEXIT_CRITICAL();
}

return uxCount;
Expand Down
14 changes: 12 additions & 2 deletions source/portable/NetworkInterface/RX/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ void prvLinkStatusChange( BaseType_t xStatus );

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

NetworkInterface_t * pxRX_FillInterfaceDescriptor( BaseType_t xEMACIndex,
NetworkInterface_t * pxInterface );
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE != 0 )
NetworkInterface_t * pxRX_FillInterfaceDescriptor( BaseType_t xEMACIndex,
NetworkInterface_t * pxInterface );
#endif

/* Function to initialise the network interface */
BaseType_t xRX_NetworkInterfaceInitialise( NetworkInterface_t * pxInterface );
Expand Down Expand Up @@ -136,6 +138,14 @@ NetworkInterface_t * pxRX_FillInterfaceDescriptor( BaseType_t xEMACIndex,
return pxInterface;
}

#if ( ipconfigIPv4_BACKWARD_COMPATIBLE != 0 )
NetworkInterface_t * pxFillInterfaceDescriptor( BaseType_t xEMACIndex,
NetworkInterface_t * pxInterface )
{
return pxRX_FillInterfaceDescriptor( xEMACIndex, pxInterface );
}
#endif

/***********************************************************************************************************************
* Function Name: xRX_NetworkInterfaceInitialise ()
* Description : Initialization of Ethernet driver.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,23 @@ static BaseType_t prvLoopback_Output( NetworkInterface_t * pxInterface,
}

{
MACAddress_t xMACAddress;
const MACAddress_t * pxMACAddress = &( pxDescriptor->pxEndPoint->xMACAddress );

if( pxDescriptor->pxEndPoint->bits.bIPv6 != 0 )
{
#if ( ipconfigUSE_IPv6 != 0 )
if( xIsIPv6Loopback( &( pxDescriptor->xIPAddress ) ) != pdFALSE )
if( xIsIPv6Loopback( &( pxDescriptor->xIPAddress.xIP_IPv6 ) ) != pdFALSE )
{
vNDRefreshCacheEntry( &xMACAddress, &( pxDescriptor->xIPAddress.xIP_IPv6 ), pxDescriptor->pxEndPoint );
vNDRefreshCacheEntry( pxMACAddress, &( pxDescriptor->xIPAddress.xIP_IPv6 ), pxDescriptor->pxEndPoint );
}
#endif
}
else
{
#if ( ipconfigUSE_IPv4 != 0 )
if( xIsIPv4Loopback( pxDescriptor->xIPAddress.ulIP_IPv4 ) )
if( xIsIPv4Loopback( pxDescriptor->xIPAddress.ulIP_IPv4 ) != pdFALSE )
{
vARPRefreshCacheEntry( &xMACAddress, pxDescriptor->xIPAddress.ulIP_IPv4, pxDescriptor->pxEndPoint );
vARPRefreshCacheEntry( pxMACAddress, pxDescriptor->xIPAddress.ulIP_IPv4, pxDescriptor->pxEndPoint );
}
#endif
}
Expand All @@ -170,11 +170,21 @@ static BaseType_t prvLoopback_Output( NetworkInterface_t * pxInterface,
xRxEvent.eEventType = eNetworkRxEvent;
xRxEvent.pvData = ( void * ) pxDescriptor;

if( xSendEventStructToIPTask( &xRxEvent, 0u ) != pdTRUE )
pxDescriptor->pxInterface = xLoopbackInterface;
pxDescriptor->pxEndPoint = FreeRTOS_MatchingEndpoint( xLoopbackInterface, pxDescriptor->pucEthernetBuffer );

if( pxDescriptor->pxEndPoint == NULL )
{
vReleaseNetworkBufferAndDescriptor( pxDescriptor );
iptraceETHERNET_RX_EVENT_LOST();
FreeRTOS_printf( ( "prvLoopback_Output: Can not find a proper endpoint\n" ) );
}
else if( xSendEventStructToIPTask( &xRxEvent, 0u ) != pdTRUE )
{
/* Sending failed, release the descriptor. */
vReleaseNetworkBufferAndDescriptor( pxDescriptor );
iptraceETHERNET_RX_EVENT_LOST();
FreeRTOS_printf( ( "prvEMACRxPoll: Can not queue return packet!\n" ) );
FreeRTOS_printf( ( "prvLoopback_Output: Can not queue return packet!\n" ) );
}
}

Expand Down
Loading

0 comments on commit ced2fd6

Please sign in to comment.