Skip to content

Commit a45bfe2

Browse files
Fix ARP failure with loopback addresses (#1185)
* Apply patch from @htibosch * Fix existing ARP tests * Make ARP coverage 100% * Fix DNS Callback utests * Minor code standardisation * Minor cleanup * Fix formatting and spell check
1 parent 3c9140d commit a45bfe2

File tree

5 files changed

+141
-14
lines changed

5 files changed

+141
-14
lines changed

source/FreeRTOS_ARP.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress,
962962
MACAddress_t * const pxMACAddress,
963963
struct xNetworkEndPoint ** ppxEndPoint )
964964
{
965-
eARPLookupResult_t eReturn;
965+
eARPLookupResult_t eReturn = eCantSendPacket;
966966
uint32_t ulAddressToLookup;
967967
NetworkEndPoint_t * pxEndPoint = NULL;
968968

@@ -974,12 +974,21 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress,
974974
ulAddressToLookup = *pulIPAddress;
975975
pxEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( ulAddressToLookup );
976976

977-
if( xIsIPv4Multicast( ulAddressToLookup ) != 0 )
977+
if( xIsIPv4Loopback( ulAddressToLookup ) != 0 )
978+
{
979+
if( pxEndPoint != NULL )
980+
{
981+
/* For multi-cast, use the first IPv4 end-point. */
982+
memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) );
983+
*( ppxEndPoint ) = pxEndPoint;
984+
eReturn = eARPCacheHit;
985+
}
986+
}
987+
else if( xIsIPv4Multicast( ulAddressToLookup ) != 0 )
978988
{
979989
/* Get the lowest 23 bits of the IP-address. */
980990
vSetMultiCastIPv4MacAddress( ulAddressToLookup, pxMACAddress );
981991

982-
eReturn = eCantSendPacket;
983992
pxEndPoint = FreeRTOS_FirstEndPoint( NULL );
984993

985994
for( ;

source/FreeRTOS_DNS_Callback.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
BaseType_t xMatching;
7777
DNSCallback_t * pxCallback = ( ( DNSCallback_t * ) listGET_LIST_ITEM_OWNER( pxIterator ) );
7878
#if ( ipconfigUSE_MDNS == 1 )
79-
/* mDNS port 5353. */
80-
if( pxSet->usPortNumber == FreeRTOS_htons( ipMDNS_PORT ) )
79+
/* mDNS port 5353. Host byte order comparison. */
80+
if( pxSet->usPortNumber == ipMDNS_PORT )
8181
{
8282
/* In mDNS, the query ID field is ignored and the
8383
* hostname will be compared with outstanding requests. */

source/portable/NetworkInterface/loopback/loopbackNetworkInterface.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,23 @@ static BaseType_t prvLoopback_Output( NetworkInterface_t * pxInterface,
134134
}
135135

136136
{
137-
MACAddress_t xMACAddress;
137+
const MACAddress_t * pxMACAddress = &( pxDescriptor->pxEndPoint->xMACAddress );
138138

139139
if( pxDescriptor->pxEndPoint->bits.bIPv6 != 0 )
140140
{
141141
#if ( ipconfigUSE_IPv6 != 0 )
142-
if( xIsIPv6Loopback( &( pxDescriptor->xIPAddress ) ) != pdFALSE )
142+
if( xIsIPv6Loopback( &( pxDescriptor->xIPAddress.xIP_IPv6 ) ) != pdFALSE )
143143
{
144-
vNDRefreshCacheEntry( &xMACAddress, &( pxDescriptor->xIPAddress.xIP_IPv6 ), pxDescriptor->pxEndPoint );
144+
vNDRefreshCacheEntry( pxMACAddress, &( pxDescriptor->xIPAddress.xIP_IPv6 ), pxDescriptor->pxEndPoint );
145145
}
146146
#endif
147147
}
148148
else
149149
{
150150
#if ( ipconfigUSE_IPv4 != 0 )
151-
if( xIsIPv4Loopback( pxDescriptor->xIPAddress.ulIP_IPv4 ) )
151+
if( xIsIPv4Loopback( pxDescriptor->xIPAddress.ulIP_IPv4 ) != pdFALSE )
152152
{
153-
vARPRefreshCacheEntry( &xMACAddress, pxDescriptor->xIPAddress.ulIP_IPv4, pxDescriptor->pxEndPoint );
153+
vARPRefreshCacheEntry( pxMACAddress, pxDescriptor->xIPAddress.ulIP_IPv4, pxDescriptor->pxEndPoint );
154154
}
155155
#endif
156156
}
@@ -170,11 +170,21 @@ static BaseType_t prvLoopback_Output( NetworkInterface_t * pxInterface,
170170
xRxEvent.eEventType = eNetworkRxEvent;
171171
xRxEvent.pvData = ( void * ) pxDescriptor;
172172

173-
if( xSendEventStructToIPTask( &xRxEvent, 0u ) != pdTRUE )
173+
pxDescriptor->pxInterface = xLoopbackInterface;
174+
pxDescriptor->pxEndPoint = FreeRTOS_MatchingEndpoint( xLoopbackInterface, pxDescriptor->pucEthernetBuffer );
175+
176+
if( pxDescriptor->pxEndPoint == NULL )
177+
{
178+
vReleaseNetworkBufferAndDescriptor( pxDescriptor );
179+
iptraceETHERNET_RX_EVENT_LOST();
180+
FreeRTOS_printf( ( "prvLoopback_Output: Can not find a proper endpoint\n" ) );
181+
}
182+
else if( xSendEventStructToIPTask( &xRxEvent, 0u ) != pdTRUE )
174183
{
184+
/* Sending failed, release the descriptor. */
175185
vReleaseNetworkBufferAndDescriptor( pxDescriptor );
176186
iptraceETHERNET_RX_EVENT_LOST();
177-
FreeRTOS_printf( ( "prvEMACRxPoll: Can not queue return packet!\n" ) );
187+
FreeRTOS_printf( ( "prvLoopback_Output: Can not queue return packet!\n" ) );
178188
}
179189
}
180190

test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ void test_eARPProcessPacket_Request_GratuitousARP( void )
558558
vResetARPClashCounter();
559559

560560
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint );
561+
xIsIPv4Loopback_ExpectAndReturn( ulTargetIP, 0UL );
561562
xIsIPv4Multicast_ExpectAndReturn( ulTargetIP, 0UL );
562563
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint );
563564
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint );
@@ -621,6 +622,7 @@ void test_eARPProcessPacket_Request_GratuitousARP_MACUnchanged( void )
621622
vResetARPClashCounter();
622623

623624
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint );
625+
xIsIPv4Loopback_ExpectAndReturn( ulTargetIP, 0UL );
624626
xIsIPv4Multicast_ExpectAndReturn( ulTargetIP, 0UL );
625627
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint );
626628
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint );
@@ -863,6 +865,7 @@ void test_eARPProcessPacket_Request_GratuitousARP_NonMatchingEndpoint( void )
863865
vResetARPClashCounter();
864866

