140006Sphk#!/bin/sh
240006Sphk#
366830Sobrien# Copyright (c) 2000  The FreeBSD Project
466830Sobrien# All rights reserved.
540006Sphk#
666830Sobrien# Redistribution and use in source and binary forms, with or without
766830Sobrien# modification, are permitted provided that the following conditions
866830Sobrien# are met:
966830Sobrien# 1. Redistributions of source code must retain the above copyright
1066830Sobrien#    notice, this list of conditions and the following disclaimer.
1166830Sobrien# 2. Redistributions in binary form must reproduce the above copyright
1266830Sobrien#    notice, this list of conditions and the following disclaimer in the
1366830Sobrien#    documentation and/or other materials provided with the distribution.
1466830Sobrien#
1566830Sobrien# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1666830Sobrien# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1766830Sobrien# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1866830Sobrien# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1966830Sobrien# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2066830Sobrien# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2166830Sobrien# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2266830Sobrien# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2366830Sobrien# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2466830Sobrien# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2566830Sobrien# SUCH DAMAGE.
2666830Sobrien#
2750472Speter# $FreeBSD$
2866830Sobrien#
2940006Sphk
30100280Sgordon# PROVIDE: atm2
31113676Smtm# REQUIRE: atm1 netif
32117020Smtm# BEFORE:  routing
33136224Smtm# KEYWORD: nojail
3440006Sphk
3540006Sphk#
36100280Sgordon# Additional ATM interface configuration
3740006Sphk#
38100280Sgordon. /etc/rc.subr
3940006Sphk
40118123Shartiname="atm2"
41118123Shartircvar="atm_enable"
42118123Shartistart_cmd="atm2_start"
43118123Shartistop_cmd=":"
44118123Sharti
45100280Sgordonatm2_start()
46100280Sgordon{
4751231Ssheldonh	# Configure network interfaces
48118123Sharti
49118123Sharti	# get a list of physical interfaces
50118123Sharti	atm_phy=`atm show stat int | { read junk ; read junk ; \
51118123Sharti	    while read dev junk ; do
52118123Sharti		case ${dev} in
53118123Sharti		en[0-9] | en[0-9][0-9])
54118123Sharti			;;
55118123Sharti		*)
56118123Sharti			echo "${dev} "
57118123Sharti			;;
58118123Sharti		esac
59118123Sharti	done ; }`
60118123Sharti
6151231Ssheldonh	for phy in ${atm_phy}; do
6251231Ssheldonh		eval netif_args=\$atm_netif_${phy}
6351231Ssheldonh		set -- ${netif_args}
64118123Sharti		# skip unused physical interfaces
65118123Sharti		if [ $# -lt 2 ] ; then
66118123Sharti			continue
67118123Sharti		fi
68118123Sharti
6951231Ssheldonh		netname=$1
7051231Ssheldonh		netcnt=$2
7151231Ssheldonh		netindx=0
7251231Ssheldonh		while [ ${netindx} -lt ${netcnt} ]; do
7351231Ssheldonh			net="${netname}${netindx}"
7486342Ssheldonh			netindx=$((${netindx} + 1))
7551231Ssheldonh			echo -n " ${net}"
7640006Sphk
7751231Ssheldonh			# Configure atmarp server
7851231Ssheldonh			eval atmarp_args=\$atm_arpserver_${net}
7951231Ssheldonh			if [ -n "${atmarp_args}" ]; then
8051231Ssheldonh				atm set arpserver ${net} ${atmarp_args} ||
81100280Sgordon				    continue
8240006Sphk			fi
8351231Ssheldonh		done
8440006Sphk	done
8570108Sdougb	echo '.'
8640006Sphk
8751231Ssheldonh	# Define any permanent ARP entries.
8851231Ssheldonh	if [ -n "${atm_arps}" ]; then
8951231Ssheldonh		for i in ${atm_arps}; do
9051231Ssheldonh			eval arp_args=\$atm_arp_${i}
9151231Ssheldonh			atm add arp ${arp_args}
9251231Ssheldonh		done
9351231Ssheldonh	fi
9440006Sphk}
9540006Sphk
96118123Shartiload_rc_config $name
97118123Shartirun_rc_command "$1"
98