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 ipv4_up ${ifn} && cfg=0
48 ipv6_up ${ifn} && cfg=0
49 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 ipx_down ${ifn} && cfg=0
68 ipv6_down ${ifn} && cfg=0
69 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
90 ifconfig_args=`ifconfig_getargs $1`
91 if [ -n "${ifconfig_args}" ]; then
92 ifconfig $1 ${ifconfig_args}
97 if afexists inet6; then
99 if checkyesno ipv6_gateway_enable; then
100 _ipv6_opts="-accept_rtadv"
103 if checkyesno ipv6_activate_all_interfaces; then
104 _ipv6_opts="-ifdisabled"
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"
117 if [ -n "${_ipv6_opts}" ]; then
118 ifconfig $1 inet6 ${_ipv6_opts}
122 ifconfig_args=`ifconfig_getargs $1 ipv6`
123 if [ -n "${ifconfig_args}" ]; then
124 ifconfig $1 inet6 -ifdisabled
125 ifconfig $1 ${ifconfig_args}
129 # backward compatiblity: $ipv6_ifconfig_IF
130 ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF`
131 if [ -n "${ifconfig_args}" ]; then
132 warn "\$ipv6_ifconfig_$1 is obsolete." \
133 " Use ifconfig_$1_ipv6 instead."
134 ifconfig $1 inet6 -ifdisabled
135 ifconfig $1 inet6 ${ifconfig_args}
140 if [ ${_cfg} -eq 0 ]; then
145 /etc/rc.d/wpa_supplicant start $1
146 _cfg=0 # XXX: not sure this should count
150 if [ $_cfg -ne 0 ] ; then
153 if syncdhcpif $1; then
154 /etc/rc.d/dhclient start $1
163 # returns 1 if wpa_supplicant or dhclient was stopped or
164 # the interface exists.
172 /etc/rc.d/wpa_supplicant stop $1
177 /etc/rc.d/dhclient stop $1
189 # get_if_var if var [default]
190 # Return the value of the pseudo-hash corresponding to $if where
191 # $var is a string containg the sub-string "IF" which will be
192 # replaced with $if after the characters defined in _punct are
193 # replaced with '_'. If the variable is unset, replace it with
197 local _if _punct _punct_c _var _default prefix suffix
199 if [ $# -ne 2 -a $# -ne 3 ]; then
200 err 3 'USAGE: get_if_var name var [default]'
205 for _punct_c in $_punct; do
206 _if=`ltr ${_if} ${_punct_c} '_'`
213 eval echo \${${prefix}${_if}${suffix}-${_default}}
216 # _ifconfig_getargs if [af]
217 # Echos the arguments for the supplied interface to stdout.
218 # returns 1 if empty. In general, ifconfig_getargs should be used
226 if [ -z "$_ifn" ]; then
230 get_if_var $_ifn ifconfig_IF$_af "$ifconfig_DEFAULT"
233 # ifconfig_getargs if [af]
234 # Takes the result from _ifconfig_getargs and removes pseudo
235 # args such as DHCP and WPA.
238 local _tmpargs _arg _args
239 _tmpargs=`_ifconfig_getargs $1 $2`
240 if [ $? -eq 1 ]; then
245 for _arg in $_tmpargs; do
248 [Nn][Oo][Aa][Uu][Tt][Oo]) ;;
249 [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) ;;
250 [Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) ;;
262 # Returns 0 if the interface should be automaticly configured at
263 # boot time and 1 otherwise.
267 _tmpargs=`_ifconfig_getargs $1`
269 for _arg in $_tmpargs; do
271 [Nn][Oo][Aa][Uu][Tt][Oo])
281 # Returns 0 if the interface is a DHCP interface and 1 otherwise.
285 _tmpargs=`_ifconfig_getargs $1`
287 for _arg in $_tmpargs; do
292 [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp])
295 [Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp])
305 # Returns 0 if the interface should be configured synchronously and
310 _tmpargs=`_ifconfig_getargs $1`
312 for _arg in $_tmpargs; do
314 [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp])
317 [Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp])
323 checkyesno synchronous_dhclient
327 # Returns 0 if the interface is a WPA interface and 1 otherwise.
331 _tmpargs=`_ifconfig_getargs $1`
333 for _arg in $_tmpargs; do
345 # Returns 0 if the address family is enabled in the kernel
354 ${SYSCTL_N} net.inet > /dev/null 2>&1
357 ${SYSCTL_N} net.inet6 > /dev/null 2>&1
360 ${SYSCTL_N} net.ipx > /dev/null 2>&1
363 if [ -x /sbin/atmconfig ]; then
364 /sbin/atmconfig diag list > /dev/null 2>&1
370 err 1 "afexists(): Unsupported address family: $_af"
376 # Returns 0 if the interface has no af configuration and 1 otherwise.
403 # Returns 0 if the interface should be configured for IPv6 and
410 if ! afexists inet6; then
414 # lo0 is always IPv6-enabled
421 case "${ipv6_network_interfaces}" in
422 $_if|"$_if "*|*" $_if"|*" $_if "*|[Aa][Uu][Tt][Oo])
423 # True if $ifconfig_IF_ipv6 is defined.
424 _tmpargs=`_ifconfig_getargs $_if ipv6`
425 if [ -n "${_tmpargs}" ]; then
429 # backward compatibility: True if $ipv6_ifconfig_IF is defined.
430 _tmpargs=`get_if_var $_if ipv6_ifconfig_IF`
431 if [ -n "${_tmpargs}" ]; then
441 # Returns 0 if the interface should be configured for IPv6 with
442 # Stateless Address Configuration, 1 otherwise.
445 local _if _tmpargs _arg
460 if ! ipv6if $_if; then
463 if checkyesno ipv6_gateway_enable; then
466 _tmpargs=`get_if_var $_if ipv6_prefix_IF`
467 if [ -n "${_tmpargs}" ]; then
470 # backward compatibility: $ipv6_enable
472 [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
477 _tmpargs=`_ifconfig_getargs $_if ipv6`
478 for _arg in $_tmpargs; do
486 # backward compatibility: $ipv6_ifconfig_IF
487 _tmpargs=`get_if_var $_if ipv6_ifconfig_IF`
488 for _arg in $_tmpargs; do
500 # Returns 0 if the interface exists and 1 otherwise.
503 [ -z "$1" ] && return 1
504 ifconfig -n $1 > /dev/null 2>&1
508 # add IPv4 addresses to the interface $if
515 ifalias_up ${_if} inet && _ret=0
516 ipv4_addrs_common ${_if} alias && _ret=0
522 # add IPv6 addresses to the interface $if
529 if ! ipv6if $_if; then
533 ifalias_up ${_if} inet6 && _ret=0
534 ipv6_prefix_hostid_addr_up ${_if} && _ret=0
535 ipv6_accept_rtadv_up ${_if} && _ret=0
538 sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
545 # remove IPv4 addresses from the interface $if
548 local _if _ifs _ret inetList oldifs _inet
553 inetList="`ifconfig ${_if} | grep 'inet ' | tr "\n" "$_ifs"`"
557 for _inet in $inetList ; do
558 # get rid of extraneous line
559 [ -z "$_inet" ] && break
561 _inet=`expr "$_inet" : '.*\(inet \([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*'`
564 ifconfig ${_if} ${_inet} delete
570 ifalias_down ${_if} inet && _ret=0
571 ipv4_addrs_common ${_if} -alias && _ret=0
577 # remove IPv6 addresses from the interface $if
580 local _if _ifs _ret inetList oldifs _inet6
585 if ! ipv6if $_if; then
589 ipv6_accept_rtadv_down ${_if} && _ret=0
590 ifalias_down ${_if} inet6 && _ret=0
592 inetList="`ifconfig ${_if} | grep 'inet6 ' | tr "\n" "$_ifs"`"
596 for _inet6 in $inetList ; do
597 # get rid of extraneous line
598 [ -z "$_inet6" ] && break
600 _inet6=`expr "$_inet6" : '.*\(inet6 \([0-9a-f:]*\)\).*'`
603 ifconfig ${_if} ${_inet6} -alias
612 # ipv4_addrs_common if action
613 # Evaluate the ifconfig_if_ipv4 arguments for interface $if and
614 # use $action to add or remove IPv4 addresses from $if.
617 local _ret _if _action _cidr _cidr_addr
618 local _ipaddr _netmask _range _ipnet _iplow _iphigh _ipcount
624 cidr_addr=`get_if_var $_if ipv4_addrs_IF`
626 for _cidr in ${cidr_addr}; do
628 _netmask="/"${_cidr##*/}
629 _range=${_ipaddr##*.}
634 # clear netmask when removing aliases
635 if [ "${_action}" = "-alias" ]; then
640 while [ "${_ipcount}" -le "${_iphigh}" ]; do
641 eval "ifconfig ${_if} ${_action} ${_ipnet}.${_ipcount}${_netmask}"
642 _ipcount=$((${_ipcount}+1))
645 # only the first ipaddr in a subnet need the real netmask
646 if [ "${_action}" != "-alias" ]; then
656 # Configure aliases for network interface $if.
657 # It returns 0 if at least one alias was configured or
658 # 1 if there were none.
667 _ret=`ifalias_ipv4_up "$1"`
670 _ret=`ifalias_ipv6_up "$1"`
678 # Helper function for ifalias_up(). Handles IPv4.
682 local _ret alias ifconfig_args
685 # ifconfig_IF_aliasN which starts with "inet"
688 ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
689 case "${ifconfig_args}" in
691 ifconfig $1 ${ifconfig_args} alias && _ret=0
697 alias=$((${alias} + 1))
704 # Helper function for ifalias_up(). Handles IPv6.
708 local _ret alias ifconfig_args
711 # ifconfig_IF_aliasN which starts with "inet6"
714 ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
715 case "${ifconfig_args}" in
717 ifconfig $1 ${ifconfig_args} alias && _ret=0
723 alias=$((${alias} + 1))
726 # backward compatibility: ipv6_ifconfig_IF_aliasN.
729 ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF_alias${alias}`
730 case "${ifconfig_args}" in
735 ifconfig $1 inet6 ${ifconfig_args} alias && _ret=0
736 warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete." \
737 " Use ifconfig_$1_aliasN instead."
740 alias=$((${alias} + 1))
747 # Remove aliases for network interface $if.
748 # It returns 0 if at least one alias was removed or
749 # 1 if there were none.
758 _ret=`ifalias_ipv4_down "$1"`
761 _ret=`ifalias_ipv6_down "$1"`
768 # ifalias_ipv4_down if
769 # Helper function for ifalias_down(). Handles IPv4.
773 local _ret alias ifconfig_args
776 # ifconfig_IF_aliasN which starts with "inet"
779 ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
780 case "${ifconfig_args}" in
782 ifconfig $1 ${ifconfig_args} -alias && _ret=0
788 alias=$((${alias} + 1))
794 # ifalias_ipv6_down if
795 # Helper function for ifalias_down(). Handles IPv6.
799 local _ret alias ifconfig_args
802 # ifconfig_IF_aliasN which starts with "inet6"
805 ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
806 case "${ifconfig_args}" in
808 ifconfig $1 ${ifconfig_args} -alias && _ret=0
814 alias=$((${alias} + 1))
817 # backward compatibility: ipv6_ifconfig_IF_aliasN.
820 ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF_alias${alias}`
821 case "${ifconfig_args}" in
826 ifconfig $1 inet6 ${ifconfig_args} -alias && _ret=0
827 warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete." \
828 " Use ifconfig_$1_aliasN instead."
831 alias=$((${alias} + 1))
837 # ipv6_prefix_hostid_addr_up if
838 # add IPv6 prefix + hostid addr to the interface $if
839 ipv6_prefix_hostid_addr_up()
841 local _if prefix laddr hostid j address
843 prefix=`get_if_var ${_if} ipv6_prefix_IF`
845 if [ -n "${prefix}" ]; then
846 laddr=`network6_getladdr ${_if}`
847 hostid=${laddr#fe80::}
850 for j in ${prefix}; do
851 address=$j\:${hostid}
852 ifconfig ${_if} inet6 ${address} prefixlen 64 alias
854 # if I am a router, add subnet router
855 # anycast address (RFC 2373).
856 if checkyesno ipv6_gateway_enable; then
857 ifconfig ${_if} inet6 $j:: prefixlen 64 \
864 # ipv6_accept_rtadv_up if
865 # Enable accepting Router Advertisement and send Router
866 # Solicitation message
867 ipv6_accept_rtadv_up()
869 if ipv6_autoconfif $1; then
870 ifconfig $1 inet6 accept_rtadv up
871 if ! checkyesno rtsold_enable; then
872 rtsol ${rtsol_flags} $1
877 # ipv6_accept_rtadv_down if
878 # Disable accepting Router Advertisement
879 ipv6_accept_rtadv_down()
881 if ipv6_autoconfif $1; then
882 ifconfig $1 inet6 -accept_rtadv
887 # Evaluate a startup script for the $if interface.
888 # It returns 0 if a script was found and processed or
889 # 1 if no script was found.
893 if [ -r /etc/start_if.$1 ]; then
902 # Evaluate a shutdown script for the $if interface.
903 # It returns 0 if a script was found and processed or
904 # 1 if no script was found.
908 if [ -r /etc/stop_if.$1 ]; then
917 # Create cloneable interfaces.
921 local _prefix _list ifn
926 for ifn in ${cloned_interfaces}; do
927 ifconfig ${ifn} create `get_if_var ${ifn} create_args_IF`
928 if [ $? -eq 0 ]; then
929 _list="${_list}${_prefix}${ifn}"
930 [ -z "$_prefix" ] && _prefix=' '
933 debug "Cloned: ${_list}"
937 # Destroy cloned interfaces. Destroyed interfaces are echoed to
942 local _prefix _list ifn
946 for ifn in ${cloned_interfaces}; do
947 ifconfig -n ${ifn} destroy
948 if [ $? -eq 0 ]; then
949 _list="${_list}${_prefix}${ifn}"
950 [ -z "$_prefix" ] && _prefix=' '
953 debug "Destroyed clones: ${_list}"
957 # Create and configure child interfaces. Return 0 if child
958 # interfaces are created.
962 local cfg child child_vlans child_wlans create_args debug_flags ifn i
966 # Create wireless interfaces
967 child_wlans=`get_if_var $ifn wlans_IF`
969 for child in ${child_wlans}; do
970 create_args="wlandev $ifn `get_if_var $child create_args_IF`"
971 debug_flags="`get_if_var $child wlandebug_IF`"
973 if expr $child : 'wlan[0-9][0-9]*$' >/dev/null 2>&1; then
974 ifconfig $child create ${create_args} && cfg=0
975 if [ -n "${debug_flags}" ]; then
976 wlandebug -i $child ${debug_flags}
979 i=`ifconfig wlan create ${create_args}`
980 if [ -n "${debug_flags}" ]; then
981 wlandebug -i $i ${debug_flags}
983 ifconfig $i name $child && cfg=0
985 if autoif $child; then
990 # Create vlan interfaces
991 child_vlans=`get_if_var $ifn vlans_IF`
993 if [ -n "${child_vlans}" ]; then
997 for child in ${child_vlans}; do
998 if expr $child : '[1-9][0-9]*$' >/dev/null 2>&1; then
999 child="${ifn}.${child}"
1000 create_args=`get_if_var $child create_args_IF`
1001 ifconfig $child create ${create_args} && cfg=0
1003 create_args="vlandev $ifn `get_if_var $child create_args_IF`"
1004 if expr $child : 'vlan[0-9][0-9]*$' >/dev/null 2>&1; then
1005 ifconfig $child create ${create_args} && cfg=0
1007 i=`ifconfig vlan create ${create_args}`
1008 ifconfig $i name $child && cfg=0
1011 if autoif $child; then
1020 # Destroy child interfaces.
1024 local cfg child child_vlans child_wlans ifn
1027 child_wlans=`get_if_var $ifn wlans_IF`
1028 for child in ${child_wlans}; do
1029 if ! ifexists $child; then
1032 ifconfig -n $child destroy && cfg=0
1035 child_vlans=`get_if_var $ifn vlans_IF`
1036 for child in ${child_vlans}; do
1037 if expr $child : '[1-9][0-9]*$' >/dev/null 2>&1; then
1038 child="${ifn}.${child}"
1040 if ! ifexists $child; then
1043 ifconfig -n $child destroy && cfg=0
1050 # Create netgraph nodes.
1054 ngctl -f - 2> /dev/null <<EOF
1061 # Create netgraph nodes.
1067 ng_mkpeer $* | while read line; do
1068 t=`expr "${line}" : '.* name="\([a-z]*[0-9]*\)" .*'`
1069 if [ -n "${t}" ]; then
1077 # Create gif(4) tunnel interfaces.
1082 for i in ${gif_interfaces}; do
1083 peers=`get_if_var $i gifconfig_IF`
1089 if expr $i : 'gif[0-9][0-9]*$' >/dev/null 2>&1; then
1090 ifconfig $i create >/dev/null 2>&1
1092 gif=`ifconfig gif create`
1093 ifconfig $gif name $i
1095 ifconfig $i tunnel ${peers}
1103 # Configure Fast EtherChannel for interface $ifn. Returns 0 if
1104 # FEC arguments were found and configured; returns !0 otherwise.
1107 local req_iface iface bogus
1110 ngctl shutdown ${req_iface}: > /dev/null 2>&1
1114 iface=`ng_create_one fec dummy fec`
1115 if [ -z "${iface}" ]; then
1118 if [ "${iface}" = "${req_iface}" ]; then
1121 bogus="${bogus} ${iface}"
1124 for iface in ${bogus}; do
1125 ngctl shutdown ${iface}:
1130 # Create Fast EtherChannel interfaces.
1135 for i in ${fec_interfaces}; do
1137 for j in `get_if_var $i fecconfig_IF`; do
1143 ngctl msg ${i}: add_iface "\"${j}\""
1151 # Configure any IPX addresses for interface $ifn. Returns 0 if
1152 # IPX arguments were found and configured; returns 1 otherwise.
1160 ifconfig_args=`_ifconfig_getargs $ifn ipx`
1161 if [ -n "${ifconfig_args}" ]; then
1162 ifconfig ${ifn} ${ifconfig_args}
1170 # Remove IPX addresses for interface $ifn. Returns 0 if IPX
1171 # addresses were found and unconfigured. It returns 1, otherwise.
1175 local _if _ifs _ret ipxList oldifs _ipx
1179 ipxList="`ifconfig ${_if} | grep 'ipx ' | tr "\n" "$_ifs"`"
1183 for _ipx in $ipxList ; do
1184 # get rid of extraneous line
1185 [ -z "$_ipx" ] && break
1187 _ipx=`expr "$_ipx" : '.*\(ipx [0-9a-h]\{1,8\}H*\.[0-9a-h]\{1,12\}\).*'`
1190 ifconfig ${_if} ${_ipx} delete
1200 # Rename all requested interfaces.
1207 for _if in `ifconfig -l`; do
1208 _ifname=`get_if_var $_if ifconfig_IF_name`
1209 if [ ! -z "$_ifname" ]; then
1210 ifconfig $_if name $_ifname
1217 # list_net_interfaces type
1218 # List all network interfaces. The type of interface returned
1219 # can be controlled by the type argument. The type
1220 # argument can be any of the following:
1221 # nodhcp - all interfaces, excluding DHCP configured interfaces
1222 # dhcp - list only DHCP configured interfaces
1223 # noautoconf - all interfaces, excluding IPv6 Stateless
1224 # Address Autoconf configured interfaces
1225 # autoconf - list only IPv6 Stateless Address Autoconf
1226 # configured interfaces
1227 # If no argument is specified all network interfaces are output.
1228 # Note that the list will include cloned interfaces if applicable.
1229 # Cloned interfaces must already exist to have a chance to appear
1230 # in the list if ${network_interfaces} is set to `auto'.
1232 list_net_interfaces()
1234 local type _tmplist _list _autolist _lo _if
1237 # Get a list of ALL the interfaces and make lo0 first if it's there.
1240 case ${network_interfaces} in
1242 _autolist="`ifconfig -l`"
1244 for _if in ${_autolist} ; do
1245 if autoif $_if; then
1246 if [ "$_if" = "lo0" ]; then
1249 _tmplist="${_tmplist} ${_if}"
1253 _tmplist="${_lo}${_tmplist# }"
1256 _tmplist="${network_interfaces} ${cloned_interfaces}"
1258 # lo0 is effectively mandatory, so help prevent foot-shooting
1261 lo0|'lo0 '*|*' lo0'|*' lo0 '*) ;; # This is fine, do nothing
1262 *) _tmplist="lo0 ${_tmplist}" ;;
1270 for _if in ${_tmplist} ; do
1271 if ! dhcpif $_if && \
1272 [ -n "`_ifconfig_getargs $_if`" ]; then
1273 _list="${_list# } ${_if}"
1278 for _if in ${_tmplist} ; do
1279 if dhcpif $_if; then
1280 _list="${_list# } ${_if}"
1285 for _if in ${_tmplist} ; do
1286 if ! ipv6_autoconfif $_if && \
1287 [ -n "`_ifconfig_getargs $_if ipv6`" ]; then
1288 _list="${_list# } ${_if}"
1293 for _if in ${_tmplist} ; do
1294 if ipv6_autoconfif $_if; then
1295 _list="${_list# } ${_if}"
1309 # get_default_if -address_family
1310 # Get the interface of the default route for the given address family.
1311 # The -address_family argument must be suitable passing to route(8).
1315 local routeget oldifs defif line
1320 for line in `route -n get $1 default 2>/dev/null`; do
1333 # Echo decimal number $arg (single digit) in hexadecimal format.
1336 if [ $1 -lt 10 ]; then
1351 # Echo decimal number $arg (multiple digits) in hexadecimal format.
1357 dig=`hexdigit $((${val} & 15))`
1359 val=$((${val} >> 4))
1361 while [ ${val} -gt 0 ]; do
1362 dig=`hexdigit $((${val} & 15))`
1364 val=$((${val} >> 4))
1370 is_wired_interface()
1374 case `ifconfig $1 2>/dev/null` in
1375 *media:?Ethernet*) media=Ethernet ;;
1378 test "$media" = "Ethernet"
1381 # network6_getladdr if [flag]
1382 # Echo link-local address from $if if any.
1383 # If flag is defined, tentative ones will be excluded.
1386 local proto addr rest
1387 ifconfig $1 2>/dev/null | while read proto addr rest; do
1392 if [ -z "$2" ]; then