Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / netisdn / i4b_l3timer.c
blob87c748b77b6a7b331493a0d34d00c14677efd397
1 /*
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
6 * are met:
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
23 * SUCH DAMAGE.
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 $
32 * $FreeBSD$
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 $");
41 #ifdef __FreeBSD__
42 #include "i4bq931.h"
43 #else
44 #define NI4BQ931 1
45 #endif
46 #if NI4BQ931 > 0
48 #include <sys/param.h>
49 #include <sys/kernel.h>
50 #include <sys/systm.h>
51 #include <sys/mbuf.h>
52 #include <sys/socket.h>
53 #include <net/if.h>
55 #if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
56 #include <sys/callout.h>
57 #endif
59 #ifdef __FreeBSD__
60 #include <machine/i4b_debug.h>
61 #include <machine/i4b_ioctl.h>
62 #else
63 #include <netisdn/i4b_debug.h>
64 #include <netisdn/i4b_ioctl.h>
65 #endif
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)
83 T303_stop(cd);
84 T305_stop(cd);
85 T308_stop(cd);
86 T309_stop(cd);
87 T310_stop(cd);
88 T313_stop(cd);
91 /*---------------------------------------------------------------------------*
92 * timer T303 timeout function
93 *---------------------------------------------------------------------------*/
94 static void
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 /*---------------------------------------------------------------------------*
102 * timer T303 start
103 *---------------------------------------------------------------------------*/
104 void
105 T303_start(call_desc_t *cd)
107 if (cd->T303 == TIMER_ACTIVE)
108 return;
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 /*---------------------------------------------------------------------------*
117 * timer T303 stop
118 *---------------------------------------------------------------------------*/
119 void
120 T303_stop(call_desc_t *cd)
122 int s;
123 s = splnet();
125 if(cd->T303 != TIMER_IDLE)
127 STOP_TIMER(cd->T303_callout, T303_timeout, cd);
128 cd->T303 = TIMER_IDLE;
130 splx(s);
131 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
134 /*---------------------------------------------------------------------------*
135 * timer T305 timeout function
136 *---------------------------------------------------------------------------*/
137 static void
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 /*---------------------------------------------------------------------------*
145 * timer T305 start
146 *---------------------------------------------------------------------------*/
147 void
148 T305_start(call_desc_t *cd)
150 if (cd->T305 == TIMER_ACTIVE)
151 return;
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 /*---------------------------------------------------------------------------*
160 * timer T305 stop
161 *---------------------------------------------------------------------------*/
162 void
163 T305_stop(call_desc_t *cd)
165 int s;
166 s = splnet();
168 if(cd->T305 != TIMER_IDLE)
170 STOP_TIMER(cd->T305_callout, T305_timeout, cd);
171 cd->T305 = TIMER_IDLE;
173 splx(s);
175 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
178 /*---------------------------------------------------------------------------*
179 * timer T308 timeout function
180 *---------------------------------------------------------------------------*/
181 static void
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 /*---------------------------------------------------------------------------*
189 * timer T308 start
190 *---------------------------------------------------------------------------*/
191 void
192 T308_start(call_desc_t *cd)
194 if(cd->T308 == TIMER_ACTIVE)
195 return;
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 /*---------------------------------------------------------------------------*
204 * timer T308 stop
205 *---------------------------------------------------------------------------*/
206 void
207 T308_stop(call_desc_t *cd)
209 int s;
210 s = splnet();
212 if(cd->T308 != TIMER_IDLE)
214 STOP_TIMER(cd->T308_callout, T308_timeout, cd);
215 cd->T308 = TIMER_IDLE;
217 splx(s);
219 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
222 /*---------------------------------------------------------------------------*
223 * timer T309 timeout function
224 *---------------------------------------------------------------------------*/
225 static void
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 /*---------------------------------------------------------------------------*
233 * timer T309 start
234 *---------------------------------------------------------------------------*/
235 void
236 T309_start(call_desc_t *cd)
238 if (cd->T309 == TIMER_ACTIVE)
239 return;
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 /*---------------------------------------------------------------------------*
248 * timer T309 stop
249 *---------------------------------------------------------------------------*/
250 void
251 T309_stop(call_desc_t *cd)
253 int s;
254 s = splnet();
256 if(cd->T309 != TIMER_IDLE)
258 STOP_TIMER(cd->T309_callout, T309_timeout, cd);
259 cd->T309 = TIMER_IDLE;
261 splx(s);
263 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
266 /*---------------------------------------------------------------------------*
267 * timer T310 timeout function
268 *---------------------------------------------------------------------------*/
269 static void
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 /*---------------------------------------------------------------------------*
277 * timer T310 start
278 *---------------------------------------------------------------------------*/
279 void
280 T310_start(call_desc_t *cd)
282 if (cd->T310 == TIMER_ACTIVE)
283 return;
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 /*---------------------------------------------------------------------------*
292 * timer T310 stop
293 *---------------------------------------------------------------------------*/
294 void
295 T310_stop(call_desc_t *cd)
297 int s;
298 s = splnet();
300 if(cd->T310 != TIMER_IDLE)
302 STOP_TIMER(cd->T310_callout, T310_timeout, cd);
303 cd->T310 = TIMER_IDLE;
305 splx(s);
307 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
310 /*---------------------------------------------------------------------------*
311 * timer T313 timeout function
312 *---------------------------------------------------------------------------*/
313 static void
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 /*---------------------------------------------------------------------------*
321 * timer T313 start
322 *---------------------------------------------------------------------------*/
323 void
324 T313_start(call_desc_t *cd)
326 if (cd->T313 == TIMER_ACTIVE)
327 return;
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 /*---------------------------------------------------------------------------*
336 * timer T313 stop
337 *---------------------------------------------------------------------------*/
338 void
339 T313_stop(call_desc_t *cd)
341 int s;
342 s = splnet();
344 if(cd->T313 != TIMER_IDLE)
346 cd->T313 = TIMER_IDLE;
347 STOP_TIMER(cd->T313_callout, T313_timeout, cd);
349 splx(s);
351 NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
354 #endif /* NI4BQ931 > 0 */