From 9831ddd14bada152ce79bbfc273cbbc8bcf8dfa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20Mi=C5=9B?= Date: Sun, 7 Feb 2021 12:25:19 +0100 Subject: [PATCH] net: ipv6: add function checking if given address is ULA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds a helper function to verify if given IPv6 address is a unique local address. Signed-off-by: Hubert Miś --- include/net/net_ip.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/net/net_ip.h b/include/net/net_ip.h index 61eccba7033..ecc7f3d3eb4 100644 --- a/include/net/net_ip.h +++ b/include/net/net_ip.h @@ -763,6 +763,18 @@ static inline bool net_ipv6_is_ll_addr(const struct in6_addr *addr) return UNALIGNED_GET(&addr->s6_addr16[0]) == htons(0xFE80); } +/** + * @brief Check if the given IPv6 address is a unique local address. + * + * @param addr A valid pointer on an IPv6 address + * + * @return True if it is, false otherwise. + */ +static inline bool net_ipv6_is_ula_addr(const struct in6_addr *addr) +{ + return addr->s6_addr[0] == 0xFD; +} + /** * @brief Return pointer to any (all bits zeros) IPv6 address. *