oldnet: convert netmask to decimal numbers in _netmask2cidr

Free BSD's ifconfig outputs a netmask in the form 0xffffff00, which
was translating to 0xff.0xff.0xff.0x00,. Now we convert this to decimal
numbers before we convert it to cidr notation.

Reported-by: 4glitch@gmail.com
X-Gentoo-Bug: 460268
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=460268
This commit is contained in:
Yuta SATOH 2013-03-08 15:16:21 -06:00 committed by William Hubbs
parent 3b05586a73
commit f1ae8963c9

View File

@ -151,6 +151,9 @@ _netmask2cidr()
local i= len=
local IFS=.
for i in $1; do
case $i in
0x*) i=$((i)) ;;
esac
while [ ${i} -ne 0 ]; do
: $(( len += i % 2 ))
: $(( i >>= 1 ))