Date: Fri, 12 Feb 2016 01:12:44 +0000 (UTC) From: Devin Teske <dteske@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r295553 - head/share/examples/jails Message-ID: <201602120112.u1C1CibJ084749@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dteske Date: Fri Feb 12 01:12:44 2016 New Revision: 295553 URL: https://svnweb.freebsd.org/changeset/base/295553 Log: Refactor conversion to hex Modified: head/share/examples/jails/jib head/share/examples/jails/jng Modified: head/share/examples/jails/jib ============================================================================== --- head/share/examples/jails/jib Fri Feb 12 00:03:39 2016 (r295552) +++ head/share/examples/jails/jib Fri Feb 12 01:12:44 2016 (r295553) @@ -214,25 +214,19 @@ derive_mac() # unique value preventing conflict. # __iface_devid=$( ifconfig $__iface ether | awk '/ether/,$0=$2' ) - __new_devid=${__iface_devid#??:??:??} - # :II:II:II => S:II:II:II + # ??:??:??:II:II:II + __new_devid=${__iface_devid#??:??:??} # => :II:II:II + # => :SS:SS:II:II:II __num=$( set -- `echo -n "$__name" | sum` && echo $1 ) - __new_devid=$( printf %x $(( $__num & 15 )) )$__new_devid - # S:II:II:II => :SS:II:II:II - __num=$(( $__num >> 4 )) - __new_devid=:$( printf %x $(( $__num & 15 )) )$__new_devid - # :SS:II:II:II => S:SS:II:II:II - __num=$(( $__num >> 4 )) - __new_devid=$( printf %x $(( $__num & 15 )) )$__new_devid - # S:SS:II:II:II => :SS:SS:II:II:II - __new_devid=:$( printf %x $(( $__num & 15 )) )$__new_devid - # :SS:SS:II:II:II => P:SS:SS:II:II:II + __new_devid=$( printf :%02x:%02x \ + $(( $__num >> 8 & 255 )) $(( $__num & 255 )) )$__new_devid + # => P:SS:SS:II:II:II case "$__iface_devid" in ?2:*) __new_devid=a$__new_devid __new_devid_b=e$__new_devid ;; ?[Ee]:*) __new_devid=2$__new_devid __new_devid_b=6$__new_devid ;; *) __new_devid=2$__new_devid __new_devid_b=e$__new_devid esac - # P:SS:SS:II:II:II => NP:SS:SS:II:II:II + # => NP:SS:SS:II:II:II __new_devid=$( printf %x $(( $__mac_num & 15 )) )$__new_devid __new_devid_b=$( printf %x $(( $__mac_num & 15 )) )$__new_devid_b Modified: head/share/examples/jails/jng ============================================================================== --- head/share/examples/jails/jng Fri Feb 12 00:03:39 2016 (r295552) +++ head/share/examples/jails/jng Fri Feb 12 01:12:44 2016 (r295553) @@ -216,25 +216,19 @@ derive_mac() # unique value preventing conflict. # __iface_devid=$( ifconfig $__iface ether | awk '/ether/,$0=$2' ) - __new_devid=${__iface_devid#??:??:??} - # :II:II:II => S:II:II:II + # ??:??:??:II:II:II + __new_devid=${__iface_devid#??:??:??} # => :II:II:II + # => :SS:SS:II:II:II __num=$( set -- `echo -n "$__name" | sum` && echo $1 ) - __new_devid=$( printf %x $(( $__num & 15 )) )$__new_devid - # S:II:II:II => :SS:II:II:II - __num=$(( $__num >> 4 )) - __new_devid=:$( printf %x $(( $__num & 15 )) )$__new_devid - # :SS:II:II:II => S:SS:II:II:II - __num=$(( $__num >> 4 )) - __new_devid=$( printf %x $(( $__num & 15 )) )$__new_devid - # S:SS:II:II:II => :SS:SS:II:II:II - __new_devid=:$( printf %x $(( $__num & 15 )) )$__new_devid - # :SS:SS:II:II:II => P:SS:SS:II:II:II + __new_devid=$( printf :%02x:%02x \ + $(( $__num >> 8 & 255 )) $(( $__num & 255 )) )$__new_devid + # => P:SS:SS:II:II:II case "$__iface_devid" in ?2:*) __new_devid=a$__new_devid __new_devid_b=e$__new_devid ;; ?[Ee]:*) __new_devid=2$__new_devid __new_devid_b=6$__new_devid ;; *) __new_devid=2$__new_devid __new_devid_b=e$__new_devid esac - # P:SS:SS:II:II:II => NP:SS:SS:II:II:II + # => NP:SS:SS:II:II:II __new_devid=$( printf %x $(( $__mac_num & 15 )) )$__new_devid __new_devid_b=$( printf %x $(( $__mac_num & 15 )) )$__new_devid_b
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201602120112.u1C1CibJ084749>