2 * Copyright (c) 1997, 2002 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
26 /*---------------------------------------------------------------------------
28 * i4b_l3timer.c - timer and timeout handling for layer 3
29 * ------------------------------------------------------
30 * last edit-date: [Sat Mar 9 19:35:31 2002]
32 *---------------------------------------------------------------------------*/
34 #include <sys/cdefs.h>
35 __FBSDID("$FreeBSD$");
37 #include <sys/param.h>
38 #include <sys/kernel.h>
39 #include <sys/systm.h>
42 #include <i4b/include/i4b_debug.h>
43 #include <i4b/include/i4b_ioctl.h>
45 #include <i4b/include/i4b_global.h>
46 #include <i4b/include/i4b_l3l4.h>
48 #include <i4b/layer3/i4b_l3.h>
49 #include <i4b/layer3/i4b_l3fsm.h>
51 /*---------------------------------------------------------------------------*
52 * stop all layer 3 timers
53 *---------------------------------------------------------------------------*/
54 void i4b_l3_stop_all_timers(call_desc_t *cd)
64 /*---------------------------------------------------------------------------*
65 * timer T303 timeout function
66 *---------------------------------------------------------------------------*/
68 T303_timeout(call_desc_t *cd)
70 NDBGL3(L3_T_ERR, "SETUP not answered, cr = %d", cd->cr);
71 next_l3state(cd, EV_T303EXP);
74 /*---------------------------------------------------------------------------*
76 *---------------------------------------------------------------------------*/
78 T303_start(call_desc_t *cd)
80 if (cd->T303 == TIMER_ACTIVE)
83 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
84 cd->T303 = TIMER_ACTIVE;
86 START_TIMER(cd->T303_callout, T303_timeout, cd, T303VAL);
89 /*---------------------------------------------------------------------------*
91 *---------------------------------------------------------------------------*/
93 T303_stop(call_desc_t *cd)
98 if(cd->T303 != TIMER_IDLE)
100 STOP_TIMER(cd->T303_callout, T303_timeout, cd);
101 cd->T303 = TIMER_IDLE;
104 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
107 /*---------------------------------------------------------------------------*
108 * timer T305 timeout function
109 *---------------------------------------------------------------------------*/
111 T305_timeout(call_desc_t *cd)
113 NDBGL3(L3_T_ERR, "DISC not answered, cr = %d", cd->cr);
114 next_l3state(cd, EV_T305EXP);
117 /*---------------------------------------------------------------------------*
119 *---------------------------------------------------------------------------*/
121 T305_start(call_desc_t *cd)
123 if (cd->T305 == TIMER_ACTIVE)
126 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
127 cd->T305 = TIMER_ACTIVE;
129 START_TIMER(cd->T305_callout, T305_timeout, cd, T305VAL);
132 /*---------------------------------------------------------------------------*
134 *---------------------------------------------------------------------------*/
136 T305_stop(call_desc_t *cd)
141 if(cd->T305 != TIMER_IDLE)
143 STOP_TIMER(cd->T305_callout, T305_timeout, cd);
144 cd->T305 = TIMER_IDLE;
148 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
151 /*---------------------------------------------------------------------------*
152 * timer T308 timeout function
153 *---------------------------------------------------------------------------*/
155 T308_timeout(call_desc_t *cd)
157 NDBGL3(L3_T_ERR, "REL not answered, cr = %d", cd->cr);
158 next_l3state(cd, EV_T308EXP);
161 /*---------------------------------------------------------------------------*
163 *---------------------------------------------------------------------------*/
165 T308_start(call_desc_t *cd)
167 if(cd->T308 == TIMER_ACTIVE)
170 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
171 cd->T308 = TIMER_ACTIVE;
173 START_TIMER(cd->T308_callout, T308_timeout, cd, T308VAL);
176 /*---------------------------------------------------------------------------*
178 *---------------------------------------------------------------------------*/
180 T308_stop(call_desc_t *cd)
185 if(cd->T308 != TIMER_IDLE)
187 STOP_TIMER(cd->T308_callout, T308_timeout, cd);
188 cd->T308 = TIMER_IDLE;
192 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
195 /*---------------------------------------------------------------------------*
196 * timer T309 timeout function
197 *---------------------------------------------------------------------------*/
199 T309_timeout(call_desc_t *cd)
201 NDBGL3(L3_T_ERR, "datalink not reconnected, cr = %d", cd->cr);
202 next_l3state(cd, EV_T309EXP);
205 /*---------------------------------------------------------------------------*
207 *---------------------------------------------------------------------------*/
209 T309_start(call_desc_t *cd)
211 if (cd->T309 == TIMER_ACTIVE)
214 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
215 cd->T309 = TIMER_ACTIVE;
217 START_TIMER(cd->T309_callout, T309_timeout, cd, T309VAL);
220 /*---------------------------------------------------------------------------*
222 *---------------------------------------------------------------------------*/
224 T309_stop(call_desc_t *cd)
229 if(cd->T309 != TIMER_IDLE)
231 STOP_TIMER(cd->T309_callout, T309_timeout, cd);
232 cd->T309 = TIMER_IDLE;
236 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
239 /*---------------------------------------------------------------------------*
240 * timer T310 timeout function
241 *---------------------------------------------------------------------------*/
243 T310_timeout(call_desc_t *cd)
245 NDBGL3(L3_T_ERR, "CALL PROC timeout, cr = %d", cd->cr);
246 next_l3state(cd, EV_T310EXP);
249 /*---------------------------------------------------------------------------*
251 *---------------------------------------------------------------------------*/
253 T310_start(call_desc_t *cd)
255 if (cd->T310 == TIMER_ACTIVE)
258 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
259 cd->T310 = TIMER_ACTIVE;
261 START_TIMER(cd->T310_callout, T310_timeout, cd, T310VAL);
264 /*---------------------------------------------------------------------------*
266 *---------------------------------------------------------------------------*/
268 T310_stop(call_desc_t *cd)
273 if(cd->T310 != TIMER_IDLE)
275 STOP_TIMER(cd->T310_callout, T310_timeout, cd);
276 cd->T310 = TIMER_IDLE;
280 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
283 /*---------------------------------------------------------------------------*
284 * timer T313 timeout function
285 *---------------------------------------------------------------------------*/
287 T313_timeout(call_desc_t *cd)
289 NDBGL3(L3_T_ERR, "CONN ACK not received, cr = %d", cd->cr);
290 next_l3state(cd, EV_T313EXP);
293 /*---------------------------------------------------------------------------*
295 *---------------------------------------------------------------------------*/
297 T313_start(call_desc_t *cd)
299 if (cd->T313 == TIMER_ACTIVE)
302 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
303 cd->T313 = TIMER_ACTIVE;
305 START_TIMER(cd->T313_callout, T313_timeout, cd, T313VAL);
308 /*---------------------------------------------------------------------------*
310 *---------------------------------------------------------------------------*/
312 T313_stop(call_desc_t *cd)
317 if(cd->T313 != TIMER_IDLE)
319 cd->T313 = TIMER_IDLE;
320 STOP_TIMER(cd->T313_callout, T313_timeout, cd);
324 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);