Deleted Added
full compact
network.subr (256040) network.subr (256255)
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 256040 2013-10-04 04:15:18Z hrs $
25# $FreeBSD: head/etc/network.subr 256255 2013-10-10 07:41:11Z hrs $
26#
27IFCONFIG_CMD="/sbin/ifconfig"
28
29# Maximum number of addresses expanded from a address range specification.
30_IPEXPANDMAX=31
31
32#
33# Subroutines commonly used from network startup scripts.

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

77 fi
78 ifconfig_down ${ifn} && cfg=0
79 ifscript_down ${ifn} && cfg=0
80 childif_destroy ${ifn} && cfg=0
81
82 return $cfg
83}
84
26#
27IFCONFIG_CMD="/sbin/ifconfig"
28
29# Maximum number of addresses expanded from a address range specification.
30_IPEXPANDMAX=31
31
32#
33# Subroutines commonly used from network startup scripts.

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

77 fi
78 ifconfig_down ${ifn} && cfg=0
79 ifscript_down ${ifn} && cfg=0
80 childif_destroy ${ifn} && cfg=0
81
82 return $cfg
83}
84
85# ifn_vnetup ifn
86# Move ifn to the specified vnet jail.
87#
88ifn_vnetup()
89{
90
91 ifn_vnet0 $1 vnet
92}
93
94# ifn_vnetdown ifn
95# Reclaim ifn from the specified vnet jail.
96#
97ifn_vnetdown()
98{
99
100 ifn_vnet0 $1 -vnet
101}
102
103# ifn_vnet0 ifn action
104# Helper function for ifn_vnetup and ifn_vnetdown.
105#
106ifn_vnet0()
107{
108 local _ifn _cfg _action _vnet
109 _ifn="$1"
110 _action="$2"
111 _cfg=1
112
113 if _vnet=$(vnetif $_ifn); then
114 ${IFCONFIG_CMD} $_ifn $_action $_vnet && _cfg=0
115 fi
116
117 return $_cfg
118}
119
85# ifconfig_up if
86# Evaluate ifconfig(8) arguments for interface $if and
87# run ifconfig(8) with those arguments. It returns 0 if
88# arguments were found and executed or 1 if the interface
89# had no arguments. Pseudo arguments DHCP and WPA are handled
90# here.
91#
92ifconfig_up()

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

279 get_if_var $_ifn ifconfig_IF$_af "$ifconfig_DEFAULT"
280}
281
282# ifconfig_getargs if [af]
283# Takes the result from _ifconfig_getargs and removes pseudo
284# args such as DHCP and WPA.
285ifconfig_getargs()
286{
120# ifconfig_up if
121# Evaluate ifconfig(8) arguments for interface $if and
122# run ifconfig(8) with those arguments. It returns 0 if
123# arguments were found and executed or 1 if the interface
124# had no arguments. Pseudo arguments DHCP and WPA are handled
125# here.
126#
127ifconfig_up()

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

314 get_if_var $_ifn ifconfig_IF$_af "$ifconfig_DEFAULT"
315}
316
317# ifconfig_getargs if [af]
318# Takes the result from _ifconfig_getargs and removes pseudo
319# args such as DHCP and WPA.
320ifconfig_getargs()
321{
287 local _tmpargs _arg _args
322 local _tmpargs _arg _args _vnet
288 _tmpargs=`_ifconfig_getargs $1 $2`
289 if [ $? -eq 1 ]; then
290 return 1
291 fi
292 _args=
323 _tmpargs=`_ifconfig_getargs $1 $2`
324 if [ $? -eq 1 ]; then
325 return 1
326 fi
327 _args=
328 _vnet=0
293
294 for _arg in $_tmpargs; do
329
330 for _arg in $_tmpargs; do
295 case $_arg in
296 [Dd][Hh][Cc][Pp]) ;;
297 [Nn][Oo][Aa][Uu][Tt][Oo]) ;;
298 [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) ;;
299 [Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) ;;
300 [Ww][Pp][Aa]) ;;
301 [Hh][Oo][Ss][Tt][Aa][Pp]) ;;
302 *)
331 case $_arg:$_vnet in
332 [Dd][Hh][Cc][Pp]:0) ;;
333 [Nn][Oo][Aa][Uu][Tt][Oo]:0) ;;
334 [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]:0) ;;
335 [Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]:0) ;;
336 [Ww][Pp][Aa]:0) ;;
337 [Hh][Oo][Ss][Tt][Aa][Pp]:0) ;;
338 vnet:0) _vnet=1 ;;
339 *:1) _vnet=0 ;;
340 *:0)
303 _args="$_args $_arg"
341 _args="$_args $_arg"
304 ;;
342 ;;
305 esac
306 done
307
308 echo $_args
309}
310
311# autoif
312# Returns 0 if the interface should be automatically configured at

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

421 return 0
422 ;;
423 esac
424 done
425
426 return 1
427}
428
343 esac
344 done
345
346 echo $_args
347}
348
349# autoif
350# Returns 0 if the interface should be automatically configured at

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

459 return 0
460 ;;
461 esac
462 done
463
464 return 1
465}
466
467# vnetif if
468# Returns 0 and echo jail if "vnet" keyword is specified on the
469# interface, and 1 otherwise.
470vnetif()
471{
472 local _tmpargs _arg _vnet
473 _tmpargs=`_ifconfig_getargs $1`
474
475 _vnet=0
476 for _arg in $_tmpargs; do
477 case $_arg:$_vnet in
478 vnet:0) _vnet=1 ;;
479 *:1) echo $_arg; return 0 ;;
480 esac
481 done
482
483 return 1
484}
485
429# afexists af
430# Returns 0 if the address family is enabled in the kernel
431# 1 otherwise.
432afexists()
433{
434 local _af
435 _af=$1
436

--- 1329 unchanged lines hidden ---
486# afexists af
487# Returns 0 if the address family is enabled in the kernel
488# 1 otherwise.
489afexists()
490{
491 local _af
492 _af=$1
493

--- 1329 unchanged lines hidden ---