freebsd-nq/etc/rc.d/atm1
Hartmut Brandt c5670cc3b1 Convert the atm{2,3}.sh rc scripts to normal rc.d scripts. Add support
for the harp(4) pseudo driver and for loadable native HARP drivers
(like hfa_pci).

To use harp(4) the rc variable natm_interfaces must be set to the
list of NATM interfaces to be used for HARP. These interfaces
will be brought up with ifconfig and the harp(4) will be loaded.

To use loadable native HARP drivers atm_load must be set to
the list of drivers to load.

Reviewed by:	mtm, gordon (partly)
2003-07-28 13:30:42 +00:00

177 lines
4.0 KiB
Bash

#!/bin/sh
#
# Copyright (c) 2000 The FreeBSD Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#
# PROVIDE: atm1
# REQUIRE: root
# BEFORE: netif
# KEYWORD: FreeBSD
. /etc/rc.subr
name="atm"
rcvar="atm_enable"
start_cmd="atm_start"
stop_cmd=":"
# ATM networking startup script
#
# Initial interface configuration.
# N.B. /usr is not mounted.
#
atm_start()
{
if [ -n "${natm_interfaces}" ] ; then
# Load the HARP pseudo interface
kldstat -v | grep -q if_harp || kldload if_harp
# Load all the NATM drivers that we need
for natm in ${natm_interfaces} ; do
ifconfig ${natm} up
done
fi
# Load loadable HARP drivers
for dev in ${atm_load} ; do
kldstat -v | grep -q ${dev} || kldload ${dev}
done
# Locate all probed ATM adapters
atmdev=`atm sh stat int | while read dev junk; do
case ${dev} in
hea[0-9] | hea[0-9][0-9])
echo "${dev} "
;;
hfa[0-9] | hfa[0-9][0-9])
echo "${dev} "
;;
idt[0-9] | idt[0-9][0-9])
echo "${dev} "
;;
# NATM interfaces per pseudo driver
en[0-9] | en[0-9][0-9])
echo "${dev} "
;;
fatm[0-9] | fatm[0-9][0-9])
echo "${dev} "
;;
hatm[0-9] | hatm[0-9][0-9])
echo "${dev} "
;;
patm[0-9] | patm[0-9][0-9])
echo "${dev} "
;;
*)
continue
;;
esac
done`
if [ -z "${atmdev}" ]; then
echo 'No ATM adapters found'
return 0
fi
# Load microcode into FORE adapters (if needed)
if [ `expr "${atmdev}" : '.*hfa.*'` -ne 0 ]; then
fore_dnld
fi
# Configure physical interfaces
ilmid=0
for phy in ${atmdev}; do
echo -n "Configuring ATM device ${phy}:"
# Define network interfaces
eval netif_args=\$atm_netif_${phy}
if [ -n "${netif_args}" ]; then
atm set netif ${phy} ${netif_args} || continue
else
echo ' missing network interface definition'
continue
fi
# Override physical MAC address
eval macaddr_args=\$atm_macaddr_${phy}
if [ -n "${macaddr_args}" ]; then
case ${macaddr_args} in
[Nn][Oo] | '')
;;
*)
atm set mac ${phy} ${macaddr_args} || continue
;;
esac
fi
# Configure signalling manager
eval sigmgr_args=\$atm_sigmgr_${phy}
if [ -n "${sigmgr_args}" ]; then
atm attach ${phy} ${sigmgr_args} || continue
else
echo ' missing signalling manager definition'
continue
fi
# Configure UNI NSAP prefix
eval prefix_args=\$atm_prefix_${phy}
if [ `expr "${sigmgr_args}" : '[uU][nN][iI].*'` -ne 0 ]; then
if [ -z "${prefix_args}" ]; then
echo ' missing NSAP prefix for UNI interface'
continue
fi
case ${prefix_args} in
ILMI)
ilmid=1
;;
*)
atm set prefix ${phy} ${prefix_args} || continue
;;
esac
fi
atm_phy="${atm_phy} ${phy}"
echo '.'
done
echo -n 'Starting initial ATM daemons:'
# Start ILMI daemon (if needed)
case ${ilmid} in
1)
echo -n ' ilmid'
ilmid
;;
esac
echo '.'
}
load_rc_config $name
run_rc_command "$1"