summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ip.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/ip.h b/lib/ip.h
index b78a5e22..abd825ae 100644
--- a/lib/ip.h
+++ b/lib/ip.h
@@ -226,6 +226,9 @@ int ip6_compare(ip6_addr a, ip6_addr b);
int ip4_classify(ip4_addr ad);
int ip6_classify(ip6_addr *a);
+static inline int ip4_is_link_local(ip6_addr a)
+{ return (_I3(a) & 0xffff0000) == 0xa9fe0000; }
+
static inline int ip6_is_link_local(ip6_addr a)
{ return (_I0(a) & 0xffc00000) == 0xfe800000; }
@@ -233,7 +236,7 @@ static inline int ip6_is_v4mapped(ip6_addr a)
{ return _I0(a) == 0 && _I1(a) == 0 && _I2(a) == 0xffff; }
#define ipa_classify(x) ip6_classify(&(x))
-#define ipa_is_link_local(x) ip6_is_link_local(x)
+#define ipa_is_link_local(x) (ipa_is_ip4(x) ? ip4_is_link_local(x) : ip6_is_link_local(x))
static inline int ip4_is_unicast(ip4_addr a)
{ return _I(a) < 0xe0000000; }