mirror of
https://github.com/openwrt/openwrt.git
synced 2025-01-18 10:46:41 +00:00
base-files: ipcalc.sh: don't print broadcast addr for prefix > 30
Printing a broadcast address doesn't make any sense for /31 and /32 prefixes. Strictly speaking, the same goes for the network address but it is useful to get the first address in the prefix, e.g. to create a canonical CIDR notation "$NETWORK/$PREFIX". Signed-off-by: Leon M. Busch-George <leon@georgemail.eu>
This commit is contained in:
parent
9b2f8a33b6
commit
59e681eea1
@ -50,12 +50,14 @@ BEGIN {
|
||||
|
||||
network=and(ipaddr,netmask)
|
||||
prefix=32-bitcount(compl32(netmask))
|
||||
broadcast=or(network,compl32(netmask))
|
||||
|
||||
print "IP="int2ip(ipaddr)
|
||||
print "NETMASK="int2ip(netmask)
|
||||
print "BROADCAST="int2ip(broadcast)
|
||||
print "NETWORK="int2ip(network)
|
||||
if (prefix<=30) {
|
||||
broadcast=or(network,compl32(netmask))
|
||||
print "BROADCAST="int2ip(broadcast)
|
||||
}
|
||||
print "PREFIX="prefix
|
||||
|
||||
# range calculations:
|
||||
|
Loading…
Reference in New Issue
Block a user