1159138Sthompsa#!/bin/sh 2159138Sthompsa# 3159138Sthompsa# Copyright (c) 2006 The FreeBSD Project. All rights reserved. 4159138Sthompsa# 5159138Sthompsa# Redistribution and use in source and binary forms, with or without 6159138Sthompsa# modification, are permitted provided that the following conditions 7159138Sthompsa# are met: 8159138Sthompsa# 1. Redistributions of source code must retain the above copyright 9159138Sthompsa# notice, this list of conditions and the following disclaimer. 10159138Sthompsa# 2. Redistributions in binary form must reproduce the above copyright 11159138Sthompsa# notice, this list of conditions and the following disclaimer in the 12159138Sthompsa# documentation and/or other materials provided with the distribution. 13159138Sthompsa# 14159138Sthompsa# THIS SOFTWARE IS PROVIDED BY THE PROJECT ``AS IS'' AND ANY EXPRESS OR 15159138Sthompsa# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16159138Sthompsa# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17159138Sthompsa# IN NO EVENT SHALL THE PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, 18159138Sthompsa# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19159138Sthompsa# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20159138Sthompsa# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21159138Sthompsa# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22159138Sthompsa# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23159138Sthompsa# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24159138Sthompsa# 25159138Sthompsa# $FreeBSD: releng/10.3/etc/rc.d/bridge 238416 2012-07-13 06:46:09Z kevlo $ 26159138Sthompsa# 27159138Sthompsa 28159138Sthompsa# PROVIDE: bridge 29225669Shrs# REQUIRE: netif faith ppp stf 30159138Sthompsa# KEYWORD: nojail 31159138Sthompsa 32159138Sthompsa. /etc/rc.subr 33159138Sthompsa. /etc/network.subr 34159138Sthompsa 35159138Sthompsaname="bridge" 36159138Sthompsastart_cmd="bridge_start" 37159138Sthompsastop_cmd="bridge_stop" 38165664Syarcmd="" 39159138Sthompsa 40238416Skevloglob_int() { 41159138Sthompsa case "$1" in 42159138Sthompsa $2 ) true ;; 43159138Sthompsa * ) false ;; 44159138Sthompsa esac 45208060Sdougb} 46159138Sthompsa 47238416Skevlobridge_test() { 48159138Sthompsa bridge=$1 49159138Sthompsa iface=$2 50159138Sthompsa 51159138Sthompsa eval interfaces=\$autobridge_${bridge} 52159138Sthompsa if [ -n "${interfaces}" ]; then 53159138Sthompsa for i in ${interfaces}; do 54159138Sthompsa if glob_int $iface $i ; then 55165664Syar ifconfig $bridge $cmd $iface > /dev/null 2>&1 56159138Sthompsa return 57159138Sthompsa fi 58159138Sthompsa done 59159138Sthompsa fi 60159138Sthompsa} 61159138Sthompsa 62159138Sthompsaautobridge() 63159138Sthompsa{ 64159138Sthompsa if [ -n "${autobridge_interfaces}" ]; then 65165664Syar if [ -z "$iflist" ]; then 66159138Sthompsa # We're operating as a general network start routine. 67165664Syar iflist="`list_net_interfaces`" 68159138Sthompsa fi 69159138Sthompsa 70159138Sthompsa for br in ${autobridge_interfaces}; do 71165664Syar for i in $iflist; do 72159138Sthompsa bridge_test $br $i 73159138Sthompsa done 74159138Sthompsa done 75159138Sthompsa fi 76159138Sthompsa} 77159138Sthompsa 78159138Sthompsabridge_start() 79159138Sthompsa{ 80165664Syar cmd="addm" 81159138Sthompsa autobridge 82159138Sthompsa} 83159138Sthompsa 84159138Sthompsabridge_stop() 85159138Sthompsa{ 86165664Syar cmd="deletem" 87159138Sthompsa autobridge 88159138Sthompsa} 89159138Sthompsa 90165664Syariflist=$2 91159138Sthompsa 92159138Sthompsaload_rc_config $name 93159138Sthompsarun_rc_command "$1" 94