netif (159138) | netif (165664) |
---|---|
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 159138 2006-06-01 11:01:54Z thompsa $ | 25# $FreeBSD: head/etc/rc.d/netif 165664 2006-12-30 22:53:20Z yar $ |
26# 27 28# PROVIDE: netif 29# REQUIRE: atm1 ipfilter mountcritlocal serial sppp sysctl 30# KEYWORD: nojail 31 32. /etc/rc.subr 33. /etc/network.subr 34 35name="network" 36start_cmd="network_start" 37stop_cmd="network_stop" 38cloneup_cmd="clone_up" 39clonedown_cmd="clone_down" 40extra_commands="cloneup clonedown" | 26# 27 28# PROVIDE: netif 29# REQUIRE: atm1 ipfilter mountcritlocal serial sppp sysctl 30# KEYWORD: nojail 31 32. /etc/rc.subr 33. /etc/network.subr 34 35name="network" 36start_cmd="network_start" 37stop_cmd="network_stop" 38cloneup_cmd="clone_up" 39clonedown_cmd="clone_down" 40extra_commands="cloneup clonedown" |
41_cmdifn= | 41cmdifn= |
42 43network_start() 44{ 45 # Set the list of interfaces to work on. 46 # | 42 43network_start() 44{ 45 # Set the list of interfaces to work on. 46 # |
47 _cmdifn=$* | 47 cmdifn=$* |
48 | 48 |
49 if [ -z "$_cmdifn" ]; then | 49 if [ -z "$cmdifn" ]; then |
50 # 51 # We're operating as a general network start routine. 52 # 53 54 # disable SIGINT (Ctrl-c) when running at startup 55 trap : 2 56 57 # Create cloned interfaces --- 8 unchanged lines hidden (view full) --- 66 67 # Configure the interface(s). 68 network_common ifn_start verbose 69 70 if [ -f /etc/rc.d/ipfilter ] ; then 71 # Resync ipfilter 72 /etc/rc.d/ipfilter resync 73 fi | 50 # 51 # We're operating as a general network start routine. 52 # 53 54 # disable SIGINT (Ctrl-c) when running at startup 55 trap : 2 56 57 # Create cloned interfaces --- 8 unchanged lines hidden (view full) --- 66 67 # Configure the interface(s). 68 network_common ifn_start verbose 69 70 if [ -f /etc/rc.d/ipfilter ] ; then 71 # Resync ipfilter 72 /etc/rc.d/ipfilter resync 73 fi |
74 if [ -f /etc/rc.d/bridge -a -n "$_cmdifn" ] ; then 75 /etc/rc.d/bridge start $_cmdifn | 74 if [ -f /etc/rc.d/bridge -a -n "$cmdifn" ] ; then 75 /etc/rc.d/bridge start $cmdifn |
76 fi 77} 78 79network_stop() 80{ 81 # Set the list of interfaces to work on. 82 # | 76 fi 77} 78 79network_stop() 80{ 81 # Set the list of interfaces to work on. 82 # |
83 _cmdifn=$* | 83 cmdifn=$* |
84 85 echo -n "Stopping network:" 86 87 # Deconfigure the interface(s) 88 network_common ifn_stop 89 echo '.' 90} 91 92# network_common routine verbose 93# Common configuration subroutine for network interfaces. This 94# routine takes all the preparatory steps needed for configuriing 95# an interface and then calls $routine. If $verbose is specified, 96# it will call ifconfig(8) to show, in long format, the configured 97# interfaces. If $verbose is not given, it will simply output the 98# configured interface(s). 99network_common() 100{ | 84 85 echo -n "Stopping network:" 86 87 # Deconfigure the interface(s) 88 network_common ifn_stop 89 echo '.' 90} 91 92# network_common routine verbose 93# Common configuration subroutine for network interfaces. This 94# routine takes all the preparatory steps needed for configuriing 95# an interface and then calls $routine. If $verbose is specified, 96# it will call ifconfig(8) to show, in long format, the configured 97# interfaces. If $verbose is not given, it will simply output the 98# configured interface(s). 99network_common() 100{ |
101 local _cooked_list _fail _func _verbose 102 |
|
101 _func= 102 _verbose= 103 104 if [ -z "$1" ]; then 105 err 1 "network_common(): No function name specified." 106 else 107 _func="$1" 108 fi 109 [ -n "$2" ] && _verbose=yes 110 111 # Set the scope of the command (all interfaces or just one). 112 # 113 _cooked_list= | 103 _func= 104 _verbose= 105 106 if [ -z "$1" ]; then 107 err 1 "network_common(): No function name specified." 108 else 109 _func="$1" 110 fi 111 [ -n "$2" ] && _verbose=yes 112 113 # Set the scope of the command (all interfaces or just one). 114 # 115 _cooked_list= |
114 if [ -n "$_cmdifn" ]; then | 116 if [ -n "$cmdifn" ]; then |
115 # Don't check that the interfaces exist. We need to run 116 # the down code even when the interface doesn't exist to 117 # kill off wpa_supplicant. | 117 # Don't check that the interfaces exist. We need to run 118 # the down code even when the interface doesn't exist to 119 # kill off wpa_supplicant. |
118 _cooked_list="$_cmdifn" | 120 _cooked_list="$cmdifn" |
119 else 120 _cooked_list="`list_net_interfaces`" 121 fi 122 | 121 else 122 _cooked_list="`list_net_interfaces`" 123 fi 124 |
125 _fail= |
|
123 for ifn in ${_cooked_list}; do 124 if ${_func} ${ifn} ; then 125 eval showstat_$ifn=1 126 else 127 _fail="$_fail $ifn" 128 fi 129 done 130 --- 49 unchanged lines hidden --- | 126 for ifn in ${_cooked_list}; do 127 if ${_func} ${ifn} ; then 128 eval showstat_$ifn=1 129 else 130 _fail="$_fail $ifn" 131 fi 132 done 133 --- 49 unchanged lines hidden --- |