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.
29 # REQUIRE: atm1 cleanvar ipfilter FILESYSTEMS serial sppp sysctl
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 # disable SIGINT (Ctrl-c) when running at startup
57 # Create cloned interfaces
60 # Create Fast EtherChannel interfaces
63 # Create IPv6<-->IPv4 tunnels
70 # Configure the interface(s).
71 network_common ifn_start verbose
73 if [ -f /etc/rc.d/ipfilter ] ; then
75 /etc/rc.d/ipfilter resync
77 if [ -f /etc/rc.d/bridge -a -n "$cmdifn" ] ; then
78 /etc/rc.d/bridge start $cmdifn
84 # Set the list of interfaces to work on.
88 echo -n "Stopping network:"
90 # Deconfigure the interface(s)
91 network_common ifn_stop
95 # network_common routine verbose
96 # Common configuration subroutine for network interfaces. This
97 # routine takes all the preparatory steps needed for configuriing
98 # an interface and then calls $routine. If $verbose is specified,
99 # it will call ifconfig(8) to show, in long format, the configured
100 # interfaces. If $verbose is not given, it will simply output the
101 # configured interface(s).
104 local _cooked_list _fail _func _verbose
110 err 1 "network_common(): No function name specified."
114 [ -n "$2" ] && _verbose=yes
116 # Set the scope of the command (all interfaces or just one).
119 if [ -n "$cmdifn" ]; then
120 # Don't check that the interfaces exist. We need to run
121 # the down code even when the interface doesn't exist to
122 # kill off wpa_supplicant.
123 _cooked_list="$cmdifn"
125 _cooked_list="`list_net_interfaces`"
129 for ifn in ${_cooked_list}; do
130 if ${_func} ${ifn} ; then
137 # Display interfaces configured by this script
139 for ifn in ${_cooked_list}; do
140 eval showstat=\$showstat_${ifn}
141 if [ ! -z ${showstat} ]; then
142 if [ -n "$_verbose" ]; then
149 debug "The following interfaces were not configured: $_fail"
158 [ -z "$ifn" ] && return 1
160 ifscript_up ${ifn} && cfg=0
161 ifconfig_up ${ifn} && cfg=0
162 ipv4_up ${ifn} && cfg=0
163 ipx_up ${ifn} && cfg=0
174 [ -z "$ifn" ] && return 1
176 ipx_down ${ifn} && cfg=0
177 ipv4_down ${ifn} && cfg=0
178 ifconfig_down ${ifn} && cfg=0
179 ifscript_down ${ifn} && cfg=0