summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2008-08-25 11:19:49 +0000
committerMartin Mares <mj@ucw.cz>2008-08-25 11:19:49 +0000
commit057021df0d699f9c21368ab0fa51fe821cc9a544 (patch)
tree729c776649d05dfc1378988bbddd4d5fac8d97f7 /lib
parent6c36c4b66be5c67a8d5cfa9578aa5a85ebebab6d (diff)
Fix behavior of ipa_opposite().
It was giving wrong results on /30 networks.
Diffstat (limited to 'lib')
-rw-r--r--lib/ip.c3
-rw-r--r--lib/ipv4.h2
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/ip.c b/lib/ip.c
index b940bf53..0afe9796 100644
--- a/lib/ip.c
+++ b/lib/ip.c
@@ -153,13 +153,14 @@ 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) { DUMMY }
+ip_addr ipa_opposite(ip_addr x, int pxlen) { DUMMY }
/**
* ipa_class_mask - guess netmask according to address class
diff --git a/lib/ipv4.h b/lib/ipv4.h
index 49aa13a6..4c4fab90 100644
--- a/lib/ipv4.h
+++ b/lib/ipv4.h
@@ -53,7 +53,7 @@ typedef u32 ip_addr;
#define ipa_hton(x) x = _MI(htonl(_I(x)))
#define ipa_ntoh(x) x = _MI(ntohl(_I(x)))
#define ipa_classify(x) ipv4_classify(_I(x))
-#define ipa_opposite(x) _MI(_I(x) ^ 1)
+#define ipa_opposite(x,len) _MI(_I(x) ^ (len == 30 ? 3 : 1))
#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)