summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2010-04-28 00:39:57 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2010-04-28 00:39:57 +0200
commitba321706578de8402d50214a9e79a65835cdd821 (patch)
treea76b5e241ed7f7c698890f2f9fd26a3c35ed07b2 /lib
parent48b0814ace2d05f9fef093d9f309bfa186a6f365 (diff)
Better support for /31 networks.
Diffstat (limited to 'lib')
-rw-r--r--lib/ip.c14
-rw-r--r--lib/ipv4.h3
-rw-r--r--lib/ipv6.h4
3 files changed, 6 insertions, 15 deletions
diff --git a/lib/ip.c b/lib/ip.c
index 0afe9796..791a6013 100644
--- a/lib/ip.c
+++ b/lib/ip.c
@@ -151,18 +151,6 @@ void ipa_ntoh(ip_addr x) { DUMMY }
int ipa_classify(ip_addr x) { DUMMY }
/**
- * ipa_opposite - return address of point-to-point neighbor
- * @x: IP address of our end of the link
- * @pxlen: network prefix length
- *
- * ipa_opposite() returns an address of the opposite end of a numbered
- * point-to-point link.
- *
- * This function is available in IPv4 version only.
- */
-ip_addr ipa_opposite(ip_addr x, int pxlen) { DUMMY }
-
-/**
* ipa_class_mask - guess netmask according to address class
* @x: IP address
*
@@ -172,7 +160,7 @@ ip_addr ipa_opposite(ip_addr x, int pxlen) { DUMMY }
* routing protocols transferring no prefix lengths nor netmasks
* and this function could be useful to them.
*/
-ip_addr ipa_classify(ip_addr x) { DUMMY }
+ip_addr ipa_class_mask(ip_addr x) { DUMMY }
/**
* ipa_from_u32 - convert IPv4 address to an integer
diff --git a/lib/ipv4.h b/lib/ipv4.h
index 74f1e88f..f258d37e 100644
--- a/lib/ipv4.h
+++ b/lib/ipv4.h
@@ -56,7 +56,8 @@ typedef u32 ip_addr;
#define ipa_ntoh(x) x = _MI(ntohl(_I(x)))
#define ipa_classify(x) ipv4_classify(_I(x))
#define ipa_has_link_scope(x) ipv4_has_link_scope(_I(x))
-#define ipa_opposite(x,len) _MI(_I(x) ^ (len == 30 ? 3 : 1))
+#define ipa_opposite_m1(x) _MI(_I(x) ^ 1)
+#define ipa_opposite_m2(x) _MI(_I(x) ^ 3)
#define ipa_class_mask(x) _MI(ipv4_class_mask(_I(x)))
#define ipa_from_u32(x) _MI(x)
#define ipa_to_u32(x) _I(x)
diff --git a/lib/ipv6.h b/lib/ipv6.h
index e15c57af..6f8e7b3c 100644
--- a/lib/ipv6.h
+++ b/lib/ipv6.h
@@ -62,7 +62,9 @@ typedef struct ipv6_addr {
#define ipa_ntoh(x) ipv6_ntoh(&(x))
#define ipa_classify(x) ipv6_classify(&(x))
#define ipa_has_link_scope(x) ipv6_has_link_scope(&(x))
-/* ipa_opposite and ipa_class_mask don't make sense with IPv6 */
+#define ipa_opposite_m1(x) ({ ip_addr _a=(x); _MI(_I0(_a),_I1(_a),_I2(_a),_I3(_a) ^ 1); })
+#define ipa_opposite_m2(x) ({ ip_addr _a=(x); _MI(_I0(_a),_I1(_a),_I2(_a),_I3(_a) ^ 3); })
+/* ipa_class_mask don't make sense with IPv6 */
/* 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)