865867
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint );
868+
xIsIPv4Loopback_ExpectAndReturn( ulTargetIP, 0UL );
866869
xIsIPv4Multicast_ExpectAndReturn( ulTargetIP, 0UL );
867870
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint );
868871

@@ -926,6 +929,7 @@ void test_eARPProcessPacket_Request_GratuitousARP_NonMatchingIP( void )
926929
vResetARPClashCounter();
927930

928931
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint );
932+
xIsIPv4Loopback_ExpectAndReturn( ulTargetIP, 0UL );
929933
xIsIPv4Multicast_ExpectAndReturn( ulTargetIP, 0UL );
930934
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint );
931935

@@ -2090,6 +2094,7 @@ void test_eARPGetCacheEntry_IPMatchesBroadcastAddr( void )
20902094
ulIPAddress = FreeRTOS_ntohl( xNetworkAddressing.ulBroadcastAddress );
20912095
/* Not worried about what these functions do. */
20922096
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2097+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
20932098
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
20942099
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint );
20952100
eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint );
@@ -2112,6 +2117,7 @@ void test_eARPGetCacheEntry_IPMatchesBroadcastAddr_NullEndPointOnNetMask( void )
21122117
ulIPAddress = FreeRTOS_ntohl( xNetworkAddressing.ulBroadcastAddress );
21132118
/* Not worried about what these functions do. */
21142119
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2120+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
21152121
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
21162122
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL );
21172123
eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint );
@@ -2132,6 +2138,7 @@ void test_eARPGetCacheEntry_MultiCastAddr( void )
21322138
/* =================================================== */
21332139
ulIPAddress = FreeRTOS_ntohl( xNetworkAddressing.ulBroadcastAddress );
21342140
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2141+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
21352142
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 1UL );
21362143
vSetMultiCastIPv4MacAddress_Ignore();
21372144
FreeRTOS_FirstEndPoint_ExpectAndReturn( NULL, NULL );
@@ -2144,6 +2151,7 @@ void test_eARPGetCacheEntry_MultiCastAddr( void )
21442151

