diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index 1e1fa615e..1a3dc6a47 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -962,7 +962,7 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ) { - eARPLookupResult_t eReturn; + eARPLookupResult_t eReturn = eCantSendPacket; uint32_t ulAddressToLookup; NetworkEndPoint_t * pxEndPoint = NULL; @@ -974,12 +974,21 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, ulAddressToLookup = *pulIPAddress; pxEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( ulAddressToLookup ); - if( xIsIPv4Multicast( ulAddressToLookup ) != 0 ) + if( xIsIPv4Loopback( ulAddressToLookup ) != 0 ) + { + if( pxEndPoint != NULL ) + { + /* For multi-cast, use the first IPv4 end-point. */ + memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) ); + *( ppxEndPoint ) = pxEndPoint; + eReturn = eARPCacheHit; + } + } + else if( xIsIPv4Multicast( ulAddressToLookup ) != 0 ) { /* Get the lowest 23 bits of the IP-address. */ vSetMultiCastIPv4MacAddress( ulAddressToLookup, pxMACAddress ); - eReturn = eCantSendPacket; pxEndPoint = FreeRTOS_FirstEndPoint( NULL ); for( ; diff --git a/source/FreeRTOS_DNS_Callback.c b/source/FreeRTOS_DNS_Callback.c index 15bddbfe5..5dd1658ac 100644 --- a/source/FreeRTOS_DNS_Callback.c +++ b/source/FreeRTOS_DNS_Callback.c @@ -76,8 +76,8 @@ BaseType_t xMatching; DNSCallback_t * pxCallback = ( ( DNSCallback_t * ) listGET_LIST_ITEM_OWNER( pxIterator ) ); #if ( ipconfigUSE_MDNS == 1 ) - /* mDNS port 5353. */ - if( pxSet->usPortNumber == FreeRTOS_htons( ipMDNS_PORT ) ) + /* mDNS port 5353. Host byte order comparison. */ + if( pxSet->usPortNumber == ipMDNS_PORT ) { /* In mDNS, the query ID field is ignored and the * hostname will be compared with outstanding requests. */ diff --git a/source/portable/NetworkInterface/loopback/loopbackNetworkInterface.c b/source/portable/NetworkInterface/loopback/loopbackNetworkInterface.c index cf66a62ff..9152d4744 100644 --- a/source/portable/NetworkInterface/loopback/loopbackNetworkInterface.c +++ b/source/portable/NetworkInterface/loopback/loopbackNetworkInterface.c @@ -134,23 +134,23 @@ static BaseType_t prvLoopback_Output( NetworkInterface_t * pxInterface, } { - MACAddress_t xMACAddress; + const MACAddress_t * pxMACAddress = &( pxDescriptor->pxEndPoint->xMACAddress ); if( pxDescriptor->pxEndPoint->bits.bIPv6 != 0 ) { #if ( ipconfigUSE_IPv6 != 0 ) - if( xIsIPv6Loopback( &( pxDescriptor->xIPAddress ) ) != pdFALSE ) + if( xIsIPv6Loopback( &( pxDescriptor->xIPAddress.xIP_IPv6 ) ) != pdFALSE ) { - vNDRefreshCacheEntry( &xMACAddress, &( pxDescriptor->xIPAddress.xIP_IPv6 ), pxDescriptor->pxEndPoint ); + vNDRefreshCacheEntry( pxMACAddress, &( pxDescriptor->xIPAddress.xIP_IPv6 ), pxDescriptor->pxEndPoint ); } #endif } else { #if ( ipconfigUSE_IPv4 != 0 ) - if( xIsIPv4Loopback( pxDescriptor->xIPAddress.ulIP_IPv4 ) ) + if( xIsIPv4Loopback( pxDescriptor->xIPAddress.ulIP_IPv4 ) != pdFALSE ) { - vARPRefreshCacheEntry( &xMACAddress, pxDescriptor->xIPAddress.ulIP_IPv4, pxDescriptor->pxEndPoint ); + vARPRefreshCacheEntry( pxMACAddress, pxDescriptor->xIPAddress.ulIP_IPv4, pxDescriptor->pxEndPoint ); } #endif } @@ -170,11 +170,21 @@ static BaseType_t prvLoopback_Output( NetworkInterface_t * pxInterface, xRxEvent.eEventType = eNetworkRxEvent; xRxEvent.pvData = ( void * ) pxDescriptor; - if( xSendEventStructToIPTask( &xRxEvent, 0u ) != pdTRUE ) + pxDescriptor->pxInterface = xLoopbackInterface; + pxDescriptor->pxEndPoint = FreeRTOS_MatchingEndpoint( xLoopbackInterface, pxDescriptor->pucEthernetBuffer ); + + if( pxDescriptor->pxEndPoint == NULL ) + { + vReleaseNetworkBufferAndDescriptor( pxDescriptor ); + iptraceETHERNET_RX_EVENT_LOST(); + FreeRTOS_printf( ( "prvLoopback_Output: Can not find a proper endpoint\n" ) ); + } + else if( xSendEventStructToIPTask( &xRxEvent, 0u ) != pdTRUE ) { + /* Sending failed, release the descriptor. */ vReleaseNetworkBufferAndDescriptor( pxDescriptor ); iptraceETHERNET_RX_EVENT_LOST(); - FreeRTOS_printf( ( "prvEMACRxPoll: Can not queue return packet!\n" ) ); + FreeRTOS_printf( ( "prvLoopback_Output: Can not queue return packet!\n" ) ); } } diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c index 057d39619..106520eb7 100644 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c @@ -558,6 +558,7 @@ void test_eARPProcessPacket_Request_GratuitousARP( void ) vResetARPClashCounter(); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint ); + xIsIPv4Loopback_ExpectAndReturn( ulTargetIP, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulTargetIP, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); @@ -621,6 +622,7 @@ void test_eARPProcessPacket_Request_GratuitousARP_MACUnchanged( void ) vResetARPClashCounter(); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint ); + xIsIPv4Loopback_ExpectAndReturn( ulTargetIP, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulTargetIP, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); @@ -863,6 +865,7 @@ void test_eARPProcessPacket_Request_GratuitousARP_NonMatchingEndpoint( void ) vResetARPClashCounter(); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint ); + xIsIPv4Loopback_ExpectAndReturn( ulTargetIP, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulTargetIP, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); @@ -926,6 +929,7 @@ void test_eARPProcessPacket_Request_GratuitousARP_NonMatchingIP( void ) vResetARPClashCounter(); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint ); + xIsIPv4Loopback_ExpectAndReturn( ulTargetIP, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulTargetIP, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); @@ -2090,6 +2094,7 @@ void test_eARPGetCacheEntry_IPMatchesBroadcastAddr( void ) ulIPAddress = FreeRTOS_ntohl( xNetworkAddressing.ulBroadcastAddress ); /* Not worried about what these functions do. */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); @@ -2112,6 +2117,7 @@ void test_eARPGetCacheEntry_IPMatchesBroadcastAddr_NullEndPointOnNetMask( void ) ulIPAddress = FreeRTOS_ntohl( xNetworkAddressing.ulBroadcastAddress ); /* Not worried about what these functions do. */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); @@ -2132,6 +2138,7 @@ void test_eARPGetCacheEntry_MultiCastAddr( void ) /* =================================================== */ ulIPAddress = FreeRTOS_ntohl( xNetworkAddressing.ulBroadcastAddress ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 1UL ); vSetMultiCastIPv4MacAddress_Ignore(); FreeRTOS_FirstEndPoint_ExpectAndReturn( NULL, NULL ); @@ -2144,6 +2151,7 @@ void test_eARPGetCacheEntry_MultiCastAddr( void ) xEndPoint.bits.bIPv6 = 1; FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 1UL ); vSetMultiCastIPv4MacAddress_Ignore(); FreeRTOS_FirstEndPoint_ExpectAndReturn( NULL, &xEndPoint ); @@ -2169,6 +2177,7 @@ void test_eARPGetCacheEntry_IPMatchesOtherBroadcastAddr( void ) ulIPAddress = FreeRTOS_ntohl( ipBROADCAST_IP_ADDRESS ); /* Not worried about what these functions do. */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); @@ -2198,6 +2207,7 @@ void test_eARPGetCacheEntry_MatchingInvalidEntry( void ) /* Not worried about what these functions do. */ xEndPoint.ipv4_settings.ulGatewayAddress = xNetworkAddressing.ulGatewayAddress; FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( &xEndPoint ); @@ -2227,6 +2237,7 @@ void test_eARPGetCacheEntry_MatchingValidEntry( void ) /* Not worried about what these functions do. */ xEndPoint.ipv4_settings.ulGatewayAddress = xNetworkAddressing.ulGatewayAddress; FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( &xEndPoint ); @@ -2259,6 +2270,7 @@ void test_eARPGetCacheEntry_GatewayAddressZero( void ) /* Not worried about what these functions do. */ xEndPoint.ipv4_settings.ulGatewayAddress = 0; FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( NULL ); @@ -2286,6 +2298,7 @@ void test_eARPGetCacheEntry_AddressNotOnLocalAddress( void ) /* Not worried about what these functions do. */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( NULL ); @@ -2324,6 +2337,7 @@ void test_eARPGetCacheEntry_NoCacheHit( void ) pxNetworkEndPoints = &xEndPoint; /* Not worried about what these functions do. */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); @@ -2333,6 +2347,91 @@ void test_eARPGetCacheEntry_NoCacheHit( void ) /* =================================================== */ } +/** + * @brief Test the scenario that the address given is a loopback address + * but there is no loopback endpoint + */ +void test_eARPGetCacheEntry_LoopbackAddress( void ) +{ + uint32_t ulIPAddress; + MACAddress_t xMACAddress = { 0 }; + MACAddress_t xMACAddressExp = { 0 }; + eARPLookupResult_t eResult; + uint32_t ulSavedGatewayAddress; + struct xNetworkInterface * xInterface; + struct xNetworkEndPoint * pxEndPoint, xEndPoint; + int i; + + /* =================================================== */ + for( i = 0; i < ipconfigARP_CACHE_ENTRIES; i++ ) + { + xARPCache[ i ].ulIPAddress = 0; + xARPCache[ i ].ucValid = ( uint8_t ) pdTRUE; + xARPCache[ i ].pxEndPoint = NULL; + } + + ulSavedGatewayAddress = xNetworkAddressing.ulGatewayAddress; + xNetworkAddressing.ulGatewayAddress = 0; + /* Make IP address param == 0 */ + ulIPAddress = 0x7F000000UL; + + /* Make both values (IP address and local IP pointer) different + * and on different net masks. */ + xEndPoint.ipv4_settings.ulIPAddress = 0x1234; + pxNetworkEndPoints = &xEndPoint; + /* Not worried about what these functions do. */ + FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 1UL ); + eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); + TEST_ASSERT_EQUAL( eCantSendPacket, eResult ); + TEST_ASSERT_NOT_EQUAL( pxEndPoint, &xEndPoint ); + TEST_ASSERT_EQUAL_MEMORY( xMACAddressExp.ucBytes, xMACAddress.ucBytes, sizeof( MACAddress_t ) ); + /* =================================================== */ +} + +/** + * @brief Test the scenario that the address given is a loopback address + * and there is a loopback endpoint + */ +void test_eARPGetCacheEntry_LoopbackAddress_ValidLPEndpoint( void ) +{ + uint32_t ulIPAddress; + MACAddress_t xMACAddress = { 0 }; + MACAddress_t xMACAddressExp = { 0x11, 0x22, 0x33, 0x11, 0x22, 0x33 }; + eARPLookupResult_t eResult; + uint32_t ulSavedGatewayAddress; + struct xNetworkInterface * xInterface; + struct xNetworkEndPoint * pxEndPoint, xEndPoint; + int i; + + /* =================================================== */ + for( i = 0; i < ipconfigARP_CACHE_ENTRIES; i++ ) + { + xARPCache[ i ].ulIPAddress = 0; + xARPCache[ i ].ucValid = ( uint8_t ) pdTRUE; + xARPCache[ i ].pxEndPoint = NULL; + } + + ulSavedGatewayAddress = xNetworkAddressing.ulGatewayAddress; + xNetworkAddressing.ulGatewayAddress = 0; + /* Make IP address param == 0 */ + ulIPAddress = 0x7F000000UL; + + /* Make both values (IP address and local IP pointer) different + * and on different net masks. */ + xEndPoint.ipv4_settings.ulIPAddress = 0x1234; + memcpy( xEndPoint.xMACAddress.ucBytes, xMACAddressExp.ucBytes, sizeof( MACAddress_t ) ); + pxNetworkEndPoints = &xEndPoint; + /* Not worried about what these functions do. */ + FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 1UL ); + eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); + TEST_ASSERT_EQUAL( eARPCacheHit, eResult ); + TEST_ASSERT_EQUAL( pxEndPoint, &xEndPoint ); + TEST_ASSERT_EQUAL_MEMORY( xMACAddressExp.ucBytes, xMACAddress.ucBytes, sizeof( MACAddress_t ) ); + /* =================================================== */ +} + void test_vARPAgeCache( void ) { NetworkEndPoint_t xEndPoint = { 0 }; @@ -2641,6 +2740,7 @@ void test_xARPWaitResolution_PrivateFunctionReturnsHit( void ) xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE ); /* Not worried about what these functions do. */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 1UL ); vSetMultiCastIPv4MacAddress_Ignore(); FreeRTOS_FirstEndPoint_ExpectAndReturn( NULL, &xEndPoint ); @@ -2679,6 +2779,7 @@ void test_xARPWaitResolution_GNWFailsNoTimeout( void ) FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE ); /* Not worried about what these functions do. */ + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 ); @@ -2691,6 +2792,7 @@ void test_xARPWaitResolution_GNWFailsNoTimeout( void ) pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL ); vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 ); xTaskCheckForTimeOut_IgnoreAndReturn( pdFALSE ); @@ -2730,6 +2832,7 @@ void test_xARPWaitResolution( void ) FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE ); /* Not worried about what these functions do. */ + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 ); @@ -2742,6 +2845,7 @@ void test_xARPWaitResolution( void ) pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL ); vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 ); xTaskCheckForTimeOut_IgnoreAndReturn( pdFALSE ); @@ -2751,6 +2855,7 @@ void test_xARPWaitResolution( void ) pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL ); vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 ); xTaskCheckForTimeOut_IgnoreAndReturn( pdTRUE ); @@ -2778,6 +2883,7 @@ void test_xARPWaitResolution( void ) FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE ); /* Not worried about what these functions do. */ + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 ); @@ -2790,6 +2896,7 @@ void test_xARPWaitResolution( void ) pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL ); vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 ); xTaskCheckForTimeOut_IgnoreAndReturn( pdFALSE ); @@ -2799,6 +2906,7 @@ void test_xARPWaitResolution( void ) pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL ); vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 1UL ); vSetMultiCastIPv4MacAddress_Ignore(); FreeRTOS_FirstEndPoint_ExpectAndReturn( NULL, &xEndPoint ); diff --git a/test/unit-test/FreeRTOS_DNS_Callback/FreeRTOS_DNS_Callback_utest.c b/test/unit-test/FreeRTOS_DNS_Callback/FreeRTOS_DNS_Callback_utest.c index d35100387..1f3eae7f0 100644 --- a/test/unit-test/FreeRTOS_DNS_Callback/FreeRTOS_DNS_Callback_utest.c +++ b/test/unit-test/FreeRTOS_DNS_Callback/FreeRTOS_DNS_Callback_utest.c @@ -216,7 +216,7 @@ void test_xDNSDoCallback_success_equal_port_number_equal_name( void ) DNSCallback_t * pxDnsCallback = ( DNSCallback_t * ) &dnsCallbackMemory; pxSet.pxDNSMessageHeader = &xDNSMessageHeader; - pxSet.usPortNumber = FreeRTOS_htons( ipMDNS_PORT ); + pxSet.usPortNumber = ipMDNS_PORT; strcpy( pxSet.pcName, pc_name ); pxDnsCallback->pCallbackFunction = dns_callback; strcpy( pxDnsCallback->pcName, pc_name ); @@ -255,7 +255,7 @@ void test_xDNSDoCallback_fail_equal_port_number_not_equal_name( void ) pxSet.pxDNSMessageHeader = &xDNSMessageHeader; pxSet.pxDNSMessageHeader->usIdentifier = 123; - pxSet.usPortNumber = FreeRTOS_htons( ipMDNS_PORT ); + pxSet.usPortNumber = ipMDNS_PORT; char pc_name[] = "test"; strcpy( pxSet.pcName, pc_name ); dnsCallback->pCallbackFunction = dns_callback;