2006-06-01 11:01:54 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2006 The FreeBSD Project. All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE PROJECT ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
# IN NO EVENT SHALL THE PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: bridge
|
2014-11-09 21:33:01 +00:00
|
|
|
# REQUIRE: netif ppp stf
|
2006-06-01 11:01:54 +00:00
|
|
|
# KEYWORD: nojail
|
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
. /etc/network.subr
|
|
|
|
|
|
|
|
name="bridge"
|
2016-04-23 16:10:54 +00:00
|
|
|
desc="Network bridge setup"
|
2006-06-01 11:01:54 +00:00
|
|
|
start_cmd="bridge_start"
|
|
|
|
stop_cmd="bridge_stop"
|
2006-12-30 22:53:20 +00:00
|
|
|
cmd=""
|
2006-06-01 11:01:54 +00:00
|
|
|
|
2012-07-13 06:46:09 +00:00
|
|
|
glob_int() {
|
2006-06-01 11:01:54 +00:00
|
|
|
case "$1" in
|
|
|
|
$2 ) true ;;
|
|
|
|
* ) false ;;
|
|
|
|
esac
|
2010-05-14 04:53:57 +00:00
|
|
|
}
|
2006-06-01 11:01:54 +00:00
|
|
|
|
2012-07-13 06:46:09 +00:00
|
|
|
bridge_test() {
|
2006-06-01 11:01:54 +00:00
|
|
|
bridge=$1
|
|
|
|
iface=$2
|
|
|
|
|
|
|
|
eval interfaces=\$autobridge_${bridge}
|
|
|
|
if [ -n "${interfaces}" ]; then
|
|
|
|
for i in ${interfaces}; do
|
|
|
|
if glob_int $iface $i ; then
|
2006-12-30 22:53:20 +00:00
|
|
|
ifconfig $bridge $cmd $iface > /dev/null 2>&1
|
2006-06-01 11:01:54 +00:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
autobridge()
|
|
|
|
{
|
|
|
|
if [ -n "${autobridge_interfaces}" ]; then
|
2006-12-30 22:53:20 +00:00
|
|
|
if [ -z "$iflist" ]; then
|
2006-06-01 11:01:54 +00:00
|
|
|
# We're operating as a general network start routine.
|
2006-12-30 22:53:20 +00:00
|
|
|
iflist="`list_net_interfaces`"
|
2006-06-01 11:01:54 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
for br in ${autobridge_interfaces}; do
|
2006-12-30 22:53:20 +00:00
|
|
|
for i in $iflist; do
|
2006-06-01 11:01:54 +00:00
|
|
|
bridge_test $br $i
|
|
|
|
done
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
bridge_start()
|
|
|
|
{
|
2006-12-30 22:53:20 +00:00
|
|
|
cmd="addm"
|
2006-06-01 11:01:54 +00:00
|
|
|
autobridge
|
|
|
|
}
|
|
|
|
|
|
|
|
bridge_stop()
|
|
|
|
{
|
2006-12-30 22:53:20 +00:00
|
|
|
cmd="deletem"
|
2006-06-01 11:01:54 +00:00
|
|
|
autobridge
|
|
|
|
}
|
|
|
|
|
2006-12-30 22:53:20 +00:00
|
|
|
iflist=$2
|
2006-06-01 11:01:54 +00:00
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|