21452152
xEndPoint.bits.bIPv6 = 1;
21462153
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2154+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
21472155
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 1UL );
21482156
vSetMultiCastIPv4MacAddress_Ignore();
21492157
FreeRTOS_FirstEndPoint_ExpectAndReturn( NULL, &xEndPoint );
@@ -2169,6 +2177,7 @@ void test_eARPGetCacheEntry_IPMatchesOtherBroadcastAddr( void )
21692177
ulIPAddress = FreeRTOS_ntohl( ipBROADCAST_IP_ADDRESS );
21702178
/* Not worried about what these functions do. */
21712179
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2180+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
21722181
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
21732182
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint );
21742183
eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint );
@@ -2198,6 +2207,7 @@ void test_eARPGetCacheEntry_MatchingInvalidEntry( void )
21982207
/* Not worried about what these functions do. */
21992208
xEndPoint.ipv4_settings.ulGatewayAddress = xNetworkAddressing.ulGatewayAddress;
22002209
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2210+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
22012211
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
22022212
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL );
22032213
FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( &xEndPoint );
@@ -2227,6 +2237,7 @@ void test_eARPGetCacheEntry_MatchingValidEntry( void )
22272237
/* Not worried about what these functions do. */
22282238
xEndPoint.ipv4_settings.ulGatewayAddress = xNetworkAddressing.ulGatewayAddress;
22292239
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2240+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
22302241
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
22312242
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL );
22322243
FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( &xEndPoint );
@@ -2259,6 +2270,7 @@ void test_eARPGetCacheEntry_GatewayAddressZero( void )
22592270
/* Not worried about what these functions do. */
22602271
xEndPoint.ipv4_settings.ulGatewayAddress = 0;
22612272
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2273+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
22622274
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
22632275
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL );
22642276
FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( NULL );
@@ -2286,6 +2298,7 @@ void test_eARPGetCacheEntry_AddressNotOnLocalAddress( void )
22862298

22872299
/* Not worried about what these functions do. */
22882300
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2301+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
22892302
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
22902303
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL );
22912304
FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( NULL );
@@ -2324,6 +2337,7 @@ void test_eARPGetCacheEntry_NoCacheHit( void )
23242337
pxNetworkEndPoints = &xEndPoint;
23252338
/* Not worried about what these functions do. */
23262339
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2340+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
23272341
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
23282342
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL );
23292343
eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint );
@@ -2333,6 +2347,91 @@ void test_eARPGetCacheEntry_NoCacheHit( void )
23332347
/* =================================================== */
23342348
}
23352349

