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.8 2006/01/14 11:05:18 swildner Exp $
35 * last edit-date: [Thu Aug 24 12:49:50 2000]
37 *---------------------------------------------------------------------------*/
39 #include "use_i4bq931.h"
42 #include <sys/param.h>
43 #include <sys/kernel.h>
44 #include <sys/systm.h>
45 #include <sys/thread2.h>
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"
54 #include "i4b_l3fsm.h"
57 /*---------------------------------------------------------------------------*
58 * stop all layer 3 timers
59 *---------------------------------------------------------------------------*/
61 i4b_l3_stop_all_timers(call_desc_t *cd)
71 /*---------------------------------------------------------------------------*
72 * timer T303 timeout function
73 *---------------------------------------------------------------------------*/
75 T303_timeout(call_desc_t *cd)
77 NDBGL3(L3_T_ERR, "SETUP not answered, cr = %d", cd->cr);
78 next_l3state(cd, EV_T303EXP);
81 /*---------------------------------------------------------------------------*
83 *---------------------------------------------------------------------------*/
85 T303_start(call_desc_t *cd)
87 if (cd->T303 == TIMER_ACTIVE)
90 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
91 cd->T303 = TIMER_ACTIVE;
93 callout_reset(&cd->T303_timeout, T303VAL, (void *)T303_timeout, cd);
96 /*---------------------------------------------------------------------------*
98 *---------------------------------------------------------------------------*/
100 T303_stop(call_desc_t *cd)
105 if(cd->T303 != TIMER_IDLE)
107 callout_stop(&cd->T303_timeout);
108 cd->T303 = TIMER_IDLE;
111 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
114 /*---------------------------------------------------------------------------*
115 * timer T305 timeout function
116 *---------------------------------------------------------------------------*/
118 T305_timeout(call_desc_t *cd)
120 NDBGL3(L3_T_ERR, "DISC not answered, cr = %d", cd->cr);
121 next_l3state(cd, EV_T305EXP);
124 /*---------------------------------------------------------------------------*
126 *---------------------------------------------------------------------------*/
128 T305_start(call_desc_t *cd)
130 if (cd->T305 == TIMER_ACTIVE)
133 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
134 cd->T305 = TIMER_ACTIVE;
136 callout_reset(&cd->T305_timeout, T305VAL, (void *)T305_timeout, cd);
139 /*---------------------------------------------------------------------------*
141 *---------------------------------------------------------------------------*/
143 T305_stop(call_desc_t *cd)
148 if(cd->T305 != TIMER_IDLE)
150 callout_stop(&cd->T305_timeout);
151 cd->T305 = TIMER_IDLE;
155 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
158 /*---------------------------------------------------------------------------*
159 * timer T308 timeout function
160 *---------------------------------------------------------------------------*/
162 T308_timeout(call_desc_t *cd)
164 NDBGL3(L3_T_ERR, "REL not answered, cr = %d", cd->cr);
165 next_l3state(cd, EV_T308EXP);
168 /*---------------------------------------------------------------------------*
170 *---------------------------------------------------------------------------*/
172 T308_start(call_desc_t *cd)
174 if(cd->T308 == TIMER_ACTIVE)
177 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
178 cd->T308 = TIMER_ACTIVE;
180 callout_reset(&cd->T308_timeout, T308VAL, (void *)T308_timeout, cd);
183 /*---------------------------------------------------------------------------*
185 *---------------------------------------------------------------------------*/
187 T308_stop(call_desc_t *cd)
192 if(cd->T308 != TIMER_IDLE)
194 callout_stop(&cd->T308_timeout);
195 cd->T308 = TIMER_IDLE;
199 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
202 /*---------------------------------------------------------------------------*
203 * timer T309 timeout function
204 *---------------------------------------------------------------------------*/
206 T309_timeout(call_desc_t *cd)
208 NDBGL3(L3_T_ERR, "datalink not reconnected, cr = %d", cd->cr);
209 next_l3state(cd, EV_T309EXP);
212 /*---------------------------------------------------------------------------*
214 *---------------------------------------------------------------------------*/
216 T309_start(call_desc_t *cd)
218 if (cd->T309 == TIMER_ACTIVE)
221 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
222 cd->T309 = TIMER_ACTIVE;
224 callout_reset(&cd->T309_timeout, T309VAL, (void *)T309_timeout, cd);
227 /*---------------------------------------------------------------------------*
229 *---------------------------------------------------------------------------*/
231 T309_stop(call_desc_t *cd)
236 if(cd->T309 != TIMER_IDLE)
238 callout_stop(&cd->T309_timeout);
239 cd->T309 = TIMER_IDLE;
243 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
246 /*---------------------------------------------------------------------------*
247 * timer T310 timeout function
248 *---------------------------------------------------------------------------*/
250 T310_timeout(call_desc_t *cd)
252 NDBGL3(L3_T_ERR, "CALL PROC timeout, cr = %d", cd->cr);
253 next_l3state(cd, EV_T310EXP);
256 /*---------------------------------------------------------------------------*
258 *---------------------------------------------------------------------------*/
260 T310_start(call_desc_t *cd)
262 if (cd->T310 == TIMER_ACTIVE)
265 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
266 cd->T310 = TIMER_ACTIVE;
268 callout_reset(&cd->T310_timeout, T310VAL, (void *)T310_timeout, cd);
271 /*---------------------------------------------------------------------------*
273 *---------------------------------------------------------------------------*/
275 T310_stop(call_desc_t *cd)
280 if(cd->T310 != TIMER_IDLE)
282 callout_stop(&cd->T310_timeout);
283 cd->T310 = TIMER_IDLE;
287 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
290 /*---------------------------------------------------------------------------*
291 * timer T313 timeout function
292 *---------------------------------------------------------------------------*/
294 T313_timeout(call_desc_t *cd)
296 NDBGL3(L3_T_ERR, "CONN ACK not received, cr = %d", cd->cr);
297 next_l3state(cd, EV_T313EXP);
300 /*---------------------------------------------------------------------------*
302 *---------------------------------------------------------------------------*/
304 T313_start(call_desc_t *cd)
306 if (cd->T313 == TIMER_ACTIVE)
309 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
310 cd->T313 = TIMER_ACTIVE;
312 callout_reset(&cd->T313_timeout, T313VAL, (void *)T313_timeout, cd);
315 /*---------------------------------------------------------------------------*
317 *---------------------------------------------------------------------------*/
319 T313_stop(call_desc_t *cd)
324 if(cd->T313 != TIMER_IDLE)
326 cd->T313 = TIMER_IDLE;
327 callout_stop(&cd->T313_timeout);
331 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
334 #endif /* NI4BQ931 > 0 */