Skip to content

Commit

Permalink
Fix ARP failure with loopback addresses (#1185)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tony-josi-aws committed Sep 12, 2024
1 parent 3c9140d commit a45bfe2
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 14 deletions.
15 changes: 12 additions & 3 deletions source/FreeRTOS_ARP.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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( ;
Expand Down
4 changes: 2 additions & 2 deletions source/FreeRTOS_DNS_Callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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" ) );
}
}

Expand Down
108 changes: 108 additions & 0 deletions test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand All @@ -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 };
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );

Expand All @@ -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 );
Expand Down Expand Up @@ -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 );

Expand All @@ -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 );
Expand All @@ -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 );
Expand Down Expand Up @@ -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 );

Expand All @@ -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 );
Expand All @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a45bfe2

Please sign in to comment.