Deleted Added
full compact
netif (175676) netif (178356)
1#!/bin/sh
2#
3# Copyright (c) 2003 The FreeBSD Project. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

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.
24#
1#!/bin/sh
2#
3# Copyright (c) 2003 The FreeBSD Project. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

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.
24#
25# $FreeBSD: head/etc/rc.d/netif 175676 2008-01-26 11:22:12Z mtm $
25# $FreeBSD: head/etc/rc.d/netif 178356 2008-04-20 20:37:21Z sam $
26#
27
28# PROVIDE: netif
29# REQUIRE: atm1 cleanvar ipfilter FILESYSTEMS serial sppp sysctl
30# KEYWORD: nojail
31
32. /etc/rc.subr
33. /etc/network.subr

--- 29 unchanged lines hidden (view full) ---

63 # Create IPv6<-->IPv4 tunnels
64 gif_up
65
66 # Rename interfaces.
67 ifnet_rename
68 fi
69
70 # Configure the interface(s).
26#
27
28# PROVIDE: netif
29# REQUIRE: atm1 cleanvar ipfilter FILESYSTEMS serial sppp sysctl
30# KEYWORD: nojail
31
32. /etc/rc.subr
33. /etc/network.subr

--- 29 unchanged lines hidden (view full) ---

63 # Create IPv6<-->IPv4 tunnels
64 gif_up
65
66 # Rename interfaces.
67 ifnet_rename
68 fi
69
70 # Configure the interface(s).
71 network_common ifn_start verbose
71 network_common ifn_start
72
73 if [ -f /etc/rc.d/ipfilter ] ; then
74 # Resync ipfilter
75 /etc/rc.d/ipfilter quietresync
76 fi
77 if [ -f /etc/rc.d/bridge -a -n "$cmdifn" ] ; then
78 /etc/rc.d/bridge start $cmdifn
79 fi

--- 7 unchanged lines hidden (view full) ---

87
88 echo -n "Stopping network:"
89
90 # Deconfigure the interface(s)
91 network_common ifn_stop
92 echo '.'
93}
94
72
73 if [ -f /etc/rc.d/ipfilter ] ; then
74 # Resync ipfilter
75 /etc/rc.d/ipfilter quietresync
76 fi
77 if [ -f /etc/rc.d/bridge -a -n "$cmdifn" ] ; then
78 /etc/rc.d/bridge start $cmdifn
79 fi

--- 7 unchanged lines hidden (view full) ---

87
88 echo -n "Stopping network:"
89
90 # Deconfigure the interface(s)
91 network_common ifn_stop
92 echo '.'
93}
94
95# network_common routine verbose
95# network_common routine
96# Common configuration subroutine for network interfaces. This
97# routine takes all the preparatory steps needed for configuriing
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).
98# an interface and then calls $routine.
102network_common()
103{
99network_common()
100{
104 local _cooked_list _fail _func _verbose
101 local _cooked_list _fail _func
105
106 _func=
102
103 _func=
107 _verbose=
108
109 if [ -z "$1" ]; then
110 err 1 "network_common(): No function name specified."
111 else
112 _func="$1"
113 fi
104
105 if [ -z "$1" ]; then
106 err 1 "network_common(): No function name specified."
107 else
108 _func="$1"
109 fi
114 [ -n "$2" ] && _verbose=yes
115
116 # Set the scope of the command (all interfaces or just one).
117 #
118 _cooked_list=
119 if [ -n "$cmdifn" ]; then
110
111 # Set the scope of the command (all interfaces or just one).
112 #
113 _cooked_list=
114 if [ -n "$cmdifn" ]; then
120 # Don't check that the interfaces exist. We need to run
115 # Don't check that the interface(s) exist. We need to run
121 # the down code even when the interface doesn't exist to
122 # kill off wpa_supplicant.
116 # the down code even when the interface doesn't exist to
117 # kill off wpa_supplicant.
118 # XXXBED: is this really true or does wpa_supplicant die?
119 # if so, we should get rid of the devd entry
123 _cooked_list="$cmdifn"
124 else
125 _cooked_list="`list_net_interfaces`"
126 fi
127
128 _fail=
129 for ifn in ${_cooked_list}; do
120 _cooked_list="$cmdifn"
121 else
122 _cooked_list="`list_net_interfaces`"
123 fi
124
125 _fail=
126 for ifn in ${_cooked_list}; do
130 if ${_func} ${ifn} ; then
131 eval showstat_$ifn=1
132 else
133 _fail="$_fail $ifn"
127 if ! ${_func} ${ifn} $2; then
128 _fail="${_fail} ${ifn}"
134 fi
135 done
136
129 fi
130 done
131
137 # Display interfaces configured by this script
138 #
139 for ifn in ${_cooked_list}; do
140 eval showstat=\$showstat_${ifn}
141 if [ ! -z ${showstat} ]; then
142 if [ -n "$_verbose" ]; then
143 ifconfig ${ifn}
144 else
145 echo -n " ${ifn}"
146 fi
147 fi
148 done
149 debug "The following interfaces were not configured: $_fail"
150}
151
132 debug "The following interfaces were not configured: $_fail"
133}
134
152ifn_start()
153{
154 local ifn cfg
155 ifn="$1"
156 cfg=1
157
158 [ -z "$ifn" ] && return 1
159
160 ifscript_up ${ifn} && cfg=0
161 ifconfig_up ${ifn} && cfg=0
162 ipv4_up ${ifn} && cfg=0
163 ipx_up ${ifn} && cfg=0
164
165 return $cfg
166}
167
168ifn_stop()
169{
170 local ifn cfg
171 ifn="$1"
172 cfg=1
173
174 [ -z "$ifn" ] && return 1
175
176 ipx_down ${ifn} && cfg=0
177 ipv4_down ${ifn} && cfg=0
178 ifconfig_down ${ifn} && cfg=0
179 ifscript_down ${ifn} && cfg=0
180
181 return $cfg
182}
183
184load_rc_config $name
185run_rc_command $*
135load_rc_config $name
136run_rc_command $*