3 awk -f $dir/common.awk -f - $* <<EOF
5 slpos=index(ARGV[1],"/")
8 netmask=ip2int(ARGV[2])
10 ipaddr=ip2int(substr(ARGV[1],0,slpos-1))
11 netmask=compl(2**(32-int(substr(ARGV[1],slpos+1)))-1)
16 network=and(ipaddr,netmask)
17 broadcast=or(network,compl(netmask))
19 start=or(network,and(ip2int(ARGV[3]),compl(netmask)))
21 if (start<limit) start=limit
24 limit=or(network,compl(netmask))-1
25 if (end>limit) end=limit
27 print "IP="int2ip(ipaddr)
28 print "NETMASK="int2ip(netmask)
29 print "BROADCAST="int2ip(broadcast)
30 print "NETWORK="int2ip(network)
31 print "PREFIX="32-bitcount(compl(netmask))
34 # ipcalc <ip> <netmask> <start> <num>
37 print "START="int2ip(start)
38 print "END="int2ip(end)