]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Added ipa_absolutize() which converts link-scope addresses to global scope
authorMartin Mares <mj@ucw.cz>
Tue, 30 May 2000 22:47:33 +0000 (22:47 +0000)
committerMartin Mares <mj@ucw.cz>
Tue, 30 May 2000 22:47:33 +0000 (22:47 +0000)
ones according to prefix assigned to the corresponding interface.

lib/ipv6.c
lib/ipv6.h

index b666ddd8e175511362684f3aebf022b059d06703..88c54eb6e733550a3ecbfa9640bc46dca3c4f953 100644 (file)
@@ -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"
index cf7a9bbeacba3591d5dcb57d2da81a2134b6bf7d..90aedb94118ec7e767af17d1ae10a0345149e28d 100644 (file)
@@ -55,6 +55,7 @@ typedef struct ipv6_addr {
 /* ipa_from_u32 and ipa_to_u32 replaced by ipa_build */
 #define ipa_build(a,b,c,d) _MI(a,b,c,d)
 #define ipa_compare(x,y) ipv6_compare(x,y)
+#define ipa_absolutize(x,y) ipv6_absolutize(x,y)
 
 ip_addr ipv6_mkmask(unsigned);
 unsigned ipv6_mklen(ip_addr *);
@@ -63,6 +64,7 @@ void ipv6_hton(ip_addr *);
 void ipv6_ntoh(ip_addr *);
 int ipv6_compare(ip_addr, ip_addr);
 int ipv4_pton_u32(char *, u32 *);
+void ipv6_absolutize(ip_addr *, ip_addr *);
 
 /*
  *  This hash function looks well, but once IPv6 enters