* Remove (void) casts for discarded return values.
[dragonfly.git] / sys / net / i4b / layer3 / i4b_l3timer.c
1 /*
2  * Copyright (c) 1997, 2000 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  *      i4b_l3timer.c - timer and timeout handling for layer 3
28  *      ------------------------------------------------------
29  *
30  *      $Id: i4b_l3timer.c,v 1.17 2000/08/24 11:48:58 hm Exp $ 
31  *
32  * $FreeBSD: src/sys/i4b/layer3/i4b_l3timer.c,v 1.6.2.1 2001/08/10 14:08:42 obrien Exp $
33  * $DragonFly: src/sys/net/i4b/layer3/i4b_l3timer.c,v 1.8 2006/01/14 11:05:18 swildner Exp $
34  *
35  *      last edit-date: [Thu Aug 24 12:49:50 2000]
36  *
37  *---------------------------------------------------------------------------*/
38
39 #include "use_i4bq931.h"
40 #if NI4BQ931 > 0
41
42 #include <sys/param.h>
43 #include <sys/kernel.h>
44 #include <sys/systm.h>
45 #include <sys/thread2.h>
46 #include <sys/mbuf.h>
47
48 #include <net/i4b/include/machine/i4b_debug.h>
49 #include <net/i4b/include/machine/i4b_ioctl.h>
50 #include "../include/i4b_global.h"
51 #include "../include/i4b_l3l4.h"
52
53 #include "i4b_l3.h"
54 #include "i4b_l3fsm.h"
55
56
57 /*---------------------------------------------------------------------------*
58  *      stop all layer 3 timers
59  *---------------------------------------------------------------------------*/
60 void
61 i4b_l3_stop_all_timers(call_desc_t *cd)
62 {
63         T303_stop(cd);
64         T305_stop(cd);
65         T308_stop(cd);
66         T309_stop(cd);
67         T310_stop(cd);
68         T313_stop(cd);  
69 }
70         
71 /*---------------------------------------------------------------------------*
72  *      timer T303 timeout function
73  *---------------------------------------------------------------------------*/
74 static void
75 T303_timeout(call_desc_t *cd)
76 {
77         NDBGL3(L3_T_ERR, "SETUP not answered, cr = %d", cd->cr);
78         next_l3state(cd, EV_T303EXP);
79 }
80
81 /*---------------------------------------------------------------------------*
82  *      timer T303 start
83  *---------------------------------------------------------------------------*/
84 void
85 T303_start(call_desc_t *cd)
86 {
87         if (cd->T303 == TIMER_ACTIVE)
88                 return;
89                 
90         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
91         cd->T303 = TIMER_ACTIVE;
92
93         callout_reset(&cd->T303_timeout, T303VAL, (void *)T303_timeout, cd);
94 }
95
96 /*---------------------------------------------------------------------------*
97  *      timer T303 stop
98  *---------------------------------------------------------------------------*/
99 void
100 T303_stop(call_desc_t *cd)
101 {
102         CRIT_VAR;
103         CRIT_BEG;
104         
105         if(cd->T303 != TIMER_IDLE)
106         {
107                 callout_stop(&cd->T303_timeout);
108                 cd->T303 = TIMER_IDLE;
109         }
110         CRIT_END;
111         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
112 }
113
114 /*---------------------------------------------------------------------------*
115  *      timer T305 timeout function
116  *---------------------------------------------------------------------------*/
117 static void
118 T305_timeout(call_desc_t *cd)
119 {
120         NDBGL3(L3_T_ERR, "DISC not answered, cr = %d", cd->cr);
121         next_l3state(cd, EV_T305EXP);
122 }
123
124 /*---------------------------------------------------------------------------*
125  *      timer T305 start
126  *---------------------------------------------------------------------------*/
127 void
128 T305_start(call_desc_t *cd)
129 {
130         if (cd->T305 == TIMER_ACTIVE)
131                 return;
132                 
133         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
134         cd->T305 = TIMER_ACTIVE;
135
136         callout_reset(&cd->T305_timeout, T305VAL, (void *)T305_timeout, cd);
137 }
138
139 /*---------------------------------------------------------------------------*
140  *      timer T305 stop
141  *---------------------------------------------------------------------------*/
142 void
143 T305_stop(call_desc_t *cd)
144 {
145         CRIT_VAR;
146         CRIT_BEG;
147         
148         if(cd->T305 != TIMER_IDLE)
149         {
150                 callout_stop(&cd->T305_timeout);
151                 cd->T305 = TIMER_IDLE;
152         }
153         CRIT_END;
154         
155         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
156 }
157
158 /*---------------------------------------------------------------------------*
159  *      timer T308 timeout function
160  *---------------------------------------------------------------------------*/
161 static void
162 T308_timeout(call_desc_t *cd)
163 {
164         NDBGL3(L3_T_ERR, "REL not answered, cr = %d", cd->cr);
165         next_l3state(cd, EV_T308EXP);
166 }
167
168 /*---------------------------------------------------------------------------*
169  *      timer T308 start
170  *---------------------------------------------------------------------------*/
171 void
172 T308_start(call_desc_t *cd)
173 {
174         if(cd->T308 == TIMER_ACTIVE)
175                 return;
176                 
177         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
178         cd->T308 = TIMER_ACTIVE;
179
180         callout_reset(&cd->T308_timeout, T308VAL, (void *)T308_timeout, cd);
181 }
182
183 /*---------------------------------------------------------------------------*
184  *      timer T308 stop
185  *---------------------------------------------------------------------------*/
186 void
187 T308_stop(call_desc_t *cd)
188 {
189         CRIT_VAR;
190         CRIT_BEG;
191         
192         if(cd->T308 != TIMER_IDLE)
193         {
194                 callout_stop(&cd->T308_timeout);
195                 cd->T308 = TIMER_IDLE;
196         }
197         CRIT_END;
198         
199         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
200 }
201
202 /*---------------------------------------------------------------------------*
203  *      timer T309 timeout function
204  *---------------------------------------------------------------------------*/
205 static void
206 T309_timeout(call_desc_t *cd)
207 {
208         NDBGL3(L3_T_ERR, "datalink not reconnected, cr = %d", cd->cr);
209         next_l3state(cd, EV_T309EXP);
210 }
211
212 /*---------------------------------------------------------------------------*
213  *      timer T309 start
214  *---------------------------------------------------------------------------*/
215 void
216 T309_start(call_desc_t *cd)
217 {
218         if (cd->T309 == TIMER_ACTIVE)
219                 return;
220
221         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
222         cd->T309 = TIMER_ACTIVE;
223
224         callout_reset(&cd->T309_timeout, T309VAL, (void *)T309_timeout, cd);
225 }
226
227 /*---------------------------------------------------------------------------*
228  *      timer T309 stop
229  *---------------------------------------------------------------------------*/
230 void
231 T309_stop(call_desc_t *cd)
232 {
233         CRIT_VAR;
234         CRIT_BEG;
235         
236         if(cd->T309 != TIMER_IDLE)
237         {
238                 callout_stop(&cd->T309_timeout);
239                 cd->T309 = TIMER_IDLE;
240         }
241         CRIT_END;
242         
243         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
244 }
245
246 /*---------------------------------------------------------------------------*
247  *      timer T310 timeout function
248  *---------------------------------------------------------------------------*/
249 static void
250 T310_timeout(call_desc_t *cd)
251 {
252         NDBGL3(L3_T_ERR, "CALL PROC timeout, cr = %d", cd->cr);
253         next_l3state(cd, EV_T310EXP);
254 }
255
256 /*---------------------------------------------------------------------------*
257  *      timer T310 start
258  *---------------------------------------------------------------------------*/
259 void
260 T310_start(call_desc_t *cd)
261 {
262         if (cd->T310 == TIMER_ACTIVE)
263                 return;
264                 
265         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
266         cd->T310 = TIMER_ACTIVE;
267
268         callout_reset(&cd->T310_timeout, T310VAL, (void *)T310_timeout, cd);
269 }
270
271 /*---------------------------------------------------------------------------*
272  *      timer T310 stop
273  *---------------------------------------------------------------------------*/
274 void
275 T310_stop(call_desc_t *cd)
276 {
277         CRIT_VAR;
278         CRIT_BEG;
279         
280         if(cd->T310 != TIMER_IDLE)
281         {
282                 callout_stop(&cd->T310_timeout);
283                 cd->T310 = TIMER_IDLE;
284         }
285         CRIT_END;
286
287         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
288 }
289
290 /*---------------------------------------------------------------------------*
291  *      timer T313 timeout function
292  *---------------------------------------------------------------------------*/
293 static void
294 T313_timeout(call_desc_t *cd)
295 {
296         NDBGL3(L3_T_ERR, "CONN ACK not received, cr = %d", cd->cr);
297         next_l3state(cd, EV_T313EXP);
298 }
299
300 /*---------------------------------------------------------------------------*
301  *      timer T313 start
302  *---------------------------------------------------------------------------*/
303 void
304 T313_start(call_desc_t *cd)
305 {
306         if (cd->T313 == TIMER_ACTIVE)
307                 return;
308                 
309         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
310         cd->T313 = TIMER_ACTIVE;
311
312         callout_reset(&cd->T313_timeout, T313VAL, (void *)T313_timeout, cd);
313 }
314
315 /*---------------------------------------------------------------------------*
316  *      timer T313 stop
317  *---------------------------------------------------------------------------*/
318 void
319 T313_stop(call_desc_t *cd)
320 {
321         CRIT_VAR;
322         CRIT_BEG;
323         
324         if(cd->T313 != TIMER_IDLE)
325         {
326                 cd->T313 = TIMER_IDLE;
327                 callout_stop(&cd->T313_timeout);
328         }
329         CRIT_END;
330         
331         NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
332 }
333
334 #endif /* NI4BQ931 > 0 */
335