X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=package%2Fbase-files%2Ffiles%2Fbin%2Fipcalc.sh;h=9b5e5accdca8ca1c4198ae573240eb57e7e70448;hb=1481d5cb0b70d15edea607ed7cfc718c85166e98;hp=827cb5dc2ead717d9258dbba9e93841ffbdc5462;hpb=e9ac1b19e0f3d383ab83373c261bfb5527a29521;p=openwrt%2Fstaging%2Fhauke.git diff --git a/package/base-files/files/bin/ipcalc.sh b/package/base-files/files/bin/ipcalc.sh index 827cb5dc2e..9b5e5accdc 100755 --- a/package/base-files/files/bin/ipcalc.sh +++ b/package/base-files/files/bin/ipcalc.sh @@ -34,19 +34,19 @@ function compl32(v) { BEGIN { slpos=index(ARGV[1],"/") - if (slpos == 0) { - ipaddr=ip2int(ARGV[1]) - dotpos=index(ARGV[2],".") - if (dotpos == 0) - netmask=compl32(2**(32-int(ARGV[2]))-1) - else - netmask=ip2int(ARGV[2]) - } else { - ipaddr=ip2int(substr(ARGV[1],0,slpos-1)) - netmask=compl32(2**(32-int(substr(ARGV[1],slpos+1)))-1) + if (slpos != 0) { + # rearrange arguments to not use compound notation ARGV[4]=ARGV[3] ARGV[3]=ARGV[2] + ARGV[2]=substr(ARGV[1],slpos+1) + ARGV[1]=substr(ARGV[1],0,slpos-1) } + ipaddr=ip2int(ARGV[1]) + dotpos=index(ARGV[2],".") + if (dotpos == 0) + netmask=compl32(2**(32-int(ARGV[2]))-1) + else + netmask=ip2int(ARGV[2]) network=and(ipaddr,netmask) prefix=32-bitcount(compl32(netmask))