Changeset View
Changeset View
Standalone View
Standalone View
libexec/rc/network.subr
Show First 20 Lines • Show All 704 Lines • ▼ Show 20 Lines | ipv4_down() | ||||
inetList="`${IFCONFIG_CMD} ${_if} | grep 'inet ' | tr "\n\t" "$_ifs"`" | inetList="`${IFCONFIG_CMD} ${_if} | grep 'inet ' | tr "\n\t" "$_ifs"`" | ||||
oldifs="$IFS" | oldifs="$IFS" | ||||
IFS="$_ifs" | IFS="$_ifs" | ||||
for _inet in $inetList ; do | for _inet in $inetList ; do | ||||
# get rid of extraneous line | # get rid of extraneous line | ||||
case $_inet in | case $_inet in | ||||
inet\ *) ;; | inet[[:space:]]*) ;; | ||||
*) continue ;; | *) continue ;; | ||||
esac | esac | ||||
_inet=`expr "$_inet" : '.*\(inet \([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*'` | _inet=`expr "$_inet" : '.*\(inet \([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*'` | ||||
IFS="$oldifs" | IFS="$oldifs" | ||||
${IFCONFIG_CMD} ${_if} ${_inet} delete | ${IFCONFIG_CMD} ${_if} ${_inet} delete | ||||
IFS="$_ifs" | IFS="$_ifs" | ||||
Show All 23 Lines | ipv6_down() | ||||
inetList="`${IFCONFIG_CMD} ${_if} | grep 'inet6 ' | tr "\n\t" "$_ifs"`" | inetList="`${IFCONFIG_CMD} ${_if} | grep 'inet6 ' | tr "\n\t" "$_ifs"`" | ||||
oldifs="$IFS" | oldifs="$IFS" | ||||
IFS="$_ifs" | IFS="$_ifs" | ||||
for _inet6 in $inetList ; do | for _inet6 in $inetList ; do | ||||
# get rid of extraneous line | # get rid of extraneous line | ||||
case $_inet6 in | case $_inet6 in | ||||
inet6\ *) ;; | inet6[[:space:]]*) ;; | ||||
*) continue ;; | *) continue ;; | ||||
esac | esac | ||||
_inet6=`expr "$_inet6" : '.*\(inet6 \([0-9a-f:]*\)\).*'` | _inet6=`expr "$_inet6" : '.*\(inet6 \([0-9a-f:]*\)\).*'` | ||||
IFS="$oldifs" | IFS="$oldifs" | ||||
${IFCONFIG_CMD} ${_if} ${_inet6} -alias | ${IFCONFIG_CMD} ${_if} ${_inet6} -alias | ||||
IFS="$_ifs" | IFS="$_ifs" | ||||
▲ Show 20 Lines • Show All 250 Lines • ▼ Show 20 Lines | ifalias_af_common_handler() | ||||
_ret=1 | _ret=1 | ||||
_if=$1 | _if=$1 | ||||
_af=$2 | _af=$2 | ||||
_action=$3 | _action=$3 | ||||
shift 3 | shift 3 | ||||
_args=$* | _args=$* | ||||
case $_args in | case $_args in | ||||
${_af}\ *) ;; | ${_af}[[:space:]]*) ;; | ||||
*) return ;; | *) return ;; | ||||
esac | esac | ||||
# link(ether) does not support address removal. | # link(ether) does not support address removal. | ||||
case $_af:$_action in | case $_af:$_action in | ||||
link:-alias|ether:-alias) return ;; | link:-alias|ether:-alias) return ;; | ||||
esac | esac | ||||
_tmpargs= | _tmpargs= | ||||
for _c in $_args; do | for _c in $_args; do | ||||
case $_c in | case $_c in | ||||
${_af}) | ${_af}) | ||||
case $_tmpargs in | case $_tmpargs in | ||||
${_af}\ *[0-9a-fA-F]-*) | ${_af}[[:space:]]*[0-9a-fA-F]-*) | ||||
ifalias_af_common_handler $_if $_af $_action \ | ifalias_af_common_handler $_if $_af $_action \ | ||||
`ifalias_expand_addr $_af $_action ${_tmpargs#${_af}\ }` | `ifalias_expand_addr $_af $_action ${_tmpargs#${_af}[[:space:]]}` | ||||
;; | ;; | ||||
${_af}\ *) | ${_af}[[:space:]]*) | ||||
${IFCONFIG_CMD} $_if $_tmpargs $_action && _ret=0 | ${IFCONFIG_CMD} $_if $_tmpargs $_action && _ret=0 | ||||
;; | ;; | ||||
esac | esac | ||||
_tmpargs=$_af | _tmpargs=$_af | ||||
;; | ;; | ||||
*) | *) | ||||
_tmpargs="$_tmpargs $_c" | _tmpargs="$_tmpargs $_c" | ||||
;; | ;; | ||||
esac | esac | ||||
done | done | ||||
# Process the last component if any. | # Process the last component if any. | ||||
if [ -n "$_tmpargs}" ]; then | if [ -n "$_tmpargs}" ]; then | ||||
case $_tmpargs in | case $_tmpargs in | ||||
${_af}\ *[0-9a-fA-F]-*) | ${_af}[[:space:]]*[0-9a-fA-F]-*) | ||||
ifalias_af_common_handler $_if $_af $_action \ | ifalias_af_common_handler $_if $_af $_action \ | ||||
`ifalias_expand_addr $_af $_action ${_tmpargs#${_af}\ }` | `ifalias_expand_addr $_af $_action ${_tmpargs#${_af}[[:space:]]}` | ||||
;; | ;; | ||||
${_af}\ *) | ${_af}[[:space:]]*) | ||||
${IFCONFIG_CMD} $_if $_tmpargs $_action && _ret=0 | ${IFCONFIG_CMD} $_if $_tmpargs $_action && _ret=0 | ||||
;; | ;; | ||||
esac | esac | ||||
fi | fi | ||||
return $_ret | return $_ret | ||||
} | } | ||||
Show All 16 Lines | ifalias_af_common() | ||||
# ifconfig_IF_aliasN which starts with $_af | # ifconfig_IF_aliasN which starts with $_af | ||||
for alias in `list_vars ifconfig_${_vif}_alias[0-9]\* | | for alias in `list_vars ifconfig_${_vif}_alias[0-9]\* | | ||||
sort_lite -nk1.$((9+${#_vif}+7))` | sort_lite -nk1.$((9+${#_vif}+7))` | ||||
do | do | ||||
eval ifconfig_args=\"\$$alias\" | eval ifconfig_args=\"\$$alias\" | ||||
_iaf= | _iaf= | ||||
case $ifconfig_args in | case $ifconfig_args in | ||||
inet\ *) _iaf=inet ;; | inet[[:space:]]*) _iaf=inet ;; | ||||
inet6\ *) _iaf=inet6 ;; | inet6[[:space:]]*) _iaf=inet6 ;; | ||||
link\ *) _iaf=link ;; | link[[:space:]]*) _iaf=link ;; | ||||
ether\ *) _iaf=ether ;; | ether[[:space:]]*) _iaf=ether ;; | ||||
esac | esac | ||||
case ${_af}:${_action}:${_iaf}:"${ifconfig_args}" in | case ${_af}:${_action}:${_iaf}:"${ifconfig_args}" in | ||||
${_af}:*:${_af}:*) | ${_af}:*:${_af}:*) | ||||
_aliasn="$_aliasn $ifconfig_args" | _aliasn="$_aliasn $ifconfig_args" | ||||
;; | ;; | ||||
${_af}:*:"":"") | ${_af}:*:"":"") | ||||
break | break | ||||
Show All 31 Lines | ifalias_af_common() | ||||
done | done | ||||
# Handle ifconfig_IF_aliases, ifconfig_IF_aliasN, and the others. | # Handle ifconfig_IF_aliases, ifconfig_IF_aliasN, and the others. | ||||
_tmpargs= | _tmpargs= | ||||
for _c in `get_if_var $_if ifconfig_IF_aliases` $_aliasn; do | for _c in `get_if_var $_if ifconfig_IF_aliases` $_aliasn; do | ||||
case $_c in | case $_c in | ||||
inet|inet6|link|ether) | inet|inet6|link|ether) | ||||
case $_tmpargs in | case $_tmpargs in | ||||
${_af}\ *) | ${_af}[[:space:]]*) | ||||
eval ifalias_af_common_handler $_if $_af $_action $_tmpargs && _ret=0 | eval ifalias_af_common_handler $_if $_af $_action $_tmpargs && _ret=0 | ||||
;; | ;; | ||||
esac | esac | ||||
_tmpargs=$_c | _tmpargs=$_c | ||||
;; | ;; | ||||
*) | *) | ||||
_tmpargs="$_tmpargs $_c" | _tmpargs="$_tmpargs $_c" | ||||
esac | esac | ||||
done | done | ||||
# Process the last component | # Process the last component | ||||
case $_tmpargs in | case $_tmpargs in | ||||
${_af}\ *) | ${_af}[[:space:]]*) | ||||
ifalias_af_common_handler $_if $_af $_action $_tmpargs && _ret=0 | ifalias_af_common_handler $_if $_af $_action $_tmpargs && _ret=0 | ||||
;; | ;; | ||||
esac | esac | ||||
return $_ret | return $_ret | ||||
} | } | ||||
# ipv6_prefix_hostid_addr_common if action | # ipv6_prefix_hostid_addr_common if action | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | wlan_up() | ||||
# Parse wlans_$parent="$child ..." | # Parse wlans_$parent="$child ..." | ||||
for parent in `set | sed -nE 's/wlans_([a-z]+[0-9]+)=.*/\1/p'`; do | for parent in `set | sed -nE 's/wlans_([a-z]+[0-9]+)=.*/\1/p'`; do | ||||
child_wlans=`get_if_var $parent wlans_IF` | child_wlans=`get_if_var $parent wlans_IF` | ||||
for child in ${child_wlans}; do | for child in ${child_wlans}; do | ||||
create_args="wlandev $parent `get_if_var $child create_args_IF`" | create_args="wlandev $parent `get_if_var $child create_args_IF`" | ||||
debug_flags="`get_if_var $child wlandebug_IF`" | debug_flags="`get_if_var $child wlandebug_IF`" | ||||
case $_iflist in | case $_iflist in | ||||
""|$child|$child\ *|*\ $child\ *|*\ $child) ;; | ""|$child|$child[[:space:]]*|*[[:space:]]$child[[:space:]]*|*[[:space:]]$child) ;; | ||||
*) continue ;; | *) continue ;; | ||||
esac | esac | ||||
# Skip if ${child} already exists. | # Skip if ${child} already exists. | ||||
if ${IFCONFIG_CMD} $child > /dev/null 2>&1; then | if ${IFCONFIG_CMD} $child > /dev/null 2>&1; then | ||||
continue | continue | ||||
fi | fi | ||||
if expr $child : 'wlan[0-9][0-9]*$' >/dev/null 2>&1; then | if expr $child : 'wlan[0-9][0-9]*$' >/dev/null 2>&1; then | ||||
${IFCONFIG_CMD} $child create ${create_args} && cfg=0 | ${IFCONFIG_CMD} $child create ${create_args} && cfg=0 | ||||
Show All 23 Lines | wlan_down() | ||||
_list= | _list= | ||||
_iflist=$* | _iflist=$* | ||||
# Parse wlans_$parent="$child ..." | # Parse wlans_$parent="$child ..." | ||||
for parent in `set | sed -nE 's/wlans_([a-z]+[0-9]+)=.*/\1/p'`; do | for parent in `set | sed -nE 's/wlans_([a-z]+[0-9]+)=.*/\1/p'`; do | ||||
child_wlans=`get_if_var $parent wlans_IF` | child_wlans=`get_if_var $parent wlans_IF` | ||||
for child in ${child_wlans}; do | for child in ${child_wlans}; do | ||||
case $_iflist in | case $_iflist in | ||||
""|$child|$child\ *|*\ $child\ *|*\ $child) ;; | ""|$child|$child[[:space:]]*|*[[:space:]]$child[[:space:]]*|*[[:space:]]$child) ;; | ||||
*) continue ;; | *) continue ;; | ||||
esac | esac | ||||
# Skip if ${child} doesn't exists. | # Skip if ${child} doesn't exists. | ||||
if ! ${IFCONFIG_CMD} $child > /dev/null 2>&1; then | if ! ${IFCONFIG_CMD} $child > /dev/null 2>&1; then | ||||
continue | continue | ||||
fi | fi | ||||
${IFCONFIG_CMD} -n ${child} destroy | ${IFCONFIG_CMD} -n ${child} destroy | ||||
if [ $? -eq 0 ]; then | if [ $? -eq 0 ]; then | ||||
Show All 16 Lines | clone_up() | ||||
_list= | _list= | ||||
_iflist=$* | _iflist=$* | ||||
# create_args_IF | # create_args_IF | ||||
for ifn in ${cloned_interfaces}; do | for ifn in ${cloned_interfaces}; do | ||||
# Parse ifn:ifopt. | # Parse ifn:ifopt. | ||||
OIFS=$IFS; IFS=:; set -- $ifn; ifn=$1; ifopt=$2; IFS=$OIFS | OIFS=$IFS; IFS=:; set -- $ifn; ifn=$1; ifopt=$2; IFS=$OIFS | ||||
case $_iflist in | case $_iflist in | ||||
""|$ifn|$ifn\ *|*\ $ifn\ *|*\ $ifn) ;; | ""|$ifn|$ifn[[:space:]]*|*[[:space:]]$ifn[[:space:]]*|*[[:space:]]$ifn) ;; | ||||
*) continue ;; | *) continue ;; | ||||
esac | esac | ||||
case $ifn in | case $ifn in | ||||
epair[0-9]*) | epair[0-9]*) | ||||
# epair(4) uses epair[0-9] for creation and | # epair(4) uses epair[0-9] for creation and | ||||
# epair[0-9][ab] for configuration. | # epair[0-9][ab] for configuration. | ||||
# | # | ||||
# Skip if ${ifn}a or ${ifn}b already exist. | # Skip if ${ifn}a or ${ifn}b already exist. | ||||
Show All 19 Lines | *) | ||||
_list="$_list $ifn" | _list="$_list $ifn" | ||||
fi | fi | ||||
esac | esac | ||||
done | done | ||||
for ifn in ${gif_interfaces}; do | for ifn in ${gif_interfaces}; do | ||||
# Parse ifn:ifopt. | # Parse ifn:ifopt. | ||||
OIFS=$IFS; IFS=:; set -- $ifn; ifn=$1; ifopt=$2; IFS=$OIFS | OIFS=$IFS; IFS=:; set -- $ifn; ifn=$1; ifopt=$2; IFS=$OIFS | ||||
case $_iflist in | case $_iflist in | ||||
""|$ifn|$ifn\ *|*\ $ifn\ *|*\ $ifn) ;; | ""|$ifn|$ifn[[:space:]]*|*[[:space:]]$ifn[[:space:]]*|*[[:space:]]$ifn) ;; | ||||
*) continue ;; | *) continue ;; | ||||
esac | esac | ||||
# Skip if ifn already exists. | # Skip if ifn already exists. | ||||
if ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then | if ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then | ||||
continue | continue | ||||
fi | fi | ||||
case $ifn in | case $ifn in | ||||
gif[0-9]*) | gif[0-9]*) | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | for ifn in ${cloned_interfaces} ${gif_interfaces}; do | ||||
# Parse ifn:ifopt. | # Parse ifn:ifopt. | ||||
OIFS=$IFS; IFS=:; set -- $ifn; ifn=$1; ifopt=$2; IFS=$OIFS | OIFS=$IFS; IFS=:; set -- $ifn; ifn=$1; ifopt=$2; IFS=$OIFS | ||||
case $ifopt:$_sticky in | case $ifopt:$_sticky in | ||||
sticky:*) continue ;; # :sticky => not destroy | sticky:*) continue ;; # :sticky => not destroy | ||||
nosticky:*) ;; # :nosticky => destroy | nosticky:*) ;; # :nosticky => destroy | ||||
*:1) continue ;; # global sticky knob == 1 | *:1) continue ;; # global sticky knob == 1 | ||||
esac | esac | ||||
case $_iflist in | case $_iflist in | ||||
""|$ifn|$ifn\ *|*\ $ifn\ *|*\ $ifn) ;; | ""|$ifn|$ifn[[:space:]]*|*[[:space:]]$ifn[[:space:]]*|*[[:space:]]$ifn) ;; | ||||
*) continue ;; | *) continue ;; | ||||
esac | esac | ||||
case $ifn in | case $ifn in | ||||
epair[0-9]*) | epair[0-9]*) | ||||
# Note: epair(4) uses epair[0-9] for removal and | # Note: epair(4) uses epair[0-9] for removal and | ||||
# epair[0-9][ab] for configuration. | # epair[0-9][ab] for configuration. | ||||
# | # | ||||
# Skip if both of ${ifn}a and ${ifn}b do not exist. | # Skip if both of ${ifn}a and ${ifn}b do not exist. | ||||
▲ Show 20 Lines • Show All 321 Lines • Show Last 20 Lines |