summaryrefslogtreecommitdiffstats
path: root/lib/ipv6.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-05-31 00:47:33 +0200
committerMartin Mares <mj@ucw.cz>2000-05-31 00:47:33 +0200
commitcfa6ab0593a02c3d4d0d959c771f72430f1adf67 (patch)
tree28a620d00a36699ec901dd5b9d46fd8568dcdc5d /lib/ipv6.c
parent69a20d2effb651e475b8ab8b04ee1a04a76db07f (diff)
downloadbird-cfa6ab0593a02c3d4d0d959c771f72430f1adf67.tar
bird-cfa6ab0593a02c3d4d0d959c771f72430f1adf67.zip
Added ipa_absolutize() which converts link-scope addresses to global scope
ones according to prefix assigned to the corresponding interface.
Diffstat (limited to 'lib/ipv6.c')
-rw-r--r--lib/ipv6.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/ipv6.c b/lib/ipv6.c
index b666ddd..88c54eb 100644
--- a/lib/ipv6.c
+++ b/lib/ipv6.c
@@ -322,6 +322,17 @@ ip_pton(char *a, ip_addr *o)
return 1;
}
+void ipv6_absolutize(ip_addr *a, ip_addr *ifa)
+{
+ if ((a->addr[0] & 0xffc00000) == 0xfe800000 && /* a is link-scope */
+ ((ifa->addr[0] & 0xe0000000) == 0x20000000 | /* ifa is AGU ... */
+ (ifa->addr[0] & 0xffc00000) == 0xfec00000)) /* ... or site-scope */
+ {
+ a->addr[0] = ifa->addr[0]; /* Copy the prefix, leave interface ID */
+ a->addr[1] = ifa->addr[1];
+ }
+}
+
#ifdef TEST
#include "bitops.c"