summaryrefslogtreecommitdiffstats
path: root/lib/prefix.c
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas.abraitis@gmail.com>2021-07-01 16:42:03 +0200
committerDonatas Abraitis <donatas.abraitis@gmail.com>2021-07-01 16:44:09 +0200
commit936fbaef4794277a56185c535574df0f2771c117 (patch)
tree22e9f5b8ccaddd165187244bde90fdd61492630c /lib/prefix.c
parent*: Replace IPV6_MAX_PREFIXLEN to IPV6_MAX_BITLEN (diff)
downloadfrr-936fbaef4794277a56185c535574df0f2771c117.tar.xz
frr-936fbaef4794277a56185c535574df0f2771c117.zip
*: Replace IPV4_MAX_PREFIXLEN to IPV4_MAX_BITLEN
Just drop IPV4_MAX_PREFIXLEN at all, no need keeping both. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
Diffstat (limited to 'lib/prefix.c')
-rw-r--r--lib/prefix.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/prefix.c b/lib/prefix.c
index 7dbb5f07f..1c57715e8 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -577,7 +577,7 @@ int str2prefix_ipv4(const char *str, struct prefix_ipv4 *p)
/* Get prefix length. */
plen = (uint8_t)atoi(++pnt);
- if (plen > IPV4_MAX_PREFIXLEN)
+ if (plen > IPV4_MAX_BITLEN)
return 0;
p->family = AF_INET;
@@ -1128,7 +1128,7 @@ void apply_classful_mask_ipv4(struct prefix_ipv4 *p)
destination = ntohl(p->prefix.s_addr);
- if (p->prefixlen == IPV4_MAX_PREFIXLEN)
+ if (p->prefixlen == IPV4_MAX_BITLEN)
;
/* do nothing for host routes */
else if (IN_CLASSC(destination)) {
@@ -1148,12 +1148,13 @@ in_addr_t ipv4_broadcast_addr(in_addr_t hostaddr, int masklen)
struct in_addr mask;
masklen2ip(masklen, &mask);
- return (masklen != IPV4_MAX_PREFIXLEN - 1) ?
- /* normal case */
- (hostaddr | ~mask.s_addr)
- :
- /* For prefix 31 return 255.255.255.255 (RFC3021) */
- htonl(0xFFFFFFFF);
+ return (masklen != IPV4_MAX_BITLEN - 1)
+ ?
+ /* 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