From: Jo-Philipp Wich Date: Mon, 16 Dec 2013 16:29:23 +0000 (+0000) Subject: base-files: ipcalc.sh: support bit length as netmask parameter X-Git-Tag: reboot~8357 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=ef0ce72b39024942f236f81ab336d3a1b9269242;p=openwrt%2Fstaging%2Fblogic.git base-files: ipcalc.sh: support bit length as netmask parameter SVN-Revision: 39100 --- diff --git a/package/base-files/files/bin/ipcalc.sh b/package/base-files/files/bin/ipcalc.sh index 27a52d6f83d7..5d5eac3ea80b 100755 --- a/package/base-files/files/bin/ipcalc.sh +++ b/package/base-files/files/bin/ipcalc.sh @@ -31,7 +31,11 @@ BEGIN { slpos=index(ARGV[1],"/") if (slpos == 0) { ipaddr=ip2int(ARGV[1]) - netmask=ip2int(ARGV[2]) + 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)