aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2012-11-07 00:13:58 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2012-11-07 00:13:58 +0000
commit3809eac54d575d52d8793df38f826f1d7d7398fb (patch)
treee209c53ae049cc43900871f3573df1ba81f83e51 /net
parentdabd8b22ca2313e217cc26a4d30b72b777d771ac (diff)
net/iwconfig: Even more bashism fun.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Diffstat (limited to 'net')
-rw-r--r--net/ip6rd.sh19
1 files changed, 13 insertions, 6 deletions
diff --git a/net/ip6rd.sh b/net/ip6rd.sh
index 03b5897f..a35e2b76 100644
--- a/net/ip6rd.sh
+++ b/net/ip6rd.sh
@@ -117,27 +117,34 @@ _ip6rd_inet_atoi()
{
local IFS="${IFS}." ipi=0 j=3
for i in $1 ; do
- ipi=$(( ipi | i << 8*j-- ))
+ # post-decrement isn't valid
+ ipi=$(( ipi | (i << (8*j)) ))
+ j=$(( j - 1 ))
done
echo ${ipi}
}
_ip6rd_inet_itoa()
{
- local ipi=$1
+ local ipi=$1 bitmask v
+ bitmask=$(( (1 << 24)-1 ))
for i in 0 1 2 3; do
+ v=$(( (ipi & ~bitmask) >> 24 ))
+ ipi=$(( (ipi & bitmask) << 8 ))
if [ $i != 3 ] ; then
- printf "%d." $(( (ipi & ~((1<<24)-1)) >> 24 ))
- ipi=$(( (ipi & ((1<<24)-1)) << 8))
+ printf "%d." $v
else
- printf "%d\n" $(( (ipi & ~((1<<24)-1)) >> 24 ))
+ printf "%d\n" $v
fi
done
}
_ip6rd_inet_get_network()
{
- echo $(_ip6rd_inet_itoa $(( ($(_ip6rd_inet_atoi $1) & ((1<<$2)-1) << (32-$2) ) )) )
+ local a=$(_ip6rd_inet_atoi $1)
+ local net=$(( a & ( (1<<$2)-1 ) ))
+ local cidr=$(( 32 - $2 ))
+ echo $(_ip6rd_inet_itoa $(( (net << cidr ) )) )
}
_ip6rd_inet_is_private_network()