3 # Copyright (c) 2003 The FreeBSD Project. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE PROJECT ``AS IS'' AND ANY EXPRESS OR
15 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 # IN NO EVENT SHALL THE PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT,
18 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 # $FreeBSD: src/etc/rc.d/netif,v 1.2 2003/06/29 05:34:41 mtm Exp $
26 # $DragonFly: src/etc/rc.d/netif,v 1.8 2008/07/06 23:56:32 thomas Exp $
30 # REQUIRE: atm1 ipfilter mountcritlocal serial sppp sysctl tty
36 start_cmd
="network_start"
37 stop_cmd
="network_stop"
38 cloneup_cmd
="clone_up"
39 clonedown_cmd
="clone_down"
40 extra_commands
="cloneup clonedown"
45 # Set the list of interfaces to work on.
49 if [ -z "$_cmdifn" ]; then
51 # We're operating as a general network start routine.
54 # Create cloned interfaces
57 # Create IPv6<-->IPv4 tunnels
64 # Configure the interface(s).
65 network_common ifn_start verbose
67 # Give our interfaces a little time to come up
68 # before we start pounding them. In particular, dhclient
69 # and named can get mightily confused.
73 /etc
/rc.d
/ipfilter resync
78 # Set the list of interfaces to work on.
82 echo -n "Stopping network:"
84 # Deconfigure the interface(s)
85 network_common ifn_stop
89 # network_common routine verbose
90 # Common configuration subroutine for network interfaces. This
91 # routine takes all the preparatory steps needed for configuring
92 # an interface and then calls $routine. If $verbose is specified,
93 # it will call ifconfig(8) to show, in long format, the configured
94 # interfaces. If $verbose is not given, it will simply output the
95 # configured interface(s).
102 err
1 "network_common(): No function name specified."
106 [ -n "$2" ] && _verbose
=yes
108 # Get a list of network interfaces.
109 _ifn_list
="`list_net_interfaces`"
111 # Set the scope of the command (all interfaces or just one).
114 if [ -n "$_cmdifn" ]; then
115 for i
in $_cmdifn ; do
116 eval _if
=\"`expr "$_ifn_list" : ".*\(${i}\).*"`\"
117 if [ -z "$_if" ]; then
118 err
1 "No such network interface: $i"
120 _cooked_list
="$_cooked_list $_if"
123 _cooked_list
="$_ifn_list"
126 for ifn
in ${_cooked_list}; do
127 if ${_func} ${ifn} ; then
134 # Display interfaces configured by this script
136 for ifn
in ${_cooked_list}; do
137 eval showstat
=\
$showstat_${ifn}
138 if [ ! -z ${showstat} ]; then
139 if [ -n "$_verbose" ]; then
146 debug
"The following interfaces were not configured: $_fail"
155 [ -z "$ifn" ] && return 1
157 ifscript_up
${ifn} && cfg
=0
158 ifconfig_up
${ifn} && cfg
=0
159 ifalias_up
${ifn} && cfg
=0
160 ipx_up
${ifn} && cfg
=0
171 [ -z "$ifn" ] && return 1
173 ipx_down
${ifn} && cfg
=0
174 ifalias_down
${ifn} && cfg
=0
175 ifconfig_down
${ifn} && cfg
=0
176 ifscript_down
${ifn} && cfg
=0