mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-15 13:30:21 +00:00
Merge pull request #4773 from thozza/31-prefix-bcast-addr
ipv4_broadcast_addr() didn't comply with RFC3021
This commit is contained in:
commit
b27b58be24
10
lib/prefix.c
10
lib/prefix.c
@ -1113,11 +1113,11 @@ in_addr_t ipv4_broadcast_addr(in_addr_t hostaddr, int masklen)
|
|||||||
|
|
||||||
masklen2ip(masklen, &mask);
|
masklen2ip(masklen, &mask);
|
||||||
return (masklen != IPV4_MAX_PREFIXLEN - 1) ?
|
return (masklen != IPV4_MAX_PREFIXLEN - 1) ?
|
||||||
/* normal case */
|
/* normal case */
|
||||||
(hostaddr | ~mask.s_addr)
|
(hostaddr | ~mask.s_addr)
|
||||||
:
|
:
|
||||||
/* special case for /31 */
|
/* For prefix 31 return 255.255.255.255 (RFC3021) */
|
||||||
(hostaddr ^ ~mask.s_addr);
|
htonl(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Utility function to convert ipv4 netmask to prefixes
|
/* Utility function to convert ipv4 netmask to prefixes
|
||||||
|
@ -451,8 +451,7 @@ extern uint8_t ip_masklen(struct in_addr);
|
|||||||
extern void masklen2ip(const int, struct in_addr *);
|
extern void masklen2ip(const int, struct in_addr *);
|
||||||
/* given the address of a host on a network and the network mask length,
|
/* given the address of a host on a network and the network mask length,
|
||||||
* calculate the broadcast address for that network;
|
* calculate the broadcast address for that network;
|
||||||
* special treatment for /31: returns the address of the other host
|
* special treatment for /31 according to RFC3021 section 3.3 */
|
||||||
* on the network by flipping the host bit */
|
|
||||||
extern in_addr_t ipv4_broadcast_addr(in_addr_t hostaddr, int masklen);
|
extern in_addr_t ipv4_broadcast_addr(in_addr_t hostaddr, int masklen);
|
||||||
|
|
||||||
extern int netmask_str2prefix_str(const char *, const char *, char *);
|
extern int netmask_str2prefix_str(const char *, const char *, char *);
|
||||||
|
Loading…
Reference in New Issue
Block a user