diff options
| -rw-r--r-- | lib/prefix.c | 10 | ||||
| -rw-r--r-- | lib/prefix.h | 3 | 
2 files changed, 6 insertions, 7 deletions
diff --git a/lib/prefix.c b/lib/prefix.c index 1a4a914e05..85bbb18f3d 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -1468,11 +1468,11 @@ in_addr_t ipv4_broadcast_addr(in_addr_t hostaddr, int masklen)  	masklen2ip(masklen, &mask);  	return (masklen != IPV4_MAX_PREFIXLEN - 1) ? -						   /* normal case */ -		       (hostaddr | ~mask.s_addr) -						   : -						   /* special case for /31 */ -		       (hostaddr ^ ~mask.s_addr); +		/* normal case */ +		(hostaddr | ~mask.s_addr) +		   : +		/* For prefix 31 return 255.255.255.255 (RFC3021) */ +		htonl(0xFFFFFFFF);  }  /* Utility function to convert ipv4 netmask to prefixes diff --git a/lib/prefix.h b/lib/prefix.h index e338140f1a..7a7e13518a 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -451,8 +451,7 @@ extern void masklen2ip(const int, struct in_addr *);  extern in_addr_t ipv4_network_addr(in_addr_t hostaddr, int masklen);  /* given the address of a host on a network and the network mask length,   * calculate the broadcast address for that network; - * special treatment for /31: returns the address of the other host - * on the network by flipping the host bit */ + * special treatment for /31 according to RFC3021 section 3.3 */  extern in_addr_t ipv4_broadcast_addr(in_addr_t hostaddr, int masklen);  extern int netmask_str2prefix_str(const char *, const char *, char *);  | 
