atm1 revision 40006
162587Sitojun#!/bin/sh
291671Sume#
362587Sitojun
455009Sshin# ATM networking startup script
555009Sshin#
655009Sshin#	$Id$
755009Sshin
855009Sshin#
955009Sshin# Initial interface configuration.
1055009Sshin# N.B. /usr is not mounted.
1155009Sshin#
1255009Sshinatm_pass1() {
1355009Sshin    # Locate all probed ATM adapters by scanning dmesg output
1455009Sshin    saveifs="${IFS}"
1555009Sshin    IFS=$IFS:
1655009Sshin    atmdev=`dmesg | while read dev junk; do
1755009Sshin	case ${dev} in
1855009Sshin	hea[0-9]|hea[0-9][0-9])
1955009Sshin		echo "${dev} "
2055009Sshin		;;
2155009Sshin	hfa[0-9]|hfa[0-9][0-9])
2255009Sshin		echo "${dev} "
2355009Sshin		;;
2455009Sshin	*)
2555009Sshin		continue
2655009Sshin		;;
2755009Sshin	esac
2855009Sshin    done`
2955009Sshin    IFS="${saveifs}"
3055009Sshin
3155009Sshin    if [ -z "${atmdev}" ]; then
3255009Sshin	echo "No ATM adapters found."
3355009Sshin	return 0
3455009Sshin    fi
3555009Sshin
3655009Sshin    # Load microcode into FORE adapters (if needed)
3755009Sshin    if [ `expr "${atmdev}" : '.*hfa.*'` -ne 0 ]; then
3855009Sshin	fore_dnld -d /etc
3955009Sshin    fi
4055009Sshin
4155009Sshin    # Configure physical interfaces
4255009Sshin    ilmid=0
4355009Sshin    for phy in ${atmdev}; do
4455009Sshin	echo -n "Configuring ATM device ${phy}:"
4555009Sshin
4655009Sshin	# Define network interfaces
4755009Sshin	eval netif_args=\$atm_netif_${phy}
4855009Sshin	if [ -n "${netif_args}" ]; then
4955009Sshin		atm set netif ${phy} ${netif_args} || continue
5055009Sshin	else
5155009Sshin		echo "missing network interface definition"
5255009Sshin		continue
5355009Sshin	fi
5455009Sshin
5555009Sshin	# Override physical MAC address
5655009Sshin	eval macaddr_args=\$atm_macaddr_${phy}
5755009Sshin	if [ -n "${macaddr_args}" -a "${macaddr_args}" != "NO" ]; then
5855009Sshin		atm set mac ${phy} ${macaddr_args} || continue
5955009Sshin	fi
6055009Sshin
6155009Sshin	# Configure signalling manager
6255009Sshin	eval sigmgr_args=\$atm_sigmgr_${phy}
6362587Sitojun	if [ -n "${sigmgr_args}" ]; then
6455009Sshin		atm attach ${phy} ${sigmgr_args} || continue
6555009Sshin	else
6655009Sshin		echo "missing signalling manager definition"
6755009Sshin		continue
6855009Sshin	fi
6962587Sitojun
7062587Sitojun	# Configure UNI NSAP prefix
7155009Sshin	eval prefix_args=\$atm_prefix_${phy}
7278064Sume	if [ `expr "${sigmgr_args}" : '[uU][nN][iI].*'` -ne 0 ]; then
7378064Sume		if [ -z "${prefix_args}" ]; then
7455009Sshin			echo "missing NSAP prefix for UNI interface"
7562587Sitojun			continue
7662587Sitojun		fi
7755009Sshin		if [ "${prefix_args}" = "ILMI" ]; then
7878064Sume			ilmid=1
7955009Sshin		else
8055009Sshin			atm set prefix ${phy} ${prefix_args} || continue
8178064Sume		fi
8255009Sshin	fi
8392756Salfred
8492756Salfred	atm_phy="${atm_phy} ${phy}"
8592756Salfred	echo "."
86121072Sume    done
87121072Sume
8891671Sume    echo -n "Starting initial ATM daemons:"
8955009Sshin    # Start ILMI daemon (if needed)
9055009Sshin    if [ ${ilmid} -eq 1 ]; then
9155009Sshin	echo -n " ilmid"
9255009Sshin	ilmid
9355009Sshin    fi
94
95    echo "."
96    atm_pass1_done=YES
97}
98
99#
100# Finish up configuration.
101# N.B. /usr is not mounted.
102#
103atm_pass2() {
104    echo -n "Configuring ATM network interfaces:"
105
106    atm_scspd=0
107    atm_atmarpd=""
108
109    # Configure network interfaces
110    for phy in ${atm_phy}; do
111	eval netif_args=\$atm_netif_${phy}
112	set -- ${netif_args}
113	netname=$1
114	netcnt=$2
115	netindx=0
116	while [ ${netindx} -lt ${netcnt} ]; do
117
118		net="${netname}${netindx}"
119		netindx=`expr ${netindx} + 1`
120		echo -n " ${net}"
121
122		# Configure atmarp server
123		eval atmarp_args=\$atm_arpserver_${net}
124		if [ -n "${atmarp_args}" ]; then
125			atm set arpserver ${net} ${atmarp_args} || continue
126		fi
127		eval scsparp_args=\$atm_scsparp_${net}
128		if [ "X${scsparp_args}" = X"YES" ]; then
129			if [ "${atmarp_args}" != "local" ]; then
130				echo "local arpserver required for SCSP"
131				continue
132			fi
133			atm_atmarpd="${atm_atmarpd} ${net}"
134			atm_scspd=1
135		fi
136	done
137    done
138    echo "."
139
140    # Define any PVCs.
141    if [ "X${atm_pvcs}" != "X" ]; then
142	for i in ${atm_pvcs}; do
143		eval pvc_args=\$atm_pvc_${i}
144		atm add pvc ${pvc_args}
145	done
146    fi
147
148    # Define any permanent ARP entries.
149    if [ "X${atm_arps}" != "X" ]; then
150	for i in ${atm_arps}; do
151		eval arp_args=\$atm_arp_${i}
152		atm add arp ${arp_args}
153	done
154    fi
155    atm_pass2_done=YES
156}
157
158#
159# Start any necessary daemons.
160#
161atm_pass3() {
162    # Start SCSP daemon (if needed)
163    if [ ${atm_scspd} -eq 1 ]; then
164	echo -n " scspd"
165	scspd
166    fi
167
168    # Start ATMARP daemon (if needed)
169    if [ -n "${atm_atmarpd}" ]; then
170	echo -n " atmarpd"
171	atmarpd ${atm_atmarpd}
172    fi
173
174    atm_pass3_done=YES
175}
176