Skip to content

Commit

Permalink
Remove xCheckLoopback function (#1098)
Browse files Browse the repository at this point in the history
* Remove xCheckLoopback function because we now have a loopback endpoint.

* Remove xCheckLoopback CBMC proof

* Remove xCheckLoopback UTs

---------

Co-authored-by: tony-josi-aws <tonyjosi@amazon.com>
  • Loading branch information
htibosch and tony-josi-aws authored Feb 10, 2024
1 parent 6aa48a5 commit 7a58ae8
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 396 deletions.
79 changes: 0 additions & 79 deletions source/FreeRTOS_ARP.c
Original file line number Diff line number Diff line change
Expand Up @@ -1516,85 +1516,6 @@ void FreeRTOS_ClearARP( const struct xNetworkEndPoint * pxEndPoint )
}
/*-----------------------------------------------------------*/

#if 1

/**
* @brief This function will check if the target IP-address belongs to this device.
* If so, the packet will be passed to the IP-stack, who will answer it.
* The function is to be called within the function xNetworkInterfaceOutput().
*
* @param[in] pxDescriptor The network buffer which is to be checked for loop-back.
* @param[in] bReleaseAfterSend pdTRUE: Driver is allowed to transfer ownership of descriptor.
* pdFALSE: Driver is not allowed to take ownership of descriptor,
* make a copy of it.
*
* @return pdTRUE/pdFALSE: There is/isn't a loopback address in the packet.
*/
BaseType_t xCheckLoopback( NetworkBufferDescriptor_t * const pxDescriptor,
BaseType_t bReleaseAfterSend )
{
BaseType_t xResult = pdFALSE;
NetworkBufferDescriptor_t * pxUseDescriptor = pxDescriptor;

const IPPacket_t * pxIPPacket;

if( ( pxUseDescriptor == NULL ) || ( pxUseDescriptor->xDataLength < sizeof( IPPacket_t ) ) )
{
/* The packet is too small to parse. */
}
else
{
/* MISRA Ref 11.3.1 [Misaligned access] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
/* coverity[misra_c_2012_rule_11_3_violation] */
pxIPPacket = ( ( IPPacket_t * ) pxUseDescriptor->pucEthernetBuffer );

if( pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE )
{
NetworkEndPoint_t * pxEndPoint;

pxEndPoint = FreeRTOS_FindEndPointOnMAC( &( pxIPPacket->xEthernetHeader.xDestinationAddress ), NULL );

if( ( pxEndPoint != NULL ) &&
( memcmp( pxIPPacket->xEthernetHeader.xDestinationAddress.ucBytes, pxEndPoint->xMACAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) )
{
xResult = pdTRUE;

if( bReleaseAfterSend == pdFALSE )
{
/* Driver is not allowed to transfer the ownership
* of descriptor, so make a copy of it */
pxUseDescriptor =
pxDuplicateNetworkBufferWithDescriptor( pxDescriptor, pxDescriptor->xDataLength );
}

if( pxUseDescriptor != NULL )
{
IPStackEvent_t xRxEvent;

pxUseDescriptor->pxInterface = pxEndPoint->pxNetworkInterface;
pxUseDescriptor->pxEndPoint = pxEndPoint;

xRxEvent.eEventType = eNetworkRxEvent;
xRxEvent.pvData = pxUseDescriptor;

if( xSendEventStructToIPTask( &xRxEvent, 0U ) != pdTRUE )
{
vReleaseNetworkBufferAndDescriptor( pxUseDescriptor );
iptraceETHERNET_RX_EVENT_LOST();
FreeRTOS_printf( ( "prvEMACRxPoll: Can not queue return packet!\n" ) );
}
}
}
}
}

return xResult;
}

#endif /* 0 */
/*-----------------------------------------------------------*/

#if ( ipconfigHAS_PRINTF != 0 ) || ( ipconfigHAS_DEBUG_PRINTF != 0 )

void FreeRTOS_PrintARPCache( void )
Expand Down
20 changes: 0 additions & 20 deletions source/include/FreeRTOS_ARP.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,26 +163,6 @@ eARPLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress,
*/
void vARPGenerateRequestPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer );



/* This function will check if the target IP-address belongs to this device.
* If so, the packet will be passed to the IP-stack, who will answer it.
* The function is to be called within the function xNetworkInterfaceOutput()
* in NetworkInterface.c as follows:
*
* if( xCheckLoopback( pxDescriptor, bReleaseAfterSend ) != 0 )
* {
* / * The packet has been sent back to the IP-task.
* * The IP-task will further handle it.
* * Do not release the descriptor.
* * /
* return pdTRUE;
* }
* / * Send the packet as usual. * /
*/
BaseType_t xCheckLoopback( NetworkBufferDescriptor_t * const pxDescriptor,
BaseType_t bReleaseAfterSend );

void FreeRTOS_OutputARPRequest( uint32_t ulIPAddress );

/* Clear all entries in the ARp cache. */
Expand Down
9 changes: 0 additions & 9 deletions source/portable/NetworkInterface/DriverSAM/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,15 +598,6 @@ static BaseType_t prvSAM_NetworkInterfaceOutput( NetworkInterface_t * pxInterfac
* statement. */
do
{
if( xCheckLoopback( pxDescriptor, bReleaseAfterSend ) != 0 )
{
/* The packet has been sent back to the IP-task.
* The IP-task will further handle it.
* Do not release the descriptor. */
bReleaseAfterSend = pdFALSE;
break;
}

uint32_t ulResult;

if( xPhyObject.ulLinkStatusMask == 0ul )
Expand Down
9 changes: 0 additions & 9 deletions source/portable/NetworkInterface/NXP1060/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,6 @@ static BaseType_t prvNXP1060_NetworkInterfaceOutput( NetworkInterface_t * pxInte

do
{
if( xCheckLoopback( pxNetworkBuffer, xReleaseAfterSend ) != 0 )
{
/* The packet has been sent back to the IP-task.
* The IP-task will further handle it.
* Do not release the descriptor. */
xReleaseAfterSend = pdFALSE;
break;
}

if( bGlobalLinkStatus == true )
{
/* ENET_SendFrame copies the data before sending it. Therefore, the network buffer can
Expand Down
9 changes: 0 additions & 9 deletions source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -799,15 +799,6 @@ static BaseType_t xSTM32F_NetworkInterfaceOutput( NetworkInterface_t * pxInterfa
/* Open a do {} while ( 0 ) loop to be able to call break. */
do
{
if( xCheckLoopback( pxDescriptor, bReleaseAfterSend ) != 0 )
{
/* The packet has been sent back to the IP-task.
* The IP-task will further handle it.
* Do not release the descriptor. */
bReleaseAfterSend = pdFALSE;
break;
}

#if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 )
{
const IPPacket_t * pxIPPacket;
Expand Down
17 changes: 0 additions & 17 deletions test/cbmc/proofs/ARP/xCheckLoopback/Makefile.json

This file was deleted.

61 changes: 0 additions & 61 deletions test/cbmc/proofs/ARP/xCheckLoopback/xCheckLoopback_harness.c

This file was deleted.

Loading

0 comments on commit 7a58ae8

Please sign in to comment.