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 # Implicitly handles ipv6_gateway_enable
100 _ipv6_opts='-ifdisabled -accept_rtadv'
102 if ipv6_autoconfif $1; then
103 _ipv6_opts='-ifdisabled accept_rtadv'
106 ifconfig $1 inet6 $_ipv6_opts
109 ifconfig_args=`ifconfig_getargs $1 ipv6`
111 if [ -n "$ifconfig_args" ]; then
112 ifconfig $1 $ifconfig_args
116 # Remove in FreeBSD 10.x
117 # Explicit test is necessary here to avoid nonexistence error
118 case "$ipv6_enable" in
119 [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
120 warn "Interface $1 will NOT be configured for IPv6"
124 ifconfig $1 inet6 ifdisabled
128 if [ ${_cfg} -eq 0 ]; then
133 /etc/rc.d/wpa_supplicant start $1
134 _cfg=0 # XXX: not sure this should count
138 if [ $_cfg -ne 0 ] ; then
141 if syncdhcpif $1; then
142 /etc/rc.d/dhclient start $1
151 # returns 1 if wpa_supplicant or dhclient was stopped or
152 # the interface exists.
160 /etc/rc.d/wpa_supplicant stop $1
165 /etc/rc.d/dhclient stop $1
177 # get_if_var if var [default]
178 # Return the value of the pseudo-hash corresponding to $if where
179 # $var is a string containg the sub-string "IF" which will be
180 # replaced with $if after the characters defined in _punct are
181 # replaced with '_'. If the variable is unset, replace it with
185 local _if _punct _punct_c _var _default prefix suffix
187 if [ $# -ne 2 -a $# -ne 3 ]; then
188 err 3 'USAGE: get_if_var name var [default]'
193 for _punct_c in $_punct; do
194 _if=`ltr ${_if} ${_punct_c} '_'`
201 eval echo \${${prefix}${_if}${suffix}-${_default}}
204 # _ifconfig_getargs if [af]
205 # Echos the arguments for the supplied interface to stdout.
206 # returns 1 if empty. In general, ifconfig_getargs should be used
214 if [ -z "$_ifn" ]; then
218 value=`get_if_var $_ifn ifconfig_IF$_af "$ifconfig_DEFAULT"`
220 # Remove in FreeBSD 10.x
221 if [ "$_af" = _ipv6 -a -z "$value" ]; then
222 value=`get_if_var $_ifn ipv6_ifconfig_IF "$ifconfig_DEFAULT"`
223 if [ -n "$value" ]; then
224 warn "\$ipv6_ifconfig_$1 is obsolete." \
225 " Use ifconfig_$1_ipv6 instead."
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]) ;;
251 [Rr][Tt][Aa][Dd][Vv]) ;;
252 [Nn][Oo][Rr][Tt][Aa][Dd][Vv]) ;;
263 # Returns 0 if the interface should be automaticly configured at
264 # boot time and 1 otherwise.
268 _tmpargs=`_ifconfig_getargs $1`
270 for _arg in $_tmpargs; do
272 [Nn][Oo][Aa][Uu][Tt][Oo])
282 # Returns 0 if the interface is a DHCP interface and 1 otherwise.
286 _tmpargs=`_ifconfig_getargs $1`
288 for _arg in $_tmpargs; do
293 [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp])
296 [Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp])
306 # Returns 0 if the interface should be configured synchronously and
311 _tmpargs=`_ifconfig_getargs $1`
313 for _arg in $_tmpargs; do
315 [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp])
318 [Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp])
324 checkyesno synchronous_dhclient
328 # Returns 0 if the interface is a WPA interface and 1 otherwise.
332 _tmpargs=`_ifconfig_getargs $1`
334 for _arg in $_tmpargs; do
346 # Returns 0 if the address family is enabled in the kernel
355 ${SYSCTL_N} net.inet > /dev/null 2>&1
358 ${SYSCTL_N} net.inet6 > /dev/null 2>&1
361 ${SYSCTL_N} net.ipx > /dev/null 2>&1
364 if [ -x /sbin/atmconfig ]; then
365 /sbin/atmconfig diag list > /dev/null 2>&1
371 err 1 "afexists(): Unsupported address family: $_af"
377 # Returns 0 if the interface should be configured for IPv6 and
381 if ! afexists inet6; then
385 # lo0 is always IPv6-enabled
395 case "$ipv6_network_interfaces" in
399 $_if|"$_if "*|*" $_if"|*" $_if "*|[Aa][Uu][Tt][Oo])
400 # True if $ifconfig_IF_ipv6 is defined.
401 _tmpargs=`_ifconfig_getargs $_if ipv6`
402 # Also true if ipv6_prefix_IF is defined
403 [ -n "$_tmpargs" ] || _tmpargs=`get_if_var $_if ipv6_prefix_IF`
407 if [ -n "$_tmpargs" ]; then
408 # Remove in FreeBSD 10.x
409 # Explicit test is necessary here to avoid nonexistence error
410 case "$ipv6_enable" in
411 [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
422 # Returns 0 if the interface should be configured for IPv6 with
423 # Stateless Address Configuration, 1 otherwise.
438 local _if _tmpargs _arg
441 if ! ipv6if $_if; then
444 if checkyesno ipv6_gateway_enable; then
447 _tmpargs=`get_if_var $_if ipv6_prefix_IF`
448 if [ -n "${_tmpargs}" ]; then
451 if ! is_wired_interface $_if; then
453 wlan[0-9]*) ;; # Allow test to continue
459 _tmpargs=`_ifconfig_getargs $_if ipv6`
461 *inet6\ *|*[Nn][Oo][Rr][Tt][Aa][Dd][Vv]*|*-accept_rtadv*)
464 *[Rr][Tt][Aa][Dd][Vv]*|*accept_rtadv*)
473 # Returns 0 if the interface exists and 1 otherwise.
476 [ -z "$1" ] && return 1
477 ifconfig -n $1 > /dev/null 2>&1
481 # add IPv4 addresses to the interface $if
488 ifalias_up ${_if} inet && _ret=0
489 ipv4_addrs_common ${_if} alias && _ret=0
495 # add IPv6 addresses to the interface $if
502 if ! ipv6if $_if; then
506 ifalias_up ${_if} inet6 && _ret=0
507 ipv6_prefix_hostid_addr_up ${_if} && _ret=0
508 ipv6_accept_rtadv_up ${_if} && _ret=0
511 sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
518 # remove IPv4 addresses from the interface $if
521 local _if _ifs _ret inetList oldifs _inet
526 inetList="`ifconfig ${_if} | grep 'inet ' | tr "\n" "$_ifs"`"
530 for _inet in $inetList ; do
531 # get rid of extraneous line
532 [ -z "$_inet" ] && break
534 _inet=`expr "$_inet" : '.*\(inet \([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*'`
537 ifconfig ${_if} ${_inet} delete
543 ifalias_down ${_if} inet && _ret=0
544 ipv4_addrs_common ${_if} -alias && _ret=0
550 # remove IPv6 addresses from the interface $if
553 local _if _ifs _ret inetList oldifs _inet6
558 if ! ipv6if $_if; then
562 ipv6_accept_rtadv_down ${_if} && _ret=0
563 ifalias_down ${_if} inet6 && _ret=0
565 inetList="`ifconfig ${_if} | grep 'inet6 ' | tr "\n" "$_ifs"`"
569 for _inet6 in $inetList ; do
570 # get rid of extraneous line
571 [ -z "$_inet6" ] && break
573 _inet6=`expr "$_inet6" : '.*\(inet6 \([0-9a-f:]*\)\).*'`
576 ifconfig ${_if} ${_inet6} -alias
585 # ipv4_addrs_common if action
586 # Evaluate the ifconfig_if_ipv4 arguments for interface $if and
587 # use $action to add or remove IPv4 addresses from $if.
590 local _ret _if _action _cidr _cidr_addr
591 local _ipaddr _netmask _range _ipnet _iplow _iphigh _ipcount
597 cidr_addr=`get_if_var $_if ipv4_addrs_IF`
599 for _cidr in ${cidr_addr}; do
601 _netmask="/"${_cidr##*/}
602 _range=${_ipaddr##*.}
607 # clear netmask when removing aliases
608 if [ "${_action}" = "-alias" ]; then
613 while [ "${_ipcount}" -le "${_iphigh}" ]; do
614 eval "ifconfig ${_if} ${_action} ${_ipnet}.${_ipcount}${_netmask}"
615 _ipcount=$((${_ipcount}+1))
618 # only the first ipaddr in a subnet need the real netmask
619 if [ "${_action}" != "-alias" ]; then
629 # Configure aliases for network interface $if.
630 # It returns 0 if at least one alias was configured or
631 # 1 if there were none.
640 _ret=`ifalias_ipv4_up "$1"`
643 _ret=`ifalias_ipv6_up "$1"`
651 # Helper function for ifalias_up(). Handles IPv4.
655 local _ret alias ifconfig_args
658 # ifconfig_IF_aliasN which starts with "inet"
661 ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
662 case "${ifconfig_args}" in
664 ifconfig $1 ${ifconfig_args} alias && _ret=0
670 alias=$((${alias} + 1))
677 # Helper function for ifalias_up(). Handles IPv6.
681 local _ret alias ifconfig_args
684 # ifconfig_IF_aliasN which starts with "inet6"
687 ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
688 case "${ifconfig_args}" in
690 ifconfig $1 ${ifconfig_args} alias && _ret=0
696 alias=$((${alias} + 1))
699 # backward compatibility: ipv6_ifconfig_IF_aliasN.
702 ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF_alias${alias}`
703 case "${ifconfig_args}" in
708 ifconfig $1 inet6 ${ifconfig_args} alias && _ret=0
709 warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete." \
710 " Use ifconfig_$1_aliasN instead."
713 alias=$((${alias} + 1))
720 # Remove aliases for network interface $if.
721 # It returns 0 if at least one alias was removed or
722 # 1 if there were none.
731 _ret=`ifalias_ipv4_down "$1"`
734 _ret=`ifalias_ipv6_down "$1"`
741 # ifalias_ipv4_down if
742 # Helper function for ifalias_down(). Handles IPv4.
746 local _ret alias ifconfig_args
749 # ifconfig_IF_aliasN which starts with "inet"
752 ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
753 case "${ifconfig_args}" in
755 ifconfig $1 ${ifconfig_args} -alias && _ret=0
761 alias=$((${alias} + 1))
767 # ifalias_ipv6_down if
768 # Helper function for ifalias_down(). Handles IPv6.
772 local _ret alias ifconfig_args
775 # ifconfig_IF_aliasN which starts with "inet6"
778 ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}`
779 case "${ifconfig_args}" in
781 ifconfig $1 ${ifconfig_args} -alias && _ret=0
787 alias=$((${alias} + 1))
790 # backward compatibility: ipv6_ifconfig_IF_aliasN.
793 ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF_alias${alias}`
794 case "${ifconfig_args}" in
799 ifconfig $1 inet6 ${ifconfig_args} -alias && _ret=0
800 warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete." \
801 " Use ifconfig_$1_aliasN instead."
804 alias=$((${alias} + 1))
810 # ipv6_prefix_hostid_addr_up if
811 # add IPv6 prefix + hostid addr to the interface $if
812 ipv6_prefix_hostid_addr_up()
814 local _if prefix laddr hostid j address
816 prefix=`get_if_var ${_if} ipv6_prefix_IF`
818 if [ -n "${prefix}" ]; then
819 laddr=`network6_getladdr ${_if}`
820 hostid=${laddr#fe80::}
823 for j in ${prefix}; do
824 address=$j\:${hostid}
825 ifconfig ${_if} inet6 ${address} prefixlen 64 alias
827 # if I am a router, add subnet router
828 # anycast address (RFC 2373).
829 if checkyesno ipv6_gateway_enable; then
830 ifconfig ${_if} inet6 $j:: prefixlen 64 \
837 # ipv6_accept_rtadv_up if
838 # Enable accepting Router Advertisement and send Router
839 # Solicitation message
840 ipv6_accept_rtadv_up()
842 if ipv6_autoconfif $1; then
843 ifconfig $1 inet6 accept_rtadv up
844 if ! checkyesno rtsold_enable; then
845 rtsol ${rtsol_flags} $1
850 # ipv6_accept_rtadv_down if
851 # Disable accepting Router Advertisement
852 ipv6_accept_rtadv_down()
854 if ipv6_autoconfif $1; then
855 ifconfig $1 inet6 -accept_rtadv
860 # Evaluate a startup script for the $if interface.
861 # It returns 0 if a script was found and processed or
862 # 1 if no script was found.
866 if [ -r /etc/start_if.$1 ]; then
875 # Evaluate a shutdown script for the $if interface.
876 # It returns 0 if a script was found and processed or
877 # 1 if no script was found.
881 if [ -r /etc/stop_if.$1 ]; then
890 # Create cloneable interfaces.
894 local _prefix _list ifn
899 for ifn in ${cloned_interfaces}; do
900 ifconfig ${ifn} create `get_if_var ${ifn} create_args_IF`
901 if [ $? -eq 0 ]; then
902 _list="${_list}${_prefix}${ifn}"
903 [ -z "$_prefix" ] && _prefix=' '
906 debug "Cloned: ${_list}"
910 # Destroy cloned interfaces. Destroyed interfaces are echoed to
915 local _prefix _list ifn
919 for ifn in ${cloned_interfaces}; do
920 ifconfig -n ${ifn} destroy
921 if [ $? -eq 0 ]; then
922 _list="${_list}${_prefix}${ifn}"
923 [ -z "$_prefix" ] && _prefix=' '
926 debug "Destroyed clones: ${_list}"
930 # Create and configure child interfaces. Return 0 if child
931 # interfaces are created.
935 local cfg child child_vlans child_wlans create_args debug_flags ifn i
939 # Create wireless interfaces
940 child_wlans=`get_if_var $ifn wlans_IF`
942 for child in ${child_wlans}; do
943 create_args="wlandev $ifn `get_if_var $child create_args_IF`"
944 debug_flags="`get_if_var $child wlandebug_IF`"
946 if expr $child : 'wlan[0-9][0-9]*$' >/dev/null 2>&1; then
947 ifconfig $child create ${create_args} && cfg=0
948 if [ -n "${debug_flags}" ]; then
949 wlandebug -i $child ${debug_flags}
952 i=`ifconfig wlan create ${create_args}`
953 if [ -n "${debug_flags}" ]; then
954 wlandebug -i $i ${debug_flags}
956 ifconfig $i name $child && cfg=0
958 if autoif $child; then
963 # Create vlan interfaces
964 child_vlans=`get_if_var $ifn vlans_IF`
966 if [ -n "${child_vlans}" ]; then
970 for child in ${child_vlans}; do
971 if expr $child : '[1-9][0-9]*$' >/dev/null 2>&1; then
972 child="${ifn}.${child}"
973 create_args=`get_if_var $child create_args_IF`
974 ifconfig $child create ${create_args} && cfg=0
976 create_args="vlandev $ifn `get_if_var $child create_args_IF`"
977 if expr $child : 'vlan[0-9][0-9]*$' >/dev/null 2>&1; then
978 ifconfig $child create ${create_args} && cfg=0
980 i=`ifconfig vlan create ${create_args}`
981 ifconfig $i name $child && cfg=0
984 if autoif $child; then
993 # Destroy child interfaces.
997 local cfg child child_vlans child_wlans ifn
1000 child_wlans=`get_if_var $ifn wlans_IF`
1001 for child in ${child_wlans}; do
1002 if ! ifexists $child; then
1005 ifconfig -n $child destroy && cfg=0
1008 child_vlans=`get_if_var $ifn vlans_IF`
1009 for child in ${child_vlans}; do
1010 if expr $child : '[1-9][0-9]*$' >/dev/null 2>&1; then
1011 child="${ifn}.${child}"
1013 if ! ifexists $child; then
1016 ifconfig -n $child destroy && cfg=0
1023 # Create netgraph nodes.
1027 ngctl -f - 2> /dev/null <<EOF
1034 # Create netgraph nodes.
1040 ng_mkpeer $* | while read line; do
1041 t=`expr "${line}" : '.* name="\([a-z]*[0-9]*\)" .*'`
1042 if [ -n "${t}" ]; then
1050 # Create gif(4) tunnel interfaces.
1055 for i in ${gif_interfaces}; do
1056 peers=`get_if_var $i gifconfig_IF`
1062 if expr $i : 'gif[0-9][0-9]*$' >/dev/null 2>&1; then
1063 ifconfig $i create >/dev/null 2>&1
1065 gif=`ifconfig gif create`
1066 ifconfig $gif name $i
1068 ifconfig $i tunnel ${peers}
1076 # Configure Fast EtherChannel for interface $ifn. Returns 0 if
1077 # FEC arguments were found and configured; returns !0 otherwise.
1080 local req_iface iface bogus
1083 ngctl shutdown ${req_iface}: > /dev/null 2>&1
1087 iface=`ng_create_one fec dummy fec`
1088 if [ -z "${iface}" ]; then
1091 if [ "${iface}" = "${req_iface}" ]; then
1094 bogus="${bogus} ${iface}"
1097 for iface in ${bogus}; do
1098 ngctl shutdown ${iface}:
1103 # Create Fast EtherChannel interfaces.
1108 for i in ${fec_interfaces}; do
1110 for j in `get_if_var $i fecconfig_IF`; do
1116 ngctl msg ${i}: add_iface "\"${j}\""
1124 # Configure any IPX addresses for interface $ifn. Returns 0 if
1125 # IPX arguments were found and configured; returns 1 otherwise.
1133 ifconfig_args=`_ifconfig_getargs $ifn ipx`
1134 if [ -n "${ifconfig_args}" ]; then
1135 ifconfig ${ifn} ${ifconfig_args}
1143 # Remove IPX addresses for interface $ifn. Returns 0 if IPX
1144 # addresses were found and unconfigured. It returns 1, otherwise.
1148 local _if _ifs _ret ipxList oldifs _ipx
1152 ipxList="`ifconfig ${_if} | grep 'ipx ' | tr "\n" "$_ifs"`"
1156 for _ipx in $ipxList ; do
1157 # get rid of extraneous line
1158 [ -z "$_ipx" ] && break
1160 _ipx=`expr "$_ipx" : '.*\(ipx [0-9a-h]\{1,8\}H*\.[0-9a-h]\{1,12\}\).*'`
1163 ifconfig ${_if} ${_ipx} delete
1173 # Rename all requested interfaces.
1180 for _if in `ifconfig -l`; do
1181 _ifname=`get_if_var $_if ifconfig_IF_name`
1182 if [ ! -z "$_ifname" ]; then
1183 ifconfig $_if name $_ifname
1190 # list_net_interfaces type
1191 # List all network interfaces. The type of interface returned
1192 # can be controlled by the type argument. The type
1193 # argument can be any of the following:
1194 # nodhcp - all interfaces, excluding DHCP configured interfaces
1195 # dhcp - list only DHCP configured interfaces
1196 # noautoconf - all interfaces, excluding IPv6 Stateless
1197 # Address Autoconf configured interfaces
1198 # autoconf - list only IPv6 Stateless Address Autoconf
1199 # configured interfaces
1200 # If no argument is specified all network interfaces are output.
1201 # Note that the list will include cloned interfaces if applicable.
1202 # Cloned interfaces must already exist to have a chance to appear
1203 # in the list if ${network_interfaces} is set to `auto'.
1205 list_net_interfaces()
1207 local type _tmplist _list _autolist _lo _if
1210 # Get a list of ALL the interfaces and make lo0 first if it's there.
1213 case ${network_interfaces} in
1215 _autolist="`ifconfig -l`"
1217 for _if in ${_autolist} ; do
1218 if autoif $_if; then
1219 if [ "$_if" = "lo0" ]; then
1222 _tmplist="${_tmplist} ${_if}"
1226 _tmplist="${_lo}${_tmplist# }"
1229 _tmplist="${network_interfaces} ${cloned_interfaces}"
1231 # lo0 is effectively mandatory, so help prevent foot-shooting
1234 lo0|'lo0 '*|*' lo0'|*' lo0 '*) ;; # This is fine, do nothing
1235 *) _tmplist="lo0 ${_tmplist}" ;;
1243 for _if in ${_tmplist} ; do
1244 if ! dhcpif $_if && \
1245 [ -n "`_ifconfig_getargs $_if`" ]; then
1246 _list="${_list# } ${_if}"
1251 for _if in ${_tmplist} ; do
1252 if dhcpif $_if; then
1253 _list="${_list# } ${_if}"
1258 for _if in ${_tmplist} ; do
1259 if ! ipv6_autoconfif $_if && \
1260 [ -n "`_ifconfig_getargs $_if ipv6`" ]; then
1261 _list="${_list# } ${_if}"
1266 for _if in ${_tmplist} ; do
1267 if ipv6_autoconfif $_if; then
1268 _list="${_list# } ${_if}"
1282 # get_default_if -address_family
1283 # Get the interface of the default route for the given address family.
1284 # The -address_family argument must be suitable passing to route(8).
1288 local routeget oldifs defif line
1293 for line in `route -n get $1 default 2>/dev/null`; do
1306 # Echo decimal number $arg (single digit) in hexadecimal format.
1309 if [ $1 -lt 10 ]; then
1324 # Echo decimal number $arg (multiple digits) in hexadecimal format.
1330 dig=`hexdigit $((${val} & 15))`
1332 val=$((${val} >> 4))
1334 while [ ${val} -gt 0 ]; do
1335 dig=`hexdigit $((${val} & 15))`
1337 val=$((${val} >> 4))
1343 is_wired_interface()
1347 case `ifconfig $1 2>/dev/null` in
1348 *media:?Ethernet*) media=Ethernet ;;
1351 test "$media" = "Ethernet"
1354 # network6_getladdr if [flag]
1355 # Echo link-local address from $if if any.
1356 # If flag is defined, tentative ones will be excluded.
1359 local proto addr rest
1360 ifconfig $1 2>/dev/null | while read proto addr rest; do
1365 if [ -z "$2" ]; then