Skip to content

Commit 9831ddd

Browse files
Hubert Miśjukkar
authored andcommitted
net: ipv6: add function checking if given address is ULA
This patch adds a helper function to verify if given IPv6 address is a unique local address. Signed-off-by: Hubert Miś <[email protected]>
1 parent fe6266e commit 9831ddd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/net/net_ip.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,18 @@ static inline bool net_ipv6_is_ll_addr(const struct in6_addr *addr)
763763
return UNALIGNED_GET(&addr->s6_addr16[0]) == htons(0xFE80);
764764
}
765765

766+
/**
767+
* @brief Check if the given IPv6 address is a unique local address.
768+
*
769+
* @param addr A valid pointer on an IPv6 address
770+
*
771+
* @return True if it is, false otherwise.
772+
*/
773+
static inline bool net_ipv6_is_ula_addr(const struct in6_addr *addr)
774+
{
775+
return addr->s6_addr[0] == 0xFD;
776+
}
777+
766778
/**
767779
* @brief Return pointer to any (all bits zeros) IPv6 address.
768780
*

0 commit comments

Comments
 (0)