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>
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: