From: Michael Tremer Date: Thu, 17 May 2012 15:30:26 +0000 (+0000) Subject: Merge remote-tracking branch 'ms/isdn' X-Git-Tag: 004~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f49dbacc0661882d427084020c5fbc2c497ec6d;p=network.git Merge remote-tracking branch 'ms/isdn' --- 6f49dbacc0661882d427084020c5fbc2c497ec6d diff --cc functions.ipv4 index 1220d491,65cdcf73..dff33e39 --- a/functions.ipv4 +++ b/functions.ipv4 @@@ -74,33 -80,20 +80,50 @@@ function ipv4_get_netaddress() return ${EXIT_OK} } +function ipv4_get_prefix() { + local address=${1} + local broadcast=${2} + + assert isset address + assert isset broadcast + + local PREFIX + eval $(ipcalc --prefix ${address} ${broadcast}) + assert isset PREFIX + + echo "${PREFIX}" + return ${EXIT_OK} +} + +function ipv4_flush_device() { + # + # Flushes all routes, addresses from the device + # and clears the ARP cache. + # + + local device=${1} + assert isset device + + ip -4 addr flush dev ${device} >/dev/null 2>&1 + ip -4 route flush dev ${device} >/dev/null 2>&1 + ip -4 neigh flush dev ${device} >/dev/null 2>&1 + + return 0 ++ + function ipv4_prefix2netmask() { + local prefix=${1} + shift + + assert isinteger prefix + + # XXX this function is a stub + + case "${prefix}" in + 24) + echo "255.255.255.0" + ;; + *) + assert false NOT IMPLEMENTED + ;; + esac }