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_l2timer.c - layer 2 timer handling
29 * --------------------------------------
30 * last edit-date: [Sat Mar 9 17:48:58 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>
40 #include <sys/socket.h>
43 #include <i4b/include/i4b_debug.h>
45 #include <i4b/include/i4b_global.h>
47 #include <i4b/layer2/i4b_l2.h>
48 #include <i4b/layer2/i4b_l2fsm.h>
50 /*---------------------------------------------------------------------------*
51 * Q.921 timer T200 timeout function
52 *---------------------------------------------------------------------------*/
54 i4b_T200_timeout(l2_softc_t *l2sc)
56 NDBGL2(L2_T_ERR, "unit %d, RC = %d", l2sc->unit, l2sc->RC);
57 i4b_next_l2state(l2sc, EV_T200EXP);
60 /*---------------------------------------------------------------------------*
61 * Q.921 timer T200 start
62 *---------------------------------------------------------------------------*/
64 i4b_T200_start(l2_softc_t *l2sc)
66 if(l2sc->T200 == TIMER_ACTIVE)
69 NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
70 l2sc->T200 = TIMER_ACTIVE;
72 START_TIMER(l2sc->T200_callout, i4b_T200_timeout, l2sc, T200DEF);
75 /*---------------------------------------------------------------------------*
76 * Q.921 timer T200 stop
77 *---------------------------------------------------------------------------*/
79 i4b_T200_stop(l2_softc_t *l2sc)
83 if(l2sc->T200 != TIMER_IDLE)
85 STOP_TIMER(l2sc->T200_callout, i4b_T200_timeout, l2sc);
86 l2sc->T200 = TIMER_IDLE;
89 NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
92 /*---------------------------------------------------------------------------*
93 * Q.921 timer T200 restart
94 *---------------------------------------------------------------------------*/
96 i4b_T200_restart(l2_softc_t *l2sc)
100 if(l2sc->T200 != TIMER_IDLE)
102 STOP_TIMER(l2sc->T200_callout, i4b_T200_timeout, l2sc);
106 l2sc->T200 = TIMER_ACTIVE;
109 START_TIMER(l2sc->T200_callout, i4b_T200_timeout, l2sc, T200DEF);
111 NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
114 /*---------------------------------------------------------------------------*
115 * Q.921 timer T202 timeout function
116 *---------------------------------------------------------------------------*/
118 i4b_T202_timeout(l2_softc_t *l2sc)
120 NDBGL2(L2_T_ERR, "unit %d, N202 = %d", l2sc->unit, l2sc->N202);
124 (*l2sc->T202func)(l2sc);
128 /*---------------------------------------------------------------------------*
129 * Q.921 timer T202 start
130 *---------------------------------------------------------------------------*/
132 i4b_T202_start(l2_softc_t *l2sc)
134 if (l2sc->N202 == TIMER_ACTIVE)
137 NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
138 l2sc->N202 = N202DEF;
139 l2sc->T202 = TIMER_ACTIVE;
141 START_TIMER(l2sc->T202_callout, i4b_T202_timeout, l2sc, T202DEF);
144 /*---------------------------------------------------------------------------*
145 * Q.921 timer T202 stop
146 *---------------------------------------------------------------------------*/
148 i4b_T202_stop(l2_softc_t *l2sc)
152 if(l2sc->T202 != TIMER_IDLE)
154 STOP_TIMER(l2sc->T202_callout, i4b_T202_timeout, l2sc);
155 l2sc->T202 = TIMER_IDLE;
158 NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
161 /*---------------------------------------------------------------------------*
162 * Q.921 timer T203 timeout function
163 *---------------------------------------------------------------------------*/
164 #if defined(I4B_T203_ACTIVE) && I4B_T203_ACTIVE
166 i4b_T203_timeout(l2_softc_t *l2sc)
168 NDBGL2(L2_T_ERR, "unit %d", l2sc->unit);
169 i4b_next_l2state(l2sc, EV_T203EXP);
173 /*---------------------------------------------------------------------------*
174 * Q.921 timer T203 start
175 *---------------------------------------------------------------------------*/
177 i4b_T203_start(l2_softc_t *l2sc)
179 #if defined(I4B_T203_ACTIVE) && I4B_T203_ACTIVE
180 if (l2sc->T203 == TIMER_ACTIVE)
183 NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
184 l2sc->T203 = TIMER_ACTIVE;
186 START_TIMER(l2sc->T203_callout, i4b_T203_timeout, l2sc, T203DEF);
190 /*---------------------------------------------------------------------------*
191 * Q.921 timer T203 stop
192 *---------------------------------------------------------------------------*/
194 i4b_T203_stop(l2_softc_t *l2sc)
196 #if defined(I4B_T203_ACTIVE) && I4B_T203_ACTIVE
199 if(l2sc->T203 != TIMER_IDLE)
201 STOP_TIMER(l2sc->T203_callout, i4b_T203_timeout, l2sc);
202 l2sc->T203 = TIMER_IDLE;
205 NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
209 /*---------------------------------------------------------------------------*
210 * Q.921 timer T203 restart
211 *---------------------------------------------------------------------------*/
213 i4b_T203_restart(l2_softc_t *l2sc)
215 #if defined(I4B_T203_ACTIVE) && I4B_T203_ACTIVE
219 if(l2sc->T203 != TIMER_IDLE)
221 STOP_TIMER(l2sc->T203_callout, i4b_T203_timerout, l2sc);
225 l2sc->T203 = TIMER_ACTIVE;
228 START_TIMER(l2sc->T203_callout, i4b_T203_timerout, l2sc, T203DEF);
230 NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);