atm1 revision 180563
195584Sanholt#!/bin/sh
2152909Sanholt#
3152909Sanholt# Copyright (c) 2000  The FreeBSD Project
495584Sanholt# All rights reserved.
595584Sanholt#
695584Sanholt# Redistribution and use in source and binary forms, with or without
795584Sanholt# modification, are permitted provided that the following conditions
895584Sanholt# are met:
995584Sanholt# 1. Redistributions of source code must retain the above copyright
1095584Sanholt#    notice, this list of conditions and the following disclaimer.
1195584Sanholt# 2. Redistributions in binary form must reproduce the above copyright
1295584Sanholt#    notice, this list of conditions and the following disclaimer in the
1395584Sanholt#    documentation and/or other materials provided with the distribution.
1495584Sanholt#
1595584Sanholt# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1695584Sanholt# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1795584Sanholt# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1895584Sanholt# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1995584Sanholt# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2095584Sanholt# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2195584Sanholt# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2295584Sanholt# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2395584Sanholt# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2495584Sanholt# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2595584Sanholt# SUCH DAMAGE.
2695584Sanholt#
2795584Sanholt# $FreeBSD: head/etc/rc.d/atm1 180563 2008-07-16 19:22:48Z dougb $
2895584Sanholt#
29152909Sanholt
30152909Sanholt# PROVIDE: atm1
31152909Sanholt# REQUIRE: root
3295584Sanholt# BEFORE: netif
3395584Sanholt# KEYWORD: nojail
3495584Sanholt
3595584Sanholt. /etc/rc.subr
3695584Sanholt
3795584Sanholtname="atm"
3895584Sanholtrcvar="atm_enable"
3995584Sanholtstart_cmd="atm_start"
4095584Sanholtstop_cmd=":"
4195584Sanholt
4295584Sanholt# ATM networking startup script
4395584Sanholt#
4495584Sanholt# Initial interface configuration.
4595584Sanholt# N.B. /usr is not mounted.
46145132Sanholt#
47145132Sanholtatm_start()
4895584Sanholt{
49145132Sanholt	if [ -n "${natm_interfaces}" ] ; then
50145132Sanholt		# Load the HARP pseudo interface
5195584Sanholt		load_kld if_harp || return 1
52145132Sanholt
53145132Sanholt		# Load all the NATM drivers that we need
5495584Sanholt		for natm in ${natm_interfaces} ; do
55145132Sanholt			ifconfig ${natm} up
56145132Sanholt		done
5795584Sanholt	fi
58145132Sanholt
59145132Sanholt	# Load loadable HARP drivers
6095584Sanholt	for dev in ${atm_load} ; do
61145132Sanholt		load_kld ${dev} || return 1
62145132Sanholt	done
6395584Sanholt
64145132Sanholt	# Locate all probed ATM adapters
65145132Sanholt	atmdev=`atm sh stat int | while read dev junk; do
6695584Sanholt		case ${dev} in
67145132Sanholt		hea[0-9] | hea[0-9][0-9])
68145132Sanholt			echo "${dev} "
6995584Sanholt			;;
70145132Sanholt		hfa[0-9] | hfa[0-9][0-9])
71145132Sanholt			echo "${dev} "
72145132Sanholt			;;
73145132Sanholt		idt[0-9] | idt[0-9][0-9])
7495584Sanholt			echo "${dev} "
75145132Sanholt			;;
76145132Sanholt
77145132Sanholt		# NATM interfaces per pseudo driver
7895584Sanholt		en[0-9] | en[0-9][0-9])
79145132Sanholt			echo "${dev} "
80145132Sanholt			;;
8195584Sanholt		fatm[0-9] | fatm[0-9][0-9])
82145132Sanholt			echo "${dev} "
83145132Sanholt			;;
8495584Sanholt		hatm[0-9] | hatm[0-9][0-9])
85145132Sanholt			echo "${dev} "
86145132Sanholt			;;
87145132Sanholt		patm[0-9] | patm[0-9][0-9])
88145132Sanholt			echo "${dev} "
8995584Sanholt			;;
90145132Sanholt		*)
91145132Sanholt			continue
9295584Sanholt			;;
93145132Sanholt		esac
94145132Sanholt	done`
9595584Sanholt
96145132Sanholt	if [ -z "${atmdev}" ]; then
97145132Sanholt		echo 'No ATM adapters found'
9895584Sanholt		return 0
99145132Sanholt	fi
100145132Sanholt
10195584Sanholt	# Load microcode into FORE adapters (if needed)
102145132Sanholt	if [ `expr "${atmdev}" : '.*hfa.*'` -ne 0 ]; then
103145132Sanholt		fore_dnld
10495584Sanholt	fi
105145132Sanholt
106145132Sanholt	# Configure physical interfaces
10795584Sanholt	ilmid=0
108145132Sanholt	for phy in ${atmdev}; do
109145132Sanholt		echo -n "Configuring ATM device ${phy}:"
11095584Sanholt
111145132Sanholt		# Define network interfaces
112145132Sanholt		eval netif_args=\$atm_netif_${phy}
11395584Sanholt		if [ -n "${netif_args}" ]; then
114145132Sanholt			atm set netif ${phy} ${netif_args} || continue
115145132Sanholt		else
11695584Sanholt			echo ' missing network interface definition'
117145132Sanholt			continue
118145132Sanholt		fi
119145132Sanholt
120145132Sanholt		# Override physical MAC address
12195584Sanholt		eval macaddr_args=\$atm_macaddr_${phy}
122145132Sanholt		if [ -n "${macaddr_args}" ]; then
123145132Sanholt			case ${macaddr_args} in
12495584Sanholt			[Nn][Oo] | '')
125145132Sanholt				;;
126145132Sanholt			*)
12795584Sanholt				atm set mac ${phy} ${macaddr_args} || continue
128145132Sanholt				;;
129145132Sanholt			esac
130145132Sanholt		fi
131145132Sanholt
13295584Sanholt		# Configure signalling manager
133145132Sanholt		eval sigmgr_args=\$atm_sigmgr_${phy}
134145132Sanholt		if [ -n "${sigmgr_args}" ]; then
135145132Sanholt			atm attach ${phy} ${sigmgr_args} || continue
136145132Sanholt		else
13795584Sanholt			echo ' missing signalling manager definition'
138145132Sanholt			continue
139145132Sanholt		fi
14095584Sanholt
141145132Sanholt		# Configure UNI NSAP prefix
142145132Sanholt		eval prefix_args=\$atm_prefix_${phy}
143145132Sanholt		if [ `expr "${sigmgr_args}" : '[uU][nN][iI].*'` -ne 0 ]; then
14495584Sanholt			if [ -z "${prefix_args}" ]; then
145145132Sanholt				echo ' missing NSAP prefix for UNI interface'
146145132Sanholt				continue
147145132Sanholt			fi
14895584Sanholt
149145132Sanholt			case ${prefix_args} in
150145132Sanholt			ILMI)
15195584Sanholt				ilmid=1
152145132Sanholt				;;
153145132Sanholt			*)
154145132Sanholt				atm set prefix ${phy} ${prefix_args} || continue
15595584Sanholt				;;
156145132Sanholt			esac
157145132Sanholt		fi
158145132Sanholt
159145132Sanholt		atm_phy="${atm_phy} ${phy}"
16095584Sanholt		echo '.'
161145132Sanholt	done
162145132Sanholt
163145132Sanholt	echo -n 'Starting initial ATM daemons:'
16495584Sanholt	# Start ILMI daemon (if needed)
165145132Sanholt	case ${ilmid} in
166145132Sanholt	1)
16795584Sanholt		echo -n ' ilmid'
168145132Sanholt		ilmid
169145132Sanholt		;;
170145132Sanholt	esac
171145132Sanholt
17295584Sanholt	echo '.'
173145132Sanholt}
174145132Sanholt
17595584Sanholtload_rc_config $name
176145132Sanholtrun_rc_command "$1"
177145132Sanholt