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.6 2005/12/11 12:25:06 christos Exp $
34 * last edit-date: [Fri Jan 5 11:33:47 2001]
36 *---------------------------------------------------------------------------*/
38 #include <sys/cdefs.h>
39 __KERNEL_RCSID(0, "$NetBSD: i4b_l3timer.c,v 1.4.16.1 2005/03/04 16:53:45 skrll Exp $");
48 #include <sys/param.h>
49 #include <sys/kernel.h>
50 #include <sys/systm.h>
52 #include <sys/socket.h>
55 #if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
56 #include <sys/callout.h>
60 #include <machine/i4b_debug.h>
61 #include <machine/i4b_ioctl.h>
63 #include <netisdn/i4b_debug.h>
64 #include <netisdn/i4b_ioctl.h>
67 #include <netisdn/i4b_global.h>
68 #include <netisdn/i4b_isdnq931.h>
69 #include <netisdn/i4b_l3l4.h>
70 #include <netisdn/i4b_mbuf.h>
72 #include <netisdn/i4b_l3.h>
73 #include <netisdn/i4b_l3fsm.h>
74 #include <netisdn/i4b_q931.h>
76 #include <netisdn/i4b_l4.h>
78 /*---------------------------------------------------------------------------*
79 * stop all layer 3 timers
80 *---------------------------------------------------------------------------*/
81 void i4b_l3_stop_all_timers(call_desc_t
*cd
)
91 /*---------------------------------------------------------------------------*
92 * timer T303 timeout function
93 *---------------------------------------------------------------------------*/
95 T303_timeout(call_desc_t
*cd
)
97 NDBGL3(L3_T_ERR
, "SETUP not answered, cr = %d", cd
->cr
);
98 next_l3state(cd
, EV_T303EXP
);
101 /*---------------------------------------------------------------------------*
103 *---------------------------------------------------------------------------*/
105 T303_start(call_desc_t
*cd
)
107 if (cd
->T303
== TIMER_ACTIVE
)
110 NDBGL3(L3_T_MSG
, "cr = %d", cd
->cr
);
111 cd
->T303
= TIMER_ACTIVE
;
113 START_TIMER(cd
->T303_callout
, T303_timeout
, cd
, T303VAL
);
116 /*---------------------------------------------------------------------------*
118 *---------------------------------------------------------------------------*/
120 T303_stop(call_desc_t
*cd
)
125 if(cd
->T303
!= TIMER_IDLE
)
127 STOP_TIMER(cd
->T303_callout
, T303_timeout
, cd
);
128 cd
->T303
= TIMER_IDLE
;
131 NDBGL3(L3_T_MSG
, "cr = %d", cd
->cr
);
134 /*---------------------------------------------------------------------------*
135 * timer T305 timeout function
136 *---------------------------------------------------------------------------*/
138 T305_timeout(call_desc_t
*cd
)
140 NDBGL3(L3_T_ERR
, "DISC not answered, cr = %d", cd
->cr
);
141 next_l3state(cd
, EV_T305EXP
);
144 /*---------------------------------------------------------------------------*
146 *---------------------------------------------------------------------------*/
148 T305_start(call_desc_t
*cd
)
150 if (cd
->T305
== TIMER_ACTIVE
)
153 NDBGL3(L3_T_MSG
, "cr = %d", cd
->cr
);
154 cd
->T305
= TIMER_ACTIVE
;
156 START_TIMER(cd
->T305_callout
, T305_timeout
, cd
, T305VAL
);
159 /*---------------------------------------------------------------------------*
161 *---------------------------------------------------------------------------*/
163 T305_stop(call_desc_t
*cd
)
168 if(cd
->T305
!= TIMER_IDLE
)
170 STOP_TIMER(cd
->T305_callout
, T305_timeout
, cd
);
171 cd
->T305
= TIMER_IDLE
;
175 NDBGL3(L3_T_MSG
, "cr = %d", cd
->cr
);
178 /*---------------------------------------------------------------------------*
179 * timer T308 timeout function
180 *---------------------------------------------------------------------------*/
182 T308_timeout(call_desc_t
*cd
)
184 NDBGL3(L3_T_ERR
, "REL not answered, cr = %d", cd
->cr
);
185 next_l3state(cd
, EV_T308EXP
);
188 /*---------------------------------------------------------------------------*
190 *---------------------------------------------------------------------------*/
192 T308_start(call_desc_t
*cd
)
194 if(cd
->T308
== TIMER_ACTIVE
)
197 NDBGL3(L3_T_MSG
, "cr = %d", cd
->cr
);
198 cd
->T308
= TIMER_ACTIVE
;
200 START_TIMER(cd
->T308_callout
, T308_timeout
, cd
, T308VAL
);
203 /*---------------------------------------------------------------------------*
205 *---------------------------------------------------------------------------*/
207 T308_stop(call_desc_t
*cd
)
212 if(cd
->T308
!= TIMER_IDLE
)
214 STOP_TIMER(cd
->T308_callout
, T308_timeout
, cd
);
215 cd
->T308
= TIMER_IDLE
;
219 NDBGL3(L3_T_MSG
, "cr = %d", cd
->cr
);
222 /*---------------------------------------------------------------------------*
223 * timer T309 timeout function
224 *---------------------------------------------------------------------------*/
226 T309_timeout(call_desc_t
*cd
)
228 NDBGL3(L3_T_ERR
, "datalink not reconnected, cr = %d", cd
->cr
);
229 next_l3state(cd
, EV_T309EXP
);
232 /*---------------------------------------------------------------------------*
234 *---------------------------------------------------------------------------*/
236 T309_start(call_desc_t
*cd
)
238 if (cd
->T309
== TIMER_ACTIVE
)
241 NDBGL3(L3_T_MSG
, "cr = %d", cd
->cr
);
242 cd
->T309
= TIMER_ACTIVE
;
244 START_TIMER(cd
->T309_callout
, T309_timeout
, cd
, T309VAL
);
247 /*---------------------------------------------------------------------------*
249 *---------------------------------------------------------------------------*/
251 T309_stop(call_desc_t
*cd
)
256 if(cd
->T309
!= TIMER_IDLE
)
258 STOP_TIMER(cd
->T309_callout
, T309_timeout
, cd
);
259 cd
->T309
= TIMER_IDLE
;
263 NDBGL3(L3_T_MSG
, "cr = %d", cd
->cr
);
266 /*---------------------------------------------------------------------------*
267 * timer T310 timeout function
268 *---------------------------------------------------------------------------*/
270 T310_timeout(call_desc_t
*cd
)
272 NDBGL3(L3_T_ERR
, "CALL PROC timeout, cr = %d", cd
->cr
);
273 next_l3state(cd
, EV_T310EXP
);
276 /*---------------------------------------------------------------------------*
278 *---------------------------------------------------------------------------*/
280 T310_start(call_desc_t
*cd
)
282 if (cd
->T310
== TIMER_ACTIVE
)
285 NDBGL3(L3_T_MSG
, "cr = %d", cd
->cr
);
286 cd
->T310
= TIMER_ACTIVE
;
288 START_TIMER(cd
->T310_callout
, T310_timeout
, cd
, T310VAL
);
291 /*---------------------------------------------------------------------------*
293 *---------------------------------------------------------------------------*/
295 T310_stop(call_desc_t
*cd
)
300 if(cd
->T310
!= TIMER_IDLE
)
302 STOP_TIMER(cd
->T310_callout
, T310_timeout
, cd
);
303 cd
->T310
= TIMER_IDLE
;
307 NDBGL3(L3_T_MSG
, "cr = %d", cd
->cr
);
310 /*---------------------------------------------------------------------------*
311 * timer T313 timeout function
312 *---------------------------------------------------------------------------*/
314 T313_timeout(call_desc_t
*cd
)
316 NDBGL3(L3_T_ERR
, "CONN ACK not received, cr = %d", cd
->cr
);
317 next_l3state(cd
, EV_T313EXP
);
320 /*---------------------------------------------------------------------------*
322 *---------------------------------------------------------------------------*/
324 T313_start(call_desc_t
*cd
)
326 if (cd
->T313
== TIMER_ACTIVE
)
329 NDBGL3(L3_T_MSG
, "cr = %d", cd
->cr
);
330 cd
->T313
= TIMER_ACTIVE
;
332 START_TIMER(cd
->T313_callout
, T313_timeout
, cd
, T313VAL
);
335 /*---------------------------------------------------------------------------*
337 *---------------------------------------------------------------------------*/
339 T313_stop(call_desc_t
*cd
)
344 if(cd
->T313
!= TIMER_IDLE
)
346 cd
->T313
= TIMER_IDLE
;
347 STOP_TIMER(cd
->T313_callout
, T313_timeout
, cd
);
351 NDBGL3(L3_T_MSG
, "cr = %d", cd
->cr
);
354 #endif /* NI4BQ931 > 0 */