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.3 2003/08/07 21:17:29 dillon Exp $
35 * last edit-date: [Thu Aug 24 12:49:50 2000]
37 *---------------------------------------------------------------------------*/
40 #include "use_i4bq931.h"
46 #include <sys/param.h>
47 #include <sys/kernel.h>
48 #include <sys/systm.h>
51 #if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
52 #include <sys/callout.h>
56 #include <net/i4b/include/machine/i4b_debug.h>
57 #include <net/i4b/include/machine/i4b_ioctl.h>
59 #include <i4b/i4b_debug.h>
60 #include <i4b/i4b_ioctl.h>
63 #include "../include/i4b_global.h"
64 #include "../include/i4b_l3l4.h"
67 #include "i4b_l3fsm.h"
70 /*---------------------------------------------------------------------------*
71 * stop all layer 3 timers
72 *---------------------------------------------------------------------------*/
73 void i4b_l3_stop_all_timers(call_desc_t *cd)
83 /*---------------------------------------------------------------------------*
84 * timer T303 timeout function
85 *---------------------------------------------------------------------------*/
87 T303_timeout(call_desc_t *cd)
89 NDBGL3(L3_T_ERR, "SETUP not answered, cr = %d", cd->cr);
90 next_l3state(cd, EV_T303EXP);
93 /*---------------------------------------------------------------------------*
95 *---------------------------------------------------------------------------*/
97 T303_start(call_desc_t *cd)
99 if (cd->T303 == TIMER_ACTIVE)
102 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
103 cd->T303 = TIMER_ACTIVE;
105 START_TIMER(cd->T303_callout, T303_timeout, cd, T303VAL);
108 /*---------------------------------------------------------------------------*
110 *---------------------------------------------------------------------------*/
112 T303_stop(call_desc_t *cd)
117 if(cd->T303 != TIMER_IDLE)
119 STOP_TIMER(cd->T303_callout, T303_timeout, cd);
120 cd->T303 = TIMER_IDLE;
123 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
126 /*---------------------------------------------------------------------------*
127 * timer T305 timeout function
128 *---------------------------------------------------------------------------*/
130 T305_timeout(call_desc_t *cd)
132 NDBGL3(L3_T_ERR, "DISC not answered, cr = %d", cd->cr);
133 next_l3state(cd, EV_T305EXP);
136 /*---------------------------------------------------------------------------*
138 *---------------------------------------------------------------------------*/
140 T305_start(call_desc_t *cd)
142 if (cd->T305 == TIMER_ACTIVE)
145 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
146 cd->T305 = TIMER_ACTIVE;
148 START_TIMER(cd->T305_callout, T305_timeout, cd, T305VAL);
151 /*---------------------------------------------------------------------------*
153 *---------------------------------------------------------------------------*/
155 T305_stop(call_desc_t *cd)
160 if(cd->T305 != TIMER_IDLE)
162 STOP_TIMER(cd->T305_callout, T305_timeout, cd);
163 cd->T305 = TIMER_IDLE;
167 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
170 /*---------------------------------------------------------------------------*
171 * timer T308 timeout function
172 *---------------------------------------------------------------------------*/
174 T308_timeout(call_desc_t *cd)
176 NDBGL3(L3_T_ERR, "REL not answered, cr = %d", cd->cr);
177 next_l3state(cd, EV_T308EXP);
180 /*---------------------------------------------------------------------------*
182 *---------------------------------------------------------------------------*/
184 T308_start(call_desc_t *cd)
186 if(cd->T308 == TIMER_ACTIVE)
189 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
190 cd->T308 = TIMER_ACTIVE;
192 START_TIMER(cd->T308_callout, T308_timeout, cd, T308VAL);
195 /*---------------------------------------------------------------------------*
197 *---------------------------------------------------------------------------*/
199 T308_stop(call_desc_t *cd)
204 if(cd->T308 != TIMER_IDLE)
206 STOP_TIMER(cd->T308_callout, T308_timeout, cd);
207 cd->T308 = TIMER_IDLE;
211 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
214 /*---------------------------------------------------------------------------*
215 * timer T309 timeout function
216 *---------------------------------------------------------------------------*/
218 T309_timeout(call_desc_t *cd)
220 NDBGL3(L3_T_ERR, "datalink not reconnected, cr = %d", cd->cr);
221 next_l3state(cd, EV_T309EXP);
224 /*---------------------------------------------------------------------------*
226 *---------------------------------------------------------------------------*/
228 T309_start(call_desc_t *cd)
230 if (cd->T309 == TIMER_ACTIVE)
233 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
234 cd->T309 = TIMER_ACTIVE;
236 START_TIMER(cd->T309_callout, T309_timeout, cd, T309VAL);
239 /*---------------------------------------------------------------------------*
241 *---------------------------------------------------------------------------*/
243 T309_stop(call_desc_t *cd)
248 if(cd->T309 != TIMER_IDLE)
250 STOP_TIMER(cd->T309_callout, T309_timeout, cd);
251 cd->T309 = TIMER_IDLE;
255 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
258 /*---------------------------------------------------------------------------*
259 * timer T310 timeout function
260 *---------------------------------------------------------------------------*/
262 T310_timeout(call_desc_t *cd)
264 NDBGL3(L3_T_ERR, "CALL PROC timeout, cr = %d", cd->cr);
265 next_l3state(cd, EV_T310EXP);
268 /*---------------------------------------------------------------------------*
270 *---------------------------------------------------------------------------*/
272 T310_start(call_desc_t *cd)
274 if (cd->T310 == TIMER_ACTIVE)
277 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
278 cd->T310 = TIMER_ACTIVE;
280 START_TIMER(cd->T310_callout, T310_timeout, cd, T310VAL);
283 /*---------------------------------------------------------------------------*
285 *---------------------------------------------------------------------------*/
287 T310_stop(call_desc_t *cd)
292 if(cd->T310 != TIMER_IDLE)
294 STOP_TIMER(cd->T310_callout, T310_timeout, cd);
295 cd->T310 = TIMER_IDLE;
299 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
302 /*---------------------------------------------------------------------------*
303 * timer T313 timeout function
304 *---------------------------------------------------------------------------*/
306 T313_timeout(call_desc_t *cd)
308 NDBGL3(L3_T_ERR, "CONN ACK not received, cr = %d", cd->cr);
309 next_l3state(cd, EV_T313EXP);
312 /*---------------------------------------------------------------------------*
314 *---------------------------------------------------------------------------*/
316 T313_start(call_desc_t *cd)
318 if (cd->T313 == TIMER_ACTIVE)
321 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
322 cd->T313 = TIMER_ACTIVE;
324 START_TIMER(cd->T313_callout, T313_timeout, cd, T313VAL);
327 /*---------------------------------------------------------------------------*
329 *---------------------------------------------------------------------------*/
331 T313_stop(call_desc_t *cd)
336 if(cd->T313 != TIMER_IDLE)
338 cd->T313 = TIMER_IDLE;
339 STOP_TIMER(cd->T313_callout, T313_timeout, cd);
343 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
346 #endif /* NI4BQ931 > 0 */