From d70ec50cfe0797ae622c20a888a2486c02803419 Mon Sep 17 00:00:00 2001 From: Holden Date: Thu, 8 Feb 2024 19:20:21 -0500 Subject: [PATCH 01/25] Separate ARP and ND --- source/FreeRTOS_ARP.c | 142 +++--------------- source/FreeRTOS_IP.c | 2 +- source/FreeRTOS_IP_Utils.c | 4 +- source/FreeRTOS_ND.c | 65 ++++++++ source/FreeRTOS_Routing.c | 36 +++++ source/FreeRTOS_UDP_IPv6.c | 2 +- source/include/FreeRTOS_ND.h | 2 + source/include/FreeRTOS_Routing.h | 2 + .../FreeRTOS_ARP/FreeRTOS_ARP_utest.c | 80 ---------- .../unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c | 18 +-- .../unit-test/FreeRTOS_ND/FreeRTOS_ND_stubs.c | 21 +++ .../unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c | 124 +++++++++++++++ .../FreeRTOS_Routing/FreeRTOS_Routing_stubs.c | 21 +++ .../FreeRTOS_Routing/FreeRTOS_Routing_utest.c | 47 ++++++ test/unit-test/FreeRTOS_Routing/ut.cmake | 1 + .../ut.cmake | 1 + .../FreeRTOS_UDP_IPv6_utest.c | 18 +-- 17 files changed, 366 insertions(+), 220 deletions(-) diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index 2e300209d..ab8977ebb 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -56,6 +56,7 @@ #include "FreeRTOS_Routing.h" #include "FreeRTOS_ND.h" +#if ( ipconfigUSE_IPv4 != 0 ) /** @brief When the age of an entry in the ARP table reaches this value (it counts down * to zero, so this is an old entry) an ARP request will be sent to see if the @@ -82,7 +83,6 @@ #define arpIP_CLASH_MAX_RETRIES 1U #endif -#if ( ipconfigUSE_IPv4 != 0 ) static void vARPProcessPacketRequest( ARPPacket_t * pxARPFrame, NetworkEndPoint_t * pxTargetEndPoint, @@ -103,8 +103,6 @@ MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ); -#endif /* ( ipconfigUSE_IPv4 != 0 ) */ - static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, const uint32_t ulIPAddress, struct xNetworkEndPoint * pxEndPoint, @@ -130,8 +128,6 @@ _static ARPCacheRow_t xARPCache[ ipconfigARP_CACHE_ENTRIES ]; /*-----------------------------------------------------------*/ -#if ( ipconfigUSE_IPv4 != 0 ) - /** @brief The time at which the last gratuitous ARP was sent. Gratuitous ARPs are used * to ensure ARP tables are up to date and to detect IP address conflicts. */ static TickType_t xLastGratuitousARPTime = 0U; @@ -473,8 +469,6 @@ _static ARPCacheRow_t xARPCache[ ipconfigARP_CACHE_ENTRIES ]; } /*-----------------------------------------------------------*/ -#endif /* ( ipconfigUSE_IPv4 != 0 ) */ - /** * @brief Check whether an IP address is in the ARP cache. * @@ -521,97 +515,25 @@ BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetw { BaseType_t xNeedsARPResolution = pdFALSE; - switch( uxIPHeaderSizePacket( pxNetworkBuffer ) ) + /* 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] */ + const IPPacket_t * pxIPPacket = ( ( const IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); + const IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); + const IPV4Parameters_t * pxIPv4Settings = &( pxNetworkBuffer->pxEndPoint->ipv4_settings ); + + if( ( pxIPHeader->ulSourceIPAddress & pxIPv4Settings->ulNetMask ) == ( pxIPv4Settings->ulIPAddress & pxIPv4Settings->ulNetMask ) ) { - #if ( ipconfigUSE_IPv4 != 0 ) - case ipSIZE_OF_IPv4_HEADER: - { - /* 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] */ - const IPPacket_t * pxIPPacket = ( ( const IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); - const IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); - const IPV4Parameters_t * pxIPv4Settings = &( pxNetworkBuffer->pxEndPoint->ipv4_settings ); - - if( ( pxIPHeader->ulSourceIPAddress & pxIPv4Settings->ulNetMask ) == ( pxIPv4Settings->ulIPAddress & pxIPv4Settings->ulNetMask ) ) - { - /* If the IP is on the same subnet and we do not have an ARP entry already, - * then we should send out ARP for finding the MAC address. */ - if( xIsIPInARPCache( pxIPHeader->ulSourceIPAddress ) == pdFALSE ) - { - FreeRTOS_OutputARPRequest( pxIPHeader->ulSourceIPAddress ); - - /* This packet needs resolution since this is on the same subnet - * but not in the ARP cache. */ - xNeedsARPResolution = pdTRUE; - } - } - - break; - } - #endif /* ( ipconfigUSE_IPv4 != 0 ) */ - - #if ( ipconfigUSE_IPv6 != 0 ) - case ipSIZE_OF_IPv6_HEADER: - { - /* 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] */ - IPPacket_IPv6_t * pxIPPacket = ( ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer ); - IPHeader_IPv6_t * pxIPHeader = &( pxIPPacket->xIPHeader ); - IPv6_Address_t * pxIPAddress = &( pxIPHeader->xSourceAddress ); - uint8_t ucNextHeader = pxIPHeader->ucNextHeader; - - if( ( ucNextHeader == ipPROTOCOL_TCP ) || - ( ucNextHeader == ipPROTOCOL_UDP ) ) - { - IPv6_Type_t eType = xIPv6_GetIPType( ( const IPv6_Address_t * ) pxIPAddress ); - FreeRTOS_debug_printf( ( "xCheckRequiresARPResolution: %pip type %s\n", - ( void * ) pxIPAddress->ucBytes, - ( eType == eIPv6_Global ) ? "Global" : - ( eType == eIPv6_LinkLocal ) ? "LinkLocal" : - ( eType == eIPv6_Loopback ) ? "Loopback" : - "other" ) ); - - if( eType == eIPv6_LinkLocal ) - { - MACAddress_t xMACAddress; - NetworkEndPoint_t * pxEndPoint; - eARPLookupResult_t eResult; - char pcName[ 80 ]; - - ( void ) memset( &( pcName ), 0, sizeof( pcName ) ); - eResult = eNDGetCacheEntry( pxIPAddress, &xMACAddress, &pxEndPoint ); - FreeRTOS_printf( ( "xCheckRequiresARPResolution: eResult %s with EP %s\n", ( eResult == eARPCacheMiss ) ? "Miss" : ( eResult == eARPCacheHit ) ? "Hit" : "Error", pcEndpointName( pxEndPoint, pcName, sizeof pcName ) ) ); - - if( eResult == eARPCacheMiss ) - { - NetworkBufferDescriptor_t * pxTempBuffer; - size_t uxNeededSize; - - uxNeededSize = sizeof( ICMPPacket_IPv6_t ); - pxTempBuffer = pxGetNetworkBufferWithDescriptor( BUFFER_FROM_WHERE_CALL( 199 ) uxNeededSize, 0U ); - - if( pxTempBuffer != NULL ) - { - pxTempBuffer->pxEndPoint = pxNetworkBuffer->pxEndPoint; - pxTempBuffer->pxInterface = pxNetworkBuffer->pxInterface; - vNDSendNeighbourSolicitation( pxTempBuffer, pxIPAddress ); - } - - xNeedsARPResolution = pdTRUE; - } - } - } - - break; - } - #endif /* ( ipconfigUSE_IPv6 != 0 ) */ - - default: - /* Shouldn't reach here */ - /* MISRA 16.4 Compliance */ - break; + /* If the IP is on the same subnet and we do not have an ARP entry already, + * then we should send out ARP for finding the MAC address. */ + if( xIsIPInARPCache( pxIPHeader->ulSourceIPAddress ) == pdFALSE ) + { + FreeRTOS_OutputARPRequest( pxIPHeader->ulSourceIPAddress ); + + /* This packet needs resolution since this is on the same subnet + * but not in the ARP cache. */ + xNeedsARPResolution = pdTRUE; + } } return xNeedsARPResolution; @@ -941,8 +863,6 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, /*-----------------------------------------------------------*/ -#if ( ipconfigUSE_IPv4 != 0 ) - /** * @brief Look for ulIPAddress in the ARP cache. * @@ -1217,25 +1137,9 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, { if( ( pxEndPoint->bits.bEndPointUp != pdFALSE_UNSIGNED ) && ( pxEndPoint->ipv4_settings.ulIPAddress != 0U ) ) { - /* Case default is never toggled because IPv6 flag can be TRUE or FALSE */ - switch( pxEndPoint->bits.bIPv6 ) /* LCOV_EXCL_BR_LINE */ + if( pxEndPoint->bits.bIPv6 == pdFALSE_UNSIGNED ) /* LCOV_EXCL_BR_LINE */ { - #if ( ipconfigUSE_IPv4 != 0 ) - case pdFALSE_UNSIGNED: - FreeRTOS_OutputARPRequest( pxEndPoint->ipv4_settings.ulIPAddress ); - break; - #endif /* ( ipconfigUSE_IPv4 != 0 ) */ - - #if ( ipconfigUSE_IPv6 != 0 ) - case pdTRUE_UNSIGNED: - FreeRTOS_OutputAdvertiseIPv6( pxEndPoint ); - break; - #endif /* ( ipconfigUSE_IPv6 != 0 ) */ - - default: /* LCOV_EXCL_LINE */ - /* Shouldn't reach here */ - /* MISRA 16.4 Compliance */ - break; /* LCOV_EXCL_LINE */ + FreeRTOS_OutputARPRequest( pxEndPoint->ipv4_settings.ulIPAddress ); } } @@ -1488,8 +1392,6 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, } /*-----------------------------------------------------------*/ -#endif /* ( ipconfigUSE_IPv4 != 0 ) */ - /** * @brief A call to this function will clear the ARP cache. * @param[in] pxEndPoint only clean entries with this end-point, or when NULL, @@ -1624,3 +1526,5 @@ void FreeRTOS_ClearARP( const struct xNetworkEndPoint * pxEndPoint ) FreeRTOS_printf( ( "Arp has %ld entries\n", xCount ) ); } #endif /* ( ipconfigHAS_PRINTF != 0 ) || ( ipconfigHAS_DEBUG_PRINTF != 0 ) */ + +#endif /* ( ipconfigUSE_IPv4 != 0 ) */ diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index c469f91ac..858c328f4 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1923,7 +1923,7 @@ static eFrameProcessingResult_t prvProcessIPPacket( const IPPacket_t * pxIPPacke * entry. */ if( ucProtocol != ( uint8_t ) ipPROTOCOL_UDP ) { - if( xCheckRequiresARPResolution( pxNetworkBuffer ) == pdTRUE ) + if( xCheckRequiresResolution( pxNetworkBuffer ) == pdTRUE ) { eReturn = eWaitingARPResolution; } diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index dfbc2607e..6d53e743c 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -860,7 +860,9 @@ void prvProcessNetworkDownEvent( struct xNetworkInterface * pxInterface ) /* Per the ARP Cache Validation section of https://tools.ietf.org/html/rfc1122 * treat network down as a "delivery problem" and flush the ARP cache for this * interface. */ - FreeRTOS_ClearARP( pxEndPoint ); + #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + FreeRTOS_ClearARP( pxEndPoint ); + #endif #if ( ipconfigUSE_DHCP == 1 ) if( END_POINT_USES_DHCP( pxEndPoint ) ) diff --git a/source/FreeRTOS_ND.c b/source/FreeRTOS_ND.c index f5c21cb84..67a1f1b6f 100644 --- a/source/FreeRTOS_ND.c +++ b/source/FreeRTOS_ND.c @@ -1316,4 +1316,69 @@ return xResult; } /*-----------------------------------------------------------*/ + +/** + * @brief Check whether a packet needs ND resolution if it is on local subnet. If required send an ND Solicitation. + * + * @param[in] pxNetworkBuffer The network buffer with the packet to be checked. + * + * @return pdTRUE if the packet needs ND resolution, pdFALSE otherwise. + */ +BaseType_t xCheckRequiresNDResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer ) +{ + BaseType_t xNeedsNDResolution = pdFALSE; + + /* 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] */ + IPPacket_IPv6_t * pxIPPacket = ( ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer ); + IPHeader_IPv6_t * pxIPHeader = &( pxIPPacket->xIPHeader ); + IPv6_Address_t * pxIPAddress = &( pxIPHeader->xSourceAddress ); + uint8_t ucNextHeader = pxIPHeader->ucNextHeader; + + if( ( ucNextHeader == ipPROTOCOL_TCP ) || + ( ucNextHeader == ipPROTOCOL_UDP ) ) + { + IPv6_Type_t eType = xIPv6_GetIPType( ( const IPv6_Address_t * ) pxIPAddress ); + FreeRTOS_debug_printf( ( "xCheckRequiresARPResolution: %pip type %s\n", + ( void * ) pxIPAddress->ucBytes, + ( eType == eIPv6_Global ) ? "Global" : + ( eType == eIPv6_LinkLocal ) ? "LinkLocal" : + ( eType == eIPv6_Loopback ) ? "Loopback" : + "other" ) ); + + if( eType == eIPv6_LinkLocal ) + { + MACAddress_t xMACAddress; + NetworkEndPoint_t * pxEndPoint; + eARPLookupResult_t eResult; + char pcName[ 80 ]; + + ( void ) memset( &( pcName ), 0, sizeof( pcName ) ); + eResult = eNDGetCacheEntry( pxIPAddress, &xMACAddress, &pxEndPoint ); + FreeRTOS_printf( ( "xCheckRequiresARPResolution: eResult %s with EP %s\n", ( eResult == eARPCacheMiss ) ? "Miss" : ( eResult == eARPCacheHit ) ? "Hit" : "Error", pcEndpointName( pxEndPoint, pcName, sizeof pcName ) ) ); + + if( eResult == eARPCacheMiss ) + { + NetworkBufferDescriptor_t * pxTempBuffer; + size_t uxNeededSize; + + uxNeededSize = sizeof( ICMPPacket_IPv6_t ); + pxTempBuffer = pxGetNetworkBufferWithDescriptor( BUFFER_FROM_WHERE_CALL( 199 ) uxNeededSize, 0U ); + + if( pxTempBuffer != NULL ) + { + pxTempBuffer->pxEndPoint = pxNetworkBuffer->pxEndPoint; + pxTempBuffer->pxInterface = pxNetworkBuffer->pxInterface; + vNDSendNeighbourSolicitation( pxTempBuffer, pxIPAddress ); + } + + xNeedsNDResolution = pdTRUE; + } + } + } + + return xNeedsNDResolution; +} +/*-----------------------------------------------------------*/ #endif /* ipconfigUSE_IPv6 */ diff --git a/source/FreeRTOS_Routing.c b/source/FreeRTOS_Routing.c index d7b3a10ac..91de0642c 100644 --- a/source/FreeRTOS_Routing.c +++ b/source/FreeRTOS_Routing.c @@ -41,6 +41,7 @@ #include "FreeRTOS_Sockets.h" #include "FreeRTOS_IP_Private.h" #include "FreeRTOS_ARP.h" +#include "FreeRTOS_ND.h" #include "FreeRTOS_UDP_IP.h" #include "FreeRTOS_DHCP.h" #include "NetworkBufferManagement.h" @@ -1545,3 +1546,38 @@ struct xIPv6_Couple } /*-----------------------------------------------------------*/ #endif /* ( ( ipconfigHAS_PRINTF != 0 ) || ( ipconfigHAS_DEBUG_PRINTF != 0 ) ) */ + +/** + * @brief Check whether a packet needs resolution if it is on local subnet. If required send a request. + * + * @param[in] pxNetworkBuffer The network buffer with the packet to be checked. + * + * @return pdTRUE if the packet needs resolution, pdFALSE otherwise. + */ +BaseType_t xCheckRequiresResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer ) +{ + BaseType_t xNeedsResolution = pdFALSE; + + switch( uxIPHeaderSizePacket( pxNetworkBuffer ) ) + { + #if ( ipconfigUSE_IPv4 != 0 ) + case ipSIZE_OF_IPv4_HEADER: + xNeedsResolution = xCheckRequiresARPResolution( pxNetworkBuffer ); + break; + #endif /* ( ipconfigUSE_IPv4 != 0 ) */ + + #if ( ipconfigUSE_IPv6 != 0 ) + case ipSIZE_OF_IPv6_HEADER: + xNeedsResolution = xCheckRequiresNDResolution( pxNetworkBuffer ); + break; + #endif /* ( ipconfigUSE_IPv6 != 0 ) */ + + default: + /* Shouldn't reach here */ + /* MISRA 16.4 Compliance */ + break; + } + + return xNeedsResolution; +} +/*-----------------------------------------------------------*/ diff --git a/source/FreeRTOS_UDP_IPv6.c b/source/FreeRTOS_UDP_IPv6.c index 0557f4725..e2b4e2f99 100644 --- a/source/FreeRTOS_UDP_IPv6.c +++ b/source/FreeRTOS_UDP_IPv6.c @@ -423,7 +423,7 @@ BaseType_t xProcessReceivedUDPPacket_IPv6( NetworkBufferDescriptor_t * pxNetwork if( pxSocket != NULL ) { - if( xCheckRequiresARPResolution( pxNetworkBuffer ) == pdTRUE ) + if( xCheckRequiresNDResolution( pxNetworkBuffer ) == pdTRUE ) { /* Mark this packet as waiting for ARP resolution. */ *pxIsWaitingForARPResolution = pdTRUE; diff --git a/source/include/FreeRTOS_ND.h b/source/include/FreeRTOS_ND.h index bdbabdec7..f4bc5dd53 100644 --- a/source/include/FreeRTOS_ND.h +++ b/source/include/FreeRTOS_ND.h @@ -204,6 +204,8 @@ void FreeRTOS_PrintNDCache( void ); #endif + BaseType_t xCheckRequiresNDResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer ); + #endif /* ipconfigUSE_IPv6 != 0 */ diff --git a/source/include/FreeRTOS_Routing.h b/source/include/FreeRTOS_Routing.h index 7fbdc001b..d43ed712e 100644 --- a/source/include/FreeRTOS_Routing.h +++ b/source/include/FreeRTOS_Routing.h @@ -342,6 +342,8 @@ IPv6_Type_t xIPv6_GetIPType( const IPv6_Address_t * pxAddress ); #endif + BaseType_t xCheckRequiresResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer ); + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c index 6cff20d53..ab4bf14cb 100644 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c @@ -1681,86 +1681,6 @@ void test_xCheckRequiresARPResolution_NotOnLocalNetwork_InvalidHeader( void ) TEST_ASSERT_EQUAL( pdFALSE, xResult ); } -void test_xCheckRequiresARPResolution_NotOnLocalNetwork_IPv6( void ) -{ - struct xNetworkEndPoint xEndPoint = { 0 }; - NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer; - uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; - BaseType_t xResult; - NetworkInterface_t xInterface; - - pxNetworkBuffer = &xNetworkBuffer; - pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; - - IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); - IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); - - *ipLOCAL_IP_ADDRESS_POINTER = 0xABCD1234; - - xEndPoint.ipv4_settings.ulNetMask = 0xFFFFFF00; - xNetworkBuffer.pxEndPoint = &xEndPoint; - - /* Make sure there is no match. */ - pxIPHeader->ulSourceIPAddress = ~( *ipLOCAL_IP_ADDRESS_POINTER & xEndPoint.ipv4_settings.ulNetMask ); - - uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv6_HEADER ); - - xResult = xCheckRequiresARPResolution( pxNetworkBuffer ); - - TEST_ASSERT_EQUAL( pdFALSE, xResult ); - /* =================================================== */ - - IPPacket_IPv6_t * pxIPPacket_V6 = ( ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer ); - IPHeader_IPv6_t * pxIPHeader_V6 = &( pxIPPacket_V6->xIPHeader ); - IPv6_Address_t * pxIPAddress = &( pxIPHeader_V6->xSourceAddress ); - pxIPHeader_V6->ucNextHeader = ipPROTOCOL_TCP; - - xIPv6_GetIPType_ExpectAnyArgsAndReturn( eIPv6_LinkLocal ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); - - xResult = xCheckRequiresARPResolution( pxNetworkBuffer ); - - TEST_ASSERT_EQUAL( pdFALSE, xResult ); - /* =================================================== */ - - pxIPHeader_V6->ucNextHeader = ipPROTOCOL_UDP; - - xIPv6_GetIPType_ExpectAnyArgsAndReturn( eIPv6_LinkLocal ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); - - xResult = xCheckRequiresARPResolution( pxNetworkBuffer ); - - TEST_ASSERT_EQUAL( pdFALSE, xResult ); - /* =================================================== */ - - xIPv6_GetIPType_ExpectAnyArgsAndReturn( eIPv6_LinkLocal ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheMiss ); - NetworkBufferDescriptor_t xTempBuffer = { 0 }; - pxGetNetworkBufferWithDescriptor_ExpectAnyArgsAndReturn( &xTempBuffer ); - vNDSendNeighbourSolicitation_Expect( &xTempBuffer, pxIPAddress ); - - xResult = xCheckRequiresARPResolution( pxNetworkBuffer ); - - TEST_ASSERT_EQUAL( pdTRUE, xResult ); - /* =================================================== */ - - xIPv6_GetIPType_ExpectAnyArgsAndReturn( eIPv6_LinkLocal ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheMiss ); - pxGetNetworkBufferWithDescriptor_ExpectAnyArgsAndReturn( NULL ); - - xResult = xCheckRequiresARPResolution( pxNetworkBuffer ); - - TEST_ASSERT_EQUAL( pdTRUE, xResult ); - /* =================================================== */ - - xIPv6_GetIPType_ExpectAnyArgsAndReturn( eIPv6_SiteLocal ); - - xResult = xCheckRequiresARPResolution( pxNetworkBuffer ); - - TEST_ASSERT_EQUAL( pdFALSE, xResult ); - /* =================================================== */ -} - void test_xCheckRequiresARPResolution_OnLocalNetwork_NotInCache( void ) { struct xNetworkEndPoint xEndPoint = { 0 }; diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c index ddcaed26a..8b845c423 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c @@ -2134,7 +2134,7 @@ void test_prvProcessIPPacket_ValidHeader_ARPResolutionReqd( void ) pxIPHeader->ucVersionHeaderLength = 0x45; prvAllowIPPacketIPv4_ExpectAndReturn( pxIPPacket, pxNetworkBuffer, ( pxIPHeader->ucVersionHeaderLength & 0x0FU ) << 2, eProcessBuffer ); - xCheckRequiresARPResolution_ExpectAndReturn( pxNetworkBuffer, pdTRUE ); + xCheckRequiresResolution_ExpectAndReturn( pxNetworkBuffer, pdTRUE ); eResult = prvProcessIPPacket( pxIPPacket, pxNetworkBuffer ); @@ -2172,7 +2172,7 @@ void test_prvProcessIPPacket_ARPResolutionNotReqd_InvalidProt( void ) prvAllowIPPacketIPv4_ExpectAndReturn( pxIPPacket, pxNetworkBuffer, ( pxIPHeader->ucVersionHeaderLength & 0x0FU ) << 2, eProcessBuffer ); prvCheckIP4HeaderOptions_ExpectAndReturn( pxNetworkBuffer, eProcessBuffer ); - xCheckRequiresARPResolution_ExpectAndReturn( pxNetworkBuffer, pdFALSE ); + xCheckRequiresResolution_ExpectAndReturn( pxNetworkBuffer, pdFALSE ); vARPRefreshCacheEntryAge_ExpectAnyArgs(); eResult = prvProcessIPPacket( pxIPPacket, pxNetworkBuffer ); @@ -2211,7 +2211,7 @@ void test_prvProcessIPPacket_ARPResolutionNotReqd_ICMPRelease( void ) prvAllowIPPacketIPv4_ExpectAndReturn( pxIPPacket, pxNetworkBuffer, ( pxIPHeader->ucVersionHeaderLength & 0x0FU ) << 2, eProcessBuffer ); prvCheckIP4HeaderOptions_ExpectAndReturn( pxNetworkBuffer, eProcessBuffer ); - xCheckRequiresARPResolution_ExpectAndReturn( pxNetworkBuffer, pdFALSE ); + xCheckRequiresResolution_ExpectAndReturn( pxNetworkBuffer, pdFALSE ); vARPRefreshCacheEntryAge_ExpectAnyArgs(); ProcessICMPPacket_ExpectAndReturn( pxNetworkBuffer, eReleaseBuffer ); @@ -2251,7 +2251,7 @@ void test_prvProcessIPPacket_ARPResolutionNotReqd_ICMPProcess( void ) prvAllowIPPacketIPv4_ExpectAndReturn( pxIPPacket, pxNetworkBuffer, ( pxIPHeader->ucVersionHeaderLength & 0x0FU ) << 2, eProcessBuffer ); prvCheckIP4HeaderOptions_ExpectAndReturn( pxNetworkBuffer, eProcessBuffer ); - xCheckRequiresARPResolution_ExpectAndReturn( pxNetworkBuffer, pdFALSE ); + xCheckRequiresResolution_ExpectAndReturn( pxNetworkBuffer, pdFALSE ); vARPRefreshCacheEntryAge_ExpectAnyArgs(); ProcessICMPPacket_ExpectAndReturn( pxNetworkBuffer, eProcessBuffer ); @@ -2568,7 +2568,7 @@ void test_prvProcessIPPacket_TCP( void ) pxIPPacket->xIPHeader.ucProtocol = ipPROTOCOL_TCP; prvAllowIPPacketIPv4_ExpectAndReturn( pxIPPacket, pxNetworkBuffer, ( pxIPHeader->ucVersionHeaderLength & 0x0FU ) << 2, eProcessBuffer ); - xCheckRequiresARPResolution_ExpectAndReturn( pxNetworkBuffer, pdFALSE ); + xCheckRequiresResolution_ExpectAndReturn( pxNetworkBuffer, pdFALSE ); vARPRefreshCacheEntryAge_ExpectAnyArgs(); xProcessReceivedTCPPacket_ExpectAndReturn( pxNetworkBuffer, pdPASS ); @@ -2613,7 +2613,7 @@ void test_prvProcessIPPacket_TCPProcessFail( void ) pxIPPacket->xIPHeader.ucProtocol = ipPROTOCOL_TCP; prvAllowIPPacketIPv4_ExpectAndReturn( pxIPPacket, pxNetworkBuffer, ( pxIPHeader->ucVersionHeaderLength & 0x0FU ) << 2, eProcessBuffer ); - xCheckRequiresARPResolution_ExpectAndReturn( pxNetworkBuffer, pdFALSE ); + xCheckRequiresResolution_ExpectAndReturn( pxNetworkBuffer, pdFALSE ); vARPRefreshCacheEntryAge_ExpectAnyArgs(); xProcessReceivedTCPPacket_ExpectAndReturn( pxNetworkBuffer, pdFAIL ); @@ -2958,7 +2958,7 @@ void test_prvProcessIPPacket_TCP_IPv6_HappyPath( void ) prvAllowIPPacketIPv6_ExpectAndReturn( pxIPHeader, pxNetworkBuffer, ipSIZE_OF_IPv6_HEADER, eProcessBuffer ); xGetExtensionOrder_ExpectAndReturn( ipPROTOCOL_TCP, 0U, 0 ); - xCheckRequiresARPResolution_ExpectAndReturn( pxNetworkBuffer, pdFALSE ); + xCheckRequiresResolution_ExpectAndReturn( pxNetworkBuffer, pdFALSE ); vNDRefreshCacheEntry_Ignore(); xProcessReceivedTCPPacket_ExpectAnyArgsAndReturn( pdPASS ); @@ -3008,7 +3008,7 @@ void test_prvProcessIPPacket_TCP_IPv6_ARPResolution( void ) prvAllowIPPacketIPv6_ExpectAndReturn( pxIPHeader, pxNetworkBuffer, ipSIZE_OF_IPv6_HEADER, eProcessBuffer ); xGetExtensionOrder_ExpectAndReturn( ipPROTOCOL_TCP, 0U, 0 ); - xCheckRequiresARPResolution_ExpectAndReturn( pxNetworkBuffer, pdTRUE ); + xCheckRequiresResolution_ExpectAndReturn( pxNetworkBuffer, pdTRUE ); eResult = prvProcessIPPacket( pxIPPacket, pxNetworkBuffer ); @@ -3055,7 +3055,7 @@ void test_prvProcessIPPacket_ICMP_IPv6_HappyPath( void ) prvAllowIPPacketIPv6_ExpectAndReturn( pxIPHeader, pxNetworkBuffer, ipSIZE_OF_IPv6_HEADER, eProcessBuffer ); xGetExtensionOrder_ExpectAndReturn( ipPROTOCOL_ICMP_IPv6, 0U, 0 ); - xCheckRequiresARPResolution_ExpectAndReturn( pxNetworkBuffer, pdFALSE ); + xCheckRequiresResolution_ExpectAndReturn( pxNetworkBuffer, pdFALSE ); vNDRefreshCacheEntry_Ignore(); prvProcessICMPMessage_IPv6_ExpectAnyArgsAndReturn( eReleaseBuffer ); diff --git a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_stubs.c b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_stubs.c index caf91a5a7..52e1a290a 100644 --- a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_stubs.c +++ b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_stubs.c @@ -21,6 +21,27 @@ NetworkBufferDescriptor_t * pxARPWaitingNetworkBuffer; BaseType_t NetworkInterfaceOutputFunction_Stub_Called = 0; +/** @brief The expected IP version and header length coded into the IP header itself. */ +#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) + +UDPPacketHeader_t xDefaultPartUDPPacketHeader = +{ + /* .ucBytes : */ + { + 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ + 0x08, 0x00, /* Ethernet frame type. */ + ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ + 0x00, /* ucDifferentiatedServicesCode. */ + 0x00, 0x00, /* usLength. */ + 0x00, 0x00, /* usIdentification. */ + 0x00, 0x00, /* usFragmentOffset. */ + ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ + ipPROTOCOL_UDP, /* ucProtocol. */ + 0x00, 0x00, /* usHeaderChecksum. */ + 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ + } +}; + /* ======================== Stub Callback Functions ========================= */ BaseType_t NetworkInterfaceOutputFunction_Stub( struct xNetworkInterface * pxDescriptor, diff --git a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c index 19344736e..6d0a353db 100644 --- a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c +++ b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c @@ -1979,3 +1979,127 @@ void test_pcMessageType_All( void ) xType = ipICMP_NEIGHBOR_ADVERTISEMENT_IPv6 + 1; ( void ) pcMessageType( xType ); } + +void test_xCheckIPv6RequiresResolution_Protocols( void ) +{ + struct xNetworkEndPoint xEndPoint = { 0 }; + NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer; + uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; + BaseType_t xResult; + + pxNetworkBuffer = &xNetworkBuffer; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + IPPacket_IPv6_t * pxIPPacket_V6 = ( ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer ); + IPHeader_IPv6_t * pxIPHeader_V6 = &( pxIPPacket_V6->xIPHeader ); + IPv6_Address_t * pxIPAddress = &( pxIPHeader_V6->xSourceAddress ); + pxIPPacket_V6->xEthernetHeader.usFrameType = ipIPv6_FRAME_TYPE; + pxIPHeader_V6->ucNextHeader = 1; + + xResult = xCheckRequiresNDResolution( pxNetworkBuffer ); + + TEST_ASSERT_EQUAL( pdFALSE, xResult ); + + pxIPHeader_V6->ucNextHeader = ipPROTOCOL_UDP; + + xIPv6_GetIPType_ExpectAnyArgsAndReturn( eIPv6_SiteLocal ); + xResult = xCheckRequiresNDResolution( pxNetworkBuffer ); + + TEST_ASSERT_EQUAL( pdFALSE, xResult ); + + pxIPHeader_V6->ucNextHeader = ipPROTOCOL_TCP; + + xIPv6_GetIPType_ExpectAnyArgsAndReturn( eIPv6_SiteLocal ); + xResult = xCheckRequiresNDResolution( pxNetworkBuffer ); + + TEST_ASSERT_EQUAL( pdFALSE, xResult ); +} + +void test_xCheckRequiresNDResolution_TCPNotOnLocalNetwork( void ) +{ + struct xNetworkEndPoint xEndPoint = { 0 }; + NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer; + uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; + BaseType_t xResult; + + pxNetworkBuffer = &xNetworkBuffer; + pxNetworkBuffer->pxEndPoint = &xEndPoint; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + IPPacket_IPv6_t * pxIPPacket_V6 = ( ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer ); + IPHeader_IPv6_t * pxIPHeader_V6 = &( pxIPPacket_V6->xIPHeader ); + IPv6_Address_t * pxIPAddress = &( pxIPHeader_V6->xSourceAddress ); + pxIPPacket_V6->xEthernetHeader.usFrameType = ipIPv6_FRAME_TYPE; + pxIPHeader_V6->ucNextHeader = ipPROTOCOL_TCP; + + xIPv6_GetIPType_ExpectAnyArgsAndReturn( eIPv6_SiteLocal ); + xResult = xCheckRequiresNDResolution( pxNetworkBuffer ); + + TEST_ASSERT_EQUAL( pdFALSE, xResult ); +} + +void test_xCheckRequiresNDResolution_Hit( void ) +{ + struct xNetworkEndPoint xEndPoint = { 0 }; + NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer; + uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; + BaseType_t xResult; + + ( void ) memset( xNDCache, 0, sizeof( xNDCache ) ); + + pxNetworkBuffer = &xNetworkBuffer; + pxNetworkBuffer->pxEndPoint = &xEndPoint; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + IPPacket_IPv6_t * pxIPPacket_V6 = ( ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer ); + IPHeader_IPv6_t * pxIPHeader_V6 = &( pxIPPacket_V6->xIPHeader ); + IPv6_Address_t * pxIPAddress = &( pxIPHeader_V6->xSourceAddress ); + pxIPPacket_V6->xEthernetHeader.usFrameType = ipIPv6_FRAME_TYPE; + pxIPHeader_V6->ucNextHeader = ipPROTOCOL_TCP; + + xIPv6_GetIPType_ExpectAnyArgsAndReturn( eIPv6_LinkLocal ); + xIsIPv6AllowedMulticast_ExpectAndReturn( pxIPAddress, pdTRUE ); + vSetMultiCastIPv6MacAddress_Expect( pxIPAddress, NULL ); + vSetMultiCastIPv6MacAddress_IgnoreArg_pxMACAddress(); + FreeRTOS_FirstEndPoint_ExpectAnyArgsAndReturn( NULL ); + xResult = xCheckRequiresNDResolution( pxNetworkBuffer ); + + TEST_ASSERT_EQUAL( pdFALSE, xResult ); +} + +void test_xCheckRequiresNDResolution_Miss( void ) +{ + struct xNetworkEndPoint xEndPoint, * pxEndPoint = &xEndPoint; + NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer; + uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; + BaseType_t xResult; + + ( void ) memset( xNDCache, 0, sizeof( xNDCache ) ); + + pxNetworkBuffer = &xNetworkBuffer; + pxNetworkBuffer->pxEndPoint = &xEndPoint; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + IPPacket_IPv6_t * pxIPPacket_V6 = ( ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer ); + IPHeader_IPv6_t * pxIPHeader_V6 = &( pxIPPacket_V6->xIPHeader ); + IPv6_Address_t * pxIPAddress = &( pxIPHeader_V6->xSourceAddress ); + pxIPPacket_V6->xEthernetHeader.usFrameType = ipIPv6_FRAME_TYPE; + pxIPHeader_V6->ucNextHeader = ipPROTOCOL_TCP; + + xIPv6_GetIPType_ExpectAnyArgsAndReturn( eIPv6_LinkLocal ); + xIsIPv6AllowedMulticast_ExpectAndReturn( pxIPAddress, pdFALSE ); + xIPv6_GetIPType_ExpectAnyArgsAndReturn( eIPv6_LinkLocal ); + FreeRTOS_FindEndPointOnIP_IPv6_ExpectAnyArgsAndReturn( pxEndPoint ); + pxGetNetworkBufferWithDescriptor_ExpectAnyArgsAndReturn( pxNetworkBuffer ); + vReleaseNetworkBufferAndDescriptor_Expect( pxNetworkBuffer ); + + xResult = xCheckRequiresNDResolution( pxNetworkBuffer ); + + TEST_ASSERT_EQUAL( pdTRUE, xResult ); + + xIPv6_GetIPType_ExpectAnyArgsAndReturn( eIPv6_LinkLocal ); + xIsIPv6AllowedMulticast_ExpectAndReturn( pxIPAddress, pdFALSE ); + xIPv6_GetIPType_ExpectAnyArgsAndReturn( eIPv6_LinkLocal ); + FreeRTOS_FindEndPointOnIP_IPv6_ExpectAnyArgsAndReturn( pxEndPoint ); + pxGetNetworkBufferWithDescriptor_ExpectAnyArgsAndReturn( NULL ); + + xResult = xCheckRequiresNDResolution( pxNetworkBuffer ); + + TEST_ASSERT_EQUAL( pdTRUE, xResult ); +} \ No newline at end of file diff --git a/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_stubs.c b/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_stubs.c index cd7b72136..9369a7394 100644 --- a/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_stubs.c +++ b/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_stubs.c @@ -42,6 +42,27 @@ uint32_t ulStubFreeRTOS_inet_ntop_TargetSize; const char * pcStubFreeRTOS_inet_ntop_TargetCopySource; uint32_t ulStubFreeRTOS_inet_ntop_CopySize; +/** @brief The expected IP version and header length coded into the IP header itself. */ +#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) + +UDPPacketHeader_t xDefaultPartUDPPacketHeader = +{ + /* .ucBytes : */ + { + 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ + 0x08, 0x00, /* Ethernet frame type. */ + ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ + 0x00, /* ucDifferentiatedServicesCode. */ + 0x00, 0x00, /* usLength. */ + 0x00, 0x00, /* usIdentification. */ + 0x00, 0x00, /* usFragmentOffset. */ + ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ + ipPROTOCOL_UDP, /* ucProtocol. */ + 0x00, 0x00, /* usHeaderChecksum. */ + 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ + } +}; + /* ======================== Stub Callback Functions ========================= */ const char * pcStubFreeRTOS_inet_ntop( BaseType_t xAddressFamily, diff --git a/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_utest.c b/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_utest.c index f843d3324..f8a1cf542 100644 --- a/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_utest.c +++ b/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_utest.c @@ -43,8 +43,11 @@ #include "mock_event_groups.h" #include "mock_FreeRTOS_IP.h" +#include "mock_FreeRTOS_IP_Private.h" #include "mock_FreeRTOS_IPv6.h" #include "mock_FreeRTOS_Sockets.h" +#include "mock_FreeRTOS_ARP.h" +#include "mock_FreeRTOS_ND.h" #include "FreeRTOS_Routing.h" @@ -3672,3 +3675,47 @@ void test_FreeRTOS_MatchingEndpoint_MatchCustomFrameType() pxEndPoint = FreeRTOS_MatchingEndpoint( &xNetworkInterface, ( const uint8_t * ) ( pxProtocolPacket ) ); TEST_ASSERT_EQUAL( NULL, pxEndPoint ); } + +void test_xCheckRequiresResolution( void ) +{ + struct xNetworkEndPoint xEndPoint = { 0 }; + NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer; + uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; + BaseType_t xResult; + NetworkInterface_t xInterface; + + pxNetworkBuffer = &xNetworkBuffer; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + + IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); + IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); + + *ipLOCAL_IP_ADDRESS_POINTER = 0xABCD1234; + + xEndPoint.ipv4_settings.ulNetMask = 0xFFFFFF00; + xNetworkBuffer.pxEndPoint = &xEndPoint; + + /* Make sure there is no match. */ + pxIPHeader->ulSourceIPAddress = ~( *ipLOCAL_IP_ADDRESS_POINTER & xEndPoint.ipv4_settings.ulNetMask ); + + uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); + xCheckRequiresARPResolution_IgnoreAndReturn( pdFALSE ); + + xResult = xCheckRequiresResolution( pxNetworkBuffer ); + + TEST_ASSERT_EQUAL( pdFALSE, xResult ); + + uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv6_HEADER ); + xCheckRequiresNDResolution_IgnoreAndReturn( pdFALSE ); + + xResult = xCheckRequiresResolution( pxNetworkBuffer ); + + TEST_ASSERT_EQUAL( pdFALSE, xResult ); + + uxIPHeaderSizePacket_IgnoreAndReturn( 1 ); + xCheckRequiresNDResolution_IgnoreAndReturn( pdFALSE ); + + xResult = xCheckRequiresResolution( pxNetworkBuffer ); + + TEST_ASSERT_EQUAL( pdFALSE, xResult ); +} diff --git a/test/unit-test/FreeRTOS_Routing/ut.cmake b/test/unit-test/FreeRTOS_Routing/ut.cmake index 2ceb2a26b..4b3d08ce0 100644 --- a/test/unit-test/FreeRTOS_Routing/ut.cmake +++ b/test/unit-test/FreeRTOS_Routing/ut.cmake @@ -19,6 +19,7 @@ list(APPEND mock_list "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Sockets.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Private.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ARP.h" + "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ND.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_UDP_IP.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DHCP.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DNS.h" diff --git a/test/unit-test/FreeRTOS_Routing_ConfigCompatibleWithSingle/ut.cmake b/test/unit-test/FreeRTOS_Routing_ConfigCompatibleWithSingle/ut.cmake index 1c1c75ee5..2ca840d29 100644 --- a/test/unit-test/FreeRTOS_Routing_ConfigCompatibleWithSingle/ut.cmake +++ b/test/unit-test/FreeRTOS_Routing_ConfigCompatibleWithSingle/ut.cmake @@ -20,6 +20,7 @@ list(APPEND mock_list "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Sockets.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Private.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ARP.h" + "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ND.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_UDP_IP.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DHCP.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DNS.h" diff --git a/test/unit-test/FreeRTOS_UDP_IPv6/FreeRTOS_UDP_IPv6_utest.c b/test/unit-test/FreeRTOS_UDP_IPv6/FreeRTOS_UDP_IPv6_utest.c index ec887f2e3..9ac618158 100644 --- a/test/unit-test/FreeRTOS_UDP_IPv6/FreeRTOS_UDP_IPv6_utest.c +++ b/test/unit-test/FreeRTOS_UDP_IPv6/FreeRTOS_UDP_IPv6_utest.c @@ -504,7 +504,7 @@ void test_xProcessReceivedUDPPacket_IPv6_SocketNeedND() pxUDPv6Packet->xUDPHeader.usDestinationPort = usDestPortNetworkEndian; pxUDPSocketLookup_ExpectAndReturn( usDestPortNetworkEndian, &xSocket ); - xCheckRequiresARPResolution_ExpectAndReturn( &xNetworkBuffer, pdTRUE ); + xCheckRequiresNDResolution_ExpectAndReturn( &xNetworkBuffer, pdTRUE ); xReturn = xProcessReceivedUDPPacket_IPv6( &xNetworkBuffer, usDestPortNetworkEndian, &xIsWaitingForARPResolution ); @@ -545,7 +545,7 @@ void test_xProcessReceivedUDPPacket_IPv6_SocketRecvHandlerFail() xSocket.u.xUDP.pxHandleReceive = xStubUDPReceiveHandler_Fail; pxUDPSocketLookup_ExpectAndReturn( usDestPortNetworkEndian, &xSocket ); - xCheckRequiresARPResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); + xCheckRequiresNDResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); vNDRefreshCacheEntry_Ignore(); uxIPHeaderSizePacket_ExpectAndReturn( &xNetworkBuffer, ipSIZE_OF_IPv6_HEADER ); @@ -587,7 +587,7 @@ void test_xProcessReceivedUDPPacket_IPv6_UDPListBufferFull() xSocket.u.xUDP.pxHandleReceive = xStubUDPReceiveHandler_Pass; pxUDPSocketLookup_ExpectAndReturn( usDestPortNetworkEndian, &xSocket ); - xCheckRequiresARPResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); + xCheckRequiresNDResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); vNDRefreshCacheEntry_Ignore(); uxIPHeaderSizePacket_ExpectAndReturn( &xNetworkBuffer, ipSIZE_OF_IPv6_HEADER ); @@ -635,7 +635,7 @@ void test_xProcessReceivedUDPPacket_IPv6_Pass() xSocket.u.xUDP.pxHandleReceive = NULL; pxUDPSocketLookup_ExpectAndReturn( usDestPortNetworkEndian, &xSocket ); - xCheckRequiresARPResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); + xCheckRequiresNDResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); vNDRefreshCacheEntry_Ignore(); uxIPHeaderSizePacket_ExpectAndReturn( &xNetworkBuffer, ipSIZE_OF_IPv6_HEADER ); @@ -702,7 +702,7 @@ void test_xProcessReceivedUDPPacket_IPv6_PassNoEventGroup() xSocket.xEventGroup = NULL; pxUDPSocketLookup_ExpectAndReturn( usDestPortNetworkEndian, &xSocket ); - xCheckRequiresARPResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); + xCheckRequiresNDResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); vNDRefreshCacheEntry_Ignore(); uxIPHeaderSizePacket_ExpectAndReturn( &xNetworkBuffer, ipSIZE_OF_IPv6_HEADER ); @@ -767,7 +767,7 @@ void test_xProcessReceivedUDPPacket_IPv6_PassNoSelectBit() xSocket.xEventGroup = xEventGroup; pxUDPSocketLookup_ExpectAndReturn( usDestPortNetworkEndian, &xSocket ); - xCheckRequiresARPResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); + xCheckRequiresNDResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); vNDRefreshCacheEntry_Ignore(); uxIPHeaderSizePacket_ExpectAndReturn( &xNetworkBuffer, ipSIZE_OF_IPv6_HEADER ); @@ -831,7 +831,7 @@ void test_xProcessReceivedUDPPacket_IPv6_PassNoSelectSet() xSocket.xEventGroup = xEventGroup; pxUDPSocketLookup_ExpectAndReturn( usDestPortNetworkEndian, &xSocket ); - xCheckRequiresARPResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); + xCheckRequiresNDResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); vNDRefreshCacheEntry_Ignore(); uxIPHeaderSizePacket_ExpectAndReturn( &xNetworkBuffer, ipSIZE_OF_IPv6_HEADER ); @@ -893,7 +893,7 @@ void test_xProcessReceivedUDPPacket_IPv6_PassNoSem() xSocket.xEventGroup = xEventGroup; pxUDPSocketLookup_ExpectAndReturn( usDestPortNetworkEndian, &xSocket ); - xCheckRequiresARPResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); + xCheckRequiresNDResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); vNDRefreshCacheEntry_Ignore(); uxIPHeaderSizePacket_ExpectAndReturn( &xNetworkBuffer, ipSIZE_OF_IPv6_HEADER ); @@ -956,7 +956,7 @@ void test_xProcessReceivedUDPPacket_IPv6_PassNoDHCP() xSocket.xEventGroup = xEventGroup; pxUDPSocketLookup_ExpectAndReturn( usDestPortNetworkEndian, &xSocket ); - xCheckRequiresARPResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); + xCheckRequiresNDResolution_ExpectAndReturn( &xNetworkBuffer, pdFALSE ); vNDRefreshCacheEntry_Ignore(); uxIPHeaderSizePacket_ExpectAndReturn( &xNetworkBuffer, ipSIZE_OF_IPv6_HEADER ); From 4ec67839ea3d25219d48421eb954c638fa57e029 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 9 Feb 2024 00:33:12 +0000 Subject: [PATCH 02/25] Uncrustify: triggered by comment. --- source/FreeRTOS_ARP.c | 728 +++++++++--------- source/FreeRTOS_ND.c | 108 +-- source/FreeRTOS_Routing.c | 8 +- .../unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c | 2 +- 4 files changed, 423 insertions(+), 423 deletions(-) diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index ab8977ebb..46b52e9de 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -61,27 +61,27 @@ /** @brief When the age of an entry in the ARP table reaches this value (it counts down * to zero, so this is an old entry) an ARP request will be sent to see if the * entry is still valid and can therefore be refreshed. */ -#define arpMAX_ARP_AGE_BEFORE_NEW_ARP_REQUEST ( 3U ) + #define arpMAX_ARP_AGE_BEFORE_NEW_ARP_REQUEST ( 3U ) /** @brief The time between gratuitous ARPs. */ -#ifndef arpGRATUITOUS_ARP_PERIOD - #define arpGRATUITOUS_ARP_PERIOD ( pdMS_TO_TICKS( 20000U ) ) -#endif + #ifndef arpGRATUITOUS_ARP_PERIOD + #define arpGRATUITOUS_ARP_PERIOD ( pdMS_TO_TICKS( 20000U ) ) + #endif /** @brief When there is another device which has the same IP address as the IP address * of this device, a defensive ARP request should be sent out. However, according to * RFC 5227 section 1.1, there must be a minimum interval of 10 seconds between * consecutive defensive ARP packets. */ -#ifndef arpIP_CLASH_RESET_TIMEOUT_MS - #define arpIP_CLASH_RESET_TIMEOUT_MS 10000U -#endif + #ifndef arpIP_CLASH_RESET_TIMEOUT_MS + #define arpIP_CLASH_RESET_TIMEOUT_MS 10000U + #endif /** @brief Maximum number of defensive ARPs to be sent for an ARP clash per * arpIP_CLASH_RESET_TIMEOUT_MS period. The retries are limited to one as outlined * by RFC 5227 section 2.4 part b.*/ -#ifndef arpIP_CLASH_MAX_RETRIES - #define arpIP_CLASH_MAX_RETRIES 1U -#endif + #ifndef arpIP_CLASH_MAX_RETRIES + #define arpIP_CLASH_MAX_RETRIES 1U + #endif static void vARPProcessPacketRequest( ARPPacket_t * pxARPFrame, @@ -103,15 +103,15 @@ MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ); -static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, - const uint32_t ulIPAddress, - struct xNetworkEndPoint * pxEndPoint, - CacheLocation_t * pxLocation ); + static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, + const uint32_t ulIPAddress, + struct xNetworkEndPoint * pxEndPoint, + CacheLocation_t * pxLocation ); /*-----------------------------------------------------------*/ /** @brief The ARP cache. */ -_static ARPCacheRow_t xARPCache[ ipconfigARP_CACHE_ENTRIES ]; + _static ARPCacheRow_t xARPCache[ ipconfigARP_CACHE_ENTRIES ]; /* @@ -119,12 +119,12 @@ _static ARPCacheRow_t xARPCache[ ipconfigARP_CACHE_ENTRIES ]; * driver can try out a random LinkLayer IP address (169.254.x.x). It will send out a * gratuitous ARP message and, after a period of time, check the variables here below: */ -#if ( ipconfigARP_USE_CLASH_DETECTION != 0 ) - /* Becomes non-zero if another device responded to a gratuitous ARP message. */ - BaseType_t xARPHadIPClash; - /* MAC-address of the other device containing the same IP-address. */ - MACAddress_t xARPClashMacAddress; -#endif /* ipconfigARP_USE_CLASH_DETECTION */ + #if ( ipconfigARP_USE_CLASH_DETECTION != 0 ) + /* Becomes non-zero if another device responded to a gratuitous ARP message. */ + BaseType_t xARPHadIPClash; + /* MAC-address of the other device containing the same IP-address. */ + MACAddress_t xARPClashMacAddress; + #endif /* ipconfigARP_USE_CLASH_DETECTION */ /*-----------------------------------------------------------*/ @@ -477,32 +477,32 @@ _static ARPCacheRow_t xARPCache[ ipconfigARP_CACHE_ENTRIES ]; * * @return When the IP-address is found: pdTRUE, else pdFALSE. */ -BaseType_t xIsIPInARPCache( uint32_t ulAddressToLookup ) -{ - BaseType_t x, xReturn = pdFALSE; - - /* Loop through each entry in the ARP cache. */ - for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) + BaseType_t xIsIPInARPCache( uint32_t ulAddressToLookup ) { - /* Does this row in the ARP cache table hold an entry for the IP address - * being queried? */ - if( xARPCache[ x ].ulIPAddress == ulAddressToLookup ) - { - xReturn = pdTRUE; + BaseType_t x, xReturn = pdFALSE; - /* A matching valid entry was found. */ - if( xARPCache[ x ].ucValid == ( uint8_t ) pdFALSE ) + /* Loop through each entry in the ARP cache. */ + for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) + { + /* Does this row in the ARP cache table hold an entry for the IP address + * being queried? */ + if( xARPCache[ x ].ulIPAddress == ulAddressToLookup ) { - /* This entry is waiting an ARP reply, so is not valid. */ - xReturn = pdFALSE; - } + xReturn = pdTRUE; - break; + /* A matching valid entry was found. */ + if( xARPCache[ x ].ucValid == ( uint8_t ) pdFALSE ) + { + /* This entry is waiting an ARP reply, so is not valid. */ + xReturn = pdFALSE; + } + + break; + } } - } - return xReturn; -} + return xReturn; + } /** * @brief Check whether a packet needs ARP resolution if it is on local subnet. If required send an ARP request. @@ -511,35 +511,35 @@ BaseType_t xIsIPInARPCache( uint32_t ulAddressToLookup ) * * @return pdTRUE if the packet needs ARP resolution, pdFALSE otherwise. */ -BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer ) -{ - BaseType_t xNeedsARPResolution = pdFALSE; - - /* 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] */ - const IPPacket_t * pxIPPacket = ( ( const IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); - const IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); - const IPV4Parameters_t * pxIPv4Settings = &( pxNetworkBuffer->pxEndPoint->ipv4_settings ); - - if( ( pxIPHeader->ulSourceIPAddress & pxIPv4Settings->ulNetMask ) == ( pxIPv4Settings->ulIPAddress & pxIPv4Settings->ulNetMask ) ) + BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer ) { - /* If the IP is on the same subnet and we do not have an ARP entry already, - * then we should send out ARP for finding the MAC address. */ - if( xIsIPInARPCache( pxIPHeader->ulSourceIPAddress ) == pdFALSE ) + BaseType_t xNeedsARPResolution = pdFALSE; + + /* 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] */ + const IPPacket_t * pxIPPacket = ( ( const IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); + const IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); + const IPV4Parameters_t * pxIPv4Settings = &( pxNetworkBuffer->pxEndPoint->ipv4_settings ); + + if( ( pxIPHeader->ulSourceIPAddress & pxIPv4Settings->ulNetMask ) == ( pxIPv4Settings->ulIPAddress & pxIPv4Settings->ulNetMask ) ) { - FreeRTOS_OutputARPRequest( pxIPHeader->ulSourceIPAddress ); + /* If the IP is on the same subnet and we do not have an ARP entry already, + * then we should send out ARP for finding the MAC address. */ + if( xIsIPInARPCache( pxIPHeader->ulSourceIPAddress ) == pdFALSE ) + { + FreeRTOS_OutputARPRequest( pxIPHeader->ulSourceIPAddress ); - /* This packet needs resolution since this is on the same subnet - * but not in the ARP cache. */ - xNeedsARPResolution = pdTRUE; + /* This packet needs resolution since this is on the same subnet + * but not in the ARP cache. */ + xNeedsARPResolution = pdTRUE; + } } - } - return xNeedsARPResolution; -} + return xNeedsARPResolution; + } -#if ( ipconfigUSE_ARP_REMOVE_ENTRY != 0 ) + #if ( ipconfigUSE_ARP_REMOVE_ENTRY != 0 ) /** * @brief Remove an ARP cache entry that matches with .pxMACAddress. @@ -548,28 +548,28 @@ BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetw * be removed. * @return When the entry was found and remove: the IP-address, otherwise zero. */ - uint32_t ulARPRemoveCacheEntryByMac( const MACAddress_t * pxMACAddress ) - { - BaseType_t x; - uint32_t lResult = 0; + uint32_t ulARPRemoveCacheEntryByMac( const MACAddress_t * pxMACAddress ) + { + BaseType_t x; + uint32_t lResult = 0; - configASSERT( pxMACAddress != NULL ); + configASSERT( pxMACAddress != NULL ); - /* For each entry in the ARP cache table. */ - for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) - { - if( ( memcmp( xARPCache[ x ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ) == 0 ) ) + /* For each entry in the ARP cache table. */ + for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) { - lResult = xARPCache[ x ].ulIPAddress; - ( void ) memset( &xARPCache[ x ], 0, sizeof( xARPCache[ x ] ) ); - break; + if( ( memcmp( xARPCache[ x ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ) == 0 ) ) + { + lResult = xARPCache[ x ].ulIPAddress; + ( void ) memset( &xARPCache[ x ], 0, sizeof( xARPCache[ x ] ) ); + break; + } } - } - return lResult; - } + return lResult; + } -#endif /* ipconfigUSE_ARP_REMOVE_ENTRY != 0 */ + #endif /* ipconfigUSE_ARP_REMOVE_ENTRY != 0 */ /*-----------------------------------------------------------*/ /** @@ -579,31 +579,31 @@ BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetw * @param[in] pxMACAddress Pointer to the MAC address whose entry needs to be updated. * @param[in] ulIPAddress the IP address whose corresponding entry needs to be updated. */ -void vARPRefreshCacheEntryAge( const MACAddress_t * pxMACAddress, - const uint32_t ulIPAddress ) -{ - BaseType_t x; - - if( pxMACAddress != NULL ) + void vARPRefreshCacheEntryAge( const MACAddress_t * pxMACAddress, + const uint32_t ulIPAddress ) { - /* Loop through each entry in the ARP cache. */ - for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) + BaseType_t x; + + if( pxMACAddress != NULL ) { - /* Does this line in the cache table hold an entry for the IP - * address being queried? */ - if( xARPCache[ x ].ulIPAddress == ulIPAddress ) + /* Loop through each entry in the ARP cache. */ + for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) { - /* Does this cache entry have the same MAC address? */ - if( memcmp( xARPCache[ x ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ) == 0 ) + /* Does this line in the cache table hold an entry for the IP + * address being queried? */ + if( xARPCache[ x ].ulIPAddress == ulIPAddress ) { - /* The IP address and the MAC matched, update this entry age. */ - xARPCache[ x ].ucAge = ( uint8_t ) ipconfigMAX_ARP_AGE; - break; + /* Does this cache entry have the same MAC address? */ + if( memcmp( xARPCache[ x ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ) == 0 ) + { + /* The IP address and the MAC matched, update this entry age. */ + xARPCache[ x ].ucAge = ( uint8_t ) ipconfigMAX_ARP_AGE; + break; + } } } } } -} /*-----------------------------------------------------------*/ /** @@ -615,82 +615,82 @@ void vARPRefreshCacheEntryAge( const MACAddress_t * pxMACAddress, * is being updated. * @param[in] pxEndPoint The end-point stored in the table. */ -void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, - const uint32_t ulIPAddress, - struct xNetworkEndPoint * pxEndPoint ) -{ - #if ( ipconfigARP_STORES_REMOTE_ADDRESSES == 0 ) - /* Only process the IP address if it is on the local network. */ - BaseType_t xAddressIsLocal = ( FreeRTOS_FindEndPointOnNetMask( ulIPAddress, 2 ) != NULL ) ? 1 : 0; /* ARP remote address. */ - - /* Only process the IP address if it matches with one of the end-points. */ - if( xAddressIsLocal != 0 ) - #else - - /* If ipconfigARP_STORES_REMOTE_ADDRESSES is non-zero, IP addresses with - * a different netmask will also be stored. After when replying to a UDP - * message from a different netmask, the IP address can be looped up and a - * reply sent. This option is useful for systems with multiple gateways, - * the reply will surely arrive. If ipconfigARP_STORES_REMOTE_ADDRESSES is - * zero the the gateway address is the only option. */ - - if( pdTRUE ) - #endif + void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, + const uint32_t ulIPAddress, + struct xNetworkEndPoint * pxEndPoint ) { - CacheLocation_t xLocation; - BaseType_t xReady; + #if ( ipconfigARP_STORES_REMOTE_ADDRESSES == 0 ) + /* Only process the IP address if it is on the local network. */ + BaseType_t xAddressIsLocal = ( FreeRTOS_FindEndPointOnNetMask( ulIPAddress, 2 ) != NULL ) ? 1 : 0; /* ARP remote address. */ + + /* Only process the IP address if it matches with one of the end-points. */ + if( xAddressIsLocal != 0 ) + #else + + /* If ipconfigARP_STORES_REMOTE_ADDRESSES is non-zero, IP addresses with + * a different netmask will also be stored. After when replying to a UDP + * message from a different netmask, the IP address can be looped up and a + * reply sent. This option is useful for systems with multiple gateways, + * the reply will surely arrive. If ipconfigARP_STORES_REMOTE_ADDRESSES is + * zero the the gateway address is the only option. */ + + if( pdTRUE ) + #endif + { + CacheLocation_t xLocation; + BaseType_t xReady; - xReady = prvFindCacheEntry( pxMACAddress, ulIPAddress, pxEndPoint, &( xLocation ) ); + xReady = prvFindCacheEntry( pxMACAddress, ulIPAddress, pxEndPoint, &( xLocation ) ); - if( xReady == pdFALSE ) - { - if( xLocation.xMacEntry >= 0 ) + if( xReady == pdFALSE ) { - xLocation.xUseEntry = xLocation.xMacEntry; + if( xLocation.xMacEntry >= 0 ) + { + xLocation.xUseEntry = xLocation.xMacEntry; - if( xLocation.xIpEntry >= 0 ) + if( xLocation.xIpEntry >= 0 ) + { + /* Both the MAC address as well as the IP address were found in + * different locations: clear the entry which matches the + * IP-address */ + ( void ) memset( &( xARPCache[ xLocation.xIpEntry ] ), 0, sizeof( ARPCacheRow_t ) ); + } + } + else if( xLocation.xIpEntry >= 0 ) { - /* Both the MAC address as well as the IP address were found in - * different locations: clear the entry which matches the - * IP-address */ - ( void ) memset( &( xARPCache[ xLocation.xIpEntry ] ), 0, sizeof( ARPCacheRow_t ) ); + /* An entry containing the IP-address was found, but it had a different MAC address */ + xLocation.xUseEntry = xLocation.xIpEntry; + } + else + { + /* No matching entry found. */ } - } - else if( xLocation.xIpEntry >= 0 ) - { - /* An entry containing the IP-address was found, but it had a different MAC address */ - xLocation.xUseEntry = xLocation.xIpEntry; - } - else - { - /* No matching entry found. */ - } - /* If the entry was not found, we use the oldest entry and set the IPaddress */ - xARPCache[ xLocation.xUseEntry ].ulIPAddress = ulIPAddress; + /* If the entry was not found, we use the oldest entry and set the IPaddress */ + xARPCache[ xLocation.xUseEntry ].ulIPAddress = ulIPAddress; - if( pxMACAddress != NULL ) - { - ( void ) memcpy( xARPCache[ xLocation.xUseEntry ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ); + if( pxMACAddress != NULL ) + { + ( void ) memcpy( xARPCache[ xLocation.xUseEntry ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ); - iptraceARP_TABLE_ENTRY_CREATED( ulIPAddress, ( *pxMACAddress ) ); - /* And this entry does not need immediate attention */ - xARPCache[ xLocation.xUseEntry ].ucAge = ( uint8_t ) ipconfigMAX_ARP_AGE; - xARPCache[ xLocation.xUseEntry ].ucValid = ( uint8_t ) pdTRUE; - xARPCache[ xLocation.xUseEntry ].pxEndPoint = pxEndPoint; - } - else if( xLocation.xIpEntry < 0 ) - { - xARPCache[ xLocation.xUseEntry ].ucAge = ( uint8_t ) ipconfigMAX_ARP_RETRANSMISSIONS; - xARPCache[ xLocation.xUseEntry ].ucValid = ( uint8_t ) pdFALSE; - } - else - { - /* Nothing will be stored. */ + iptraceARP_TABLE_ENTRY_CREATED( ulIPAddress, ( *pxMACAddress ) ); + /* And this entry does not need immediate attention */ + xARPCache[ xLocation.xUseEntry ].ucAge = ( uint8_t ) ipconfigMAX_ARP_AGE; + xARPCache[ xLocation.xUseEntry ].ucValid = ( uint8_t ) pdTRUE; + xARPCache[ xLocation.xUseEntry ].pxEndPoint = pxEndPoint; + } + else if( xLocation.xIpEntry < 0 ) + { + xARPCache[ xLocation.xUseEntry ].ucAge = ( uint8_t ) ipconfigMAX_ARP_RETRANSMISSIONS; + xARPCache[ xLocation.xUseEntry ].ucValid = ( uint8_t ) pdFALSE; + } + else + { + /* Nothing will be stored. */ + } } } } -} /*-----------------------------------------------------------*/ /** @@ -701,118 +701,118 @@ void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, * @param[in] pxEndPoint The end-point that will stored in the table. * @param[out] pxLocation The results of this search are written in this struct. */ -static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, - const uint32_t ulIPAddress, - struct xNetworkEndPoint * pxEndPoint, - CacheLocation_t * pxLocation ) -{ - BaseType_t x = 0; - uint8_t ucMinAgeFound = 0U; - BaseType_t xReturn = pdFALSE; - - #if ( ipconfigARP_STORES_REMOTE_ADDRESSES != 0 ) - BaseType_t xAddressIsLocal = ( FreeRTOS_FindEndPointOnNetMask( ulIPAddress, 2 ) != NULL ) ? 1 : 0; /* ARP remote address. */ - #endif + static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, + const uint32_t ulIPAddress, + struct xNetworkEndPoint * pxEndPoint, + CacheLocation_t * pxLocation ) + { + BaseType_t x = 0; + uint8_t ucMinAgeFound = 0U; + BaseType_t xReturn = pdFALSE; - /* Start with the maximum possible number. */ - ucMinAgeFound--; + #if ( ipconfigARP_STORES_REMOTE_ADDRESSES != 0 ) + BaseType_t xAddressIsLocal = ( FreeRTOS_FindEndPointOnNetMask( ulIPAddress, 2 ) != NULL ) ? 1 : 0; /* ARP remote address. */ + #endif - pxLocation->xIpEntry = -1; - pxLocation->xMacEntry = -1; - pxLocation->xUseEntry = 0; + /* Start with the maximum possible number. */ + ucMinAgeFound--; - /* For each entry in the ARP cache table. */ - for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) - { - BaseType_t xMatchingMAC = pdFALSE; + pxLocation->xIpEntry = -1; + pxLocation->xMacEntry = -1; + pxLocation->xUseEntry = 0; - if( pxMACAddress != NULL ) + /* For each entry in the ARP cache table. */ + for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) { - if( memcmp( xARPCache[ x ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ) == 0 ) - { - xMatchingMAC = pdTRUE; - } - } + BaseType_t xMatchingMAC = pdFALSE; - /* Does this line in the cache table hold an entry for the IP - * address being queried? */ - if( xARPCache[ x ].ulIPAddress == ulIPAddress ) - { - if( pxMACAddress == NULL ) + if( pxMACAddress != NULL ) { - /* In case the parameter pxMACAddress is NULL, an entry will be reserved to - * indicate that there is an outstanding ARP request, This entry will have - * "ucValid == pdFALSE". */ - pxLocation->xIpEntry = x; - break; + if( memcmp( xARPCache[ x ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ) == 0 ) + { + xMatchingMAC = pdTRUE; + } } - /* See if the MAC-address also matches. */ - if( xMatchingMAC != pdFALSE ) + /* Does this line in the cache table hold an entry for the IP + * address being queried? */ + if( xARPCache[ x ].ulIPAddress == ulIPAddress ) { - /* This function will be called for each received packet - * This is by far the most common path. */ - xARPCache[ x ].ucAge = ( uint8_t ) ipconfigMAX_ARP_AGE; - xARPCache[ x ].ucValid = ( uint8_t ) pdTRUE; - xARPCache[ x ].pxEndPoint = pxEndPoint; - /* Indicate to the caller that the entry is updated. */ - xReturn = pdTRUE; - break; - } + if( pxMACAddress == NULL ) + { + /* In case the parameter pxMACAddress is NULL, an entry will be reserved to + * indicate that there is an outstanding ARP request, This entry will have + * "ucValid == pdFALSE". */ + pxLocation->xIpEntry = x; + break; + } - /* Found an entry containing ulIPAddress, but the MAC address - * doesn't match. Might be an entry with ucValid=pdFALSE, waiting - * for an ARP reply. Still want to see if there is match with the - * given MAC address.ucBytes. If found, either of the two entries - * must be cleared. */ - pxLocation->xIpEntry = x; - } - else if( xMatchingMAC != pdFALSE ) - { - /* Found an entry with the given MAC-address, but the IP-address - * is different. Continue looping to find a possible match with - * ulIPAddress. */ - #if ( ipconfigARP_STORES_REMOTE_ADDRESSES != 0 ) + /* See if the MAC-address also matches. */ + if( xMatchingMAC != pdFALSE ) + { + /* This function will be called for each received packet + * This is by far the most common path. */ + xARPCache[ x ].ucAge = ( uint8_t ) ipconfigMAX_ARP_AGE; + xARPCache[ x ].ucValid = ( uint8_t ) pdTRUE; + xARPCache[ x ].pxEndPoint = pxEndPoint; + /* Indicate to the caller that the entry is updated. */ + xReturn = pdTRUE; + break; + } + + /* Found an entry containing ulIPAddress, but the MAC address + * doesn't match. Might be an entry with ucValid=pdFALSE, waiting + * for an ARP reply. Still want to see if there is match with the + * given MAC address.ucBytes. If found, either of the two entries + * must be cleared. */ + pxLocation->xIpEntry = x; + } + else if( xMatchingMAC != pdFALSE ) { - /* If ARP stores the MAC address of IP addresses outside the - * network, than the MAC address of the gateway should not be - * overwritten. */ - BaseType_t xOtherIsLocal = ( FreeRTOS_FindEndPointOnNetMask( xARPCache[ x ].ulIPAddress, 3 ) != NULL ) ? 1 : 0; /* ARP remote address. */ + /* Found an entry with the given MAC-address, but the IP-address + * is different. Continue looping to find a possible match with + * ulIPAddress. */ + #if ( ipconfigARP_STORES_REMOTE_ADDRESSES != 0 ) + { + /* If ARP stores the MAC address of IP addresses outside the + * network, than the MAC address of the gateway should not be + * overwritten. */ + BaseType_t xOtherIsLocal = ( FreeRTOS_FindEndPointOnNetMask( xARPCache[ x ].ulIPAddress, 3 ) != NULL ) ? 1 : 0; /* ARP remote address. */ - if( xAddressIsLocal == xOtherIsLocal ) + if( xAddressIsLocal == xOtherIsLocal ) + { + pxLocation->xMacEntry = x; + } + } + #else /* if ( ipconfigARP_STORES_REMOTE_ADDRESSES != 0 ) */ { pxLocation->xMacEntry = x; } + #endif /* if ( ipconfigARP_STORES_REMOTE_ADDRESSES != 0 ) */ } - #else /* if ( ipconfigARP_STORES_REMOTE_ADDRESSES != 0 ) */ + + /* _HT_ + * Shouldn't we test for xARPCache[ x ].ucValid == pdFALSE here ? */ + else if( xARPCache[ x ].ucAge < ucMinAgeFound ) { - pxLocation->xMacEntry = x; + /* As the table is traversed, remember the table row that + * contains the oldest entry (the lowest age count, as ages are + * decremented to zero) so the row can be re-used if this function + * needs to add an entry that does not already exist. */ + ucMinAgeFound = xARPCache[ x ].ucAge; + pxLocation->xUseEntry = x; } - #endif /* if ( ipconfigARP_STORES_REMOTE_ADDRESSES != 0 ) */ - } - - /* _HT_ - * Shouldn't we test for xARPCache[ x ].ucValid == pdFALSE here ? */ - else if( xARPCache[ x ].ucAge < ucMinAgeFound ) - { - /* As the table is traversed, remember the table row that - * contains the oldest entry (the lowest age count, as ages are - * decremented to zero) so the row can be re-used if this function - * needs to add an entry that does not already exist. */ - ucMinAgeFound = xARPCache[ x ].ucAge; - pxLocation->xUseEntry = x; - } - else - { - /* Nothing happens to this cache entry for now. */ - } - } /* for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) */ + else + { + /* Nothing happens to this cache entry for now. */ + } + } /* for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) */ - return xReturn; -} + return xReturn; + } /*-----------------------------------------------------------*/ -#if ( ipconfigUSE_ARP_REVERSED_LOOKUP == 1 ) + #if ( ipconfigUSE_ARP_REVERSED_LOOKUP == 1 ) /** * @brief Retrieve an entry from the cache table @@ -822,44 +822,44 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, * * @return Either eARPCacheMiss or eARPCacheHit. */ - eARPLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, - uint32_t * pulIPAddress, - struct xNetworkInterface ** ppxInterface ) - { - BaseType_t x; - eARPLookupResult_t eReturn = eARPCacheMiss; - - configASSERT( pxMACAddress != NULL ); - configASSERT( pulIPAddress != NULL ); - - if( ppxInterface != NULL ) + eARPLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, + uint32_t * pulIPAddress, + struct xNetworkInterface ** ppxInterface ) { - *( ppxInterface ) = NULL; - } + BaseType_t x; + eARPLookupResult_t eReturn = eARPCacheMiss; - /* Loop through each entry in the ARP cache. */ - for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) - { - /* Does this row in the ARP cache table hold an entry for the MAC - * address being searched? */ - if( memcmp( pxMACAddress->ucBytes, xARPCache[ x ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + configASSERT( pxMACAddress != NULL ); + configASSERT( pulIPAddress != NULL ); + + if( ppxInterface != NULL ) { - *pulIPAddress = xARPCache[ x ].ulIPAddress; + *( ppxInterface ) = NULL; + } - if( ( ppxInterface != NULL ) && - ( xARPCache[ x ].pxEndPoint != NULL ) ) + /* Loop through each entry in the ARP cache. */ + for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) + { + /* Does this row in the ARP cache table hold an entry for the MAC + * address being searched? */ + if( memcmp( pxMACAddress->ucBytes, xARPCache[ x ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) { - *( ppxInterface ) = xARPCache[ x ].pxEndPoint->pxNetworkInterface; - } + *pulIPAddress = xARPCache[ x ].ulIPAddress; - eReturn = eARPCacheHit; - break; + if( ( ppxInterface != NULL ) && + ( xARPCache[ x ].pxEndPoint != NULL ) ) + { + *( ppxInterface ) = xARPCache[ x ].pxEndPoint->pxNetworkInterface; + } + + eReturn = eARPCacheHit; + break; + } } - } - return eReturn; - } -#endif /* ipconfigUSE_ARP_REVERSED_LOOKUP */ + return eReturn; + } + #endif /* ipconfigUSE_ARP_REVERSED_LOOKUP */ /*-----------------------------------------------------------*/ @@ -1397,28 +1397,28 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, * @param[in] pxEndPoint only clean entries with this end-point, or when NULL, * clear the entire ARP cache. */ -void FreeRTOS_ClearARP( const struct xNetworkEndPoint * pxEndPoint ) -{ - if( pxEndPoint != NULL ) + void FreeRTOS_ClearARP( const struct xNetworkEndPoint * pxEndPoint ) { - BaseType_t x; - - for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) + if( pxEndPoint != NULL ) { - if( xARPCache[ x ].pxEndPoint == pxEndPoint ) + BaseType_t x; + + for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) { - ( void ) memset( &( xARPCache[ x ] ), 0, sizeof( ARPCacheRow_t ) ); + if( xARPCache[ x ].pxEndPoint == pxEndPoint ) + { + ( void ) memset( &( xARPCache[ x ] ), 0, sizeof( ARPCacheRow_t ) ); + } } } + else + { + ( void ) memset( xARPCache, 0, sizeof( xARPCache ) ); + } } - else - { - ( void ) memset( xARPCache, 0, sizeof( xARPCache ) ); - } -} /*-----------------------------------------------------------*/ -#if 1 + #if 1 /** * @brief This function will check if the target IP-address belongs to this device. @@ -1432,99 +1432,99 @@ void FreeRTOS_ClearARP( const struct xNetworkEndPoint * pxEndPoint ) * * @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 ) ) ) + BaseType_t xCheckLoopback( NetworkBufferDescriptor_t * const pxDescriptor, + BaseType_t bReleaseAfterSend ) { - /* 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 ); + BaseType_t xResult = pdFALSE; + NetworkBufferDescriptor_t * pxUseDescriptor = pxDescriptor; - if( pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) - { - NetworkEndPoint_t * pxEndPoint; + const IPPacket_t * pxIPPacket; - pxEndPoint = FreeRTOS_FindEndPointOnMAC( &( pxIPPacket->xEthernetHeader.xDestinationAddress ), NULL ); + 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( ( pxEndPoint != NULL ) && - ( memcmp( pxIPPacket->xEthernetHeader.xDestinationAddress.ucBytes, pxEndPoint->xMACAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) ) + if( pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) { - xResult = pdTRUE; + NetworkEndPoint_t * pxEndPoint; - if( bReleaseAfterSend == pdFALSE ) - { - /* Driver is not allowed to transfer the ownership - * of descriptor, so make a copy of it */ - pxUseDescriptor = - pxDuplicateNetworkBufferWithDescriptor( pxDescriptor, pxDescriptor->xDataLength ); - } + pxEndPoint = FreeRTOS_FindEndPointOnMAC( &( pxIPPacket->xEthernetHeader.xDestinationAddress ), NULL ); - if( pxUseDescriptor != NULL ) + if( ( pxEndPoint != NULL ) && + ( memcmp( pxIPPacket->xEthernetHeader.xDestinationAddress.ucBytes, pxEndPoint->xMACAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) ) { - IPStackEvent_t xRxEvent; - - pxUseDescriptor->pxInterface = pxEndPoint->pxNetworkInterface; - pxUseDescriptor->pxEndPoint = pxEndPoint; + xResult = pdTRUE; - xRxEvent.eEventType = eNetworkRxEvent; - xRxEvent.pvData = pxUseDescriptor; + 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( xSendEventStructToIPTask( &xRxEvent, 0U ) != pdTRUE ) + if( pxUseDescriptor != NULL ) { - vReleaseNetworkBufferAndDescriptor( pxUseDescriptor ); - iptraceETHERNET_RX_EVENT_LOST(); - FreeRTOS_printf( ( "prvEMACRxPoll: Can not queue return packet!\n" ) ); + 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; - } + return xResult; + } -#endif /* 0 */ + #endif /* 0 */ /*-----------------------------------------------------------*/ -#if ( ipconfigHAS_PRINTF != 0 ) || ( ipconfigHAS_DEBUG_PRINTF != 0 ) + #if ( ipconfigHAS_PRINTF != 0 ) || ( ipconfigHAS_DEBUG_PRINTF != 0 ) - void FreeRTOS_PrintARPCache( void ) - { - BaseType_t x, xCount = 0; - - /* Loop through each entry in the ARP cache. */ - for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) + void FreeRTOS_PrintARPCache( void ) { - if( ( xARPCache[ x ].ulIPAddress != 0U ) && ( xARPCache[ x ].ucAge > ( uint8_t ) 0U ) ) + BaseType_t x, xCount = 0; + + /* Loop through each entry in the ARP cache. */ + for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) { - /* See if the MAC-address also matches, and we're all happy */ - FreeRTOS_printf( ( "ARP %2d: %3u - %16xip : %02x:%02x:%02x : %02x:%02x:%02x\n", - ( int ) x, - xARPCache[ x ].ucAge, - ( unsigned ) FreeRTOS_ntohl( xARPCache[ x ].ulIPAddress ), - xARPCache[ x ].xMACAddress.ucBytes[ 0 ], - xARPCache[ x ].xMACAddress.ucBytes[ 1 ], - xARPCache[ x ].xMACAddress.ucBytes[ 2 ], - xARPCache[ x ].xMACAddress.ucBytes[ 3 ], - xARPCache[ x ].xMACAddress.ucBytes[ 4 ], - xARPCache[ x ].xMACAddress.ucBytes[ 5 ] ) ); - xCount++; + if( ( xARPCache[ x ].ulIPAddress != 0U ) && ( xARPCache[ x ].ucAge > ( uint8_t ) 0U ) ) + { + /* See if the MAC-address also matches, and we're all happy */ + FreeRTOS_printf( ( "ARP %2d: %3u - %16xip : %02x:%02x:%02x : %02x:%02x:%02x\n", + ( int ) x, + xARPCache[ x ].ucAge, + ( unsigned ) FreeRTOS_ntohl( xARPCache[ x ].ulIPAddress ), + xARPCache[ x ].xMACAddress.ucBytes[ 0 ], + xARPCache[ x ].xMACAddress.ucBytes[ 1 ], + xARPCache[ x ].xMACAddress.ucBytes[ 2 ], + xARPCache[ x ].xMACAddress.ucBytes[ 3 ], + xARPCache[ x ].xMACAddress.ucBytes[ 4 ], + xARPCache[ x ].xMACAddress.ucBytes[ 5 ] ) ); + xCount++; + } } - } - FreeRTOS_printf( ( "Arp has %ld entries\n", xCount ) ); - } -#endif /* ( ipconfigHAS_PRINTF != 0 ) || ( ipconfigHAS_DEBUG_PRINTF != 0 ) */ + FreeRTOS_printf( ( "Arp has %ld entries\n", xCount ) ); + } + #endif /* ( ipconfigHAS_PRINTF != 0 ) || ( ipconfigHAS_DEBUG_PRINTF != 0 ) */ #endif /* ( ipconfigUSE_IPv4 != 0 ) */ diff --git a/source/FreeRTOS_ND.c b/source/FreeRTOS_ND.c index 67a1f1b6f..f465b3c4a 100644 --- a/source/FreeRTOS_ND.c +++ b/source/FreeRTOS_ND.c @@ -1324,61 +1324,61 @@ * * @return pdTRUE if the packet needs ND resolution, pdFALSE otherwise. */ -BaseType_t xCheckRequiresNDResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer ) -{ - BaseType_t xNeedsNDResolution = pdFALSE; - - /* 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] */ - IPPacket_IPv6_t * pxIPPacket = ( ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer ); - IPHeader_IPv6_t * pxIPHeader = &( pxIPPacket->xIPHeader ); - IPv6_Address_t * pxIPAddress = &( pxIPHeader->xSourceAddress ); - uint8_t ucNextHeader = pxIPHeader->ucNextHeader; - - if( ( ucNextHeader == ipPROTOCOL_TCP ) || - ( ucNextHeader == ipPROTOCOL_UDP ) ) + BaseType_t xCheckRequiresNDResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer ) { - IPv6_Type_t eType = xIPv6_GetIPType( ( const IPv6_Address_t * ) pxIPAddress ); - FreeRTOS_debug_printf( ( "xCheckRequiresARPResolution: %pip type %s\n", - ( void * ) pxIPAddress->ucBytes, - ( eType == eIPv6_Global ) ? "Global" : - ( eType == eIPv6_LinkLocal ) ? "LinkLocal" : - ( eType == eIPv6_Loopback ) ? "Loopback" : - "other" ) ); - - if( eType == eIPv6_LinkLocal ) - { - MACAddress_t xMACAddress; - NetworkEndPoint_t * pxEndPoint; - eARPLookupResult_t eResult; - char pcName[ 80 ]; - - ( void ) memset( &( pcName ), 0, sizeof( pcName ) ); - eResult = eNDGetCacheEntry( pxIPAddress, &xMACAddress, &pxEndPoint ); - FreeRTOS_printf( ( "xCheckRequiresARPResolution: eResult %s with EP %s\n", ( eResult == eARPCacheMiss ) ? "Miss" : ( eResult == eARPCacheHit ) ? "Hit" : "Error", pcEndpointName( pxEndPoint, pcName, sizeof pcName ) ) ); - - if( eResult == eARPCacheMiss ) - { - NetworkBufferDescriptor_t * pxTempBuffer; - size_t uxNeededSize; - - uxNeededSize = sizeof( ICMPPacket_IPv6_t ); - pxTempBuffer = pxGetNetworkBufferWithDescriptor( BUFFER_FROM_WHERE_CALL( 199 ) uxNeededSize, 0U ); - - if( pxTempBuffer != NULL ) - { - pxTempBuffer->pxEndPoint = pxNetworkBuffer->pxEndPoint; - pxTempBuffer->pxInterface = pxNetworkBuffer->pxInterface; - vNDSendNeighbourSolicitation( pxTempBuffer, pxIPAddress ); - } - - xNeedsNDResolution = pdTRUE; - } - } - } + BaseType_t xNeedsNDResolution = pdFALSE; + + /* 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] */ + IPPacket_IPv6_t * pxIPPacket = ( ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer ); + IPHeader_IPv6_t * pxIPHeader = &( pxIPPacket->xIPHeader ); + IPv6_Address_t * pxIPAddress = &( pxIPHeader->xSourceAddress ); + uint8_t ucNextHeader = pxIPHeader->ucNextHeader; + + if( ( ucNextHeader == ipPROTOCOL_TCP ) || + ( ucNextHeader == ipPROTOCOL_UDP ) ) + { + IPv6_Type_t eType = xIPv6_GetIPType( ( const IPv6_Address_t * ) pxIPAddress ); + FreeRTOS_debug_printf( ( "xCheckRequiresARPResolution: %pip type %s\n", + ( void * ) pxIPAddress->ucBytes, + ( eType == eIPv6_Global ) ? "Global" : + ( eType == eIPv6_LinkLocal ) ? "LinkLocal" : + ( eType == eIPv6_Loopback ) ? "Loopback" : + "other" ) ); + + if( eType == eIPv6_LinkLocal ) + { + MACAddress_t xMACAddress; + NetworkEndPoint_t * pxEndPoint; + eARPLookupResult_t eResult; + char pcName[ 80 ]; + + ( void ) memset( &( pcName ), 0, sizeof( pcName ) ); + eResult = eNDGetCacheEntry( pxIPAddress, &xMACAddress, &pxEndPoint ); + FreeRTOS_printf( ( "xCheckRequiresARPResolution: eResult %s with EP %s\n", ( eResult == eARPCacheMiss ) ? "Miss" : ( eResult == eARPCacheHit ) ? "Hit" : "Error", pcEndpointName( pxEndPoint, pcName, sizeof pcName ) ) ); + + if( eResult == eARPCacheMiss ) + { + NetworkBufferDescriptor_t * pxTempBuffer; + size_t uxNeededSize; + + uxNeededSize = sizeof( ICMPPacket_IPv6_t ); + pxTempBuffer = pxGetNetworkBufferWithDescriptor( BUFFER_FROM_WHERE_CALL( 199 ) uxNeededSize, 0U ); + + if( pxTempBuffer != NULL ) + { + pxTempBuffer->pxEndPoint = pxNetworkBuffer->pxEndPoint; + pxTempBuffer->pxInterface = pxNetworkBuffer->pxInterface; + vNDSendNeighbourSolicitation( pxTempBuffer, pxIPAddress ); + } - return xNeedsNDResolution; -} + xNeedsNDResolution = pdTRUE; + } + } + } + + return xNeedsNDResolution; + } /*-----------------------------------------------------------*/ #endif /* ipconfigUSE_IPv6 */ diff --git a/source/FreeRTOS_Routing.c b/source/FreeRTOS_Routing.c index 91de0642c..63009d835 100644 --- a/source/FreeRTOS_Routing.c +++ b/source/FreeRTOS_Routing.c @@ -1562,14 +1562,14 @@ BaseType_t xCheckRequiresResolution( const NetworkBufferDescriptor_t * pxNetwork { #if ( ipconfigUSE_IPv4 != 0 ) case ipSIZE_OF_IPv4_HEADER: - xNeedsResolution = xCheckRequiresARPResolution( pxNetworkBuffer ); - break; + xNeedsResolution = xCheckRequiresARPResolution( pxNetworkBuffer ); + break; #endif /* ( ipconfigUSE_IPv4 != 0 ) */ #if ( ipconfigUSE_IPv6 != 0 ) case ipSIZE_OF_IPv6_HEADER: - xNeedsResolution = xCheckRequiresNDResolution( pxNetworkBuffer ); - break; + xNeedsResolution = xCheckRequiresNDResolution( pxNetworkBuffer ); + break; #endif /* ( ipconfigUSE_IPv6 != 0 ) */ default: diff --git a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c index 6d0a353db..1e654525b 100644 --- a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c +++ b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c @@ -2102,4 +2102,4 @@ void test_xCheckRequiresNDResolution_Miss( void ) xResult = xCheckRequiresNDResolution( pxNetworkBuffer ); TEST_ASSERT_EQUAL( pdTRUE, xResult ); -} \ No newline at end of file +} From aa863548ef2e68d1e0c9c44bcf76b6a553857cce Mon Sep 17 00:00:00 2001 From: Holden Date: Wed, 20 Mar 2024 12:32:13 -0400 Subject: [PATCH 03/25] Fully separate ARP & ND --- source/FreeRTOS_ARP.c | 23 ++-- source/FreeRTOS_DHCP.c | 1 - source/FreeRTOS_DHCPv6.c | 11 +- source/FreeRTOS_ICMP.c | 1 - source/FreeRTOS_IP.c | 77 ++++++------- source/FreeRTOS_IP_Timers.c | 9 +- source/FreeRTOS_IP_Utils.c | 16 +-- source/FreeRTOS_ND.c | 101 ++++++++++-------- source/FreeRTOS_RA.c | 3 +- source/FreeRTOS_TCP_IP.c | 3 +- source/FreeRTOS_TCP_IP_IPv4.c | 1 - source/FreeRTOS_TCP_IP_IPv6.c | 1 - source/FreeRTOS_TCP_Reception.c | 1 - source/FreeRTOS_TCP_State_Handling.c | 1 - source/FreeRTOS_TCP_State_Handling_IPv4.c | 1 - source/FreeRTOS_TCP_State_Handling_IPv6.c | 1 - source/FreeRTOS_TCP_Transmission.c | 17 ++- source/FreeRTOS_TCP_Transmission_IPv4.c | 8 +- source/FreeRTOS_TCP_Transmission_IPv6.c | 19 ++-- source/FreeRTOS_UDP_IP.c | 12 +-- source/FreeRTOS_UDP_IPv4.c | 6 +- source/FreeRTOS_UDP_IPv6.c | 33 +++--- source/include/FreeRTOSIPConfigDefaults.h | 16 +++ source/include/FreeRTOS_ARP.h | 32 +++--- source/include/FreeRTOS_DNS_Cache.h | 2 +- source/include/FreeRTOS_ICMP.h | 1 - source/include/FreeRTOS_IP.h | 10 +- source/include/FreeRTOS_IP_Private.h | 22 +--- source/include/FreeRTOS_IP_Timers.h | 41 +++++-- source/include/FreeRTOS_IPv4.h | 6 -- source/include/FreeRTOS_IPv6.h | 2 - source/include/FreeRTOS_ND.h | 11 +- source/include/FreeRTOS_Routing.h | 7 ++ source/include/FreeRTOS_TCP_Transmission.h | 2 +- source/include/FreeRTOS_UDP_IP.h | 19 +++- source/include/IPTraceMacroDefaults.h | 19 ++++ .../unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c | 2 +- tools/tcp_utilities/plus_tcp_demo_cli.c | 2 +- 38 files changed, 293 insertions(+), 247 deletions(-) diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index 34282110d..c894bc5f1 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -54,7 +54,6 @@ #include "NetworkBufferManagement.h" #include "NetworkInterface.h" #include "FreeRTOS_Routing.h" -#include "FreeRTOS_ND.h" #if ( ipconfigUSE_IPv4 != 0 ) @@ -95,11 +94,11 @@ /* * Lookup an MAC address in the ARP cache from the IP address. */ - static eARPLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, + static eResolutionLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ); - static eARPLookupResult_t eARPGetCacheEntryGateWay( uint32_t * pulIPAddress, + static eResolutionLookupResult_t eARPGetCacheEntryGateWay( uint32_t * pulIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ); @@ -822,12 +821,12 @@ * * @return Either eARPCacheMiss or eARPCacheHit. */ - eARPLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, + eResolutionLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, uint32_t * pulIPAddress, struct xNetworkInterface ** ppxInterface ) { BaseType_t x; - eARPLookupResult_t eReturn = eARPCacheMiss; + eResolutionLookupResult_t eReturn = eResolutionCacheMiss; configASSERT( pxMACAddress != NULL ); configASSERT( pulIPAddress != NULL ); @@ -878,11 +877,11 @@ * addressing needs a gateway but there isn't a gateway defined) then return * eCantSendPacket. */ - eARPLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, + eResolutionLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ) { - eARPLookupResult_t eReturn; + eResolutionLookupResult_t eReturn; uint32_t ulAddressToLookup; NetworkEndPoint_t * pxEndPoint = NULL; @@ -945,11 +944,11 @@ * stored to the buffer provided. * @param[out] ppxEndPoint The end-point of the gateway will be copy to the pointee. */ - static eARPLookupResult_t eARPGetCacheEntryGateWay( uint32_t * pulIPAddress, + static eResolutionLookupResult_t eARPGetCacheEntryGateWay( uint32_t * pulIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ) { - eARPLookupResult_t eReturn = eARPCacheMiss; + eResolutionLookupResult_t eReturn = eARPCacheMiss; uint32_t ulAddressToLookup = *( pulIPAddress ); NetworkEndPoint_t * pxEndPoint; uint32_t ulOriginal = *pulIPAddress; @@ -1040,12 +1039,12 @@ * @return When the IP-address is found: eARPCacheHit, when not found: eARPCacheMiss, * and when waiting for a ARP reply: eCantSendPacket. */ - static eARPLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, + static eResolutionLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ) { BaseType_t x; - eARPLookupResult_t eReturn = eARPCacheMiss; + eResolutionLookupResult_t eReturn = eARPCacheMiss; /* Loop through each entry in the ARP cache. */ for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) @@ -1275,7 +1274,7 @@ BaseType_t xResult = -pdFREERTOS_ERRNO_EADDRNOTAVAIL; TimeOut_t xTimeOut; MACAddress_t xMACAddress; - eARPLookupResult_t xLookupResult; + eResolutionLookupResult_t xLookupResult; NetworkEndPoint_t * pxEndPoint; size_t uxSendCount = ipconfigMAX_ARP_RETRANSMISSIONS; uint32_t ulIPAddressCopy = ulIPAddress; diff --git a/source/FreeRTOS_DHCP.c b/source/FreeRTOS_DHCP.c index e44c7644b..1f8ff33f8 100644 --- a/source/FreeRTOS_DHCP.c +++ b/source/FreeRTOS_DHCP.c @@ -817,7 +817,6 @@ /* DHCP failed, the default configured IP-address will be used. Now * call vIPNetworkUpCalls() to send the network-up event and start the ARP * timer. */ - vIPNetworkUpCalls( pxEndPoint ); /* Close socket to ensure packets don't queue on it. */ diff --git a/source/FreeRTOS_DHCPv6.c b/source/FreeRTOS_DHCPv6.c index f08e9852c..4b212ecbd 100644 --- a/source/FreeRTOS_DHCPv6.c +++ b/source/FreeRTOS_DHCPv6.c @@ -50,17 +50,12 @@ #include "FreeRTOS_DHCPv6.h" #include "FreeRTOS_DNS.h" #include "NetworkBufferManagement.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_Sockets.h" #include "FreeRTOS_IP_Private.h" #include "FreeRTOS_IP_Timers.h" - #include "FreeRTOS_BitConfig.h" - #include "FreeRTOS_Routing.h" -#include "FreeRTOS_ND.h" - /* Timer parameters */ #ifndef dhcpINITIAL_DHCP_TX_PERIOD /** @brief DHCP timer period in ms */ @@ -531,7 +526,7 @@ static void vDHCPv6ProcessEndPoint_HandleReply( NetworkEndPoint_t * pxEndPoint, /* DHCP failed, the default configured IP-address will be used * Now call vIPNetworkUpCalls() to send the network-up event and - * start the ARP timer. */ + * start the Address Resolution timer. */ vIPNetworkUpCalls( pxEndPoint ); } /*-----------------------------------------------------------*/ @@ -823,8 +818,8 @@ static void vDHCPv6ProcessEndPoint( BaseType_t xReset, prvCloseDHCPv6Socket( pxEndPoint ); /* DHCP failed, the default configured IP-address will be used. Now - * call vIPNetworkUpCalls() to send the network-up event and start the ARP - * timer. */ + * call vIPNetworkUpCalls() to send the network-up event and start the + * Address Resolution timer. */ vIPNetworkUpCalls( pxEndPoint ); } } diff --git a/source/FreeRTOS_ICMP.c b/source/FreeRTOS_ICMP.c index 75e51bb79..062922d5d 100644 --- a/source/FreeRTOS_ICMP.c +++ b/source/FreeRTOS_ICMP.c @@ -46,7 +46,6 @@ #include "FreeRTOS_IP_Private.h" #include "FreeRTOS_ICMP.h" #include "FreeRTOS_Sockets.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_UDP_IP.h" #include "FreeRTOS_DHCP.h" #include "NetworkInterface.h" diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 015692369..519a950ae 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -49,6 +49,7 @@ #include "FreeRTOS_Sockets.h" #include "FreeRTOS_IP_Private.h" #include "FreeRTOS_ARP.h" +#include "FreeRTOS_ND.h" #include "FreeRTOS_UDP_IP.h" #include "FreeRTOS_DHCP.h" #if ( ipconfigUSE_DHCPv6 == 1 ) @@ -58,7 +59,6 @@ #include "NetworkBufferManagement.h" #include "FreeRTOS_DNS.h" #include "FreeRTOS_Routing.h" -#include "FreeRTOS_ND.h" /** @brief Time delay between repeated attempts to initialise the network hardware. */ #ifndef ipINITIALISATION_RETRY_DELAY @@ -68,9 +68,9 @@ #include "tcp_mem_stats.h" #endif -/** @brief Maximum time to wait for an ARP resolution while holding a packet. */ -#ifndef ipARP_RESOLUTION_MAX_DELAY - #define ipARP_RESOLUTION_MAX_DELAY ( pdMS_TO_TICKS( 2000U ) ) +/** @brief Maximum time to wait for a resolution while holding a packet. */ +#ifndef ipADDR_RES_MAX_DELAY + #define ipADDR_RES_MAX_DELAY ( pdMS_TO_TICKS( 2000U ) ) #endif #ifndef iptraceIP_TASK_STARTING @@ -82,13 +82,13 @@ #define ipTCP_TIMER_PERIOD_MS ( 1000U ) #endif -/** @brief Defines how often the ARP timer callback function is executed. The time is +/** @brief Defines how often the resolution timer callback function is executed. The time is * shorter in the Windows simulator as simulated time is not real time. */ -#ifndef ipARP_TIMER_PERIOD_MS +#ifndef ipADDR_RES_TIMER_PERIOD_MS #ifdef _WINDOWS_ - #define ipARP_TIMER_PERIOD_MS ( 500U ) /* For windows simulator builds. */ + #define ipADDR_RES_TIMER_PERIOD_MS ( 500U ) /* For windows simulator builds. */ #else - #define ipARP_TIMER_PERIOD_MS ( 10000U ) + #define ipADDR_RES_TIMER_PERIOD_MS ( 10000U ) #endif #endif @@ -121,8 +121,8 @@ static void prvIPTask_CheckPendingEvents( void ); /*-----------------------------------------------------------*/ -/** @brief The pointer to buffer with packet waiting for ARP resolution. */ -NetworkBufferDescriptor_t * pxARPWaitingNetworkBuffer = NULL; +/** @brief The pointer to buffer with packet waiting for resolution. */ +NetworkBufferDescriptor_t * pxResolutionWaitingNetworkBuffer = NULL; /*-----------------------------------------------------------*/ @@ -253,7 +253,7 @@ static void prvProcessIPEventsAndTimers( void ) ipconfigWATCHDOG_TIMER(); - /* Check the ARP, DHCP and TCP timers to see if there is any periodic + /* Check the Resolution, DHCP and TCP timers to see if there is any periodic * or timeout processing to perform. */ vCheckNetworkTimers(); @@ -308,8 +308,8 @@ static void prvProcessIPEventsAndTimers( void ) prvForwardTxPacket( ( ( NetworkBufferDescriptor_t * ) xReceivedEvent.pvData ), pdTRUE ); break; - case eARPTimerEvent: - /* The ARP timer has expired, process the ARP cache. */ + case eResolutionTimerEvent: + /* The Resolution timer has expired, process the cache. */ #if ( ipconfigUSE_IPv4 != 0 ) vARPAgeCache(); #endif /* ( ipconfigUSE_IPv4 != 0 ) */ @@ -508,8 +508,8 @@ static void prvIPTask_Initialise( void ) } #endif - /* Mark the timer as inactive since we are not waiting on any ARP resolution as of now. */ - vIPSetARPResolutionTimerEnableState( pdFALSE ); + /* Mark the timer as inactive since we are not waiting on any resolution as of now. */ + vIPSetResolutionTimerEnableState( pdFALSE ); #if ( ( ipconfigDNS_USE_CALLBACKS != 0 ) && ( ipconfigUSE_DNS != 0 ) ) { @@ -655,7 +655,7 @@ void vIPNetworkUpCalls( struct xNetworkEndPoint * pxEndPoint ) #endif /* ipconfigDNS_USE_CALLBACKS != 0 */ /* Set remaining time to 0 so it will become active immediately. */ - vARPTimerReload( pdMS_TO_TICKS( ipARP_TIMER_PERIOD_MS ) ); + vResolutionTimerReload( pdMS_TO_TICKS( ipADDR_RES_TIMER_PERIOD_MS ) ); } /*-----------------------------------------------------------*/ @@ -1646,7 +1646,7 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor case eReturnEthernetFrame: /* The Ethernet frame will have been updated (maybe it was - * an ARP request or a PING request?) and should be sent back to + * a resolution request or a PING request?) and should be sent back to * its source. */ vReturnEthernetFrame( pxNetworkBuffer, pdTRUE ); @@ -1660,21 +1660,21 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor * yet. */ break; - case eWaitingARPResolution: + case eWaitingResolution: - if( pxARPWaitingNetworkBuffer == NULL ) + if( pxResolutionWaitingNetworkBuffer == NULL ) { - pxARPWaitingNetworkBuffer = pxNetworkBuffer; - vIPTimerStartARPResolution( ipARP_RESOLUTION_MAX_DELAY ); + pxResolutionWaitingNetworkBuffer = pxNetworkBuffer; + vIPTimerStartResolution( ipADDR_RES_MAX_DELAY ); - iptraceDELAYED_ARP_REQUEST_STARTED(); + iptraceDELAYED_RESOLUTION_REQUEST_STARTED(); } else { - /* We are already waiting on one ARP resolution. This frame will be dropped. */ + /* We are already waiting on one resolution. This frame will be dropped. */ vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - iptraceDELAYED_ARP_BUFFER_FULL(); + iptraceDELAYED_RESOLUTION_BUFFER_FULL(); } break; @@ -1703,7 +1703,7 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor static eFrameProcessingResult_t prvProcessUDPPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer ) { eFrameProcessingResult_t eReturn = eReleaseBuffer; - BaseType_t xIsWaitingARPResolution = pdFALSE; + BaseType_t xIsWaitingResolution = pdFALSE; /* The IP packet contained a UDP frame. */ /* MISRA Ref 11.3.1 [Misaligned access] */ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ @@ -1775,16 +1775,16 @@ static eFrameProcessingResult_t prvProcessUDPPacket( NetworkBufferDescriptor_t * * implementation. */ if( xProcessReceivedUDPPacket( pxNetworkBuffer, pxUDPHeader->usDestinationPort, - &( xIsWaitingARPResolution ) ) == pdPASS ) + &( xIsWaitingResolution ) ) == pdPASS ) { eReturn = eFrameConsumed; } else { - /* Is this packet to be set aside for ARP resolution. */ - if( xIsWaitingARPResolution == pdTRUE ) + /* Is this packet to be set aside for resolution. */ + if( xIsWaitingResolution == pdTRUE ) { - eReturn = eWaitingARPResolution; + eReturn = eWaitingResolution; } } } @@ -1942,21 +1942,21 @@ static eFrameProcessingResult_t prvProcessIPPacket( const IPPacket_t * pxIPPacke /* coverity[const] */ if( eReturn != eReleaseBuffer ) { - /* Add the IP and MAC addresses to the ARP table if they are not + /* Add the IP and MAC addresses to the cache if they are not * already there - otherwise refresh the age of the existing * entry. */ if( ucProtocol != ( uint8_t ) ipPROTOCOL_UDP ) { if( xCheckRequiresResolution( pxNetworkBuffer ) == pdTRUE ) { - eReturn = eWaitingARPResolution; + eReturn = eWaitingResolution; } else { - /* Refresh the ARP cache with the IP/MAC-address of the received + /* Refresh the cache with the IP/MAC-address of the received * packet. For UDP packets, this will be done later in * xProcessReceivedUDPPacket(), as soon as it's know that the message - * will be handled. This will prevent the ARP cache getting + * will be handled. This will prevent the cache getting * overwritten with the IP address of useless broadcast packets. */ /* Case default is never toggled because eReturn is not eProcessBuffer in previous step. */ switch( pxIPPacket->xEthernetHeader.usFrameType ) /* LCOV_EXCL_BR_LINE */ @@ -1982,7 +1982,8 @@ static eFrameProcessingResult_t prvProcessIPPacket( const IPPacket_t * pxIPPacke } } - if( eReturn != eWaitingARPResolution ) /*TODO eReturn != eReleaseBuffer */ + /* TODO: eReturn != eReleaseBuffer */ + if( eReturn != eWaitingResolution ) { switch( ucProtocol ) { @@ -2103,7 +2104,7 @@ void vReturnEthernetFrame( NetworkBufferDescriptor_t * pxNetworkBuffer, #if ( ipconfigUSE_IPv4 != 0 ) MACAddress_t xMACAddress; - eARPLookupResult_t eResult; + eResolutionLookupResult_t eResult; uint32_t ulDestinationIPAddress = 0U; #endif /* ( ipconfigUSE_IPv4 != 0 ) */ @@ -2151,7 +2152,7 @@ void vReturnEthernetFrame( NetworkBufferDescriptor_t * pxNetworkBuffer, * address. */ eResult = eARPGetCacheEntry( &ulDestinationIPAddress, &xMACAddress, &( pxNetworkBuffer->pxEndPoint ) ); - if( eResult == eARPCacheHit ) + if( eResult == eResolutionCacheHit ) { /* Best case scenario - an address is found, use it. */ pvCopySource = &xMACAddress; @@ -2167,7 +2168,7 @@ void vReturnEthernetFrame( NetworkBufferDescriptor_t * pxNetworkBuffer, case ipIPv6_FRAME_TYPE: case ipARP_FRAME_TYPE: default: - /* In case of ARP frame, just swap the source and destination MAC addresses. */ + /* Just swap the source and destination MAC addresses. */ pvCopySource = &( pxIPPacket->xEthernetHeader.xSourceAddress ); break; } @@ -2194,7 +2195,7 @@ void vReturnEthernetFrame( NetworkBufferDescriptor_t * pxNetworkBuffer, { IPStackEvent_t xSendEvent; - /* Send a message to the IP-task to send this ARP packet. */ + /* Send a message to the IP-task to send this packet. */ xSendEvent.eEventType = eNetworkTxEvent; xSendEvent.pvData = pxNetworkBuffer; diff --git a/source/FreeRTOS_IP_Timers.c b/source/FreeRTOS_IP_Timers.c index 0e2259ac5..d5825d25d 100644 --- a/source/FreeRTOS_IP_Timers.c +++ b/source/FreeRTOS_IP_Timers.c @@ -47,8 +47,6 @@ #include "FreeRTOS_IP_Utils.h" #include "FreeRTOS_Sockets.h" #include "FreeRTOS_IP_Private.h" -#include "FreeRTOS_ARP.h" -#include "FreeRTOS_ND.h" #include "FreeRTOS_UDP_IP.h" #include "FreeRTOS_DHCP.h" #include "NetworkInterface.h" @@ -101,6 +99,13 @@ static IPTimer_t xARPResolutionTimer; /** @brief ARP timer, to check its table entries. */ static IPTimer_t xARPTimer; +/** @brief Timer to limit the maximum time a packet should be stored while + * awaiting an ND resolution. */ +static IPTimer_t xNDResolutionTimer; + +/** @brief ND timer, to check its table entries. */ +static IPTimer_t xNDTimer; + #if ( ipconfigUSE_TCP != 0 ) /** @brief TCP timer, to check for timeouts, resends. */ static IPTimer_t xTCPTimer; diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index b5cdada33..d90fd2ef4 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -48,13 +48,13 @@ #include "FreeRTOS_Sockets.h" #include "FreeRTOS_IP_Private.h" #include "FreeRTOS_ARP.h" +#include "FreeRTOS_ND.h" #include "FreeRTOS_UDP_IP.h" #include "FreeRTOS_DHCP.h" #include "NetworkInterface.h" #include "NetworkBufferManagement.h" #include "FreeRTOS_DNS.h" #include "FreeRTOS_Routing.h" -#include "FreeRTOS_ND.h" /*-----------------------------------------------------------*/ /* Used to ensure the structure packing is having the desired effect. The @@ -822,8 +822,8 @@ void prvProcessNetworkDownEvent( struct xNetworkInterface * pxInterface ) configASSERT( pxInterface != NULL ); configASSERT( pxInterface->pfInitialise != NULL ); - /* Stop the ARP timer while there is no network. */ - vIPSetARPTimerEnableState( pdFALSE ); + /* Stop the Address Resolution timer while there is no network. */ + vIPSetAddrResTimerEnableState( pdFALSE ); /* The first network down event is generated by the IP stack itself to * initialise the network hardware, so do not call the network down event @@ -857,13 +857,17 @@ void prvProcessNetworkDownEvent( struct xNetworkInterface * pxInterface ) } #endif /* ipconfigUSE_NETWORK_EVENT_HOOK */ - /* Per the ARP Cache Validation section of https://tools.ietf.org/html/rfc1122 - * treat network down as a "delivery problem" and flush the ARP cache for this - * interface. */ #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + /* Per the ARP Cache Validation section of https://tools.ietf.org/html/rfc1122 + * treat network down as a "delivery problem" and flush the ARP cache for this + * interface. */ FreeRTOS_ClearARP( pxEndPoint ); #endif + #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + FreeRTOS_ClearND( pxEndPoint ); + #endif + #if ( ipconfigUSE_DHCP == 1 ) if( END_POINT_USES_DHCP( pxEndPoint ) ) { diff --git a/source/FreeRTOS_ND.c b/source/FreeRTOS_ND.c index 8974db514..cc3d8acba 100644 --- a/source/FreeRTOS_ND.c +++ b/source/FreeRTOS_ND.c @@ -41,7 +41,6 @@ #include "FreeRTOS_IP.h" #include "FreeRTOS_Sockets.h" #include "FreeRTOS_IP_Private.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_UDP_IP.h" #include "FreeRTOS_Routing.h" #include "FreeRTOS_ND.h" @@ -82,12 +81,12 @@ static const uint8_t pcLOCAL_ALL_NODES_MULTICAST_MAC[ ipMAC_ADDRESS_LENGTH_BYTES ] = { 0x33, 0x33, 0x00, 0x00, 0x00, 0x01 }; /** @brief See if the MAC-address can be resolved because it is a multi-cast address. */ - static eARPLookupResult_t prvMACResolve( const IPv6_Address_t * pxAddressToLookup, + static eResolutionLookupResult_t prvMACResolve( const IPv6_Address_t * pxAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ); /** @brief Lookup an MAC address in the ND cache from the IP address. */ - static eARPLookupResult_t prvNDCacheLookup( const IPv6_Address_t * pxAddressToLookup, + static eResolutionLookupResult_t prvNDCacheLookup( const IPv6_Address_t * pxAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ); @@ -144,13 +143,13 @@ * @param[out] pxMACAddress The resulting MAC-address is stored here. * @param[out] ppxEndPoint A pointer to an end-point pointer where the end-point will be stored. * - * @return An enum, either eARPCacheHit or eARPCacheMiss. + * @return An enum, either eAddrResCacheHit or eAddrResCacheMiss. */ - static eARPLookupResult_t prvMACResolve( const IPv6_Address_t * pxAddressToLookup, + static eAddrResLookupResult_t prvMACResolve( const IPv6_Address_t * pxAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ) { - eARPLookupResult_t eReturn; + eAddrResLookupResult_t eReturn; /* Mostly used multi-cast address is ff02::. */ if( xIsIPv6AllowedMulticast( pxAddressToLookup ) != pdFALSE ) @@ -162,12 +161,12 @@ *ppxEndPoint = pxFindLocalEndpoint(); } - eReturn = eARPCacheHit; + eReturn = eAddrResCacheHit; } else { /* Not a multicast IP address. */ - eReturn = eARPCacheMiss; + eReturn = eAddrResCacheMiss; } return eReturn; @@ -182,30 +181,30 @@ * @param[out] pxMACAddress The MAC-address found. * @param[out] ppxEndPoint A pointer to a pointer to an end-point, where the end-point will be stored. * - * @return An enum which says whether the address was found: eARPCacheHit or eARPCacheMiss. + * @return An enum which says whether the address was found: eAddrResCacheHit or eAddrResCacheMiss. */ - eARPLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, + eAddrResLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ) { - eARPLookupResult_t eReturn; + eAddrResLookupResult_t eReturn; NetworkEndPoint_t * pxEndPoint; /* Multi-cast addresses can be resolved immediately. */ eReturn = prvMACResolve( pxIPAddress, pxMACAddress, ppxEndPoint ); - if( eReturn == eARPCacheMiss ) + if( eReturn == eAddrResCacheMiss ) { /* See if the IP-address has an entry in the cache. */ eReturn = prvNDCacheLookup( pxIPAddress, pxMACAddress, ppxEndPoint ); } - if( eReturn == eARPCacheMiss ) + if( eReturn == eAddrResCacheMiss ) { FreeRTOS_printf( ( "eNDGetCacheEntry: lookup %pip miss\n", ( void * ) pxIPAddress->ucBytes ) ); } - if( eReturn == eARPCacheMiss ) + if( eReturn == eAddrResCacheMiss ) { IPv6_Type_t eIPType = xIPv6_GetIPType( pxIPAddress ); @@ -240,7 +239,7 @@ } FreeRTOS_printf( ( "eNDGetCacheEntry: LinkLocal %pip \"%s\"\n", ( void * ) pxIPAddress->ucBytes, - ( eReturn == eARPCacheHit ) ? "hit" : "miss" ) ); + ( eReturn == eAddrResCacheHit ) ? "hit" : "miss" ) ); } else { @@ -285,7 +284,7 @@ { BaseType_t x; BaseType_t xFreeEntry = -1, xEntryFound = -1; - uint16_t xOldestValue = ipconfigMAX_ARP_AGE + 1; + uint16_t xOldestValue = ipconfigMAX_ND_AGE + 1; BaseType_t xOldestEntry = 0; /* For each entry in the ND cache table. */ @@ -308,10 +307,10 @@ /* Entry is valid but the IP-address doesn't match. */ /* Keep track of the oldest entry in case we need to overwrite it. The problem we are trying to avoid is - * that there may be a queued packet in pxARPWaitingNetworkBuffer and we may have just received the + * that there may be a queued packet in pxNDWaitingNetworkBuffer and we may have just received the * neighbor advertisement needed for that packet. If we don't store this network advertisement in cache, - * the parting of the frame from pxARPWaitingNetworkBuffer will cause the sending of neighbor solicitation - * and stores the frame in pxARPWaitingNetworkBuffer. This becomes a vicious circle with thousands of + * the parting of the frame from pxNDWaitingNetworkBuffer will cause the sending of neighbor solicitation + * and stores the frame in pxNDWaitingNetworkBuffer. This becomes a vicious circle with thousands of * neighbor solicitation/advertisement packets going back and forth because the ND cache is full. * Overwriting the oldest cache entry is not a fool-proof solution, but it's something. */ if( xNDCache[ x ].ucAge < xOldestValue ) @@ -343,7 +342,7 @@ /* Copy the MAC-address. */ ( void ) memcpy( xNDCache[ xEntryFound ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( MACAddress_t ) ); xNDCache[ xEntryFound ].pxEndPoint = pxEndPoint; - xNDCache[ xEntryFound ].ucAge = ( uint8_t ) ipconfigMAX_ARP_AGE; + xNDCache[ xEntryFound ].ucAge = ( uint8_t ) ipconfigMAX_ND_AGE; xNDCache[ xEntryFound ].ucValid = ( uint8_t ) pdTRUE; } /*-----------------------------------------------------------*/ @@ -417,11 +416,29 @@ /*-----------------------------------------------------------*/ /** - * @brief Clear the Neighbour Discovery cache. + * @brief A call to this function will clear the ND cache. + * @param[in] pxEndPoint only clean entries with this end-point, or when NULL, + * clear the entire ND cache. */ - void FreeRTOS_ClearND( void ) + void FreeRTOS_ClearND( const struct xNetworkEndPoint * pxEndPoint ) { ( void ) memset( xNDCache, 0, sizeof( xNDCache ) ); + if( pxEndPoint != NULL ) + { + BaseType_t x; + + for( x = 0; x < ipconfigND_CACHE_ENTRIES; x++ ) + { + if( xNDCache[ x ].pxEndPoint == pxEndPoint ) + { + ( void ) memset( &( xNDCache[ x ] ), 0, sizeof( NDCacheRow_t ) ); + } + } + } + else + { + ( void ) memset( xNDCache, 0, sizeof( xNDCache ) ); + } } /*-----------------------------------------------------------*/ @@ -432,14 +449,14 @@ * @param[out] pxMACAddress The resulting MAC-address will be stored here. * @param[out] ppxEndPoint A pointer to a pointer to an end-point, where the end-point will be stored. * - * @return An enum: either eARPCacheHit or eARPCacheMiss. + * @return An enum: either eAddrResCacheHit or eAddrResCacheMiss. */ - static eARPLookupResult_t prvNDCacheLookup( const IPv6_Address_t * pxAddressToLookup, + static eAddrResLookupResult_t prvNDCacheLookup( const IPv6_Address_t * pxAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ) { BaseType_t x; - eARPLookupResult_t eReturn = eARPCacheMiss; + eAddrResLookupResult_t eReturn = eAddrResCacheMiss; /* For each entry in the ND cache table. */ for( x = 0; x < ipconfigND_CACHE_ENTRIES; x++ ) @@ -451,7 +468,7 @@ else if( memcmp( xNDCache[ x ].xIPAddress.ucBytes, pxAddressToLookup->ucBytes, ipSIZE_OF_IPv6_ADDRESS ) == 0 ) { ( void ) memcpy( pxMACAddress->ucBytes, xNDCache[ x ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ); - eReturn = eARPCacheHit; + eReturn = eAddrResCacheHit; if( ppxEndPoint != NULL ) { @@ -475,7 +492,7 @@ } } - if( eReturn == eARPCacheMiss ) + if( eReturn == eAddrResCacheMiss ) { FreeRTOS_printf( ( "prvNDCacheLookup %pip Miss\n", ( void * ) pxAddressToLookup->ucBytes ) ); @@ -521,7 +538,7 @@ } } - FreeRTOS_printf( ( "Arp has %ld entries\n", xCount ) ); + FreeRTOS_printf( ( "ND has %ld entries\n", xCount ) ); } #endif /* ( ipconfigHAS_PRINTF != 0 ) || ( ipconfigHAS_DEBUG_PRINTF != 0 ) */ @@ -910,7 +927,7 @@ /*-----------------------------------------------------------*/ /** - * @brief When a neighbour advertisement has been received, check if 'pxARPWaitingNetworkBuffer' + * @brief When a neighbour advertisement has been received, check if 'pxNDWaitingNetworkBuffer' * was waiting for this new address look-up. If so, feed it to the IP-task as a new * incoming packet. */ @@ -919,7 +936,7 @@ /* 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] */ - const IPPacket_IPv6_t * pxIPPacket = ( ( IPPacket_IPv6_t * ) pxARPWaitingNetworkBuffer->pucEthernetBuffer ); + const IPPacket_IPv6_t * pxIPPacket = ( ( IPPacket_IPv6_t * ) pxNDWaitingNetworkBuffer->pucEthernetBuffer ); const IPHeader_IPv6_t * pxIPHeader = &( pxIPPacket->xIPHeader ); if( memcmp( pxIPv6Address->ucBytes, pxIPHeader->xSourceAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ) == 0 ) @@ -930,21 +947,21 @@ FreeRTOS_printf( ( "Waiting done\n" ) ); xEventMessage.eEventType = eNetworkRxEvent; - xEventMessage.pvData = ( void * ) pxARPWaitingNetworkBuffer; + xEventMessage.pvData = ( void * ) pxNDWaitingNetworkBuffer; if( xSendEventStructToIPTask( &xEventMessage, xDontBlock ) != pdPASS ) { /* Failed to send the message, so release the network buffer. */ - vReleaseNetworkBufferAndDescriptor( BUFFER_FROM_WHERE_CALL( 140 ) pxARPWaitingNetworkBuffer ); + vReleaseNetworkBufferAndDescriptor( BUFFER_FROM_WHERE_CALL( 140 ) pxNDWaitingNetworkBuffer ); } /* Clear the buffer. */ - pxARPWaitingNetworkBuffer = NULL; + pxNDWaitingNetworkBuffer = NULL; - /* Found an ARP resolution, disable ARP resolution timer. */ - vIPSetARPResolutionTimerEnableState( pdFALSE ); + /* Found an ND resolution, disable ND resolution timer. */ + vIPSetNDResolutionTimerEnableState( pdFALSE ); - iptrace_DELAYED_ARP_REQUEST_REPLIED(); + iptrace_DELAYED_ND_REQUEST_REPLIED(); } } /*-----------------------------------------------------------*/ @@ -1124,8 +1141,8 @@ vReceiveNA( pxNetworkBuffer ); #endif - if( ( pxARPWaitingNetworkBuffer != NULL ) && - ( uxIPHeaderSizePacket( pxARPWaitingNetworkBuffer ) == ipSIZE_OF_IPv6_HEADER ) ) + if( ( pxNDWaitingNetworkBuffer != NULL ) && + ( uxIPHeaderSizePacket( pxNDWaitingNetworkBuffer ) == ipSIZE_OF_IPv6_HEADER ) ) { prvCheckWaitingBuffer( &( pxICMPHeader_IPv6->xIPv6Address ) ); } @@ -1341,7 +1358,7 @@ ( ucNextHeader == ipPROTOCOL_UDP ) ) { IPv6_Type_t eType = xIPv6_GetIPType( ( const IPv6_Address_t * ) pxIPAddress ); - FreeRTOS_debug_printf( ( "xCheckRequiresARPResolution: %pip type %s\n", + FreeRTOS_debug_printf( ( "xCheckRequiresNDResolution: %pip type %s\n", ( void * ) pxIPAddress->ucBytes, ( eType == eIPv6_Global ) ? "Global" : ( eType == eIPv6_LinkLocal ) ? "LinkLocal" : @@ -1352,14 +1369,14 @@ { MACAddress_t xMACAddress; NetworkEndPoint_t * pxEndPoint; - eARPLookupResult_t eResult; + eAddrResLookupResult_t eResult; char pcName[ 80 ]; ( void ) memset( &( pcName ), 0, sizeof( pcName ) ); eResult = eNDGetCacheEntry( pxIPAddress, &xMACAddress, &pxEndPoint ); - FreeRTOS_printf( ( "xCheckRequiresARPResolution: eResult %s with EP %s\n", ( eResult == eARPCacheMiss ) ? "Miss" : ( eResult == eARPCacheHit ) ? "Hit" : "Error", pcEndpointName( pxEndPoint, pcName, sizeof pcName ) ) ); + FreeRTOS_printf( ( "xCheckRequiresNDResolution: eResult %s with EP %s\n", ( eResult == eAddrResCacheMiss ) ? "Miss" : ( eResult == eAddrResCacheHit ) ? "Hit" : "Error", pcEndpointName( pxEndPoint, pcName, sizeof pcName ) ) ); - if( eResult == eARPCacheMiss ) + if( eResult == eAddrResCacheMiss ) { NetworkBufferDescriptor_t * pxTempBuffer; size_t uxNeededSize; diff --git a/source/FreeRTOS_RA.c b/source/FreeRTOS_RA.c index 501bbdb4f..6fd0e9825 100644 --- a/source/FreeRTOS_RA.c +++ b/source/FreeRTOS_RA.c @@ -42,7 +42,6 @@ #include "FreeRTOS_Sockets.h" #include "FreeRTOS_IP_Private.h" #include "FreeRTOS_IP_Timers.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_UDP_IP.h" #include "FreeRTOS_Routing.h" #include "FreeRTOS_ND.h" @@ -509,7 +508,7 @@ } /* Now call vIPNetworkUpCalls() to send the network-up event and - * start the ARP timer. */ + * start the Resolution timer. */ vIPNetworkUpCalls( pxEndPoint ); } } diff --git a/source/FreeRTOS_TCP_IP.c b/source/FreeRTOS_TCP_IP.c index cfba8d04f..8a1352b80 100644 --- a/source/FreeRTOS_TCP_IP.c +++ b/source/FreeRTOS_TCP_IP.c @@ -54,7 +54,6 @@ #include "FreeRTOS_DHCP.h" #include "NetworkInterface.h" #include "NetworkBufferManagement.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_TCP_Reception.h" #include "FreeRTOS_TCP_Transmission.h" @@ -587,7 +586,7 @@ } else { - /* Still in the ARP phase: check every half second. */ + /* Still in the Resolution phase: check every half second. */ ulDelayMs = 500U; } diff --git a/source/FreeRTOS_TCP_IP_IPv4.c b/source/FreeRTOS_TCP_IP_IPv4.c index 9ccb72901..39552cc3c 100644 --- a/source/FreeRTOS_TCP_IP_IPv4.c +++ b/source/FreeRTOS_TCP_IP_IPv4.c @@ -53,7 +53,6 @@ #include "FreeRTOS_DHCP.h" #include "NetworkInterface.h" #include "NetworkBufferManagement.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_TCP_Reception.h" #include "FreeRTOS_TCP_Transmission.h" diff --git a/source/FreeRTOS_TCP_IP_IPv6.c b/source/FreeRTOS_TCP_IP_IPv6.c index f9b2dd75f..acb24fda1 100644 --- a/source/FreeRTOS_TCP_IP_IPv6.c +++ b/source/FreeRTOS_TCP_IP_IPv6.c @@ -53,7 +53,6 @@ #include "FreeRTOS_DHCP.h" #include "NetworkInterface.h" #include "NetworkBufferManagement.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_TCP_Reception.h" #include "FreeRTOS_TCP_Transmission.h" diff --git a/source/FreeRTOS_TCP_Reception.c b/source/FreeRTOS_TCP_Reception.c index 4dcd396b6..cad11e9a9 100644 --- a/source/FreeRTOS_TCP_Reception.c +++ b/source/FreeRTOS_TCP_Reception.c @@ -51,7 +51,6 @@ #include "FreeRTOS_DHCP.h" #include "NetworkInterface.h" #include "NetworkBufferManagement.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_TCP_Transmission.h" #include "FreeRTOS_TCP_Reception.h" diff --git a/source/FreeRTOS_TCP_State_Handling.c b/source/FreeRTOS_TCP_State_Handling.c index a897eae01..acb68ee59 100644 --- a/source/FreeRTOS_TCP_State_Handling.c +++ b/source/FreeRTOS_TCP_State_Handling.c @@ -51,7 +51,6 @@ #include "FreeRTOS_DHCP.h" #include "NetworkInterface.h" #include "NetworkBufferManagement.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_TCP_Reception.h" #include "FreeRTOS_TCP_Transmission.h" diff --git a/source/FreeRTOS_TCP_State_Handling_IPv4.c b/source/FreeRTOS_TCP_State_Handling_IPv4.c index 5bba5a771..60684b1a0 100644 --- a/source/FreeRTOS_TCP_State_Handling_IPv4.c +++ b/source/FreeRTOS_TCP_State_Handling_IPv4.c @@ -51,7 +51,6 @@ #include "FreeRTOS_DHCP.h" #include "NetworkInterface.h" #include "NetworkBufferManagement.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_TCP_Reception.h" #include "FreeRTOS_TCP_Transmission.h" diff --git a/source/FreeRTOS_TCP_State_Handling_IPv6.c b/source/FreeRTOS_TCP_State_Handling_IPv6.c index 60a168207..da02de362 100644 --- a/source/FreeRTOS_TCP_State_Handling_IPv6.c +++ b/source/FreeRTOS_TCP_State_Handling_IPv6.c @@ -51,7 +51,6 @@ #include "FreeRTOS_DHCP.h" #include "NetworkInterface.h" #include "NetworkBufferManagement.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_TCP_Reception.h" #include "FreeRTOS_TCP_Transmission.h" diff --git a/source/FreeRTOS_TCP_Transmission.c b/source/FreeRTOS_TCP_Transmission.c index bdfbe4e19..c0a1ff62b 100644 --- a/source/FreeRTOS_TCP_Transmission.c +++ b/source/FreeRTOS_TCP_Transmission.c @@ -52,7 +52,6 @@ #include "FreeRTOS_IP_Private.h" #include "NetworkInterface.h" #include "NetworkBufferManagement.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOSIPConfigDefaults.h" #include "FreeRTOS_TCP_IP.h" @@ -66,10 +65,7 @@ static BaseType_t prvTCPMakeSurePrepared( FreeRTOS_Socket_t * pxSocket ); -/* - * Let ARP look-up the MAC-address of the peer and initialise the first SYN - * packet. - */ +/* Resolve the MAC-address of the peer and initialise the first SYN packet. */ static BaseType_t prvTCPPrepareConnect( FreeRTOS_Socket_t * pxSocket ); #if ipconfigIS_ENABLED( ipconfigUSE_TCP_WIN ) @@ -92,7 +88,7 @@ { if( prvTCPPrepareConnect( pxSocket ) != pdTRUE ) { - /* The preparation of a connection ( ARP resolution ) is not yet ready. */ + /* The preparation of a connection ( resolution ) is not yet ready. */ xReturn = pdFALSE; } } @@ -477,8 +473,7 @@ /*-----------------------------------------------------------*/ /** - * @brief Let ARP look-up the MAC-address of the peer and initialise the first SYN - * packet. + * @brief Resolve the MAC-address of the peer and initialise the first SYN packet. * * @param[in] pxSocket The socket owning the TCP connection. The first packet shall * be created in this socket. @@ -487,9 +482,9 @@ * Else pdFALSE. * * @note Connecting sockets have a special state: eCONNECT_SYN. In this phase, - * the Ethernet address of the target will be found using ARP. In case the - * target IP address is not within the netmask, the hardware address of the - * gateway will be used. + * the Ethernet address of the target will be found through address resolution. + * In case the target IP address is not within the netmask, the hardware address + * of the gateway will be used. */ static BaseType_t prvTCPPrepareConnect( FreeRTOS_Socket_t * pxSocket ) { diff --git a/source/FreeRTOS_TCP_Transmission_IPv4.c b/source/FreeRTOS_TCP_Transmission_IPv4.c index 00dd3fb0b..826dd2e62 100644 --- a/source/FreeRTOS_TCP_Transmission_IPv4.c +++ b/source/FreeRTOS_TCP_Transmission_IPv4.c @@ -99,7 +99,7 @@ void prvTCPReturnPacket_IPV4( FreeRTOS_Socket_t * pxSocket, void * pvCopyDest = NULL; const size_t uxIPHeaderSize = ipSIZE_OF_IPv4_HEADER; uint32_t ulDestinationIPAddress; - eARPLookupResult_t eResult; + eResolutionLookupResult_t eResult; NetworkEndPoint_t * pxEndPoint = NULL; do @@ -235,7 +235,7 @@ void prvTCPReturnPacket_IPV4( FreeRTOS_Socket_t * pxSocket, eResult = eARPGetCacheEntry( &ulDestinationIPAddress, &xMACAddress, &pxEndPoint ); - if( eResult == eARPCacheHit ) + if( eResult == eResolutionCacheHit ) { pvCopySource = &xMACAddress; pxNetworkBuffer->pxEndPoint = pxEndPoint; @@ -352,10 +352,10 @@ BaseType_t prvTCPPrepareConnect_IPV4( FreeRTOS_Socket_t * pxSocket ) switch( eReturned ) { - case eARPCacheHit: /* An ARP table lookup found a valid entry. */ + case eResolutionCacheHit: /* An ARP table lookup found a valid entry. */ break; /* We can now prepare the SYN packet. */ - case eARPCacheMiss: /* An ARP table lookup did not find a valid entry. */ + case eResolutionCacheMiss: /* An ARP table lookup did not find a valid entry. */ case eCantSendPacket: /* There is no IP address, or an ARP is still in progress. */ default: /* Count the number of times it could not find the ARP address. */ diff --git a/source/FreeRTOS_TCP_Transmission_IPv6.c b/source/FreeRTOS_TCP_Transmission_IPv6.c index 03c2ef302..e11b4e0fd 100644 --- a/source/FreeRTOS_TCP_Transmission_IPv6.c +++ b/source/FreeRTOS_TCP_Transmission_IPv6.c @@ -52,7 +52,6 @@ #include "FreeRTOS_IP_Private.h" #include "NetworkInterface.h" #include "NetworkBufferManagement.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOSIPConfigDefaults.h" #include "FreeRTOS_ND.h" @@ -158,7 +157,7 @@ void prvTCPReturnPacket_IPV6( FreeRTOS_Socket_t * pxSocket, if( pxNetworkBuffer != NULL ) /* LCOV_EXCL_BR_LINE the 2nd branch will never be reached */ #endif { - eARPLookupResult_t eResult; + eResolutionLookupResult_t eResult; NetworkInterface_t * pxInterface; /* Map the Ethernet buffer onto a TCPPacket_t struct for easy access to the fields. */ @@ -235,7 +234,7 @@ void prvTCPReturnPacket_IPV6( FreeRTOS_Socket_t * pxSocket, eResult = eNDGetCacheEntry( &xDestinationIPAddress, &xMACAddress, &( pxNetworkBuffer->pxEndPoint ) ); - if( eResult == eARPCacheHit ) + if( eResult == eResolutionCacheHit ) { pvCopySource = &xMACAddress; } @@ -301,7 +300,7 @@ void prvTCPReturnPacket_IPV6( FreeRTOS_Socket_t * pxSocket, /*-----------------------------------------------------------*/ /** - * @brief Let ARP look-up the MAC-address of the peer and initialise the first SYN + * @brief Let ND look-up the MAC-address of the peer and initialise the first SYN * packet. * * @param[in] pxSocket The socket owning the TCP connection. The first packet shall @@ -311,7 +310,7 @@ void prvTCPReturnPacket_IPV6( FreeRTOS_Socket_t * pxSocket, * Else pdFALSE. * * @note Connecting sockets have a special state: eCONNECT_SYN. In this phase, - * the Ethernet address of the target will be found using ARP. In case the + * the Ethernet address of the target will be found using ND. In case the * target IP address is not within the netmask, the hardware address of the * gateway will be used. */ @@ -319,7 +318,7 @@ BaseType_t prvTCPPrepareConnect_IPV6( FreeRTOS_Socket_t * pxSocket ) { TCPPacket_IPv6_t * pxTCPPacket = NULL; IPHeader_IPv6_t * pxIPHeader = NULL; - eARPLookupResult_t eReturned; + eResolutionLookupResult_t eReturned; IP_Address_t xRemoteIP; MACAddress_t xEthAddress; BaseType_t xReturn = pdTRUE; @@ -352,13 +351,13 @@ BaseType_t prvTCPPrepareConnect_IPV6( FreeRTOS_Socket_t * pxSocket ) switch( eReturned ) { - case eARPCacheHit: /* An ARP table lookup found a valid entry. */ + case eResolutionCacheHit: /* An ND table lookup found a valid entry. */ break; /* We can now prepare the SYN packet. */ - case eARPCacheMiss: /* An ARP table lookup did not find a valid entry. */ - case eCantSendPacket: /* There is no IP address, or an ARP is still in progress. */ + case eResolutionCacheMiss: /* An ND table lookup did not find a valid entry. */ + case eCantSendPacket: /* There is no IP address, or an ND is still in progress. */ default: - /* Count the number of times it could not find the ARP address. */ + /* Count the number of times it could not find the ND address. */ pxSocket->u.xTCP.ucRepCount++; FreeRTOS_printf( ( "Looking up %pip with%s end-point\n", ( void * ) xRemoteIP.xIP_IPv6.ucBytes, ( pxEndPoint != NULL ) ? "" : "out" ) ); diff --git a/source/FreeRTOS_UDP_IP.c b/source/FreeRTOS_UDP_IP.c index 5dc967d8f..f53a11698 100644 --- a/source/FreeRTOS_UDP_IP.c +++ b/source/FreeRTOS_UDP_IP.c @@ -48,10 +48,8 @@ #include "FreeRTOS_Sockets.h" #include "FreeRTOS_IP_Private.h" #include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_DNS.h" #include "FreeRTOS_DHCP.h" -#include "FreeRTOS_ND.h" #include "FreeRTOS_IP_Utils.h" #include "NetworkInterface.h" #include "NetworkBufferManagement.h" @@ -88,7 +86,7 @@ UDPPacketHeader_t xDefaultPartUDPPacketHeader = /** * @brief Process the generated UDP packet and do other checks before sending the - * packet such as ARP cache check and address resolution. + * packet such as cache check and address resolution. * * @param[in] pxNetworkBuffer The network buffer carrying the packet. */ @@ -130,14 +128,14 @@ void vProcessGeneratedUDPPacket( NetworkBufferDescriptor_t * const pxNetworkBuff * * @param[in] pxNetworkBuffer The network buffer carrying the UDP packet. * @param[in] usPort The port number on which this packet was received. - * @param[out] pxIsWaitingForARPResolution If the packet is awaiting ARP resolution, + * @param[out] pxIsWaitingForResolution If the packet is awaiting resolution, * this pointer will be set to pdTRUE. pdFALSE otherwise. * * @return pdPASS in case the UDP packet could be processed. Else pdFAIL is returned. */ BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t * pxNetworkBuffer, uint16_t usPort, - BaseType_t * pxIsWaitingForARPResolution ) + BaseType_t * pxIsWaitingForResolution ) { /* Returning pdPASS means that the packet was consumed, released. */ BaseType_t xReturn = pdFAIL; @@ -158,13 +156,13 @@ BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t * pxNetworkBuffe #if ( ipconfigUSE_IPv4 != 0 ) case ipIPv4_FRAME_TYPE: xReturn = xProcessReceivedUDPPacket_IPv4( pxNetworkBuffer, - usPort, pxIsWaitingForARPResolution ); + usPort, pxIsWaitingForResolution ); break; #endif #if ( ipconfigUSE_IPv6 != 0 ) case ipIPv6_FRAME_TYPE: xReturn = xProcessReceivedUDPPacket_IPv6( pxNetworkBuffer, - usPort, pxIsWaitingForARPResolution ); + usPort, pxIsWaitingForResolution ); break; #endif default: diff --git a/source/FreeRTOS_UDP_IPv4.c b/source/FreeRTOS_UDP_IPv4.c index 28df47cdf..1fe05b69f 100644 --- a/source/FreeRTOS_UDP_IPv4.c +++ b/source/FreeRTOS_UDP_IPv4.c @@ -79,7 +79,7 @@ void vProcessGeneratedUDPPacket_IPv4( NetworkBufferDescriptor_t * const pxNetwor { UDPPacket_t * pxUDPPacket; IPHeader_t * pxIPHeader; - eARPLookupResult_t eReturned; + eResolutionLookupResult_t eReturned; uint32_t ulIPAddress = pxNetworkBuffer->xIPAddress.ulIP_IPv4; NetworkEndPoint_t * pxEndPoint = pxNetworkBuffer->pxEndPoint; size_t uxPayloadSize; @@ -115,7 +115,7 @@ void vProcessGeneratedUDPPacket_IPv4( NetworkBufferDescriptor_t * const pxNetwor if( eReturned != eCantSendPacket ) { - if( eReturned == eARPCacheHit ) + if( eReturned == eResolutionCacheHit ) { #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) uint8_t ucSocketOptions; @@ -246,7 +246,7 @@ void vProcessGeneratedUDPPacket_IPv4( NetworkBufferDescriptor_t * const pxNetwor } #endif /* if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) */ } - else if( eReturned == eARPCacheMiss ) + else if( eReturned == eResolutionCacheMiss ) { /* Add an entry to the ARP table with a null hardware address. * This allows the ARP timer to know that an ARP reply is diff --git a/source/FreeRTOS_UDP_IPv6.c b/source/FreeRTOS_UDP_IPv6.c index e2b4e2f99..d9cc61205 100644 --- a/source/FreeRTOS_UDP_IPv6.c +++ b/source/FreeRTOS_UDP_IPv6.c @@ -48,7 +48,6 @@ #include "FreeRTOS_Sockets.h" #include "FreeRTOS_IP_Private.h" #include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_DNS.h" #include "FreeRTOS_DHCP.h" #include "FreeRTOS_ND.h" @@ -118,18 +117,18 @@ static NetworkEndPoint_t * pxGetEndpoint( BaseType_t xIPType, /** * @brief This function is called in case the IP-address was not found, - * i.e. in the cache 'eARPCacheMiss' was returned. - * Either an ARP request or a Neighbour solicitation will be emitted. + * i.e. in the cache 'eResolutionCacheMiss' was returned. + * A Neighbour solicitation will be emitted. * * @param[in] pxNetworkBuffer The network buffer carrying the UDP or ICMP packet. * * @param[out] pxLostBuffer The pointee will be set to true in case the network packet got released * ( the ownership was taken ). */ -static eARPLookupResult_t prvStartLookup( NetworkBufferDescriptor_t * const pxNetworkBuffer, +static eResolutionLookupResult_t prvStartLookup( NetworkBufferDescriptor_t * const pxNetworkBuffer, BaseType_t * pxLostBuffer ) { - eARPLookupResult_t eReturned = eARPCacheMiss; + eResolutionLookupResult_t eReturned = eResolutionCacheMiss; FreeRTOS_printf( ( "Looking up %pip with%s end-point\n", ( void * ) pxNetworkBuffer->xIPAddress.xIP_IPv6.ucBytes, @@ -158,7 +157,7 @@ static eARPLookupResult_t prvStartLookup( NetworkBufferDescriptor_t * const pxNe /** * @brief Process the generated UDP packet and do other checks before sending the - * packet such as ARP cache check and address resolution. + * packet such as ND cache check and address resolution. * * @param[in] pxNetworkBuffer The network buffer carrying the packet. */ @@ -166,7 +165,7 @@ void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetwor { UDPPacket_IPv6_t * pxUDPPacket_IPv6; IPHeader_IPv6_t * pxIPHeader_IPv6; - eARPLookupResult_t eReturned; + eResolutionLookupResult_t eReturned; size_t uxPayloadSize; /* memcpy() helper variables for MISRA Rule 21.15 compliance*/ NetworkInterface_t * pxInterface = NULL; @@ -205,7 +204,7 @@ void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetwor if( eReturned != eCantSendPacket ) { - if( eReturned == eARPCacheHit ) + if( eReturned == eResolutionCacheHit ) { #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) uint8_t ucSocketOptions; @@ -302,7 +301,7 @@ void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetwor } #endif /* if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) */ } - else if( eReturned == eARPCacheMiss ) + else if( eReturned == eResolutionCacheMiss ) { if( pxEndPoint != NULL ) { @@ -313,7 +312,7 @@ void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetwor } else { - /* The lookup indicated that an ARP request has already been + /* The lookup indicated that an ND Solicitation has already been * sent out for the queried IP address. */ eReturned = eCantSendPacket; } @@ -321,7 +320,7 @@ void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetwor if( xLostBuffer == pdTRUE ) { - /* An ND solicitation or ARP request has been sent. */ + /* An ND solicitation has been sent. */ } else if( eReturned != eCantSendPacket ) { @@ -377,14 +376,14 @@ void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetwor * * @param[in] pxNetworkBuffer The network buffer carrying the UDP packet. * @param[in] usPort The port number on which this packet was received. - * @param[out] pxIsWaitingForARPResolution If the packet is awaiting ARP resolution, + * @param[out] pxIsWaitingForNDResolution If the packet is awaiting ND resolution, * this pointer will be set to pdTRUE. pdFALSE otherwise. * * @return pdPASS in case the UDP packet could be processed. Else pdFAIL is returned. */ BaseType_t xProcessReceivedUDPPacket_IPv6( NetworkBufferDescriptor_t * pxNetworkBuffer, uint16_t usPort, - BaseType_t * pxIsWaitingForARPResolution ) + BaseType_t * pxIsWaitingForNDResolution ) { /* Returning pdPASS means that the packet was consumed, released. */ BaseType_t xReturn = pdPASS; @@ -394,7 +393,7 @@ BaseType_t xProcessReceivedUDPPacket_IPv6( NetworkBufferDescriptor_t * pxNetwork configASSERT( pxNetworkBuffer != NULL ); configASSERT( pxNetworkBuffer->pucEthernetBuffer != NULL ); - /* When refreshing the ARP/ND cache with received UDP packets we must be + /* When refreshing the ND cache with received UDP packets we must be * careful; hundreds of broadcast messages may pass and if we're not * handling them, no use to fill the cache with those IP addresses. */ @@ -406,7 +405,7 @@ BaseType_t xProcessReceivedUDPPacket_IPv6( NetworkBufferDescriptor_t * pxNetwork /* Caller must check for minimum packet size. */ pxSocket = pxUDPSocketLookup( usPort ); - *pxIsWaitingForARPResolution = pdFALSE; + *pxIsWaitingForNDResolution = pdFALSE; do { @@ -425,8 +424,8 @@ BaseType_t xProcessReceivedUDPPacket_IPv6( NetworkBufferDescriptor_t * pxNetwork { if( xCheckRequiresNDResolution( pxNetworkBuffer ) == pdTRUE ) { - /* Mark this packet as waiting for ARP resolution. */ - *pxIsWaitingForARPResolution = pdTRUE; + /* Mark this packet as waiting for ND resolution. */ + *pxIsWaitingForNDResolution = pdTRUE; /* Return a fail to show that the frame will not be processed right now. */ xReturn = pdFAIL; diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index 3dfddd0bc..52d94ce65 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -2946,6 +2946,22 @@ STATIC_ASSERT( ipconfigDNS_SEND_BLOCK_TIME_TICKS <= portMAX_DELAY ); /*===========================================================================*/ /*---------------------------------------------------------------------------*/ /*===========================================================================*/ +/* ND CONFIG */ +/*===========================================================================*/ + +/*---------------------------------------------------------------------------*/ + + + +/*---------------------------------------------------------------------------*/ + +/*===========================================================================*/ +/* ND CONFIG */ +/*===========================================================================*/ +/*---------------------------------------------------------------------------*/ +/*===========================================================================*/ +/*---------------------------------------------------------------------------*/ +/*===========================================================================*/ /* ICMP CONFIG */ /*===========================================================================*/ diff --git a/source/include/FreeRTOS_ARP.h b/source/include/FreeRTOS_ARP.h index 21357b799..83aadd83e 100644 --- a/source/include/FreeRTOS_ARP.h +++ b/source/include/FreeRTOS_ARP.h @@ -62,13 +62,6 @@ typedef struct xARP_CACHE_TABLE_ROW * pxEndPoint; /**< The end-point on which the MAC address was last seen. */ } ARPCacheRow_t; -typedef enum -{ - eARPCacheMiss = 0, /* 0 An ARP table lookup did not find a valid entry. */ - eARPCacheHit, /* 1 An ARP table lookup found a valid entry. */ - eCantSendPacket /* 2 There is no IP address, or an ARP is still in progress, so the packet cannot be sent. */ -} eARPLookupResult_t; - /** @brief A structure used internally in FreeRTOS_ARP.c. * It is used as a parameter for the function prvFindCacheEntry().*/ typedef struct xCacheLocation @@ -91,9 +84,6 @@ void vARPRefreshCacheEntryAge( const MACAddress_t * pxMACAddress, * cache table then add it - replacing the oldest current entry if there is not * a free space available. */ -/*void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, */ -/* const uint32_t ulIPAddress ); */ - void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, const uint32_t ulIPAddress, struct xNetworkEndPoint * pxEndPoint ); @@ -128,33 +118,30 @@ BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetw * (maybe DHCP is still in process, or the addressing needs a gateway but there * isn't a gateway defined) then return eCantSendPacket. */ -eARPLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, +eResolutionLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ); #if ( ipconfigUSE_ARP_REVERSED_LOOKUP != 0 ) /* Lookup an IP-address if only the MAC-address is known */ - eARPLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, + eResolutionLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, uint32_t * pulIPAddress, struct xNetworkInterface ** ppxInterface ); #endif -#if ( ipconfigUSE_IPv4 != 0 ) - /* * Reduce the age count in each entry within the ARP cache. An entry is no * longer considered valid and is deleted if its age reaches zero. */ - void vARPAgeCache( void ); +void vARPAgeCache( void ); /* * After DHCP is ready and when changing IP address, force a quick send of our new IP * address */ - void vARPSendGratuitous( void ); -#endif /* ( ipconfigUSE_IPv4 != 0 ) */ +void vARPSendGratuitous( void ); /* * Send out an ARP request for the IP address contained in pxNetworkBuffer, and @@ -171,9 +158,20 @@ void FreeRTOS_OutputARPRequest( uint32_t ulIPAddress ); void FreeRTOS_OutputARPRequest_Multi( NetworkEndPoint_t * pxEndPoint, uint32_t ulIPAddress ); +/* xARPWaitResolution checks if an IPv4 address is already known. If not + * it may send an ARP request and wait for a reply. This function will + * only be called from an application. */ +BaseType_t xARPWaitResolution( uint32_t ulIPAddress, + TickType_t uxTicksToWait ); + /* Clear all entries in the ARp cache. */ void FreeRTOS_ClearARP( const struct xNetworkEndPoint * pxEndPoint ); +/* Show all valid ARP entries */ +#if ( ipconfigHAS_PRINTF != 0 ) || ( ipconfigHAS_DEBUG_PRINTF != 0 ) + void FreeRTOS_PrintARPCache( void ); +#endif + /* *INDENT-OFF* */ #ifdef __cplusplus } /* extern "C" */ diff --git a/source/include/FreeRTOS_DNS_Cache.h b/source/include/FreeRTOS_DNS_Cache.h index 2dd6b19a3..f94442217 100644 --- a/source/include/FreeRTOS_DNS_Cache.h +++ b/source/include/FreeRTOS_DNS_Cache.h @@ -43,7 +43,7 @@ */ typedef struct xDNS_CACHE_TABLE_ROW { - IPv46_Address_t xAddresses[ ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY ]; /*!< The IP address(es) of an ARP cache entry. */ + IPv46_Address_t xAddresses[ ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY ]; /*!< The IP address(es) of a DNS cache entry. */ char pcName[ ipconfigDNS_CACHE_NAME_LENGTH ]; /*!< The name of the host */ uint32_t ulTTL; /*!< Time-to-Live (in seconds) from the DNS server. */ uint32_t ulTimeWhenAddedInSeconds; /*!< time at which the entry was added */ diff --git a/source/include/FreeRTOS_ICMP.h b/source/include/FreeRTOS_ICMP.h index fa7cd8bb1..0c8012832 100644 --- a/source/include/FreeRTOS_ICMP.h +++ b/source/include/FreeRTOS_ICMP.h @@ -48,7 +48,6 @@ #include "FreeRTOS_IP.h" #include "FreeRTOS_Sockets.h" #include "FreeRTOS_IP_Private.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_UDP_IP.h" #include "FreeRTOS_DHCP.h" #include "NetworkInterface.h" diff --git a/source/include/FreeRTOS_IP.h b/source/include/FreeRTOS_IP.h index 8e6acf4e9..2240b99ac 100644 --- a/source/include/FreeRTOS_IP.h +++ b/source/include/FreeRTOS_IP.h @@ -399,12 +399,6 @@ void FreeRTOS_UpdateMACAddress( const uint8_t ucMACAddress[ ipMAC_ADDRESS_LENGTH uint16_t usIdentifier ); #endif -/* xARPWaitResolution checks if an IPv4 address is already known. If not - * it may send an ARP request and wait for a reply. This function will - * only be called from an application. */ -BaseType_t xARPWaitResolution( uint32_t ulIPAddress, - TickType_t uxTicksToWait ); - BaseType_t FreeRTOS_IsNetworkUp( void ); #if ( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) @@ -447,10 +441,10 @@ BaseType_t xIsNetworkDownEventPending( void ); * be defined in a user module. */ BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber ); -/** @brief The pointer to buffer with packet waiting for ARP resolution. This variable +/** @brief The pointer to buffer with packet waiting for resolution. This variable * is defined in FreeRTOS_IP.c. * This pointer is for internal use only. */ -extern NetworkBufferDescriptor_t * pxARPWaitingNetworkBuffer; +extern NetworkBufferDescriptor_t * pxResolutionWaitingNetworkBuffer; #if ( ipconfigENABLE_BACKWARD_COMPATIBILITY == 1 ) #define xIPStackEvent_t IPStackEvent_t diff --git a/source/include/FreeRTOS_IP_Private.h b/source/include/FreeRTOS_IP_Private.h index a19878866..f57d45c7d 100644 --- a/source/include/FreeRTOS_IP_Private.h +++ b/source/include/FreeRTOS_IP_Private.h @@ -34,6 +34,7 @@ #include "FreeRTOS_Sockets.h" #include "FreeRTOS_Stream_Buffer.h" #include "FreeRTOS_Routing.h" +#include "FreeRTOS_ARP.h" #if ( ipconfigUSE_TCP == 1 ) #include "FreeRTOS_TCP_WIN.h" @@ -65,7 +66,7 @@ typedef enum eFrameProcessingResult eProcessBuffer, /* An Ethernet frame has a valid address - continue process its contents. */ eReturnEthernetFrame, /* The Ethernet frame contains an ARP or ICMP packet that can be returned to its source. */ eFrameConsumed, /* Processing the Ethernet packet contents resulted in the payload being sent to the stack. */ - eWaitingARPResolution /* Frame is awaiting ARP resolution. */ + eWaitingAddrRes /* Frame is awaiting resolution. */ } eFrameProcessingResult_t; typedef enum @@ -74,7 +75,7 @@ typedef enum eNetworkDownEvent, /* 0: The network interface has been lost and/or needs [re]connecting. */ eNetworkRxEvent, /* 1: The network interface has queued a received Ethernet frame. */ eNetworkTxEvent, /* 2: Let the IP-task send a network packet. */ - eARPTimerEvent, /* 3: The ARP timer expired. */ + eAddrResTimerEvent, /* 3: The resolution timer expired. */ eStackTxEvent, /* 4: The software stack has queued a packet to transmit. */ eDHCPEvent, /* 5: Process the DHCP state machine. */ eTCPTimerEvent, /* 6: See if any TCP socket needs attention. */ @@ -456,23 +457,6 @@ uint16_t usGenerateChecksum( uint16_t usSum, /* Socket related private functions. */ -/* - * The caller must ensure that pxNetworkBuffer->xDataLength is the UDP packet - * payload size (excluding packet headers) and that the packet in pucEthernetBuffer - * is at least the size of UDPPacket_t. - */ -BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t * pxNetworkBuffer, - uint16_t usPort, - BaseType_t * pxIsWaitingForARPResolution ); - -BaseType_t xProcessReceivedUDPPacket_IPv4( NetworkBufferDescriptor_t * pxNetworkBuffer, - uint16_t usPort, - BaseType_t * pxIsWaitingForARPResolution ); - -BaseType_t xProcessReceivedUDPPacket_IPv6( NetworkBufferDescriptor_t * pxNetworkBuffer, - uint16_t usPort, - BaseType_t * pxIsWaitingForARPResolution ); - /* * Initialize the socket list data structures for TCP and UDP. */ diff --git a/source/include/FreeRTOS_IP_Timers.h b/source/include/FreeRTOS_IP_Timers.h index 8d7a84e26..f73e9c7e0 100644 --- a/source/include/FreeRTOS_IP_Timers.h +++ b/source/include/FreeRTOS_IP_Timers.h @@ -48,7 +48,6 @@ #include "FreeRTOS_IP.h" #include "FreeRTOS_Sockets.h" #include "FreeRTOS_IP_Private.h" -#include "FreeRTOS_ARP.h" #include "FreeRTOS_UDP_IP.h" #include "FreeRTOS_DHCP.h" #include "NetworkInterface.h" @@ -62,7 +61,7 @@ /* *INDENT-ON* */ /* - * Checks the ARP, DHCP and TCP timers to see if any periodic or timeout + * Checks the ARP, ND, DHCP and TCP timers to see if any periodic or timeout * processing is required. */ void vCheckNetworkTimers( void ); @@ -74,14 +73,19 @@ void vCheckNetworkTimers( void ); TickType_t xCalculateSleepTime( void ); /* - * Start an ARP Resolution timer. + * Enable/disable the TCP timer. */ -void vIPTimerStartARPResolution( TickType_t xTime ); +void vIPSetTCPTimerExpiredState( BaseType_t xExpiredState ); + +/** + * Sets the reload time of an ARP timer and restarts it. + */ +void vARPTimerReload( TickType_t xTime ); /* - * Enable/disable the TCP timer. + * Start an ARP Resolution timer. */ -void vIPSetTCPTimerExpiredState( BaseType_t xExpiredState ); +void vIPTimerStartARPResolution( TickType_t xTime ); /* * Enable/disable the ARP timer. @@ -93,6 +97,26 @@ void vIPSetARPTimerEnableState( BaseType_t xEnableState ); */ void vIPSetARPResolutionTimerEnableState( BaseType_t xEnableState ); +/** + * Sets the reload time of an ND timer and restarts it. + */ +void vNDTimerReload( TickType_t xTime ); + +/* + * Start an ND Resolution timer. + */ +void vIPTimerStartNDResolution( TickType_t xTime ); + +/* + * Enable/disable the ND timer. + */ +void vIPSetNDTimerEnableState( BaseType_t xEnableState ); + +/* + * Enable or disable the ARP resolution timer. + */ +void vIPSetNDResolutionTimerEnableState( BaseType_t xEnableState ); + #if ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) /** @@ -113,11 +137,6 @@ void vIPSetARPResolutionTimerEnableState( BaseType_t xEnableState ); void vIPSetDNSTimerEnableState( BaseType_t xEnableState ); #endif /* ipconfigDNS_USE_CALLBACKS != 0 */ -/** - * Sets the reload time of an ARP timer and restarts it. - */ -void vARPTimerReload( TickType_t xTime ); - /** * Sets the reload time of an TCP timer and restarts it. */ diff --git a/source/include/FreeRTOS_IPv4.h b/source/include/FreeRTOS_IPv4.h index 233620d37..9c397e99f 100644 --- a/source/include/FreeRTOS_IPv4.h +++ b/source/include/FreeRTOS_IPv4.h @@ -77,12 +77,6 @@ uint32_t FreeRTOS_GetDNSServerAddress( void ); uint32_t FreeRTOS_GetNetmask( void ); uint32_t FreeRTOS_GetIPAddress( void ); -/* Show all valid ARP entries - */ -#if ( ipconfigHAS_PRINTF != 0 ) || ( ipconfigHAS_DEBUG_PRINTF != 0 ) - void FreeRTOS_PrintARPCache( void ); -#endif - /* Return pdTRUE if the IPv4 address is a multicast address. */ BaseType_t xIsIPv4Multicast( uint32_t ulIPAddress ); diff --git a/source/include/FreeRTOS_IPv6.h b/source/include/FreeRTOS_IPv6.h index 0706a7dac..ea2d9dbca 100644 --- a/source/include/FreeRTOS_IPv6.h +++ b/source/include/FreeRTOS_IPv6.h @@ -107,8 +107,6 @@ BaseType_t xIsIPv6Loopback( const IPv6_Address_t * pxAddress ); eFrameProcessingResult_t eHandleIPv6ExtensionHeaders( NetworkBufferDescriptor_t * const pxNetworkBuffer, BaseType_t xDoRemove ); -extern void FreeRTOS_ClearND( void ); - /* Check whether this IPv6 address is an allowed multicast address or not. */ BaseType_t xIsIPv6AllowedMulticast( const IPv6_Address_t * pxIPAddress ); diff --git a/source/include/FreeRTOS_ND.h b/source/include/FreeRTOS_ND.h index f4bc5dd53..d3efd0889 100644 --- a/source/include/FreeRTOS_ND.h +++ b/source/include/FreeRTOS_ND.h @@ -32,8 +32,6 @@ #include "FreeRTOSIPConfig.h" #include "FreeRTOSIPConfigDefaults.h" -#include "FreeRTOS_ARP.h" - /* *INDENT-OFF* */ #ifdef __cplusplus extern "C" { @@ -88,12 +86,12 @@ * * @note Look for ulIPAddress in the ND cache. If the IP address exists, copy the * associated MAC address into pxMACAddress, refresh the ND cache entry's - * age, and return eARPCacheHit. If the IP address does not exist in the ND - * cache return eARPCacheMiss. If the packet cannot be sent for any reason + * age, and return eAddrResCacheHit. If the IP address does not exist in the ND + * cache return eAddrResCacheMiss. If the packet cannot be sent for any reason * (maybe DHCP is still in process, or the addressing needs a gateway but there * isn't a gateway defined) then return eCantSendPacket. */ - eARPLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, + eAddrResLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ); @@ -206,6 +204,9 @@ BaseType_t xCheckRequiresNDResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer ); + /* Clear all entries in the ND cache. */ + void FreeRTOS_ClearND( const struct xNetworkEndPoint * pxEndPoint ); + #endif /* ipconfigUSE_IPv6 != 0 */ diff --git a/source/include/FreeRTOS_Routing.h b/source/include/FreeRTOS_Routing.h index b6951ae80..c62a98012 100644 --- a/source/include/FreeRTOS_Routing.h +++ b/source/include/FreeRTOS_Routing.h @@ -352,6 +352,13 @@ BaseType_t xCheckRequiresResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer ); + typedef enum + { + eAddrResCacheMiss = 0, /* 0 A cache lookup did not find a valid entry. */ + eAddrResCacheHit, /* 1 A cache lookup found a valid entry. */ + eCantSendPacket /* 2 There is no IP address, or a resolution is still in progress, so the packet cannot be sent. */ + } eAddrResLookupResult_t; + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/source/include/FreeRTOS_TCP_Transmission.h b/source/include/FreeRTOS_TCP_Transmission.h index ab1eae67b..c4800b664 100644 --- a/source/include/FreeRTOS_TCP_Transmission.h +++ b/source/include/FreeRTOS_TCP_Transmission.h @@ -97,7 +97,7 @@ void prvTCPReturn_SetEndPoint( const FreeRTOS_Socket_t * pxSocket, BaseType_t prvTCPPrepareConnect_IPV4( FreeRTOS_Socket_t * pxSocket ); /* - * Let ARP look-up the MAC-address of the peer and initialise the first SYN + * Let ND look-up the MAC-address of the peer and initialise the first SYN * packet. */ BaseType_t prvTCPPrepareConnect_IPV6( FreeRTOS_Socket_t * pxSocket ); diff --git a/source/include/FreeRTOS_UDP_IP.h b/source/include/FreeRTOS_UDP_IP.h index 0285aaebb..c1a6f3544 100644 --- a/source/include/FreeRTOS_UDP_IP.h +++ b/source/include/FreeRTOS_UDP_IP.h @@ -44,11 +44,26 @@ */ void vProcessGeneratedUDPPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer ); -/* - * _HT_ added in order to avoid warnings while testing. */ void vProcessGeneratedUDPPacket_IPv4( NetworkBufferDescriptor_t * const pxNetworkBuffer ); void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetworkBuffer ); +/* + * The caller must ensure that pxNetworkBuffer->xDataLength is the UDP packet + * payload size (excluding packet headers) and that the packet in pucEthernetBuffer + * is at least the size of UDPPacket_t. + */ +BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t * pxNetworkBuffer, + uint16_t usPort, + BaseType_t * pxIsWaitingForResolution ); + +BaseType_t xProcessReceivedUDPPacket_IPv4( NetworkBufferDescriptor_t * pxNetworkBuffer, + uint16_t usPort, + BaseType_t * pxIsWaitingForARPResolution ); + +BaseType_t xProcessReceivedUDPPacket_IPv6( NetworkBufferDescriptor_t * pxNetworkBuffer, + uint16_t usPort, + BaseType_t * pxIsWaitingForNDResolution ); + /* *INDENT-OFF* */ #ifdef __cplusplus } /* extern "C" */ diff --git a/source/include/IPTraceMacroDefaults.h b/source/include/IPTraceMacroDefaults.h index 3c3872f15..e0c037593 100644 --- a/source/include/IPTraceMacroDefaults.h +++ b/source/include/IPTraceMacroDefaults.h @@ -587,6 +587,25 @@ /*===========================================================================*/ /*---------------------------------------------------------------------------*/ /*===========================================================================*/ +/* ND TRACE MACROS */ +/*===========================================================================*/ + +/*---------------------------------------------------------------------------*/ + + + + + + +/*---------------------------------------------------------------------------*/ + +/*===========================================================================*/ +/* ND TRACE MACROS */ +/*===========================================================================*/ +/*---------------------------------------------------------------------------*/ +/*===========================================================================*/ +/*---------------------------------------------------------------------------*/ +/*===========================================================================*/ /* DHCP TRACE MACROS */ /*===========================================================================*/ diff --git a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c index f50fa9933..242eb3641 100644 --- a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c +++ b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c @@ -785,7 +785,7 @@ void test_FreeRTOS_ClearND( void ) /* Set xNDCache to non zero entries*/ ( void ) memset( xNDCache, 1, sizeof( xNDCache ) ); ( void ) memset( xTempNDCache, 0, sizeof( xTempNDCache ) ); - FreeRTOS_ClearND(); + FreeRTOS_ClearND( NULL ); TEST_ASSERT_EQUAL_MEMORY( xNDCache, xTempNDCache, sizeof( xNDCache ) ); } diff --git a/tools/tcp_utilities/plus_tcp_demo_cli.c b/tools/tcp_utilities/plus_tcp_demo_cli.c index b6c005f1a..598f37bbe 100644 --- a/tools/tcp_utilities/plus_tcp_demo_cli.c +++ b/tools/tcp_utilities/plus_tcp_demo_cli.c @@ -1650,7 +1650,7 @@ static void clear_caches() { FreeRTOS_dnsclear(); #if ( ipconfigUSE_IPv6 != 0 ) - FreeRTOS_ClearND(); + FreeRTOS_ClearND( NULL ); #endif /* ( ipconfigUSE_IPv6 != 0 ) */ } #endif /* ipconfigUSE_DNS_CACHE */ From 8238b6f728db9117e847d3fb110b06ae94487472 Mon Sep 17 00:00:00 2001 From: Holden Date: Mon, 22 Apr 2024 12:30:52 -0400 Subject: [PATCH 04/25] Fix tracing and config macros --- source/include/FreeRTOSIPConfigDefaults.h | 46 +++++++++----------- source/include/IPTraceMacroDefaults.h | 52 +++++++++-------------- 2 files changed, 42 insertions(+), 56 deletions(-) diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index a4bd5eecc..aa0a7e67c 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -254,31 +254,6 @@ /*---------------------------------------------------------------------------*/ -/* - * ipconfigND_CACHE_ENTRIES - * - * Type: size_t - * Unit: length of NDCacheRow_t array - * Minimum: 1 - * - * Maximum number of entries in the Neighbour Discovery cache of IPv6 addresses - * & MAC addresses - */ - -#ifndef ipconfigND_CACHE_ENTRIES - #define ipconfigND_CACHE_ENTRIES ( 24 ) -#endif - -#if ( ipconfigND_CACHE_ENTRIES < 1 ) - #error ipconfigND_CACHE_ENTRIES must be at least 1 -#endif - -#if ( ipconfigND_CACHE_ENTRIES > SIZE_MAX ) - #error ipconfigND_CACHE_ENTRIES overflows a size_t -#endif - -/*---------------------------------------------------------------------------*/ - /* * ipconfigUSE_RA * @@ -2951,7 +2926,28 @@ STATIC_ASSERT( ipconfigDNS_SEND_BLOCK_TIME_TICKS <= portMAX_DELAY ); /*---------------------------------------------------------------------------*/ +/* + * ipconfigND_CACHE_ENTRIES + * + * Type: size_t + * Unit: length of NDCacheRow_t array + * Minimum: 1 + * + * Maximum number of entries in the Neighbour Discovery cache of IPv6 addresses + * & MAC addresses + */ +#ifndef ipconfigND_CACHE_ENTRIES + #define ipconfigND_CACHE_ENTRIES ( 24 ) +#endif + +#if ( ipconfigND_CACHE_ENTRIES < 1 ) + #error ipconfigND_CACHE_ENTRIES must be at least 1 +#endif + +#if ( ipconfigND_CACHE_ENTRIES > SIZE_MAX ) + #error ipconfigND_CACHE_ENTRIES overflows a size_t +#endif /*---------------------------------------------------------------------------*/ diff --git a/source/include/IPTraceMacroDefaults.h b/source/include/IPTraceMacroDefaults.h index e0c037593..fdd36a2a5 100644 --- a/source/include/IPTraceMacroDefaults.h +++ b/source/include/IPTraceMacroDefaults.h @@ -129,7 +129,7 @@ * [re]connecting. * eNetworkRxEvent - The network interface has queued a received Ethernet * frame. - * eARPTimerEvent - The ARP timer expired. + * eResolutionTimerEvent - The Resolution timer expired. * eStackTxEvent - The software stack has queued a packet to transmit. * eDHCPEvent - Process the DHCP state machine. * @@ -592,10 +592,30 @@ /*---------------------------------------------------------------------------*/ +/* + * iptraceND_TABLE_ENTRY_EXPIRED + */ +#ifndef iptraceND_TABLE_ENTRY_EXPIRED + #define iptraceND_TABLE_ENTRY_EXPIRED( pxIPAddress ) +#endif +/*---------------------------------------------------------------------------*/ +/* + * iptraceND_TABLE_ENTRY_WILL_EXPIRE + */ +#ifndef iptraceND_TABLE_ENTRY_WILL_EXPIRE + #define iptraceND_TABLE_ENTRY_WILL_EXPIRE( pxIPAddress ) +#endif +/*---------------------------------------------------------------------------*/ +/* + * iptrace_DELAYED_ND_REQUEST_REPLIED + */ +#ifndef iptrace_DELAYED_ND_REQUEST_REPLIED + #define iptrace_DELAYED_ND_REQUEST_REPLIED() +#endif /*---------------------------------------------------------------------------*/ @@ -734,36 +754,6 @@ /*===========================================================================*/ /*---------------------------------------------------------------------------*/ /*===========================================================================*/ -/* NDP TRACE MACROS */ -/*===========================================================================*/ - -/*---------------------------------------------------------------------------*/ - -/* - * iptraceND_TABLE_ENTRY_EXPIRED - */ -#ifndef iptraceND_TABLE_ENTRY_EXPIRED - #define iptraceND_TABLE_ENTRY_EXPIRED( pxIPAddress ) -#endif - -/*---------------------------------------------------------------------------*/ - -/* - * iptraceND_TABLE_ENTRY_WILL_EXPIRE - */ -#ifndef iptraceND_TABLE_ENTRY_WILL_EXPIRE - #define iptraceND_TABLE_ENTRY_WILL_EXPIRE( pxIPAddress ) -#endif - -/*---------------------------------------------------------------------------*/ - -/*===========================================================================*/ -/* NDP TRACE MACROS */ -/*===========================================================================*/ -/*---------------------------------------------------------------------------*/ -/*===========================================================================*/ -/*---------------------------------------------------------------------------*/ -/*===========================================================================*/ /* ROUTER ADVERTISEMENT TRACE MACROS */ /*===========================================================================*/ From afd46669b9041b9c183866831acdeb1c4cb1b77b Mon Sep 17 00:00:00 2001 From: Holden Date: Mon, 22 Apr 2024 12:43:21 -0400 Subject: [PATCH 05/25] Fix Build Issues --- source/FreeRTOS_ARP.c | 56 ++++++++-------- source/FreeRTOS_IP.c | 2 +- source/FreeRTOS_ND.c | 4 +- source/FreeRTOS_TCP_Transmission_IPv4.c | 2 +- source/FreeRTOS_TCP_Transmission_IPv6.c | 4 +- source/FreeRTOS_UDP_IPv4.c | 2 +- source/FreeRTOS_UDP_IPv6.c | 6 +- source/include/FreeRTOS_ARP.h | 9 +-- source/include/FreeRTOS_ND.h | 2 + source/include/IPTraceMacroDefaults.h | 6 +- .../TCPReturnPacket_harness.c | 2 +- .../FreeRTOS_ARP/FreeRTOS_ARP_utest.c | 22 +++---- .../FreeRTOS_IP_DiffConfig_utest.c | 4 +- .../unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c | 26 ++++---- .../unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c | 6 +- .../FreeRTOS_TCP_Transmission_utest.c | 66 +++++++++---------- .../FreeRTOS_TCP_Transmission_IPv6_utest.c | 24 +++---- .../FreeRTOS_UDP_IPv4_utest.c | 22 +++---- .../FreeRTOS_UDP_IPv6_utest.c | 16 ++--- tools/tcp_utilities/plus_tcp_demo_cli.c | 8 +-- 20 files changed, 146 insertions(+), 143 deletions(-) diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index c894bc5f1..6b93b9e4e 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -94,11 +94,11 @@ /* * Lookup an MAC address in the ARP cache from the IP address. */ - static eResolutionLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, + static eAddrResLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ); - static eResolutionLookupResult_t eARPGetCacheEntryGateWay( uint32_t * pulIPAddress, + static eAddrResLookupResult_t eARPGetCacheEntryGateWay( uint32_t * pulIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ); @@ -252,7 +252,7 @@ } else { - traceARP_PACKET_RECEIVED(); + iptraceARP_PACKET_RECEIVED(); /* Some extra logging while still testing. */ #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) @@ -318,7 +318,7 @@ /* The request is a Gratuitous ARP message. * Refresh the entry if it already exists. */ /* Determine the ARP cache status for the requested IP address. */ - if( eARPGetCacheEntry( &( ulSenderProtocolAddress ), &( xHardwareAddress ), &( pxCachedEndPoint ) ) == eARPCacheHit ) + if( eARPGetCacheEntry( &( ulSenderProtocolAddress ), &( xHardwareAddress ), &( pxCachedEndPoint ) ) == eAddrResCacheHit ) { /* Check if the endpoint matches with the one present in the ARP cache */ if( pxCachedEndPoint == pxTargetEndPoint ) @@ -819,14 +819,14 @@ * @param[in] pxMACAddress The MAC-address of the entry of interest. * @param[out] pulIPAddress set to the IP-address found, or unchanged when not found. * - * @return Either eARPCacheMiss or eARPCacheHit. + * @return Either eAddrResCacheMiss or eAddrResCacheHit. */ - eResolutionLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, + eAddrResLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, uint32_t * pulIPAddress, struct xNetworkInterface ** ppxInterface ) { BaseType_t x; - eResolutionLookupResult_t eReturn = eResolutionCacheMiss; + eAddrResLookupResult_t eReturn = eResolutionCacheMiss; configASSERT( pxMACAddress != NULL ); configASSERT( pulIPAddress != NULL ); @@ -851,7 +851,7 @@ *( ppxInterface ) = xARPCache[ x ].pxEndPoint->pxNetworkInterface; } - eReturn = eARPCacheHit; + eReturn = eAddrResCacheHit; break; } } @@ -871,17 +871,17 @@ * @param[out] ppxEndPoint Pointer to the end-point of the gateway will be stored. * * @return If the IP address exists, copy the associated MAC address into pxMACAddress, - * refresh the ARP cache entry's age, and return eARPCacheHit. If the IP - * address does not exist in the ARP cache return eARPCacheMiss. If the packet + * refresh the ARP cache entry's age, and return eAddrResCacheHit. If the IP + * address does not exist in the ARP cache return eAddrResCacheMiss. If the packet * cannot be sent for any reason (maybe DHCP is still in process, or the * addressing needs a gateway but there isn't a gateway defined) then return * eCantSendPacket. */ - eResolutionLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, + eAddrResLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ) { - eResolutionLookupResult_t eReturn; + eAddrResLookupResult_t eReturn; uint32_t ulAddressToLookup; NetworkEndPoint_t * pxEndPoint = NULL; @@ -909,7 +909,7 @@ { /* For multi-cast, use the first IPv4 end-point. */ *( ppxEndPoint ) = pxEndPoint; - eReturn = eARPCacheHit; + eReturn = eAddrResCacheHit; break; } } @@ -925,7 +925,7 @@ *( ppxEndPoint ) = pxEndPoint; } - eReturn = eARPCacheHit; + eReturn = eAddrResCacheHit; } else { @@ -944,11 +944,11 @@ * stored to the buffer provided. * @param[out] ppxEndPoint The end-point of the gateway will be copy to the pointee. */ - static eResolutionLookupResult_t eARPGetCacheEntryGateWay( uint32_t * pulIPAddress, + static eAddrResLookupResult_t eARPGetCacheEntryGateWay( uint32_t * pulIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ) { - eResolutionLookupResult_t eReturn = eARPCacheMiss; + eAddrResLookupResult_t eReturn = eAddrResCacheMiss; uint32_t ulAddressToLookup = *( pulIPAddress ); NetworkEndPoint_t * pxEndPoint; uint32_t ulOriginal = *pulIPAddress; @@ -963,7 +963,7 @@ #if ( ipconfigARP_STORES_REMOTE_ADDRESSES == 1 ) eReturn = prvCacheLookup( ulAddressToLookup, pxMACAddress, ppxEndPoint ); - if( eReturn == eARPCacheHit ) + if( eReturn == eAddrResCacheHit ) { /* The stack is configured to store 'remote IP addresses', i.e. addresses * belonging to a different the netmask. prvCacheLookup() returned a hit, so @@ -996,7 +996,7 @@ } #if ( ipconfigARP_STORES_REMOTE_ADDRESSES == 1 ) - if( eReturn == eARPCacheMiss ) + if( eReturn == eAddrResCacheMiss ) #endif { if( ulAddressToLookup == 0U ) @@ -1009,11 +1009,11 @@ { eReturn = prvCacheLookup( ulAddressToLookup, pxMACAddress, ppxEndPoint ); - if( ( eReturn != eARPCacheHit ) || ( ulOriginal != ulAddressToLookup ) ) + if( ( eReturn != eAddrResCacheHit ) || ( ulOriginal != ulAddressToLookup ) ) { FreeRTOS_debug_printf( ( "ARP %xip %s using %xip\n", ( unsigned ) FreeRTOS_ntohl( ulOriginal ), - ( eReturn == eARPCacheHit ) ? "hit" : "miss", + ( eReturn == eAddrResCacheHit ) ? "hit" : "miss", ( unsigned ) FreeRTOS_ntohl( ulAddressToLookup ) ) ); } @@ -1036,15 +1036,15 @@ * the IP address will be stored. * @param[in,out] ppxEndPoint a pointer to the end-point will be stored. * - * @return When the IP-address is found: eARPCacheHit, when not found: eARPCacheMiss, + * @return When the IP-address is found: eAddrResCacheHit, when not found: eAddrResCacheMiss, * and when waiting for a ARP reply: eCantSendPacket. */ - static eResolutionLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, + static eAddrResLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ) { BaseType_t x; - eResolutionLookupResult_t eReturn = eARPCacheMiss; + eAddrResLookupResult_t eReturn = eAddrResCacheMiss; /* Loop through each entry in the ARP cache. */ for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) @@ -1065,7 +1065,7 @@ ( void ) memcpy( pxMACAddress->ucBytes, xARPCache[ x ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ); /* ppxEndPoint != NULL was tested in the only caller eARPGetCacheEntry(). */ *( ppxEndPoint ) = xARPCache[ x ].pxEndPoint; - eReturn = eARPCacheHit; + eReturn = eAddrResCacheHit; } break; @@ -1274,7 +1274,7 @@ BaseType_t xResult = -pdFREERTOS_ERRNO_EADDRNOTAVAIL; TimeOut_t xTimeOut; MACAddress_t xMACAddress; - eResolutionLookupResult_t xLookupResult; + eAddrResLookupResult_t xLookupResult; NetworkEndPoint_t * pxEndPoint; size_t uxSendCount = ipconfigMAX_ARP_RETRANSMISSIONS; uint32_t ulIPAddressCopy = ulIPAddress; @@ -1284,7 +1284,7 @@ xLookupResult = eARPGetCacheEntry( &( ulIPAddressCopy ), &( xMACAddress ), &( pxEndPoint ) ); - if( xLookupResult == eARPCacheMiss ) + if( xLookupResult == eAddrResCacheMiss ) { const TickType_t uxSleepTime = pdMS_TO_TICKS( 250U ); @@ -1300,7 +1300,7 @@ xLookupResult = eARPGetCacheEntry( &( ulIPAddressCopy ), &( xMACAddress ), &( pxEndPoint ) ); if( ( xTaskCheckForTimeOut( &( xTimeOut ), &( uxTicksToWait ) ) == pdTRUE ) || - ( xLookupResult != eARPCacheMiss ) ) + ( xLookupResult != eAddrResCacheMiss ) ) { break; } @@ -1310,7 +1310,7 @@ } } - if( xLookupResult == eARPCacheHit ) + if( xLookupResult == eAddrResCacheHit ) { xResult = 0; } diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 2ca7ba98e..afb40ade4 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -2101,7 +2101,7 @@ void vReturnEthernetFrame( NetworkBufferDescriptor_t * pxNetworkBuffer, #if ( ipconfigUSE_IPv4 != 0 ) MACAddress_t xMACAddress; - eResolutionLookupResult_t eResult; + eAddrResLookupResult_t eResult; uint32_t ulDestinationIPAddress = 0U; #endif /* ( ipconfigUSE_IPv4 != 0 ) */ diff --git a/source/FreeRTOS_ND.c b/source/FreeRTOS_ND.c index aa94dd9a6..62612fba3 100644 --- a/source/FreeRTOS_ND.c +++ b/source/FreeRTOS_ND.c @@ -78,12 +78,12 @@ const uint8_t pcLOCAL_ALL_NODES_MULTICAST_MAC[ ipMAC_ADDRESS_LENGTH_BYTES ] = { 0x33U, 0x33U, 0x00U, 0x00U, 0x00U, 0x01U }; /** @brief See if the MAC-address can be resolved because it is a multi-cast address. */ - static eResolutionLookupResult_t prvMACResolve( const IPv6_Address_t * pxAddressToLookup, + static eAddrResLookupResult_t prvMACResolve( const IPv6_Address_t * pxAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ); /** @brief Lookup an MAC address in the ND cache from the IP address. */ - static eResolutionLookupResult_t prvNDCacheLookup( const IPv6_Address_t * pxAddressToLookup, + static eAddrResLookupResult_t prvNDCacheLookup( const IPv6_Address_t * pxAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ); diff --git a/source/FreeRTOS_TCP_Transmission_IPv4.c b/source/FreeRTOS_TCP_Transmission_IPv4.c index ba8dc0856..4f83eefa8 100644 --- a/source/FreeRTOS_TCP_Transmission_IPv4.c +++ b/source/FreeRTOS_TCP_Transmission_IPv4.c @@ -99,7 +99,7 @@ void prvTCPReturnPacket_IPV4( FreeRTOS_Socket_t * pxSocket, void * pvCopyDest = NULL; const size_t uxIPHeaderSize = ipSIZE_OF_IPv4_HEADER; uint32_t ulDestinationIPAddress; - eResolutionLookupResult_t eResult; + eAddrResLookupResult_t eResult; NetworkEndPoint_t * pxEndPoint = NULL; do diff --git a/source/FreeRTOS_TCP_Transmission_IPv6.c b/source/FreeRTOS_TCP_Transmission_IPv6.c index 3f5671eb0..dd4bf291d 100644 --- a/source/FreeRTOS_TCP_Transmission_IPv6.c +++ b/source/FreeRTOS_TCP_Transmission_IPv6.c @@ -150,7 +150,7 @@ void prvTCPReturnPacket_IPV6( FreeRTOS_Socket_t * pxSocket, if( pxNetworkBuffer != NULL ) /* LCOV_EXCL_BR_LINE the 2nd branch will never be reached */ #endif { - eResolutionLookupResult_t eResult; + eAddrResLookupResult_t eResult; NetworkInterface_t * pxInterface; configASSERT( pxNetworkBuffer->pucEthernetBuffer != NULL ); @@ -318,7 +318,7 @@ BaseType_t prvTCPPrepareConnect_IPV6( FreeRTOS_Socket_t * pxSocket ) { TCPPacket_IPv6_t * pxTCPPacket = NULL; IPHeader_IPv6_t * pxIPHeader = NULL; - eResolutionLookupResult_t eReturned; + eAddrResLookupResult_t eReturned; IP_Address_t xRemoteIP; MACAddress_t xEthAddress; BaseType_t xReturn = pdTRUE; diff --git a/source/FreeRTOS_UDP_IPv4.c b/source/FreeRTOS_UDP_IPv4.c index 3efb7e990..dd35aad36 100644 --- a/source/FreeRTOS_UDP_IPv4.c +++ b/source/FreeRTOS_UDP_IPv4.c @@ -76,7 +76,7 @@ void vProcessGeneratedUDPPacket_IPv4( NetworkBufferDescriptor_t * const pxNetwor { UDPPacket_t * pxUDPPacket; IPHeader_t * pxIPHeader; - eResolutionLookupResult_t eReturned; + eAddrResLookupResult_t eReturned; uint32_t ulIPAddress = pxNetworkBuffer->xIPAddress.ulIP_IPv4; NetworkEndPoint_t * pxEndPoint = pxNetworkBuffer->pxEndPoint; size_t uxPayloadSize; diff --git a/source/FreeRTOS_UDP_IPv6.c b/source/FreeRTOS_UDP_IPv6.c index 61dc11d48..52a250b0c 100644 --- a/source/FreeRTOS_UDP_IPv6.c +++ b/source/FreeRTOS_UDP_IPv6.c @@ -121,10 +121,10 @@ static NetworkEndPoint_t * pxGetEndpoint( BaseType_t xIPType, * @param[out] pxLostBuffer The pointee will be set to true in case the network packet got released * ( the ownership was taken ). */ -static eResolutionLookupResult_t prvStartLookup( NetworkBufferDescriptor_t * const pxNetworkBuffer, +static eAddrResLookupResult_t prvStartLookup( NetworkBufferDescriptor_t * const pxNetworkBuffer, BaseType_t * pxLostBuffer ) { - eResolutionLookupResult_t eReturned = eResolutionCacheMiss; + eAddrResLookupResult_t eReturned = eResolutionCacheMiss; FreeRTOS_printf( ( "Looking up %pip with%s end-point\n", ( void * ) pxNetworkBuffer->xIPAddress.xIP_IPv6.ucBytes, @@ -161,7 +161,7 @@ void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetwor { UDPPacket_IPv6_t * pxUDPPacket_IPv6; IPHeader_IPv6_t * pxIPHeader_IPv6; - eResolutionLookupResult_t eReturned; + eAddrResLookupResult_t eReturned; size_t uxPayloadSize; /* memcpy() helper variables for MISRA Rule 21.15 compliance*/ NetworkInterface_t * pxInterface = NULL; diff --git a/source/include/FreeRTOS_ARP.h b/source/include/FreeRTOS_ARP.h index 83aadd83e..c1a2b96a5 100644 --- a/source/include/FreeRTOS_ARP.h +++ b/source/include/FreeRTOS_ARP.h @@ -33,6 +33,7 @@ #include "FreeRTOSIPConfigDefaults.h" #include "FreeRTOS_IP.h" +#include "FreeRTOS_Routing.h" /* *INDENT-OFF* */ #ifdef __cplusplus @@ -113,19 +114,19 @@ BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetw /* * Look for ulIPAddress in the ARP cache. If the IP address exists, copy the * associated MAC address into pxMACAddress, refresh the ARP cache entry's - * age, and return eARPCacheHit. If the IP address does not exist in the ARP - * cache return eARPCacheMiss. If the packet cannot be sent for any reason + * age, and return eAddrResCacheHit. If the IP address does not exist in the ARP + * cache return eAddrResCacheMiss. If the packet cannot be sent for any reason * (maybe DHCP is still in process, or the addressing needs a gateway but there * isn't a gateway defined) then return eCantSendPacket. */ -eResolutionLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, +eAddrResLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ); #if ( ipconfigUSE_ARP_REVERSED_LOOKUP != 0 ) /* Lookup an IP-address if only the MAC-address is known */ - eResolutionLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, + eAddrResLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, uint32_t * pulIPAddress, struct xNetworkInterface ** ppxInterface ); diff --git a/source/include/FreeRTOS_ND.h b/source/include/FreeRTOS_ND.h index fbd54c884..57ad004bb 100644 --- a/source/include/FreeRTOS_ND.h +++ b/source/include/FreeRTOS_ND.h @@ -32,6 +32,8 @@ #include "FreeRTOSIPConfig.h" #include "FreeRTOSIPConfigDefaults.h" +#include "FreeRTOS_Routing.h" + /* *INDENT-OFF* */ #ifdef __cplusplus extern "C" { diff --git a/source/include/IPTraceMacroDefaults.h b/source/include/IPTraceMacroDefaults.h index fdd36a2a5..c9fd6eac6 100644 --- a/source/include/IPTraceMacroDefaults.h +++ b/source/include/IPTraceMacroDefaults.h @@ -418,13 +418,13 @@ /*---------------------------------------------------------------------------*/ /* - * traceARP_PACKET_RECEIVED + * iptraceARP_PACKET_RECEIVED * * Called when an ARP packet is received, even if the local network node is not * involved in the ARP transaction. */ -#ifndef traceARP_PACKET_RECEIVED - #define traceARP_PACKET_RECEIVED() +#ifndef iptraceARP_PACKET_RECEIVED + #define iptraceARP_PACKET_RECEIVED() #endif /*---------------------------------------------------------------------------*/ diff --git a/test/cbmc/proofs/TCP/prvTCPReturnPacket/TCPReturnPacket_harness.c b/test/cbmc/proofs/TCP/prvTCPReturnPacket/TCPReturnPacket_harness.c index 786d10cfd..3c7682e8f 100644 --- a/test/cbmc/proofs/TCP/prvTCPReturnPacket/TCPReturnPacket_harness.c +++ b/test/cbmc/proofs/TCP/prvTCPReturnPacket/TCPReturnPacket_harness.c @@ -148,7 +148,7 @@ eARPLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, __CPROVER_assert( pulIPAddress != NULL, "The pulIPAddress cannot be NULL" ); __CPROVER_assert( pxMACAddress != NULL, "The pxMACAddress cannot be NULL" ); - if( eReturn == eARPCacheHit ) + if( eReturn == eAddrResCacheHit ) { /* If its a cache hit, update ppxEndPoint with a valid endpoint. */ struct xNetworkEndPoint * pxEndPoint = ( NetworkEndPoint_t * ) safeMalloc( sizeof( NetworkEndPoint_t ) ); diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c index 2bfea875c..80f8b5e90 100644 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c @@ -1950,7 +1950,7 @@ void test_eARPGetCacheEntryByMac_NullInterface( void ) } eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, NULL ); - TEST_ASSERT_EQUAL( eARPCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); TEST_ASSERT_EQUAL( 0x12345678, ulIPAddress ); /* =================================================== */ } @@ -1972,7 +1972,7 @@ void test_eARPGetCacheEntryByMac_NoMatchingEntries( void ) } eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &xInterface ); - TEST_ASSERT_EQUAL( eARPCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); TEST_ASSERT_EQUAL( 0x12345678, ulIPAddress ); /* =================================================== */ } @@ -1997,16 +1997,16 @@ void test_eARPGetCacheEntryByMac_OneMatchingEntry( void ) memset( xARPCache[ ulEntryToTest ].xMACAddress.ucBytes, 0x22, sizeof( xMACAddress.ucBytes ) ); xARPCache[ ulEntryToTest ].ulIPAddress = 0xAABBCCEE; eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &xInterface ); - TEST_ASSERT_EQUAL( eARPCacheHit, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); TEST_ASSERT_EQUAL( xARPCache[ ulEntryToTest ].ulIPAddress, ulIPAddress ); /* =================================================== */ eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, NULL ); - TEST_ASSERT_EQUAL( eARPCacheHit, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); TEST_ASSERT_EQUAL( xARPCache[ ulEntryToTest ].ulIPAddress, ulIPAddress ); /* =================================================== */ xARPCache[ ulEntryToTest ].pxEndPoint = NULL; eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &xInterface ); - TEST_ASSERT_EQUAL( eARPCacheHit, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); TEST_ASSERT_EQUAL( xARPCache[ ulEntryToTest ].ulIPAddress, ulIPAddress ); /* =================================================== */ } @@ -2038,7 +2038,7 @@ void test_eARPGetCacheEntry_IPMatchesBroadcastAddr( void ) FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL_MESSAGE( eARPCacheHit, eResult, "Test 3" ); + TEST_ASSERT_EQUAL_MESSAGE( eAddrResCacheHit, eResult, "Test 3" ); TEST_ASSERT_EQUAL( pxEndPoint, &xEndPoint ); TEST_ASSERT_EQUAL_MEMORY_MESSAGE( &xBroadcastMACAddress, &xMACAddress, sizeof( xMACAddress ), "Test 3" ); /* =================================================== */ @@ -2060,7 +2060,7 @@ void test_eARPGetCacheEntry_IPMatchesBroadcastAddr_NullEndPointOnNetMask( void ) FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eARPCacheHit, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); TEST_ASSERT_NOT_EQUAL( pxEndPoint, &xEndPoint ); /* =================================================== */ } @@ -2116,7 +2116,7 @@ void test_eARPGetCacheEntry_IPMatchesOtherBroadcastAddr( void ) xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL_MESSAGE( eARPCacheHit, eResult, "Test 3" ); + TEST_ASSERT_EQUAL_MESSAGE( eAddrResCacheHit, eResult, "Test 3" ); TEST_ASSERT_EQUAL_MEMORY_MESSAGE( &xBroadcastMACAddress, &xMACAddress, sizeof( xMACAddress ), "Test 3" ); TEST_ASSERT_EQUAL( pxEndPoint, &xEndPoint ); /* =================================================== */ @@ -2178,7 +2178,7 @@ void test_eARPGetCacheEntry_MatchingValidEntry( void ) FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( &xEndPoint ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL_MESSAGE( eARPCacheHit, eResult, "Test 7" ); + TEST_ASSERT_EQUAL_MESSAGE( eAddrResCacheHit, eResult, "Test 7" ); TEST_ASSERT_EQUAL_MEMORY_MESSAGE( &xARPCache[ 1 ].xMACAddress, &xMACAddress, sizeof( xMACAddress ), "Test 7" ); TEST_ASSERT_NOT_EQUAL( pxEndPoint, &xEndPoint ); /* =================================================== */ @@ -2274,7 +2274,7 @@ void test_eARPGetCacheEntry_NoCacheHit( void ) FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); xNetworkAddressing.ulGatewayAddress = ulSavedGatewayAddress; - TEST_ASSERT_EQUAL( eARPCacheHit, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); TEST_ASSERT_NOT_EQUAL( pxEndPoint, &xEndPoint ); /* =================================================== */ } @@ -2580,7 +2580,7 @@ void test_xARPWaitResolution_PrivateFunctionReturnsHit( void ) /* Make the resolution pass without any attempt by making - * eARPGetCacheEntry return eARPCacheHit. */ + * eARPGetCacheEntry return eAddrResCacheHit. */ /* =================================================== */ /* Assertion on calling from IP-task */ xEndPoint.bits.bIPv6 = pdFALSE_UNSIGNED; diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_utest.c b/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_utest.c index 9a530d1ec..fe670a2e3 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_utest.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_utest.c @@ -383,7 +383,7 @@ void test_vReturnEthernetFrame_DuplicationSuccess( void ) FreeRTOS_FindEndPointOnNetMask_IgnoreAndReturn( pxEndPoint ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheMiss ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); xIsCallingFromIPTask_ExpectAndReturn( pdTRUE ); @@ -438,7 +438,7 @@ void test_vReturnEthernetFrame_DuplicationSuccessCacheHit( void ) FreeRTOS_FindEndPointOnNetMask_IgnoreAndReturn( pxEndPoint ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnMemThruPtr_pxMACAddress( &xCacheMACAddress, sizeof( MACAddress_t ) ); xIsCallingFromIPTask_ExpectAndReturn( pdTRUE ); diff --git a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c index 242eb3641..e84a31ca9 100644 --- a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c +++ b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c @@ -124,7 +124,7 @@ void test_eNDGetCacheEntry_MulticastEndPoint( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eARPCacheHit, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); } /** @@ -154,7 +154,7 @@ void test_eNDGetCacheEntry_Multicast_ValidEndPoint( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eARPCacheHit, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); } /** @@ -175,7 +175,7 @@ void test_eNDGetCacheEntry_Multicast_InvalidEndPoint( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, ppxEndPoint ); - TEST_ASSERT_EQUAL( eARPCacheHit, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); } /** @@ -202,7 +202,7 @@ void test_eNDGetCacheEntry_NDCacheLookupHit_InvalidEndPoint( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, ppxEndPoint ); - TEST_ASSERT_EQUAL( eARPCacheHit, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); TEST_ASSERT_EQUAL_MEMORY( xMACAddress.ucBytes, xNDCache[ xUseEntry ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ); } @@ -235,7 +235,7 @@ void test_eNDGetCacheEntry_NDCacheLookupHit_ValidEndPoint( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eARPCacheHit, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); TEST_ASSERT_EQUAL_MEMORY( xMACAddress.ucBytes, xNDCache[ xUseEntry ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ); TEST_ASSERT_EQUAL_MEMORY( pxEndPoint, &xEndPoint2, sizeof( NetworkEndPoint_t ) ); } @@ -264,7 +264,7 @@ void test_eNDGetCacheEntry_NDCacheLookupMiss_InvalidEntry( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eARPCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); } /** @@ -290,7 +290,7 @@ void test_eNDGetCacheEntry_NDCacheLookupMiss_InvalidEntry2( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, ppxEndPoint ); - TEST_ASSERT_EQUAL( eARPCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); } /** @@ -318,7 +318,7 @@ void test_eNDGetCacheEntry_NDCacheLookupMiss_NoEntry( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eARPCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); } /** @@ -350,7 +350,7 @@ void test_eNDGetCacheEntry_NDCacheLookupMiss_NoLinkLocal( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eARPCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); } /** @@ -380,7 +380,7 @@ void test_eNDGetCacheEntry_NDCacheLookupMiss_LinkLocal( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eARPCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); } /** @@ -412,7 +412,7 @@ void test_eNDGetCacheEntry_NDCacheLookupHit_Gateway( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eARPCacheHit, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); TEST_ASSERT_EQUAL_MEMORY( xMACAddress.ucBytes, xNDCache[ xUseEntry ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ); } @@ -445,7 +445,7 @@ void test_eNDGetCacheEntry_NDCacheLookupMiss_Gateway( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eARPCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); } /** @@ -474,7 +474,7 @@ void test_eNDGetCacheEntry_NDCacheLookupMiss_NoEP( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eARPCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); } /** diff --git a/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c b/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c index 63b09a9e4..9b1c0a6a2 100644 --- a/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c +++ b/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c @@ -24,8 +24,8 @@ * * @note Look for ulIPAddress in the ND cache. If the IP address exists, copy the * associated MAC address into pxMACAddress, refresh the ND cache entry's - * age, and return eARPCacheHit. If the IP address does not exist in the ND - * cache return eARPCacheMiss. If the packet cannot be sent for any reason + * age, and return eAddrResCacheHit. If the IP address does not exist in the ND + * cache return eAddrResCacheMiss. If the packet cannot be sent for any reason * (maybe DHCP is still in process, or the addressing needs a gateway but there * isn't a gateway defined) then return eCantSendPacket. */ @@ -35,7 +35,7 @@ eARPLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, { memset( pxMACAddress, 0, sizeof( MACAddress_t ) ); - return eARPCacheHit; + return eAddrResCacheHit; } /** diff --git a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c index 745dc1a20..4783cd9a7 100644 --- a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c +++ b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c @@ -104,7 +104,7 @@ void test_prvTCPMakeSurePrepared_NotPrepared( void ) pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE; - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); ulApplicationGetNextSequenceNumber_ExpectAnyArgsAndReturn( 1000 ); prvSocketSetMSS_ExpectAnyArgs(); vTCPWindowCreate_ExpectAnyArgs(); @@ -128,7 +128,7 @@ void test_prvTCPMakeSurePrepared_Not_Ready_Error_Connect( void ) pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE; - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheMiss ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); FreeRTOS_OutputARPRequest_ExpectAnyArgs(); xResult = prvTCPMakeSurePrepared( pxSocket ); @@ -183,7 +183,7 @@ void test_prvTCPSendPacket_Syn_State( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 1000 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1234 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2345 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvTCPSendPacket( pxSocket ); @@ -222,7 +222,7 @@ void test_prvTCPSendPacket_Syn_State_NULL_Endpoint( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 1000 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1234 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2345 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvTCPSendPacket( pxSocket ); @@ -270,7 +270,7 @@ void test_prvTCPSendPacket_Syn_State_Not_Prepared( void ) pxSocket->u.xTCP.ucRepCount = 1; pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE; - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheMiss ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); FreeRTOS_OutputARPRequest_ExpectAnyArgs(); BytesSent = prvTCPSendPacket( pxSocket ); @@ -361,7 +361,7 @@ void test_prvTCPSendPacket_Other_State_Something_To_Send( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 1000 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1234 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2345 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); for( RepeatCount = 1; RepeatCount < SEND_REPEATED_COUNT; RepeatCount++ ) @@ -372,7 +372,7 @@ void test_prvTCPSendPacket_Other_State_Something_To_Send( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 1000 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1234 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2345 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); } @@ -458,7 +458,7 @@ void test_prvTCPSendRepeated_Repeat_8( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 1000 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1234 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2345 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); } @@ -517,7 +517,7 @@ void test_prvTCPReturnPacket_Null_Buffer_Null_Rx_Stream_KL( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 40, pdFALSE ); @@ -649,7 +649,7 @@ void test_prvTCPReturnPacket_Null_Socket( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( NULL, pxNetworkBuffer, 40, pdFALSE ); @@ -690,7 +690,7 @@ void test_prvTCPReturnPacket_Assert_Interface_NULL( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); @@ -729,7 +729,7 @@ void test_prvTCPReturnPacket_Assert_InterfaceOutput_NULL( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); catch_assert( prvTCPReturnPacket( NULL, pxNetworkBuffer, 40, pdFALSE ) ); @@ -769,7 +769,7 @@ void test_prvTCPReturnPacket_Null_Socket_Release_True( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( NULL, pxNetworkBuffer, 40, pdTRUE ); @@ -819,7 +819,7 @@ void test_prvTCPReturnPacket_No_KL( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 40, pdFALSE ); @@ -873,7 +873,7 @@ void test_prvTCPReturnPacket_No_KL_LocalIP( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 40, pdTRUE ); @@ -933,7 +933,7 @@ void test_prvTCPReturnPacket_No_KL_LocalIP_GT_Eth_Packet_Length( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 1000, pdTRUE ); @@ -990,7 +990,7 @@ void test_prvTCPReturnPacket_No_KL_LocalIP_ARP_Not_Hit( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheMiss ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 40, pdTRUE ); TEST_ASSERT_EQUAL( 1, NetworkInterfaceOutputFunction_Stub_Called ); @@ -1042,7 +1042,7 @@ void test_prvTCPReturnPacket_No_KL_Fin_Suppress_Rx_Stop( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 40, pdFALSE ); @@ -1093,7 +1093,7 @@ void test_prvTCPReturnPacket_No_KL_Fin_Not_Suppress_Low_Water( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 40, pdFALSE ); @@ -1144,7 +1144,7 @@ void test_prvTCPReturnPacket_No_KL_Fin_Not_Suppress_Big_Win( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 0x10000 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 40, pdFALSE ); @@ -1183,7 +1183,7 @@ void test_prvTCPPrepareConnect_Ready( void ) pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE; pxSocket->bits.bIsIPv6 = pdFALSE; - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); ulApplicationGetNextSequenceNumber_ExpectAnyArgsAndReturn( 0x11111111 ); prvSocketSetMSS_ExpectAnyArgs(); vTCPWindowCreate_ExpectAnyArgs(); @@ -1204,7 +1204,7 @@ void test_prvTCPPrepareConnect_No_Arp_Entry( void ) pxSocket->u.xTCP.ucRepCount = 0; pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE; - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheMiss ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); FreeRTOS_OutputARPRequest_ExpectAnyArgs(); Return = prvTCPPrepareConnect( pxSocket ); @@ -1223,7 +1223,7 @@ void test_prvTCPPrepareConnect_Zero_SequenceNum( void ) pxSocket->u.xTCP.ucRepCount = 0; pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE; - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); ulApplicationGetNextSequenceNumber_ExpectAnyArgsAndReturn( 0 ); Return = prvTCPPrepareConnect( pxSocket ); @@ -2158,7 +2158,7 @@ void test_prvSendData_AckMsg_Not_Null_Small_Length( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvSendData( pxSocket, &pxNetworkBuffer, 100, 40 ); @@ -2214,7 +2214,7 @@ void test_prvSendData_AckMsg_Not_Null_Same_NetBuffer_Syn_State( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvSendData( pxSocket, &pxNetworkBuffer, 100, 40 ); @@ -2269,7 +2269,7 @@ void test_prvSendData_AckMsg_Not_Null_Same_NetBuffer_Syn_State_Data_To_Send( voi FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvSendData( pxSocket, &pxNetworkBuffer, 100, 50 ); @@ -2324,7 +2324,7 @@ void test_prvSendData_AckMsg_Null_Syn_State_Data_To_Send( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvSendData( pxSocket, &pxNetworkBuffer, 100, 50 ); @@ -2380,7 +2380,7 @@ void test_prvSendData_AckMsg_Null_Syn_State_Data_To_Send_Log( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvSendData( pxSocket, &pxNetworkBuffer, 100, 50 ); @@ -2436,7 +2436,7 @@ void test_prvSendData_AckMsg_Null_Syn_State_Data_To_Send_Rcv_Zero( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvSendData( pxSocket, &pxNetworkBuffer, 0, 50 ); @@ -2502,7 +2502,7 @@ void test_prvTCPSendSpecialPacketHelper( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); Return = prvTCPSendSpecialPacketHelper( pxNetworkBuffer, tcpTCP_FLAG_ACK ); @@ -2539,7 +2539,7 @@ void test_prvTCPSendSpecialPacketHelper_flagSYN( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); Return = prvTCPSendSpecialPacketHelper( pxNetworkBuffer, tcpTCP_FLAG_ACK ); @@ -2575,7 +2575,7 @@ void test_prvTCPSendChallengeAck( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); Return = prvTCPSendChallengeAck( pxNetworkBuffer ); @@ -2610,7 +2610,7 @@ void test_prvTCPSendReset( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); Return = prvTCPSendReset( pxNetworkBuffer ); diff --git a/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c b/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c index 70aacd374..58abfbeec 100644 --- a/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c +++ b/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c @@ -133,7 +133,7 @@ void test_prvTCPReturnPacket_IPV6_SocketNULL( void ) xDescriptor.pxEndPoint->pxNetworkInterface->pfOutput = &NetworkInterfaceOutputFunction_Stub; usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( ipCORRECT_CRC ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); prvTCPReturnPacket_IPV6( pxSocket, &xDescriptor, ulLen, xReleaseAfterSend ); } @@ -215,7 +215,7 @@ void test_prvTCPReturnPacket_IPV6_Assert1( void ) xSocket.pxEndPoint->pxNetworkInterface = NULL; usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( ipCORRECT_CRC ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); catch_assert( prvTCPReturnPacket_IPV6( &xSocket, pxDescriptor, ulLen, xReleaseAfterSend ) ); } @@ -251,7 +251,7 @@ void test_prvTCPReturnPacket_IPV6_Assert2( void ) pxIPHeader = &pxTCPPacket->xIPHeader; usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( ipCORRECT_CRC ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheMiss ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); catch_assert( prvTCPReturnPacket_IPV6( &xSocket, pxDescriptor, ulLen, xReleaseAfterSend ) ); } @@ -288,7 +288,7 @@ void test_prvTCPReturnPacket_IPV6_Assert3( void ) pxIPHeader = &pxTCPPacket->xIPHeader; usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( ipCORRECT_CRC ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); catch_assert( prvTCPReturnPacket_IPV6( &xSocket, pxDescriptor, ulLen, xReleaseAfterSend ) ); } @@ -323,7 +323,7 @@ void test_prvTCPReturnPacket_IPV6_HappyPath_ReleaseAfterSend( void ) pxDescriptor->pxEndPoint->pxNetworkInterface->pfOutput = &NetworkInterfaceOutputFunction_Stub; usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( ipCORRECT_CRC ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); prvTCPReturnPacket_IPV6( &xSocket, pxDescriptor, ulLen, xReleaseAfterSend ); } @@ -358,7 +358,7 @@ void test_prvTCPReturnPacket_IPV6_HappyPath_NoReleaseAfterSend( void ) pxDescriptor->pxEndPoint->pxNetworkInterface->pfOutput = &NetworkInterfaceOutputFunction_Stub; usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( ipCORRECT_CRC ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); prvTCPReturnPacket_IPV6( &xSocket, pxDescriptor, ulLen, xReleaseAfterSend ); } @@ -374,7 +374,7 @@ void test_prvTCPPrepareConnect_IPV6_CacheMiss_NULLEP( void ) FreeRTOS_Socket_t xSocket, * pxSocket = &xSocket; BaseType_t xReturn = pdFALSE; - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheMiss ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv6_HEADER ); @@ -394,7 +394,7 @@ void test_prvTCPPrepareConnect_IPV6_CacheHit_NULLEP( void ) FreeRTOS_Socket_t xSocket, * pxSocket = &xSocket; BaseType_t xReturn = pdFALSE; - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv6_HEADER ); ulApplicationGetNextSequenceNumber_ExpectAnyArgsAndReturn( 0 ); @@ -415,7 +415,7 @@ void test_prvTCPPrepareConnect_IPV6_CacheHit_RandNumFail( void ) FreeRTOS_Socket_t xSocket, * pxSocket = &xSocket; BaseType_t xReturn = pdFALSE; - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv6_HEADER ); ulApplicationGetNextSequenceNumber_ExpectAnyArgsAndReturn( 10 ); @@ -455,7 +455,7 @@ void test_prvTCPPrepareConnect_IPV6_CacheMiss_ValidEP( void ) BaseType_t xReturn = pdFALSE; memset( pxEndPoint, 0, sizeof( NetworkEndPoint_t ) ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheMiss ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv6_HEADER ); @@ -512,7 +512,7 @@ void test_prvTCPPrepareConnect_IPV6_HappyPath_IPv4( void ) memset( &xNetworkBuffer, 0, sizeof( NetworkBufferDescriptor_t ) ); pxSocket->bits.bIsIPv6 = 0; - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv4_HEADER ); @@ -540,7 +540,7 @@ void test_prvTCPPrepareConnect_IPV6_HappyPath_IPv6( void ) memset( pxEndPoint, 0, sizeof( NetworkEndPoint_t ) ); memset( &xNetworkBuffer, 0, sizeof( NetworkBufferDescriptor_t ) ); pxSocket->bits.bIsIPv6 = 1; - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv6_HEADER ); diff --git a/test/unit-test/FreeRTOS_UDP_IPv4/FreeRTOS_UDP_IPv4_utest.c b/test/unit-test/FreeRTOS_UDP_IPv4/FreeRTOS_UDP_IPv4_utest.c index 04e860be8..e7802455d 100644 --- a/test/unit-test/FreeRTOS_UDP_IPv4/FreeRTOS_UDP_IPv4_utest.c +++ b/test/unit-test/FreeRTOS_UDP_IPv4/FreeRTOS_UDP_IPv4_utest.c @@ -1317,7 +1317,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_ICMPPingCacheHit() pxICMPPacket = ( ICMPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxICMPPacket->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxICMPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1350,7 +1350,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHit() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1390,7 +1390,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHitLessBufferLength() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1429,7 +1429,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHitDiffEndPoint() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxDifferentEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1466,7 +1466,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHitLLMNR() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1505,7 +1505,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHitMDNS() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1545,7 +1545,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHitNoInterface() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1584,7 +1584,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHitInterfaceNoOutput() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1618,7 +1618,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHitNoEndPoint() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1652,7 +1652,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheMissEndPointFound() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheMiss ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheMiss ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPointNull ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1685,7 +1685,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheMissEndPointNotFound() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheMiss ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheMiss ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPointNull ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); diff --git a/test/unit-test/FreeRTOS_UDP_IPv6/FreeRTOS_UDP_IPv6_utest.c b/test/unit-test/FreeRTOS_UDP_IPv6/FreeRTOS_UDP_IPv6_utest.c index 9ac618158..9495fc03b 100644 --- a/test/unit-test/FreeRTOS_UDP_IPv6/FreeRTOS_UDP_IPv6_utest.c +++ b/test/unit-test/FreeRTOS_UDP_IPv6/FreeRTOS_UDP_IPv6_utest.c @@ -1055,7 +1055,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_ICMPPingCacheHit() pxICMPv6Packet = ( ICMPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxICMPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheHit ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxICMPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); usGenerateProtocolChecksum_ExpectAndReturn( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength, pdTRUE, ipCORRECT_CRC ); @@ -1086,7 +1086,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_UDPv6CacheHit() pxUDPv6Packet = ( UDPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheHit ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); usGenerateProtocolChecksum_ExpectAndReturn( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength, pdTRUE, ipCORRECT_CRC ); @@ -1126,7 +1126,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_UDPv6CacheHitLessBufferLength() pxUDPv6Packet = ( UDPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheHit ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); usGenerateProtocolChecksum_ExpectAndReturn( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength, pdTRUE, ipCORRECT_CRC ); @@ -1161,7 +1161,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_UDPv6CacheHitNoEndPoint() pxUDPv6Packet = ( UDPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheHit ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); vReleaseNetworkBufferAndDescriptor_Expect( pxNetworkBuffer ); @@ -1195,7 +1195,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_UDPv6CacheMissBothGlobal() pxUDPv6Packet = ( UDPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheMiss ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheMiss ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPointNull ); xIPv6_GetIPType_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), eIPv6_Global ); @@ -1227,7 +1227,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_UDPv6CacheMissButEndPointFound() pxUDPv6Packet = ( UDPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheMiss ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheMiss ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); @@ -1255,7 +1255,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_UDPv6CacheMissDifferentIPType() pxUDPv6Packet = ( UDPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheMiss ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheMiss ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPointNull ); xIPv6_GetIPType_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), eIPv6_LinkLocal ); @@ -1288,7 +1288,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_UDPv6CacheMissDifferentIPType2() pxUDPv6Packet = ( UDPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eARPCacheMiss ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheMiss ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPointNull ); xIPv6_GetIPType_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), eIPv6_Global ); diff --git a/tools/tcp_utilities/plus_tcp_demo_cli.c b/tools/tcp_utilities/plus_tcp_demo_cli.c index cf40f7903..7cada8bb9 100644 --- a/tools/tcp_utilities/plus_tcp_demo_cli.c +++ b/tools/tcp_utilities/plus_tcp_demo_cli.c @@ -285,11 +285,11 @@ static const char * pcARPReturnType( eARPLookupResult_t eResult ) switch( eResult ) { - case eARPCacheMiss: + case eAddrResCacheMiss: pcReturn = "Miss"; break; - case eARPCacheHit: + case eAddrResCacheHit: pcReturn = "Hit"; break; @@ -453,7 +453,7 @@ static void handle_arpq( char * pcBuffer ) { CommandOptions_t xOptions; char * ptr = pcBuffer; - eARPLookupResult_t eResult = eARPCacheMiss; + eARPLookupResult_t eResult = eAddrResCacheMiss; uint32_t ulIPAddress; uint32_t ulLookUpIP; MACAddress_t xMACAddress; @@ -537,7 +537,7 @@ static void handle_arpq( char * pcBuffer ) break; } - if( ( eResult == eARPCacheMiss ) && ( pxEndPoint != NULL ) ) + if( ( eResult == eAddrResCacheMiss ) && ( pxEndPoint != NULL ) ) { size_t uxNeededSize = sizeof( ARPPacket_t ); From 9d5ec4994fa945b8c19d13d59328559cc0081100 Mon Sep 17 00:00:00 2001 From: Holden Date: Thu, 1 Aug 2024 14:40:24 -0400 Subject: [PATCH 06/25] Changed resolution enum name --- source/FreeRTOS_ARP.c | 64 +++++++++--------- source/FreeRTOS_IP.c | 2 +- source/FreeRTOS_ND.c | 44 ++++++------- source/FreeRTOS_TCP_Transmission_IPv4.c | 4 +- source/FreeRTOS_TCP_Transmission_IPv6.c | 6 +- source/FreeRTOS_UDP_IPv4.c | 10 +-- source/FreeRTOS_UDP_IPv6.c | 12 ++-- source/include/FreeRTOS_ARP.h | 10 +-- source/include/FreeRTOS_ND.h | 8 +-- source/include/FreeRTOS_Routing.h | 8 +-- .../TCPReturnPacket_harness.c | 2 +- .../FreeRTOS_ARP/FreeRTOS_ARP_utest.c | 32 ++++----- .../FreeRTOS_IP_DiffConfig_utest.c | 4 +- .../unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c | 26 ++++---- .../unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c | 8 +-- .../FreeRTOS_TCP_Transmission_utest.c | 66 +++++++++---------- .../FreeRTOS_TCP_Transmission_IPv6_utest.c | 28 ++++---- .../FreeRTOS_UDP_IPv4_utest.c | 24 +++---- .../FreeRTOS_UDP_IPv6_utest.c | 18 ++--- tools/tcp_utilities/plus_tcp_demo_cli.c | 10 +-- 20 files changed, 193 insertions(+), 193 deletions(-) diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index 6b93b9e4e..6e7f38704 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -94,11 +94,11 @@ /* * Lookup an MAC address in the ARP cache from the IP address. */ - static eAddrResLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, + static eResolutionLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ); - static eAddrResLookupResult_t eARPGetCacheEntryGateWay( uint32_t * pulIPAddress, + static eResolutionLookupResult_t eARPGetCacheEntryGateWay( uint32_t * pulIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ); @@ -318,7 +318,7 @@ /* The request is a Gratuitous ARP message. * Refresh the entry if it already exists. */ /* Determine the ARP cache status for the requested IP address. */ - if( eARPGetCacheEntry( &( ulSenderProtocolAddress ), &( xHardwareAddress ), &( pxCachedEndPoint ) ) == eAddrResCacheHit ) + if( eARPGetCacheEntry( &( ulSenderProtocolAddress ), &( xHardwareAddress ), &( pxCachedEndPoint ) ) == eResolutionCacheHit ) { /* Check if the endpoint matches with the one present in the ARP cache */ if( pxCachedEndPoint == pxTargetEndPoint ) @@ -819,14 +819,14 @@ * @param[in] pxMACAddress The MAC-address of the entry of interest. * @param[out] pulIPAddress set to the IP-address found, or unchanged when not found. * - * @return Either eAddrResCacheMiss or eAddrResCacheHit. + * @return Either eResolutionCacheMiss or eResolutionCacheHit. */ - eAddrResLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, + eResolutionLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, uint32_t * pulIPAddress, struct xNetworkInterface ** ppxInterface ) { BaseType_t x; - eAddrResLookupResult_t eReturn = eResolutionCacheMiss; + eResolutionLookupResult_t eReturn = eResolutionCacheMiss; configASSERT( pxMACAddress != NULL ); configASSERT( pulIPAddress != NULL ); @@ -851,7 +851,7 @@ *( ppxInterface ) = xARPCache[ x ].pxEndPoint->pxNetworkInterface; } - eReturn = eAddrResCacheHit; + eReturn = eResolutionCacheHit; break; } } @@ -871,17 +871,17 @@ * @param[out] ppxEndPoint Pointer to the end-point of the gateway will be stored. * * @return If the IP address exists, copy the associated MAC address into pxMACAddress, - * refresh the ARP cache entry's age, and return eAddrResCacheHit. If the IP - * address does not exist in the ARP cache return eAddrResCacheMiss. If the packet + * refresh the ARP cache entry's age, and return eResolutionCacheHit. If the IP + * address does not exist in the ARP cache return eResolutionCacheMiss. If the packet * cannot be sent for any reason (maybe DHCP is still in process, or the * addressing needs a gateway but there isn't a gateway defined) then return - * eCantSendPacket. + * eResolutionFailed. */ - eAddrResLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, + eResolutionLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ) { - eAddrResLookupResult_t eReturn; + eResolutionLookupResult_t eReturn; uint32_t ulAddressToLookup; NetworkEndPoint_t * pxEndPoint = NULL; @@ -898,7 +898,7 @@ /* Get the lowest 23 bits of the IP-address. */ vSetMultiCastIPv4MacAddress( ulAddressToLookup, pxMACAddress ); - eReturn = eCantSendPacket; + eReturn = eResolutionFailed; pxEndPoint = FreeRTOS_FirstEndPoint( NULL ); for( ; @@ -909,7 +909,7 @@ { /* For multi-cast, use the first IPv4 end-point. */ *( ppxEndPoint ) = pxEndPoint; - eReturn = eAddrResCacheHit; + eReturn = eResolutionCacheHit; break; } } @@ -925,7 +925,7 @@ *( ppxEndPoint ) = pxEndPoint; } - eReturn = eAddrResCacheHit; + eReturn = eResolutionCacheHit; } else { @@ -944,11 +944,11 @@ * stored to the buffer provided. * @param[out] ppxEndPoint The end-point of the gateway will be copy to the pointee. */ - static eAddrResLookupResult_t eARPGetCacheEntryGateWay( uint32_t * pulIPAddress, + static eResolutionLookupResult_t eARPGetCacheEntryGateWay( uint32_t * pulIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ) { - eAddrResLookupResult_t eReturn = eAddrResCacheMiss; + eResolutionLookupResult_t eReturn = eResolutionCacheMiss; uint32_t ulAddressToLookup = *( pulIPAddress ); NetworkEndPoint_t * pxEndPoint; uint32_t ulOriginal = *pulIPAddress; @@ -963,7 +963,7 @@ #if ( ipconfigARP_STORES_REMOTE_ADDRESSES == 1 ) eReturn = prvCacheLookup( ulAddressToLookup, pxMACAddress, ppxEndPoint ); - if( eReturn == eAddrResCacheHit ) + if( eReturn == eResolutionCacheHit ) { /* The stack is configured to store 'remote IP addresses', i.e. addresses * belonging to a different the netmask. prvCacheLookup() returned a hit, so @@ -996,24 +996,24 @@ } #if ( ipconfigARP_STORES_REMOTE_ADDRESSES == 1 ) - if( eReturn == eAddrResCacheMiss ) + if( eReturn == eResolutionCacheMiss ) #endif { if( ulAddressToLookup == 0U ) { /* The address is not on the local network, and there is not a * router. */ - eReturn = eCantSendPacket; + eReturn = eResolutionFailed; } else { eReturn = prvCacheLookup( ulAddressToLookup, pxMACAddress, ppxEndPoint ); - if( ( eReturn != eAddrResCacheHit ) || ( ulOriginal != ulAddressToLookup ) ) + if( ( eReturn != eResolutionCacheHit ) || ( ulOriginal != ulAddressToLookup ) ) { FreeRTOS_debug_printf( ( "ARP %xip %s using %xip\n", ( unsigned ) FreeRTOS_ntohl( ulOriginal ), - ( eReturn == eAddrResCacheHit ) ? "hit" : "miss", + ( eReturn == eResolutionCacheHit ) ? "hit" : "miss", ( unsigned ) FreeRTOS_ntohl( ulAddressToLookup ) ) ); } @@ -1036,15 +1036,15 @@ * the IP address will be stored. * @param[in,out] ppxEndPoint a pointer to the end-point will be stored. * - * @return When the IP-address is found: eAddrResCacheHit, when not found: eAddrResCacheMiss, - * and when waiting for a ARP reply: eCantSendPacket. + * @return When the IP-address is found: eResolutionCacheHit, when not found: eResolutionCacheMiss, + * and when waiting for a ARP reply: eResolutionFailed. */ - static eAddrResLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, + static eResolutionLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ) { BaseType_t x; - eAddrResLookupResult_t eReturn = eAddrResCacheMiss; + eResolutionLookupResult_t eReturn = eResolutionCacheMiss; /* Loop through each entry in the ARP cache. */ for( x = 0; x < ipconfigARP_CACHE_ENTRIES; x++ ) @@ -1057,7 +1057,7 @@ if( xARPCache[ x ].ucValid == ( uint8_t ) pdFALSE ) { /* This entry is waiting an ARP reply, so is not valid. */ - eReturn = eCantSendPacket; + eReturn = eResolutionFailed; } else { @@ -1065,7 +1065,7 @@ ( void ) memcpy( pxMACAddress->ucBytes, xARPCache[ x ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ); /* ppxEndPoint != NULL was tested in the only caller eARPGetCacheEntry(). */ *( ppxEndPoint ) = xARPCache[ x ].pxEndPoint; - eReturn = eAddrResCacheHit; + eReturn = eResolutionCacheHit; } break; @@ -1274,7 +1274,7 @@ BaseType_t xResult = -pdFREERTOS_ERRNO_EADDRNOTAVAIL; TimeOut_t xTimeOut; MACAddress_t xMACAddress; - eAddrResLookupResult_t xLookupResult; + eResolutionLookupResult_t xLookupResult; NetworkEndPoint_t * pxEndPoint; size_t uxSendCount = ipconfigMAX_ARP_RETRANSMISSIONS; uint32_t ulIPAddressCopy = ulIPAddress; @@ -1284,7 +1284,7 @@ xLookupResult = eARPGetCacheEntry( &( ulIPAddressCopy ), &( xMACAddress ), &( pxEndPoint ) ); - if( xLookupResult == eAddrResCacheMiss ) + if( xLookupResult == eResolutionCacheMiss ) { const TickType_t uxSleepTime = pdMS_TO_TICKS( 250U ); @@ -1300,7 +1300,7 @@ xLookupResult = eARPGetCacheEntry( &( ulIPAddressCopy ), &( xMACAddress ), &( pxEndPoint ) ); if( ( xTaskCheckForTimeOut( &( xTimeOut ), &( uxTicksToWait ) ) == pdTRUE ) || - ( xLookupResult != eAddrResCacheMiss ) ) + ( xLookupResult != eResolutionCacheMiss ) ) { break; } @@ -1310,7 +1310,7 @@ } } - if( xLookupResult == eAddrResCacheHit ) + if( xLookupResult == eResolutionCacheHit ) { xResult = 0; } diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index afb40ade4..2ca7ba98e 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -2101,7 +2101,7 @@ void vReturnEthernetFrame( NetworkBufferDescriptor_t * pxNetworkBuffer, #if ( ipconfigUSE_IPv4 != 0 ) MACAddress_t xMACAddress; - eAddrResLookupResult_t eResult; + eResolutionLookupResult_t eResult; uint32_t ulDestinationIPAddress = 0U; #endif /* ( ipconfigUSE_IPv4 != 0 ) */ diff --git a/source/FreeRTOS_ND.c b/source/FreeRTOS_ND.c index 62612fba3..d187681b9 100644 --- a/source/FreeRTOS_ND.c +++ b/source/FreeRTOS_ND.c @@ -78,12 +78,12 @@ const uint8_t pcLOCAL_ALL_NODES_MULTICAST_MAC[ ipMAC_ADDRESS_LENGTH_BYTES ] = { 0x33U, 0x33U, 0x00U, 0x00U, 0x00U, 0x01U }; /** @brief See if the MAC-address can be resolved because it is a multi-cast address. */ - static eAddrResLookupResult_t prvMACResolve( const IPv6_Address_t * pxAddressToLookup, + static eResolutionLookupResult_t prvMACResolve( const IPv6_Address_t * pxAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ); /** @brief Lookup an MAC address in the ND cache from the IP address. */ - static eAddrResLookupResult_t prvNDCacheLookup( const IPv6_Address_t * pxAddressToLookup, + static eResolutionLookupResult_t prvNDCacheLookup( const IPv6_Address_t * pxAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ); @@ -140,13 +140,13 @@ * @param[out] pxMACAddress The resulting MAC-address is stored here. * @param[out] ppxEndPoint A pointer to an end-point pointer where the end-point will be stored. * - * @return An enum, either eAddrResCacheHit or eAddrResCacheMiss. + * @return An enum, either eResolutionCacheHit or eResolutionCacheMiss. */ - static eAddrResLookupResult_t prvMACResolve( const IPv6_Address_t * pxAddressToLookup, + static eResolutionLookupResult_t prvMACResolve( const IPv6_Address_t * pxAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ) { - eAddrResLookupResult_t eReturn; + eResolutionLookupResult_t eReturn; /* Mostly used multi-cast address is ff02::. */ if( xIsIPv6AllowedMulticast( pxAddressToLookup ) != pdFALSE ) @@ -158,12 +158,12 @@ *ppxEndPoint = pxFindLocalEndpoint(); } - eReturn = eAddrResCacheHit; + eReturn = eResolutionCacheHit; } else { /* Not a multicast IP address. */ - eReturn = eAddrResCacheMiss; + eReturn = eResolutionCacheMiss; } return eReturn; @@ -178,30 +178,30 @@ * @param[out] pxMACAddress The MAC-address found. * @param[out] ppxEndPoint A pointer to a pointer to an end-point, where the end-point will be stored. * - * @return An enum which says whether the address was found: eAddrResCacheHit or eAddrResCacheMiss. + * @return An enum which says whether the address was found: eResolutionCacheHit or eResolutionCacheMiss. */ - eAddrResLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, + eResolutionLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ) { - eAddrResLookupResult_t eReturn; + eResolutionLookupResult_t eReturn; NetworkEndPoint_t * pxEndPoint; /* Multi-cast addresses can be resolved immediately. */ eReturn = prvMACResolve( pxIPAddress, pxMACAddress, ppxEndPoint ); - if( eReturn == eAddrResCacheMiss ) + if( eReturn == eResolutionCacheMiss ) { /* See if the IP-address has an entry in the cache. */ eReturn = prvNDCacheLookup( pxIPAddress, pxMACAddress, ppxEndPoint ); } - if( eReturn == eAddrResCacheMiss ) + if( eReturn == eResolutionCacheMiss ) { FreeRTOS_printf( ( "eNDGetCacheEntry: lookup %pip miss\n", ( void * ) pxIPAddress->ucBytes ) ); } - if( eReturn == eAddrResCacheMiss ) + if( eReturn == eResolutionCacheMiss ) { IPv6_Type_t eIPType = xIPv6_GetIPType( pxIPAddress ); @@ -236,7 +236,7 @@ } FreeRTOS_printf( ( "eNDGetCacheEntry: LinkLocal %pip \"%s\"\n", ( void * ) pxIPAddress->ucBytes, - ( eReturn == eAddrResCacheHit ) ? "hit" : "miss" ) ); + ( eReturn == eResolutionCacheHit ) ? "hit" : "miss" ) ); } else { @@ -446,14 +446,14 @@ * @param[out] pxMACAddress The resulting MAC-address will be stored here. * @param[out] ppxEndPoint A pointer to a pointer to an end-point, where the end-point will be stored. * - * @return An enum: either eAddrResCacheHit or eAddrResCacheMiss. + * @return An enum: either eResolutionCacheHit or eResolutionCacheMiss. */ - static eAddrResLookupResult_t prvNDCacheLookup( const IPv6_Address_t * pxAddressToLookup, + static eResolutionLookupResult_t prvNDCacheLookup( const IPv6_Address_t * pxAddressToLookup, MACAddress_t * const pxMACAddress, NetworkEndPoint_t ** ppxEndPoint ) { BaseType_t x; - eAddrResLookupResult_t eReturn = eAddrResCacheMiss; + eResolutionLookupResult_t eReturn = eResolutionCacheMiss; /* For each entry in the ND cache table. */ for( x = 0; x < ipconfigND_CACHE_ENTRIES; x++ ) @@ -465,7 +465,7 @@ else if( memcmp( xNDCache[ x ].xIPAddress.ucBytes, pxAddressToLookup->ucBytes, ipSIZE_OF_IPv6_ADDRESS ) == 0 ) { ( void ) memcpy( pxMACAddress->ucBytes, xNDCache[ x ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ); - eReturn = eAddrResCacheHit; + eReturn = eResolutionCacheHit; if( ppxEndPoint != NULL ) { @@ -489,7 +489,7 @@ } } - if( eReturn == eAddrResCacheMiss ) + if( eReturn == eResolutionCacheMiss ) { FreeRTOS_printf( ( "prvNDCacheLookup %pip Miss\n", ( void * ) pxAddressToLookup->ucBytes ) ); @@ -1366,14 +1366,14 @@ { MACAddress_t xMACAddress; NetworkEndPoint_t * pxEndPoint; - eAddrResLookupResult_t eResult; + eResolutionLookupResult_t eResult; char pcName[ 80 ]; ( void ) memset( &( pcName ), 0, sizeof( pcName ) ); eResult = eNDGetCacheEntry( pxIPAddress, &xMACAddress, &pxEndPoint ); - FreeRTOS_printf( ( "xCheckRequiresNDResolution: eResult %s with EP %s\n", ( eResult == eAddrResCacheMiss ) ? "Miss" : ( eResult == eAddrResCacheHit ) ? "Hit" : "Error", pcEndpointName( pxEndPoint, pcName, sizeof pcName ) ) ); + FreeRTOS_printf( ( "xCheckRequiresNDResolution: eResult %s with EP %s\n", ( eResult == eResolutionCacheMiss ) ? "Miss" : ( eResult == eResolutionCacheHit ) ? "Hit" : "Error", pcEndpointName( pxEndPoint, pcName, sizeof pcName ) ) ); - if( eResult == eAddrResCacheMiss ) + if( eResult == eResolutionCacheMiss ) { NetworkBufferDescriptor_t * pxTempBuffer; size_t uxNeededSize; diff --git a/source/FreeRTOS_TCP_Transmission_IPv4.c b/source/FreeRTOS_TCP_Transmission_IPv4.c index 4f83eefa8..2dfede55c 100644 --- a/source/FreeRTOS_TCP_Transmission_IPv4.c +++ b/source/FreeRTOS_TCP_Transmission_IPv4.c @@ -99,7 +99,7 @@ void prvTCPReturnPacket_IPV4( FreeRTOS_Socket_t * pxSocket, void * pvCopyDest = NULL; const size_t uxIPHeaderSize = ipSIZE_OF_IPv4_HEADER; uint32_t ulDestinationIPAddress; - eAddrResLookupResult_t eResult; + eResolutionLookupResult_t eResult; NetworkEndPoint_t * pxEndPoint = NULL; do @@ -355,7 +355,7 @@ BaseType_t prvTCPPrepareConnect_IPV4( FreeRTOS_Socket_t * pxSocket ) break; /* We can now prepare the SYN packet. */ case eResolutionCacheMiss: /* An ARP table lookup did not find a valid entry. */ - case eCantSendPacket: /* There is no IP address, or an ARP is still in progress. */ + case eResolutionFailed: /* There is no IP address, or an ARP is still in progress. */ default: /* Count the number of times it could not find the ARP address. */ pxSocket->u.xTCP.ucRepCount++; diff --git a/source/FreeRTOS_TCP_Transmission_IPv6.c b/source/FreeRTOS_TCP_Transmission_IPv6.c index dd4bf291d..ec81cf8dd 100644 --- a/source/FreeRTOS_TCP_Transmission_IPv6.c +++ b/source/FreeRTOS_TCP_Transmission_IPv6.c @@ -150,7 +150,7 @@ void prvTCPReturnPacket_IPV6( FreeRTOS_Socket_t * pxSocket, if( pxNetworkBuffer != NULL ) /* LCOV_EXCL_BR_LINE the 2nd branch will never be reached */ #endif { - eAddrResLookupResult_t eResult; + eResolutionLookupResult_t eResult; NetworkInterface_t * pxInterface; configASSERT( pxNetworkBuffer->pucEthernetBuffer != NULL ); @@ -318,7 +318,7 @@ BaseType_t prvTCPPrepareConnect_IPV6( FreeRTOS_Socket_t * pxSocket ) { TCPPacket_IPv6_t * pxTCPPacket = NULL; IPHeader_IPv6_t * pxIPHeader = NULL; - eAddrResLookupResult_t eReturned; + eResolutionLookupResult_t eReturned; IP_Address_t xRemoteIP; MACAddress_t xEthAddress; BaseType_t xReturn = pdTRUE; @@ -355,7 +355,7 @@ BaseType_t prvTCPPrepareConnect_IPV6( FreeRTOS_Socket_t * pxSocket ) break; /* We can now prepare the SYN packet. */ case eResolutionCacheMiss: /* An ND table lookup did not find a valid entry. */ - case eCantSendPacket: /* There is no IP address, or an ND is still in progress. */ + case eResolutionFailed: /* There is no IP address, or an ND is still in progress. */ default: /* Count the number of times it could not find the ND address. */ pxSocket->u.xTCP.ucRepCount++; diff --git a/source/FreeRTOS_UDP_IPv4.c b/source/FreeRTOS_UDP_IPv4.c index dd35aad36..2aedc7470 100644 --- a/source/FreeRTOS_UDP_IPv4.c +++ b/source/FreeRTOS_UDP_IPv4.c @@ -76,7 +76,7 @@ void vProcessGeneratedUDPPacket_IPv4( NetworkBufferDescriptor_t * const pxNetwor { UDPPacket_t * pxUDPPacket; IPHeader_t * pxIPHeader; - eAddrResLookupResult_t eReturned; + eResolutionLookupResult_t eReturned; uint32_t ulIPAddress = pxNetworkBuffer->xIPAddress.ulIP_IPv4; NetworkEndPoint_t * pxEndPoint = pxNetworkBuffer->pxEndPoint; size_t uxPayloadSize; @@ -110,7 +110,7 @@ void vProcessGeneratedUDPPacket_IPv4( NetworkBufferDescriptor_t * const pxNetwor pxNetworkBuffer->pxEndPoint = pxEndPoint; } - if( eReturned != eCantSendPacket ) + if( eReturned != eResolutionFailed ) { if( eReturned == eResolutionCacheHit ) { @@ -278,7 +278,7 @@ void vProcessGeneratedUDPPacket_IPv4( NetworkBufferDescriptor_t * const pxNetwor if( pxNetworkBuffer->pxEndPoint == NULL ) { - eReturned = eCantSendPacket; + eReturned = eResolutionFailed; } else { @@ -290,11 +290,11 @@ void vProcessGeneratedUDPPacket_IPv4( NetworkBufferDescriptor_t * const pxNetwor { /* The lookup indicated that an ARP request has already been * sent out for the queried IP address. */ - eReturned = eCantSendPacket; + eReturned = eResolutionFailed; } } - if( eReturned != eCantSendPacket ) + if( eReturned != eResolutionFailed ) { /* The network driver is responsible for freeing the network buffer * after the packet has been sent. */ diff --git a/source/FreeRTOS_UDP_IPv6.c b/source/FreeRTOS_UDP_IPv6.c index 52a250b0c..3be2f3ffa 100644 --- a/source/FreeRTOS_UDP_IPv6.c +++ b/source/FreeRTOS_UDP_IPv6.c @@ -121,10 +121,10 @@ static NetworkEndPoint_t * pxGetEndpoint( BaseType_t xIPType, * @param[out] pxLostBuffer The pointee will be set to true in case the network packet got released * ( the ownership was taken ). */ -static eAddrResLookupResult_t prvStartLookup( NetworkBufferDescriptor_t * const pxNetworkBuffer, +static eResolutionLookupResult_t prvStartLookup( NetworkBufferDescriptor_t * const pxNetworkBuffer, BaseType_t * pxLostBuffer ) { - eAddrResLookupResult_t eReturned = eResolutionCacheMiss; + eResolutionLookupResult_t eReturned = eResolutionCacheMiss; FreeRTOS_printf( ( "Looking up %pip with%s end-point\n", ( void * ) pxNetworkBuffer->xIPAddress.xIP_IPv6.ucBytes, @@ -161,7 +161,7 @@ void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetwor { UDPPacket_IPv6_t * pxUDPPacket_IPv6; IPHeader_IPv6_t * pxIPHeader_IPv6; - eAddrResLookupResult_t eReturned; + eResolutionLookupResult_t eReturned; size_t uxPayloadSize; /* memcpy() helper variables for MISRA Rule 21.15 compliance*/ NetworkInterface_t * pxInterface = NULL; @@ -198,7 +198,7 @@ void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetwor eReturned = eNDGetCacheEntry( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPPacket_IPv6->xEthernetHeader.xDestinationAddress ), &( pxEndPoint ) ); - if( eReturned != eCantSendPacket ) + if( eReturned != eResolutionFailed ) { if( eReturned == eResolutionCacheHit ) { @@ -310,7 +310,7 @@ void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetwor { /* The lookup indicated that an ND Solicitation has already been * sent out for the queried IP address. */ - eReturned = eCantSendPacket; + eReturned = eResolutionFailed; } } @@ -318,7 +318,7 @@ void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetwor { /* An ND solicitation has been sent. */ } - else if( eReturned != eCantSendPacket ) + else if( eReturned != eResolutionFailed ) { /* The network driver is responsible for freeing the network buffer * after the packet has been sent. */ diff --git a/source/include/FreeRTOS_ARP.h b/source/include/FreeRTOS_ARP.h index c1a2b96a5..8d343913d 100644 --- a/source/include/FreeRTOS_ARP.h +++ b/source/include/FreeRTOS_ARP.h @@ -114,19 +114,19 @@ BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetw /* * Look for ulIPAddress in the ARP cache. If the IP address exists, copy the * associated MAC address into pxMACAddress, refresh the ARP cache entry's - * age, and return eAddrResCacheHit. If the IP address does not exist in the ARP - * cache return eAddrResCacheMiss. If the packet cannot be sent for any reason + * age, and return eResolutionCacheHit. If the IP address does not exist in the ARP + * cache return eResolutionCacheMiss. If the packet cannot be sent for any reason * (maybe DHCP is still in process, or the addressing needs a gateway but there - * isn't a gateway defined) then return eCantSendPacket. + * isn't a gateway defined) then return eResolutionFailed. */ -eAddrResLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, +eResolutionLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ); #if ( ipconfigUSE_ARP_REVERSED_LOOKUP != 0 ) /* Lookup an IP-address if only the MAC-address is known */ - eAddrResLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, + eResolutionLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, uint32_t * pulIPAddress, struct xNetworkInterface ** ppxInterface ); diff --git a/source/include/FreeRTOS_ND.h b/source/include/FreeRTOS_ND.h index 57ad004bb..5f1771eee 100644 --- a/source/include/FreeRTOS_ND.h +++ b/source/include/FreeRTOS_ND.h @@ -88,12 +88,12 @@ * * @note Look for ulIPAddress in the ND cache. If the IP address exists, copy the * associated MAC address into pxMACAddress, refresh the ND cache entry's - * age, and return eAddrResCacheHit. If the IP address does not exist in the ND - * cache return eAddrResCacheMiss. If the packet cannot be sent for any reason + * age, and return eResolutionCacheHit. If the IP address does not exist in the ND + * cache return eResolutionCacheMiss. If the packet cannot be sent for any reason * (maybe DHCP is still in process, or the addressing needs a gateway but there - * isn't a gateway defined) then return eCantSendPacket. + * isn't a gateway defined) then return eResolutionFailed. */ - eAddrResLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, + eResolutionLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ); diff --git a/source/include/FreeRTOS_Routing.h b/source/include/FreeRTOS_Routing.h index 7e1468a04..1d8f285f2 100644 --- a/source/include/FreeRTOS_Routing.h +++ b/source/include/FreeRTOS_Routing.h @@ -395,10 +395,10 @@ typedef enum { - eAddrResCacheMiss = 0, /* 0 A cache lookup did not find a valid entry. */ - eAddrResCacheHit, /* 1 A cache lookup found a valid entry. */ - eCantSendPacket /* 2 There is no IP address, or a resolution is still in progress, so the packet cannot be sent. */ - } eAddrResLookupResult_t; + eResolutionCacheMiss = 0, /* 0 A cache lookup did not find a valid entry. */ + eResolutionCacheHit, /* 1 A cache lookup found a valid entry. */ + eResolutionFailed /* 2 There is no IP address, or a resolution is still in progress, so the packet cannot be sent. */ + } eResolutionLookupResult_t; #ifdef __cplusplus } /* extern "C" */ diff --git a/test/cbmc/proofs/TCP/prvTCPReturnPacket/TCPReturnPacket_harness.c b/test/cbmc/proofs/TCP/prvTCPReturnPacket/TCPReturnPacket_harness.c index 3c7682e8f..fa4097c12 100644 --- a/test/cbmc/proofs/TCP/prvTCPReturnPacket/TCPReturnPacket_harness.c +++ b/test/cbmc/proofs/TCP/prvTCPReturnPacket/TCPReturnPacket_harness.c @@ -148,7 +148,7 @@ eARPLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, __CPROVER_assert( pulIPAddress != NULL, "The pulIPAddress cannot be NULL" ); __CPROVER_assert( pxMACAddress != NULL, "The pxMACAddress cannot be NULL" ); - if( eReturn == eAddrResCacheHit ) + if( eReturn == eResolutionCacheHit ) { /* If its a cache hit, update ppxEndPoint with a valid endpoint. */ struct xNetworkEndPoint * pxEndPoint = ( NetworkEndPoint_t * ) safeMalloc( sizeof( NetworkEndPoint_t ) ); diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c index 80f8b5e90..ce017b622 100644 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c @@ -1950,7 +1950,7 @@ void test_eARPGetCacheEntryByMac_NullInterface( void ) } eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, NULL ); - TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheMiss, eResult ); TEST_ASSERT_EQUAL( 0x12345678, ulIPAddress ); /* =================================================== */ } @@ -1972,7 +1972,7 @@ void test_eARPGetCacheEntryByMac_NoMatchingEntries( void ) } eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &xInterface ); - TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheMiss, eResult ); TEST_ASSERT_EQUAL( 0x12345678, ulIPAddress ); /* =================================================== */ } @@ -1997,16 +1997,16 @@ void test_eARPGetCacheEntryByMac_OneMatchingEntry( void ) memset( xARPCache[ ulEntryToTest ].xMACAddress.ucBytes, 0x22, sizeof( xMACAddress.ucBytes ) ); xARPCache[ ulEntryToTest ].ulIPAddress = 0xAABBCCEE; eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &xInterface ); - TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); TEST_ASSERT_EQUAL( xARPCache[ ulEntryToTest ].ulIPAddress, ulIPAddress ); /* =================================================== */ eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, NULL ); - TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); TEST_ASSERT_EQUAL( xARPCache[ ulEntryToTest ].ulIPAddress, ulIPAddress ); /* =================================================== */ xARPCache[ ulEntryToTest ].pxEndPoint = NULL; eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &xInterface ); - TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); TEST_ASSERT_EQUAL( xARPCache[ ulEntryToTest ].ulIPAddress, ulIPAddress ); /* =================================================== */ } @@ -2038,7 +2038,7 @@ void test_eARPGetCacheEntry_IPMatchesBroadcastAddr( void ) FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL_MESSAGE( eAddrResCacheHit, eResult, "Test 3" ); + TEST_ASSERT_EQUAL_MESSAGE( eResolutionCacheHit, eResult, "Test 3" ); TEST_ASSERT_EQUAL( pxEndPoint, &xEndPoint ); TEST_ASSERT_EQUAL_MEMORY_MESSAGE( &xBroadcastMACAddress, &xMACAddress, sizeof( xMACAddress ), "Test 3" ); /* =================================================== */ @@ -2060,7 +2060,7 @@ void test_eARPGetCacheEntry_IPMatchesBroadcastAddr_NullEndPointOnNetMask( void ) FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); TEST_ASSERT_NOT_EQUAL( pxEndPoint, &xEndPoint ); /* =================================================== */ } @@ -2082,7 +2082,7 @@ void test_eARPGetCacheEntry_MultiCastAddr( void ) eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eCantSendPacket, eResult ); + TEST_ASSERT_EQUAL( eResolutionFailed, eResult ); TEST_ASSERT_NOT_EQUAL( pxEndPoint, &xEndPoint ); /* =================================================== */ @@ -2095,7 +2095,7 @@ void test_eARPGetCacheEntry_MultiCastAddr( void ) eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eCantSendPacket, eResult ); + TEST_ASSERT_EQUAL( eResolutionFailed, eResult ); TEST_ASSERT_NOT_EQUAL( pxEndPoint, &xEndPoint ); /* =================================================== */ } @@ -2116,7 +2116,7 @@ void test_eARPGetCacheEntry_IPMatchesOtherBroadcastAddr( void ) xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL_MESSAGE( eAddrResCacheHit, eResult, "Test 3" ); + TEST_ASSERT_EQUAL_MESSAGE( eResolutionCacheHit, eResult, "Test 3" ); TEST_ASSERT_EQUAL_MEMORY_MESSAGE( &xBroadcastMACAddress, &xMACAddress, sizeof( xMACAddress ), "Test 3" ); TEST_ASSERT_EQUAL( pxEndPoint, &xEndPoint ); /* =================================================== */ @@ -2149,7 +2149,7 @@ void test_eARPGetCacheEntry_MatchingInvalidEntry( void ) FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( &xEndPoint ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL_MESSAGE( eCantSendPacket, eResult, "Test 6" ); + TEST_ASSERT_EQUAL_MESSAGE( eResolutionFailed, eResult, "Test 6" ); TEST_ASSERT_EQUAL( pxEndPoint, &xEndPoint ); /* =================================================== */ } @@ -2178,7 +2178,7 @@ void test_eARPGetCacheEntry_MatchingValidEntry( void ) FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( &xEndPoint ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL_MESSAGE( eAddrResCacheHit, eResult, "Test 7" ); + TEST_ASSERT_EQUAL_MESSAGE( eResolutionCacheHit, eResult, "Test 7" ); TEST_ASSERT_EQUAL_MEMORY_MESSAGE( &xARPCache[ 1 ].xMACAddress, &xMACAddress, sizeof( xMACAddress ), "Test 7" ); TEST_ASSERT_NOT_EQUAL( pxEndPoint, &xEndPoint ); /* =================================================== */ @@ -2211,7 +2211,7 @@ void test_eARPGetCacheEntry_GatewayAddressZero( void ) FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( NULL ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL_MESSAGE( eCantSendPacket, eResult, "Test 9" ); + TEST_ASSERT_EQUAL_MESSAGE( eResolutionFailed, eResult, "Test 9" ); /* =================================================== */ } @@ -2237,7 +2237,7 @@ void test_eARPGetCacheEntry_AddressNotOnLocalAddress( void ) FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( NULL ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL_MESSAGE( eCantSendPacket, eResult, "Test 11" ); + TEST_ASSERT_EQUAL_MESSAGE( eResolutionFailed, eResult, "Test 11" ); TEST_ASSERT_NOT_EQUAL( pxEndPoint, &xEndPoint ); /* =================================================== */ } @@ -2274,7 +2274,7 @@ void test_eARPGetCacheEntry_NoCacheHit( void ) FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); xNetworkAddressing.ulGatewayAddress = ulSavedGatewayAddress; - TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); TEST_ASSERT_NOT_EQUAL( pxEndPoint, &xEndPoint ); /* =================================================== */ } @@ -2580,7 +2580,7 @@ void test_xARPWaitResolution_PrivateFunctionReturnsHit( void ) /* Make the resolution pass without any attempt by making - * eARPGetCacheEntry return eAddrResCacheHit. */ + * eARPGetCacheEntry return eResolutionCacheHit. */ /* =================================================== */ /* Assertion on calling from IP-task */ xEndPoint.bits.bIPv6 = pdFALSE_UNSIGNED; diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_utest.c b/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_utest.c index fe670a2e3..b9dce4a0b 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_utest.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_utest.c @@ -383,7 +383,7 @@ void test_vReturnEthernetFrame_DuplicationSuccess( void ) FreeRTOS_FindEndPointOnNetMask_IgnoreAndReturn( pxEndPoint ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheMiss ); xIsCallingFromIPTask_ExpectAndReturn( pdTRUE ); @@ -438,7 +438,7 @@ void test_vReturnEthernetFrame_DuplicationSuccessCacheHit( void ) FreeRTOS_FindEndPointOnNetMask_IgnoreAndReturn( pxEndPoint ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnMemThruPtr_pxMACAddress( &xCacheMACAddress, sizeof( MACAddress_t ) ); xIsCallingFromIPTask_ExpectAndReturn( pdTRUE ); diff --git a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c index e84a31ca9..61f32fad6 100644 --- a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c +++ b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c @@ -124,7 +124,7 @@ void test_eNDGetCacheEntry_MulticastEndPoint( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); } /** @@ -154,7 +154,7 @@ void test_eNDGetCacheEntry_Multicast_ValidEndPoint( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); } /** @@ -175,7 +175,7 @@ void test_eNDGetCacheEntry_Multicast_InvalidEndPoint( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, ppxEndPoint ); - TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); } /** @@ -202,7 +202,7 @@ void test_eNDGetCacheEntry_NDCacheLookupHit_InvalidEndPoint( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, ppxEndPoint ); - TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); TEST_ASSERT_EQUAL_MEMORY( xMACAddress.ucBytes, xNDCache[ xUseEntry ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ); } @@ -235,7 +235,7 @@ void test_eNDGetCacheEntry_NDCacheLookupHit_ValidEndPoint( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); TEST_ASSERT_EQUAL_MEMORY( xMACAddress.ucBytes, xNDCache[ xUseEntry ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ); TEST_ASSERT_EQUAL_MEMORY( pxEndPoint, &xEndPoint2, sizeof( NetworkEndPoint_t ) ); } @@ -264,7 +264,7 @@ void test_eNDGetCacheEntry_NDCacheLookupMiss_InvalidEntry( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheMiss, eResult ); } /** @@ -290,7 +290,7 @@ void test_eNDGetCacheEntry_NDCacheLookupMiss_InvalidEntry2( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, ppxEndPoint ); - TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheMiss, eResult ); } /** @@ -318,7 +318,7 @@ void test_eNDGetCacheEntry_NDCacheLookupMiss_NoEntry( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheMiss, eResult ); } /** @@ -350,7 +350,7 @@ void test_eNDGetCacheEntry_NDCacheLookupMiss_NoLinkLocal( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheMiss, eResult ); } /** @@ -380,7 +380,7 @@ void test_eNDGetCacheEntry_NDCacheLookupMiss_LinkLocal( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheMiss, eResult ); } /** @@ -412,7 +412,7 @@ void test_eNDGetCacheEntry_NDCacheLookupHit_Gateway( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eAddrResCacheHit, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); TEST_ASSERT_EQUAL_MEMORY( xMACAddress.ucBytes, xNDCache[ xUseEntry ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ); } @@ -445,7 +445,7 @@ void test_eNDGetCacheEntry_NDCacheLookupMiss_Gateway( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheMiss, eResult ); } /** @@ -474,7 +474,7 @@ void test_eNDGetCacheEntry_NDCacheLookupMiss_NoEP( void ) eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, &pxEndPoint ); - TEST_ASSERT_EQUAL( eAddrResCacheMiss, eResult ); + TEST_ASSERT_EQUAL( eResolutionCacheMiss, eResult ); } /** diff --git a/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c b/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c index 9b1c0a6a2..f20c7d847 100644 --- a/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c +++ b/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c @@ -24,10 +24,10 @@ * * @note Look for ulIPAddress in the ND cache. If the IP address exists, copy the * associated MAC address into pxMACAddress, refresh the ND cache entry's - * age, and return eAddrResCacheHit. If the IP address does not exist in the ND - * cache return eAddrResCacheMiss. If the packet cannot be sent for any reason + * age, and return eResolutionCacheHit. If the IP address does not exist in the ND + * cache return eResolutionCacheMiss. If the packet cannot be sent for any reason * (maybe DHCP is still in process, or the addressing needs a gateway but there - * isn't a gateway defined) then return eCantSendPacket. + * isn't a gateway defined) then return eResolutionFailed. */ eARPLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, MACAddress_t * const pxMACAddress, @@ -35,7 +35,7 @@ eARPLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, { memset( pxMACAddress, 0, sizeof( MACAddress_t ) ); - return eAddrResCacheHit; + return eResolutionCacheHit; } /** diff --git a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c index 4783cd9a7..667eabe09 100644 --- a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c +++ b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c @@ -104,7 +104,7 @@ void test_prvTCPMakeSurePrepared_NotPrepared( void ) pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE; - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); ulApplicationGetNextSequenceNumber_ExpectAnyArgsAndReturn( 1000 ); prvSocketSetMSS_ExpectAnyArgs(); vTCPWindowCreate_ExpectAnyArgs(); @@ -128,7 +128,7 @@ void test_prvTCPMakeSurePrepared_Not_Ready_Error_Connect( void ) pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE; - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheMiss ); FreeRTOS_OutputARPRequest_ExpectAnyArgs(); xResult = prvTCPMakeSurePrepared( pxSocket ); @@ -183,7 +183,7 @@ void test_prvTCPSendPacket_Syn_State( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 1000 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1234 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2345 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvTCPSendPacket( pxSocket ); @@ -222,7 +222,7 @@ void test_prvTCPSendPacket_Syn_State_NULL_Endpoint( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 1000 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1234 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2345 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvTCPSendPacket( pxSocket ); @@ -270,7 +270,7 @@ void test_prvTCPSendPacket_Syn_State_Not_Prepared( void ) pxSocket->u.xTCP.ucRepCount = 1; pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE; - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheMiss ); FreeRTOS_OutputARPRequest_ExpectAnyArgs(); BytesSent = prvTCPSendPacket( pxSocket ); @@ -361,7 +361,7 @@ void test_prvTCPSendPacket_Other_State_Something_To_Send( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 1000 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1234 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2345 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); for( RepeatCount = 1; RepeatCount < SEND_REPEATED_COUNT; RepeatCount++ ) @@ -372,7 +372,7 @@ void test_prvTCPSendPacket_Other_State_Something_To_Send( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 1000 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1234 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2345 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); } @@ -458,7 +458,7 @@ void test_prvTCPSendRepeated_Repeat_8( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 1000 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1234 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2345 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); } @@ -517,7 +517,7 @@ void test_prvTCPReturnPacket_Null_Buffer_Null_Rx_Stream_KL( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 40, pdFALSE ); @@ -649,7 +649,7 @@ void test_prvTCPReturnPacket_Null_Socket( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( NULL, pxNetworkBuffer, 40, pdFALSE ); @@ -690,7 +690,7 @@ void test_prvTCPReturnPacket_Assert_Interface_NULL( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); @@ -729,7 +729,7 @@ void test_prvTCPReturnPacket_Assert_InterfaceOutput_NULL( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); catch_assert( prvTCPReturnPacket( NULL, pxNetworkBuffer, 40, pdFALSE ) ); @@ -769,7 +769,7 @@ void test_prvTCPReturnPacket_Null_Socket_Release_True( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( NULL, pxNetworkBuffer, 40, pdTRUE ); @@ -819,7 +819,7 @@ void test_prvTCPReturnPacket_No_KL( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 40, pdFALSE ); @@ -873,7 +873,7 @@ void test_prvTCPReturnPacket_No_KL_LocalIP( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 40, pdTRUE ); @@ -933,7 +933,7 @@ void test_prvTCPReturnPacket_No_KL_LocalIP_GT_Eth_Packet_Length( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 1000, pdTRUE ); @@ -990,7 +990,7 @@ void test_prvTCPReturnPacket_No_KL_LocalIP_ARP_Not_Hit( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheMiss ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 40, pdTRUE ); TEST_ASSERT_EQUAL( 1, NetworkInterfaceOutputFunction_Stub_Called ); @@ -1042,7 +1042,7 @@ void test_prvTCPReturnPacket_No_KL_Fin_Suppress_Rx_Stop( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 40, pdFALSE ); @@ -1093,7 +1093,7 @@ void test_prvTCPReturnPacket_No_KL_Fin_Not_Suppress_Low_Water( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 40, pdFALSE ); @@ -1144,7 +1144,7 @@ void test_prvTCPReturnPacket_No_KL_Fin_Not_Suppress_Big_Win( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 0x10000 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); prvTCPReturnPacket( pxSocket, pxNetworkBuffer, 40, pdFALSE ); @@ -1183,7 +1183,7 @@ void test_prvTCPPrepareConnect_Ready( void ) pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE; pxSocket->bits.bIsIPv6 = pdFALSE; - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); ulApplicationGetNextSequenceNumber_ExpectAnyArgsAndReturn( 0x11111111 ); prvSocketSetMSS_ExpectAnyArgs(); vTCPWindowCreate_ExpectAnyArgs(); @@ -1204,7 +1204,7 @@ void test_prvTCPPrepareConnect_No_Arp_Entry( void ) pxSocket->u.xTCP.ucRepCount = 0; pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE; - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheMiss ); FreeRTOS_OutputARPRequest_ExpectAnyArgs(); Return = prvTCPPrepareConnect( pxSocket ); @@ -1223,7 +1223,7 @@ void test_prvTCPPrepareConnect_Zero_SequenceNum( void ) pxSocket->u.xTCP.ucRepCount = 0; pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE; - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); ulApplicationGetNextSequenceNumber_ExpectAnyArgsAndReturn( 0 ); Return = prvTCPPrepareConnect( pxSocket ); @@ -2158,7 +2158,7 @@ void test_prvSendData_AckMsg_Not_Null_Small_Length( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvSendData( pxSocket, &pxNetworkBuffer, 100, 40 ); @@ -2214,7 +2214,7 @@ void test_prvSendData_AckMsg_Not_Null_Same_NetBuffer_Syn_State( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvSendData( pxSocket, &pxNetworkBuffer, 100, 40 ); @@ -2269,7 +2269,7 @@ void test_prvSendData_AckMsg_Not_Null_Same_NetBuffer_Syn_State_Data_To_Send( voi FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvSendData( pxSocket, &pxNetworkBuffer, 100, 50 ); @@ -2324,7 +2324,7 @@ void test_prvSendData_AckMsg_Null_Syn_State_Data_To_Send( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvSendData( pxSocket, &pxNetworkBuffer, 100, 50 ); @@ -2380,7 +2380,7 @@ void test_prvSendData_AckMsg_Null_Syn_State_Data_To_Send_Log( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvSendData( pxSocket, &pxNetworkBuffer, 100, 50 ); @@ -2436,7 +2436,7 @@ void test_prvSendData_AckMsg_Null_Syn_State_Data_To_Send_Rcv_Zero( void ) FreeRTOS_min_uint32_ExpectAnyArgsAndReturn( 500 ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); BytesSent = prvSendData( pxSocket, &pxNetworkBuffer, 0, 50 ); @@ -2502,7 +2502,7 @@ void test_prvTCPSendSpecialPacketHelper( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); Return = prvTCPSendSpecialPacketHelper( pxNetworkBuffer, tcpTCP_FLAG_ACK ); @@ -2539,7 +2539,7 @@ void test_prvTCPSendSpecialPacketHelper_flagSYN( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); Return = prvTCPSendSpecialPacketHelper( pxNetworkBuffer, tcpTCP_FLAG_ACK ); @@ -2575,7 +2575,7 @@ void test_prvTCPSendChallengeAck( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); Return = prvTCPSendChallengeAck( pxNetworkBuffer ); @@ -2610,7 +2610,7 @@ void test_prvTCPSendReset( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); usGenerateChecksum_ExpectAnyArgsAndReturn( 0x1111 ); usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( 0x2222 ); - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); Return = prvTCPSendReset( pxNetworkBuffer ); diff --git a/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c b/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c index 58abfbeec..55f0daa5b 100644 --- a/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c +++ b/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c @@ -133,7 +133,7 @@ void test_prvTCPReturnPacket_IPV6_SocketNULL( void ) xDescriptor.pxEndPoint->pxNetworkInterface->pfOutput = &NetworkInterfaceOutputFunction_Stub; usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( ipCORRECT_CRC ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); prvTCPReturnPacket_IPV6( pxSocket, &xDescriptor, ulLen, xReleaseAfterSend ); } @@ -215,7 +215,7 @@ void test_prvTCPReturnPacket_IPV6_Assert1( void ) xSocket.pxEndPoint->pxNetworkInterface = NULL; usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( ipCORRECT_CRC ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); catch_assert( prvTCPReturnPacket_IPV6( &xSocket, pxDescriptor, ulLen, xReleaseAfterSend ) ); } @@ -251,7 +251,7 @@ void test_prvTCPReturnPacket_IPV6_Assert2( void ) pxIPHeader = &pxTCPPacket->xIPHeader; usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( ipCORRECT_CRC ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheMiss ); catch_assert( prvTCPReturnPacket_IPV6( &xSocket, pxDescriptor, ulLen, xReleaseAfterSend ) ); } @@ -288,7 +288,7 @@ void test_prvTCPReturnPacket_IPV6_Assert3( void ) pxIPHeader = &pxTCPPacket->xIPHeader; usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( ipCORRECT_CRC ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); catch_assert( prvTCPReturnPacket_IPV6( &xSocket, pxDescriptor, ulLen, xReleaseAfterSend ) ); } @@ -323,7 +323,7 @@ void test_prvTCPReturnPacket_IPV6_HappyPath_ReleaseAfterSend( void ) pxDescriptor->pxEndPoint->pxNetworkInterface->pfOutput = &NetworkInterfaceOutputFunction_Stub; usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( ipCORRECT_CRC ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); prvTCPReturnPacket_IPV6( &xSocket, pxDescriptor, ulLen, xReleaseAfterSend ); } @@ -358,7 +358,7 @@ void test_prvTCPReturnPacket_IPV6_HappyPath_NoReleaseAfterSend( void ) pxDescriptor->pxEndPoint->pxNetworkInterface->pfOutput = &NetworkInterfaceOutputFunction_Stub; usGenerateProtocolChecksum_ExpectAnyArgsAndReturn( ipCORRECT_CRC ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); prvTCPReturnPacket_IPV6( &xSocket, pxDescriptor, ulLen, xReleaseAfterSend ); } @@ -374,7 +374,7 @@ void test_prvTCPPrepareConnect_IPV6_CacheMiss_NULLEP( void ) FreeRTOS_Socket_t xSocket, * pxSocket = &xSocket; BaseType_t xReturn = pdFALSE; - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheMiss ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv6_HEADER ); @@ -394,7 +394,7 @@ void test_prvTCPPrepareConnect_IPV6_CacheHit_NULLEP( void ) FreeRTOS_Socket_t xSocket, * pxSocket = &xSocket; BaseType_t xReturn = pdFALSE; - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv6_HEADER ); ulApplicationGetNextSequenceNumber_ExpectAnyArgsAndReturn( 0 ); @@ -415,7 +415,7 @@ void test_prvTCPPrepareConnect_IPV6_CacheHit_RandNumFail( void ) FreeRTOS_Socket_t xSocket, * pxSocket = &xSocket; BaseType_t xReturn = pdFALSE; - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv6_HEADER ); ulApplicationGetNextSequenceNumber_ExpectAnyArgsAndReturn( 10 ); @@ -435,7 +435,7 @@ void test_prvTCPPrepareConnect_IPV6_CantSendPacket_NULLEP( void ) FreeRTOS_Socket_t xSocket, * pxSocket = &xSocket; BaseType_t xReturn = pdFALSE; - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eCantSendPacket ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionFailed ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv6_HEADER ); @@ -455,7 +455,7 @@ void test_prvTCPPrepareConnect_IPV6_CacheMiss_ValidEP( void ) BaseType_t xReturn = pdFALSE; memset( pxEndPoint, 0, sizeof( NetworkEndPoint_t ) ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheMiss ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheMiss ); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv6_HEADER ); @@ -482,7 +482,7 @@ void test_prvTCPPrepareConnect_IPV6_DefaultCase_ValidEP( void ) memset( pxEndPoint, 0, sizeof( NetworkEndPoint_t ) ); memset( &xNetworkBuffer, 0, sizeof( NetworkBufferDescriptor_t ) ); - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eCantSendPacket + 1 ); /* Default case */ + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionFailed + 1 ); /* Default case */ eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv6_HEADER ); @@ -512,7 +512,7 @@ void test_prvTCPPrepareConnect_IPV6_HappyPath_IPv4( void ) memset( &xNetworkBuffer, 0, sizeof( NetworkBufferDescriptor_t ) ); pxSocket->bits.bIsIPv6 = 0; - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv4_HEADER ); @@ -540,7 +540,7 @@ void test_prvTCPPrepareConnect_IPV6_HappyPath_IPv6( void ) memset( pxEndPoint, 0, sizeof( NetworkEndPoint_t ) ); memset( &xNetworkBuffer, 0, sizeof( NetworkBufferDescriptor_t ) ); pxSocket->bits.bIsIPv6 = 1; - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eAddrResCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv6_HEADER ); diff --git a/test/unit-test/FreeRTOS_UDP_IPv4/FreeRTOS_UDP_IPv4_utest.c b/test/unit-test/FreeRTOS_UDP_IPv4/FreeRTOS_UDP_IPv4_utest.c index e7802455d..bd41b5a9b 100644 --- a/test/unit-test/FreeRTOS_UDP_IPv4/FreeRTOS_UDP_IPv4_utest.c +++ b/test/unit-test/FreeRTOS_UDP_IPv4/FreeRTOS_UDP_IPv4_utest.c @@ -1262,7 +1262,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_ICMPPingCantSend() pxICMPPacket = ( ICMPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxICMPPacket->xEthernetHeader.xDestinationAddress ), NULL, eCantSendPacket ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxICMPPacket->xEthernetHeader.xDestinationAddress ), NULL, eResolutionFailed ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1317,7 +1317,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_ICMPPingCacheHit() pxICMPPacket = ( ICMPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxICMPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxICMPPacket->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1350,7 +1350,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHit() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1390,7 +1390,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHitLessBufferLength() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1429,7 +1429,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHitDiffEndPoint() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxDifferentEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1466,7 +1466,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHitLLMNR() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1505,7 +1505,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHitMDNS() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1545,7 +1545,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHitNoInterface() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1584,7 +1584,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHitInterfaceNoOutput() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1618,7 +1618,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheHitNoEndPoint() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheHit ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1652,7 +1652,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheMissEndPointFound() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheMiss ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheMiss ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPointNull ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); @@ -1685,7 +1685,7 @@ void test_vProcessGeneratedUDPPacket_IPv4_UDPCacheMissEndPointNotFound() pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; - eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheMiss ); + eARPGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.ulIP_IPv4 ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheMiss ); eARPGetCacheEntry_IgnoreArg_ppxEndPoint(); eARPGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPointNull ); eARPGetCacheEntry_IgnoreArg_pulIPAddress(); diff --git a/test/unit-test/FreeRTOS_UDP_IPv6/FreeRTOS_UDP_IPv6_utest.c b/test/unit-test/FreeRTOS_UDP_IPv6/FreeRTOS_UDP_IPv6_utest.c index 9495fc03b..4c1cc683a 100644 --- a/test/unit-test/FreeRTOS_UDP_IPv6/FreeRTOS_UDP_IPv6_utest.c +++ b/test/unit-test/FreeRTOS_UDP_IPv6/FreeRTOS_UDP_IPv6_utest.c @@ -1002,7 +1002,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_ICMPPingCantSend() pxICMPv6Packet = ( ICMPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxICMPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eCantSendPacket ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxICMPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eResolutionFailed ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); vReleaseNetworkBufferAndDescriptor_Expect( pxNetworkBuffer ); @@ -1055,7 +1055,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_ICMPPingCacheHit() pxICMPv6Packet = ( ICMPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxICMPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxICMPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheHit ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); usGenerateProtocolChecksum_ExpectAndReturn( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength, pdTRUE, ipCORRECT_CRC ); @@ -1086,7 +1086,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_UDPv6CacheHit() pxUDPv6Packet = ( UDPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheHit ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); usGenerateProtocolChecksum_ExpectAndReturn( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength, pdTRUE, ipCORRECT_CRC ); @@ -1126,7 +1126,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_UDPv6CacheHitLessBufferLength() pxUDPv6Packet = ( UDPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheHit ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); usGenerateProtocolChecksum_ExpectAndReturn( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength, pdTRUE, ipCORRECT_CRC ); @@ -1161,7 +1161,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_UDPv6CacheHitNoEndPoint() pxUDPv6Packet = ( UDPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheHit ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheHit ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); vReleaseNetworkBufferAndDescriptor_Expect( pxNetworkBuffer ); @@ -1195,7 +1195,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_UDPv6CacheMissBothGlobal() pxUDPv6Packet = ( UDPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheMiss ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheMiss ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPointNull ); xIPv6_GetIPType_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), eIPv6_Global ); @@ -1227,7 +1227,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_UDPv6CacheMissButEndPointFound() pxUDPv6Packet = ( UDPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheMiss ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheMiss ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); @@ -1255,7 +1255,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_UDPv6CacheMissDifferentIPType() pxUDPv6Packet = ( UDPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheMiss ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheMiss ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPointNull ); xIPv6_GetIPType_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), eIPv6_LinkLocal ); @@ -1288,7 +1288,7 @@ void test_vProcessGeneratedUDPPacket_IPv6_UDPv6CacheMissDifferentIPType2() pxUDPv6Packet = ( UDPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; - eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eAddrResCacheMiss ); + eNDGetCacheEntry_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), &( pxUDPv6Packet->xEthernetHeader.xDestinationAddress ), NULL, eResolutionCacheMiss ); eNDGetCacheEntry_IgnoreArg_ppxEndPoint(); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPointNull ); xIPv6_GetIPType_ExpectAndReturn( &( pxNetworkBuffer->xIPAddress.xIP_IPv6 ), eIPv6_Global ); diff --git a/tools/tcp_utilities/plus_tcp_demo_cli.c b/tools/tcp_utilities/plus_tcp_demo_cli.c index 7cada8bb9..d1a5bb127 100644 --- a/tools/tcp_utilities/plus_tcp_demo_cli.c +++ b/tools/tcp_utilities/plus_tcp_demo_cli.c @@ -285,15 +285,15 @@ static const char * pcARPReturnType( eARPLookupResult_t eResult ) switch( eResult ) { - case eAddrResCacheMiss: + case eResolutionCacheMiss: pcReturn = "Miss"; break; - case eAddrResCacheHit: + case eResolutionCacheHit: pcReturn = "Hit"; break; - case eCantSendPacket: + case eResolutionFailed: pcReturn = "Can not send"; break; } @@ -453,7 +453,7 @@ static void handle_arpq( char * pcBuffer ) { CommandOptions_t xOptions; char * ptr = pcBuffer; - eARPLookupResult_t eResult = eAddrResCacheMiss; + eARPLookupResult_t eResult = eResolutionCacheMiss; uint32_t ulIPAddress; uint32_t ulLookUpIP; MACAddress_t xMACAddress; @@ -537,7 +537,7 @@ static void handle_arpq( char * pcBuffer ) break; } - if( ( eResult == eAddrResCacheMiss ) && ( pxEndPoint != NULL ) ) + if( ( eResult == eResolutionCacheMiss ) && ( pxEndPoint != NULL ) ) { size_t uxNeededSize = sizeof( ARPPacket_t ); From bf49f4f5016b41b20e43cc9e61d2fab87935d9be Mon Sep 17 00:00:00 2001 From: Holden Date: Thu, 1 Aug 2024 15:31:10 -0400 Subject: [PATCH 07/25] Add ND Timer event implementation --- source/FreeRTOS_IP.c | 138 ++++++++--- source/FreeRTOS_IP_Timers.c | 220 ++++++++++++++---- source/FreeRTOS_IP_Utils.c | 7 +- source/FreeRTOS_ND.c | 20 ++ source/include/FreeRTOSIPConfigDefaults.h | 31 +++ source/include/FreeRTOS_IP.h | 9 +- source/include/FreeRTOS_IP_Private.h | 28 +-- source/include/FreeRTOS_IP_Timers.h | 50 ++-- source/include/FreeRTOS_IP_Utils.h | 2 +- source/include/FreeRTOS_ND.h | 2 + source/include/IPTraceMacroDefaults.h | 38 ++- test/build-combination/Common/main.c | 1 + test/unit-test/FreeRTOS_ARP/ut.cmake | 2 +- .../ut.cmake | 2 +- .../unit-test/FreeRTOS_ND/FreeRTOS_ND_stubs.c | 25 +- .../unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c | 45 ++-- test/unit-test/FreeRTOS_ND/ut.cmake | 3 +- .../FreeRTOS_Routing/FreeRTOS_Routing_stubs.c | 21 -- 18 files changed, 445 insertions(+), 199 deletions(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index e9b5ef029..f80f12f5e 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -64,34 +64,50 @@ #ifndef ipINITIALISATION_RETRY_DELAY #define ipINITIALISATION_RETRY_DELAY ( pdMS_TO_TICKS( 3000U ) ) #endif + #if ( ipconfigUSE_TCP_MEM_STATS != 0 ) #include "tcp_mem_stats.h" #endif -/** @brief Maximum time to wait for a resolution while holding a packet. */ -#ifndef ipADDR_RES_MAX_DELAY - #define ipADDR_RES_MAX_DELAY ( pdMS_TO_TICKS( 2000U ) ) +/** @brief Maximum time to wait for an ARP resolution while holding a packet. */ +#ifndef ipARP_RESOLUTION_MAX_DELAY + #define ipARP_RESOLUTION_MAX_DELAY ( pdMS_TO_TICKS( 2000U ) ) #endif -#ifndef iptraceIP_TASK_STARTING - #define iptraceIP_TASK_STARTING() do {} while( ipFALSE_BOOL ) /**< Empty definition in case iptraceIP_TASK_STARTING is not defined. */ +/** @brief Maximum time to wait for a ND resolution while holding a packet. */ +#ifndef ipND_RESOLUTION_MAX_DELAY + #define ipND_RESOLUTION_MAX_DELAY ( pdMS_TO_TICKS( 2000U ) ) #endif -#if ( ( ipconfigUSE_TCP == 1 ) && !defined( ipTCP_TIMER_PERIOD_MS ) ) - /** @brief When initialising the TCP timer, give it an initial time-out of 1 second. */ - #define ipTCP_TIMER_PERIOD_MS ( 1000U ) +/** @brief Defines how often the ARP resolution timer callback function is executed. The time is + * shorter in the Windows simulator as simulated time is not real time. */ +#ifndef ipARP_TIMER_PERIOD_MS + #ifdef _WINDOWS_ + #define ipARP_TIMER_PERIOD_MS ( 500U ) /* For windows simulator builds. */ + #else + #define ipARP_TIMER_PERIOD_MS ( 10000U ) + #endif #endif -/** @brief Defines how often the resolution timer callback function is executed. The time is +/** @brief Defines how often the ND resolution timer callback function is executed. The time is * shorter in the Windows simulator as simulated time is not real time. */ -#ifndef ipADDR_RES_TIMER_PERIOD_MS +#ifndef ipND_TIMER_PERIOD_MS #ifdef _WINDOWS_ - #define ipADDR_RES_TIMER_PERIOD_MS ( 500U ) /* For windows simulator builds. */ + #define ipND_TIMER_PERIOD_MS ( 500U ) /* For windows simulator builds. */ #else - #define ipADDR_RES_TIMER_PERIOD_MS ( 10000U ) + #define ipND_TIMER_PERIOD_MS ( 10000U ) #endif #endif +#if ( ( ipconfigUSE_TCP == 1 ) && !defined( ipTCP_TIMER_PERIOD_MS ) ) + /** @brief When initialising the TCP timer, give it an initial time-out of 1 second. */ + #define ipTCP_TIMER_PERIOD_MS ( 1000U ) +#endif + +#ifndef iptraceIP_TASK_STARTING + #define iptraceIP_TASK_STARTING() do {} while( ipFALSE_BOOL ) /**< Empty definition in case iptraceIP_TASK_STARTING is not defined. */ +#endif + /** @brief The frame type field in the Ethernet header must have a value greater than 0x0600. * If the configuration option ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is enabled, the stack * will discard packets with a frame type value less than or equal to 0x0600. @@ -106,8 +122,15 @@ static void prvIPTask_CheckPendingEvents( void ); /*-----------------------------------------------------------*/ -/** @brief The pointer to buffer with packet waiting for resolution. */ -NetworkBufferDescriptor_t * pxResolutionWaitingNetworkBuffer = NULL; +/** @brief The pointer to buffer with packet waiting for ARP resolution. */ +#if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + NetworkBufferDescriptor_t * pxARPWaitingNetworkBuffer = NULL; +#endif + +/** @brief The pointer to buffer with packet waiting for ND resolution. */ +#if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + NetworkBufferDescriptor_t * pxNDWaitingNetworkBuffer = NULL; +#endif /*-----------------------------------------------------------*/ @@ -293,16 +316,18 @@ static void prvProcessIPEventsAndTimers( void ) prvForwardTxPacket( ( ( NetworkBufferDescriptor_t * ) xReceivedEvent.pvData ), pdTRUE ); break; - case eResolutionTimerEvent: - /* The Resolution timer has expired, process the cache. */ - #if ( ipconfigUSE_IPv4 != 0 ) + case eARPTimerEvent: + /* The ARP Resolution timer has expired, process the cache. */ + #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) vARPAgeCache(); #endif /* ( ipconfigUSE_IPv4 != 0 ) */ + break; - #if ( ipconfigUSE_IPv6 != 0 ) + case eNDTimerEvent: + /* The ND Resolution timer has expired, process the cache. */ + #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) vNDAgeCache(); #endif /* ( ipconfigUSE_IPv6 != 0 ) */ - break; case eSocketBindEvent: @@ -493,8 +518,15 @@ static void prvIPTask_Initialise( void ) } #endif - /* Mark the timer as inactive since we are not waiting on any resolution as of now. */ - vIPSetResolutionTimerEnableState( pdFALSE ); + #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + /* Mark the ARP timer as inactive since we are not waiting on any resolution as of now. */ + vIPSetARPResolutionTimerEnableState( pdFALSE ); + #endif + + #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + /* Mark the ND timer as inactive since we are not waiting on any resolution as of now. */ + vIPSetNDResolutionTimerEnableState( pdFALSE ); + #endif #if ( ( ipconfigDNS_USE_CALLBACKS != 0 ) && ( ipconfigUSE_DNS != 0 ) ) { @@ -648,7 +680,18 @@ void vIPNetworkUpCalls( struct xNetworkEndPoint * pxEndPoint ) #endif /* ipconfigDNS_USE_CALLBACKS != 0 */ /* Set remaining time to 0 so it will become active immediately. */ - vResolutionTimerReload( pdMS_TO_TICKS( ipADDR_RES_TIMER_PERIOD_MS ) ); + if( pxEndPoint->bits.bIPv6 == pdTRUE_UNSIGNED ) + { + #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + vNDTimerReload( pdMS_TO_TICKS( ipND_TIMER_PERIOD_MS ) ); + #endif + } + else + { + #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + vARPTimerReload( pdMS_TO_TICKS( ipARP_TIMER_PERIOD_MS ) ); + #endif + } } /*-----------------------------------------------------------*/ @@ -1733,20 +1776,47 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor case eWaitingResolution: - if( pxResolutionWaitingNetworkBuffer == NULL ) - { - pxResolutionWaitingNetworkBuffer = pxNetworkBuffer; - vIPTimerStartResolution( ipADDR_RES_MAX_DELAY ); + #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + if( pxEthernetHeader->usFrameType == ipIPv4_FRAME_TYPE ) + { + if( pxARPWaitingNetworkBuffer == NULL ) + { + pxARPWaitingNetworkBuffer = pxNetworkBuffer; + vIPTimerStartARPResolution( ipARP_RESOLUTION_MAX_DELAY ); - iptraceDELAYED_RESOLUTION_REQUEST_STARTED(); - } - else - { - /* We are already waiting on one resolution. This frame will be dropped. */ - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); + iptraceDELAYED_ARP_REQUEST_STARTED(); + } + else + { + /* We are already waiting on one resolution. This frame will be dropped. */ + vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - iptraceDELAYED_RESOLUTION_BUFFER_FULL(); - } + iptraceDELAYED_ARP_BUFFER_FULL(); + } + break; + } + #endif + + #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + if( pxEthernetHeader->usFrameType == ipIPv6_FRAME_TYPE ) + { + if( pxNDWaitingNetworkBuffer == NULL ) + { + pxNDWaitingNetworkBuffer = pxNetworkBuffer; + vIPTimerStartNDResolution( ipND_RESOLUTION_MAX_DELAY ); + + iptraceDELAYED_ND_REQUEST_STARTED(); + } + else + { + /* We are already waiting on one resolution. This frame will be dropped. */ + vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); + + iptraceDELAYED_ND_BUFFER_FULL(); + } + break; + } + #endif break; diff --git a/source/FreeRTOS_IP_Timers.c b/source/FreeRTOS_IP_Timers.c index 87ffe4e14..e5ce73fbd 100644 --- a/source/FreeRTOS_IP_Timers.c +++ b/source/FreeRTOS_IP_Timers.c @@ -49,6 +49,8 @@ #include "FreeRTOS_IP_Private.h" #include "FreeRTOS_UDP_IP.h" #include "FreeRTOS_DHCP.h" +#include "FreeRTOS_ARP.h" +#include "FreeRTOS_ND.h" #include "NetworkInterface.h" #include "NetworkBufferManagement.h" #include "FreeRTOS_Routing.h" @@ -92,20 +94,22 @@ static void prvIPTimerReload( IPTimer_t * pxTimer, * regular basis */ +#if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) /** @brief Timer to limit the maximum time a packet should be stored while * awaiting an ARP resolution. */ -static IPTimer_t xARPResolutionTimer; + static IPTimer_t xARPResolutionTimer; /** @brief ARP timer, to check its table entries. */ -static IPTimer_t xARPTimer; - + static IPTimer_t xARPTimer; +#endif +#if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) /** @brief Timer to limit the maximum time a packet should be stored while * awaiting an ND resolution. */ -static IPTimer_t xNDResolutionTimer; + static IPTimer_t xNDResolutionTimer; /** @brief ND timer, to check its table entries. */ -static IPTimer_t xNDTimer; - + static IPTimer_t xNDTimer; +#endif #if ( ipconfigUSE_TCP != 0 ) /** @brief TCP timer, to check for timeouts, resends. */ static IPTimer_t xTCPTimer; @@ -142,13 +146,25 @@ TickType_t xCalculateSleepTime( void ) * time in any other timers that are active. */ uxMaximumSleepTime = ipconfigMAX_IP_TASK_SLEEP_TIME; - if( xARPTimer.bActive != pdFALSE_UNSIGNED ) - { - if( xARPTimer.ulRemainingTime < uxMaximumSleepTime ) + #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + if( xARPTimer.bActive != pdFALSE_UNSIGNED ) { - uxMaximumSleepTime = xARPTimer.ulRemainingTime; + if( xARPTimer.ulRemainingTime < uxMaximumSleepTime ) + { + uxMaximumSleepTime = xARPTimer.ulRemainingTime; + } } - } + #endif + + #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + if( xNDTimer.bActive != pdFALSE_UNSIGNED ) + { + if( xNDTimer.ulRemainingTime < uxMaximumSleepTime ) + { + uxMaximumSleepTime = xNDTimer.ulRemainingTime; + } + } + #endif #if ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) { @@ -198,7 +214,7 @@ TickType_t xCalculateSleepTime( void ) /*-----------------------------------------------------------*/ /** - * @brief Check the network timers (ARP/DHCP/DNS/TCP) and if they are + * @brief Check the network timers (ARP/ND/DHCP/DNS/TCP) and if they are * expired, send an event to the IP-Task. */ /* MISRA Ref 8.9.1 [File scoped variables] */ @@ -209,30 +225,59 @@ void vCheckNetworkTimers( void ) { NetworkInterface_t * pxInterface; - /* Is it time for ARP processing? */ - if( prvIPTimerCheck( &xARPTimer ) != pdFALSE ) - { - ( void ) xSendEventToIPTask( eARPTimerEvent ); - } + #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + /* Is it time for ARP processing? */ + if( prvIPTimerCheck( &xARPTimer ) != pdFALSE ) + { + ( void ) xSendEventToIPTask( eARPTimerEvent ); + } - /* Is the ARP resolution timer expired? */ - if( prvIPTimerCheck( &xARPResolutionTimer ) != pdFALSE ) - { - if( pxARPWaitingNetworkBuffer != NULL ) + /* Is the ARP resolution timer expired? */ + if( prvIPTimerCheck( &xARPResolutionTimer ) != pdFALSE ) { - /* Disable the ARP resolution timer. */ - vIPSetARPResolutionTimerEnableState( pdFALSE ); + if( pxARPWaitingNetworkBuffer != NULL ) + { + /* Disable the ARP resolution timer. */ + vIPSetARPResolutionTimerEnableState( pdFALSE ); - /* We have waited long enough for the ARP response. Now, free the network - * buffer. */ - vReleaseNetworkBufferAndDescriptor( pxARPWaitingNetworkBuffer ); + /* We have waited long enough for the ARP response. Now, free the network + * buffer. */ + vReleaseNetworkBufferAndDescriptor( pxARPWaitingNetworkBuffer ); - /* Clear the pointer. */ - pxARPWaitingNetworkBuffer = NULL; + /* Clear the pointer. */ + pxARPWaitingNetworkBuffer = NULL; - iptraceDELAYED_ARP_TIMER_EXPIRED(); + iptraceDELAYED_ARP_TIMER_EXPIRED(); + } + } + #endif + + #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + /* Is it time for ND processing? */ + if( prvIPTimerCheck( &xNDTimer ) != pdFALSE ) + { + ( void ) xSendEventToIPTask( eNDTimerEvent ); } - } + + /* Is the ND resolution timer expired? */ + if( prvIPTimerCheck( &xNDResolutionTimer ) != pdFALSE ) + { + if( pxNDWaitingNetworkBuffer != NULL ) + { + /* Disable the ND resolution timer. */ + vIPSetNDResolutionTimerEnableState( pdFALSE ); + + /* We have waited long enough for the ND response. Now, free the network + * buffer. */ + vReleaseNetworkBufferAndDescriptor( pxNDWaitingNetworkBuffer ); + + /* Clear the pointer. */ + pxNDWaitingNetworkBuffer = NULL; + + iptraceDELAYED_ND_TIMER_EXPIRED(); + } + } + #endif #if ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) { @@ -365,15 +410,32 @@ static void prvIPTimerStart( IPTimer_t * pxTimer, } /*-----------------------------------------------------------*/ +#if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + /** * @brief Start an ARP Resolution timer. * * @param[in] xTime Time to be loaded into the ARP Resolution timer. */ -void vIPTimerStartARPResolution( TickType_t xTime ) -{ - prvIPTimerStart( &( xARPResolutionTimer ), xTime ); -} + void vIPTimerStartARPResolution( TickType_t xTime ) + { + prvIPTimerStart( &( xARPResolutionTimer ), xTime ); + } +#endif +/*-----------------------------------------------------------*/ + +#if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + +/** + * @brief Start an ND Resolution timer. + * + * @param[in] xTime Time to be loaded into the ND Resolution timer. + */ + void vIPTimerStartNDResolution( TickType_t xTime ) + { + prvIPTimerStart( &( xNDResolutionTimer ), xTime ); + } +#endif /*-----------------------------------------------------------*/ /** @@ -404,6 +466,8 @@ static void prvIPTimerReload( IPTimer_t * pxTimer, #endif /*-----------------------------------------------------------*/ +#if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + /** * @brief Sets the reload time of the ARP timer and restarts it. * @@ -413,7 +477,21 @@ void vARPTimerReload( TickType_t xTime ) { prvIPTimerReload( &xARPTimer, xTime ); } +#endif +/*-----------------------------------------------------------*/ + +#if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) +/** + * @brief Sets the reload time of the ND timer and restarts it. + * + * @param[in] xTime Time to be reloaded into the ND timer. + */ +void vNDTimerReload( TickType_t xTime ) +{ + prvIPTimerReload( &xNDTimer, xTime ); +} +#endif /*-----------------------------------------------------------*/ #if ( ipconfigDNS_USE_CALLBACKS != 0 ) @@ -525,40 +603,82 @@ static BaseType_t prvIPTimerCheck( IPTimer_t * pxTimer ) #endif /* if ( ipconfigUSE_TCP == 1 ) */ /*-----------------------------------------------------------*/ +#if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + /** * @brief Enable/disable the ARP timer. * * @param[in] xEnableState pdTRUE - enable timer; pdFALSE - disable timer. */ -void vIPSetARPTimerEnableState( BaseType_t xEnableState ) -{ - if( xEnableState != pdFALSE ) + void vIPSetARPTimerEnableState( BaseType_t xEnableState ) { - xARPTimer.bActive = pdTRUE_UNSIGNED; + if( xEnableState != pdFALSE ) + { + xARPTimer.bActive = pdTRUE_UNSIGNED; + } + else + { + xARPTimer.bActive = pdFALSE_UNSIGNED; + } } - else + /*-----------------------------------------------------------*/ + +/** + * @brief Enable or disable the ARP resolution timer. + * + * @param[in] xEnableState pdTRUE if the timer must be enabled, pdFALSE otherwise. + */ + void vIPSetARPResolutionTimerEnableState( BaseType_t xEnableState ) { - xARPTimer.bActive = pdFALSE_UNSIGNED; + if( xEnableState != pdFALSE ) + { + xARPResolutionTimer.bActive = pdTRUE_UNSIGNED; + } + else + { + xARPResolutionTimer.bActive = pdFALSE_UNSIGNED; + } } -} +#endif /*-----------------------------------------------------------*/ +#if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + /** - * @brief Enable or disable the ARP resolution timer. + * @brief Enable/disable the ND timer. * - * @param[in] xEnableState pdTRUE if the timer must be enabled, pdFALSE otherwise. + * @param[in] xEnableState pdTRUE - enable timer; pdFALSE - disable timer. */ -void vIPSetARPResolutionTimerEnableState( BaseType_t xEnableState ) -{ - if( xEnableState != pdFALSE ) + void vIPSetNDTimerEnableState( BaseType_t xEnableState ) { - xARPResolutionTimer.bActive = pdTRUE_UNSIGNED; + if( xEnableState != pdFALSE ) + { + xNDTimer.bActive = pdTRUE_UNSIGNED; + } + else + { + xNDTimer.bActive = pdFALSE_UNSIGNED; + } } - else + /*-----------------------------------------------------------*/ + +/** + * @brief Enable or disable the ND resolution timer. + * + * @param[in] xEnableState pdTRUE if the timer must be enabled, pdFALSE otherwise. + */ + void vIPSetNDResolutionTimerEnableState( BaseType_t xEnableState ) { - xARPResolutionTimer.bActive = pdFALSE_UNSIGNED; + if( xEnableState != pdFALSE ) + { + xNDResolutionTimer.bActive = pdTRUE_UNSIGNED; + } + else + { + xNDResolutionTimer.bActive = pdFALSE_UNSIGNED; + } } -} +#endif /*-----------------------------------------------------------*/ #if ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) || ( ipconfigUSE_DHCPv6 == 1 ) diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index 95880c851..f1bae8a0a 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -823,7 +823,12 @@ void prvProcessNetworkDownEvent( struct xNetworkInterface * pxInterface ) configASSERT( pxInterface != NULL ); configASSERT( pxInterface->pfInitialise != NULL ); /* Stop the Address Resolution timer while there is no network. */ - vIPSetAddrResTimerEnableState( pdFALSE ); + #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + vIPSetARPTimerEnableState( pdFALSE ); + #endif + #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + vIPSetNDTimerEnableState( pdFALSE ); + #endif /* The first network down event is generated by the IP stack itself to * initialise the network hardware, so do not call the network down event diff --git a/source/FreeRTOS_ND.c b/source/FreeRTOS_ND.c index d187681b9..4350ad39d 100644 --- a/source/FreeRTOS_ND.c +++ b/source/FreeRTOS_ND.c @@ -97,6 +97,10 @@ /** @brief The ND cache. */ static NDCacheRow_t xNDCache[ ipconfigND_CACHE_ENTRIES ]; +/** @brief The time at which the last unsolicited ND was sent. Unsolicited NDs are used + * to ensure ND tables are up to date and to detect IP address conflicts. */ + static TickType_t xLastUnsolicitedNDTime = 0U; + /*-----------------------------------------------------------*/ /* @@ -1395,5 +1399,21 @@ return xNeedsNDResolution; } + +/*-----------------------------------------------------------*/ + +/** + * @brief Send an unsolicited ND packet to allow this node to announce the IP-MAC + * mapping to the entire network. + */ + void vNDSendUnsolicited( void ) + { + /* Setting xLastUnsolicitedNDTime to 0 will force an unsolicited ND the next + * time vNDAgeCache() is called. */ + xLastUnsolicitedNDTime = ( TickType_t ) 0; + + /* Let the IP-task call vARPAgeCache(). */ + ( void ) xSendEventToIPTask( eNDTimerEvent ); + } /*-----------------------------------------------------------*/ #endif /* ipconfigUSE_IPv6 */ diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index a31d962ea..245a56840 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -2951,6 +2951,37 @@ STATIC_ASSERT( ipconfigDNS_SEND_BLOCK_TIME_TICKS <= portMAX_DELAY ); /*---------------------------------------------------------------------------*/ +/* + * ipconfigMAX_ND_AGE + * + * Type: uint8_t + * Unit: decaseconds + * Minimum: 0 + * + * Defines the maximum time between an entry in the ND table being created or + * refreshed and the entry being removed because it is stale. New ND requests + * are sent for ND cache entries that are nearing their maximum age. + * The maximum age of an entry in the ND cache table can be + * calculated as 'ipND_TIMER_PERIOD_MS' x 'ipconfigMAX_ND_AGE'. + * + * Units are derived from ipND_TIMER_PERIOD_MS, which is 10000 ms or 10 sec. + * So, a value of 150 is equal to 1500 seconds. + */ + +#ifndef ipconfigMAX_ND_AGE + #define ipconfigMAX_ND_AGE ( 150 ) +#endif + +#if ( ipconfigMAX_ND_AGE < 0 ) + #error ipconfigMAX_ND_AGE must be at least 0 +#endif + +#if ( ipconfigMAX_ND_AGE > UINT8_MAX ) + #error ipconfigMAX_ND_AGE overflows a uint8_t +#endif + +/*---------------------------------------------------------------------------*/ + /*===========================================================================*/ /* ND CONFIG */ /*===========================================================================*/ diff --git a/source/include/FreeRTOS_IP.h b/source/include/FreeRTOS_IP.h index 2423990ed..72516894c 100644 --- a/source/include/FreeRTOS_IP.h +++ b/source/include/FreeRTOS_IP.h @@ -439,10 +439,11 @@ BaseType_t xIsNetworkDownEventPending( void ); * be defined in a user module. */ BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber ); -/** @brief The pointer to buffer with packet waiting for resolution. This variable - * is defined in FreeRTOS_IP.c. - * This pointer is for internal use only. */ -extern NetworkBufferDescriptor_t * pxResolutionWaitingNetworkBuffer; +/** @brief The pointers to buffers with packet waiting for resolution. These variables + * are defined in FreeRTOS_IP.c. + * These pointers are for internal use only. */ +extern NetworkBufferDescriptor_t * pxARPWaitingNetworkBuffer; +extern NetworkBufferDescriptor_t * pxNDWaitingNetworkBuffer; #if ( ipconfigENABLE_BACKWARD_COMPATIBILITY == 1 ) #define xIPStackEvent_t IPStackEvent_t diff --git a/source/include/FreeRTOS_IP_Private.h b/source/include/FreeRTOS_IP_Private.h index 16fe1967d..cd5afb8c0 100644 --- a/source/include/FreeRTOS_IP_Private.h +++ b/source/include/FreeRTOS_IP_Private.h @@ -34,7 +34,6 @@ #include "FreeRTOS_Sockets.h" #include "FreeRTOS_Stream_Buffer.h" #include "FreeRTOS_Routing.h" -#include "FreeRTOS_ARP.h" #if ( ipconfigUSE_TCP == 1 ) #include "FreeRTOS_TCP_WIN.h" @@ -66,7 +65,7 @@ typedef enum eFrameProcessingResult eProcessBuffer, /* An Ethernet frame has a valid address - continue process its contents. */ eReturnEthernetFrame, /* The Ethernet frame contains an ARP or ICMP packet that can be returned to its source. */ eFrameConsumed, /* Processing the Ethernet packet contents resulted in the payload being sent to the stack. */ - eWaitingAddrRes /* Frame is awaiting resolution. */ + eWaitingResolution /* Frame is awaiting resolution. */ } eFrameProcessingResult_t; typedef enum @@ -75,17 +74,18 @@ typedef enum eNetworkDownEvent, /* 0: The network interface has been lost and/or needs [re]connecting. */ eNetworkRxEvent, /* 1: The network interface has queued a received Ethernet frame. */ eNetworkTxEvent, /* 2: Let the IP-task send a network packet. */ - eAddrResTimerEvent, /* 3: The resolution timer expired. */ - eStackTxEvent, /* 4: The software stack has queued a packet to transmit. */ - eDHCPEvent, /* 5: Process the DHCP state machine. */ - eTCPTimerEvent, /* 6: See if any TCP socket needs attention. */ - eTCPAcceptEvent, /* 7: Client API FreeRTOS_accept() waiting for client connections. */ - eTCPNetStat, /* 8: IP-task is asked to produce a netstat listing. */ - eSocketBindEvent, /* 9: Send a message to the IP-task to bind a socket to a port. */ - eSocketCloseEvent, /*10: Send a message to the IP-task to close a socket. */ - eSocketSelectEvent, /*11: Send a message to the IP-task for select(). */ - eSocketSignalEvent, /*12: A socket must be signalled. */ - eSocketSetDeleteEvent /*13: A socket set must be deleted. */ + eARPTimerEvent, /* 3: The ARP timer expired. */ + eNDTimerEvent, /* 4: The ND timer expired. */ + eStackTxEvent, /* 5: The software stack has queued a packet to transmit. */ + eDHCPEvent, /* 6: Process the DHCP state machine. */ + eTCPTimerEvent, /* 7: See if any TCP socket needs attention. */ + eTCPAcceptEvent, /* 8: Client API FreeRTOS_accept() waiting for client connections. */ + eTCPNetStat, /* 9: IP-task is asked to produce a netstat listing. */ + eSocketBindEvent, /*10: Send a message to the IP-task to bind a socket to a port. */ + eSocketCloseEvent, /*11: Send a message to the IP-task to close a socket. */ + eSocketSelectEvent, /*12: Send a message to the IP-task for select(). */ + eSocketSignalEvent, /*13: A socket must be signalled. */ + eSocketSetDeleteEvent /*14: A socket set must be deleted. */ } eIPEvent_t; /** @@ -843,7 +843,7 @@ BaseType_t xIsCallingFromIPTask( void ); #endif /* ipconfigSUPPORT_SELECT_FUNCTION */ -/* Send the network-up event and start the ARP timer. */ +/* Send the network-up event and start the ARP/ND timers. */ void vIPNetworkUpCalls( struct xNetworkEndPoint * pxEndPoint ); /* Mark whether all interfaces are up or at least one interface is down. */ diff --git a/source/include/FreeRTOS_IP_Timers.h b/source/include/FreeRTOS_IP_Timers.h index f73e9c7e0..0c7328911 100644 --- a/source/include/FreeRTOS_IP_Timers.h +++ b/source/include/FreeRTOS_IP_Timers.h @@ -77,45 +77,49 @@ TickType_t xCalculateSleepTime( void ); */ void vIPSetTCPTimerExpiredState( BaseType_t xExpiredState ); +#if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) /** * Sets the reload time of an ARP timer and restarts it. */ -void vARPTimerReload( TickType_t xTime ); + void vARPTimerReload( TickType_t xTime ); /* * Start an ARP Resolution timer. */ -void vIPTimerStartARPResolution( TickType_t xTime ); + void vIPTimerStartARPResolution( TickType_t xTime ); /* * Enable/disable the ARP timer. */ -void vIPSetARPTimerEnableState( BaseType_t xEnableState ); + void vIPSetARPTimerEnableState( BaseType_t xEnableState ); /* * Enable or disable the ARP resolution timer. */ -void vIPSetARPResolutionTimerEnableState( BaseType_t xEnableState ); - -/** - * Sets the reload time of an ND timer and restarts it. - */ -void vNDTimerReload( TickType_t xTime ); - -/* - * Start an ND Resolution timer. - */ -void vIPTimerStartNDResolution( TickType_t xTime ); - -/* - * Enable/disable the ND timer. - */ -void vIPSetNDTimerEnableState( BaseType_t xEnableState ); + void vIPSetARPResolutionTimerEnableState( BaseType_t xEnableState ); +#endif -/* - * Enable or disable the ARP resolution timer. - */ -void vIPSetNDResolutionTimerEnableState( BaseType_t xEnableState ); +#if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + /** + * Sets the reload time of an ND timer and restarts it. + */ + void vNDTimerReload( TickType_t xTime ); + + /* + * Start an ND Resolution timer. + */ + void vIPTimerStartNDResolution( TickType_t xTime ); + + /* + * Enable/disable the ND timer. + */ + void vIPSetNDTimerEnableState( BaseType_t xEnableState ); + + /* + * Enable or disable the ARP resolution timer. + */ + void vIPSetNDResolutionTimerEnableState( BaseType_t xEnableState ); +#endif #if ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) diff --git a/source/include/FreeRTOS_IP_Utils.h b/source/include/FreeRTOS_IP_Utils.h index 301f14905..6f8cd07b6 100644 --- a/source/include/FreeRTOS_IP_Utils.h +++ b/source/include/FreeRTOS_IP_Utils.h @@ -47,7 +47,6 @@ /* FreeRTOS+TCP includes. */ #include "FreeRTOS_IP.h" #include "FreeRTOS_Sockets.h" -#include "FreeRTOS_Routing.h" #include "FreeRTOS_IP_Private.h" #include "FreeRTOS_UDP_IP.h" #include "FreeRTOS_DHCP.h" @@ -66,6 +65,7 @@ /* Forward declaration. */ struct xNetworkInterface; +struct xNetworkEndPoint; #if ( ( ipconfigUSE_DHCPv6 == 1 ) || ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) ) diff --git a/source/include/FreeRTOS_ND.h b/source/include/FreeRTOS_ND.h index 5f1771eee..9ca2d32af 100644 --- a/source/include/FreeRTOS_ND.h +++ b/source/include/FreeRTOS_ND.h @@ -209,6 +209,8 @@ /* Clear all entries in the ND cache. */ void FreeRTOS_ClearND( const struct xNetworkEndPoint * pxEndPoint ); + void vNDSendUnsolicited( void ); + extern const uint8_t pcLOCAL_ALL_NODES_MULTICAST_IP[ ipSIZE_OF_IPv6_ADDRESS ]; extern const uint8_t pcLOCAL_ALL_NODES_MULTICAST_MAC[ ipMAC_ADDRESS_LENGTH_BYTES ]; diff --git a/source/include/IPTraceMacroDefaults.h b/source/include/IPTraceMacroDefaults.h index c9fd6eac6..fa2b17fd0 100644 --- a/source/include/IPTraceMacroDefaults.h +++ b/source/include/IPTraceMacroDefaults.h @@ -129,7 +129,7 @@ * [re]connecting. * eNetworkRxEvent - The network interface has queued a received Ethernet * frame. - * eResolutionTimerEvent - The Resolution timer expired. + * eARPTimerEvent - The Resolution timer expired. * eStackTxEvent - The software stack has queued a packet to transmit. * eDHCPEvent - Process the DHCP state machine. * @@ -610,6 +610,18 @@ /*---------------------------------------------------------------------------*/ +/* + * iptraceDELAYED_ND_BUFFER_FULL + * + * A packet has come in from an unknown IPv6 address. An ND request has been + * sent, but the queue is still filled with a different packet. + */ +#ifndef iptraceDELAYED_ND_BUFFER_FULL + #define iptraceDELAYED_ND_BUFFER_FULL() +#endif + +/*---------------------------------------------------------------------------*/ + /* * iptrace_DELAYED_ND_REQUEST_REPLIED */ @@ -619,6 +631,30 @@ /*---------------------------------------------------------------------------*/ +/* + * iptraceDELAYED_ND_REQUEST_STARTED + * + * A packet came in from an unknown IPv6 address. An ND request has been sent + * and the network buffer is stored for processing later. + */ +#ifndef iptraceDELAYED_ND_REQUEST_STARTED + #define iptraceDELAYED_ND_REQUEST_STARTED() +#endif + +/*---------------------------------------------------------------------------*/ + +/* + * iptraceDELAYED_ND_TIMER_EXPIRED + * + * A packet was stored for delayed processing, but there is no ND reply. The + * network buffer will be released without being processed. + */ +#ifndef iptraceDELAYED_ND_TIMER_EXPIRED + #define iptraceDELAYED_ND_TIMER_EXPIRED() +#endif + +/*---------------------------------------------------------------------------*/ + /*===========================================================================*/ /* ND TRACE MACROS */ /*===========================================================================*/ diff --git a/test/build-combination/Common/main.c b/test/build-combination/Common/main.c index f2617a1d2..f904ad5a7 100644 --- a/test/build-combination/Common/main.c +++ b/test/build-combination/Common/main.c @@ -38,6 +38,7 @@ #include "FreeRTOS_IP.h" #include "FreeRTOS_Sockets.h" #include "FreeRTOS_DHCP.h" +#include "FreeRTOS_Routing.h" #include #include diff --git a/test/unit-test/FreeRTOS_ARP/ut.cmake b/test/unit-test/FreeRTOS_ARP/ut.cmake index a8757579e..5df8b8a09 100644 --- a/test/unit-test/FreeRTOS_ARP/ut.cmake +++ b/test/unit-test/FreeRTOS_ARP/ut.cmake @@ -39,7 +39,7 @@ list(APPEND mock_define_list # list the files you would like to test here list(APPEND real_source_files - ${MODULE_ROOT_DIR}/source/FreeRTOS_ARP.c + ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources/${project_name}.c ) # list the directories the module under test includes list(APPEND real_include_directories diff --git a/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake b/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake index 2c25b6b68..645595565 100644 --- a/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake +++ b/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake @@ -41,7 +41,7 @@ list(APPEND mock_define_list # list the files you would like to test here set(real_source_files "") list(APPEND real_source_files - ${MODULE_ROOT_DIR}/source/FreeRTOS_ARP.c + ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources/${project_name}.c ) # list the directories the module under test includes set(real_include_directories "") diff --git a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_stubs.c b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_stubs.c index 52e1a290a..d5f5a3548 100644 --- a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_stubs.c +++ b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_stubs.c @@ -14,34 +14,13 @@ /* =========================== EXTERN VARIABLES =========================== */ -/** @brief The pointer to buffer with packet waiting for ARP resolution. This variable +/** @brief The pointer to buffer with packet waiting for ND resolution. This variable * is defined in FreeRTOS_IP.c. * This pointer is for internal use only. */ -NetworkBufferDescriptor_t * pxARPWaitingNetworkBuffer; +NetworkBufferDescriptor_t * pxNDWaitingNetworkBuffer; BaseType_t NetworkInterfaceOutputFunction_Stub_Called = 0; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - /* ======================== Stub Callback Functions ========================= */ BaseType_t NetworkInterfaceOutputFunction_Stub( struct xNetworkInterface * pxDescriptor, diff --git a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c index 084866a1c..672bfac25 100644 --- a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c +++ b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c @@ -43,7 +43,6 @@ #include "mock_queue.h" #include "mock_event_groups.h" -#include "mock_FreeRTOS_ARP.h" #include "mock_FreeRTOS_IP.h" #include "mock_FreeRTOS_IPv6.h" #include "mock_FreeRTOS_IP_Private.h" @@ -523,7 +522,7 @@ void test_vNDRefreshCacheEntry_NoMatchingEntryAdd( void ) /* Since no matching entry will be found, 0th entry will be updated to have the below details. */ vNDRefreshCacheEntry( &xMACAddress, &xIPAddress, &xEndPoint ); - TEST_ASSERT_EQUAL( xNDCache[ xUseEntry ].ucAge, ( uint8_t ) ipconfigMAX_ARP_AGE ); + TEST_ASSERT_EQUAL( xNDCache[ xUseEntry ].ucAge, ( uint8_t ) ipconfigMAX_ND_AGE ); TEST_ASSERT_EQUAL( xNDCache[ xUseEntry ].ucValid, pdTRUE ); TEST_ASSERT_EQUAL_MEMORY( xNDCache[ xUseEntry ].xIPAddress.ucBytes, xIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); TEST_ASSERT_EQUAL_MEMORY( xNDCache[ xUseEntry ].xMACAddress.ucBytes, xMACAddress.ucBytes, sizeof( MACAddress_t ) ); @@ -550,7 +549,7 @@ void test_vNDRefreshCacheEntry_MatchingEntryRefresh( void ) /* Since a matching entry is found at xUseEntry = 1st location, the entry will be refreshed.*/ vNDRefreshCacheEntry( &xMACAddress, &xIPAddress, &xEndPoint ); - TEST_ASSERT_EQUAL( xNDCache[ xUseEntry ].ucAge, ( uint8_t ) ipconfigMAX_ARP_AGE ); + TEST_ASSERT_EQUAL( xNDCache[ xUseEntry ].ucAge, ( uint8_t ) ipconfigMAX_ND_AGE ); TEST_ASSERT_EQUAL_MEMORY( xNDCache[ xUseEntry ].xMACAddress.ucBytes, xMACAddress.ucBytes, sizeof( MACAddress_t ) ); TEST_ASSERT_EQUAL_MEMORY( xNDCache[ xUseEntry ].pxEndPoint, &xEndPoint, sizeof( NetworkEndPoint_t ) ); } @@ -1546,7 +1545,7 @@ void test_prvProcessICMPMessage_IPv6_NeighborSolicitation( void ) /** * @brief This function process ICMP message when message type is * ipICMP_NEIGHBOR_ADVERTISEMENT_IPv6. - * It handles case when pxARPWaitingNetworkBuffer is NULL. + * It handles case when pxNDWaitingNetworkBuffer is NULL. */ void test_prvProcessICMPMessage_IPv6_NeighborAdvertisement1( void ) { @@ -1560,7 +1559,7 @@ void test_prvProcessICMPMessage_IPv6_NeighborAdvertisement1( void ) pxNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) &xICMPPacket; pxNetworkBuffer->pxEndPoint = &xEndPoint; xICMPPacket.xICMPHeaderIPv6.ucTypeOfMessage = ipICMP_NEIGHBOR_ADVERTISEMENT_IPv6; - pxARPWaitingNetworkBuffer = NULL; + pxNDWaitingNetworkBuffer = NULL; eReturn = prvProcessICMPMessage_IPv6( pxNetworkBuffer ); @@ -1580,14 +1579,14 @@ void test_prvProcessICMPMessage_IPv6_NeighborAdvertisement2( void ) ICMPHeader_IPv6_t * pxICMPHeader_IPv6 = ( ( ICMPHeader_IPv6_t * ) &( xICMPPacket.xICMPHeaderIPv6 ) ); NetworkEndPoint_t xEndPoint; eFrameProcessingResult_t eReturn; - NetworkBufferDescriptor_t xARPWaitingNetworkBuffer; + NetworkBufferDescriptor_t xNDWaitingNetworkBuffer; xEndPoint.bits.bIPv6 = pdTRUE_UNSIGNED; pxNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) &xICMPPacket; pxNetworkBuffer->pxEndPoint = &xEndPoint; xICMPPacket.xICMPHeaderIPv6.ucTypeOfMessage = ipICMP_NEIGHBOR_ADVERTISEMENT_IPv6; - pxARPWaitingNetworkBuffer = &xARPWaitingNetworkBuffer; + pxNDWaitingNetworkBuffer = &xNDWaitingNetworkBuffer; uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); eReturn = prvProcessICMPMessage_IPv6( pxNetworkBuffer ); @@ -1598,7 +1597,7 @@ void test_prvProcessICMPMessage_IPv6_NeighborAdvertisement2( void ) /** * @brief This function process ICMP message when message type is * ipICMP_NEIGHBOR_ADVERTISEMENT_IPv6. - * This verifies a case 'pxARPWaitingNetworkBuffer' was + * This verifies a case 'pxNDWaitingNetworkBuffer' was * not waiting for this new address look-up. */ void test_prvProcessICMPMessage_IPv6_NeighborAdvertisement3( void ) @@ -1608,12 +1607,12 @@ void test_prvProcessICMPMessage_IPv6_NeighborAdvertisement3( void ) ICMPHeader_IPv6_t * pxICMPHeader_IPv6 = ( ( ICMPHeader_IPv6_t * ) &( xICMPPacket.xICMPHeaderIPv6 ) ); NetworkEndPoint_t xEndPoint; eFrameProcessingResult_t eReturn; - NetworkBufferDescriptor_t xARPWaitingNetworkBuffer; + NetworkBufferDescriptor_t xNDWaitingNetworkBuffer; IPPacket_IPv6_t xIPPacket; IPHeader_IPv6_t * pxIPHeader = &( xIPPacket.xIPHeader ); - pxARPWaitingNetworkBuffer = &xARPWaitingNetworkBuffer; - pxARPWaitingNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) &xIPPacket; + pxNDWaitingNetworkBuffer = &xNDWaitingNetworkBuffer; + pxNDWaitingNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) &xIPPacket; xEndPoint.bits.bIPv6 = pdTRUE_UNSIGNED; pxNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) &xICMPPacket; pxNetworkBuffer->pxEndPoint = &xEndPoint; @@ -1632,7 +1631,7 @@ void test_prvProcessICMPMessage_IPv6_NeighborAdvertisement3( void ) * ipICMP_NEIGHBOR_ADVERTISEMENT_IPv6. * This verifies a case where a packet is handled as a new * incoming IP packet when a neighbour advertisement has been received, - * and 'pxARPWaitingNetworkBuffer' was waiting for this new address look-up. + * and 'pxNDWaitingNetworkBuffer' was waiting for this new address look-up. */ void test_prvProcessICMPMessage_IPv6_NeighborAdvertisement4( void ) { @@ -1641,12 +1640,12 @@ void test_prvProcessICMPMessage_IPv6_NeighborAdvertisement4( void ) ICMPHeader_IPv6_t * pxICMPHeader_IPv6 = ( ( ICMPHeader_IPv6_t * ) &( xICMPPacket.xICMPHeaderIPv6 ) ); NetworkEndPoint_t xEndPoint; eFrameProcessingResult_t eReturn; - NetworkBufferDescriptor_t xARPWaitingNetworkBuffer; + NetworkBufferDescriptor_t xNDWaitingNetworkBuffer; IPPacket_IPv6_t xIPPacket; IPHeader_IPv6_t * pxIPHeader = &( xIPPacket.xIPHeader ); - pxARPWaitingNetworkBuffer = &xARPWaitingNetworkBuffer; - pxARPWaitingNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) &xIPPacket; + pxNDWaitingNetworkBuffer = &xNDWaitingNetworkBuffer; + pxNDWaitingNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) &xIPPacket; xEndPoint.bits.bIPv6 = pdTRUE_UNSIGNED; pxNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) &xICMPPacket; @@ -1659,12 +1658,12 @@ void test_prvProcessICMPMessage_IPv6_NeighborAdvertisement4( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv6_HEADER ); xSendEventStructToIPTask_IgnoreAndReturn( pdFAIL ); vReleaseNetworkBufferAndDescriptor_Ignore(); - vIPSetARPResolutionTimerEnableState_ExpectAnyArgs(); + vIPSetNDResolutionTimerEnableState_ExpectAnyArgs(); eReturn = prvProcessICMPMessage_IPv6( pxNetworkBuffer ); TEST_ASSERT_EQUAL( eReturn, eReleaseBuffer ); - TEST_ASSERT_EQUAL( pxARPWaitingNetworkBuffer, NULL ); + TEST_ASSERT_EQUAL( pxNDWaitingNetworkBuffer, NULL ); } /** @@ -1672,7 +1671,7 @@ void test_prvProcessICMPMessage_IPv6_NeighborAdvertisement4( void ) * ipICMP_NEIGHBOR_ADVERTISEMENT_IPv6. * This verifies a case where a packet is handled as a new * incoming IP packet when a neighbour advertisement has been received, - * and 'pxARPWaitingNetworkBuffer' was waiting for this new address look-up. + * and 'pxNDWaitingNetworkBuffer' was waiting for this new address look-up. */ void test_prvProcessICMPMessage_IPv6_NeighborAdvertisement5( void ) { @@ -1681,12 +1680,12 @@ void test_prvProcessICMPMessage_IPv6_NeighborAdvertisement5( void ) ICMPHeader_IPv6_t * pxICMPHeader_IPv6 = ( ( ICMPHeader_IPv6_t * ) &( xICMPPacket.xICMPHeaderIPv6 ) ); NetworkEndPoint_t xEndPoint; eFrameProcessingResult_t eReturn; - NetworkBufferDescriptor_t xARPWaitingNetworkBuffer; + NetworkBufferDescriptor_t xNDWaitingNetworkBuffer; IPPacket_IPv6_t xIPPacket; IPHeader_IPv6_t * pxIPHeader = &( xIPPacket.xIPHeader ); - pxARPWaitingNetworkBuffer = &xARPWaitingNetworkBuffer; - pxARPWaitingNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) &xIPPacket; + pxNDWaitingNetworkBuffer = &xNDWaitingNetworkBuffer; + pxNDWaitingNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) &xIPPacket; xEndPoint.bits.bIPv6 = pdTRUE_UNSIGNED; pxNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) &xICMPPacket; @@ -1698,12 +1697,12 @@ void test_prvProcessICMPMessage_IPv6_NeighborAdvertisement5( void ) uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv6_HEADER ); xSendEventStructToIPTask_IgnoreAndReturn( pdPASS ); - vIPSetARPResolutionTimerEnableState_ExpectAnyArgs(); + vIPSetNDResolutionTimerEnableState_ExpectAnyArgs(); eReturn = prvProcessICMPMessage_IPv6( pxNetworkBuffer ); TEST_ASSERT_EQUAL( eReturn, eReleaseBuffer ); - TEST_ASSERT_EQUAL( pxARPWaitingNetworkBuffer, NULL ); + TEST_ASSERT_EQUAL( pxNDWaitingNetworkBuffer, NULL ); } /** diff --git a/test/unit-test/FreeRTOS_ND/ut.cmake b/test/unit-test/FreeRTOS_ND/ut.cmake index 9e113d158..09fbf7bc2 100644 --- a/test/unit-test/FreeRTOS_ND/ut.cmake +++ b/test/unit-test/FreeRTOS_ND/ut.cmake @@ -14,7 +14,6 @@ list(APPEND mock_list "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include/list.h" "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include/queue.h" "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include/event_groups.h" - "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ARP.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Private.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IPv6.h" @@ -113,4 +112,4 @@ create_test(${utest_name} "${utest_link_list}" "${utest_dep_list}" "${test_include_directories}" - ) \ No newline at end of file + ) diff --git a/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_stubs.c b/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_stubs.c index 9369a7394..cd7b72136 100644 --- a/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_stubs.c +++ b/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_stubs.c @@ -42,27 +42,6 @@ uint32_t ulStubFreeRTOS_inet_ntop_TargetSize; const char * pcStubFreeRTOS_inet_ntop_TargetCopySource; uint32_t ulStubFreeRTOS_inet_ntop_CopySize; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - /* ======================== Stub Callback Functions ========================= */ const char * pcStubFreeRTOS_inet_ntop( BaseType_t xAddressFamily, From 6a8b5014881ba4ae872da54ebc764d2b5f4f76be Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sat, 3 Aug 2024 03:52:44 +0000 Subject: [PATCH 08/25] Uncrustify: triggered by comment. --- source/FreeRTOS_ARP.c | 24 +++++++-------- source/FreeRTOS_IP.c | 6 ++-- source/FreeRTOS_IP_Timers.c | 26 ++++++++-------- source/FreeRTOS_IP_Utils.c | 1 + source/FreeRTOS_ND.c | 21 ++++++------- source/FreeRTOS_TCP_Transmission_IPv4.c | 8 ++--- source/FreeRTOS_TCP_Transmission_IPv6.c | 8 ++--- source/FreeRTOS_UDP_IPv6.c | 2 +- source/include/FreeRTOS_ARP.h | 8 ++--- source/include/FreeRTOS_IP_Timers.h | 30 ++++++++++--------- source/include/FreeRTOS_ND.h | 6 ++-- source/include/FreeRTOS_Routing.h | 6 ++-- .../ARPProcessPacket_harness.c | 4 +-- .../xCheckRequiresARPResolution_harness.c | 4 +-- .../TCPReturnPacket_harness.c | 4 +-- .../TCPReturnPacket_IPv6_harness.c | 4 +-- .../vProcessGeneratedUDPPacket_harness.c | 2 +- .../vProcessGeneratedUDPPacket_IPv6_harness.c | 4 +-- .../unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c | 4 +-- 19 files changed, 90 insertions(+), 82 deletions(-) diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index 654e566e3..c6134b0af 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -95,12 +95,12 @@ * Lookup an MAC address in the ARP cache from the IP address. */ static eResolutionLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, - MACAddress_t * const pxMACAddress, - NetworkEndPoint_t ** ppxEndPoint ); + MACAddress_t * const pxMACAddress, + NetworkEndPoint_t ** ppxEndPoint ); static eResolutionLookupResult_t eARPGetCacheEntryGateWay( uint32_t * pulIPAddress, - MACAddress_t * const pxMACAddress, - struct xNetworkEndPoint ** ppxEndPoint ); + MACAddress_t * const pxMACAddress, + struct xNetworkEndPoint ** ppxEndPoint ); static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, const uint32_t ulIPAddress, @@ -822,8 +822,8 @@ * @return Either eResolutionCacheMiss or eResolutionCacheHit. */ eResolutionLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, - uint32_t * pulIPAddress, - struct xNetworkInterface ** ppxInterface ) + uint32_t * pulIPAddress, + struct xNetworkInterface ** ppxInterface ) { BaseType_t x; eResolutionLookupResult_t eReturn = eResolutionCacheMiss; @@ -878,8 +878,8 @@ * eResolutionFailed. */ eResolutionLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, - MACAddress_t * const pxMACAddress, - struct xNetworkEndPoint ** ppxEndPoint ) + MACAddress_t * const pxMACAddress, + struct xNetworkEndPoint ** ppxEndPoint ) { eResolutionLookupResult_t eReturn; uint32_t ulAddressToLookup; @@ -945,8 +945,8 @@ * @param[out] ppxEndPoint The end-point of the gateway will be copy to the pointee. */ static eResolutionLookupResult_t eARPGetCacheEntryGateWay( uint32_t * pulIPAddress, - MACAddress_t * const pxMACAddress, - struct xNetworkEndPoint ** ppxEndPoint ) + MACAddress_t * const pxMACAddress, + struct xNetworkEndPoint ** ppxEndPoint ) { eResolutionLookupResult_t eReturn = eResolutionCacheMiss; uint32_t ulAddressToLookup = *( pulIPAddress ); @@ -1040,8 +1040,8 @@ * and when waiting for a ARP reply: eResolutionFailed. */ static eResolutionLookupResult_t prvCacheLookup( uint32_t ulAddressToLookup, - MACAddress_t * const pxMACAddress, - NetworkEndPoint_t ** ppxEndPoint ) + MACAddress_t * const pxMACAddress, + NetworkEndPoint_t ** ppxEndPoint ) { BaseType_t x; eResolutionLookupResult_t eReturn = eResolutionCacheMiss; diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index f80f12f5e..99a172e23 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1793,9 +1793,10 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor iptraceDELAYED_ARP_BUFFER_FULL(); } + break; } - #endif + #endif /* if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) */ #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) if( pxEthernetHeader->usFrameType == ipIPv6_FRAME_TYPE ) @@ -1814,9 +1815,10 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor iptraceDELAYED_ND_BUFFER_FULL(); } + break; } - #endif + #endif /* if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) */ break; diff --git a/source/FreeRTOS_IP_Timers.c b/source/FreeRTOS_IP_Timers.c index e5ce73fbd..2edf0c675 100644 --- a/source/FreeRTOS_IP_Timers.c +++ b/source/FreeRTOS_IP_Timers.c @@ -95,6 +95,7 @@ static void prvIPTimerReload( IPTimer_t * pxTimer, */ #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + /** @brief Timer to limit the maximum time a packet should be stored while * awaiting an ARP resolution. */ static IPTimer_t xARPResolutionTimer; @@ -103,6 +104,7 @@ static void prvIPTimerReload( IPTimer_t * pxTimer, static IPTimer_t xARPTimer; #endif #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + /** @brief Timer to limit the maximum time a packet should be stored while * awaiting an ND resolution. */ static IPTimer_t xNDResolutionTimer; @@ -250,7 +252,7 @@ void vCheckNetworkTimers( void ) iptraceDELAYED_ARP_TIMER_EXPIRED(); } } - #endif + #endif /* if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) */ #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) /* Is it time for ND processing? */ @@ -277,7 +279,7 @@ void vCheckNetworkTimers( void ) iptraceDELAYED_ND_TIMER_EXPIRED(); } } - #endif + #endif /* if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) */ #if ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) { @@ -473,10 +475,10 @@ static void prvIPTimerReload( IPTimer_t * pxTimer, * * @param[in] xTime Time to be reloaded into the ARP timer. */ -void vARPTimerReload( TickType_t xTime ) -{ - prvIPTimerReload( &xARPTimer, xTime ); -} + void vARPTimerReload( TickType_t xTime ) + { + prvIPTimerReload( &xARPTimer, xTime ); + } #endif /*-----------------------------------------------------------*/ @@ -487,10 +489,10 @@ void vARPTimerReload( TickType_t xTime ) * * @param[in] xTime Time to be reloaded into the ND timer. */ -void vNDTimerReload( TickType_t xTime ) -{ - prvIPTimerReload( &xNDTimer, xTime ); -} + void vNDTimerReload( TickType_t xTime ) + { + prvIPTimerReload( &xNDTimer, xTime ); + } #endif /*-----------------------------------------------------------*/ @@ -639,7 +641,7 @@ static BaseType_t prvIPTimerCheck( IPTimer_t * pxTimer ) xARPResolutionTimer.bActive = pdFALSE_UNSIGNED; } } -#endif +#endif /* if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) */ /*-----------------------------------------------------------*/ #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) @@ -678,7 +680,7 @@ static BaseType_t prvIPTimerCheck( IPTimer_t * pxTimer ) xNDResolutionTimer.bActive = pdFALSE_UNSIGNED; } } -#endif +#endif /* if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) */ /*-----------------------------------------------------------*/ #if ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) || ( ipconfigUSE_DHCPv6 == 1 ) diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index f1bae8a0a..02e1cbe46 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -872,6 +872,7 @@ void prvProcessNetworkDownEvent( struct xNetworkInterface * pxInterface ) #endif /* ipconfigUSE_NETWORK_EVENT_HOOK */ #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + /* Per the ARP Cache Validation section of https://tools.ietf.org/html/rfc1122 * treat network down as a "delivery problem" and flush the ARP cache for this * interface. */ diff --git a/source/FreeRTOS_ND.c b/source/FreeRTOS_ND.c index 4350ad39d..934371882 100644 --- a/source/FreeRTOS_ND.c +++ b/source/FreeRTOS_ND.c @@ -79,13 +79,13 @@ /** @brief See if the MAC-address can be resolved because it is a multi-cast address. */ static eResolutionLookupResult_t prvMACResolve( const IPv6_Address_t * pxAddressToLookup, - MACAddress_t * const pxMACAddress, - NetworkEndPoint_t ** ppxEndPoint ); + MACAddress_t * const pxMACAddress, + NetworkEndPoint_t ** ppxEndPoint ); /** @brief Lookup an MAC address in the ND cache from the IP address. */ static eResolutionLookupResult_t prvNDCacheLookup( const IPv6_Address_t * pxAddressToLookup, - MACAddress_t * const pxMACAddress, - NetworkEndPoint_t ** ppxEndPoint ); + MACAddress_t * const pxMACAddress, + NetworkEndPoint_t ** ppxEndPoint ); #if ( ipconfigHAS_PRINTF == 1 ) static const char * pcMessageType( BaseType_t xType ); @@ -147,8 +147,8 @@ * @return An enum, either eResolutionCacheHit or eResolutionCacheMiss. */ static eResolutionLookupResult_t prvMACResolve( const IPv6_Address_t * pxAddressToLookup, - MACAddress_t * const pxMACAddress, - NetworkEndPoint_t ** ppxEndPoint ) + MACAddress_t * const pxMACAddress, + NetworkEndPoint_t ** ppxEndPoint ) { eResolutionLookupResult_t eReturn; @@ -185,8 +185,8 @@ * @return An enum which says whether the address was found: eResolutionCacheHit or eResolutionCacheMiss. */ eResolutionLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, - MACAddress_t * const pxMACAddress, - struct xNetworkEndPoint ** ppxEndPoint ) + MACAddress_t * const pxMACAddress, + struct xNetworkEndPoint ** ppxEndPoint ) { eResolutionLookupResult_t eReturn; NetworkEndPoint_t * pxEndPoint; @@ -424,6 +424,7 @@ void FreeRTOS_ClearND( const struct xNetworkEndPoint * pxEndPoint ) { ( void ) memset( xNDCache, 0, sizeof( xNDCache ) ); + if( pxEndPoint != NULL ) { BaseType_t x; @@ -453,8 +454,8 @@ * @return An enum: either eResolutionCacheHit or eResolutionCacheMiss. */ static eResolutionLookupResult_t prvNDCacheLookup( const IPv6_Address_t * pxAddressToLookup, - MACAddress_t * const pxMACAddress, - NetworkEndPoint_t ** ppxEndPoint ) + MACAddress_t * const pxMACAddress, + NetworkEndPoint_t ** ppxEndPoint ) { BaseType_t x; eResolutionLookupResult_t eReturn = eResolutionCacheMiss; diff --git a/source/FreeRTOS_TCP_Transmission_IPv4.c b/source/FreeRTOS_TCP_Transmission_IPv4.c index db744fc02..f341b09ac 100644 --- a/source/FreeRTOS_TCP_Transmission_IPv4.c +++ b/source/FreeRTOS_TCP_Transmission_IPv4.c @@ -351,11 +351,11 @@ BaseType_t prvTCPPrepareConnect_IPV4( FreeRTOS_Socket_t * pxSocket ) switch( eReturned ) { - case eResolutionCacheHit: /* An ARP table lookup found a valid entry. */ - break; /* We can now prepare the SYN packet. */ + case eResolutionCacheHit: /* An ARP table lookup found a valid entry. */ + break; /* We can now prepare the SYN packet. */ - case eResolutionCacheMiss: /* An ARP table lookup did not find a valid entry. */ - case eResolutionFailed: /* There is no IP address, or an ARP is still in progress. */ + case eResolutionCacheMiss: /* An ARP table lookup did not find a valid entry. */ + case eResolutionFailed: /* There is no IP address, or an ARP is still in progress. */ default: /* Count the number of times it could not find the ARP address. */ pxSocket->u.xTCP.ucRepCount++; diff --git a/source/FreeRTOS_TCP_Transmission_IPv6.c b/source/FreeRTOS_TCP_Transmission_IPv6.c index c0a39f7f2..1a3cc3620 100644 --- a/source/FreeRTOS_TCP_Transmission_IPv6.c +++ b/source/FreeRTOS_TCP_Transmission_IPv6.c @@ -351,11 +351,11 @@ BaseType_t prvTCPPrepareConnect_IPV6( FreeRTOS_Socket_t * pxSocket ) switch( eReturned ) { - case eResolutionCacheHit: /* An ND table lookup found a valid entry. */ - break; /* We can now prepare the SYN packet. */ + case eResolutionCacheHit: /* An ND table lookup found a valid entry. */ + break; /* We can now prepare the SYN packet. */ - case eResolutionCacheMiss: /* An ND table lookup did not find a valid entry. */ - case eResolutionFailed: /* There is no IP address, or an ND is still in progress. */ + case eResolutionCacheMiss: /* An ND table lookup did not find a valid entry. */ + case eResolutionFailed: /* There is no IP address, or an ND is still in progress. */ default: /* Count the number of times it could not find the ND address. */ pxSocket->u.xTCP.ucRepCount++; diff --git a/source/FreeRTOS_UDP_IPv6.c b/source/FreeRTOS_UDP_IPv6.c index 3be2f3ffa..1efd1927a 100644 --- a/source/FreeRTOS_UDP_IPv6.c +++ b/source/FreeRTOS_UDP_IPv6.c @@ -122,7 +122,7 @@ static NetworkEndPoint_t * pxGetEndpoint( BaseType_t xIPType, * ( the ownership was taken ). */ static eResolutionLookupResult_t prvStartLookup( NetworkBufferDescriptor_t * const pxNetworkBuffer, - BaseType_t * pxLostBuffer ) + BaseType_t * pxLostBuffer ) { eResolutionLookupResult_t eReturned = eResolutionCacheMiss; diff --git a/source/include/FreeRTOS_ARP.h b/source/include/FreeRTOS_ARP.h index 8d343913d..e01ece18a 100644 --- a/source/include/FreeRTOS_ARP.h +++ b/source/include/FreeRTOS_ARP.h @@ -120,15 +120,15 @@ BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetw * isn't a gateway defined) then return eResolutionFailed. */ eResolutionLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, - MACAddress_t * const pxMACAddress, - struct xNetworkEndPoint ** ppxEndPoint ); + MACAddress_t * const pxMACAddress, + struct xNetworkEndPoint ** ppxEndPoint ); #if ( ipconfigUSE_ARP_REVERSED_LOOKUP != 0 ) /* Lookup an IP-address if only the MAC-address is known */ eResolutionLookupResult_t eARPGetCacheEntryByMac( const MACAddress_t * const pxMACAddress, - uint32_t * pulIPAddress, - struct xNetworkInterface ** ppxInterface ); + uint32_t * pulIPAddress, + struct xNetworkInterface ** ppxInterface ); #endif diff --git a/source/include/FreeRTOS_IP_Timers.h b/source/include/FreeRTOS_IP_Timers.h index 0c7328911..3f23ffe34 100644 --- a/source/include/FreeRTOS_IP_Timers.h +++ b/source/include/FreeRTOS_IP_Timers.h @@ -78,6 +78,7 @@ TickType_t xCalculateSleepTime( void ); void vIPSetTCPTimerExpiredState( BaseType_t xExpiredState ); #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + /** * Sets the reload time of an ARP timer and restarts it. */ @@ -97,29 +98,30 @@ void vIPSetTCPTimerExpiredState( BaseType_t xExpiredState ); * Enable or disable the ARP resolution timer. */ void vIPSetARPResolutionTimerEnableState( BaseType_t xEnableState ); -#endif +#endif /* if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) */ #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) - /** - * Sets the reload time of an ND timer and restarts it. - */ + +/** + * Sets the reload time of an ND timer and restarts it. + */ void vNDTimerReload( TickType_t xTime ); - /* - * Start an ND Resolution timer. - */ +/* + * Start an ND Resolution timer. + */ void vIPTimerStartNDResolution( TickType_t xTime ); - /* - * Enable/disable the ND timer. - */ +/* + * Enable/disable the ND timer. + */ void vIPSetNDTimerEnableState( BaseType_t xEnableState ); - /* - * Enable or disable the ARP resolution timer. - */ +/* + * Enable or disable the ARP resolution timer. + */ void vIPSetNDResolutionTimerEnableState( BaseType_t xEnableState ); -#endif +#endif /* if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) */ #if ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) diff --git a/source/include/FreeRTOS_ND.h b/source/include/FreeRTOS_ND.h index 9ca2d32af..e6119f05c 100644 --- a/source/include/FreeRTOS_ND.h +++ b/source/include/FreeRTOS_ND.h @@ -94,8 +94,8 @@ * isn't a gateway defined) then return eResolutionFailed. */ eResolutionLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, - MACAddress_t * const pxMACAddress, - struct xNetworkEndPoint ** ppxEndPoint ); + MACAddress_t * const pxMACAddress, + struct xNetworkEndPoint ** ppxEndPoint ); /** * @brief Reduce the age counter in each entry within the ND cache. An entry is no @@ -206,7 +206,7 @@ BaseType_t xCheckRequiresNDResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer ); - /* Clear all entries in the ND cache. */ +/* Clear all entries in the ND cache. */ void FreeRTOS_ClearND( const struct xNetworkEndPoint * pxEndPoint ); void vNDSendUnsolicited( void ); diff --git a/source/include/FreeRTOS_Routing.h b/source/include/FreeRTOS_Routing.h index 9469eb6b1..dc45a0d67 100644 --- a/source/include/FreeRTOS_Routing.h +++ b/source/include/FreeRTOS_Routing.h @@ -375,9 +375,9 @@ typedef enum { - eResolutionCacheMiss = 0, /* 0 A cache lookup did not find a valid entry. */ - eResolutionCacheHit, /* 1 A cache lookup found a valid entry. */ - eResolutionFailed /* 2 There is no IP address, or a resolution is still in progress, so the packet cannot be sent. */ + eResolutionCacheMiss = 0, /* 0 A cache lookup did not find a valid entry. */ + eResolutionCacheHit, /* 1 A cache lookup found a valid entry. */ + eResolutionFailed /* 2 There is no IP address, or a resolution is still in progress, so the packet cannot be sent. */ } eResolutionLookupResult_t; #ifdef __cplusplus diff --git a/test/cbmc/proofs/ARP/ARPProcessPacket/ARPProcessPacket_harness.c b/test/cbmc/proofs/ARP/ARPProcessPacket/ARPProcessPacket_harness.c index 98841d9d0..b170e22cb 100644 --- a/test/cbmc/proofs/ARP/ARPProcessPacket/ARPProcessPacket_harness.c +++ b/test/cbmc/proofs/ARP/ARPProcessPacket/ARPProcessPacket_harness.c @@ -47,8 +47,8 @@ void FreeRTOS_OutputARPRequest_Multi( NetworkEndPoint_t * pxEndPoint, /* This function is proved elsewhere hence stubbing it out */ eResolutionLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, - MACAddress_t * const pxMACAddress, - struct xNetworkEndPoint ** ppxEndPoint ) + MACAddress_t * const pxMACAddress, + struct xNetworkEndPoint ** ppxEndPoint ) { eResolutionLookupResult_t eReturn; diff --git a/test/cbmc/proofs/ARP/xCheckRequiresARPResolution/xCheckRequiresARPResolution_harness.c b/test/cbmc/proofs/ARP/xCheckRequiresARPResolution/xCheckRequiresARPResolution_harness.c index 995a98a5e..e5673ef8d 100644 --- a/test/cbmc/proofs/ARP/xCheckRequiresARPResolution/xCheckRequiresARPResolution_harness.c +++ b/test/cbmc/proofs/ARP/xCheckRequiresARPResolution/xCheckRequiresARPResolution_harness.c @@ -56,8 +56,8 @@ IPv6_Type_t xIPv6_GetIPType( const IPv6_Address_t * pxAddress ) /* Abstraction of eNDGetCacheEntry. */ eResolutionLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, - MACAddress_t * const pxMACAddress, - struct xNetworkEndPoint ** ppxEndPoint ) + MACAddress_t * const pxMACAddress, + struct xNetworkEndPoint ** ppxEndPoint ) { eResolutionLookupResult_t xReturn; diff --git a/test/cbmc/proofs/TCP/prvTCPReturnPacket/TCPReturnPacket_harness.c b/test/cbmc/proofs/TCP/prvTCPReturnPacket/TCPReturnPacket_harness.c index ffbbba664..02009b61f 100644 --- a/test/cbmc/proofs/TCP/prvTCPReturnPacket/TCPReturnPacket_harness.c +++ b/test/cbmc/proofs/TCP/prvTCPReturnPacket/TCPReturnPacket_harness.c @@ -174,8 +174,8 @@ uint16_t usGenerateChecksum( uint16_t usSum, /* This function has been tested separately. Therefore, we assume that the implementation is correct. */ eResolutionLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, - MACAddress_t * const pxMACAddress, - struct xNetworkEndPoint ** ppxEndPoint ) + MACAddress_t * const pxMACAddress, + struct xNetworkEndPoint ** ppxEndPoint ) { /* Assume random ARP lookup result. */ eResolutionLookupResult_t eReturn; diff --git a/test/cbmc/proofs/TCP/prvTCPReturnPacket_IPv6/TCPReturnPacket_IPv6_harness.c b/test/cbmc/proofs/TCP/prvTCPReturnPacket_IPv6/TCPReturnPacket_IPv6_harness.c index c41918980..a5d1827c8 100644 --- a/test/cbmc/proofs/TCP/prvTCPReturnPacket_IPv6/TCPReturnPacket_IPv6_harness.c +++ b/test/cbmc/proofs/TCP/prvTCPReturnPacket_IPv6/TCPReturnPacket_IPv6_harness.c @@ -97,8 +97,8 @@ void prvTCPReturnPacket_IPV4( FreeRTOS_Socket_t * pxSocket, /* Abstraction of eNDGetCacheEntry. */ eResolutionLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, - MACAddress_t * const pxMACAddress, - struct xNetworkEndPoint ** ppxEndPoint ) + MACAddress_t * const pxMACAddress, + struct xNetworkEndPoint ** ppxEndPoint ) { eResolutionLookupResult_t xReturn; diff --git a/test/cbmc/proofs/UDP/vProcessGeneratedUDPPacket/vProcessGeneratedUDPPacket_harness.c b/test/cbmc/proofs/UDP/vProcessGeneratedUDPPacket/vProcessGeneratedUDPPacket_harness.c index 6a51a5a68..1ff6cf86b 100644 --- a/test/cbmc/proofs/UDP/vProcessGeneratedUDPPacket/vProcessGeneratedUDPPacket_harness.c +++ b/test/cbmc/proofs/UDP/vProcessGeneratedUDPPacket/vProcessGeneratedUDPPacket_harness.c @@ -70,7 +70,7 @@ void vARPGenerateRequestPacket( NetworkBufferDescriptor_t * const pxNetworkBuffe /* This function has been tested separately. Therefore, we assume that the implementation is correct. */ eResolutionLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, - MACAddress_t * const pxMACAddress ) + MACAddress_t * const pxMACAddress ) { __CPROVER_assert( pulIPAddress != NULL, "pulIPAddress cannot be NULL" ); __CPROVER_assert( pxMACAddress != NULL, "pxMACAddress cannot be NULL" ); diff --git a/test/cbmc/proofs/UDP/vProcessGeneratedUDPPacket_IPv6/vProcessGeneratedUDPPacket_IPv6_harness.c b/test/cbmc/proofs/UDP/vProcessGeneratedUDPPacket_IPv6/vProcessGeneratedUDPPacket_IPv6_harness.c index ed34fd3ae..f4e7d9e97 100644 --- a/test/cbmc/proofs/UDP/vProcessGeneratedUDPPacket_IPv6/vProcessGeneratedUDPPacket_IPv6_harness.c +++ b/test/cbmc/proofs/UDP/vProcessGeneratedUDPPacket_IPv6/vProcessGeneratedUDPPacket_IPv6_harness.c @@ -49,8 +49,8 @@ uint16_t usGenerateProtocolChecksum( const uint8_t * const pucEthernetBuffer, /* This function has been tested separately. Therefore, we assume that the implementation is correct. */ eResolutionLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, - MACAddress_t * const pxMACAddress, - struct xNetworkEndPoint ** ppxEndPoint ) + MACAddress_t * const pxMACAddress, + struct xNetworkEndPoint ** ppxEndPoint ) { eResolutionLookupResult_t eResult; diff --git a/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c b/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c index e6c503f5f..e88ec7747 100644 --- a/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c +++ b/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_stubs.c @@ -30,8 +30,8 @@ * isn't a gateway defined) then return eResolutionFailed. */ eResolutionLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress, - MACAddress_t * const pxMACAddress, - struct xNetworkEndPoint ** ppxEndPoint ) + MACAddress_t * const pxMACAddress, + struct xNetworkEndPoint ** ppxEndPoint ) { memset( pxMACAddress, 0, sizeof( MACAddress_t ) ); From 973fbc471aeac02acfa5d6b9aba9625ad6a276a3 Mon Sep 17 00:00:00 2001 From: Holden Date: Sun, 25 Aug 2024 18:41:56 -0400 Subject: [PATCH 09/25] Fix Tests --- .github/.cSpellWords.txt | 1 + .../FreeRTOS_ARP/FreeRTOS_ARP_utest.c | 10 ++++---- .../ut.cmake | 2 +- .../unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c | 24 +++++++++---------- .../FreeRTOS_IP_Timers_stubs.c | 1 + test/unit-test/FreeRTOS_IP_Utils/ut.cmake | 1 + .../FreeRTOS_Routing/FreeRTOS_Routing_utest.c | 4 ++-- .../FreeRTOS_TCP_Transmission_utest.c | 2 +- .../FreeRTOS_TCP_Transmission_IPv6_utest.c | 2 +- 9 files changed, 25 insertions(+), 22 deletions(-) diff --git a/.github/.cSpellWords.txt b/.github/.cSpellWords.txt index ed12e1e9c..a17936017 100644 --- a/.github/.cSpellWords.txt +++ b/.github/.cSpellWords.txt @@ -1263,6 +1263,7 @@ STLIDMPUSR STLIMPUOR STLNVICACTVOR STLNVICPENDOR +Storex strbt STRBT strexb diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c index b0e3d04c1..e75eee978 100644 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c @@ -1961,7 +1961,7 @@ void test_eARPGetCacheEntryByMac_NoMatchingEntries( void ) eResolutionLookupResult_t eResult; MACAddress_t xMACAddress = { 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 }; int i; - struct xNetworkInterface * xInterface; + NetworkInterface_t xInterface, * pxInterface = &xInterface; /* =================================================== */ /* Make sure no entry matches. */ @@ -1971,7 +1971,7 @@ void test_eARPGetCacheEntryByMac_NoMatchingEntries( void ) memset( xARPCache[ i ].xMACAddress.ucBytes, 0x11, sizeof( xMACAddress.ucBytes ) ); } - eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &xInterface ); + eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &pxInterface ); TEST_ASSERT_EQUAL( eResolutionCacheMiss, eResult ); TEST_ASSERT_EQUAL( 0x12345678, ulIPAddress ); /* =================================================== */ @@ -1984,7 +1984,7 @@ void test_eARPGetCacheEntryByMac_OneMatchingEntry( void ) MACAddress_t xMACAddress = { 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 }; int i; NetworkEndPoint_t xNetworkEndPoint = { 0 }; - NetworkInterface_t xInterface, * pxInterface = NULL; + NetworkInterface_t xInterface, * pxInterface = &xInterface; xNetworkEndPoint.pxNetworkInterface = &xInterface; @@ -2000,7 +2000,7 @@ void test_eARPGetCacheEntryByMac_OneMatchingEntry( void ) ulEntryToTest = 1; memset( xARPCache[ ulEntryToTest ].xMACAddress.ucBytes, 0x22, sizeof( xMACAddress.ucBytes ) ); xARPCache[ ulEntryToTest ].ulIPAddress = 0xAABBCCEE; - eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &xInterface ); + eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &pxInterface ); TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); TEST_ASSERT_EQUAL( xARPCache[ ulEntryToTest ].ulIPAddress, ulIPAddress ); TEST_ASSERT_EQUAL( &xInterface, pxInterface ); @@ -2010,7 +2010,7 @@ void test_eARPGetCacheEntryByMac_OneMatchingEntry( void ) TEST_ASSERT_EQUAL( xARPCache[ ulEntryToTest ].ulIPAddress, ulIPAddress ); /* =================================================== */ xARPCache[ ulEntryToTest ].pxEndPoint = NULL; - eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &xInterface ); + eResult = eARPGetCacheEntryByMac( &xMACAddress, &ulIPAddress, &pxInterface ); TEST_ASSERT_EQUAL( eResolutionCacheHit, eResult ); TEST_ASSERT_EQUAL( xARPCache[ ulEntryToTest ].ulIPAddress, ulIPAddress ); /* =================================================== */ diff --git a/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake b/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake index 645595565..949036f43 100644 --- a/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake +++ b/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake @@ -41,7 +41,7 @@ list(APPEND mock_define_list # list the files you would like to test here set(real_source_files "") list(APPEND real_source_files - ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources/${project_name}.c + ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources/FreeRTOS_ARP.c ) # list the directories the module under test includes set(real_include_directories "") diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c index ff9a69706..5f2c192c5 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c @@ -2116,7 +2116,7 @@ void test_prvProcessEthernetPacket_ARPFrameType2( void ) /** * @brief test_prvProcessEthernetPacket_ARPFrameType_WaitingARPResolution - * To validate the flow to handle ARP packets but eARPProcessPacket() returns eWaitingARPResolution + * To validate the flow to handle ARP packets but eARPProcessPacket() returns eWaitingResolution * without pxARPWaitingNetworkBuffer. */ void test_prvProcessEthernetPacket_ARPFrameType_WaitingARPResolution( void ) @@ -2141,7 +2141,7 @@ void test_prvProcessEthernetPacket_ARPFrameType_WaitingARPResolution( void ) pxEthernetHeader->usFrameType = ipARP_FRAME_TYPE; - eARPProcessPacket_ExpectAndReturn( pxNetworkBuffer, eWaitingARPResolution ); + eARPProcessPacket_ExpectAndReturn( pxNetworkBuffer, eWaitingResolution ); vIPTimerStartARPResolution_ExpectAnyArgs(); @@ -2150,7 +2150,7 @@ void test_prvProcessEthernetPacket_ARPFrameType_WaitingARPResolution( void ) /** * @brief test_prvProcessEthernetPacket_ARPFrameType_WaitingARPResolution2 - * To validate the flow to handle ARP packets but eARPProcessPacket() returns eWaitingARPResolution + * To validate the flow to handle ARP packets but eARPProcessPacket() returns eWaitingResolution * with pxARPWaitingNetworkBuffer. */ void test_prvProcessEthernetPacket_ARPFrameType_WaitingARPResolution2( void ) @@ -2175,7 +2175,7 @@ void test_prvProcessEthernetPacket_ARPFrameType_WaitingARPResolution2( void ) pxEthernetHeader->usFrameType = ipARP_FRAME_TYPE; - eARPProcessPacket_ExpectAndReturn( pxNetworkBuffer, eWaitingARPResolution ); + eARPProcessPacket_ExpectAndReturn( pxNetworkBuffer, eWaitingResolution ); vReleaseNetworkBufferAndDescriptor_Expect( pxNetworkBuffer ); @@ -2489,7 +2489,7 @@ void test_prvProcessIPPacket_ValidHeader_ARPResolutionReqd( void ) eResult = prvProcessIPPacket( pxIPPacket, pxNetworkBuffer ); - TEST_ASSERT_EQUAL( eWaitingARPResolution, eResult ); + TEST_ASSERT_EQUAL( eWaitingResolution, eResult ); } /** @@ -2825,12 +2825,12 @@ void test_prvProcessIPPacket_ARPResolutionReqd_UDP( void ) prvAllowIPPacketIPv4_ExpectAndReturn( pxIPPacket, pxNetworkBuffer, ( pxIPHeader->ucVersionHeaderLength & 0x0FU ) << 2, eProcessBuffer ); xProcessReceivedUDPPacket_ExpectAndReturn( pxNetworkBuffer, pxUDPPacket->xUDPHeader.usDestinationPort, NULL, pdFAIL ); - xProcessReceivedUDPPacket_IgnoreArg_pxIsWaitingForARPResolution(); - xProcessReceivedUDPPacket_ReturnThruPtr_pxIsWaitingForARPResolution( &xReturnValue ); + xProcessReceivedUDPPacket_IgnoreArg_pxIsWaitingForResolution(); + xProcessReceivedUDPPacket_ReturnThruPtr_pxIsWaitingForResolution( &xReturnValue ); eResult = prvProcessIPPacket( pxIPPacket, pxNetworkBuffer ); - TEST_ASSERT_EQUAL( eWaitingARPResolution, eResult ); + TEST_ASSERT_EQUAL( eWaitingResolution, eResult ); TEST_ASSERT_EQUAL( FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) - sizeof( UDPHeader_t ) + sizeof( UDPPacket_t ), pxNetworkBuffer->xDataLength ); TEST_ASSERT_EQUAL( pxNetworkBuffer->usPort, pxUDPPacket->xUDPHeader.usSourcePort ); TEST_ASSERT_EQUAL( pxNetworkBuffer->xIPAddress.ulIP_IPv4, pxUDPPacket->xIPHeader.ulSourceIPAddress ); @@ -2876,12 +2876,12 @@ void test_prvProcessIPPacket_ARPResolutionReqd_UDP1( void ) prvAllowIPPacketIPv4_ExpectAndReturn( pxIPPacket, pxNetworkBuffer, ( pxIPHeader->ucVersionHeaderLength & 0x0FU ) << 2, eProcessBuffer ); xProcessReceivedUDPPacket_ExpectAndReturn( pxNetworkBuffer, pxUDPPacket->xUDPHeader.usDestinationPort, NULL, pdFAIL ); - xProcessReceivedUDPPacket_IgnoreArg_pxIsWaitingForARPResolution(); - xProcessReceivedUDPPacket_ReturnThruPtr_pxIsWaitingForARPResolution( &xReturnValue ); + xProcessReceivedUDPPacket_IgnoreArg_pxIsWaitingForResolution(); + xProcessReceivedUDPPacket_ReturnThruPtr_pxIsWaitingForResolution( &xReturnValue ); eResult = prvProcessIPPacket( pxIPPacket, pxNetworkBuffer ); - TEST_ASSERT_EQUAL( eWaitingARPResolution, eResult ); + TEST_ASSERT_EQUAL( eWaitingResolution, eResult ); TEST_ASSERT_EQUAL( pxNetworkBuffer->usPort, pxUDPPacket->xUDPHeader.usSourcePort ); TEST_ASSERT_EQUAL( pxNetworkBuffer->xIPAddress.ulIP_IPv4, pxUDPPacket->xIPHeader.ulSourceIPAddress ); } @@ -3360,7 +3360,7 @@ void test_prvProcessIPPacket_TCP_IPv6_ARPResolution( void ) eResult = prvProcessIPPacket( ( IPPacket_t * ) pxIPPacket, pxNetworkBuffer ); - TEST_ASSERT_EQUAL( eWaitingARPResolution, eResult ); + TEST_ASSERT_EQUAL( eWaitingResolution, eResult ); } /** diff --git a/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c b/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c index 2674e6408..11feca071 100644 --- a/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c +++ b/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c @@ -43,6 +43,7 @@ volatile BaseType_t xInsideInterrupt = pdFALSE; NetworkBufferDescriptor_t * pxARPWaitingNetworkBuffer; +NetworkBufferDescriptor_t * pxNDWaitingNetworkBuffer; struct xNetworkEndPoint * pxNetworkEndPoints; struct xNetworkInterface * pxNetworkInterfaces; diff --git a/test/unit-test/FreeRTOS_IP_Utils/ut.cmake b/test/unit-test/FreeRTOS_IP_Utils/ut.cmake index 8c5f73078..70d93eed9 100644 --- a/test/unit-test/FreeRTOS_IP_Utils/ut.cmake +++ b/test/unit-test/FreeRTOS_IP_Utils/ut.cmake @@ -18,6 +18,7 @@ list(APPEND mock_list "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Private.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Timers.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ARP.h" + "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ND.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DHCP.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DHCPv6.h" "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Routing.h" diff --git a/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_utest.c b/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_utest.c index 8a10c4a7f..134aacbf6 100644 --- a/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_utest.c +++ b/test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_utest.c @@ -3680,13 +3680,13 @@ void test_xCheckRequiresResolution( void ) IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); - *ipLOCAL_IP_ADDRESS_POINTER = 0xABCD1234; + xEndPoint.ipv4_settings.ulIPAddress = 0xABCD1234; xEndPoint.ipv4_settings.ulNetMask = 0xFFFFFF00; xNetworkBuffer.pxEndPoint = &xEndPoint; /* Make sure there is no match. */ - pxIPHeader->ulSourceIPAddress = ~( *ipLOCAL_IP_ADDRESS_POINTER & xEndPoint.ipv4_settings.ulNetMask ); + pxIPHeader->ulSourceIPAddress = ~( xEndPoint.ipv4_settings.ulIPAddress & xEndPoint.ipv4_settings.ulNetMask ); uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); xCheckRequiresARPResolution_IgnoreAndReturn( pdFALSE ); diff --git a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c index 4980db9eb..bdfae7693 100644 --- a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c +++ b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c @@ -1212,7 +1212,7 @@ void test_prvTCPPrepareConnect_Ready_TCPWindowCreateFail( void ) pxSocket->u.xTCP.bits.bConnPrepared = pdFALSE; pxSocket->bits.bIsIPv6 = pdFALSE; - eARPGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eARPGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); ulApplicationGetNextSequenceNumber_ExpectAnyArgsAndReturn( 0x11111111 ); prvSocketSetMSS_ExpectAnyArgs(); xTCPWindowCreate_ExpectAnyArgsAndReturn( pdFAIL ); diff --git a/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c b/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c index b840ebb61..31c4339ce 100644 --- a/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c +++ b/test/unit-test/FreeRTOS_TCP_Transmission_IPv6/FreeRTOS_TCP_Transmission_IPv6_utest.c @@ -574,7 +574,7 @@ void test_prvTCPPrepareConnect_IPV6_CreateTCPWindowFails( void ) memset( pxEndPoint, 0, sizeof( NetworkEndPoint_t ) ); memset( &xNetworkBuffer, 0, sizeof( NetworkBufferDescriptor_t ) ); pxSocket->bits.bIsIPv6 = 1; - eNDGetCacheEntry_ExpectAnyArgsAndReturn( eARPCacheHit ); + eNDGetCacheEntry_ExpectAnyArgsAndReturn( eResolutionCacheHit ); eNDGetCacheEntry_ReturnThruPtr_ppxEndPoint( &pxEndPoint ); uxIPHeaderSizeSocket_ExpectAnyArgsAndReturn( ipSIZE_OF_IPv6_HEADER ); From dd1f80b2f7955f6ff248bcee172c50237c18739b Mon Sep 17 00:00:00 2001 From: Holden Date: Thu, 19 Sep 2024 06:17:22 -0400 Subject: [PATCH 10/25] Fix Unit Tests --- source/FreeRTOS_ARP.c | 5 ++- source/FreeRTOS_IP.c | 2 +- source/FreeRTOS_ND.c | 2 ++ test.sh | 28 ++++++++++++++++ .../unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c | 33 +++++++++++++++++-- .../FreeRTOS_IP_Utils_utest.c | 17 ++++++++++ 6 files changed, 81 insertions(+), 6 deletions(-) create mode 100755 test.sh diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index 6ca491203..4484fe177 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -521,6 +521,8 @@ const IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); const IPV4Parameters_t * pxIPv4Settings = &( pxNetworkBuffer->pxEndPoint->ipv4_settings ); + /* configASSERT( ( pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) || ( pxIPPacket->xEthernetHeader.usFrameType == ipARP_FRAME_TYPE ) ); */ + if( ( pxIPHeader->ulSourceIPAddress & pxIPv4Settings->ulNetMask ) == ( pxIPv4Settings->ulIPAddress & pxIPv4Settings->ulNetMask ) ) { /* If the IP is on the same subnet and we do not have an ARP entry already, @@ -908,7 +910,6 @@ /* Get the lowest 23 bits of the IP-address. */ vSetMultiCastIPv4MacAddress( ulAddressToLookup, pxMACAddress ); - eReturn = eResolutionFailed; pxEndPoint = FreeRTOS_FirstEndPoint( NULL ); for( ; @@ -1329,8 +1330,6 @@ } /*-----------------------------------------------------------*/ - - /** * @brief Generate an ARP request packet by copying various constant details to * the buffer. diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 484edb18a..bea4970d6 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1778,7 +1778,7 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor case eWaitingResolution: #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) - if( pxEthernetHeader->usFrameType == ipIPv4_FRAME_TYPE ) + if( ( pxEthernetHeader->usFrameType == ipIPv4_FRAME_TYPE ) || ( pxEthernetHeader->usFrameType == ipARP_FRAME_TYPE ) ) { if( pxARPWaitingNetworkBuffer == NULL ) { diff --git a/source/FreeRTOS_ND.c b/source/FreeRTOS_ND.c index 934371882..8c3458e2a 100644 --- a/source/FreeRTOS_ND.c +++ b/source/FreeRTOS_ND.c @@ -1356,6 +1356,8 @@ IPv6_Address_t * pxIPAddress = &( pxIPHeader->xSourceAddress ); uint8_t ucNextHeader = pxIPHeader->ucNextHeader; + configASSERT( pxIPPacket->xEthernetHeader.usFrameType == ipIPv6_FRAME_TYPE ); + if( ( ucNextHeader == ipPROTOCOL_TCP ) || ( ucNextHeader == ipPROTOCOL_UDP ) ) { diff --git a/test.sh b/test.sh new file mode 100755 index 000000000..9e79d0b18 --- /dev/null +++ b/test.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# This script should be run from the root directory of the FreeRTOS+TCP repo. + +if [[ ! -d source ]]; then + echo "Please run this script from the root directory of the FreeRTOS+TCP repo." + exit 1 +fi + +clear + +UNIT_TEST_DIR="test/unit-test" +BUILD_DIR="${UNIT_TEST_DIR}/build/" + +# Create the build directory using CMake: +rm -rf ${BUILD_DIR} +cmake -S ${UNIT_TEST_DIR} -B ${BUILD_DIR} -G Ninja + +# Create the executables: +ninja -C ${BUILD_DIR} all + +pushd ${BUILD_DIR} +# Run the tests for all units +ctest -E system --output-on-failure +popd + +# Calculate the coverage +# ninja -C ${BUILD_DIR} coverage +# lcov --list --rc lcov_branch_coverage=1 ${BUILD_DIR}coverage.info diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c index 5f2c192c5..9c85f1aeb 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c @@ -492,6 +492,7 @@ void test_prvIPTask( void ) /* In prvIPTask_Initialise. */ vTCPTimerReload_ExpectAnyArgs(); vIPSetARPResolutionTimerEnableState_Expect( pdFALSE ); + vIPSetNDResolutionTimerEnableState_Expect( pdFALSE ); vDNSInitialise_Ignore(); FreeRTOS_dnsclear_Ignore(); @@ -533,6 +534,7 @@ void test_prvIPTask_NetworkDown( void ) /* In prvIPTask_Initialise. */ vTCPTimerReload_ExpectAnyArgs(); vIPSetARPResolutionTimerEnableState_Expect( pdFALSE ); + vIPSetNDResolutionTimerEnableState_Expect( pdFALSE ); vDNSInitialise_Ignore(); FreeRTOS_dnsclear_Ignore(); @@ -731,7 +733,7 @@ void test_prvProcessIPEventsAndTimers_eNetworkRxEvent_NullEndPoint( void ) /** * @brief test_prvProcessIPEventsAndTimers_eARPTimerEvent - * Check if prvProcessIPEventsAndTimers() updates the cache for ARP/ND when timeout event triggered. + * Check if prvProcessIPEventsAndTimers() updates the cache for ARP when timeout event triggered. */ void test_prvProcessIPEventsAndTimers_eARPTimerEvent( void ) { @@ -746,6 +748,26 @@ void test_prvProcessIPEventsAndTimers_eARPTimerEvent( void ) xQueueReceive_ExpectAnyArgsAndReturn( pdTRUE ); xQueueReceive_ReturnMemThruPtr_pvBuffer( &xReceivedEvent, sizeof( xReceivedEvent ) ); vARPAgeCache_Expect(); + + prvProcessIPEventsAndTimers(); +} + +/** + * @brief test_prvProcessIPEventsAndTimers_eNDTimerEvent + * Check if prvProcessIPEventsAndTimers() updates the cache for ND when timeout event triggered. + */ +void test_prvProcessIPEventsAndTimers_eNDTimerEvent( void ) +{ + IPStackEvent_t xReceivedEvent; + + xReceivedEvent.eEventType = eNDTimerEvent; + xReceivedEvent.pvData = NULL; + + /* prvProcessIPEventsAndTimers */ + vCheckNetworkTimers_Expect(); + xCalculateSleepTime_ExpectAndReturn( 0 ); + xQueueReceive_ExpectAnyArgsAndReturn( pdTRUE ); + xQueueReceive_ReturnMemThruPtr_pvBuffer( &xReceivedEvent, sizeof( xReceivedEvent ) ); vNDAgeCache_Expect(); prvProcessIPEventsAndTimers(); @@ -4232,7 +4254,14 @@ static void prvIPNetworkUpCalls_Generic( const uint8_t * pucAddress, vApplicationIPNetworkEventHook_Multi_Expect( eNetworkUp, &xEndPoint ); vDNSInitialise_Expect(); - vARPTimerReload_Expect( pdMS_TO_TICKS( 10000 ) ); + if( xEndPoint.bits.bIPv6 == pdTRUE_UNSIGNED ) + { + vNDTimerReload_Expect( pdMS_TO_TICKS( 10000 ) ); + } + else + { + vARPTimerReload_Expect( pdMS_TO_TICKS( 10000 ) ); + } vIPNetworkUpCalls( &xEndPoint ); diff --git a/test/unit-test/FreeRTOS_IP_Utils/FreeRTOS_IP_Utils_utest.c b/test/unit-test/FreeRTOS_IP_Utils/FreeRTOS_IP_Utils_utest.c index aac452fca..cac95bf17 100644 --- a/test/unit-test/FreeRTOS_IP_Utils/FreeRTOS_IP_Utils_utest.c +++ b/test/unit-test/FreeRTOS_IP_Utils/FreeRTOS_IP_Utils_utest.c @@ -47,6 +47,7 @@ #include "mock_FreeRTOS_IP_Private.h" #include "mock_FreeRTOS_IP_Timers.h" #include "mock_FreeRTOS_ARP.h" +#include "mock_FreeRTOS_ND.h" #include "mock_FreeRTOS_DHCP.h" #include "mock_FreeRTOS_DHCPv6.h" #include "mock_FreeRTOS_Routing.h" @@ -489,11 +490,13 @@ void test_prvProcessNetworkDownEvent_Pass( void ) xEndPoint.bits.bCallDownHook = pdFALSE_UNSIGNED; vIPSetARPTimerEnableState_Expect( pdFALSE ); + vIPSetNDTimerEnableState_Expect( pdFALSE ); FreeRTOS_FirstEndPoint_IgnoreAndReturn( &xEndPoint ); FreeRTOS_NextEndPoint_IgnoreAndReturn( NULL ); FreeRTOS_ClearARP_ExpectAnyArgs(); + FreeRTOS_ClearND_ExpectAnyArgs(); vDHCPStop_Expect( &xEndPoint ); @@ -504,6 +507,7 @@ void test_prvProcessNetworkDownEvent_Pass( void ) /* Run again to trigger a different path in the code. */ vIPSetARPTimerEnableState_Expect( pdFALSE ); + vIPSetNDTimerEnableState_Expect( pdFALSE ); FreeRTOS_FirstEndPoint_IgnoreAndReturn( &xEndPoint ); FreeRTOS_NextEndPoint_IgnoreAndReturn( NULL ); @@ -511,6 +515,7 @@ void test_prvProcessNetworkDownEvent_Pass( void ) vApplicationIPNetworkEventHook_Multi_Expect( eNetworkDown, &xEndPoint ); FreeRTOS_ClearARP_Expect( &xEndPoint ); + FreeRTOS_ClearND_Expect( &xEndPoint ); vDHCPStop_Expect( &xEndPoint ); @@ -535,11 +540,13 @@ void test_prvProcessNetworkDownEvent_Fail( void ) xEndPoint.bits.bWantDHCP = pdFALSE_UNSIGNED; vIPSetARPTimerEnableState_Expect( pdFALSE ); + vIPSetNDTimerEnableState_Expect( pdFALSE ); FreeRTOS_FirstEndPoint_IgnoreAndReturn( &xEndPoint ); FreeRTOS_NextEndPoint_IgnoreAndReturn( NULL ); FreeRTOS_ClearARP_Expect( &xEndPoint ); + FreeRTOS_ClearND_Expect( &xEndPoint ); vIPNetworkUpCalls_Expect( &xEndPoint ); @@ -586,11 +593,13 @@ void test_prvProcessNetworkDownEvent_InterfaceInitFail( void ) xEndPoint.bits.bCallDownHook = pdFALSE_UNSIGNED; vIPSetARPTimerEnableState_Expect( pdFALSE ); + vIPSetNDTimerEnableState_Expect( pdFALSE ); FreeRTOS_FirstEndPoint_IgnoreAndReturn( &xEndPoint ); FreeRTOS_NextEndPoint_IgnoreAndReturn( NULL ); FreeRTOS_ClearARP_ExpectAnyArgs(); + FreeRTOS_ClearND_ExpectAnyArgs(); vDHCPStop_Expect( &xEndPoint ); @@ -616,6 +625,7 @@ void test_prvProcessNetworkDownEvent_PassDHCPv6( void ) xEndPoint.bits.bCallDownHook = pdFALSE_UNSIGNED; vIPSetARPTimerEnableState_Expect( pdFALSE ); + vIPSetNDTimerEnableState_Expect( pdFALSE ); FreeRTOS_FirstEndPoint_IgnoreAndReturn( &xEndPoint ); @@ -628,6 +638,7 @@ void test_prvProcessNetworkDownEvent_PassDHCPv6( void ) FreeRTOS_NextEndPoint_IgnoreAndReturn( NULL ); FreeRTOS_ClearARP_ExpectAnyArgs(); + FreeRTOS_ClearND_ExpectAnyArgs(); vDHCPv6Stop_Expect( &xEndPoint ); @@ -653,6 +664,7 @@ void test_prvProcessNetworkDownEvent_PassRA( void ) xEndPoint.bits.bCallDownHook = pdFALSE_UNSIGNED; vIPSetARPTimerEnableState_Expect( pdFALSE ); + vIPSetNDTimerEnableState_Expect( pdFALSE ); FreeRTOS_FirstEndPoint_IgnoreAndReturn( &xEndPoint ); @@ -665,6 +677,7 @@ void test_prvProcessNetworkDownEvent_PassRA( void ) FreeRTOS_NextEndPoint_IgnoreAndReturn( NULL ); FreeRTOS_ClearARP_ExpectAnyArgs(); + FreeRTOS_ClearND_ExpectAnyArgs(); vIPSetDHCP_RATimerEnableState_Expect( &xEndPoint, pdFALSE ); @@ -692,6 +705,7 @@ void test_prvProcessNetworkDownEvent_PassStaticIP( void ) memcpy( xEndPoint.ipv6_defaults.xIPAddress.ucBytes, xIPv6Address.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); vIPSetARPTimerEnableState_Expect( pdFALSE ); + vIPSetNDTimerEnableState_Expect( pdFALSE ); FreeRTOS_FirstEndPoint_IgnoreAndReturn( &xEndPoint ); @@ -704,6 +718,7 @@ void test_prvProcessNetworkDownEvent_PassStaticIP( void ) FreeRTOS_NextEndPoint_IgnoreAndReturn( NULL ); FreeRTOS_ClearARP_ExpectAnyArgs(); + FreeRTOS_ClearND_ExpectAnyArgs(); vIPNetworkUpCalls_Expect( &xEndPoint ); @@ -3128,6 +3143,7 @@ static void prvProcessNetworkDownEvent_Generic( const uint8_t * pucAddress, } vIPSetARPTimerEnableState_Expect( pdFALSE ); + vIPSetNDTimerEnableState_Expect( pdFALSE ); FreeRTOS_FirstEndPoint_IgnoreAndReturn( &xEndPoint ); @@ -3141,6 +3157,7 @@ static void prvProcessNetworkDownEvent_Generic( const uint8_t * pucAddress, FreeRTOS_ClearARP_Expect( &xEndPoint ); + FreeRTOS_ClearND_Expect( &xEndPoint ); vIPNetworkUpCalls_Expect( &xEndPoint ); From 5fc03b72f6be5cbcffc703763750aff0b8f91574 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 25 Sep 2024 18:24:01 +0000 Subject: [PATCH 11/25] Uncrustify: triggered by comment. --- test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c index 9c85f1aeb..8c7cd2b94 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c @@ -4254,6 +4254,7 @@ static void prvIPNetworkUpCalls_Generic( const uint8_t * pucAddress, vApplicationIPNetworkEventHook_Multi_Expect( eNetworkUp, &xEndPoint ); vDNSInitialise_Expect(); + if( xEndPoint.bits.bIPv6 == pdTRUE_UNSIGNED ) { vNDTimerReload_Expect( pdMS_TO_TICKS( 10000 ) ); From 8af0a42bea1015289b62b49a2707890e61ea67b2 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Wed, 16 Oct 2024 09:33:33 +0000 Subject: [PATCH 12/25] Fix CBMC testing --- .../ProcessICMPMessage_IPv6_harness.c | 8 ++++---- .../ND/prvReturnICMP_IPv6/ReturnICMP_IPv6_harness.c | 6 +++--- .../parsing/ProcessIPPacket/ProcessIPPacket_harness.c | 4 +++- .../ProcessReceivedUDPPacket_IPv6_harness.c | 6 ++++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/test/cbmc/proofs/ND/prvProcessICMPMessage_IPv6/ProcessICMPMessage_IPv6_harness.c b/test/cbmc/proofs/ND/prvProcessICMPMessage_IPv6/ProcessICMPMessage_IPv6_harness.c index 0b02ac8ed..8fdbc87a7 100644 --- a/test/cbmc/proofs/ND/prvProcessICMPMessage_IPv6/ProcessICMPMessage_IPv6_harness.c +++ b/test/cbmc/proofs/ND/prvProcessICMPMessage_IPv6/ProcessICMPMessage_IPv6_harness.c @@ -156,7 +156,7 @@ void harness() * which is validated only when bIPv6 is set*/ __CPROVER_assume( ( pxNetworkBuffer->pxEndPoint != NULL ) && ( pxNetworkBuffer->pxEndPoint->bits.bIPv6 == pdTRUE_UNSIGNED ) ); - /* Non deterministically determine whether the pxARPWaitingNetworkBuffer will + /* Non deterministically determine whether the pxNDWaitingNetworkBuffer will * point to some valid data or will it be NULL. */ if( nondet_bool() ) { @@ -167,7 +167,7 @@ void harness() pxLocalARPWaitingNetworkBuffer = pxGetNetworkBufferWithDescriptor( usEthernetBufferSize, 0 ); /* Since this pointer is maintained by the IP-task, either the pointer - * pxARPWaitingNetworkBuffer will be NULL or pxLocalARPWaitingNetworkBuffer.pucEthernetBuffer + * pxNDWaitingNetworkBuffer will be NULL or pxLocalARPWaitingNetworkBuffer.pucEthernetBuffer * will be non-NULL. */ __CPROVER_assume( pxLocalARPWaitingNetworkBuffer != NULL ); __CPROVER_assume( pxLocalARPWaitingNetworkBuffer->pucEthernetBuffer != NULL ); @@ -176,11 +176,11 @@ void harness() /* Add matching data length to the network buffer descriptor. */ pxLocalARPWaitingNetworkBuffer->xDataLength = usEthernetBufferSize; - pxARPWaitingNetworkBuffer = pxLocalARPWaitingNetworkBuffer; + pxNDWaitingNetworkBuffer = pxLocalARPWaitingNetworkBuffer; } else { - pxARPWaitingNetworkBuffer = NULL; + pxNDWaitingNetworkBuffer = NULL; } prvProcessICMPMessage_IPv6( pxNetworkBuffer ); diff --git a/test/cbmc/proofs/ND/prvReturnICMP_IPv6/ReturnICMP_IPv6_harness.c b/test/cbmc/proofs/ND/prvReturnICMP_IPv6/ReturnICMP_IPv6_harness.c index e0340a76c..597734285 100644 --- a/test/cbmc/proofs/ND/prvReturnICMP_IPv6/ReturnICMP_IPv6_harness.c +++ b/test/cbmc/proofs/ND/prvReturnICMP_IPv6/ReturnICMP_IPv6_harness.c @@ -161,7 +161,7 @@ void harness() __CPROVER_assume( ( pxNetworkBuffer->pxEndPoint != NULL ) && ( pxNetworkBuffer->pxEndPoint->bits.bIPv6 == pdTRUE_UNSIGNED ) ); - /* Initializing pxARPWaitingNetworkBuffer */ + /* Initializing pxNDWaitingNetworkBuffer */ /* The packet must at least be as big as an IPv6 Packet. The size is not * checked in the function as the pointer is stored by the IP-task itself @@ -170,7 +170,7 @@ void harness() pxLocalARPWaitingNetworkBuffer = pxGetNetworkBufferWithDescriptor( usEthernetBufferSize, 0 ); /* Since this pointer is maintained by the IP-task, either the pointer - * pxARPWaitingNetworkBuffer will be NULL or pxLocalARPWaitingNetworkBuffer.pucEthernetBuffer + * pxNDWaitingNetworkBuffer will be NULL or pxLocalARPWaitingNetworkBuffer.pucEthernetBuffer * will be non-NULL. */ __CPROVER_assume( pxLocalARPWaitingNetworkBuffer != NULL ); __CPROVER_assume( pxLocalARPWaitingNetworkBuffer->pucEthernetBuffer != NULL ); @@ -179,7 +179,7 @@ void harness() /* Add matching data length to the network buffer descriptor. */ pxLocalARPWaitingNetworkBuffer->xDataLength = usEthernetBufferSize; - pxARPWaitingNetworkBuffer = pxLocalARPWaitingNetworkBuffer; + pxNDWaitingNetworkBuffer = pxLocalARPWaitingNetworkBuffer; prvProcessICMPMessage_IPv6( pxNetworkBuffer ); } diff --git a/test/cbmc/proofs/parsing/ProcessIPPacket/ProcessIPPacket_harness.c b/test/cbmc/proofs/parsing/ProcessIPPacket/ProcessIPPacket_harness.c index 5b926e4c4..add375d18 100644 --- a/test/cbmc/proofs/parsing/ProcessIPPacket/ProcessIPPacket_harness.c +++ b/test/cbmc/proofs/parsing/ProcessIPPacket/ProcessIPPacket_harness.c @@ -42,12 +42,14 @@ BaseType_t xGetExtensionOrder( uint8_t ucProtocol, return xIsExtensionHeader( ucProtocol ); } -BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer ) +BaseType_t xCheckRequiresResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer ) { BaseType_t xReturn; __CPROVER_assert( pxNetworkBuffer != NULL, "pxNetworkBuffer cannot be NULL" ); __CPROVER_assert( __CPROVER_r_ok( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength ), "Data in pxNetworkBuffer must be readable" ); + + return xReturn; } void vARPRefreshCacheEntryAge( const MACAddress_t * pxMACAddress, diff --git a/test/cbmc/proofs/parsing/ProcessReceivedUDPPacket_IPv6/ProcessReceivedUDPPacket_IPv6_harness.c b/test/cbmc/proofs/parsing/ProcessReceivedUDPPacket_IPv6/ProcessReceivedUDPPacket_IPv6_harness.c index 5737bb359..aef236b61 100644 --- a/test/cbmc/proofs/parsing/ProcessReceivedUDPPacket_IPv6/ProcessReceivedUDPPacket_IPv6_harness.c +++ b/test/cbmc/proofs/parsing/ProcessReceivedUDPPacket_IPv6/ProcessReceivedUDPPacket_IPv6_harness.c @@ -43,11 +43,12 @@ FreeRTOS_Socket_t * pxUDPSocketLookup( UBaseType_t uxLocalPort ) } /* This proof was done before. Hence we assume it to be correct here. */ -BaseType_t xCheckRequiresARPResolution( NetworkBufferDescriptor_t * pxNetworkBuffer ) +BaseType_t xCheckRequiresNDResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer ) { BaseType_t xReturn; - __CPROVER_assume( ( xReturn == pdTRUE ) || ( xReturn == pdFALSE ) ); + __CPROVER_assert( pxNetworkBuffer != NULL, "pxNetworkBuffer cannot be NULL" ); + __CPROVER_assert( __CPROVER_r_ok( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength ), "Data in pxNetworkBuffer must be readable" ); return xReturn; } @@ -95,6 +96,7 @@ void harness() pxNetworkBuffer->pucEthernetBuffer = safeMalloc( sizeof( UDPPacket_IPv6_t ) ); pxNetworkBuffer->pxEndPoint = &xEndpoint; + pxNetworkBuffer->xDataLength = sizeof( UDPPacket_IPv6_t ); /* The ethernet buffer must be valid. */ __CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer != NULL ); From 5e842c65520d30d7de184cd924a655d83cb32f2e Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 17 Oct 2024 01:50:43 +0000 Subject: [PATCH 13/25] Fix ARP utest --- test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c index 99411e06f..bdf85aba6 100644 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c @@ -1076,6 +1076,7 @@ void test_eARPProcessPacket_Reply_SenderAndTargetSame( void ) vResetARPClashCounter(); xEndPoint.bits.bEndPointUp = pdTRUE_UNSIGNED; + xEndPoint.bits.bIPv6 = pdFALSE_UNSIGNED; xNetworkBuffer.pucEthernetBuffer = ( uint8_t * ) pxARPFrame; xNetworkBuffer.xDataLength = sizeof( ARPPacket_t ); xNetworkBuffer.pxEndPoint = &xEndPoint; @@ -1103,7 +1104,10 @@ void test_eARPProcessPacket_Reply_SenderAndTargetSame( void ) xARPHadIPClash = pdFALSE; /* Let there be no timeout. Let the EndPoint be NULL */ - xTaskCheckForTimeOut_ExpectAnyArgsAndReturn( pdFAIL ); + pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer ); + vReleaseNetworkBufferAndDescriptor_Expect( &xNetworkBuffer ); + xTaskGetTickCount_ExpectAndReturn( 0 ); + vTaskSetTimeOutState_ExpectAnyArgs(); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); eResult = eARPProcessPacket( &xNetworkBuffer ); @@ -1114,7 +1118,10 @@ void test_eARPProcessPacket_Reply_SenderAndTargetSame( void ) /* Reset the flag. */ xARPHadIPClash = pdFALSE; /* Let there be no timeout. */ - xTaskCheckForTimeOut_ExpectAnyArgsAndReturn( pdFAIL ); + pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer ); + vReleaseNetworkBufferAndDescriptor_Expect( &xNetworkBuffer ); + xTaskGetTickCount_ExpectAndReturn( 0 ); + vTaskSetTimeOutState_ExpectAnyArgs(); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint ); /* Call it again and do not expect the task functions to be called. */ @@ -1128,7 +1135,10 @@ void test_eARPProcessPacket_Reply_SenderAndTargetSame( void ) xEndPoint_2.ipv4_settings.ulIPAddress = ( uint32_t ) *( pxARPFrame->xARPHeader.ucSenderProtocolAddress + 0x11 ); /* Let there be no timeout. Let the EndPoint be NULL */ - xTaskCheckForTimeOut_ExpectAnyArgsAndReturn( pdFAIL ); + pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer ); + vReleaseNetworkBufferAndDescriptor_Expect( &xNetworkBuffer ); + xTaskGetTickCount_ExpectAndReturn( 0 ); + vTaskSetTimeOutState_ExpectAnyArgs(); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint_2 ); eResult = eARPProcessPacket( &xNetworkBuffer ); From 698f2c3b5d8e348e9aab991a1fdcf085ceb32ea1 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 17 Oct 2024 01:58:52 +0000 Subject: [PATCH 14/25] Code review suggestion --- source/FreeRTOS_IP.c | 44 ++++++++++++++++++++++---------------------- test.sh | 28 ---------------------------- 2 files changed, 22 insertions(+), 50 deletions(-) delete mode 100755 test.sh diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 13bee0d7c..fded6315d 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1777,9 +1777,9 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor case eWaitingResolution: - #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) - if( ( pxEthernetHeader->usFrameType == ipIPv4_FRAME_TYPE ) || ( pxEthernetHeader->usFrameType == ipARP_FRAME_TYPE ) ) - { + if( ( pxEthernetHeader->usFrameType == ipIPv4_FRAME_TYPE ) || ( pxEthernetHeader->usFrameType == ipARP_FRAME_TYPE ) ) + { + #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) if( pxARPWaitingNetworkBuffer == NULL ) { pxARPWaitingNetworkBuffer = pxNetworkBuffer; @@ -1788,20 +1788,20 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor iptraceDELAYED_ARP_REQUEST_STARTED(); } else - { - /* We are already waiting on one resolution. This frame will be dropped. */ - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - - iptraceDELAYED_ARP_BUFFER_FULL(); - } + #endif /* if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) */ + { + /* We are already waiting on one resolution. This frame will be dropped. */ + vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - break; + iptraceDELAYED_ARP_BUFFER_FULL(); } - #endif /* if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) */ - #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) - if( pxEthernetHeader->usFrameType == ipIPv6_FRAME_TYPE ) - { + break; + } + + if( pxEthernetHeader->usFrameType == ipIPv6_FRAME_TYPE ) + { + #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) if( pxNDWaitingNetworkBuffer == NULL ) { pxNDWaitingNetworkBuffer = pxNetworkBuffer; @@ -1810,16 +1810,16 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor iptraceDELAYED_ND_REQUEST_STARTED(); } else - { - /* We are already waiting on one resolution. This frame will be dropped. */ - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - - iptraceDELAYED_ND_BUFFER_FULL(); - } + #endif /* if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) */ + { + /* We are already waiting on one resolution. This frame will be dropped. */ + vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - break; + iptraceDELAYED_ND_BUFFER_FULL(); } - #endif /* if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) */ + + break; + } break; diff --git a/test.sh b/test.sh deleted file mode 100755 index 9e79d0b18..000000000 --- a/test.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# This script should be run from the root directory of the FreeRTOS+TCP repo. - -if [[ ! -d source ]]; then - echo "Please run this script from the root directory of the FreeRTOS+TCP repo." - exit 1 -fi - -clear - -UNIT_TEST_DIR="test/unit-test" -BUILD_DIR="${UNIT_TEST_DIR}/build/" - -# Create the build directory using CMake: -rm -rf ${BUILD_DIR} -cmake -S ${UNIT_TEST_DIR} -B ${BUILD_DIR} -G Ninja - -# Create the executables: -ninja -C ${BUILD_DIR} all - -pushd ${BUILD_DIR} -# Run the tests for all units -ctest -E system --output-on-failure -popd - -# Calculate the coverage -# ninja -C ${BUILD_DIR} coverage -# lcov --list --rc lcov_branch_coverage=1 ${BUILD_DIR}coverage.info From 3fee8616ad1ea995f067655f74e96a773047e7f1 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 17 Oct 2024 03:07:22 +0000 Subject: [PATCH 15/25] In unit-test, define ipconfigIS_ENABLED to nothing to pass compilation. --- test/unit-test/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/unit-test/CMakeLists.txt b/test/unit-test/CMakeLists.txt index cac757688..e3e9bcfaf 100644 --- a/test/unit-test/CMakeLists.txt +++ b/test/unit-test/CMakeLists.txt @@ -146,6 +146,7 @@ foreach( file ${TCP_INCLUDES} ) -UFreeRTOS_htonl -D__COVERITY__ -DTEST + -DipconfigIS_ENABLED -DipconfigUSE_IPv6 -DipconfigUSE_RA -I ${MODULE_ROOT_DIR}/tools/CMock/vendor/unity/src @@ -165,6 +166,7 @@ foreach( file ${TCP_INCLUDES} ) -UFreeRTOS_htonl -D__COVERITY__ -DTEST + -DipconfigIS_ENABLED -I ${MODULE_ROOT_DIR}/tools/CMock/vendor/unity/src -I ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include -I ${UNIT_TEST_DIR}/ConfigFiles From 341d974539961683e4d41b64206e262c6d0bb499 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 17 Oct 2024 10:01:44 +0000 Subject: [PATCH 16/25] Fix UT coverage. --- source/FreeRTOS_IP.c | 8 +- source/FreeRTOS_ND.c | 2 - .../FreeRTOS_ARP/FreeRTOS_ARP_utest.c | 15 +- test/unit-test/FreeRTOS_ARP/ut.cmake | 2 +- .../ut.cmake | 2 +- .../unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c | 116 ++++++++ .../FreeRTOSIPConfig.h | 4 +- .../FreeRTOS_IP_DiffConfig3_utest.c | 67 +++++ .../FreeRTOS_IP_Timers_utest.c | 249 +++++++++++++++++- .../unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c | 73 +++-- 10 files changed, 499 insertions(+), 39 deletions(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index fded6315d..fded8c851 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1798,8 +1798,7 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor break; } - - if( pxEthernetHeader->usFrameType == ipIPv6_FRAME_TYPE ) + else if( pxEthernetHeader->usFrameType == ipIPv6_FRAME_TYPE ) { #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) if( pxNDWaitingNetworkBuffer == NULL ) @@ -1820,6 +1819,11 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor break; } + else + { + /* Unknown frame type, drop the packet. */ + vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); + } break; diff --git a/source/FreeRTOS_ND.c b/source/FreeRTOS_ND.c index 8c3458e2a..c09310322 100644 --- a/source/FreeRTOS_ND.c +++ b/source/FreeRTOS_ND.c @@ -423,8 +423,6 @@ */ void FreeRTOS_ClearND( const struct xNetworkEndPoint * pxEndPoint ) { - ( void ) memset( xNDCache, 0, sizeof( xNDCache ) ); - if( pxEndPoint != NULL ) { BaseType_t x; diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c index bdf85aba6..c460c0c77 100644 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c @@ -1104,10 +1104,7 @@ void test_eARPProcessPacket_Reply_SenderAndTargetSame( void ) xARPHadIPClash = pdFALSE; /* Let there be no timeout. Let the EndPoint be NULL */ - pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer ); - vReleaseNetworkBufferAndDescriptor_Expect( &xNetworkBuffer ); - xTaskGetTickCount_ExpectAndReturn( 0 ); - vTaskSetTimeOutState_ExpectAnyArgs(); + xTaskCheckForTimeOut_ExpectAnyArgsAndReturn( pdFAIL ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); eResult = eARPProcessPacket( &xNetworkBuffer ); @@ -1118,10 +1115,7 @@ void test_eARPProcessPacket_Reply_SenderAndTargetSame( void ) /* Reset the flag. */ xARPHadIPClash = pdFALSE; /* Let there be no timeout. */ - pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer ); - vReleaseNetworkBufferAndDescriptor_Expect( &xNetworkBuffer ); - xTaskGetTickCount_ExpectAndReturn( 0 ); - vTaskSetTimeOutState_ExpectAnyArgs(); + xTaskCheckForTimeOut_ExpectAnyArgsAndReturn( pdFAIL ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint ); /* Call it again and do not expect the task functions to be called. */ @@ -1135,10 +1129,7 @@ void test_eARPProcessPacket_Reply_SenderAndTargetSame( void ) xEndPoint_2.ipv4_settings.ulIPAddress = ( uint32_t ) *( pxARPFrame->xARPHeader.ucSenderProtocolAddress + 0x11 ); /* Let there be no timeout. Let the EndPoint be NULL */ - pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer ); - vReleaseNetworkBufferAndDescriptor_Expect( &xNetworkBuffer ); - xTaskGetTickCount_ExpectAndReturn( 0 ); - vTaskSetTimeOutState_ExpectAnyArgs(); + xTaskCheckForTimeOut_ExpectAnyArgsAndReturn( pdFAIL ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint_2 ); eResult = eARPProcessPacket( &xNetworkBuffer ); diff --git a/test/unit-test/FreeRTOS_ARP/ut.cmake b/test/unit-test/FreeRTOS_ARP/ut.cmake index 5df8b8a09..a8757579e 100644 --- a/test/unit-test/FreeRTOS_ARP/ut.cmake +++ b/test/unit-test/FreeRTOS_ARP/ut.cmake @@ -39,7 +39,7 @@ list(APPEND mock_define_list # list the files you would like to test here list(APPEND real_source_files - ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources/${project_name}.c + ${MODULE_ROOT_DIR}/source/FreeRTOS_ARP.c ) # list the directories the module under test includes list(APPEND real_include_directories diff --git a/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake b/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake index 949036f43..2c25b6b68 100644 --- a/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake +++ b/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/ut.cmake @@ -41,7 +41,7 @@ list(APPEND mock_define_list # list the files you would like to test here set(real_source_files "") list(APPEND real_source_files - ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources/FreeRTOS_ARP.c + ${MODULE_ROOT_DIR}/source/FreeRTOS_ARP.c ) # list the directories the module under test includes set(real_include_directories "") diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c index 8c7cd2b94..34c8839ac 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c @@ -2387,6 +2387,122 @@ void test_prvProcessEthernetPacket_InterfaceNull( void ) prvProcessEthernetPacket( pxNetworkBuffer ); } +/** + * @brief test_prvProcessEthernetPacket_IPv4FrameType_NeedARPResolution + * To validate the flow to handle IPv4 packets and it needs ARP resolution. + * But we already have one ARP packet pending so that buffer got released + * at the end. + */ +void test_prvProcessEthernetPacket_IPv4FrameType_NeedARPResolution( void ) +{ + NetworkBufferDescriptor_t xNetworkBuffer; + NetworkBufferDescriptor_t * pxNetworkBuffer = &xNetworkBuffer; + uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ] = { 0 }; + EthernetHeader_t * pxEthernetHeader; + IPPacket_t * pxIPPacket; + IPHeader_t * pxIPHeader; + struct xNetworkInterface xInterface; + NetworkEndPoint_t xNetworkEndPoint = { 0 }; + + pxNetworkBuffer->xDataLength = ipconfigTCP_MSS; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + pxNetworkBuffer->pxInterface = &xInterface; + pxNetworkBuffer->pxEndPoint = &xNetworkEndPoint; + + pxEthernetHeader = ( EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer; + pxEthernetHeader->usFrameType = ipIPv4_FRAME_TYPE; + + pxIPPacket = ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; + pxIPHeader = &( pxIPPacket->xIPHeader ); + pxIPHeader->ucVersionHeaderLength = 0x45; + + pxARPWaitingNetworkBuffer = ( NetworkBufferDescriptor_t * ) 0x1234ABCD; + + prvAllowIPPacketIPv4_ExpectAndReturn( pxIPPacket, pxNetworkBuffer, ( pxIPHeader->ucVersionHeaderLength & 0x0FU ) << 2, eProcessBuffer ); + xCheckRequiresResolution_ExpectAndReturn( pxNetworkBuffer, pdTRUE ); + vReleaseNetworkBufferAndDescriptor_Expect( pxNetworkBuffer ); + + prvProcessEthernetPacket( pxNetworkBuffer ); +} + +/** + * @brief test_prvProcessEthernetPacket_IPv6FrameType_NeedNDResolution + * To validate the flow to handle IPv4 packets and it needs ND resolution. + * But we already have one ND packet pending so that buffer got released + * at the end. + */ +void test_prvProcessEthernetPacket_IPv6FrameType_NeedNDResolution( void ) +{ + NetworkBufferDescriptor_t xNetworkBuffer; + NetworkBufferDescriptor_t * pxNetworkBuffer = &xNetworkBuffer; + uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ] = { 0 }; + EthernetHeader_t * pxEthernetHeader; + IPPacket_IPv6_t * pxIPv6Packet; + IPHeader_IPv6_t * pxIPv6Header; + struct xNetworkInterface xInterface; + NetworkEndPoint_t xNetworkEndPoint = { 0 }; + + pxNetworkBuffer->xDataLength = ipconfigTCP_MSS; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + pxNetworkBuffer->pxInterface = &xInterface; + pxNetworkBuffer->pxEndPoint = &xNetworkEndPoint; + + pxEthernetHeader = ( EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer; + pxEthernetHeader->usFrameType = ipIPv6_FRAME_TYPE; + + pxIPv6Packet = ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; + pxIPv6Header = &( pxIPv6Packet->xIPHeader ); + pxIPv6Header->ucNextHeader = ipPROTOCOL_TCP; + + pxNDWaitingNetworkBuffer = ( NetworkBufferDescriptor_t * ) 0x1234ABCD; + + prvAllowIPPacketIPv6_ExpectAndReturn( pxIPv6Header, pxNetworkBuffer, ipSIZE_OF_IPv6_HEADER, eProcessBuffer ); + xGetExtensionOrder_ExpectAndReturn( ipPROTOCOL_TCP, 0, -1 ); + xCheckRequiresResolution_ExpectAndReturn( pxNetworkBuffer, pdTRUE ); + vReleaseNetworkBufferAndDescriptor_Expect( pxNetworkBuffer ); + + prvProcessEthernetPacket( pxNetworkBuffer ); +} + +/** + * @brief test_prvProcessEthernetPacket_IPv6FrameType_NeedNDResolution2 + * To validate the flow to handle IPv6 packets and it needs ND resolution. + * And we don't have any pending ND packet. + */ +void test_prvProcessEthernetPacket_IPv6FrameType_NeedNDResolution2( void ) +{ + NetworkBufferDescriptor_t xNetworkBuffer; + NetworkBufferDescriptor_t * pxNetworkBuffer = &xNetworkBuffer; + uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ] = { 0 }; + EthernetHeader_t * pxEthernetHeader; + IPPacket_IPv6_t * pxIPv6Packet; + IPHeader_IPv6_t * pxIPv6Header; + struct xNetworkInterface xInterface; + NetworkEndPoint_t xNetworkEndPoint = { 0 }; + + pxNetworkBuffer->xDataLength = ipconfigTCP_MSS; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + pxNetworkBuffer->pxInterface = &xInterface; + pxNetworkBuffer->pxEndPoint = &xNetworkEndPoint; + + pxEthernetHeader = ( EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer; + pxEthernetHeader->usFrameType = ipIPv6_FRAME_TYPE; + + pxIPv6Packet = ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer; + pxIPv6Header = &( pxIPv6Packet->xIPHeader ); + pxIPv6Header->ucNextHeader = ipPROTOCOL_TCP; + + pxNDWaitingNetworkBuffer = NULL; + + prvAllowIPPacketIPv6_ExpectAndReturn( pxIPv6Header, pxNetworkBuffer, ipSIZE_OF_IPv6_HEADER, eProcessBuffer ); + xGetExtensionOrder_ExpectAndReturn( ipPROTOCOL_TCP, 0, -1 ); + xCheckRequiresResolution_ExpectAndReturn( pxNetworkBuffer, pdTRUE ); + vIPTimerStartNDResolution_ExpectAnyArgs(); + + prvProcessEthernetPacket( pxNetworkBuffer ); + + TEST_ASSERT_EQUAL_PTR( pxNetworkBuffer, pxNDWaitingNetworkBuffer ); +} /** * @brief test_prvProcessIPPacket_HeaderLengthSmaller diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOSIPConfig.h b/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOSIPConfig.h index a95e7d992..9454ff172 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOSIPConfig.h +++ b/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOSIPConfig.h @@ -263,7 +263,7 @@ * because the packet will already have been passed into the stack). If the * Ethernet driver does all the necessary filtering in hardware then software * filtering can be removed by using a value other than 1 or 0. */ -#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1 +#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 0 /* When ipconfigETHERNET_DRIVER_FILTERS_PACKETS is enabled, the network * interface will inspect the incoming packets to see if they can be @@ -348,4 +348,6 @@ #define ipconfigIP_PASS_PACKETS_WITH_IP_OPTIONS ( 0 ) #define ipconfigZERO_COPY_TX_DRIVER ( 1 ) +#define ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES ( 1 ) + #endif /* FREERTOS_IP_CONFIG_H */ diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_utest.c b/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_utest.c index 8fac597cf..492831170 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_utest.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_utest.c @@ -46,6 +46,8 @@ #include "mock_FreeRTOS_IP_Timers.h" #include "mock_FreeRTOS_DHCP.h" #include "mock_FreeRTOS_DHCPv6.h" +#include "mock_NetworkBufferManagement.h" +#include "mock_FreeRTOS_Routing.h" #include "FreeRTOS_IP.h" @@ -84,6 +86,14 @@ void tearDown( void ) /* ======================== Stub Callback Functions ========================= */ +eFrameProcessingResult_t eApplicationProcessCustomFrameHook( NetworkBufferDescriptor_t * const pxNetworkBuffer ) +{ + ( void ) ( pxNetworkBuffer ); + + /* Force hook function to return waiting resultion for unknown Ethernet frame type. */ + return eWaitingResolution; +} + /* ============================== Test Cases ============================== */ /** @@ -179,3 +189,60 @@ void test_prvProcessIPEventsAndTimers_eDHCPEvent_RA( void ) prvProcessIPEventsAndTimers(); } + +/** + * @brief test_prvProcessEthernetPacket_UnknownFrameType_NeedResolution + * But we release the network buffer because the frame type is unknown. + */ +void test_prvProcessEthernetPacket_UnknownFrameType_NeedResolution( void ) +{ + NetworkBufferDescriptor_t xNetworkBuffer; + NetworkBufferDescriptor_t * pxNetworkBuffer = &xNetworkBuffer; + uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ] = { 0 }; + EthernetHeader_t * pxEthernetHeader; + IPPacket_IPv6_t * pxIPv6Packet; + IPHeader_IPv6_t * pxIPv6Header; + struct xNetworkInterface xInterface; + NetworkEndPoint_t xNetworkEndPoint = { 0 }; + + pxNetworkBuffer->xDataLength = ipconfigTCP_MSS; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + pxNetworkBuffer->pxInterface = &xInterface; + pxNetworkBuffer->pxEndPoint = &xNetworkEndPoint; + + pxEthernetHeader = ( EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer; + pxEthernetHeader->usFrameType = 0xFFFF; + + vReleaseNetworkBufferAndDescriptor_Expect( pxNetworkBuffer ); + + prvProcessEthernetPacket( pxNetworkBuffer ); +} + +/** + * @brief test_prvProcessEthernetPacket_UnknownFrameType_NeedResolution + * But we release the network buffer because the frame type is unknown. + */ +void test_prvProcessEthernetPacket_IPv4FrameType_CheckFrameFail( void ) +{ + NetworkBufferDescriptor_t xNetworkBuffer; + NetworkBufferDescriptor_t * pxNetworkBuffer = &xNetworkBuffer; + uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ] = { 0 }; + EthernetHeader_t * pxEthernetHeader; + IPPacket_IPv6_t * pxIPv6Packet; + IPHeader_IPv6_t * pxIPv6Header; + struct xNetworkInterface xInterface; + NetworkEndPoint_t xNetworkEndPoint = { 0 }; + + pxNetworkBuffer->xDataLength = ipconfigTCP_MSS; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + pxNetworkBuffer->pxInterface = &xInterface; + pxNetworkBuffer->pxEndPoint = &xNetworkEndPoint; + + pxEthernetHeader = ( EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer; + pxEthernetHeader->usFrameType = ipIPv4_FRAME_TYPE; + + FreeRTOS_FindEndPointOnMAC_ExpectAndReturn( &pxEthernetHeader->xDestinationAddress, NULL, NULL ); + vReleaseNetworkBufferAndDescriptor_Expect( pxNetworkBuffer ); + + prvProcessEthernetPacket( pxNetworkBuffer ); +} diff --git a/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_utest.c b/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_utest.c index 789cf3fc3..367fbee9b 100644 --- a/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_utest.c +++ b/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_utest.c @@ -65,6 +65,7 @@ void prvIPTimerStart( IPTimer_t * pxTimer, BaseType_t prvIPTimerCheck( IPTimer_t * pxTimer ); extern IPTimer_t xARPTimer; +extern IPTimer_t xNDTimer; #if ( ipconfigUSE_TCP != 0 ) /** @brief TCP timer, to check for timeouts, resends. */ extern IPTimer_t xTCPTimer; @@ -75,6 +76,7 @@ extern IPTimer_t xARPTimer; #endif extern IPTimer_t xARPResolutionTimer; +extern IPTimer_t xNDResolutionTimer; extern BaseType_t xAllNetworksUp; extern IPTimer_t xNetworkTimer; @@ -96,9 +98,11 @@ void setUp( void ) /* Reset all timers. */ memset( &xARPTimer, 0, sizeof( IPTimer_t ) ); + memset( &xNDTimer, 0, sizeof( IPTimer_t ) ); memset( &xDNSTimer, 0, sizeof( IPTimer_t ) ); memset( &xTCPTimer, 0, sizeof( IPTimer_t ) ); memset( &xARPResolutionTimer, 0, sizeof( IPTimer_t ) ); + memset( &xNDResolutionTimer, 0, sizeof( IPTimer_t ) ); memset( &xNetworkTimer, 0, sizeof( IPTimer_t ) ); } @@ -119,6 +123,7 @@ void test_xCalculateSleepTime_AllTimersInactive( void ) TickType_t uxTicks; xARPTimer.bActive = pdFALSE; + xNDTimer.bActive = pdFALSE; pxNetworkEndPoints->xDHCP_RATimer.bActive = pdFALSE; xDNSTimer.bActive = pdFALSE; xTCPTimer.bActive = pdFALSE; @@ -138,14 +143,16 @@ void test_xCalculateSleepTime_AllTimersActive_AllTimesGreater( void ) TickType_t uxTicks; xARPTimer.bActive = pdTRUE; + xNDTimer.bActive = pdTRUE; pxNetworkEndPoints->xDHCP_RATimer.bActive = pdTRUE; xDNSTimer.bActive = pdTRUE; xTCPTimer.bActive = pdTRUE; xARPTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; - pxNetworkEndPoints->xDHCP_RATimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME + 1; - xTCPTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME + 2; - xDNSTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME + 3; + xNDTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME + 1; + pxNetworkEndPoints->xDHCP_RATimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME + 2; + xTCPTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME + 3; + xDNSTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME + 4; uxTicks = xCalculateSleepTime(); @@ -162,11 +169,39 @@ void test_xCalculateSleepTime_AllTimersActive_AllTimesGreaterExceptARP( void ) TickType_t uxTicks; xARPTimer.bActive = pdTRUE; + xNDTimer.bActive = pdTRUE; pxNetworkEndPoints->xDHCP_RATimer.bActive = pdTRUE; xDNSTimer.bActive = pdTRUE; xTCPTimer.bActive = pdTRUE; xARPTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME - 10; + xNDTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; + pxNetworkEndPoints->xDHCP_RATimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; + xTCPTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; + xDNSTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; + + uxTicks = xCalculateSleepTime(); + + TEST_ASSERT_EQUAL( ipconfigMAX_IP_TASK_SLEEP_TIME - 10, uxTicks ); +} + +/** + * @brief test_xCalculateSleepTime_AllTimersActive_AllTimesGreaterExceptND + * To validate if xCalculateSleepTime() returns the shortest remaining time + * of all active timers. In this case, ND timer has the shortest remaining time. + */ +void test_xCalculateSleepTime_AllTimersActive_AllTimesGreaterExceptND( void ) +{ + TickType_t uxTicks; + + xARPTimer.bActive = pdTRUE; + xNDTimer.bActive = pdTRUE; + pxNetworkEndPoints->xDHCP_RATimer.bActive = pdTRUE; + xDNSTimer.bActive = pdTRUE; + xTCPTimer.bActive = pdTRUE; + + xARPTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; + xNDTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME - 10; pxNetworkEndPoints->xDHCP_RATimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; xTCPTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; xDNSTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; @@ -191,11 +226,13 @@ void test_xCalculateSleepTime_AllTimersActive_AllTimesGreaterExceptDHCP( void ) pxNetworkEndPoints = pxEndpoint; xARPTimer.bActive = pdTRUE; + xNDTimer.bActive = pdTRUE; pxEndpoint->xDHCP_RATimer.bActive = pdTRUE; xDNSTimer.bActive = pdTRUE; xTCPTimer.bActive = pdTRUE; xARPTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; + xNDTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; pxEndpoint->xDHCP_RATimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME - 10; xTCPTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; xDNSTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; @@ -215,11 +252,13 @@ void test_xCalculateSleepTime_AllTimersActive_AllTimesGreaterExceptTCP( void ) TickType_t uxTicks; xARPTimer.bActive = pdTRUE; + xNDTimer.bActive = pdTRUE; pxNetworkEndPoints->xDHCP_RATimer.bActive = pdTRUE; xDNSTimer.bActive = pdTRUE; xTCPTimer.bActive = pdTRUE; xARPTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; + xNDTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; pxNetworkEndPoints->xDHCP_RATimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; xTCPTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME - 10; xDNSTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; @@ -239,11 +278,13 @@ void test_xCalculateSleepTime_AllTimersActive_AllTimesGreaterExceptDNS( void ) TickType_t uxTicks; xARPTimer.bActive = pdTRUE; + xNDTimer.bActive = pdTRUE; pxNetworkEndPoints->xDHCP_RATimer.bActive = pdTRUE; xDNSTimer.bActive = pdTRUE; xTCPTimer.bActive = pdTRUE; xARPTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; + xNDTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; pxNetworkEndPoints->xDHCP_RATimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; xTCPTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME; xDNSTimer.ulRemainingTime = ipconfigMAX_IP_TASK_SLEEP_TIME - 10; @@ -295,6 +336,7 @@ void test_xCalculateSleepTime_MultipleDHCPTimers( void ) void test_vCheckNetworkTimers_AllTimersDisabled( void ) { xARPTimer.bActive = pdFALSE; + xNDTimer.bActive = pdFALSE; pxNetworkEndPoints->xDHCP_RATimer.bActive = pdFALSE; xDNSTimer.bActive = pdFALSE; xTCPTimer.bActive = pdFALSE; @@ -315,6 +357,7 @@ void test_vCheckNetworkTimers_AllTimersDisabled( void ) void test_vCheckNetworkTimers_ARPTimerActiveAndExpired( void ) { xARPTimer.bActive = pdTRUE; + xNDTimer.bActive = pdFALSE; pxNetworkEndPoints->xDHCP_RATimer.bActive = pdFALSE; xDNSTimer.bActive = pdFALSE; xTCPTimer.bActive = pdFALSE; @@ -342,10 +385,12 @@ void test_vCheckNetworkTimers_ARPTimerActiveAndExpired( void ) void test_vCheckNetworkTimers_ARPResolutionTimerActiveAndExpiredNullBuffer( void ) { xARPTimer.bActive = pdFALSE; + xNDTimer.bActive = pdFALSE; pxNetworkEndPoints->xDHCP_RATimer.bActive = pdFALSE; xDNSTimer.bActive = pdFALSE; xTCPTimer.bActive = pdFALSE; xARPResolutionTimer.bActive = pdTRUE; + xNDResolutionTimer.bActive = pdFALSE; xARPResolutionTimer.bExpired = pdTRUE; @@ -372,10 +417,12 @@ void test_vCheckNetworkTimers_ARPResolutionTimerActiveAndExpiredNullBuffer( void void test_vCheckNetworkTimers_ARPResolutionTimerActiveAndExpired( void ) { xARPTimer.bActive = pdFALSE; + xNDTimer.bActive = pdFALSE; pxNetworkEndPoints->xDHCP_RATimer.bActive = pdFALSE; xDNSTimer.bActive = pdFALSE; xTCPTimer.bActive = pdFALSE; xARPResolutionTimer.bActive = pdTRUE; + xNDResolutionTimer.bActive = pdFALSE; xARPResolutionTimer.bExpired = pdTRUE; @@ -397,6 +444,100 @@ void test_vCheckNetworkTimers_ARPResolutionTimerActiveAndExpired( void ) TEST_ASSERT_EQUAL_PTR( NULL, pxARPWaitingNetworkBuffer ); } +/** + * @brief test_vCheckNetworkTimers_NDTimerActiveAndExpired + * To validate if vCheckNetworkTimers() handles ND timer expired event as expected. + */ +void test_vCheckNetworkTimers_NDTimerActiveAndExpired( void ) +{ + xARPTimer.bActive = pdFALSE; + xNDTimer.bActive = pdTRUE; + pxNetworkEndPoints->xDHCP_RATimer.bActive = pdFALSE; + xDNSTimer.bActive = pdFALSE; + xTCPTimer.bActive = pdFALSE; + + xNDTimer.bExpired = pdTRUE; + + vTaskSetTimeOutState_Expect( &( xNDTimer.xTimeOut ) ); + + xSendEventToIPTask_ExpectAndReturn( eNDTimerEvent, pdTRUE ); + + uxQueueMessagesWaiting_ExpectAnyArgsAndReturn( pdTRUE ); + + vSocketCloseNextTime_Expect( NULL ); + + vSocketListenNextTime_Expect( NULL ); + + vCheckNetworkTimers(); +} + +/** + * @brief test_vCheckNetworkTimers_NDesolutionTimerActiveAndExpiredNullBuffer + * To validate if vCheckNetworkTimers() handles ND resolution timer expired event as expected. + * And there is no buffer waiting for ND reply. + */ +void test_vCheckNetworkTimers_NDesolutionTimerActiveAndExpiredNullBuffer( void ) +{ + xARPTimer.bActive = pdFALSE; + xNDTimer.bActive = pdFALSE; + pxNetworkEndPoints->xDHCP_RATimer.bActive = pdFALSE; + xDNSTimer.bActive = pdFALSE; + xTCPTimer.bActive = pdFALSE; + xARPResolutionTimer.bActive = pdFALSE; + xNDResolutionTimer.bActive = pdTRUE; + + xNDResolutionTimer.bExpired = pdTRUE; + + pxNDWaitingNetworkBuffer = NULL; + + vTaskSetTimeOutState_Expect( &( xNDResolutionTimer.xTimeOut ) ); + + uxQueueMessagesWaiting_ExpectAnyArgsAndReturn( pdTRUE ); + + vSocketCloseNextTime_Expect( NULL ); + + vSocketListenNextTime_Expect( NULL ); + + vCheckNetworkTimers(); + + TEST_ASSERT_EQUAL( pdTRUE, xNDResolutionTimer.bExpired ); +} + +/** + * @brief test_vCheckNetworkTimers_NDResolutionTimerActiveAndExpired + * To validate if vCheckNetworkTimers() handles ND resolution timer expired event as expected. + * And there is a buffer waiting for ND reply. + */ +void test_vCheckNetworkTimers_NDResolutionTimerActiveAndExpired( void ) +{ + xARPTimer.bActive = pdFALSE; + xNDTimer.bActive = pdFALSE; + pxNetworkEndPoints->xDHCP_RATimer.bActive = pdFALSE; + xDNSTimer.bActive = pdFALSE; + xTCPTimer.bActive = pdFALSE; + xARPResolutionTimer.bActive = pdFALSE; + xNDResolutionTimer.bActive = pdTRUE; + + xNDResolutionTimer.bExpired = pdTRUE; + + pxNDWaitingNetworkBuffer = ( NetworkBufferDescriptor_t * ) 0x1234ABCD; + + vTaskSetTimeOutState_Expect( &( xNDResolutionTimer.xTimeOut ) ); + + vReleaseNetworkBufferAndDescriptor_Expect( pxNDWaitingNetworkBuffer ); + + uxQueueMessagesWaiting_ExpectAnyArgsAndReturn( pdTRUE ); + + vSocketCloseNextTime_Expect( NULL ); + + vSocketListenNextTime_Expect( NULL ); + + vCheckNetworkTimers(); + + TEST_ASSERT_EQUAL( pdFALSE_UNSIGNED, xNDResolutionTimer.bActive ); + TEST_ASSERT_EQUAL_PTR( NULL, pxNDWaitingNetworkBuffer ); +} + /** * @brief test_vCheckNetworkTimers_DHCPTimerActiveAndExpired * To validate if vCheckNetworkTimers() handles DHCP timer expired event as expected. @@ -404,10 +545,12 @@ void test_vCheckNetworkTimers_ARPResolutionTimerActiveAndExpired( void ) void test_vCheckNetworkTimers_DHCPTimerActiveAndExpired( void ) { xARPTimer.bActive = pdFALSE; + xNDTimer.bActive = pdFALSE; pxNetworkEndPoints->xDHCP_RATimer.bActive = pdTRUE; xDNSTimer.bActive = pdFALSE; xTCPTimer.bActive = pdFALSE; xARPResolutionTimer.bActive = pdFALSE; + xNDResolutionTimer.bActive = pdFALSE; pxNetworkEndPoints->xDHCP_RATimer.bExpired = pdTRUE; @@ -454,10 +597,12 @@ void test_vCheckNetworkTimers_DHCPv6TimerActiveAndExpired( void ) void test_vCheckNetworkTimers_RATimerActiveAndExpired( void ) { xARPTimer.bActive = pdFALSE; + xNDTimer.bActive = pdFALSE; pxNetworkEndPoints->xDHCP_RATimer.bActive = pdTRUE; xDNSTimer.bActive = pdFALSE; xTCPTimer.bActive = pdFALSE; xARPResolutionTimer.bActive = pdFALSE; + xNDResolutionTimer.bActive = pdFALSE; pxNetworkEndPoints->xDHCP_RATimer.bExpired = pdTRUE; pxNetworkEndPoints->bits.bIPv6 = pdTRUE; @@ -486,10 +631,12 @@ void test_vCheckNetworkTimers_DNSTimerActiveAndExpired( void ) NetworkEndPoint_t xEndPoint = { 0 }; xARPTimer.bActive = pdFALSE; + xNDTimer.bActive = pdFALSE; pxNetworkEndPoints->xDHCP_RATimer.bActive = pdFALSE; xDNSTimer.bActive = pdTRUE; xTCPTimer.bActive = pdFALSE; xARPResolutionTimer.bActive = pdFALSE; + xNDResolutionTimer.bActive = pdFALSE; xDNSTimer.bExpired = pdTRUE; @@ -624,10 +771,12 @@ void test_vCheckNetworkTimers_NetworkInterfacesAlreadyUp( void ) void test_vCheckNetworkTimers_AllTimersInactivePendingMessages( void ) { xARPTimer.bActive = pdFALSE; + xNDTimer.bActive = pdFALSE; pxNetworkEndPoints->xDHCP_RATimer.bActive = pdFALSE; xDNSTimer.bActive = pdFALSE; xTCPTimer.bActive = pdFALSE; xARPResolutionTimer.bActive = pdFALSE; + xNDResolutionTimer.bActive = pdFALSE; uxQueueMessagesWaiting_ExpectAnyArgsAndReturn( pdTRUE ); @@ -646,10 +795,12 @@ void test_vCheckNetworkTimers_AllTimersInactivePendingMessages( void ) void test_vCheckNetworkTimers_AllTimersInactive_2( void ) { xARPTimer.bActive = pdFALSE; + xNDTimer.bActive = pdFALSE; pxNetworkEndPoints->xDHCP_RATimer.bActive = pdFALSE; xDNSTimer.bActive = pdFALSE; xTCPTimer.bActive = pdFALSE; xARPResolutionTimer.bActive = pdFALSE; + xNDResolutionTimer.bActive = pdFALSE; uxQueueMessagesWaiting_ExpectAnyArgsAndReturn( pdFALSE ); @@ -724,7 +875,25 @@ void test_vIPTimerStartARPResolution( void ) } /** - * @brief test_vIPTimerStartARPResolution + * @brief test_vIPTimerStartNDResolution + * To validate if vIPTimerStartNDResolution() activate the ND resolution timer + * with zero time. Timer must be expired after calling. + */ +void test_vIPTimerStartNDResolution( void ) +{ + TickType_t xTime = 0x00; + + vTaskSetTimeOutState_Expect( &xNDResolutionTimer.xTimeOut ); + + vIPTimerStartNDResolution( xTime ); + + TEST_ASSERT_EQUAL( xTime, xNDResolutionTimer.ulRemainingTime ); + TEST_ASSERT_EQUAL( pdTRUE, xNDResolutionTimer.bActive ); + TEST_ASSERT_EQUAL( pdTRUE, xNDResolutionTimer.bExpired ); +} + +/** + * @brief test_vTCPTimerReload * To validate if vTCPTimerReload() activate the TCP timer with non-zero time. */ void test_vTCPTimerReload( void ) @@ -759,6 +928,24 @@ void test_vARPTimerReload( void ) TEST_ASSERT_EQUAL( pdFALSE, xARPTimer.bExpired ); } +/** + * @brief test_vNDTimerReload + * To validate if vNDTimerReload() activate the ND timer with non-zero time. + */ +void test_vNDTimerReload( void ) +{ + TickType_t xTime = 0x12A; + + vTaskSetTimeOutState_Expect( &xNDTimer.xTimeOut ); + + vNDTimerReload( xTime ); + + TEST_ASSERT_EQUAL( 0x12A, xNDTimer.ulReloadTime ); + TEST_ASSERT_EQUAL( xTime, xNDTimer.ulRemainingTime ); + TEST_ASSERT_EQUAL( pdTRUE, xNDTimer.bActive ); + TEST_ASSERT_EQUAL( pdFALSE, xNDTimer.bExpired ); +} + /** * @brief test_vDHCP_RATimerReload * To validate if vTCPTimerReload() activate the DHCP timer with non-zero time. @@ -986,6 +1173,60 @@ void test_vIPSetARPResolutionTimerEnableState_True( void ) TEST_ASSERT_EQUAL( xEnableState, xARPResolutionTimer.bActive ); } +/** + * @brief test_vIPSetNDTimerEnableState_False + * To validate if vIPSetNDTimerEnableState() sets ND timer to non expired state. + */ +void test_vIPSetNDTimerEnableState_False( void ) +{ + BaseType_t xEnableState = pdFALSE; + + vIPSetNDTimerEnableState( xEnableState ); + + TEST_ASSERT_EQUAL( xEnableState, xNDTimer.bActive ); +} + +/** + * @brief test_vIPSetNDTimerEnableState_True + * To validate if vIPSetNDTimerEnableState() sets ND timer to expired state. + */ +void test_vIPSetNDTimerEnableState_True( void ) +{ + BaseType_t xEnableState = pdTRUE; + + vIPSetNDTimerEnableState( xEnableState ); + + TEST_ASSERT_EQUAL( xEnableState, xNDTimer.bActive ); +} + +/** + * @brief test_vIPSetNDResolutionTimerEnableState_False + * To validate if vIPSetNDResolutionTimerEnableState() sets ND resolution timer + * to non expired state. + */ +void test_vIPSetNDResolutionTimerEnableState_False( void ) +{ + BaseType_t xEnableState = pdFALSE; + + vIPSetNDResolutionTimerEnableState( xEnableState ); + + TEST_ASSERT_EQUAL( xEnableState, xNDResolutionTimer.bActive ); +} + +/** + * @brief test_vIPSetNDResolutionTimerEnableState_True + * To validate if vIPSetNDResolutionTimerEnableState() sets ND resolution timer + * to expired state. + */ +void test_vIPSetNDResolutionTimerEnableState_True( void ) +{ + BaseType_t xEnableState = pdTRUE; + + vIPSetNDResolutionTimerEnableState( xEnableState ); + + TEST_ASSERT_EQUAL( xEnableState, xNDResolutionTimer.bActive ); +} + /** * @brief test_vIPSetDHCP_RATimerEnableState_False * To validate if vIPSetDHCP_RATimerEnableState() sets DHCP timer diff --git a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c index 672bfac25..afb69714e 100644 --- a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c +++ b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c @@ -789,6 +789,40 @@ void test_FreeRTOS_ClearND( void ) TEST_ASSERT_EQUAL_MEMORY( xNDCache, xTempNDCache, sizeof( xNDCache ) ); } +/** + * @brief Clear the Neighbour Discovery cache with specific endpoint. + */ +void test_FreeRTOS_ClearND_WithEndPoint( void ) +{ + NDCacheRow_t xTempNDCache[ ipconfigND_CACHE_ENTRIES ]; + struct xNetworkEndPoint xEndPoint; + + /* Set xNDCache to non zero entries*/ + ( void ) memset( xNDCache, 1, sizeof( xNDCache ) ); + ( void ) memset( xTempNDCache, 0, sizeof( xTempNDCache ) ); + xNDCache[ 1 ].pxEndPoint = &xEndPoint; + FreeRTOS_ClearND( &xEndPoint ); + + TEST_ASSERT_EQUAL_MEMORY( &xNDCache[ 1 ], xTempNDCache, sizeof( NDCacheRow_t ) ); +} + +/** + * @brief Clear the Neighbour Discovery cache with endpoint. + * But the endpoint doesn't match any in cache. + */ +void test_FreeRTOS_ClearND_EndPointNotFound( void ) +{ + NDCacheRow_t xTempNDCache[ ipconfigND_CACHE_ENTRIES ]; + struct xNetworkEndPoint xEndPoint; + + /* Set xNDCache to non zero entries*/ + ( void ) memset( xNDCache, 1, sizeof( xNDCache ) ); + ( void ) memset( xTempNDCache, 1, sizeof( xTempNDCache ) ); + FreeRTOS_ClearND( &xEndPoint ); + + TEST_ASSERT_EQUAL_MEMORY( xTempNDCache, xNDCache, sizeof( xNDCache ) ); +} + /** * @brief Toggle happy path. */ @@ -1886,22 +1920,6 @@ void test_FreeRTOS_CreateIPv6Address_Pass2( void ) TEST_ASSERT_EQUAL( xReturn, pdPASS ); } -void test_FreeRTOS_CreateIPv6Address_Pass3( void ) /*CHECK if needed */ -{ - IPv6_Address_t xIPAddress, xPrefix; - size_t uxPrefixLength = 127; - BaseType_t xDoRandom = pdTRUE, xReturn, xIndex; - - for( xIndex = 0; xIndex < 4; xIndex++ ) - { - xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE ); - } - - xReturn = FreeRTOS_CreateIPv6Address( &xIPAddress, &xPrefix, uxPrefixLength, xDoRandom ); - - TEST_ASSERT_EQUAL( xReturn, pdPASS ); -} - /** * @brief Cover all the pcMessageType print * scenario. @@ -1944,6 +1962,9 @@ void test_pcMessageType_All( void ) ( void ) pcMessageType( xType ); } +/** + * @brief heck if the network buffer requires resolution for different protocols. + */ void test_xCheckIPv6RequiresResolution_Protocols( void ) { struct xNetworkEndPoint xEndPoint = { 0 }; @@ -1978,6 +1999,10 @@ void test_xCheckIPv6RequiresResolution_Protocols( void ) TEST_ASSERT_EQUAL( pdFALSE, xResult ); } +/** + * @brief Check if the network buffer requires resolution for addresses + * not on the local network. + */ void test_xCheckRequiresNDResolution_TCPNotOnLocalNetwork( void ) { struct xNetworkEndPoint xEndPoint = { 0 }; @@ -2000,6 +2025,9 @@ void test_xCheckRequiresNDResolution_TCPNotOnLocalNetwork( void ) TEST_ASSERT_EQUAL( pdFALSE, xResult ); } +/** + * @brief Cache hit occurs with an IP address in the multicast case. + */ void test_xCheckRequiresNDResolution_Hit( void ) { struct xNetworkEndPoint xEndPoint = { 0 }; @@ -2028,6 +2056,9 @@ void test_xCheckRequiresNDResolution_Hit( void ) TEST_ASSERT_EQUAL( pdFALSE, xResult ); } +/** + * @brief ND cache miss scenarios. + */ void test_xCheckRequiresNDResolution_Miss( void ) { struct xNetworkEndPoint xEndPoint, * pxEndPoint = &xEndPoint; @@ -2067,3 +2098,13 @@ void test_xCheckRequiresNDResolution_Miss( void ) TEST_ASSERT_EQUAL( pdTRUE, xResult ); } + +/** + * @brief Toggle vNDSendUnsolicited. + */ +void test_vNDSendUnsolicited( void ) +{ + xSendEventToIPTask_ExpectAndReturn( eNDTimerEvent, 0 ); + + vNDSendUnsolicited(); +} From 145eaac1847a616b93c897142e7625365db5be00 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 17 Oct 2024 10:10:35 +0000 Subject: [PATCH 17/25] Fix buffer access issue in UT. --- test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c index 34c8839ac..f6fa11343 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c @@ -2404,8 +2404,8 @@ void test_prvProcessEthernetPacket_IPv4FrameType_NeedARPResolution( void ) struct xNetworkInterface xInterface; NetworkEndPoint_t xNetworkEndPoint = { 0 }; - pxNetworkBuffer->xDataLength = ipconfigTCP_MSS; - pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + pxNetworkBuffer->xDataLength = ipconfigTCP_MSS - ipIP_TYPE_OFFSET; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer + ipIP_TYPE_OFFSET; pxNetworkBuffer->pxInterface = &xInterface; pxNetworkBuffer->pxEndPoint = &xNetworkEndPoint; @@ -2442,8 +2442,8 @@ void test_prvProcessEthernetPacket_IPv6FrameType_NeedNDResolution( void ) struct xNetworkInterface xInterface; NetworkEndPoint_t xNetworkEndPoint = { 0 }; - pxNetworkBuffer->xDataLength = ipconfigTCP_MSS; - pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + pxNetworkBuffer->xDataLength = ipconfigTCP_MSS - ipIP_TYPE_OFFSET; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer + ipIP_TYPE_OFFSET; pxNetworkBuffer->pxInterface = &xInterface; pxNetworkBuffer->pxEndPoint = &xNetworkEndPoint; @@ -2480,8 +2480,8 @@ void test_prvProcessEthernetPacket_IPv6FrameType_NeedNDResolution2( void ) struct xNetworkInterface xInterface; NetworkEndPoint_t xNetworkEndPoint = { 0 }; - pxNetworkBuffer->xDataLength = ipconfigTCP_MSS; - pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + pxNetworkBuffer->xDataLength = ipconfigTCP_MSS - ipIP_TYPE_OFFSET; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer + ipIP_TYPE_OFFSET; pxNetworkBuffer->pxInterface = &xInterface; pxNetworkBuffer->pxEndPoint = &xNetworkEndPoint; From be8b4f9985b529bfdf373f58794c6c5ec1d7ee92 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 17 Oct 2024 10:12:17 +0000 Subject: [PATCH 18/25] Fix spelling --- test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_utest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_utest.c b/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_utest.c index 367fbee9b..a26121951 100644 --- a/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_utest.c +++ b/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_utest.c @@ -472,11 +472,11 @@ void test_vCheckNetworkTimers_NDTimerActiveAndExpired( void ) } /** - * @brief test_vCheckNetworkTimers_NDesolutionTimerActiveAndExpiredNullBuffer + * @brief test_vCheckNetworkTimers_NDResolutionTimerActiveAndExpiredNullBuffer * To validate if vCheckNetworkTimers() handles ND resolution timer expired event as expected. * And there is no buffer waiting for ND reply. */ -void test_vCheckNetworkTimers_NDesolutionTimerActiveAndExpiredNullBuffer( void ) +void test_vCheckNetworkTimers_NDResolutionTimerActiveAndExpiredNullBuffer( void ) { xARPTimer.bActive = pdFALSE; xNDTimer.bActive = pdFALSE; From 1245cb79d5d5f97490815578504f84049665e808 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Fri, 18 Oct 2024 02:40:41 +0000 Subject: [PATCH 19/25] 100% UT coverage --- .../unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c index afb69714e..fb30cb402 100644 --- a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c +++ b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c @@ -1920,6 +1920,27 @@ void test_FreeRTOS_CreateIPv6Address_Pass2( void ) TEST_ASSERT_EQUAL( xReturn, pdPASS ); } +/** + * @brief Create an IPv6 address, based on a prefix. + * with the bits after the prefix having random value + * and uxPrefixLength is 128 bites. + */ +void test_FreeRTOS_CreateIPv6Address_Pass3( void ) +{ + IPv6_Address_t xIPAddress, xPrefix; + size_t uxPrefixLength = 128; + BaseType_t xDoRandom = pdTRUE, xReturn, xIndex; + + for( xIndex = 0; xIndex < 4; xIndex++ ) + { + xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE ); + } + + xReturn = FreeRTOS_CreateIPv6Address( &xIPAddress, &xPrefix, uxPrefixLength, xDoRandom ); + + TEST_ASSERT_EQUAL( xReturn, pdPASS ); +} + /** * @brief Cover all the pcMessageType print * scenario. @@ -2099,6 +2120,28 @@ void test_xCheckRequiresNDResolution_Miss( void ) TEST_ASSERT_EQUAL( pdTRUE, xResult ); } +/** + * @brief Trigger assertion when Ethernet frame type is not IPv6 while calling xCheckRequiresNDResolution. + */ +void test_xCheckRequiresNDResolution_AssertInvalidFrameType( void ) +{ + struct xNetworkEndPoint xEndPoint = { 0 }; + NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer; + uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; + BaseType_t xResult; + + ( void ) memset( xNDCache, 0, sizeof( xNDCache ) ); + + pxNetworkBuffer = &xNetworkBuffer; + pxNetworkBuffer->pxEndPoint = &xEndPoint; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); + IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); + pxIPPacket->xEthernetHeader.usFrameType = ipIPv4_FRAME_TYPE; + + catch_assert( xCheckRequiresNDResolution( pxNetworkBuffer ) ); +} + /** * @brief Toggle vNDSendUnsolicited. */ From dd76d502e9c7aa2462b24e29d4710ad3ff9c9288 Mon Sep 17 00:00:00 2001 From: Holden Date: Fri, 8 Nov 2024 00:54:27 -0500 Subject: [PATCH 20/25] Review Fixes --- source/FreeRTOS_ARP.c | 2 +- source/FreeRTOS_ND.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index 9501bec53..a9a3edfec 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -521,7 +521,7 @@ const IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); const IPV4Parameters_t * pxIPv4Settings = &( pxNetworkBuffer->pxEndPoint->ipv4_settings ); - /* configASSERT( ( pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) || ( pxIPPacket->xEthernetHeader.usFrameType == ipARP_FRAME_TYPE ) ); */ + configASSERT( ( pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) || ( pxIPPacket->xEthernetHeader.usFrameType == ipARP_FRAME_TYPE ) ); if( ( pxIPHeader->ulSourceIPAddress & pxIPv4Settings->ulNetMask ) == ( pxIPv4Settings->ulIPAddress & pxIPv4Settings->ulNetMask ) ) { diff --git a/source/FreeRTOS_ND.c b/source/FreeRTOS_ND.c index c09310322..62d100ed6 100644 --- a/source/FreeRTOS_ND.c +++ b/source/FreeRTOS_ND.c @@ -944,7 +944,7 @@ IPStackEvent_t xEventMessage; const TickType_t xDontBlock = ( TickType_t ) 0; - FreeRTOS_printf( ( "Waiting done\n" ) ); + FreeRTOS_debug_printf( ( "ND resolution waiting done\n" ) ); xEventMessage.eEventType = eNetworkRxEvent; xEventMessage.pvData = ( void * ) pxNDWaitingNetworkBuffer; From 869a5e64556e70ef360c2421ec1ccb13644b96d9 Mon Sep 17 00:00:00 2001 From: Holden Date: Fri, 8 Nov 2024 01:16:52 -0500 Subject: [PATCH 21/25] Fix Unit Tests --- .../FreeRTOS_ARP/FreeRTOS_ARP_utest.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c index c460c0c77..d72545896 100644 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c @@ -1469,6 +1469,8 @@ void test_xCheckRequiresARPResolution_NotOnLocalNetwork( void ) IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); + pxIPPacket->xEthernetHeader.usFrameType = ipIPv4_FRAME_TYPE; + xEndPoint.ipv4_settings.ulIPAddress = 0xABCD1234; xEndPoint.ipv4_settings.ulNetMask = 0xFFFFFF00; @@ -1498,6 +1500,8 @@ void test_xCheckRequiresARPResolution_NotOnLocalNetwork_InvalidHeader( void ) IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); + pxIPPacket->xEthernetHeader.usFrameType = ipIPv4_FRAME_TYPE; + xEndPoint.ipv4_settings.ulIPAddress = 0xABCD1234; xEndPoint.ipv4_settings.ulNetMask = 0xFFFFFF00; @@ -1527,6 +1531,8 @@ void test_xCheckRequiresARPResolution_NotOnLocalNetwork_IPv6( void ) IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); + pxIPPacket->xEthernetHeader.usFrameType = ipIPv4_FRAME_TYPE; + xEndPoint.ipv4_settings.ulIPAddress = 0xABCD1234; xEndPoint.ipv4_settings.ulNetMask = 0xFFFFFF00; @@ -1557,6 +1563,8 @@ void test_xCheckRequiresARPResolution_OnLocalNetwork_NotInCache( void ) IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); + pxIPPacket->xEthernetHeader.usFrameType = ipIPv4_FRAME_TYPE; + xEndPoint.ipv4_settings.ulIPAddress = 0xABCD1234; xEndPoint.ipv4_settings.ulNetMask = 0xFFFFFF00; @@ -1598,6 +1606,8 @@ void test_xCheckRequiresARPResolution_OnLocalNetwork_InCache( void ) IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); + pxIPPacket->xEthernetHeader.usFrameType = ipIPv4_FRAME_TYPE; + xEndPoint.ipv4_settings.ulIPAddress = 0xABCD1234; xEndPoint.ipv4_settings.ulNetMask = 0xFFFFFF00; @@ -1620,6 +1630,26 @@ void test_xCheckRequiresARPResolution_OnLocalNetwork_InCache( void ) TEST_ASSERT_EQUAL( pdFALSE, xResult ); } +/** + * @brief Trigger assertion when Ethernet frame type is not IPv6 while calling xCheckRequiresARPResolution. + */ +void test_xCheckRequiresARPResolution_AssertInvalidFrameType( void ) +{ + struct xNetworkEndPoint xEndPoint = { 0 }; + NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer; + uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; + BaseType_t xResult; + + pxNetworkBuffer = &xNetworkBuffer; + pxNetworkBuffer->pxEndPoint = &xEndPoint; + pxNetworkBuffer->pucEthernetBuffer = ucEthernetBuffer; + IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); + IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); + + pxIPPacket->xEthernetHeader.usFrameType = ipIPv6_FRAME_TYPE; + + catch_assert( xCheckRequiresARPResolution( pxNetworkBuffer ) ); +} void test_ulARPRemoveCacheEntryByMac_NoMatch( void ) { From 6ae79f1ebd21bb2ae205dedb0cd4cb5ed8b12b92 Mon Sep 17 00:00:00 2001 From: Holden Date: Fri, 8 Nov 2024 03:35:59 -0500 Subject: [PATCH 22/25] Fix Coverage --- test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c index d72545896..c6b41eb1b 100644 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c @@ -1500,7 +1500,7 @@ void test_xCheckRequiresARPResolution_NotOnLocalNetwork_InvalidHeader( void ) IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); - pxIPPacket->xEthernetHeader.usFrameType = ipIPv4_FRAME_TYPE; + pxIPPacket->xEthernetHeader.usFrameType = ipARP_FRAME_TYPE; xEndPoint.ipv4_settings.ulIPAddress = 0xABCD1234; From 5341b9b3d8f84d7be589beb8d2f537c3876825c7 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 8 Nov 2024 14:47:50 +0530 Subject: [PATCH 23/25] Fix CBMC proof for xCheckRequiresARPResolution --- .../xCheckRequiresARPResolution_harness.c | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/test/cbmc/proofs/ARP/xCheckRequiresARPResolution/xCheckRequiresARPResolution_harness.c b/test/cbmc/proofs/ARP/xCheckRequiresARPResolution/xCheckRequiresARPResolution_harness.c index e5673ef8d..f090644f8 100644 --- a/test/cbmc/proofs/ARP/xCheckRequiresARPResolution/xCheckRequiresARPResolution_harness.c +++ b/test/cbmc/proofs/ARP/xCheckRequiresARPResolution/xCheckRequiresARPResolution_harness.c @@ -90,18 +90,12 @@ void harness() NetworkBufferDescriptor_t * pxNetworkBuffer; IPPacket_t * pxIPPacket; - /* IPv4/IPv6 header size are different. To make sure buffer size is enough, - * determine the test case is for IPv4 or IPv6 at the beginning. */ - xIsIPv6 = nondet_bool(); + const IPPacket_t * pxIPPacket; + const IPHeader_t * pxIPHeader; - if( xIsIPv6 ) - { - __CPROVER_assume( ( xBufferLength >= sizeof( IPPacket_IPv6_t ) ) && ( xBufferLength < ipconfigNETWORK_MTU ) ); - } - else - { - __CPROVER_assume( ( xBufferLength >= sizeof( IPPacket_t ) ) && ( xBufferLength < ipconfigNETWORK_MTU ) ); - } + /* Make sure buffer size is enough, xCheckRequiresARPResolution is only called for + IPv4 packets hence the minimum size should be sizeof( IPPacket_t ) */ + __CPROVER_assume( ( xBufferLength >= sizeof( IPPacket_t ) ) && ( xBufferLength < ipconfigNETWORK_MTU ) ); pxNetworkBuffer = ( NetworkBufferDescriptor_t * ) safeMalloc( sizeof( NetworkBufferDescriptor_t ) ); __CPROVER_assume( pxNetworkBuffer != NULL ); @@ -111,6 +105,13 @@ void harness() pxNetworkBuffer->pucEthernetBuffer = safeMalloc( xBufferLength ); __CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer != NULL ); + /* Its asserted in the code that xCheckRequiresARPResolution is only called on IPv4 frame types */ + /* See assertion: configASSERT( ( pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) || ( pxIPPacket->xEthernetHeader.usFrameType == ipARP_FRAME_TYPE ) ); + in xCheckRequiresARPResolution() */ + pxIPPacket = ( ( const IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); + pxIPHeader = &( pxIPPacket->xIPHeader ); + __CPROVER_assume(pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE); + pxNetworkBuffer->pxEndPoint = ( NetworkEndPoint_t * ) safeMalloc( sizeof( NetworkEndPoint_t ) ); __CPROVER_assume( pxNetworkBuffer->pxEndPoint != NULL ); From c260cfc6b16afe116e57646f1a0f82bc83212590 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Fri, 8 Nov 2024 15:07:03 +0530 Subject: [PATCH 24/25] Fix CBMC proof for xCheckRequiresARPResolution and formatting --- .../xCheckRequiresARPResolution_harness.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/cbmc/proofs/ARP/xCheckRequiresARPResolution/xCheckRequiresARPResolution_harness.c b/test/cbmc/proofs/ARP/xCheckRequiresARPResolution/xCheckRequiresARPResolution_harness.c index f090644f8..fb92dfd72 100644 --- a/test/cbmc/proofs/ARP/xCheckRequiresARPResolution/xCheckRequiresARPResolution_harness.c +++ b/test/cbmc/proofs/ARP/xCheckRequiresARPResolution/xCheckRequiresARPResolution_harness.c @@ -89,12 +89,10 @@ void harness() size_t xBufferLength; NetworkBufferDescriptor_t * pxNetworkBuffer; IPPacket_t * pxIPPacket; - - const IPPacket_t * pxIPPacket; - const IPHeader_t * pxIPHeader; + IPHeader_t * pxIPHeader; /* Make sure buffer size is enough, xCheckRequiresARPResolution is only called for - IPv4 packets hence the minimum size should be sizeof( IPPacket_t ) */ + * IPv4 packets hence the minimum size should be sizeof( IPPacket_t ) */ __CPROVER_assume( ( xBufferLength >= sizeof( IPPacket_t ) ) && ( xBufferLength < ipconfigNETWORK_MTU ) ); pxNetworkBuffer = ( NetworkBufferDescriptor_t * ) safeMalloc( sizeof( NetworkBufferDescriptor_t ) ); @@ -106,11 +104,12 @@ void harness() __CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer != NULL ); /* Its asserted in the code that xCheckRequiresARPResolution is only called on IPv4 frame types */ + /* See assertion: configASSERT( ( pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) || ( pxIPPacket->xEthernetHeader.usFrameType == ipARP_FRAME_TYPE ) ); - in xCheckRequiresARPResolution() */ + * in xCheckRequiresARPResolution() */ pxIPPacket = ( ( const IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); pxIPHeader = &( pxIPPacket->xIPHeader ); - __CPROVER_assume(pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE); + __CPROVER_assume( pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ); pxNetworkBuffer->pxEndPoint = ( NetworkEndPoint_t * ) safeMalloc( sizeof( NetworkEndPoint_t ) ); __CPROVER_assume( pxNetworkBuffer->pxEndPoint != NULL ); From 504dfa6291969bd6859aa81f3ab745a18fa6c9dd Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Mon, 11 Nov 2024 10:31:23 +0530 Subject: [PATCH 25/25] Fix build issue with tools/tcp_utilities/http_client_test.c --- tools/tcp_utilities/http_client_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tcp_utilities/http_client_test.c b/tools/tcp_utilities/http_client_test.c index 1cfb00662..cd43fe43a 100644 --- a/tools/tcp_utilities/http_client_test.c +++ b/tools/tcp_utilities/http_client_test.c @@ -381,7 +381,7 @@ else #endif /* if ( ipconfigUSE_IPv6 != 0 ) */ { - pxEndPoint = FreeRTOS_FindEndPointOnNetMask( pxAddress->sin_address.ulIP_IPv4, 9999 ); + pxEndPoint = FreeRTOS_FindEndPointOnNetMask( pxAddress->sin_address.ulIP_IPv4 ); if( pxEndPoint != NULL ) {