network.subr (177682) | network.subr (178356) |
---|---|
1# 2# Copyright (c) 2003 The FreeBSD Project. All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions 6# are met: 7# 1. Redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer. --- 8 unchanged lines hidden (view full) --- 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 23# SUCH DAMAGE. 24# | 1# 2# Copyright (c) 2003 The FreeBSD Project. All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions 6# are met: 7# 1. Redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer. --- 8 unchanged lines hidden (view full) --- 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 23# SUCH DAMAGE. 24# |
25# $FreeBSD: head/etc/network.subr 177682 2008-03-28 06:50:06Z brooks $ | 25# $FreeBSD: head/etc/network.subr 178356 2008-04-20 20:37:21Z sam $ |
26# 27 28# 29# Subroutines commonly used from network startup scripts. 30# Requires that rc.conf be loaded first. 31# 32 | 26# 27 28# 29# Subroutines commonly used from network startup scripts. 30# Requires that rc.conf be loaded first. 31# 32 |
33# ifn_start ifn 34# Bring up and configure an interface. If some configuration is applied 35# print the interface configuration. 36# 37ifn_start() 38{ 39 local ifn cfg 40 ifn="$1" 41 cfg=1 42 43 [ -z "$ifn" ] && err 1 "ifn_start called without an interface" 44 45 ifscript_up ${ifn} && cfg=0 46 ifconfig_up ${ifn} && cfg=0 47 ipv4_up ${ifn} && cfg=0 48 ipx_up ${ifn} && cfg=0 49 childif_create ${ifn} && cfg=0 50 51 if [ "$cfg" -eq 0 ]; then 52 ifconfig ${ifn} 53 fi 54 55 return $cfg 56} 57 58# ifn_start ifn 59# Shutdown and de-configure an interface. If action is taken print the 60# interface name. 61# 62ifn_stop() 63{ 64 local ifn cfg 65 ifn="$1" 66 cfg=1 67 68 [ -z "$ifn" ] && return 1 69 70 ipx_down ${ifn} && cfg=0 71 ipv4_down ${ifn} && cfg=0 72 ifconfig_down ${ifn} && cfg=0 73 ifscript_down ${ifn} && cfg=0 74 childif_destroy ${ifn} && cfg=0 75 76 if [ "$cfg" -eq 0 ]; then 77 echo -n " ${ifn}" 78 fi 79 80 return $cfg 81} 82 |
|
33# ifconfig_up if 34# Evaluate ifconfig(8) arguments for interface $if and 35# run ifconfig(8) with those arguments. It returns 0 if 36# arguments were found and executed or 1 if the interface 37# had no arguments. Pseudo arguments DHCP and WPA are handled 38# here. 39# 40ifconfig_up() 41{ 42 _cfg=1 43 44 ifconfig_args=`ifconfig_getargs $1` 45 if [ -n "${ifconfig_args}" ]; then | 83# ifconfig_up if 84# Evaluate ifconfig(8) arguments for interface $if and 85# run ifconfig(8) with those arguments. It returns 0 if 86# arguments were found and executed or 1 if the interface 87# had no arguments. Pseudo arguments DHCP and WPA are handled 88# here. 89# 90ifconfig_up() 91{ 92 _cfg=1 93 94 ifconfig_args=`ifconfig_getargs $1` 95 if [ -n "${ifconfig_args}" ]; then |
46 ifconfig $1 up | |
47 ifconfig $1 ${ifconfig_args} | 96 ifconfig $1 ${ifconfig_args} |
97 ifconfig $1 up |
|
48 _cfg=0 49 fi 50 51 if wpaif $1; then 52 /etc/rc.d/wpa_supplicant start $1 53 _cfg=0 # XXX: not sure this should count 54 fi 55 --- 391 unchanged lines hidden (view full) --- 447 if [ $? -eq 0 ]; then 448 _list="${_list}${_prefix}${ifn}" 449 [ -z "$_prefix" ] && _prefix=' ' 450 fi 451 done 452 debug "Destroyed clones: ${_list}" 453} 454 | 98 _cfg=0 99 fi 100 101 if wpaif $1; then 102 /etc/rc.d/wpa_supplicant start $1 103 _cfg=0 # XXX: not sure this should count 104 fi 105 --- 391 unchanged lines hidden (view full) --- 497 if [ $? -eq 0 ]; then 498 _list="${_list}${_prefix}${ifn}" 499 [ -z "$_prefix" ] && _prefix=' ' 500 fi 501 done 502 debug "Destroyed clones: ${_list}" 503} 504 |
505# Create and configure child interfaces. 506# Return 0 if child interfaces are created. 507# 508childif_create() 509{ 510 local cfg child child_vaps create_args ifn i 511 cfg=1 512 513 ifn=$1 514 515 # Create VAPs 516 child_vaps=`get_if_var $ifn vaps_IF` 517 for child in ${child_vaps}; do 518 create_args="wlandev $ifn `get_if_var $child vap_create_IF`" 519 if expr $child : 'wlan[0-9][0-9]*$' >/dev/null 2>&1; then 520 ifconfig $child create ${create_args} && cfg=0 521 else 522 i=`ifconfig wlan create ${create_args}` 523 ifconfig $i name $child && cfg=0 524 fi 525 ifn_start $child 526 done 527 528 return 529} 530 531# Destroy child interfaces. 532# 533childif_destroy() 534{ 535 local cfg child child_vaps ifn 536 537 child_vaps=`get_if_var $ifn vaps_IF` 538 for child in ${child_vaps}; do 539 ifconfig $child destroy && cfg=0 540 done 541} 542 |
|
455# Create netgraph nodes. 456# 457ng_mkpeer() { 458 ngctl -f - 2> /dev/null <<EOF 459mkpeer $* 460msg dummy nodeinfo 461EOF 462} --- 504 unchanged lines hidden --- | 543# Create netgraph nodes. 544# 545ng_mkpeer() { 546 ngctl -f - 2> /dev/null <<EOF 547mkpeer $* 548msg dummy nodeinfo 549EOF 550} --- 504 unchanged lines hidden --- |