Use IPV4_NETMASK_HOST constant.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Signed-off-by: David Sommerseth <davids@redhat.com>
... | ... |
@@ -342,7 +342,7 @@ mroute_addr_mask_host_bits (struct mroute_addr *ma) |
342 | 342 |
if ( bits_to_clear >= 8 ) |
343 | 343 |
{ ma->addr[byte--] = 0; bits_to_clear -= 8; } |
344 | 344 |
else |
345 |
- { ma->addr[byte--] &= (~0 << bits_to_clear); bits_to_clear = 0; } |
|
345 |
+ { ma->addr[byte--] &= (IPV4_NETMASK_HOST << bits_to_clear); bits_to_clear = 0; } |
|
346 | 346 |
} |
347 | 347 |
ASSERT( bits_to_clear == 0 ); |
348 | 348 |
} |
... | ... |
@@ -125,7 +125,7 @@ add_subnet (const char *line, const char *prefix, const int line_num, struct pf_ |
125 | 125 |
{ |
126 | 126 |
/* match special "unknown" tag for addresses unrecognized by mroute */ |
127 | 127 |
network.s_addr = htonl(0); |
128 |
- netmask = ~0; |
|
128 |
+ netmask = IPV4_NETMASK_HOST; |
|
129 | 129 |
} |
130 | 130 |
|
131 | 131 |
{ |
... | ... |
@@ -268,7 +268,7 @@ init_route (struct route *r, |
268 | 268 |
const struct route_option *ro, |
269 | 269 |
const struct route_list *rl) |
270 | 270 |
{ |
271 |
- const in_addr_t default_netmask = ~0; |
|
271 |
+ const in_addr_t default_netmask = IPV4_NETMASK_HOST; |
|
272 | 272 |
bool status; |
273 | 273 |
|
274 | 274 |
CLEAR (*r); |
... | ... |
@@ -797,7 +797,7 @@ add_bypass_routes (struct route_bypass *rb, |
797 | 797 |
{ |
798 | 798 |
if (rb->bypass[i]) |
799 | 799 |
add_route3 (rb->bypass[i], |
800 |
- ~0, |
|
800 |
+ IPV4_NETMASK_HOST, |
|
801 | 801 |
gateway, |
802 | 802 |
tt, |
803 | 803 |
flags | ROUTE_REF_GW, |
... | ... |
@@ -819,7 +819,7 @@ del_bypass_routes (struct route_bypass *rb, |
819 | 819 |
{ |
820 | 820 |
if (rb->bypass[i]) |
821 | 821 |
del_route3 (rb->bypass[i], |
822 |
- ~0, |
|
822 |
+ IPV4_NETMASK_HOST, |
|
823 | 823 |
gateway, |
824 | 824 |
tt, |
825 | 825 |
flags | ROUTE_REF_GW, |
... | ... |
@@ -870,7 +870,7 @@ redirect_default_route_to_vpn (struct route_list *rl, const struct tuntap *tt, u |
870 | 870 |
* adding this special /32 route */ |
871 | 871 |
if (rl->spec.remote_host != IPV4_INVALID_ADDR) { |
872 | 872 |
add_route3 (rl->spec.remote_host, |
873 |
- ~0, |
|
873 |
+ IPV4_NETMASK_HOST, |
|
874 | 874 |
rl->rgi.gateway.addr, |
875 | 875 |
tt, |
876 | 876 |
flags | ROUTE_REF_GW, |
... | ... |
@@ -944,7 +944,7 @@ undo_redirect_default_route_to_vpn (struct route_list *rl, const struct tuntap * |
944 | 944 |
if (rl->iflags & RL_DID_LOCAL) |
945 | 945 |
{ |
946 | 946 |
del_route3 (rl->spec.remote_host, |
947 |
- ~0, |
|
947 |
+ IPV4_NETMASK_HOST, |
|
948 | 948 |
rl->rgi.gateway.addr, |
949 | 949 |
tt, |
950 | 950 |
flags | ROUTE_REF_GW, |
... | ... |
@@ -3125,7 +3125,7 @@ netmask_to_netbits (const in_addr_t network, const in_addr_t netmask, int *netbi |
3125 | 3125 |
static void |
3126 | 3126 |
add_host_route_if_nonlocal (struct route_bypass *rb, const in_addr_t addr) |
3127 | 3127 |
{ |
3128 |
- if (test_local_addr(addr, NULL) == TLA_NONLOCAL && addr != 0 && addr != ~0) |
|
3128 |
+ if (test_local_addr(addr, NULL) == TLA_NONLOCAL && addr != 0 && addr != IPV4_NETMASK_HOST) |
|
3129 | 3129 |
add_bypass_address (rb, addr); |
3130 | 3130 |
} |
3131 | 3131 |
|
... | ... |
@@ -317,7 +317,7 @@ netbits_to_netmask (const int netbits) |
317 | 317 |
const int addrlen = sizeof (in_addr_t) * 8; |
318 | 318 |
in_addr_t mask = 0; |
319 | 319 |
if (netbits > 0 && netbits <= addrlen) |
320 |
- mask = ~0 << (addrlen-netbits); |
|
320 |
+ mask = IPV4_NETMASK_HOST << (addrlen-netbits); |
|
321 | 321 |
return mask; |
322 | 322 |
} |
323 | 323 |
|
... | ... |
@@ -489,7 +489,7 @@ init_tun (const char *dev, /* --dev option */ |
489 | 489 |
if (tt->type == DEV_TYPE_TAP || (tt->type == DEV_TYPE_TUN && tt->topology == TOP_SUBNET)) |
490 | 490 |
check_subnet_conflict (tt->local, tt->remote_netmask, "TUN/TAP adapter"); |
491 | 491 |
else if (tt->type == DEV_TYPE_TUN) |
492 |
- check_subnet_conflict (tt->local, ~0, "TUN/TAP adapter"); |
|
492 |
+ check_subnet_conflict (tt->local, IPV4_NETMASK_HOST, "TUN/TAP adapter"); |
|
493 | 493 |
} |
494 | 494 |
|
495 | 495 |
/* |