tests: posix: headers: net: Add various IPv6 address check macros
Add these Posix specified IPv6 address checking macros IN6_IS_ADDR_UNSPECIFIED IN6_IS_ADDR_LOOPBACK IN6_IS_ADDR_MULTICAST IN6_IS_ADDR_LINKLOCAL IN6_IS_ADDR_SITELOCAL IN6_IS_ADDR_V4MAPPED IN6_IS_ADDR_MC_NODELOCAL IN6_IS_ADDR_MC_LINKLOCAL IN6_IS_ADDR_MC_SITELOCAL IN6_IS_ADDR_MC_ORGLOCAL IN6_IS_ADDR_MC_GLOBAL and tests for them. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
606eeed8c9
commit
8f49925a0f
2 changed files with 68 additions and 11 deletions
|
@ -1295,6 +1295,46 @@ struct in6_pktinfo {
|
||||||
#define SOMAXCONN 128
|
#define SOMAXCONN 128
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name Macros for checking special IPv6 addresses.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/** Check unspecified IPv6 address. */
|
||||||
|
#define IN6_IS_ADDR_UNSPECIFIED(addr) \
|
||||||
|
net_ipv6_addr_cmp(net_ipv6_unspecified_address(), addr)
|
||||||
|
|
||||||
|
/** Check loopback IPv6 address. */
|
||||||
|
#define IN6_IS_ADDR_LOOPBACK(addr) net_ipv6_is_addr_loopback(addr)
|
||||||
|
|
||||||
|
/** Check IPv6 multicast address */
|
||||||
|
#define IN6_IS_ADDR_MULTICAST(addr) net_ipv6_is_addr_mcast(addr)
|
||||||
|
|
||||||
|
/** Check IPv6 link local address */
|
||||||
|
#define IN6_IS_ADDR_LINKLOCAL(addr) net_ipv6_is_ll_addr(addr)
|
||||||
|
|
||||||
|
/** Check IPv6 site local address */
|
||||||
|
#define IN6_IS_ADDR_SITELOCAL(addr) net_ipv6_is_sl_addr(addr)
|
||||||
|
|
||||||
|
/** Check IPv6 v4 mapped address */
|
||||||
|
#define IN6_IS_ADDR_V4MAPPED(addr) net_ipv6_addr_is_v4_mapped(addr)
|
||||||
|
|
||||||
|
/** Check IPv6 multicast global address */
|
||||||
|
#define IN6_IS_ADDR_MC_GLOBAL(addr) net_ipv6_is_addr_mcast_global(addr)
|
||||||
|
|
||||||
|
/** Check IPv6 multicast node local address */
|
||||||
|
#define IN6_IS_ADDR_MC_NODELOCAL(addr) net_ipv6_is_addr_mcast_iface(addr)
|
||||||
|
|
||||||
|
/** Check IPv6 multicast link local address */
|
||||||
|
#define IN6_IS_ADDR_MC_LINKLOCAL(addr) net_ipv6_is_addr_mcast_link(addr)
|
||||||
|
|
||||||
|
/** Check IPv6 multicast site local address */
|
||||||
|
#define IN6_IS_ADDR_MC_SITELOCAL(addr) net_ipv6_is_addr_mcast_site(addr)
|
||||||
|
|
||||||
|
/** Check IPv6 multicast organization local address */
|
||||||
|
#define IN6_IS_ADDR_MC_ORGLOCAL(addr) net_ipv6_is_addr_mcast_org(addr)
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
/** @cond INTERNAL_HIDDEN */
|
/** @cond INTERNAL_HIDDEN */
|
||||||
/**
|
/**
|
||||||
* @brief Registration information for a given BSD socket family.
|
* @brief Registration information for a given BSD socket family.
|
||||||
|
|
|
@ -45,6 +45,23 @@ ZTEST(posix_headers, test_netinet_in_h)
|
||||||
struct in6_addr any6 = IN6ADDR_ANY_INIT;
|
struct in6_addr any6 = IN6ADDR_ANY_INIT;
|
||||||
struct in6_addr lo6 = IN6ADDR_LOOPBACK_INIT;
|
struct in6_addr lo6 = IN6ADDR_LOOPBACK_INIT;
|
||||||
|
|
||||||
|
struct in6_addr mcast6 = { { { 0xff, 0 } } };
|
||||||
|
struct in6_addr ll6 = { { { 0xfe, 0x80, 0x01, 0x02,
|
||||||
|
0, 0, 0, 0, 0, 0x01 } } };
|
||||||
|
struct in6_addr sl6 = { { { 0xfe, 0xc0, 0, 0x01, 0x02 } } };
|
||||||
|
struct in6_addr v4mapped = { { { 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0xff, 0xff, 0xff, 0xff, 0xc0, 0, 0x02, 0x01 } } };
|
||||||
|
struct in6_addr mcnl6 = { { { 0xff, 0x01, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0x01 } } };
|
||||||
|
struct in6_addr mcll6 = { { { 0xff, 0x02, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0x01 } } };
|
||||||
|
struct in6_addr mcsl6 = { { { 0xff, 0x05, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0x01 } } };
|
||||||
|
struct in6_addr mcol6 = { { { 0xff, 0x08, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0x01 } } };
|
||||||
|
struct in6_addr mcg6 = { { { 0xff, 0x0e, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0x01 } } };
|
||||||
|
|
||||||
/* not implemented */
|
/* not implemented */
|
||||||
/* zassert_not_equal(-1, offsetof(struct ipv6_mreq, ipv6mr_multiaddr)); */
|
/* zassert_not_equal(-1, offsetof(struct ipv6_mreq, ipv6mr_multiaddr)); */
|
||||||
/* not implemented */
|
/* not implemented */
|
||||||
|
@ -71,18 +88,18 @@ ZTEST(posix_headers, test_netinet_in_h)
|
||||||
zassert_not_equal(-1, IPV6_UNICAST_HOPS);
|
zassert_not_equal(-1, IPV6_UNICAST_HOPS);
|
||||||
zassert_not_equal(-1, IPV6_V6ONLY);
|
zassert_not_equal(-1, IPV6_V6ONLY);
|
||||||
|
|
||||||
/* IN6_IS_ADDR_UNSPECIFIED(&any6); */ /* not implemented */
|
zassert_true(IN6_IS_ADDR_UNSPECIFIED(&any6));
|
||||||
/* IN6_IS_ADDR_LOOPBACK(&lo6); */ /* not implemented */
|
zassert_true(IN6_IS_ADDR_LOOPBACK(&lo6));
|
||||||
|
|
||||||
/* IN6_IS_ADDR_MULTICAST(&lo6); */ /* not implemented */
|
zassert_true(IN6_IS_ADDR_MULTICAST(&mcast6));
|
||||||
/* IN6_IS_ADDR_LINKLOCAL(&lo6); */ /* not implemented */
|
zassert_true(IN6_IS_ADDR_LINKLOCAL(&ll6));
|
||||||
/* IN6_IS_ADDR_SITELOCAL(&lo6); */ /* not implemented */
|
zassert_true(IN6_IS_ADDR_SITELOCAL(&sl6));
|
||||||
/* IN6_IS_ADDR_V4MAPPED(&lo6); */ /* not implemented */
|
zassert_true(IN6_IS_ADDR_V4MAPPED(&v4mapped));
|
||||||
/* IN6_IS_ADDR_V4COMPAT(&lo6); */ /* not implemented */
|
/* IN6_IS_ADDR_V4COMPAT(&lo6); */ /* not implemented */
|
||||||
/* IN6_IS_ADDR_MC_NODELOCAL(&lo6); */ /* not implemented */
|
zassert_true(IN6_IS_ADDR_MC_NODELOCAL(&mcnl6));
|
||||||
/* IN6_IS_ADDR_MC_LINKLOCAL(&lo6); */ /* not implemented */
|
zassert_true(IN6_IS_ADDR_MC_LINKLOCAL(&mcll6));
|
||||||
/* IN6_IS_ADDR_MC_SITELOCAL(&lo6); */ /* not implemented */
|
zassert_true(IN6_IS_ADDR_MC_SITELOCAL(&mcsl6));
|
||||||
/* IN6_IS_ADDR_MC_ORGLOCAL(&lo6); */ /* not implemented */
|
zassert_true(IN6_IS_ADDR_MC_ORGLOCAL(&mcol6));
|
||||||
/* IN6_IS_ADDR_MC_GLOBAL(&lo6); */ /* not implemented */
|
zassert_true(IN6_IS_ADDR_MC_GLOBAL(&mcg6));
|
||||||
}
|
}
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue