Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/FreeRTOS_IPv6_Utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ void vManageSolicitedNodeAddress( const struct xNetworkEndPoint * pxEndPoint,
/* Solicited-node multicast addresses only apply to normal unicast non-loopback addresses. */
xAddressType = xIPv6_GetIPType( &( pxEndPoint->ipv6_settings.xIPAddress ) );

if( ( xAddressType != eIPv6_LinkLocal ) && ( xAddressType != eIPv6_SiteLocal ) && ( xAddressType != eIPv6_Global ) )
if( ( xAddressType != eIPv6_LinkLocal ) && ( xAddressType != eIPv6_SiteLocal ) && ( xAddressType != eIPv6_UniqueLocal ) && ( xAddressType != eIPv6_Global ) )
{
/* The address of this end-point is something other than a normal unicast address... Maybe it's the
* loopback address or maybe this is an error scenario. In any case, there is no corresponding
Expand Down
13 changes: 7 additions & 6 deletions source/FreeRTOS_Routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -1411,12 +1411,13 @@ struct xIPv6_Couple
BaseType_t xIndex;
static const struct xIPv6_Couple xIPCouples[] =
{
/* IP-type Mask Value */
{ eIPv6_Global, 0xE000U, 0x2000U }, /* 001 */
{ eIPv6_LinkLocal, 0xFFC0U, 0xFE80U }, /* 1111 1110 10 */
{ eIPv6_SiteLocal, 0xFFC0U, 0xFEC0U }, /* 1111 1110 11 */
{ eIPv6_Multicast, 0xFF00U, 0xFF00U }, /* 1111 1111 */
{ eIPv6_Loopback, 0xFFFFU, 0x0000U }, /* 0000 0000 ::1 */
/* IP-type Mask Value */
{ eIPv6_Global, 0xE000U, 0x2000U }, /* 001 */
{ eIPv6_LinkLocal, 0xFFC0U, 0xFE80U }, /* 1111 1110 10 */
{ eIPv6_SiteLocal, 0xFFC0U, 0xFEC0U }, /* 1111 1110 11 */
{ eIPv6_UniqueLocal, 0xFE00U, 0xFC00U }, /* 1111 110 */
{ eIPv6_Multicast, 0xFF00U, 0xFF00U }, /* 1111 1111 */
{ eIPv6_Loopback, 0xFFFFU, 0x0000U }, /* 0000 0000 ::1 */
};

if( pxAddress != NULL )
Expand Down
13 changes: 7 additions & 6 deletions source/include/FreeRTOS_Routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,13 @@

typedef enum
{
eIPv6_Global, /* 001 */
eIPv6_LinkLocal, /* 1111 1110 10 */
eIPv6_SiteLocal, /* 1111 1110 11 */
eIPv6_Multicast, /* 1111 1111 */
eIPv6_Loopback, /* 1111 (::1) */
eIPv6_Unknown /* Not implemented. */
eIPv6_Global, /* 001 */
eIPv6_LinkLocal, /* 1111 1110 10 */
eIPv6_SiteLocal, /* 1111 1110 11 */
eIPv6_UniqueLocal, /* 1111 110 */
eIPv6_Multicast, /* 1111 1111 */
eIPv6_Loopback, /* 1111 (::1) */
eIPv6_Unknown /* Not implemented. */
}
IPv6_Type_t;

Expand Down
20 changes: 20 additions & 0 deletions test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -4419,6 +4419,26 @@ void test_prvIPNetworkUpCalls_SiteLocal()
prvIPNetworkUpCalls_Generic( ucAddress, eIPv6_SiteLocal, ipHAS_IPV6 | ipHAS_METHOD );
}

