2 # Copyright (c) 2003 The FreeBSD Project. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
7 # 1. Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # 2. Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
13 # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
14 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
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
29 # Subroutines commonly used from network startup scripts.
30 # Requires that rc.conf be loaded first.
34 # Bring up and configure an interface. If some configuration is
35 # applied print the interface configuration.
43 [ -z "$ifn" ] && err 1 "ifn_start called without an interface"
45 ifscript_up ${ifn} && cfg=0
46 ifconfig_up ${ifn} && cfg=0
47 afexists inet && ipv4_up ${ifn} && cfg=0
48 afexists inet6 && ipv6_up ${ifn} && cfg=0
49 afexists ipx && ipx_up ${ifn} && cfg=0
50 childif_create ${ifn} && cfg=0
56 # Shutdown and de-configure an interface. If action is taken
57 # print the interface name.
65 [ -z "$ifn" ] && err 1 "ifn_stop called without an interface"
67 afexists ipx && ipx_down ${ifn} && cfg=0
68 afexists inet6 && ipv6_down ${ifn} && cfg=0
69 afexists inet && ipv4_down ${ifn} && cfg=0
70 ifconfig_down ${ifn} && cfg=0
71 ifscript_down ${ifn} && cfg=0
72 childif_destroy ${ifn} && cfg=0
78 # Evaluate ifconfig(8) arguments for interface $if and
79 # run ifconfig(8) with those arguments. It returns 0 if
80 # arguments were found and executed or 1 if the interface
81 # had no arguments. Pseudo arguments DHCP and WPA are handled
86 local _cfg _ipv6_opts ifconfig_args
89 # Make sure lo0 always comes up.
90 if [ "$1" = "lo0" ]; then
95 ifconfig_args=`ifconfig_getargs $1`
96 if [ -n "${ifconfig_args}" ]; then
97 eval ifconfig $1 ${ifconfig_args}
102 if afexists inet6; then
103 if checkyesno ipv6_activate_all_interfaces; then
104 _ipv6_opts="-ifdisabled"
105 elif [ "$1" != "lo0" ]; then
106 _ipv6_opts="ifdisabled"
109 # backward compatibility: $ipv6_enable
111 [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
112 _ipv6_opts="${_ipv6_opts} accept_rtadv"
116 if [ -n "${_ipv6_opts}" ]; then
117 ifconfig $1 inet6 ${_ipv6_opts}
121 ifconfig_args=`ifconfig_getargs $1 ipv6`
122 if [ -n "${ifconfig_args}" ]; then
123 ifconfig $1 inet6 -ifdisabled
124 ifconfig $1 ${ifconfig_args}
128 # backward compatiblity: $ipv6_ifconfig_IF
129 ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF`
130 if [ -n "${ifconfig_args}" ]; then
131 warn "\$ipv6_ifconfig_$1 is obsolete." \
132 " Use ifconfig_$1_ipv6 instead."
133 ifconfig $1 inet6 -ifdisabled
134 ifconfig $1 inet6 ${ifconfig_args}
139 if [ ${_cfg} -eq 0 ]; then
144 /etc/rc.d/wpa_supplicant start $1
145 _cfg=0 # XXX: not sure this should count
149 if [ $_cfg -ne 0 ] ; then
152 if syncdhcpif $1; then
153 /etc/rc.d/dhclient start $1
162 # returns 1 if wpa_supplicant or dhclient was stopped or
163 # the interface exists.
171 /etc/rc.d/wpa_supplicant stop $1
176 /etc/rc.d/dhclient stop $1
188 # get_if_var if var [default]
189 # Return the value of the pseudo-hash corresponding to $if where
190 # $var is a string containg the sub-string "IF" which will be
191 # replaced with $if after the characters defined in _punct are
192 # replaced with '_'. If the variable is unset, replace it with
196 local _if _punct _punct_c _var _default prefix suffix
198 if [ $# -ne 2 -a $# -ne 3 ]; then
199 err 3 'USAGE: get_if_var name var [default]'
204 for _punct_c in $_punct; do
205 _if=`ltr ${_if} ${_punct_c} '_'`
212 eval echo \${${prefix}${_if}${suffix}-${_default}}
215 # _ifconfig_getargs if [af]
216 # Echos the arguments for the supplied interface to stdout.
217 # returns 1 if empty. In general, ifconfig_getargs should be used
225 if [ -z "$_ifn" ]; then
229 get_if_var $_ifn ifconfig_IF$_af "$ifconfig_DEFAULT"
232 # ifconfig_getargs if [af]
233 # Takes the result from _ifconfig_getargs and removes pseudo
234 # args such as DHCP and WPA.
237 local _tmpargs _arg _args
238 _tmpargs=`_ifconfig_getargs $1 $2`
239 if [ $? -eq 1 ]; then
244 for _arg in $_tmpargs; do
247 [Nn][Oo][Aa][Uu][Tt][Oo]) ;;
248 [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) ;;
249 [Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) ;;
261 # Returns 0 if the interface should be automaticly configured at
262 # boot time and 1 otherwise.
266 _tmpargs=`_ifconfig_getargs $1`
268 for _arg in $_tmpargs; do
270 [Nn][Oo][Aa][Uu][Tt][Oo])
280 # Returns 0 if the interface is a DHCP interface and 1 otherwise.
284 _tmpargs=`_ifconfig_getargs $1`
286 for _arg in $_tmpargs; do
291 [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp])
294 [Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp])
304 # Returns 0 if the interface should be configured synchronously and
309 _tmpargs=`_ifconfig_getargs $1`
311 for _arg in $_tmpargs; do
313 [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp])
316 [Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp])
322 checkyesno synchronous_dhclient
326 # Returns 0 if the interface is a WPA interface and 1 otherwise.
330 _tmpargs=`_ifconfig_getargs $1`
332 for _arg in $_tmpargs; do
344 # Returns 0 if the address family is enabled in the kernel
353 check_kern_features ${_af}
356 ${SYSCTL_N} net.ipx > /dev/null 2>&1
359 if [ -x /sbin/atmconfig ]; then
360 /sbin/atmconfig diag list > /dev/null 2>&1
366 err 1 "afexists(): Unsupported address family: $_af"
372 # Returns 0 if the interface has no af configuration and 1 otherwise.
399 # Returns 0 if the interface should be configured for IPv6 and
406 if ! afexists inet6; then
410 # lo0 is always IPv6-enabled
417 case "${ipv6_network_interfaces}" in
418 $_if|"$_if "*|*" $_if"|*" $_if "*|[Aa][Uu][Tt][Oo])
419 # True if $ifconfig_IF_ipv6 is defined.
420 _tmpargs=`_ifconfig_getargs $_if ipv6`
421 if [ -n "${_tmpargs}" ]; then
425 # backward compatibility: True if $ipv6_ifconfig_IF is defined.
426 _tmpargs=`get_if_var $_if ipv6_ifconfig_IF`
427 if [ -n "${_tmpargs}" ]; then
437 # Returns 0 if the interface should be configured for IPv6 with
438 # Stateless Address Configuration, 1 otherwise.
441 local _if _tmpargs _arg
456 if ! ipv6if $_if; then
459 if checkyesno ipv6_gateway_enable; then
462 _tmpargs=`get_if_var $_if ipv6_prefix_IF`
463 if [ -n "${_tmpargs}" ]; then
466 # backward compatibility: $ipv6_enable
468 [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
473 _tmpargs=`_ifconfig_getargs $_if ipv6`
474 for _arg in $_tmpargs; do
482 # backward compatibility: $ipv6_ifconfig_IF
483 _tmpargs=`get_if_var $_if ipv6_ifconfig_IF`
484 for _arg in $_tmpargs; do
496 # Returns 0 if the interface exists and 1 otherwise.
499 [ -z "$1" ] && return 1
500 ifconfig -n $1 > /dev/null 2>&1
504 # add IPv4 addresses to the interface $if
511 # Add 127.0.0.1/8 to lo0 unless otherwise specified.
512 if [ "${_if}" = "lo0" ]; then
513 ifconfig_args=`ifconfig_getargs ${_if}`
514 if [ -z "${ifconfig_args}" ]; then
515 ifconfig ${_if} inet 127.0.0.1/8 alias
518 ifalias_up ${_if} inet && _ret=0
519 ipv4_addrs_common ${_if} alias && _ret=0
525 # add IPv6 addresses to the interface $if
532 if ! ipv6if $_if; then
536 ifalias_up ${_if} inet6 && _ret=0
537 ipv6_prefix_hostid_addr_up ${_if} && _ret=0
538 ipv6_accept_rtadv_up ${_if} && _ret=0
541 sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
548 # remove IPv4 addresses from the interface $if
551 local _if _ifs _ret inetList oldifs _inet
556 inetList="`ifconfig ${_if} | grep 'inet ' | tr "\n" "$_ifs"`"
560 for _inet in $inetList ; do
561 # get rid of extraneous line
562 [ -z "$_inet" ] && break
564 _inet=`expr "$_inet" : '.*\(inet \([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*'`
567 ifconfig ${_if} ${_inet} delete
573 ifalias_down ${_if} inet && _ret=0
574 ipv4_addrs_common ${_if} -alias && _ret=0
580 # remove IPv6 addresses from the interface $if
583 local _if _ifs _ret inetList oldifs _inet6
588 if ! ipv6if $_if; then
592 ipv6_accept_rtadv_down ${_if} && _ret=0
593 ifalias_down ${_if} inet6 && _ret=0
595 inetList="`ifconfig ${_if} | grep 'inet6 ' | tr "\n" "$_ifs"`"
599 for _inet6 in $inetList ; do
600 # get rid of extraneous line
601 [ -z "$_inet6" ] && break
603 _inet6=`expr "$_inet6" : '.*\(inet6 \([0-9a-f:]*\)\).*'`
606 ifconfig ${_if} ${_inet6} -alias
615 # ipv4_addrs_common if action
616 # Evaluate the ifconfig_if_ipv4 arguments for interface $if and
617 # use $action to add or remove IPv4 addresses from $if.
620 local _ret _if _action _cidr _cidr_addr
621 local _ipaddr _netmask _range _ipnet _iplow _iphigh _ipcount
627 cidr_addr=`get_if_var $_if ipv4_addrs_IF`
629 for _cidr in ${cidr_addr}; do
631 _netmask="/"${_cidr##*/}
632 _range=${_ipaddr##*.}
637 # clear netmask when removing aliases
638 if [ "${_action}" = "-alias" ]; then
643 while [ "${_ipcount}" -le "${_iphigh}" ]; do
644 eval "ifconfig ${_if} ${_action} ${_ipnet}.${_ipcount}${_netmask}"
645 _ipcount=$((${_ipcount}+1))
648 # only the first ipaddr in a subnet need the real netmask
649 if [ "${_action}" != "-alias" ]; then
659 # Configure aliases for network interface $if.
660 # It returns 0 if at least one alias was configured or
661 # 1 if there were none.
670 _ret=`ifalias_ipv4_up "$1"`
673 _ret=`ifalias_ipv6_up "$1"`
681 # Helper function for ifalias_up(). Handles IPv4.
685 local _ret alias ifconfig_args
688 # ifconfig_IF_aliasN which starts with "inet"
691 ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
692 case "${ifconfig_args}" in
694 ifconfig $1 ${ifconfig_args} alias && _ret=0
700 alias=$((${alias} + 1))
707 # Helper function for ifalias_up(). Handles IPv6.
711 local _ret alias ifconfig_args
714 # ifconfig_IF_aliasN which starts with "inet6"
717 ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
718 case "${ifconfig_args}" in
720 ifconfig $1 ${ifconfig_args} alias && _ret=0
726 alias=$((${alias} + 1))
729 # backward compatibility: ipv6_ifconfig_IF_aliasN.
732 ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF_alias${alias}`
733 case "${ifconfig_args}" in
738 ifconfig $1 inet6 ${ifconfig_args} alias && _ret=0
739 warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete." \
740 " Use ifconfig_$1_aliasN instead."
743 alias=$((${alias} + 1))
750 # Remove aliases for network interface $if.
751 # It returns 0 if at least one alias was removed or
752 # 1 if there were none.
761 _ret=`ifalias_ipv4_down "$1"`
764 _ret=`ifalias_ipv6_down "$1"`
771 # ifalias_ipv4_down if
772 # Helper function for ifalias_down(). Handles IPv4.
776 local _ret alias ifconfig_args
779 # ifconfig_IF_aliasN which starts with "inet"
782 ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
783 case "${ifconfig_args}" in
785 ifconfig $1 ${ifconfig_args} -alias && _ret=0
791 alias=$((${alias} + 1))
797 # ifalias_ipv6_down if
798 # Helper function for ifalias_down(). Handles IPv6.
802 local _ret alias ifconfig_args
805 # ifconfig_IF_aliasN which starts with "inet6"
808 ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
809 case "${ifconfig_args}" in
811 ifconfig $1 ${ifconfig_args} -alias && _ret=0
817 alias=$((${alias} + 1))
820 # backward compatibility: ipv6_ifconfig_IF_aliasN.
823 ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF_alias${alias}`
824 case "${ifconfig_args}" in
829 ifconfig $1 inet6 ${ifconfig_args} -alias && _ret=0
830 warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete." \
831 " Use ifconfig_$1_aliasN instead."
834 alias=$((${alias} + 1))
840 # ipv6_prefix_hostid_addr_up if
841 # add IPv6 prefix + hostid addr to the interface $if
842 ipv6_prefix_hostid_addr_up()
844 local _if prefix laddr hostid j address
846 prefix=`get_if_var ${_if} ipv6_prefix_IF`
848 if [ -n "${prefix}" ]; then
849 laddr=`network6_getladdr ${_if}`
850 hostid=${laddr#fe80::}
853 for j in ${prefix}; do
854 address=$j\:${hostid}
855 ifconfig ${_if} inet6 ${address} prefixlen 64 alias
857 # if I am a router, add subnet router
858 # anycast address (RFC 2373).
859 if checkyesno ipv6_gateway_enable; then
860 ifconfig ${_if} inet6 $j:: prefixlen 64 \
867 # ipv6_accept_rtadv_up if
868 # Enable accepting Router Advertisement and send Router
869 # Solicitation message
870 ipv6_accept_rtadv_up()
872 if ipv6_autoconfif $1; then
873 ifconfig $1 inet6 accept_rtadv up
874 if ! checkyesno rtsold_enable; then
875 rtsol ${rtsol_flags} $1
880 # ipv6_accept_rtadv_down if
881 # Disable accepting Router Advertisement
882 ipv6_accept_rtadv_down()
884 if ipv6_autoconfif $1; then
885 ifconfig $1 inet6 -accept_rtadv
890 # Evaluate a startup script for the $if interface.
891 # It returns 0 if a script was found and processed or
892 # 1 if no script was found.
896 if [ -r /etc/start_if.$1 ]; then
905 # Evaluate a shutdown script for the $if interface.
906 # It returns 0 if a script was found and processed or
907 # 1 if no script was found.
911 if [ -r /etc/stop_if.$1 ]; then
920 # Create cloneable interfaces.
924 local _prefix _list ifn
929 for ifn in ${cloned_interfaces}; do
930 ifconfig ${ifn} create `get_if_var ${ifn} create_args_IF`
931 if [ $? -eq 0 ]; then
932 _list="${_list}${_prefix}${ifn}"
933 [ -z "$_prefix" ] && _prefix=' '
936 debug "Cloned: ${_list}"
940 # Destroy cloned interfaces. Destroyed interfaces are echoed to
945 local _prefix _list ifn
949 for ifn in ${cloned_interfaces}; do
950 ifconfig -n ${ifn} destroy
951 if [ $? -eq 0 ]; then
952 _list="${_list}${_prefix}${ifn}"
953 [ -z "$_prefix" ] && _prefix=' '
956 debug "Destroyed clones: ${_list}"
960 # Create and configure child interfaces. Return 0 if child
961 # interfaces are created.
965 local cfg child child_vlans child_wlans create_args debug_flags ifn i
969 # Create wireless interfaces
970 child_wlans=`get_if_var $ifn wlans_IF`
972 for child in ${child_wlans}; do
973 create_args="wlandev $ifn `get_if_var $child create_args_IF`"
974 debug_flags="`get_if_var $child wlandebug_IF`"
976 if expr $child : 'wlan[0-9][0-9]*$' >/dev/null 2>&1; then
977 ifconfig $child create ${create_args} && cfg=0
978 if [ -n "${debug_flags}" ]; then
979 wlandebug -i $child ${debug_flags}
982 i=`ifconfig wlan create ${create_args}`
983 if [ -n "${debug_flags}" ]; then
984 wlandebug -i $i ${debug_flags}
986 ifconfig $i name $child && cfg=0
988 if autoif $child; then
993 # Create vlan interfaces
994 child_vlans=`get_if_var $ifn vlans_IF`
996 if [ -n "${child_vlans}" ]; then
1000 for child in ${child_vlans}; do
1001 if expr $child : '[1-9][0-9]*$' >/dev/null 2>&1; then
1002 child="${ifn}.${child}"
1003 create_args=`get_if_var $child create_args_IF`
1004 ifconfig $child create ${create_args} && cfg=0
1006 create_args="vlandev $ifn `get_if_var $child create_args_IF`"
1007 if expr $child : 'vlan[0-9][0-9]*$' >/dev/null 2>&1; then
1008 ifconfig $child create ${create_args} && cfg=0
1010 i=`ifconfig vlan create ${create_args}`
1011 ifconfig $i name $child && cfg=0
1014 if autoif $child; then
1023 # Destroy child interfaces.
1027 local cfg child child_vlans child_wlans ifn
1030 child_wlans=`get_if_var $ifn wlans_IF`
1031 for child in ${child_wlans}; do
1032 if ! ifexists $child; then
1035 ifconfig -n $child destroy && cfg=0
1038 child_vlans=`get_if_var $ifn vlans_IF`
1039 for child in ${child_vlans}; do
1040 if expr $child : '[1-9][0-9]*$' >/dev/null 2>&1; then
1041 child="${ifn}.${child}"
1043 if ! ifexists $child; then
1046 ifconfig -n $child destroy && cfg=0
1053 # Create netgraph nodes.
1057 ngctl -f - 2> /dev/null <<EOF
1064 # Create netgraph nodes.
1070 ng_mkpeer $* | while read line; do
1071 t=`expr "${line}" : '.* name="\([a-z]*[0-9]*\)" .*'`
1072 if [ -n "${t}" ]; then
1080 # Create gif(4) tunnel interfaces.
1085 for i in ${gif_interfaces}; do
1086 peers=`get_if_var $i gifconfig_IF`
1092 if expr $i : 'gif[0-9][0-9]*$' >/dev/null 2>&1; then
1093 ifconfig $i create >/dev/null 2>&1
1095 gif=`ifconfig gif create`
1096 ifconfig $gif name $i
1098 ifconfig $i tunnel ${peers}
1106 # Configure Fast EtherChannel for interface $ifn. Returns 0 if
1107 # FEC arguments were found and configured; returns !0 otherwise.
1110 local req_iface iface bogus
1113 ngctl shutdown ${req_iface}: > /dev/null 2>&1
1117 iface=`ng_create_one fec dummy fec`
1118 if [ -z "${iface}" ]; then
1121 if [ "${iface}" = "${req_iface}" ]; then
1124 bogus="${bogus} ${iface}"
1127 for iface in ${bogus}; do
1128 ngctl shutdown ${iface}:
1133 # Create Fast EtherChannel interfaces.
1138 for i in ${fec_interfaces}; do
1140 for j in `get_if_var $i fecconfig_IF`; do
1146 ngctl msg ${i}: add_iface "\"${j}\""
1154 # Configure any IPX addresses for interface $ifn. Returns 0 if
1155 # IPX arguments were found and configured; returns 1 otherwise.
1163 ifconfig_args=`_ifconfig_getargs $ifn ipx`
1164 if [ -n "${ifconfig_args}" ]; then
1165 ifconfig ${ifn} ${ifconfig_args}
1173 # Remove IPX addresses for interface $ifn. Returns 0 if IPX
1174 # addresses were found and unconfigured. It returns 1, otherwise.
1178 local _if _ifs _ret ipxList oldifs _ipx
1182 ipxList="`ifconfig ${_if} | grep 'ipx ' | tr "\n" "$_ifs"`"
1186 for _ipx in $ipxList ; do
1187 # get rid of extraneous line
1188 [ -z "$_ipx" ] && break
1190 _ipx=`expr "$_ipx" : '.*\(ipx [0-9a-h]\{1,8\}H*\.[0-9a-h]\{1,12\}\).*'`
1193 ifconfig ${_if} ${_ipx} delete
1203 # Rename all requested interfaces.
1210 for _if in `ifconfig -l`; do
1211 _ifname=`get_if_var $_if ifconfig_IF_name`
1212 if [ ! -z "$_ifname" ]; then
1213 ifconfig $_if name $_ifname
1220 # list_net_interfaces type
1221 # List all network interfaces. The type of interface returned
1222 # can be controlled by the type argument. The type
1223 # argument can be any of the following:
1224 # nodhcp - all interfaces, excluding DHCP configured interfaces
1225 # dhcp - list only DHCP configured interfaces
1226 # noautoconf - all interfaces, excluding IPv6 Stateless
1227 # Address Autoconf configured interfaces
1228 # autoconf - list only IPv6 Stateless Address Autoconf
1229 # configured interfaces
1230 # If no argument is specified all network interfaces are output.
1231 # Note that the list will include cloned interfaces if applicable.
1232 # Cloned interfaces must already exist to have a chance to appear
1233 # in the list if ${network_interfaces} is set to `auto'.
1235 list_net_interfaces()
1237 local type _tmplist _list _autolist _lo _if
1240 # Get a list of ALL the interfaces and make lo0 first if it's there.
1243 case ${network_interfaces} in
1245 _autolist="`ifconfig -l`"
1247 for _if in ${_autolist} ; do
1248 if autoif $_if; then
1249 if [ "$_if" = "lo0" ]; then
1252 _tmplist="${_tmplist} ${_if}"
1256 _tmplist="${_lo}${_tmplist# }"
1259 _tmplist="${network_interfaces} ${cloned_interfaces}"
1261 # lo0 is effectively mandatory, so help prevent foot-shooting
1264 lo0|'lo0 '*|*' lo0'|*' lo0 '*) ;; # This is fine, do nothing
1265 *) _tmplist="lo0 ${_tmplist}" ;;
1273 for _if in ${_tmplist} ; do
1274 if ! dhcpif $_if && \
1275 [ -n "`_ifconfig_getargs $_if`" ]; then
1276 _list="${_list# } ${_if}"
1281 for _if in ${_tmplist} ; do
1282 if dhcpif $_if; then
1283 _list="${_list# } ${_if}"
1288 for _if in ${_tmplist} ; do
1289 if ! ipv6_autoconfif $_if && \
1290 [ -n "`_ifconfig_getargs $_if ipv6`" ]; then
1291 _list="${_list# } ${_if}"
1296 for _if in ${_tmplist} ; do
1297 if ipv6_autoconfif $_if; then
1298 _list="${_list# } ${_if}"
1312 # get_default_if -address_family
1313 # Get the interface of the default route for the given address family.
1314 # The -address_family argument must be suitable passing to route(8).
1318 local routeget oldifs defif line
1323 for line in `route -n get $1 default 2>/dev/null`; do
1336 # Echo decimal number $arg (single digit) in hexadecimal format.
1343 # Echo decimal number $arg (multiple digits) in hexadecimal format.
1349 is_wired_interface()
1353 case `ifconfig $1 2>/dev/null` in
1354 *media:?Ethernet*) media=Ethernet ;;
1357 test "$media" = "Ethernet"
1360 # network6_getladdr if [flag]
1361 # Echo link-local address from $if if any.
1362 # If flag is defined, tentative ones will be excluded.
1365 local proto addr rest
1366 ifconfig $1 2>/dev/null | while read proto addr rest; do
1371 if [ -z "$2" ]; then