summaryrefslogtreecommitdiffstats
path: root/lib/prefix.h
diff options
context:
space:
mode:
authorMobashshera Rasool <mrasool@vmware.com>2022-06-16 05:08:35 +0200
committerMobashshera Rasool <mrasool@vmware.com>2022-06-22 05:44:10 +0200
commit3a0d338bc9f69daa1bf4f059a12d7dd4e85c89e0 (patch)
treeb1ca93b75c47599eb79787a4e9c8ae2a5f046822 /lib/prefix.h
parentMerge pull request #11443 from opensourcerouting/fix/duplicate_label (diff)
downloadfrr-3a0d338bc9f69daa1bf4f059a12d7dd4e85c89e0.tar.xz
frr-3a0d338bc9f69daa1bf4f059a12d7dd4e85c89e0.zip
lib: Add an api is_ipv6_global_unicast
Add api is_ipv6_global_unicast to identify whether a given ipv6 address is global unicast or not. Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
Diffstat (limited to '')
-rw-r--r--lib/prefix.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/prefix.h b/lib/prefix.h
index 42394ec61..f9eef28a0 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -594,6 +594,15 @@ static inline int is_default_host_route(const struct prefix *p)
return 0;
}
+static inline bool is_ipv6_global_unicast(const struct in6_addr *p)
+{
+ if (IN6_IS_ADDR_UNSPECIFIED(p) || IN6_IS_ADDR_LOOPBACK(p) ||
+ IN6_IS_ADDR_LINKLOCAL(p) || IN6_IS_ADDR_MULTICAST(p))
+ return false;
+
+ return true;
+}
+
/* IPv6 scope values, usable for IPv4 too (cf. below) */
/* clang-format off */
enum {