diff options
author | mtm <mtm@FreeBSD.org> | 2003-06-08 10:34:40 +0000 |
---|---|---|
committer | mtm <mtm@FreeBSD.org> | 2003-06-08 10:34:40 +0000 |
commit | 5e579c3a89371f65765b9e26f498a195df556c6b (patch) | |
tree | 71288887c51016c73c50081651e7ae73550fc00c /etc | |
parent | 1fa69e898906134d00985fe0607ff4d566800fde (diff) | |
download | FreeBSD-src-5e579c3a89371f65765b9e26f498a195df556c6b.zip FreeBSD-src-5e579c3a89371f65765b9e26f498a195df556c6b.tar.gz |
Implement *_down network routines for ifconfig'ed interfaces, cloned
interfaces, interface aliases, user supplied ifconfig scripts, and
ipx interfaces. The ipx routine fails unconditionaly at the moment.
Someone who has a need for it can fill it in with the appropriate incantations.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/network.subr | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/etc/network.subr b/etc/network.subr index 87800eb..85f4590 100644 --- a/etc/network.subr +++ b/etc/network.subr @@ -46,6 +46,35 @@ ifconfig_up() return 1 } +# ifconfig_down if +# Remove all inet entries from the $if interface. It returns +# 0 if inet entries were found and removed. It returns 1 if +# no entries were found or the could not be removed. +# +ifconfig_down() +{ + [ -z "$1" ] && return 1 + _ifs="^" + _ret=1 + + inetList="`ifconfig $1 | grep 'inet ' | tr "\n" "$_ifs"`" + + oldifs="$IFS" + IFS="$_ifs" + for _inet in $inetList ; do + # get rid of extraneous line + [ -z "$_inet" ] && break + + _inet=`expr "$_inet" : '.*\(inet \([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*'` + + echo ifconfig $1 ${_inet} delete + _ret=0 + done + IFS="$oldifs" + + return $_ret +} + # ifalias_up if # Configure aliases for network interface $if. # It returns 0 if at least one alias was configured or @@ -68,6 +97,28 @@ ifalias_up() return $_ret } +#ifalias_down if +# Remove aliases for network interface $if. +# It returns 0 if at least one alias was removed or +# 1 if there were none. +# +ifalias_down() +{ + _ret=1 + alias=0 + while : ; do + eval ifconfig_args=\$ifconfig_$1_alias${alias} + if [ -n "${ifconfig_args}" ]; then + ifconfig $1 ${ifconfig_args} -alias + alias=$((${alias} + 1)) + _ret=0 + else + break + fi + done + return $_ret +} + # ifscript_up if # Evaluate a startup script for the $if interface. # It returns 0 if a script was found and processed or @@ -82,6 +133,20 @@ ifscript_up() return 1 } +# ifscript_down if +# Evaluate a shutdown script for the $if interface. +# It returns 0 if a script was found and processed or +# 1 if no script was found. +# +ifscript_down() +{ + if [ -r /etc/stop_if.$1 ]; then + . /etc/stop_if.$1 + return 0 + fi + return 1 +} + # Create cloneable interfaces. # clone_up() @@ -153,6 +218,16 @@ ipx_up() return 1 } +# ipx_down ifn +# Remove IPX addresses for interface $ifn. Returns 0 if IPX +# addresses were found and unconfigured. It returns 1, otherwise. +# +ipx_down() +{ + # XXX - So, who's an IPX expert ? + return 1 +} + # # list_net_interfaces type # List all network interfaces. The type of interface returned |