]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.atm
Fix a KASSERT bug that showed up only in the LINT build, not the
[FreeBSD/FreeBSD.git] / etc / rc.atm
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$
28 #
29
30 #
31 # ATM networking startup script
32 #
33 # Initial interface configuration.
34 # N.B. /usr is not mounted.
35 #
36 atm_pass1() {
37         # Locate all probed ATM adapters
38         atmdev=`atm sh stat int | while read dev junk; do
39                 case ${dev} in
40                 hea[0-9] | hea[0-9][0-9])
41                         echo "${dev} "
42                         ;;
43                 hfa[0-9] | hfa[0-9][0-9])
44                         echo "${dev} "
45                         ;;
46                 idt[0-9] | idt[0-9][0-9])
47                         echo "${dev} "
48                         ;;
49                 *)
50                         continue
51                         ;;
52                 esac
53         done`
54
55         if [ -z "${atmdev}" ]; then
56                 echo 'No ATM adapters found'
57                 return 0
58         fi
59
60         # Load microcode into FORE adapters (if needed)
61         if [ `expr "${atmdev}" : '.*hfa.*'` -ne 0 ]; then
62                 fore_dnld
63         fi
64
65         # Configure physical interfaces
66         ilmid=0
67         for phy in ${atmdev}; do
68                 echo -n "Configuring ATM device ${phy}:"
69
70                 # Define network interfaces
71                 eval netif_args=\$atm_netif_${phy}
72                 if [ -n "${netif_args}" ]; then
73                         atm set netif ${phy} ${netif_args} || continue
74                 else
75                         echo ' missing network interface definition'
76                         continue
77                 fi
78
79                 # Override physical MAC address
80                 eval macaddr_args=\$atm_macaddr_${phy}
81                 if [ -n "${macaddr_args}" ]; then
82                         case ${macaddr_args} in
83                         [Nn][Oo] | '')
84                                 ;;
85                         *)
86                                 atm set mac ${phy} ${macaddr_args} || continue
87                                 ;;
88                         esac
89                 fi
90
91                 # Configure signalling manager
92                 eval sigmgr_args=\$atm_sigmgr_${phy}
93                 if [ -n "${sigmgr_args}" ]; then
94                         atm attach ${phy} ${sigmgr_args} || continue
95                 else
96                         echo ' missing signalling manager definition'
97                         continue
98                 fi
99
100                 # Configure UNI NSAP prefix
101                 eval prefix_args=\$atm_prefix_${phy}
102                 if [ `expr "${sigmgr_args}" : '[uU][nN][iI].*'` -ne 0 ]; then
103                         if [ -z "${prefix_args}" ]; then
104                                 echo ' missing NSAP prefix for UNI interface'
105                                 continue
106                         fi
107
108                         case ${prefix_args} in
109                         ILMI)
110                                 ilmid=1
111                                 ;;
112                         *)
113                                 atm set prefix ${phy} ${prefix_args} || continue
114                                 ;;
115                         esac
116                 fi
117
118                 atm_phy="${atm_phy} ${phy}"
119                 echo '.'
120         done
121
122         echo -n 'Starting initial ATM daemons:'
123         # Start ILMI daemon (if needed)
124         case ${ilmid} in
125         1)
126                 echo -n ' ilmid'
127                 ilmid
128                 ;;
129         esac
130
131         echo '.'
132         atm_pass1_done=YES
133 }
134
135 #
136 # Finish up configuration.
137 # N.B. /usr is not mounted.
138 #
139 atm_pass2() {
140         echo -n 'Configuring ATM network interfaces:'
141
142         atm_scspd=0
143         atm_atmarpd=""
144
145         # Configure network interfaces
146         for phy in ${atm_phy}; do
147                 eval netif_args=\$atm_netif_${phy}
148                 set -- ${netif_args}
149                 netname=$1
150                 netcnt=$2
151                 netindx=0
152                 while [ ${netindx} -lt ${netcnt} ]; do
153                         net="${netname}${netindx}"
154                         netindx=$((${netindx} + 1))
155                         echo -n " ${net}"
156
157                         # Configure atmarp server
158                         eval atmarp_args=\$atm_arpserver_${net}
159                         if [ -n "${atmarp_args}" ]; then
160                                 atm set arpserver ${net} ${atmarp_args} ||
161                                         continue
162                         fi
163                         eval scsparp_args=\$atm_scsparp_${net}
164
165                         case ${scsparp_args} in
166                         [Yy][Ee][Ss])
167                                 case ${atmarp_args} in
168                                 local)
169                                         ;;
170                                 *)
171                                         echo ' local arpserver required for SCSP'
172                                         continue
173                                         ;;
174                                 esac
175
176                                 atm_atmarpd="${atm_atmarpd} ${net}"
177                                 atm_scspd=1
178                         esac
179                 done
180         done
181         echo '.'
182
183         # Define any PVCs.
184         if [ -n "${atm_pvcs}" ]; then
185                 for i in ${atm_pvcs}; do
186                         eval pvc_args=\$atm_pvc_${i}
187                         atm add pvc ${pvc_args}
188                 done
189         fi
190
191         # Define any permanent ARP entries.
192         if [ -n "${atm_arps}" ]; then
193                 for i in ${atm_arps}; do
194                         eval arp_args=\$atm_arp_${i}
195                         atm add arp ${arp_args}
196                 done
197         fi
198         atm_pass2_done=YES
199 }
200
201 #
202 # Start any necessary daemons.
203 #
204 atm_pass3() {
205         # Start SCSP daemon (if needed)
206         case ${atm_scspd} in
207         1)
208                 echo -n ' scspd'
209                 scspd
210                 ;;
211         esac
212
213         # Start ATMARP daemon (if needed)
214         if [ -n "${atm_atmarpd}" ]; then
215                 echo -n ' atmarpd'
216                 atmarpd ${atm_atmarpd}
217         fi
218
219         atm_pass3_done=YES
220 }