atm1 revision 100280
1#!/bin/sh
2#
3# Copyright (c) 2000  The FreeBSD Project
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
27# $FreeBSD: head/etc/rc.d/atm1 100280 2002-07-18 05:00:17Z gordon $
28#
29
30# PROVIDE: atm1
31# REQUIRE: root
32# BEFORE: network1
33# KEYWORD: FreeBSD
34
35. /etc/rc.subr
36
37name="atm"
38rcvar="atm_enable"
39start_cmd="atm_start"
40stop_cmd=":"
41
42# ATM networking startup script
43#
44# Initial interface configuration.
45# N.B. /usr is not mounted.
46#
47start_cmd()
48{
49	# Locate all probed ATM adapters
50	atmdev=`atm sh stat int | while read dev junk; do
51		case ${dev} in
52		hea[0-9] | hea[0-9][0-9])
53			echo "${dev} "
54			;;
55		hfa[0-9] | hfa[0-9][0-9])
56			echo "${dev} "
57			;;
58		*)
59			continue
60			;;
61		esac
62	done`
63
64	if [ -z "${atmdev}" ]; then
65		echo 'No ATM adapters found'
66		return 0
67	fi
68
69	# Load microcode into FORE adapters (if needed)
70	if [ `expr "${atmdev}" : '.*hfa.*'` -ne 0 ]; then
71		fore_dnld
72	fi
73
74	# Configure physical interfaces
75	ilmid=0
76	for phy in ${atmdev}; do
77		echo -n "Configuring ATM device ${phy}:"
78
79		# Define network interfaces
80		eval netif_args=\$atm_netif_${phy}
81		if [ -n "${netif_args}" ]; then
82			atm set netif ${phy} ${netif_args} || continue
83		else
84			echo ' missing network interface definition'
85			continue
86		fi
87
88		# Override physical MAC address
89		eval macaddr_args=\$atm_macaddr_${phy}
90		if [ -n "${macaddr_args}" ]; then
91			case ${macaddr_args} in
92			[Nn][Oo] | '')
93				;;
94			*)
95				atm set mac ${phy} ${macaddr_args} || continue
96				;;
97			esac
98		fi
99
100		# Configure signalling manager
101		eval sigmgr_args=\$atm_sigmgr_${phy}
102		if [ -n "${sigmgr_args}" ]; then
103			atm attach ${phy} ${sigmgr_args} || continue
104		else
105			echo ' missing signalling manager definition'
106			continue
107		fi
108
109		# Configure UNI NSAP prefix
110		eval prefix_args=\$atm_prefix_${phy}
111		if [ `expr "${sigmgr_args}" : '[uU][nN][iI].*'` -ne 0 ]; then
112			if [ -z "${prefix_args}" ]; then
113				echo ' missing NSAP prefix for UNI interface'
114				continue
115			fi
116
117			case ${prefix_args} in
118			ILMI)
119				ilmid=1
120				;;
121			*)
122				atm set prefix ${phy} ${prefix_args} || continue
123				;;
124			esac
125		fi
126
127		atm_phy="${atm_phy} ${phy}"
128		echo '.'
129	done
130
131	echo -n 'Starting initial ATM daemons:'
132	# Start ILMI daemon (if needed)
133	case ${ilmid} in
134	1)
135		echo -n ' ilmid'
136		ilmid
137		;;
138	esac
139
140	echo '.'
141}
142
143load_rc_config $name
144run_rc_command "$1"
145