diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index 6ca491203..af349932b 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -908,7 +908,6 @@ /* Get the lowest 23 bits of the IP-address. */ vSetMultiCastIPv4MacAddress( ulAddressToLookup, pxMACAddress ); - eReturn = eResolutionFailed; pxEndPoint = FreeRTOS_FirstEndPoint( NULL ); for( ; @@ -1329,8 +1328,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/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 );