2 * Copyright (c) 1997, 2001 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_l3l4.h - layer 3 / layer 4 interface
28 * ------------------------------------------
30 * $Id: i4b_l3l4.h,v 1.32 2000/08/24 11:48:57 hm Exp $
32 * $FreeBSD: src/sys/i4b/include/i4b_l3l4.h,v 1.6.2.2 2001/12/16 15:12:57 hm Exp $
33 * $DragonFly: src/sys/net/i4b/include/i4b_l3l4.h,v 1.5 2005/06/14 21:19:18 joerg Exp $
35 * last edit-date: [Fri Jun 2 14:29:35 2000]
37 *---------------------------------------------------------------------------*/
42 #define T303VAL (hz*4) /* 4 seconds timeout */
43 #define T305VAL (hz*30) /* 30 seconds timeout */
44 #define T308VAL (hz*4) /* 4 seconds timeout */
45 #define T309VAL (hz*90) /* 90 seconds timeout */
46 #define T310VAL (hz*60) /* 30-120 seconds timeout */
47 #define T313VAL (hz*4) /* 4 seconds timeout */
48 #define T400DEF (hz*10) /* 10 seconds timeout */
51 #define N_CALL_DESC (MAX_CONTROLLERS*MAX_BCHAN) /* no of call descriptors */
53 extern int nctrl; /* number of controllers detected in system */
55 typedef struct bchan_statistics {
60 /*---------------------------------------------------------------------------*
61 * table of things the driver needs to know about the b channel
62 * it is connected to for data transfer
63 *---------------------------------------------------------------------------*/
64 typedef struct i4l_isdn_bchan_linktab {
67 void (*bch_config)(int unit, int channel, int bprot, int updown);
68 void (*bch_tx_start)(int unit, int channel);
69 void (*bch_stat)(int unit, int channel, bchan_statistics_t *bsp);
70 struct ifqueue *tx_queue;
71 struct ifqueue *rx_queue; /* data xfer for NON-HDLC traffic */
72 struct mbuf **rx_mbuf; /* data xfer for HDLC based traffic */
75 /*---------------------------------------------------------------------------*
76 * table of things the b channel handler needs to know about
77 * the driver it is connected to for data transfer
78 *---------------------------------------------------------------------------*/
79 typedef struct i4l_driver_bchan_linktab {
81 void (*bch_rx_data_ready)(int unit);
82 void (*bch_tx_queue_empty)(int unit);
83 void (*bch_activity)(int unit, int rxtx);
86 void (*line_connected)(int unit, void *cde);
87 void (*line_disconnected)(int unit, void *cde);
88 void (*dial_response)(int unit, int stat, cause_t cause);
89 void (*updown_ind)(int unit, int updown);
92 /* global linktab functions for controller types (aka hardware drivers) */
93 struct ctrl_type_desc {
94 isdn_link_t* (*get_linktab)(int unit, int channel);
95 void (*set_linktab)(int unit, int channel, drvr_link_t *dlt);
97 extern struct ctrl_type_desc ctrl_types[];
99 /* global linktab functions for RBCH userland driver */
101 drvr_link_t *rbch_ret_linktab(int unit);
102 void rbch_set_linktab(int unit, isdn_link_t *ilt);
104 /* global linktab functions for IPR network driver */
106 drvr_link_t *ipr_ret_linktab(int unit);
107 void ipr_set_linktab(int unit, isdn_link_t *ilt);
109 /* global linktab functions for TEL userland driver */
111 drvr_link_t *tel_ret_linktab(int unit);
112 void tel_set_linktab(int unit, isdn_link_t *ilt);
114 /* global linktab functions for ISPPP userland driver */
116 drvr_link_t *i4bisppp_ret_linktab(int unit);
117 void i4bisppp_set_linktab(int unit, isdn_link_t *ilt);
119 /* global linktab functions for ING network driver */
121 drvr_link_t *ing_ret_linktab(int unit);
122 void ing_set_linktab(int unit, isdn_link_t *ilt);
125 /*---------------------------------------------------------------------------*
126 * this structure describes one call/connection on one B-channel
127 * and all its parameters
128 *---------------------------------------------------------------------------*/
131 u_int cdid; /* call descriptor id */
132 int controller; /* isdn controller number */
133 int cr; /* call reference value */
135 int crflag; /* call reference flag */
136 #define CRF_ORIG 0 /* originating side */
137 #define CRF_DEST 1 /* destinating side */
139 int channelid; /* channel id value */
140 int channelexcl; /* channel exclusive */
142 int bprot; /* B channel protocol BPROT_XXX */
144 int driver; /* driver to use for B channel */
145 int driver_unit; /* unit for above driver number */
147 cause_t cause_in; /* cause value from NT */
148 cause_t cause_out; /* cause value to NT */
150 int call_state; /* from incoming SETUP */
152 u_char dst_telno[TELNO_MAX]; /* destination number */
153 u_char src_telno[TELNO_MAX]; /* source number */
155 int scr_ind; /* screening ind for incoming call */
156 int prs_ind; /* presentation ind for incoming call */
158 int Q931state; /* Q.931 state for call */
159 int event; /* event to be processed */
161 int response; /* setup response type */
163 int T303; /* SETUP sent response timeout */
164 int T303_first_to; /* first timeout flag */
166 int T305; /* DISC without PROG IND */
168 int T308; /* RELEASE sent response timeout*/
169 int T308_first_to; /* first timeout flag */
171 int T309; /* data link disconnect timeout */
173 int T310; /* CALL PROC received */
175 int T313; /* CONNECT sent timeout */
177 int T400; /* L4 timeout */
179 isdn_link_t *ilt; /* isdn B channel linktab */
180 drvr_link_t *dlt; /* driver linktab */
182 int dir; /* outgoing or incoming call */
183 #define DIR_OUTGOING 0
184 #define DIR_INCOMING 1
186 int timeout_active; /* idle timeout() active flag */
188 struct callout idle_timeout;
189 struct callout T303_timeout;
190 struct callout T305_timeout;
191 struct callout T308_timeout;
192 struct callout T309_timeout;
193 struct callout T310_timeout;
194 struct callout T313_timeout;
195 struct callout T400_timeout;
196 int callouts_inited; /* must init before use */
198 int idletime_state; /* wait for idle_time begin */
199 #define IST_IDLE 0 /* shorthold mode disabled */
200 #define IST_NONCHK 1 /* in non-checked window */
201 #define IST_CHECK 2 /* in idle check window */
202 #define IST_SAFE 3 /* in safety zone */
204 time_t idletimechk_start; /* check idletime window start */
205 time_t connect_time; /* time connect was made */
206 time_t last_active_time; /* last time with activity */
208 /* for incoming connections: */
209 time_t max_idle_time; /* max time without activity */
211 /* for outgoing connections: */
212 msg_shorthold_t shorthold_data; /* shorthold data to use */
214 int aocd_flag; /* AOCD used for unitlength calc*/
215 time_t last_aocd_time; /* last time AOCD received */
216 int units; /* number of AOCD charging units*/
217 int units_type; /* units type: AOCD, AOCE */
218 int cunits; /* calculated units */
220 int isdntxdelay; /* isdn tx delay after connect */
222 u_char display[DISPLAY_MAX]; /* display information element */
223 char datetime[DATETIME_MAX]; /* date/time information element*/
224 u_char keypad[KEYPAD_MAX]; /* keypad facility */
227 extern call_desc_t call_desc[N_CALL_DESC];
230 struct isdn_diagnostic_request;
233 /*---------------------------------------------------------------------------*
234 * this structure "describes" one controller
235 *---------------------------------------------------------------------------*/
238 int unit; /* unit number of this contr. */
239 int ctrl_type; /* controller type (CTRL_XXX) */
240 int card_type; /* card manufacturer (CARD_XXX) */
242 int protocol; /* D-channel protocol type */
244 int dl_est; /* layer 2 established */
248 int nbch; /* number of b channels */
249 int bch_state[MAX_BCHAN]; /* states of the b channels */
250 #define BCH_ST_FREE 0 /* free to be used, idle */
251 #define BCH_ST_RSVD 1 /* reserved, may become free or used */
252 #define BCH_ST_USED 2 /* in use for data transfer */
254 int tei; /* current tei or -1 if invalid */
256 /* pointers to functions to be called from L4 */
258 void (*N_CONNECT_REQUEST) (unsigned int);
259 void (*N_CONNECT_RESPONSE) (unsigned int, int, int);
260 void (*N_DISCONNECT_REQUEST) (unsigned int, int);
261 void (*N_ALERT_REQUEST) (unsigned int);
262 int (*N_DOWNLOAD) (int unit, int numprotos, struct isdn_dr_prot *protocols);
263 int (*N_DIAGNOSTICS) (int unit, struct isdn_diagnostic_request*);
264 void (*N_MGMT_COMMAND) (int unit, int cmd, void *);
267 extern ctrl_desc_t ctrl_desc[MAX_CONTROLLERS];
269 #endif /* _I4B_Q931_H_ */