Revision e687ec01 lib/netutils.py
b/lib/netutils.py | ||
---|---|---|
58 | 58 |
|
59 | 59 |
# Dict used to convert from a string representing an IP family to an IP |
60 | 60 |
# version |
61 |
_NAME_TO_IP_VER = {
|
|
61 |
_NAME_TO_IP_VER = { |
|
62 | 62 |
"inet": constants.IP4_VERSION, |
63 | 63 |
"inet6": constants.IP6_VERSION, |
64 | 64 |
} |
... | ... | |
417 | 417 |
assert 0 <= prefix <= cls.iplen |
418 | 418 |
target_int = cls._GetIPIntFromString(subnet[0]) |
419 | 419 |
# Convert prefix netmask to integer value of netmask |
420 |
netmask_int = (2**cls.iplen)-1 ^ ((2**cls.iplen)-1 >> prefix)
|
|
420 |
netmask_int = (2 ** cls.iplen) - 1 ^ ((2 ** cls.iplen) - 1 >> prefix)
|
|
421 | 421 |
# Calculate hostmask |
422 |
hostmask_int = netmask_int ^ (2**cls.iplen)-1
|
|
422 |
hostmask_int = netmask_int ^ (2 ** cls.iplen) - 1
|
|
423 | 423 |
# Calculate network address by and'ing netmask |
424 | 424 |
network_int = target_int & netmask_int |
425 | 425 |
# Calculate broadcast address by or'ing hostmask |
Also available in: Unified diff