Skip to content

Commit

Permalink
Remove test for 'ipIPv4_FRAME_TYPE'
Browse files Browse the repository at this point in the history
  • Loading branch information
htibosch committed Sep 28, 2023
1 parent d7ee3c2 commit c05141f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
3 changes: 1 addition & 2 deletions source/FreeRTOS_IPv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@ enum eFrameProcessingResult prvAllowIPPacketIPv4( const struct xIP_PACKET * cons
/* Can not handle, unknown or invalid header version. */
eReturn = eReleaseBuffer;
}
else if( ( pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) &&
( xBadIPv4Loopback( &( pxIPPacket->xIPHeader ) ) == pdTRUE ) )
else if( xBadIPv4Loopback( &( pxIPPacket->xIPHeader ) ) == pdTRUE )
{
/* The local loopback addresses must never appear outside a host. See RFC 1122
* section 3.2.1.3. */
Expand Down
28 changes: 7 additions & 21 deletions test/unit-test/FreeRTOS_IPv4/FreeRTOS_IPv4_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,6 @@ void test_xIsIPv4Loopback_test( void )
*/
static void xRunBadIPv4Loopback( uint32_t ulSource,
uint32_t ulTarget,
uint16_t usFrameType,
eFrameProcessingResult_t eExpected )
{
eFrameProcessingResult_t eResult;
Expand Down Expand Up @@ -892,18 +891,15 @@ static void xRunBadIPv4Loopback( uint32_t ulSource,
pxIPHeader->ulSourceIPAddress = ulIPSource;
pxIPHeader->ulDestinationIPAddress = ulIPTarget;

pxIPPacket->xEthernetHeader.usFrameType = usFrameType;
pxIPPacket->xEthernetHeader.usFrameType = ipIPv4_FRAME_TYPE;

memcpy( pxIPPacket->xEthernetHeader.xDestinationAddress.ucBytes, xMACAddress.ucBytes, sizeof( MACAddress_t ) );

FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( pxEndpoint );

if( eExpected != eReleaseBuffer )
{
if( usFrameType == ipIPv4_FRAME_TYPE )
{
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( pxEndpoint );
}
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( pxEndpoint );

FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( NULL );

Expand All @@ -924,7 +920,7 @@ static void xRunBadIPv4Loopback( uint32_t ulSource,
void test_xBadIPv4Loopback_0_test( void )
{
/* ext ext 192.168.2.5 192.168.2.6 */
xRunBadIPv4Loopback( 0xC0A80205, 0xC0A80206, ipIPv4_FRAME_TYPE, eProcessBuffer );
xRunBadIPv4Loopback( 0xC0A80205, 0xC0A80206, eProcessBuffer );
}

/**
Expand All @@ -933,8 +929,8 @@ void test_xBadIPv4Loopback_0_test( void )
*/
void test_xBadIPv4Loopback_1_test( void )
{
/* ext ext 127.0.0.1 192.168.2.5 */
xRunBadIPv4Loopback( 0x7F000001, 0xC0A80205, ipIPv4_FRAME_TYPE, eReleaseBuffer );
/* int ext 127.0.0.1 192.168.2.5 */
xRunBadIPv4Loopback( 0x7F000001, 0xC0A80205, eReleaseBuffer );
}

/**
Expand All @@ -944,7 +940,7 @@ void test_xBadIPv4Loopback_1_test( void )
void test_xBadIPv4Loopback_2_test( void )
{
/* ext -> int 192.168.2.5 127.0.0.1 */
xRunBadIPv4Loopback( 0xC0A80205, 0x7F000001, ipIPv4_FRAME_TYPE, eReleaseBuffer );
xRunBadIPv4Loopback( 0xC0A80205, 0x7F000001, eReleaseBuffer );
}

/**
Expand All @@ -954,15 +950,5 @@ void test_xBadIPv4Loopback_2_test( void )
void test_xBadIPv4Loopback_3_test( void )
{
/* int -> int 127.0.0.1 127.0.0.2 */
xRunBadIPv4Loopback( 0x7F000001, 0x7F000002, ipIPv4_FRAME_TYPE, eProcessBuffer );
}

/**
* @brief test_xBadIPv4Loopback_3_test
* To validate if xBadIPv4Loopback() makes correct decisions.
*/
void test_xBadIPv4Loopback_4_test( void )
{
/* wrong frame type 127.0.0.1 127.0.0.2 */
xRunBadIPv4Loopback( 0x7F000001, 0x7F000002, ipARP_FRAME_TYPE, eProcessBuffer );
xRunBadIPv4Loopback( 0x7F000001, 0x7F000002, eProcessBuffer );
}

0 comments on commit c05141f

Please sign in to comment.