diff --git a/hyper-v.changes b/hyper-v.changes index aea2585..d5faa2d 100644 --- a/hyper-v.changes +++ b/hyper-v.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon May 26 15:50:21 CEST 2014 - ohering@suse.de + +- copy mask2pfxlen from /etc/sysconfig/network/scripts/functions + to hv_set_ifconfig (bnc#879256) + ------------------------------------------------------------------- Wed May 21 12:05:31 CEST 2014 - ohering@suse.de diff --git a/hyper-v.tools.hv.hv_set_ifconfig.sh b/hyper-v.tools.hv.hv_set_ifconfig.sh index e3ccd56..ae861d3 100644 --- a/hyper-v.tools.hv.hv_set_ifconfig.sh +++ b/hyper-v.tools.hv.hv_set_ifconfig.sh @@ -44,14 +44,37 @@ then fi # send subshell output to syslog ( -f=/etc/sysconfig/network/scripts/functions -if test -f ${f} -then - . ${f} -else - echo "MISSING ${f}" - exit 1 -fi +# copied from /etc/sysconfig/network/scripts/functions +mask2pfxlen() { + local i octet width=0 mask=(${1//./ }) + test ${#mask[@]} -eq 4 || return 1 + for octet in 0 1 2 3 + do + test "${mask[octet]}" -ge 0 -a "${mask[octet]}" -le 255 || return 1 + for i in 128 192 224 240 248 252 254 255 + do + test ${mask[octet]} -ge $i && ((width++)) + done + done + echo $width + return 0 +} + +pfxlen2mask() { + test -n "$1" || return 1 + local o i n=0 adr=() len=$(($1)) + for o in 0 1 2 3 + do + adr[$o]=0 + for i in 128 64 32 16 8 4 2 1 + do + ((n++ < len)) && ((adr[$o] = ${adr[$o]} + $i)) + done + done + echo ${adr[0]}.${adr[1]}.${adr[2]}.${adr[3]} + return 0 +} + # remove known config variables from environment unset HWADDR unset BOOTPROTO