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 $
34 * last edit-date: [Thu Aug 24 12:49:50 2000]
36 *---------------------------------------------------------------------------*/
45 #include <sys/param.h>
46 #include <sys/kernel.h>
47 #include <sys/systm.h>
50 #if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
51 #include <sys/callout.h>
55 #include <machine/i4b_debug.h>
56 #include <machine/i4b_ioctl.h>
58 #include <i4b/i4b_debug.h>
59 #include <i4b/i4b_ioctl.h>
62 #include <i4b/include/i4b_global.h>
63 #include <i4b/include/i4b_l3l4.h>
65 #include <i4b/layer3/i4b_l3.h>
66 #include <i4b/layer3/i4b_l3fsm.h>
69 /*---------------------------------------------------------------------------*
70 * stop all layer 3 timers
71 *---------------------------------------------------------------------------*/
72 void i4b_l3_stop_all_timers(call_desc_t *cd)
82 /*---------------------------------------------------------------------------*
83 * timer T303 timeout function
84 *---------------------------------------------------------------------------*/
86 T303_timeout(call_desc_t *cd)
88 NDBGL3(L3_T_ERR, "SETUP not answered, cr = %d", cd->cr);
89 next_l3state(cd, EV_T303EXP);
92 /*---------------------------------------------------------------------------*
94 *---------------------------------------------------------------------------*/
96 T303_start(call_desc_t *cd)
98 if (cd->T303 == TIMER_ACTIVE)
101 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
102 cd->T303 = TIMER_ACTIVE;
104 START_TIMER(cd->T303_callout, T303_timeout, cd, T303VAL);
107 /*---------------------------------------------------------------------------*
109 *---------------------------------------------------------------------------*/
111 T303_stop(call_desc_t *cd)
116 if(cd->T303 != TIMER_IDLE)
118 STOP_TIMER(cd->T303_callout, T303_timeout, cd);
119 cd->T303 = TIMER_IDLE;
122 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
125 /*---------------------------------------------------------------------------*
126 * timer T305 timeout function
127 *---------------------------------------------------------------------------*/
129 T305_timeout(call_desc_t *cd)
131 NDBGL3(L3_T_ERR, "DISC not answered, cr = %d", cd->cr);
132 next_l3state(cd, EV_T305EXP);
135 /*---------------------------------------------------------------------------*
137 *---------------------------------------------------------------------------*/
139 T305_start(call_desc_t *cd)
141 if (cd->T305 == TIMER_ACTIVE)
144 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
145 cd->T305 = TIMER_ACTIVE;
147 START_TIMER(cd->T305_callout, T305_timeout, cd, T305VAL);
150 /*---------------------------------------------------------------------------*
152 *---------------------------------------------------------------------------*/
154 T305_stop(call_desc_t *cd)
159 if(cd->T305 != TIMER_IDLE)
161 STOP_TIMER(cd->T305_callout, T305_timeout, cd);
162 cd->T305 = TIMER_IDLE;
166 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
169 /*---------------------------------------------------------------------------*
170 * timer T308 timeout function
171 *---------------------------------------------------------------------------*/
173 T308_timeout(call_desc_t *cd)
175 NDBGL3(L3_T_ERR, "REL not answered, cr = %d", cd->cr);
176 next_l3state(cd, EV_T308EXP);
179 /*---------------------------------------------------------------------------*
181 *---------------------------------------------------------------------------*/
183 T308_start(call_desc_t *cd)
185 if(cd->T308 == TIMER_ACTIVE)
188 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
189 cd->T308 = TIMER_ACTIVE;
191 START_TIMER(cd->T308_callout, T308_timeout, cd, T308VAL);
194 /*---------------------------------------------------------------------------*
196 *---------------------------------------------------------------------------*/
198 T308_stop(call_desc_t *cd)
203 if(cd->T308 != TIMER_IDLE)
205 STOP_TIMER(cd->T308_callout, T308_timeout, cd);
206 cd->T308 = TIMER_IDLE;
210 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
213 /*---------------------------------------------------------------------------*
214 * timer T309 timeout function
215 *---------------------------------------------------------------------------*/
217 T309_timeout(call_desc_t *cd)
219 NDBGL3(L3_T_ERR, "datalink not reconnected, cr = %d", cd->cr);
220 next_l3state(cd, EV_T309EXP);
223 /*---------------------------------------------------------------------------*
225 *---------------------------------------------------------------------------*/
227 T309_start(call_desc_t *cd)
229 if (cd->T309 == TIMER_ACTIVE)
232 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
233 cd->T309 = TIMER_ACTIVE;
235 START_TIMER(cd->T309_callout, T309_timeout, cd, T309VAL);
238 /*---------------------------------------------------------------------------*
240 *---------------------------------------------------------------------------*/
242 T309_stop(call_desc_t *cd)
247 if(cd->T309 != TIMER_IDLE)
249 STOP_TIMER(cd->T309_callout, T309_timeout, cd);
250 cd->T309 = TIMER_IDLE;
254 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
257 /*---------------------------------------------------------------------------*
258 * timer T310 timeout function
259 *---------------------------------------------------------------------------*/
261 T310_timeout(call_desc_t *cd)
263 NDBGL3(L3_T_ERR, "CALL PROC timeout, cr = %d", cd->cr);
264 next_l3state(cd, EV_T310EXP);
267 /*---------------------------------------------------------------------------*
269 *---------------------------------------------------------------------------*/
271 T310_start(call_desc_t *cd)
273 if (cd->T310 == TIMER_ACTIVE)
276 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
277 cd->T310 = TIMER_ACTIVE;
279 START_TIMER(cd->T310_callout, T310_timeout, cd, T310VAL);
282 /*---------------------------------------------------------------------------*
284 *---------------------------------------------------------------------------*/
286 T310_stop(call_desc_t *cd)
291 if(cd->T310 != TIMER_IDLE)
293 STOP_TIMER(cd->T310_callout, T310_timeout, cd);
294 cd->T310 = TIMER_IDLE;
298 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
301 /*---------------------------------------------------------------------------*
302 * timer T313 timeout function
303 *---------------------------------------------------------------------------*/
305 T313_timeout(call_desc_t *cd)
307 NDBGL3(L3_T_ERR, "CONN ACK not received, cr = %d", cd->cr);
308 next_l3state(cd, EV_T313EXP);
311 /*---------------------------------------------------------------------------*
313 *---------------------------------------------------------------------------*/
315 T313_start(call_desc_t *cd)
317 if (cd->T313 == TIMER_ACTIVE)
320 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
321 cd->T313 = TIMER_ACTIVE;
323 START_TIMER(cd->T313_callout, T313_timeout, cd, T313VAL);
326 /*---------------------------------------------------------------------------*
328 *---------------------------------------------------------------------------*/
330 T313_stop(call_desc_t *cd)
335 if(cd->T313 != TIMER_IDLE)
337 cd->T313 = TIMER_IDLE;
338 STOP_TIMER(cd->T313_callout, T313_timeout, cd);
342 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
345 #endif /* NI4BQ931 > 0 */