void test_prvIPNetworkUpCalls_UniqueLocal()
{
/* Use the unique local address fd12:3456:789a:1::1 */
static const uint8_t ucAddress[ 16 ] =
{
0xFDU, 0x12U,
0x34U, 0x56U,
0x78U, 0x9AU,
0x00U, 0x01U,
0x00U, 0x00U,
0x00U, 0x00U,
0x00U, 0x00U,
0x00U, 0x01U
};

prvIPNetworkUpCalls_Generic( ucAddress, eIPv6_UniqueLocal, ipHAS_IPV6 | ipHAS_METHOD | ipHAS_INTERFACE );
prvIPNetworkUpCalls_Generic( ucAddress, eIPv6_UniqueLocal, ipHAS_IPV6 | ipHAS_INTERFACE );
prvIPNetworkUpCalls_Generic( ucAddress, eIPv6_UniqueLocal, ipHAS_IPV6 | ipHAS_METHOD );
}

void test_prvIPNetworkUpCalls_Multicast()
{
/* Use the multicast address "ff02::fb",
Expand Down
26 changes: 26 additions & 0 deletions test/unit-test/FreeRTOS_IPv6_Utils/FreeRTOS_IPv6_Utils_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,19 @@ void test_vManageSolicitedNodeAddress_NetworkGoingUp( void )

TEST_ASSERT_EQUAL( pdTRUE, xMACAddFunctionCalled );

/* Happy path eIPv6_UniqueLocal */
xInterface.pfAddAllowedMAC = &pfAddAllowedMAC;
xInterface.pfRemoveAllowedMAC = &pfRemoveAllowedMAC;
xInterface.pxEndPoint = &xEndPoint;

xMACAddFunctionCalled = pdFALSE;

xIPv6_GetIPType_ExpectAndReturn( &xEndPoint.ipv6_settings.xIPAddress, eIPv6_UniqueLocal );

vManageSolicitedNodeAddress( &xEndPoint, pdTRUE );

TEST_ASSERT_EQUAL( pdTRUE, xMACAddFunctionCalled );

/* Happy path eIPv6_Global */
xInterface.pfAddAllowedMAC = &pfAddAllowedMAC;
xInterface.pfRemoveAllowedMAC = &pfRemoveAllowedMAC;
Expand Down Expand Up @@ -843,6 +856,19 @@ void test_vManageSolicitedNodeAddress_NetworkGoingDown( void )

TEST_ASSERT_EQUAL( pdTRUE, xMACRemoveFunctionCalled );

/* Happy path eIPv6_UniqueLocal */
xInterface.pfAddAllowedMAC = &pfAddAllowedMAC;
xInterface.pfRemoveAllowedMAC = &pfRemoveAllowedMAC;
xInterface.pxEndPoint = &xEndPoint;

xMACRemoveFunctionCalled = pdFALSE;

xIPv6_GetIPType_ExpectAndReturn( &xEndPoint.ipv6_settings.xIPAddress, eIPv6_UniqueLocal );

vManageSolicitedNodeAddress( &xEndPoint, pdFALSE );

TEST_ASSERT_EQUAL( pdTRUE, xMACRemoveFunctionCalled );

/* Happy path eIPv6_Global */
xInterface.pfAddAllowedMAC = &pfAddAllowedMAC;
xInterface.pfRemoveAllowedMAC = &pfRemoveAllowedMAC;
Expand Down
18 changes: 18 additions & 0 deletions test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -2645,6 +2645,24 @@ void test_xIPv6_GetIPType_SiteLocal()
TEST_ASSERT_EQUAL( eIPv6_SiteLocal, xReturn );
}

/**
* @brief xIPv6_GetIPType returns eIPv6_UniqueLocal if input address matches FC00::/7.
*
* Test step:
* - Create 1 IPv6 address.
* - Set the IP address to FD12:3456:789A:1::1.
* - Call xIPv6_GetIPType to check IP type.
* - Check if it returns eIPv6_UniqueLocal.
*/
void test_xIPv6_GetIPType_UniqueLocal()
{
const IPv6_Address_t xIPv6Address = { 0xFD, 0x12, 0x34, 0x56, 0x78, 0x9A, 0, 0x01, 0, 0, 0, 0, 0, 0, 0, 0x01 };
IPv6_Type_t xReturn;

xReturn = xIPv6_GetIPType( &xIPv6Address );
TEST_ASSERT_EQUAL( eIPv6_UniqueLocal, xReturn );
}

/**
* @brief xIPv6_GetIPType returns eIPv6_Multicast if input address matches FF00::/8.
*
Expand Down