Deleted Added
full compact
network.subr (207592) network.subr (208060)
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 207592 2010-05-04 01:46:58Z dougb $
25# $FreeBSD: head/etc/network.subr 208060 2010-05-14 04:53:57Z dougb $
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

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

473# Returns 0 if the interface exists and 1 otherwise.
474ifexists()
475{
476 [ -z "$1" ] && return 1
477 ifconfig -n $1 > /dev/null 2>&1
478}
479
480# ipv4_up if
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

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

473# Returns 0 if the interface exists and 1 otherwise.
474ifexists()
475{
476 [ -z "$1" ] && return 1
477 ifconfig -n $1 > /dev/null 2>&1
478}
479
480# ipv4_up if
481# add IPv4 addresses to the interface $if
481# add IPv4 addresses to the interface $if
482ipv4_up()
483{
484 local _if _ret
485 _if=$1
486 _ret=1
487
488 ifalias_up ${_if} inet && _ret=0
489 ipv4_addrs_common ${_if} alias && _ret=0

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

583}
584
585# ipv4_addrs_common if action
586# Evaluate the ifconfig_if_ipv4 arguments for interface $if and
587# use $action to add or remove IPv4 addresses from $if.
588ipv4_addrs_common()
589{
590 local _ret _if _action _cidr _cidr_addr
482ipv4_up()
483{
484 local _if _ret
485 _if=$1
486 _ret=1
487
488 ifalias_up ${_if} inet && _ret=0
489 ipv4_addrs_common ${_if} alias && _ret=0

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

583}
584
585# ipv4_addrs_common if action
586# Evaluate the ifconfig_if_ipv4 arguments for interface $if and
587# use $action to add or remove IPv4 addresses from $if.
588ipv4_addrs_common()
589{
590 local _ret _if _action _cidr _cidr_addr
591 local _ipaddr _netmask _range _ipnet _iplow _iphigh _ipcount
591 local _ipaddr _netmask _range _ipnet _iplow _iphigh _ipcount
592 _ret=1
593 _if=$1
594 _action=$2
592 _ret=1
593 _if=$1
594 _action=$2
595
595
596 # get ipv4-addresses
597 cidr_addr=`get_if_var $_if ipv4_addrs_IF`
596 # get ipv4-addresses
597 cidr_addr=`get_if_var $_if ipv4_addrs_IF`
598
598
599 for _cidr in ${cidr_addr}; do
600 _ipaddr=${_cidr%%/*}
601 _netmask="/"${_cidr##*/}
602 _range=${_ipaddr##*.}
603 _ipnet=${_ipaddr%.*}
604 _iplow=${_range%-*}
605 _iphigh=${_range#*-}
606
607 # clear netmask when removing aliases
608 if [ "${_action}" = "-alias" ]; then
609 _netmask=""
610 fi
599 for _cidr in ${cidr_addr}; do
600 _ipaddr=${_cidr%%/*}
601 _netmask="/"${_cidr##*/}
602 _range=${_ipaddr##*.}
603 _ipnet=${_ipaddr%.*}
604 _iplow=${_range%-*}
605 _iphigh=${_range#*-}
606
607 # clear netmask when removing aliases
608 if [ "${_action}" = "-alias" ]; then
609 _netmask=""
610 fi
611
611
612 _ipcount=${_iplow}
613 while [ "${_ipcount}" -le "${_iphigh}" ]; do
614 eval "ifconfig ${_if} ${_action} ${_ipnet}.${_ipcount}${_netmask}"
615 _ipcount=$((${_ipcount}+1))
616 _ret=0
617
618 # only the first ipaddr in a subnet need the real netmask
619 if [ "${_action}" != "-alias" ]; then

--- 767 unchanged lines hidden ---
612 _ipcount=${_iplow}
613 while [ "${_ipcount}" -le "${_iphigh}" ]; do
614 eval "ifconfig ${_if} ${_action} ${_ipnet}.${_ipcount}${_netmask}"
615 _ipcount=$((${_ipcount}+1))
616 _ret=0
617
618 # only the first ipaddr in a subnet need the real netmask
619 if [ "${_action}" != "-alias" ]; then

--- 767 unchanged lines hidden ---