2350+
/**
2351+
* @brief Test the scenario that the address given is a loopback address
2352+
* but there is no loopback endpoint
2353+
*/
2354+
void test_eARPGetCacheEntry_LoopbackAddress( void )
2355+
{
2356+
uint32_t ulIPAddress;
2357+
MACAddress_t xMACAddress = { 0 };
2358+
MACAddress_t xMACAddressExp = { 0 };
2359+
eARPLookupResult_t eResult;
2360+
uint32_t ulSavedGatewayAddress;
2361+
struct xNetworkInterface * xInterface;
2362+
struct xNetworkEndPoint * pxEndPoint, xEndPoint;
2363+
int i;
2364+
2365+
/* =================================================== */
2366+
for( i = 0; i < ipconfigARP_CACHE_ENTRIES; i++ )
2367+
{
2368+
xARPCache[ i ].ulIPAddress = 0;
2369+
xARPCache[ i ].ucValid = ( uint8_t ) pdTRUE;
2370+
xARPCache[ i ].pxEndPoint = NULL;
2371+
}
2372+
2373+
ulSavedGatewayAddress = xNetworkAddressing.ulGatewayAddress;
2374+
xNetworkAddressing.ulGatewayAddress = 0;
2375+
/* Make IP address param == 0 */
2376+
ulIPAddress = 0x7F000000UL;
2377+
2378+
/* Make both values (IP address and local IP pointer) different
2379+
* and on different net masks. */
2380+
xEndPoint.ipv4_settings.ulIPAddress = 0x1234;
2381+
pxNetworkEndPoints = &xEndPoint;
2382+
/* Not worried about what these functions do. */
2383+
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2384+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 1UL );
2385+
eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint );
2386+
TEST_ASSERT_EQUAL( eCantSendPacket, eResult );
2387+
TEST_ASSERT_NOT_EQUAL( pxEndPoint, &xEndPoint );
2388+
TEST_ASSERT_EQUAL_MEMORY( xMACAddressExp.ucBytes, xMACAddress.ucBytes, sizeof( MACAddress_t ) );
2389+
/* =================================================== */
2390+
}
2391+
2392+
/**
2393+
* @brief Test the scenario that the address given is a loopback address
2394+
* and there is a loopback endpoint
2395+
*/
2396+
void test_eARPGetCacheEntry_LoopbackAddress_ValidLPEndpoint( void )
2397+
{
2398+
uint32_t ulIPAddress;
2399+
MACAddress_t xMACAddress = { 0 };
2400+
MACAddress_t xMACAddressExp = { 0x11, 0x22, 0x33, 0x11, 0x22, 0x33 };
2401+
eARPLookupResult_t eResult;
2402+
uint32_t ulSavedGatewayAddress;
2403+
struct xNetworkInterface * xInterface;
2404+
struct xNetworkEndPoint * pxEndPoint, xEndPoint;
2405+
int i;
2406+
2407+
/* =================================================== */
2408+
for( i = 0; i < ipconfigARP_CACHE_ENTRIES; i++ )
2409+
{
2410+
xARPCache[ i ].ulIPAddress = 0;
2411+
xARPCache[ i ].ucValid = ( uint8_t ) pdTRUE;
2412+
xARPCache[ i ].pxEndPoint = NULL;
2413+
}
2414+
2415+
ulSavedGatewayAddress = xNetworkAddressing.ulGatewayAddress;
2416+
xNetworkAddressing.ulGatewayAddress = 0;
2417+
/* Make IP address param == 0 */
2418+
ulIPAddress = 0x7F000000UL;
2419+
2420+
/* Make both values (IP address and local IP pointer) different
2421+
* and on different net masks. */
2422+
xEndPoint.ipv4_settings.ulIPAddress = 0x1234;
2423+
memcpy( xEndPoint.xMACAddress.ucBytes, xMACAddressExp.ucBytes, sizeof( MACAddress_t ) );
2424+
pxNetworkEndPoints = &xEndPoint;
2425+
/* Not worried about what these functions do. */
2426+
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint );
2427+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 1UL );
2428+
eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint );
2429+
TEST_ASSERT_EQUAL( eARPCacheHit, eResult );
2430+
TEST_ASSERT_EQUAL( pxEndPoint, &xEndPoint );
2431+
TEST_ASSERT_EQUAL_MEMORY( xMACAddressExp.ucBytes, xMACAddress.ucBytes, sizeof( MACAddress_t ) );
2432+
/* =================================================== */
2433+
}
2434+
23362435
void test_vARPAgeCache( void )
23372436
{
23382437
NetworkEndPoint_t xEndPoint = { 0 };
@@ -2641,6 +2740,7 @@ void test_xARPWaitResolution_PrivateFunctionReturnsHit( void )
26412740
xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE );
26422741
/* Not worried about what these functions do. */
26432742
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2743+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
26442744
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 1UL );
26452745
vSetMultiCastIPv4MacAddress_Ignore();
26462746
FreeRTOS_FirstEndPoint_ExpectAndReturn( NULL, &xEndPoint );
@@ -2679,6 +2779,7 @@ void test_xARPWaitResolution_GNWFailsNoTimeout( void )
26792779
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
26802780
xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE );
26812781
/* Not worried about what these functions do. */
2782+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
26822783
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
26832784
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 );
26842785

