Commit 200f2c79 authored by Mike Hibler's avatar Mike Hibler

Stay away from arithmetic to compute the IP address/mask for sysctl,

the 'one-true-awk' version of awk, botches the calculations when the
values get close to MAXINT.  Instead, just create a hex string since
sysctl knows about hex numbers.
parent 9667d915
#/bin/sh -
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -19,15 +19,20 @@ else
BINDIR=/etc/testbed
fi
#
# Grotesque sed/awk converts IP addrs into an integer for sysctl
# XXX update: only semi-grotesque now, we convert to hex strings since
# BSD sysctl takes hex numbers (and one-true-awk botches integers close
# to MAXINT)!
#
IPODINFO=`$BINDIR/tmcc ipodinfo`
if [ x"$IPODINFO" != x ]; then
IPODHOST=`echo $IPODINFO | \
sed -e 's/.*HOST=\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \2 \3 \4/' | \
awk '{ printf "%d\n", $1*16777216+$2*65536+$3*256+$4 }'`
awk '{ printf "0x%02x%02x%02x%02x\n", $1, $2, $3, $4 }'`
IPODMASK=`echo $IPODINFO | \
sed -e 's/.*MASK=\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \2 \3 \4/' | \
awk '{ printf "%d\n", $1*16777216+$2*65536+$3*256+$4 }'`
awk '{ printf "0x%02x%02x%02x%02x\n", $1, $2, $3, $4 }'`
IPODKEY=`echo $IPODINFO | \
sed -e 's/.*HASH=\(.*\)/\1/'`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment