]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/i4b/layer3/i4b_l3timer.c
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / i4b / layer3 / i4b_l3timer.c
1 /*-
2  * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  */
25
26 /*---------------------------------------------------------------------------
27  *
28  *      i4b_l3timer.c - timer and timeout handling for layer 3
29  *      ------------------------------------------------------
30  *      last edit-date: [Sat Mar  9 19:35:31 2002]
31  *
32  *---------------------------------------------------------------------------*/
33
34 #include <sys/cdefs.h>
35 __FBSDID("$FreeBSD$");
36
37 #include <sys/param.h>
38 #include <sys/kernel.h>
39 #include <sys/systm.h>
40 #include <sys/mbuf.h>
41
42 #include <i4b/include/i4b_debug.h>
43 #include <i4b/include/i4b_ioctl.h>
44
45 #include <i4b/include/i4b_global.h>
46 #include <i4b/include/i4b_l3l4.h>
47
48 #include <i4b/layer3/i4b_l3.h>
49 #include <i4b/layer3/i4b_l3fsm.h>
50
51 /*---------------------------------------------------------------------------*
52  *      stop all layer 3 timers
53  *---------------------------------------------------------------------------*/
54 void i4b_l3_stop_all_timers(call_desc_t *cd)
55 {
56         T303_stop(cd);
57         T305_stop(cd);
58         T308_stop(cd);
59         T309_stop(cd);
60         T310_stop(cd);
61         T313_stop(cd);  
62 }
63         
64 /*---------------------------------------------------------------------------*
65  *      timer T303 timeout function
66  *---------------------------------------------------------------------------*/
67 static void
68 T303_timeout(call_desc_t *cd)
69 {
70         NDBGL3(L3_T_ERR, "SETUP not answered, cr = %d", cd->cr);
71         next_l3state(cd, EV_T303EXP);
72 }
73
74 /*---------------------------------------------------------------------------*
75  *      timer T303 start
76  *---------------------------------------------------------------------------*/
77 void
78 T303_start(call_desc_t *cd)
79 {
80         if (cd->T303 == TIMER_ACTIVE)
81                 return;
82                 
83         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
84         cd->T303 = TIMER_ACTIVE;
85
86         START_TIMER(cd->T303_callout, T303_timeout, cd, T303VAL);
87 }
88
89 /*---------------------------------------------------------------------------*
90  *      timer T303 stop
91  *---------------------------------------------------------------------------*/
92 void
93 T303_stop(call_desc_t *cd)
94 {
95         CRIT_VAR;
96         CRIT_BEG;
97         
98         if(cd->T303 != TIMER_IDLE)
99         {
100                 STOP_TIMER(cd->T303_callout, T303_timeout, cd);
101                 cd->T303 = TIMER_IDLE;
102         }
103         CRIT_END;
104         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
105 }
106
107 /*---------------------------------------------------------------------------*
108  *      timer T305 timeout function
109  *---------------------------------------------------------------------------*/
110 static void
111 T305_timeout(call_desc_t *cd)
112 {
113         NDBGL3(L3_T_ERR, "DISC not answered, cr = %d", cd->cr);
114         next_l3state(cd, EV_T305EXP);
115 }
116
117 /*---------------------------------------------------------------------------*
118  *      timer T305 start
119  *---------------------------------------------------------------------------*/
120 void
121 T305_start(call_desc_t *cd)
122 {
123         if (cd->T305 == TIMER_ACTIVE)
124                 return;
125                 
126         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
127         cd->T305 = TIMER_ACTIVE;
128
129         START_TIMER(cd->T305_callout, T305_timeout, cd, T305VAL);
130 }
131
132 /*---------------------------------------------------------------------------*
133  *      timer T305 stop
134  *---------------------------------------------------------------------------*/
135 void
136 T305_stop(call_desc_t *cd)
137 {
138         CRIT_VAR;
139         CRIT_BEG;
140         
141         if(cd->T305 != TIMER_IDLE)
142         {
143                 STOP_TIMER(cd->T305_callout, T305_timeout, cd);
144                 cd->T305 = TIMER_IDLE;
145         }
146         CRIT_END;
147         
148         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
149 }
150
151 /*---------------------------------------------------------------------------*
152  *      timer T308 timeout function
153  *---------------------------------------------------------------------------*/
154 static void
155 T308_timeout(call_desc_t *cd)
156 {
157         NDBGL3(L3_T_ERR, "REL not answered, cr = %d", cd->cr);
158         next_l3state(cd, EV_T308EXP);
159 }
160
161 /*---------------------------------------------------------------------------*
162  *      timer T308 start
163  *---------------------------------------------------------------------------*/
164 void
165 T308_start(call_desc_t *cd)
166 {
167         if(cd->T308 == TIMER_ACTIVE)
168                 return;
169                 
170         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
171         cd->T308 = TIMER_ACTIVE;
172
173         START_TIMER(cd->T308_callout, T308_timeout, cd, T308VAL);
174 }
175
176 /*---------------------------------------------------------------------------*
177  *      timer T308 stop
178  *---------------------------------------------------------------------------*/
179 void
180 T308_stop(call_desc_t *cd)
181 {
182         CRIT_VAR;
183         CRIT_BEG;
184         
185         if(cd->T308 != TIMER_IDLE)
186         {
187                 STOP_TIMER(cd->T308_callout, T308_timeout, cd);
188                 cd->T308 = TIMER_IDLE;
189         }
190         CRIT_END;
191         
192         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
193 }
194
195 /*---------------------------------------------------------------------------*
196  *      timer T309 timeout function
197  *---------------------------------------------------------------------------*/
198 static void
199 T309_timeout(call_desc_t *cd)
200 {
201         NDBGL3(L3_T_ERR, "datalink not reconnected, cr = %d", cd->cr);
202         next_l3state(cd, EV_T309EXP);
203 }
204
205 /*---------------------------------------------------------------------------*
206  *      timer T309 start
207  *---------------------------------------------------------------------------*/
208 void
209 T309_start(call_desc_t *cd)
210 {
211         if (cd->T309 == TIMER_ACTIVE)
212                 return;
213
214         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
215         cd->T309 = TIMER_ACTIVE;
216
217         START_TIMER(cd->T309_callout, T309_timeout, cd, T309VAL);
218 }
219
220 /*---------------------------------------------------------------------------*
221  *      timer T309 stop
222  *---------------------------------------------------------------------------*/
223 void
224 T309_stop(call_desc_t *cd)
225 {
226         CRIT_VAR;
227         CRIT_BEG;
228         
229         if(cd->T309 != TIMER_IDLE)
230         {
231                 STOP_TIMER(cd->T309_callout, T309_timeout, cd);
232                 cd->T309 = TIMER_IDLE;
233         }
234         CRIT_END;
235         
236         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
237 }
238
239 /*---------------------------------------------------------------------------*
240  *      timer T310 timeout function
241  *---------------------------------------------------------------------------*/
242 static void
243 T310_timeout(call_desc_t *cd)
244 {
245         NDBGL3(L3_T_ERR, "CALL PROC timeout, cr = %d", cd->cr);
246         next_l3state(cd, EV_T310EXP);
247 }
248
249 /*---------------------------------------------------------------------------*
250  *      timer T310 start
251  *---------------------------------------------------------------------------*/
252 void
253 T310_start(call_desc_t *cd)
254 {
255         if (cd->T310 == TIMER_ACTIVE)
256                 return;
257                 
258         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
259         cd->T310 = TIMER_ACTIVE;
260
261         START_TIMER(cd->T310_callout, T310_timeout, cd, T310VAL);
262 }
263
264 /*---------------------------------------------------------------------------*
265  *      timer T310 stop
266  *---------------------------------------------------------------------------*/
267 void
268 T310_stop(call_desc_t *cd)
269 {
270         CRIT_VAR;
271         CRIT_BEG;
272         
273         if(cd->T310 != TIMER_IDLE)
274         {
275                 STOP_TIMER(cd->T310_callout, T310_timeout, cd);
276                 cd->T310 = TIMER_IDLE;
277         }
278         CRIT_END;
279
280         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
281 }
282
283 /*---------------------------------------------------------------------------*
284  *      timer T313 timeout function
285  *---------------------------------------------------------------------------*/
286 static void
287 T313_timeout(call_desc_t *cd)
288 {
289         NDBGL3(L3_T_ERR, "CONN ACK not received, cr = %d", cd->cr);
290         next_l3state(cd, EV_T313EXP);
291 }
292
293 /*---------------------------------------------------------------------------*
294  *      timer T313 start
295  *---------------------------------------------------------------------------*/
296 void
297 T313_start(call_desc_t *cd)
298 {
299         if (cd->T313 == TIMER_ACTIVE)
300                 return;
301                 
302         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
303         cd->T313 = TIMER_ACTIVE;
304
305         START_TIMER(cd->T313_callout, T313_timeout, cd, T313VAL);
306 }
307
308 /*---------------------------------------------------------------------------*
309  *      timer T313 stop
310  *---------------------------------------------------------------------------*/
311 void
312 T313_stop(call_desc_t *cd)
313 {
314         CRIT_VAR;
315         CRIT_BEG;
316         
317         if(cd->T313 != TIMER_IDLE)
318         {
319                 cd->T313 = TIMER_IDLE;
320                 STOP_TIMER(cd->T313_callout, T313_timeout, cd);
321         }
322         CRIT_END;
323         
324         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
325 }