Skip to content

Commit e659f7f

Browse files
committed
Minor fix
1 parent c8f8926 commit e659f7f

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

source/FreeRTOS_ND.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,15 @@
264264
/* See if the gateway has an entry in the cache. */
265265
eReturn = prvNDCacheLookup( pxIPAddress, pxMACAddress, ppxEndPoint );
266266

267-
if( *ppxEndPoint != NULL )
267+
if( ( ppxEndPoint != NULL ) && ( *ppxEndPoint != NULL ) )
268268
{
269269
FreeRTOS_printf( ( "eNDGetCacheEntry: found end-point %pip\n", ( void * ) ( *ppxEndPoint )->ipv6_settings.xIPAddress.ucBytes ) );
270270
}
271271

272-
*( ppxEndPoint ) = pxEndPoint;
272+
if( ppxEndPoint != NULL )
273+
{
274+
*( ppxEndPoint ) = pxEndPoint;
275+
}
273276
}
274277
}
275278
}

test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,34 @@ void test_eNDGetCacheEntry_Multicast_InvalidEndPoint( void )
216216
TEST_ASSERT_EQUAL( eResolutionCacheMiss, eResult );
217217
}
218218

219+
220+
/**
221+
* @brief This function find the MAC-address of a multicast IPv6 address
222+
* with a NULL endpoint, but no active IPv6 endpoints.
223+
*/
224+
void test_eNDGetCacheEntry_Multicast_InvalidEndPoint_NoEP( void )
225+
{
226+
NetworkEndPoint_t ** ppxEndPoint = NULL;
227+
eResolutionLookupResult_t eResult;
228+
MACAddress_t xMACAddress;
229+
IPv6_Address_t xIPAddress;
230+
NetworkEndPoint_t xEndPoint, * pxEndPoint = &xEndPoint, xEndPoint1;
231+
232+
( void ) memcpy( xIPAddress.ucBytes, xMultiCastIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
233+
234+
xIsIPv6AllowedMulticast_ExpectAnyArgsAndReturn( pdTRUE );
235+
vSetMultiCastIPv6MacAddress_ExpectAnyArgs();
236+
237+
xIPv6_GetIPType_ExpectAnyArgsAndReturn( eIPv6_Multicast );
238+
FreeRTOS_FindEndPointOnIP_IPv6_ExpectAnyArgsAndReturn( NULL );
239+
FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( &xEndPoint1 );
240+
241+
eResult = eNDGetCacheEntry( &xIPAddress, &xMACAddress, ppxEndPoint );
242+
243+
TEST_ASSERT_EQUAL( eResolutionCacheMiss, eResult );
244+
}
245+
246+
219247
/**
220248
* @brief This function find the MAC-address of an IPv6 address which is
221249
* not multi cast address, but the entry is present on the ND Cache,

0 commit comments

Comments
 (0)