2 # inet2hex - Internet address conversion, dotted-decimal to hex
11 if (( $# != 4 )); then
12 echo "inet2hex: incorrect input format: $1" >&2
13 echo "inet2hex: usage: inet2hex XX.XX.XX.XX" >&2
17 printf "0x%02x%02x%02x%02x\n" $1 $2 $3 $4
21 # hex2inet - Internet address conversion, hex to dotted-decimal
33 *) echo "hex2inet: usage: hex2inet [-r] [0x]XXXXXXXX" >&2 ; exit 2;;
36 shift $(( $OPTIND - 1 ))
43 if (( ${#h} != 8 )); then
44 echo "hex2inet: $h not in inet format" >&2
45 echo "hex2inet: usage: hex2inet [0x]XXXXXXXX" >&2
54 if [ -z "$rev" ] ; then
55 printf "%d.%d.%d.%d\n" $x1 $x2 $x3 $x4
57 printf "%d.%d.%d.%d\n" $x4 $x3 $x2 $x1