From c05141fdf71990c8bcc352d8d52f259f8ee3c085 Mon Sep 17 00:00:00 2001 From: Hein Tibosch Date: Thu, 28 Sep 2023 17:02:20 +0800 Subject: [PATCH] Remove test for 'ipIPv4_FRAME_TYPE' --- source/FreeRTOS_IPv4.c | 3 +- .../FreeRTOS_IPv4/FreeRTOS_IPv4_utest.c | 28 +++++-------------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/source/FreeRTOS_IPv4.c b/source/FreeRTOS_IPv4.c index 78ef9d9e1..dea6697c9 100644 --- a/source/FreeRTOS_IPv4.c +++ b/source/FreeRTOS_IPv4.c @@ -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. */ diff --git a/test/unit-test/FreeRTOS_IPv4/FreeRTOS_IPv4_utest.c b/test/unit-test/FreeRTOS_IPv4/FreeRTOS_IPv4_utest.c index 4f788f92b..f87a8693b 100644 --- a/test/unit-test/FreeRTOS_IPv4/FreeRTOS_IPv4_utest.c +++ b/test/unit-test/FreeRTOS_IPv4/FreeRTOS_IPv4_utest.c @@ -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; @@ -892,7 +891,7 @@ 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 ) ); @@ -900,10 +899,7 @@ static void xRunBadIPv4Loopback( uint32_t ulSource, if( eExpected != eReleaseBuffer ) { - if( usFrameType == ipIPv4_FRAME_TYPE ) - { - FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( pxEndpoint ); - } + FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( pxEndpoint ); FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( NULL ); @@ -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 ); } /** @@ -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 ); } /** @@ -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 ); } /** @@ -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 ); }