]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Add an api is_ipv6_global_unicast
authorMobashshera Rasool <mrasool@vmware.com>
Thu, 16 Jun 2022 03:08:35 +0000 (20:08 -0700)
committerMobashshera Rasool <mrasool@vmware.com>
Wed, 22 Jun 2022 03:44:10 +0000 (20:44 -0700)
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>
lib/prefix.h

index 42394ec61cec7fc85517c5e33ea3d39d2be011da..f9eef28a0bb429e63d397916b454e2bd4d5b8c5c 100644 (file)
@@ -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 {