atm2 revision 86342
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: head/etc/rc.d/atm2 86342 2001-11-14 06:35:43Z sheldonh $ 2866830Sobrien# 2940006Sphk 3040006Sphk# 3166830Sobrien# ATM networking startup script 3266830Sobrien# 3340006Sphk# Initial interface configuration. 3440006Sphk# N.B. /usr is not mounted. 3540006Sphk# 3640006Sphkatm_pass1() { 3751231Ssheldonh # Locate all probed ATM adapters 3851231Ssheldonh atmdev=`atm sh stat int | while read dev junk; do 3951231Ssheldonh case ${dev} in 4051231Ssheldonh hea[0-9] | hea[0-9][0-9]) 4151231Ssheldonh echo "${dev} " 4251231Ssheldonh ;; 4351231Ssheldonh hfa[0-9] | hfa[0-9][0-9]) 4451231Ssheldonh echo "${dev} " 4551231Ssheldonh ;; 4651231Ssheldonh *) 4751231Ssheldonh continue 4851231Ssheldonh ;; 4951231Ssheldonh esac 5051231Ssheldonh done` 5140006Sphk 5251231Ssheldonh if [ -z "${atmdev}" ]; then 5370108Sdougb echo 'No ATM adapters found' 5451231Ssheldonh return 0 5540006Sphk fi 5640006Sphk 5751231Ssheldonh # Load microcode into FORE adapters (if needed) 5851231Ssheldonh if [ `expr "${atmdev}" : '.*hfa.*'` -ne 0 ]; then 5957230Sphk fore_dnld 6040006Sphk fi 6140006Sphk 6251231Ssheldonh # Configure physical interfaces 6351231Ssheldonh ilmid=0 6451231Ssheldonh for phy in ${atmdev}; do 6551231Ssheldonh echo -n "Configuring ATM device ${phy}:" 6640006Sphk 6751231Ssheldonh # Define network interfaces 6851231Ssheldonh eval netif_args=\$atm_netif_${phy} 6951231Ssheldonh if [ -n "${netif_args}" ]; then 7051231Ssheldonh atm set netif ${phy} ${netif_args} || continue 7151231Ssheldonh else 7270108Sdougb echo ' missing network interface definition' 7340006Sphk continue 7440006Sphk fi 7551231Ssheldonh 7651231Ssheldonh # Override physical MAC address 7751231Ssheldonh eval macaddr_args=\$atm_macaddr_${phy} 7851231Ssheldonh if [ -n "${macaddr_args}" ]; then 7951231Ssheldonh case ${macaddr_args} in 8051231Ssheldonh [Nn][Oo] | '') 8151231Ssheldonh ;; 8251231Ssheldonh *) 8351231Ssheldonh atm set mac ${phy} ${macaddr_args} || continue 8451231Ssheldonh ;; 8551231Ssheldonh esac 8651231Ssheldonh fi 8751231Ssheldonh 8851231Ssheldonh # Configure signalling manager 8951231Ssheldonh eval sigmgr_args=\$atm_sigmgr_${phy} 9051231Ssheldonh if [ -n "${sigmgr_args}" ]; then 9151231Ssheldonh atm attach ${phy} ${sigmgr_args} || continue 9240006Sphk else 9370108Sdougb echo ' missing signalling manager definition' 9451231Ssheldonh continue 9540006Sphk fi 9640006Sphk 9751231Ssheldonh # Configure UNI NSAP prefix 9851231Ssheldonh eval prefix_args=\$atm_prefix_${phy} 9951231Ssheldonh if [ `expr "${sigmgr_args}" : '[uU][nN][iI].*'` -ne 0 ]; then 10051231Ssheldonh if [ -z "${prefix_args}" ]; then 10170108Sdougb echo ' missing NSAP prefix for UNI interface' 10251231Ssheldonh continue 10351231Ssheldonh fi 10440006Sphk 10551231Ssheldonh case ${prefix_args} in 10651231Ssheldonh ILMI) 10751231Ssheldonh ilmid=1 10851231Ssheldonh ;; 10951231Ssheldonh *) 11051231Ssheldonh atm set prefix ${phy} ${prefix_args} || continue 11151231Ssheldonh ;; 11251231Ssheldonh esac 11351231Ssheldonh fi 11440006Sphk 11551231Ssheldonh atm_phy="${atm_phy} ${phy}" 11670108Sdougb echo '.' 11751231Ssheldonh done 11851231Ssheldonh 11970108Sdougb echo -n 'Starting initial ATM daemons:' 12051231Ssheldonh # Start ILMI daemon (if needed) 12151231Ssheldonh case ${ilmid} in 12251231Ssheldonh 1) 12370108Sdougb echo -n ' ilmid' 12451231Ssheldonh ilmid 12551231Ssheldonh ;; 12651231Ssheldonh esac 12751231Ssheldonh 12870108Sdougb echo '.' 12951231Ssheldonh atm_pass1_done=YES 13040006Sphk} 13140006Sphk 13240006Sphk# 13340006Sphk# Finish up configuration. 13440006Sphk# N.B. /usr is not mounted. 13540006Sphk# 13640006Sphkatm_pass2() { 13770108Sdougb echo -n 'Configuring ATM network interfaces:' 13840006Sphk 13951231Ssheldonh atm_scspd=0 14051231Ssheldonh atm_atmarpd="" 14140006Sphk 14251231Ssheldonh # Configure network interfaces 14351231Ssheldonh for phy in ${atm_phy}; do 14451231Ssheldonh eval netif_args=\$atm_netif_${phy} 14551231Ssheldonh set -- ${netif_args} 14651231Ssheldonh netname=$1 14751231Ssheldonh netcnt=$2 14851231Ssheldonh netindx=0 14951231Ssheldonh while [ ${netindx} -lt ${netcnt} ]; do 15051231Ssheldonh net="${netname}${netindx}" 15186342Ssheldonh netindx=$((${netindx} + 1)) 15251231Ssheldonh echo -n " ${net}" 15340006Sphk 15451231Ssheldonh # Configure atmarp server 15551231Ssheldonh eval atmarp_args=\$atm_arpserver_${net} 15651231Ssheldonh if [ -n "${atmarp_args}" ]; then 15751231Ssheldonh atm set arpserver ${net} ${atmarp_args} || 15851231Ssheldonh continue 15940006Sphk fi 16051231Ssheldonh eval scsparp_args=\$atm_scsparp_${net} 16140006Sphk 16251231Ssheldonh case ${scsparp_args} in 16351231Ssheldonh [Yy][Ee][Ss]) 16451231Ssheldonh case ${atmarp_args} in 16551231Ssheldonh local) 16651231Ssheldonh ;; 16751231Ssheldonh *) 16870108Sdougb echo ' local arpserver required for SCSP' 16951231Ssheldonh continue 17051231Ssheldonh ;; 17151231Ssheldonh esac 17251231Ssheldonh 17351231Ssheldonh atm_atmarpd="${atm_atmarpd} ${net}" 17451231Ssheldonh atm_scspd=1 17551231Ssheldonh esac 17651231Ssheldonh done 17740006Sphk done 17870108Sdougb echo '.' 17940006Sphk 18051231Ssheldonh # Define any PVCs. 18151231Ssheldonh if [ -n "${atm_pvcs}" ]; then 18251231Ssheldonh for i in ${atm_pvcs}; do 18351231Ssheldonh eval pvc_args=\$atm_pvc_${i} 18451231Ssheldonh atm add pvc ${pvc_args} 18551231Ssheldonh done 18651231Ssheldonh fi 18751231Ssheldonh 18851231Ssheldonh # Define any permanent ARP entries. 18951231Ssheldonh if [ -n "${atm_arps}" ]; then 19051231Ssheldonh for i in ${atm_arps}; do 19151231Ssheldonh eval arp_args=\$atm_arp_${i} 19251231Ssheldonh atm add arp ${arp_args} 19351231Ssheldonh done 19451231Ssheldonh fi 19551231Ssheldonh atm_pass2_done=YES 19640006Sphk} 19740006Sphk 19840006Sphk# 19940006Sphk# Start any necessary daemons. 20040006Sphk# 20140006Sphkatm_pass3() { 20251231Ssheldonh # Start SCSP daemon (if needed) 20351231Ssheldonh case ${atm_scspd} in 20451231Ssheldonh 1) 20570108Sdougb echo -n ' scspd' 20651231Ssheldonh scspd 20751231Ssheldonh ;; 20851231Ssheldonh esac 20940006Sphk 21051231Ssheldonh # Start ATMARP daemon (if needed) 21151231Ssheldonh if [ -n "${atm_atmarpd}" ]; then 21270108Sdougb echo -n ' atmarpd' 21351231Ssheldonh atmarpd ${atm_atmarpd} 21451231Ssheldonh fi 21540006Sphk 21651231Ssheldonh atm_pass3_done=YES 21740006Sphk} 218