}
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)
- print "PREFIX="32-bitcount(compl32(netmask))
+ print "PREFIX="prefix
# range calculations:
# ipcalc <ip> <netmask> <start> <num>
if (end>limit) end=limit
if (end==ipaddr) end=ipaddr-1
+ if (start>end) {
+ print "network ("int2ip(network)"/"prefix") too small" > "/dev/stderr"
+ exit(1)
+ }
+
if (ipaddr > start && ipaddr < end) {
print "ipaddr inside range" > "/dev/stderr"
exit(1)