summaryrefslogtreecommitdiff
path: root/lib/ip.h
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2018-09-12 23:03:27 +0000
committerMikael Magnusson <mikma@users.sourceforge.net>2019-02-27 21:28:38 +0100
commitb8c0bc361f4a869a2bb96cd9641d88becbc3296e (patch)
treeeee69eaf09ce7e38b5b292f2f4289409944733c7 /lib/ip.h
parent7c36eb3e8bd7d06f65dc7319d42b6abe782c5b89 (diff)
link-local: WIPold/ipv4-link-local
Diffstat (limited to 'lib/ip.h')
-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; }