Skip to content

Commit 466d61d

Browse files
committed
Minor fix
1 parent 2e69a81 commit 466d61d

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

source/FreeRTOS_ND.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@
188188
* @return An enum which says whether the address was found: eARPCacheHit or eARPCacheMiss.
189189
*/
190190
eARPLookupResult_t eNDGetCacheEntry( IPv6_Address_t * pxIPAddress,
191-
MACAddress_t * const pxMACAddress,
192-
struct xNetworkEndPoint ** ppxEndPoint )
191+
MACAddress_t * const pxMACAddress,
192+
struct xNetworkEndPoint ** ppxEndPoint )
193193
{
194194
eARPLookupResult_t eReturn;
195195
NetworkEndPoint_t * pxEndPoint;
@@ -258,12 +258,15 @@
258258
/* See if the gateway has an entry in the cache. */
259259
eReturn = prvNDCacheLookup( pxIPAddress, pxMACAddress, ppxEndPoint );
260260

261-
if( *ppxEndPoint != NULL )
261+
if( ( ppxEndPoint != NULL ) && ( *ppxEndPoint != NULL ) )
262262
{
263263
FreeRTOS_printf( ( "eNDGetCacheEntry: found end-point %pip\n", ( void * ) ( *ppxEndPoint )->ipv6_settings.xIPAddress.ucBytes ) );
264264
}
265265

266-
*( ppxEndPoint ) = pxEndPoint;
266+
if( ppxEndPoint != NULL )
267+
{
268+
*( ppxEndPoint ) = pxEndPoint;
269+
}
267270
}
268271
}
269272
}

test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,32 @@ void test_eNDGetCacheEntry_Multicast_InvalidEndPoint( void )
217217
TEST_ASSERT_EQUAL( eARPCacheMiss, eResult );
218218
}
219219

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+
eARPLookupResult_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( eARPCacheMiss, eResult );
244+
}
245+
220246
/**
221247
* @brief This function find the MAC-address of an IPv6 address which is
222248
* not multi cast address, but the entry is present on the ND Cache,

0 commit comments

Comments
 (0)