1*0696600cSBjoern A. Zeeb#!/bin/sh 2*0696600cSBjoern A. Zeeb# 3*0696600cSBjoern A. Zeeb# Copyright (c) 2006 The FreeBSD Project. All rights reserved. 4*0696600cSBjoern A. Zeeb# 5*0696600cSBjoern A. Zeeb# Redistribution and use in source and binary forms, with or without 6*0696600cSBjoern A. Zeeb# modification, are permitted provided that the following conditions 7*0696600cSBjoern A. Zeeb# are met: 8*0696600cSBjoern A. Zeeb# 1. Redistributions of source code must retain the above copyright 9*0696600cSBjoern A. Zeeb# notice, this list of conditions and the following disclaimer. 10*0696600cSBjoern A. Zeeb# 2. Redistributions in binary form must reproduce the above copyright 11*0696600cSBjoern A. Zeeb# notice, this list of conditions and the following disclaimer in the 12*0696600cSBjoern A. Zeeb# documentation and/or other materials provided with the distribution. 13*0696600cSBjoern A. Zeeb# 14*0696600cSBjoern A. Zeeb# THIS SOFTWARE IS PROVIDED BY THE PROJECT ``AS IS'' AND ANY EXPRESS OR 15*0696600cSBjoern A. Zeeb# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16*0696600cSBjoern A. Zeeb# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17*0696600cSBjoern A. Zeeb# IN NO EVENT SHALL THE PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, 18*0696600cSBjoern A. Zeeb# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19*0696600cSBjoern A. Zeeb# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20*0696600cSBjoern A. Zeeb# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21*0696600cSBjoern A. Zeeb# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22*0696600cSBjoern A. Zeeb# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23*0696600cSBjoern A. Zeeb# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24*0696600cSBjoern A. Zeeb# 25*0696600cSBjoern A. Zeeb# $FreeBSD$ 26*0696600cSBjoern A. Zeeb# 27*0696600cSBjoern A. Zeeb 28*0696600cSBjoern A. Zeeb# PROVIDE: bridge 29*0696600cSBjoern A. Zeeb# REQUIRE: netif ppp stf 30*0696600cSBjoern A. Zeeb# KEYWORD: nojail 31*0696600cSBjoern A. Zeeb 32*0696600cSBjoern A. Zeeb. /etc/rc.subr 33*0696600cSBjoern A. Zeeb. /etc/network.subr 34*0696600cSBjoern A. Zeeb 35*0696600cSBjoern A. Zeebname="bridge" 36*0696600cSBjoern A. Zeebdesc="Network bridge setup" 37*0696600cSBjoern A. Zeebstart_cmd="bridge_start" 38*0696600cSBjoern A. Zeebstop_cmd="bridge_stop" 39*0696600cSBjoern A. Zeebcmd="" 40*0696600cSBjoern A. Zeeb 41*0696600cSBjoern A. Zeebglob_int() { 42*0696600cSBjoern A. Zeeb case "$1" in 43*0696600cSBjoern A. Zeeb $2 ) true ;; 44*0696600cSBjoern A. Zeeb * ) false ;; 45*0696600cSBjoern A. Zeeb esac 46*0696600cSBjoern A. Zeeb} 47*0696600cSBjoern A. Zeeb 48*0696600cSBjoern A. Zeebbridge_test() { 49*0696600cSBjoern A. Zeeb bridge=$1 50*0696600cSBjoern A. Zeeb iface=$2 51*0696600cSBjoern A. Zeeb 52*0696600cSBjoern A. Zeeb eval interfaces=\$autobridge_${bridge} 53*0696600cSBjoern A. Zeeb if [ -n "${interfaces}" ]; then 54*0696600cSBjoern A. Zeeb for i in ${interfaces}; do 55*0696600cSBjoern A. Zeeb if glob_int $iface $i ; then 56*0696600cSBjoern A. Zeeb ifconfig $bridge $cmd $iface > /dev/null 2>&1 57*0696600cSBjoern A. Zeeb return 58*0696600cSBjoern A. Zeeb fi 59*0696600cSBjoern A. Zeeb done 60*0696600cSBjoern A. Zeeb fi 61*0696600cSBjoern A. Zeeb} 62*0696600cSBjoern A. Zeeb 63*0696600cSBjoern A. Zeebautobridge() 64*0696600cSBjoern A. Zeeb{ 65*0696600cSBjoern A. Zeeb if [ -n "${autobridge_interfaces}" ]; then 66*0696600cSBjoern A. Zeeb if [ -z "$iflist" ]; then 67*0696600cSBjoern A. Zeeb # We're operating as a general network start routine. 68*0696600cSBjoern A. Zeeb iflist="`list_net_interfaces`" 69*0696600cSBjoern A. Zeeb fi 70*0696600cSBjoern A. Zeeb 71*0696600cSBjoern A. Zeeb for br in ${autobridge_interfaces}; do 72*0696600cSBjoern A. Zeeb for i in $iflist; do 73*0696600cSBjoern A. Zeeb bridge_test $br $i 74*0696600cSBjoern A. Zeeb done 75*0696600cSBjoern A. Zeeb done 76*0696600cSBjoern A. Zeeb fi 77*0696600cSBjoern A. Zeeb} 78*0696600cSBjoern A. Zeeb 79*0696600cSBjoern A. Zeebbridge_start() 80*0696600cSBjoern A. Zeeb{ 81*0696600cSBjoern A. Zeeb cmd="addm" 82*0696600cSBjoern A. Zeeb autobridge 83*0696600cSBjoern A. Zeeb} 84*0696600cSBjoern A. Zeeb 85*0696600cSBjoern A. Zeebbridge_stop() 86*0696600cSBjoern A. Zeeb{ 87*0696600cSBjoern A. Zeeb cmd="deletem" 88*0696600cSBjoern A. Zeeb autobridge 89*0696600cSBjoern A. Zeeb} 90*0696600cSBjoern A. Zeeb 91*0696600cSBjoern A. Zeebiflist=$2 92*0696600cSBjoern A. Zeeb 93*0696600cSBjoern A. Zeebload_rc_config $name 94*0696600cSBjoern A. Zeebrun_rc_command "$1" 95