2 * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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
25 *---------------------------------------------------------------------------
27 * i4b_l3timer.c - timer and timeout handling for layer 3
28 * ------------------------------------------------------
30 * $Id: i4b_l3timer.c,v 1.17 2000/08/24 11:48:58 hm Exp $
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.6 2005/06/03 16:50:12 dillon Exp $
35 * last edit-date: [Thu Aug 24 12:49:50 2000]
37 *---------------------------------------------------------------------------*/
39 #if defined(__DragonFly__) || defined(__FreeBSD__)
40 #include "use_i4bq931.h"
46 #include <sys/param.h>
47 #include <sys/kernel.h>
48 #include <sys/systm.h>
49 #include <sys/thread2.h>
52 #if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
53 #include <sys/callout.h>
56 #if defined(__DragonFly__) || defined(__FreeBSD__)
57 #include <net/i4b/include/machine/i4b_debug.h>
58 #include <net/i4b/include/machine/i4b_ioctl.h>
60 #include <i4b/i4b_debug.h>
61 #include <i4b/i4b_ioctl.h>
64 #include "../include/i4b_global.h"
65 #include "../include/i4b_l3l4.h"
68 #include "i4b_l3fsm.h"
71 /*---------------------------------------------------------------------------*
72 * stop all layer 3 timers
73 *---------------------------------------------------------------------------*/
74 void i4b_l3_stop_all_timers(call_desc_t *cd)
84 /*---------------------------------------------------------------------------*
85 * timer T303 timeout function
86 *---------------------------------------------------------------------------*/
88 T303_timeout(call_desc_t *cd)
90 NDBGL3(L3_T_ERR, "SETUP not answered, cr = %d", cd->cr);
91 next_l3state(cd, EV_T303EXP);
94 /*---------------------------------------------------------------------------*
96 *---------------------------------------------------------------------------*/
98 T303_start(call_desc_t *cd)
100 if (cd->T303 == TIMER_ACTIVE)
103 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
104 cd->T303 = TIMER_ACTIVE;
106 callout_reset(&cd->T303_timeout, T303VAL, (void *)T303_timeout, cd);
109 /*---------------------------------------------------------------------------*
111 *---------------------------------------------------------------------------*/
113 T303_stop(call_desc_t *cd)
118 if(cd->T303 != TIMER_IDLE)
120 callout_stop(&cd->T303_timeout);
121 cd->T303 = TIMER_IDLE;
124 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
127 /*---------------------------------------------------------------------------*
128 * timer T305 timeout function
129 *---------------------------------------------------------------------------*/
131 T305_timeout(call_desc_t *cd)
133 NDBGL3(L3_T_ERR, "DISC not answered, cr = %d", cd->cr);
134 next_l3state(cd, EV_T305EXP);
137 /*---------------------------------------------------------------------------*
139 *---------------------------------------------------------------------------*/
141 T305_start(call_desc_t *cd)
143 if (cd->T305 == TIMER_ACTIVE)
146 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
147 cd->T305 = TIMER_ACTIVE;
149 callout_reset(&cd->T305_timeout, T305VAL, (void *)T305_timeout, cd);
152 /*---------------------------------------------------------------------------*
154 *---------------------------------------------------------------------------*/
156 T305_stop(call_desc_t *cd)
161 if(cd->T305 != TIMER_IDLE)
163 callout_stop(&cd->T305_timeout);
164 cd->T305 = TIMER_IDLE;
168 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
171 /*---------------------------------------------------------------------------*
172 * timer T308 timeout function
173 *---------------------------------------------------------------------------*/
175 T308_timeout(call_desc_t *cd)
177 NDBGL3(L3_T_ERR, "REL not answered, cr = %d", cd->cr);
178 next_l3state(cd, EV_T308EXP);
181 /*---------------------------------------------------------------------------*
183 *---------------------------------------------------------------------------*/
185 T308_start(call_desc_t *cd)
187 if(cd->T308 == TIMER_ACTIVE)
190 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
191 cd->T308 = TIMER_ACTIVE;
193 callout_reset(&cd->T308_timeout, T308VAL, (void *)T308_timeout, cd);
196 /*---------------------------------------------------------------------------*
198 *---------------------------------------------------------------------------*/
200 T308_stop(call_desc_t *cd)
205 if(cd->T308 != TIMER_IDLE)
207 callout_stop(&cd->T308_timeout);
208 cd->T308 = TIMER_IDLE;
212 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
215 /*---------------------------------------------------------------------------*
216 * timer T309 timeout function
217 *---------------------------------------------------------------------------*/
219 T309_timeout(call_desc_t *cd)
221 NDBGL3(L3_T_ERR, "datalink not reconnected, cr = %d", cd->cr);
222 next_l3state(cd, EV_T309EXP);
225 /*---------------------------------------------------------------------------*
227 *---------------------------------------------------------------------------*/
229 T309_start(call_desc_t *cd)
231 if (cd->T309 == TIMER_ACTIVE)
234 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
235 cd->T309 = TIMER_ACTIVE;
237 callout_reset(&cd->T309_timeout, T309VAL, (void *)T309_timeout, cd);
240 /*---------------------------------------------------------------------------*
242 *---------------------------------------------------------------------------*/
244 T309_stop(call_desc_t *cd)
249 if(cd->T309 != TIMER_IDLE)
251 callout_stop(&cd->T309_timeout);
252 cd->T309 = TIMER_IDLE;
256 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
259 /*---------------------------------------------------------------------------*
260 * timer T310 timeout function
261 *---------------------------------------------------------------------------*/
263 T310_timeout(call_desc_t *cd)
265 NDBGL3(L3_T_ERR, "CALL PROC timeout, cr = %d", cd->cr);
266 next_l3state(cd, EV_T310EXP);
269 /*---------------------------------------------------------------------------*
271 *---------------------------------------------------------------------------*/
273 T310_start(call_desc_t *cd)
275 if (cd->T310 == TIMER_ACTIVE)
278 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
279 cd->T310 = TIMER_ACTIVE;
281 callout_reset(&cd->T310_timeout, T310VAL, (void *)T310_timeout, cd);
284 /*---------------------------------------------------------------------------*
286 *---------------------------------------------------------------------------*/
288 T310_stop(call_desc_t *cd)
293 if(cd->T310 != TIMER_IDLE)
295 callout_stop(&cd->T310_timeout);
296 cd->T310 = TIMER_IDLE;
300 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
303 /*---------------------------------------------------------------------------*
304 * timer T313 timeout function
305 *---------------------------------------------------------------------------*/
307 T313_timeout(call_desc_t *cd)
309 NDBGL3(L3_T_ERR, "CONN ACK not received, cr = %d", cd->cr);
310 next_l3state(cd, EV_T313EXP);
313 /*---------------------------------------------------------------------------*
315 *---------------------------------------------------------------------------*/
317 T313_start(call_desc_t *cd)
319 if (cd->T313 == TIMER_ACTIVE)
322 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
323 cd->T313 = TIMER_ACTIVE;
325 callout_reset(&cd->T313_timeout, T313VAL, (void *)T313_timeout, cd);
328 /*---------------------------------------------------------------------------*
330 *---------------------------------------------------------------------------*/
332 T313_stop(call_desc_t *cd)
337 if(cd->T313 != TIMER_IDLE)
339 cd->T313 = TIMER_IDLE;
340 callout_stop(&cd->T313_timeout);
344 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
347 #endif /* NI4BQ931 > 0 */