network.subr (263140) | network.subr (264243) |
---|---|
1# 2# Copyright (c) 2003 The FreeBSD Project. All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions 6# are met: 7# 1. Redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer. --- 8 unchanged lines hidden (view full) --- 17# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23# SUCH DAMAGE. 24# | 1# 2# Copyright (c) 2003 The FreeBSD Project. All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions 6# are met: 7# 1. Redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer. --- 8 unchanged lines hidden (view full) --- 17# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23# SUCH DAMAGE. 24# |
25# $FreeBSD: head/etc/network.subr 263140 2014-03-14 02:58:48Z glebius $ | 25# $FreeBSD: head/etc/network.subr 264243 2014-04-07 22:40:29Z dteske $ |
26# 27IFCONFIG_CMD="/sbin/ifconfig" 28 29# Maximum number of addresses expanded from a address range specification. 30_IPEXPANDMAX=31 31 32# 33# Subroutines commonly used from network startup scripts. --- 244 unchanged lines hidden (view full) --- 278{ 279 local _if _punct _punct_c _var _default prefix suffix 280 281 if [ $# -ne 2 -a $# -ne 3 ]; then 282 err 3 'USAGE: get_if_var name var [default]' 283 fi 284 285 _if=$1 | 26# 27IFCONFIG_CMD="/sbin/ifconfig" 28 29# Maximum number of addresses expanded from a address range specification. 30_IPEXPANDMAX=31 31 32# 33# Subroutines commonly used from network startup scripts. --- 244 unchanged lines hidden (view full) --- 278{ 279 local _if _punct _punct_c _var _default prefix suffix 280 281 if [ $# -ne 2 -a $# -ne 3 ]; then 282 err 3 'USAGE: get_if_var name var [default]' 283 fi 284 285 _if=$1 |
286 _punct=". - / +" 287 for _punct_c in $_punct; do 288 _if=`ltr ${_if} ${_punct_c} '_'` 289 done | 286 _punct=".-/+" 287 ltr ${_if} "${_punct}" '_' _if |
290 _var=$2 291 _default=$3 292 293 prefix=${_var%%IF*} 294 suffix=${_var##*IF} 295 eval echo \${${prefix}${_if}${suffix}-${_default}} 296} 297 --- 773 unchanged lines hidden (view full) --- 1071} 1072 1073# ifalias_af_common if af action 1074# Helper function for ifalias(). 1075# 1076ifalias_af_common() 1077{ 1078 local _ret _if _af _action alias ifconfig_args _aliasn _c _tmpargs _iaf | 288 _var=$2 289 _default=$3 290 291 prefix=${_var%%IF*} 292 suffix=${_var##*IF} 293 eval echo \${${prefix}${_if}${suffix}-${_default}} 294} 295 --- 773 unchanged lines hidden (view full) --- 1069} 1070 1071# ifalias_af_common if af action 1072# Helper function for ifalias(). 1073# 1074ifalias_af_common() 1075{ 1076 local _ret _if _af _action alias ifconfig_args _aliasn _c _tmpargs _iaf |
1077 local _punct=".-/+" |
|
1079 1080 _ret=1 1081 _aliasn= 1082 _if=$1 1083 _af=$2 1084 _action=$3 1085 | 1078 1079 _ret=1 1080 _aliasn= 1081 _if=$1 1082 _af=$2 1083 _action=$3 1084 |
1085 # Normalize $_if before using it in a pattern to list_vars() 1086 ltr "$_if" "$_punct" "_" _if 1087 |
|
1086 # ifconfig_IF_aliasN which starts with $_af | 1088 # ifconfig_IF_aliasN which starts with $_af |
1087 alias=0 1088 while : ; do 1089 ifconfig_args=`get_if_var $_if ifconfig_IF_alias${alias}` | 1089 for alias in `list_vars ifconfig_${_if}_alias[0-9]\* | 1090 sort_lite -nk1.$((9+${#_if}+7))` 1091 do 1092 eval ifconfig_args=\"\$$alias\" |
1090 _iaf= 1091 case $ifconfig_args in 1092 inet\ *) _iaf=inet ;; 1093 inet6\ *) _iaf=inet6 ;; 1094 link\ *) _iaf=link ;; 1095 ether\ *) _iaf=ether ;; 1096 esac 1097 --- 4 unchanged lines hidden (view full) --- 1102 ${_af}:*:"":"") 1103 break 1104 ;; 1105 inet:alias:"":*) 1106 _aliasn="$_aliasn inet $ifconfig_args" 1107 warn "\$ifconfig_${_if}_alias${alias} needs " \ 1108 "\"inet\" keyword for an IPv4 address." 1109 esac | 1093 _iaf= 1094 case $ifconfig_args in 1095 inet\ *) _iaf=inet ;; 1096 inet6\ *) _iaf=inet6 ;; 1097 link\ *) _iaf=link ;; 1098 ether\ *) _iaf=ether ;; 1099 esac 1100 --- 4 unchanged lines hidden (view full) --- 1105 ${_af}:*:"":"") 1106 break 1107 ;; 1108 inet:alias:"":*) 1109 _aliasn="$_aliasn inet $ifconfig_args" 1110 warn "\$ifconfig_${_if}_alias${alias} needs " \ 1111 "\"inet\" keyword for an IPv4 address." 1112 esac |
1110 alias=$(($alias + 1)) | |
1111 done 1112 1113 # backward compatibility: ipv6_ifconfig_IF_aliasN. 1114 case $_af in 1115 inet6) | 1113 done 1114 1115 # backward compatibility: ipv6_ifconfig_IF_aliasN. 1116 case $_af in 1117 inet6) |
1116 alias=0 1117 while : ; do 1118 ifconfig_args=`get_if_var $_if ipv6_ifconfig_IF_alias${alias}` | 1118 for alias in `list_vars ipv6_ifconfig_${_if}_alias[0-9]\* | 1119 sort_lite -nk1.$((14+${#_if}+7))` 1120 do 1121 eval ifconfig_args=\"\$$alias\" |
1119 case ${_action}:"${ifconfig_args}" in 1120 *:"") 1121 break 1122 ;; 1123 alias:*) 1124 _aliasn="${_aliasn} inet6 ${ifconfig_args}" 1125 warn "\$ipv6_ifconfig_${_if}_alias${alias} " \ 1126 "is obsolete. Use ifconfig_$1_aliasN " \ 1127 "instead." 1128 ;; 1129 esac | 1122 case ${_action}:"${ifconfig_args}" in 1123 *:"") 1124 break 1125 ;; 1126 alias:*) 1127 _aliasn="${_aliasn} inet6 ${ifconfig_args}" 1128 warn "\$ipv6_ifconfig_${_if}_alias${alias} " \ 1129 "is obsolete. Use ifconfig_$1_aliasN " \ 1130 "instead." 1131 ;; 1132 esac |
1130 alias=$(($alias + 1)) | |
1131 done 1132 esac 1133 1134 # backward compatibility: ipv4_addrs_IF. 1135 for _tmpargs in `get_if_var $_if ipv4_addrs_IF`; do 1136 _aliasn="$_aliasn inet $_tmpargs" 1137 done 1138 --- 581 unchanged lines hidden --- | 1133 done 1134 esac 1135 1136 # backward compatibility: ipv4_addrs_IF. 1137 for _tmpargs in `get_if_var $_if ipv4_addrs_IF`; do 1138 _aliasn="$_aliasn inet $_tmpargs" 1139 done 1140 --- 581 unchanged lines hidden --- |