@@ -2691,6 +2792,7 @@ void test_xARPWaitResolution_GNWFailsNoTimeout( void )
26912792
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
26922793
vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) );
26932794
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2795+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
26942796
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
26952797
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 );
26962798
xTaskCheckForTimeOut_IgnoreAndReturn( pdFALSE );
@@ -2730,6 +2832,7 @@ void test_xARPWaitResolution( void )
27302832
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
27312833
xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE );
27322834
/* Not worried about what these functions do. */
2835+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
27332836
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
27342837
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 );
27352838

@@ -2742,6 +2845,7 @@ void test_xARPWaitResolution( void )
27422845
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
27432846
vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) );
27442847
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2848+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
27452849
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
27462850
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 );
27472851
xTaskCheckForTimeOut_IgnoreAndReturn( pdFALSE );
@@ -2751,6 +2855,7 @@ void test_xARPWaitResolution( void )
27512855
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
27522856
vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) );
27532857
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2858+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
27542859
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
27552860
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 );
27562861
xTaskCheckForTimeOut_IgnoreAndReturn( pdTRUE );
@@ -2778,6 +2883,7 @@ void test_xARPWaitResolution( void )
27782883
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
27792884
xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE );
27802885
/* Not worried about what these functions do. */
2886+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
27812887
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
27822888
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 );
27832889

@@ -2790,6 +2896,7 @@ void test_xARPWaitResolution( void )
27902896
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
27912897
vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) );
27922898
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2899+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
27932900
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
27942901
FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 );
27952902
xTaskCheckForTimeOut_IgnoreAndReturn( pdFALSE );
@@ -2799,6 +2906,7 @@ void test_xARPWaitResolution( void )
27992906
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
28002907
vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) );
28012908
FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL );
2909+
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
28022910
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 1UL );
28032911
vSetMultiCastIPv4MacAddress_Ignore();
28042912
FreeRTOS_FirstEndPoint_ExpectAndReturn( NULL, &xEndPoint );

test/unit-test/FreeRTOS_DNS_Callback/FreeRTOS_DNS_Callback_utest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void test_xDNSDoCallback_success_equal_port_number_equal_name( void )
216216
DNSCallback_t * pxDnsCallback = ( DNSCallback_t * ) &dnsCallbackMemory;
217217

218218
pxSet.pxDNSMessageHeader = &xDNSMessageHeader;
219-
pxSet.usPortNumber = FreeRTOS_htons( ipMDNS_PORT );
219+
pxSet.usPortNumber = ipMDNS_PORT;
220220
strcpy( pxSet.pcName, pc_name );
221221
pxDnsCallback->pCallbackFunction = dns_callback;
222222
strcpy( pxDnsCallback->pcName, pc_name );
@@ -255,7 +255,7 @@ void test_xDNSDoCallback_fail_equal_port_number_not_equal_name( void )
255255

256256
pxSet.pxDNSMessageHeader = &xDNSMessageHeader;
257257
pxSet.pxDNSMessageHeader->usIdentifier = 123;
258-
pxSet.usPortNumber = FreeRTOS_htons( ipMDNS_PORT );
258+
pxSet.usPortNumber = ipMDNS_PORT;
259259
char pc_name[] = "test";
260260
strcpy( pxSet.pcName, pc_name );
261261
dnsCallback->pCallbackFunction = dns_callback;

0 commit comments

Comments
 (0)