summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorsheldonh <sheldonh@FreeBSD.org>2001-11-19 11:41:51 +0000
committersheldonh <sheldonh@FreeBSD.org>2001-11-19 11:41:51 +0000
commit229073ca49f328f5c1885e34ab20461fa65a6ece (patch)
treeaa3953dbadb9b60d2ae2b1f76ca2b1e0a470bdc2 /etc
parentb7f75f85b51caba6ed741a5c6597eed7f44d1f14 (diff)
downloadFreeBSD-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')
-rw-r--r--etc/rc.d/network_ipv636
-rw-r--r--etc/rc.network636
2 files changed, 68 insertions, 4 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
diff --git a/etc/rc.network6 b/etc/rc.network6
index 99f6b32..1dc8473 100644
--- a/etc/rc.network6
+++ b/etc/rc.network6
@@ -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
OpenPOWER on IntegriCloud