summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJustin Pettit <jpettit@ovn.org>2016-06-25 22:22:02 -0700
committerJustin Pettit <jpettit@ovn.org>2016-07-19 22:18:35 -0700
commit6d1a4f16a412035086aa72201de22616a8283d64 (patch)
treedf2c82468d03013a4a850d194bfb9444dfb1efe7 /lib
parentfa7f915c630529616d038c964f251b1d97d6eca9 (diff)
downloadopenvswitch-6d1a4f16a412035086aa72201de22616a8283d64.tar.gz
packets: Add in6_is_lla() function.
Checks whether the supplied IPv6 address is a link local address. This will have a caller in a future commit. Signed-off-by: Justin Pettit <jpettit@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/packets.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/packets.h b/lib/packets.h
index 0d7cfc878..8f11e2c05 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -980,6 +980,18 @@ in6_generate_lla(struct eth_addr ea, struct in6_addr *lla)
taddr->be16[7] = ea.be16[2];
}
+/* Returns true if 'addr' is a link local address. Otherwise, false. */
+static inline bool
+in6_is_lla(struct in6_addr *addr)
+{
+#ifdef s6_addr32
+ return addr->s6_addr32[0] == htonl(0xfe800000) && !(addr->s6_addr32[1]);
+#else
+ return addr->s6_addr[0] == htons(0xfe80) &&
+ !(addr->s6_addr[1] | addr->s6_addr[2] | addr->s6_addr[3]);
+#endif
+}
+
static inline void
ipv6_multicast_to_ethernet(struct eth_addr *eth, const struct in6_addr *ip6)
{