diff options
author | sheldonh <sheldonh@FreeBSD.org> | 2001-11-19 11:41:51 +0000 |
---|---|---|
committer | sheldonh <sheldonh@FreeBSD.org> | 2001-11-19 11:41:51 +0000 |
commit | 229073ca49f328f5c1885e34ab20461fa65a6ece (patch) | |
tree | aa3953dbadb9b60d2ae2b1f76ca2b1e0a470bdc2 /etc/rc.d | |
parent | b7f75f85b51caba6ed741a5c6597eed7f44d1f14 (diff) | |
download | FreeBSD-src-229073ca49f328f5c1885e34ab20461fa65a6ece.zip FreeBSD-src-229073ca49f328f5c1885e34ab20461fa65a6ece.tar.gz |
Use shell functions for printing hex instead of printf(1) so that
printf(1) can be dropped from the system shell as a shell builtin.
Diffstat (limited to 'etc/rc.d')
-rw-r--r-- | etc/rc.d/network_ipv6 | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/etc/rc.d/network_ipv6 b/etc/rc.d/network_ipv6 index 99f6b32..1dc8473 100644 --- a/etc/rc.d/network_ipv6 +++ b/etc/rc.d/network_ipv6 @@ -32,6 +32,37 @@ # first before contemplating any changes here. If you do need to change # this file for some reason, we would like to know about it. +hexdigit () { + if [ $1 -lt 10 ]; then + echo $1 + else + case $1 in + 10) echo a ;; + 11) echo b ;; + 12) echo c ;; + 13) echo d ;; + 14) echo e ;; + 15) echo f ;; + esac + fi +} + +hexprint () { + val=$1 + str='' + + dig=`hexdigit $((${val} & 15))` + str=${dig}${str} + val=$((${val} >> 4)) + while [ ${val} -gt 0 ]; do + dig=`hexdigit $((${val} & 15))` + str=${dig}${str} + val=$((${val} >> 4)) + done + + echo ${str} +} + # IPv6 startup network6_pass1() { @@ -336,8 +367,9 @@ network6_stf_setup() { IFS=".$IFS" set ${stf_interface_ipv4addr} IFS="$OIFS" - ipv4_in_hexformat=`printf "%x:%x\n" \ - $(($1*256 + $2)) $(($3*256 + $4))` + hexfrag1=`hexprint $(($1*256 + $2))` + hexfrag2=`hexprint $(($3*256 + $4))` + ipv4_in_hexformat="${hexfrag1}:${hexfrag2}" case ${stf_interface_ipv6_ifid} in [Aa][Uu][Tt][Oo] | '') for i in ${ipv6_network_interfaces}; do |