From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 868951381F3 for ; Wed, 7 Nov 2012 01:46:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 179B3E05F8; Wed, 7 Nov 2012 01:45:44 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 76E08E05F8 for ; Wed, 7 Nov 2012 01:45:43 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CD40933DCD9 for ; Wed, 7 Nov 2012 01:45:42 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 5DCE6E5442 for ; Wed, 7 Nov 2012 01:45:40 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1352247238.3809eac54d575d52d8793df38f826f1d7d7398fb.robbat2@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: net/ X-VCS-Repository: proj/openrc X-VCS-Files: net/ip6rd.sh X-VCS-Directories: net/ X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: 3809eac54d575d52d8793df38f826f1d7d7398fb X-VCS-Branch: master Date: Wed, 7 Nov 2012 01:45:40 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 8d1c42da-03f6-425a-a576-8f4c435cf5f5 X-Archives-Hash: b4f09444d4a498de51a89410870855ee commit: 3809eac54d575d52d8793df38f826f1d7d7398fb Author: Robin H. Johnson gentoo org> AuthorDate: Wed Nov 7 00:13:58 2012 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Wed Nov 7 00:13:58 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=3809eac5 net/iwconfig: Even more bashism fun. Signed-off-by: Robin H. Johnson gentoo.org> --- net/ip6rd.sh | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/net/ip6rd.sh b/net/ip6rd.sh index 03b5897..a35e2b7 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()