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_l2timer.c - layer 2 timer handling
28 * --------------------------------------
30 * $Id: i4b_l2timer.c,v 1.11 2006/11/16 01:33:49 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_l2timer.c,v 1.10 2006/10/16 12:23:00 pooka 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_l2.h>
69 #include <netisdn/i4b_l1l2.h>
70 #include <netisdn/i4b_isdnq931.h>
71 #include <netisdn/i4b_mbuf.h>
72 #include <netisdn/i4b_l2fsm.h>
73 #include <netisdn/i4b_l3l4.h>
75 /*---------------------------------------------------------------------------*
76 * Q.921 timer T200 timeout function
77 *---------------------------------------------------------------------------*/
79 i4b_T200_timeout(l2_softc_t
*l2sc
)
81 NDBGL2(L2_T_ERR
, "isdnif %d, RC = %d", l2sc
->drv
->isdnif
, l2sc
->RC
);
82 i4b_next_l2state(l2sc
, l2sc
->drv
, EV_T200EXP
);
85 /*---------------------------------------------------------------------------*
86 * Q.921 timer T200 start
87 *---------------------------------------------------------------------------*/
89 i4b_T200_start(l2_softc_t
*l2sc
)
91 if(l2sc
->T200
== TIMER_ACTIVE
)
94 NDBGL2(L2_T_MSG
, "isdnif %d", l2sc
->drv
->isdnif
);
95 l2sc
->T200
= TIMER_ACTIVE
;
97 START_TIMER(l2sc
->T200_callout
, i4b_T200_timeout
, l2sc
, T200DEF
);
100 /*---------------------------------------------------------------------------*
101 * Q.921 timer T200 stop
102 *---------------------------------------------------------------------------*/
104 i4b_T200_stop(l2_softc_t
*l2sc
)
108 if(l2sc
->T200
!= TIMER_IDLE
)
110 STOP_TIMER(l2sc
->T200_callout
, i4b_T200_timeout
, l2sc
);
111 l2sc
->T200
= TIMER_IDLE
;
114 NDBGL2(L2_T_MSG
, "isdnif %d", l2sc
->drv
->isdnif
);
117 /*---------------------------------------------------------------------------*
118 * Q.921 timer T200 restart
119 *---------------------------------------------------------------------------*/
121 i4b_T200_restart(l2_softc_t
*l2sc
)
125 if(l2sc
->T200
!= TIMER_IDLE
)
127 STOP_TIMER(l2sc
->T200_callout
, i4b_T200_timeout
, l2sc
);
131 l2sc
->T200
= TIMER_ACTIVE
;
134 START_TIMER(l2sc
->T200_callout
, i4b_T200_timeout
, l2sc
, T200DEF
);
136 NDBGL2(L2_T_MSG
, "isdnif %d", l2sc
->drv
->isdnif
);
139 /*---------------------------------------------------------------------------*
140 * Q.921 timer T202 timeout function
141 *---------------------------------------------------------------------------*/
143 i4b_T202_timeout(l2_softc_t
*l2sc
)
145 NDBGL2(L2_T_ERR
, "isdnif %d, N202 = %d", l2sc
->drv
->isdnif
, l2sc
->N202
);
149 (*l2sc
->T202func
)(l2sc
);
153 /*---------------------------------------------------------------------------*
154 * Q.921 timer T202 start
155 *---------------------------------------------------------------------------*/
157 i4b_T202_start(l2_softc_t
*l2sc
)
159 if (l2sc
->N202
== TIMER_ACTIVE
)
162 NDBGL2(L2_T_MSG
, "isdnif %d", l2sc
->drv
->isdnif
);
163 l2sc
->N202
= N202DEF
;
164 l2sc
->T202
= TIMER_ACTIVE
;
166 START_TIMER(l2sc
->T202_callout
, i4b_T202_timeout
, l2sc
, T202DEF
);
169 /*---------------------------------------------------------------------------*
170 * Q.921 timer T202 stop
171 *---------------------------------------------------------------------------*/
173 i4b_T202_stop(l2_softc_t
*l2sc
)
177 if(l2sc
->T202
!= TIMER_IDLE
)
179 STOP_TIMER(l2sc
->T202_callout
, i4b_T202_timeout
, l2sc
);
180 l2sc
->T202
= TIMER_IDLE
;
183 NDBGL2(L2_T_MSG
, "isdnif %d", l2sc
->drv
->isdnif
);
186 /*---------------------------------------------------------------------------*
187 * Q.921 timer T203 timeout function
188 *---------------------------------------------------------------------------*/
191 i4b_T203_timeout(l2_softc_t
*l2sc
)
193 NDBGL2(L2_T_ERR
, "isdnif %d", l2sc
->isdnif
);
194 i4b_next_l2state(l2sc
, EV_T203EXP
);
198 /*---------------------------------------------------------------------------*
199 * Q.921 timer T203 start
200 *---------------------------------------------------------------------------*/
202 i4b_T203_start(l2_softc_t
*l2sc
)
205 if (l2sc
->T203
== TIMER_ACTIVE
)
208 NDBGL2(L2_T_MSG
, "isdnif %d", l2sc
->isdnif
);
209 l2sc
->T203
= TIMER_ACTIVE
;
211 START_TIMER(l2sc
->T203_callout
, i4b_T203_timeout
, l2sc
, T203DEF
);
215 /*---------------------------------------------------------------------------*
216 * Q.921 timer T203 stop
217 *---------------------------------------------------------------------------*/
219 i4b_T203_stop(l2_softc_t
*l2sc
)
224 if(l2sc
->T203
!= TIMER_IDLE
)
226 STOP_TIMER(l2sc
->T203_callout
, i4b_T203_timeout
, l2sc
);
227 l2sc
->T203
= TIMER_IDLE
;
230 NDBGL2(L2_T_MSG
, "isdnif %d", l2sc
->isdnif
);
234 /*---------------------------------------------------------------------------*
235 * Q.921 timer T203 restart
236 *---------------------------------------------------------------------------*/
238 i4b_T203_restart(l2_softc_t
*l2sc
)
244 if(l2sc
->T203
!= TIMER_IDLE
)
246 STOP_TIMER(l2sc
->T203_callout
, i4b_T203_timerout
, l2sc
);
250 l2sc
->T203
= TIMER_ACTIVE
;
253 START_TIMER(l2sc
->T203_callout
, i4b_T203_timerout
, l2sc
, T203DEF
);
255 NDBGL2(L2_T_MSG
, "isdnif %d", l2sc
->isdnif
);
259 #endif /* NI4BQ921 > 0 */