1 /*-
2 * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
3 *
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.
12 *
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.
24 */
25
26 /*---------------------------------------------------------------------------
27 *
28 * i4b_l3l4.h - layer 3 / layer 4 interface
29 * ------------------------------------------
30 *
31 * $FreeBSD: releng/6.0/sys/i4b/include/i4b_l3l4.h 139790 2005-01-06 22:18:23Z imp $
32 *
33 * last edit-date: [Sun Aug 11 12:52:41 2002]
34 *
35 *---------------------------------------------------------------------------*/
36
37 #ifndef _I4B_L3L4_H_
38 #define _I4B_L3L4_H_
39
40 #define T303VAL (hz*4) /* 4 seconds timeout */
41 #define T305VAL (hz*30) /* 30 seconds timeout */
42 #define T308VAL (hz*4) /* 4 seconds timeout */
43 #define T309VAL (hz*90) /* 90 seconds timeout */
44 #define T310VAL (hz*60) /* 30-120 seconds timeout */
45 #define T313VAL (hz*4) /* 4 seconds timeout */
46 #define T400DEF (hz*10) /* 10 seconds timeout */
47
48 #define MAX_BCHAN 30
49 #define N_CALL_DESC (MAX_CONTROLLERS*MAX_BCHAN) /* no of call descriptors */
50
51 extern int nctrl; /* number of controllers detected in system */
52
53 typedef struct bchan_statistics {
54 int outbytes;
55 int inbytes;
56 } bchan_statistics_t;
57
58 /*---------------------------------------------------------------------------*
59 * table of things the driver needs to know about the b channel
60 * it is connected to for data transfer
61 *---------------------------------------------------------------------------*/
62 typedef struct i4l_isdn_bchan_linktab {
63 int unit;
64 int channel;
65 void (*bch_config)(int unit, int channel, int bprot, int updown);
66 void (*bch_tx_start)(int unit, int channel);
67 void (*bch_stat)(int unit, int channel, bchan_statistics_t *bsp);
68 struct ifqueue *tx_queue;
69 struct ifqueue *rx_queue; /* data xfer for NON-HDLC traffic */
70 struct mbuf **rx_mbuf; /* data xfer for HDLC based traffic */
71 } isdn_link_t;
72
73 /*---------------------------------------------------------------------------*
74 * table of things the b channel handler needs to know about
75 * the driver it is connected to for data transfer
76 *---------------------------------------------------------------------------*/
77 typedef struct i4l_driver_bchan_linktab {
78 int unit;
79 void (*bch_rx_data_ready)(int unit);
80 void (*bch_tx_queue_empty)(int unit);
81 void (*bch_activity)(int unit, int rxtx);
82 #define ACT_RX 0
83 #define ACT_TX 1
84 void (*line_connected)(int unit, void *cde);
85 void (*line_disconnected)(int unit, void *cde);
86 void (*dial_response)(int unit, int stat, cause_t cause);
87 void (*updown_ind)(int unit, int updown);
88 } drvr_link_t;
89
90 /* global linktab functions for controller types (aka hardware drivers) */
91 struct ctrl_type_desc {
92 isdn_link_t* (*get_linktab)(int unit, int channel);
93 void (*set_linktab)(int unit, int channel, drvr_link_t *dlt);
94 };
95 extern struct ctrl_type_desc ctrl_types[];
96
97 /* global linktab functions for RBCH userland driver */
98
99 drvr_link_t *rbch_ret_linktab(int unit);
100 void rbch_set_linktab(int unit, isdn_link_t *ilt);
101
102 /* global linktab functions for IPR network driver */
103
104 drvr_link_t *ipr_ret_linktab(int unit);
105 void ipr_set_linktab(int unit, isdn_link_t *ilt);
106
107 /* global linktab functions for TEL userland driver */
108
109 drvr_link_t *tel_ret_linktab(int unit);
110 void tel_set_linktab(int unit, isdn_link_t *ilt);
111
112 /* global linktab functions for ISPPP userland driver */
113
114 drvr_link_t *i4bisppp_ret_linktab(int unit);
115 void i4bisppp_set_linktab(int unit, isdn_link_t *ilt);
116
117 /* global linktab functions for ING network driver */
118
119 drvr_link_t *ing_ret_linktab(int unit);
120 void ing_set_linktab(int unit, isdn_link_t *ilt);
121
122
123 /*---------------------------------------------------------------------------*
124 * this structure describes one call/connection on one B-channel
125 * and all its parameters
126 *---------------------------------------------------------------------------*/
127 typedef struct
128 {
129 u_int cdid; /* call descriptor id */
130 int controller; /* isdn controller number */
131 int cr; /* call reference value */
132
133 int crflag; /* call reference flag */
134 #define CRF_ORIG 0 /* originating side */
135 #define CRF_DEST 1 /* destinating side */
136
137 int channelid; /* channel id value */
138 int channelexcl; /* channel exclusive */
139
140 int bprot; /* B channel protocol BPROT_XXX */
141
142 int bcap; /* special bearer capabilities BCAP_XXX */
143
144 int driver; /* driver to use for B channel */
145 int driver_unit; /* unit for above driver number */
146
147 cause_t cause_in; /* cause value from NT */
148 cause_t cause_out; /* cause value to NT */
149
150 int call_state; /* from incoming SETUP */
151
152 u_char dst_telno[TELNO_MAX]; /* destination number */
153 u_char dst_subaddr[SUBADDR_MAX]; /* destination subaddr */
154 u_char src_telno[TELNO_MAX]; /* source number */
155 u_char src_subaddr[SUBADDR_MAX]; /* source subaddr */
156
157 int dst_ton; /* destination type of number */
158 int src_ton; /* source type of number */
159
160 int scr_ind; /* screening ind for incoming call */
161 int prs_ind; /* presentation ind for incoming call */
162
163 int Q931state; /* Q.931 state for call */
164 int event; /* event to be processed */
165
166 int response; /* setup response type */
167
168 int T303; /* SETUP sent response timeout */
169 int T303_first_to; /* first timeout flag */
170
171 int T305; /* DISC without PROG IND */
172
173 int T308; /* RELEASE sent response timeout*/
174 int T308_first_to; /* first timeout flag */
175
176 int T309; /* data link disconnect timeout */
177
178 int T310; /* CALL PROC received */
179
180 int T313; /* CONNECT sent timeout */
181
182 int T400; /* L4 timeout */
183
184 isdn_link_t *ilt; /* isdn B channel linktab */
185 drvr_link_t *dlt; /* driver linktab */
186
187 int dir; /* outgoing or incoming call */
188 #define DIR_OUTGOING 0
189 #define DIR_INCOMING 1
190
191 int timeout_active; /* idle timeout() active flag */
192
193 int callouts_inited; /* must init before use */
194 struct callout_handle idle_timeout_handle;
195 struct callout_handle T303_callout;
196 struct callout_handle T305_callout;
197 struct callout_handle T308_callout;
198 struct callout_handle T309_callout;
199 struct callout_handle T310_callout;
200 struct callout_handle T313_callout;
201 struct callout_handle T400_callout;
202
203 int idletime_state; /* wait for idle_time begin */
204 #define IST_IDLE 0 /* shorthold mode disabled */
205 #define IST_NONCHK 1 /* in non-checked window */
206 #define IST_CHECK 2 /* in idle check window */
207 #define IST_SAFE 3 /* in safety zone */
208
209 time_t idletimechk_start; /* check idletime window start */
210 time_t connect_time; /* time connect was made */
211 time_t last_active_time; /* last time with activity */
212
213 /* for incoming connections: */
214 time_t max_idle_time; /* max time without activity */
215
216 /* for outgoing connections: */
217 msg_shorthold_t shorthold_data; /* shorthold data to use */
218
219 int aocd_flag; /* AOCD used for unitlength calc*/
220 time_t last_aocd_time; /* last time AOCD received */
221 int units; /* number of AOCD charging units*/
222 int units_type; /* units type: AOCD, AOCE */
223 int cunits; /* calculated units */
224
225 int isdntxdelay; /* isdn tx delay after connect */
226
227 u_char display[DISPLAY_MAX]; /* display information element */
228 char datetime[DATETIME_MAX]; /* date/time information element*/
229 u_char keypad[KEYPAD_MAX]; /* keypad facility */
230 } call_desc_t;
231
232 extern call_desc_t call_desc[N_CALL_DESC];
233
234 /* forward decl. */
235 struct isdn_diagnostic_request;
236 struct isdn_dr_prot;
237
238 /*---------------------------------------------------------------------------*
239 * this structure "describes" one controller
240 *---------------------------------------------------------------------------*/
241 typedef struct
242 {
243 int unit; /* unit number of this contr. */
244 int ctrl_type; /* controller type (CTRL_XXX) */
245 int card_type; /* card manufacturer (CARD_XXX) */
246
247 int protocol; /* D-channel protocol type */
248
249 int dl_est; /* layer 2 established */
250 #define DL_DOWN 0
251 #define DL_UP 1
252
253 int nbch; /* number of b channels */
254 int bch_state[MAX_BCHAN]; /* states of the b channels */
255 #define BCH_ST_FREE 0 /* free to be used, idle */
256 #define BCH_ST_RSVD 1 /* reserved, may become free or used */
257 #define BCH_ST_USED 2 /* in use for data transfer */
258
259 int tei; /* current tei or -1 if invalid */
260
261 /* pointers to functions to be called from L4 */
262
263 void (*N_CONNECT_REQUEST) (unsigned int);
264 void (*N_CONNECT_RESPONSE) (unsigned int, int, int);
265 void (*N_DISCONNECT_REQUEST) (unsigned int, int);
266 void (*N_ALERT_REQUEST) (unsigned int);
267 int (*N_DOWNLOAD) (int unit, int numprotos, struct isdn_dr_prot *protocols);
268 int (*N_DIAGNOSTICS) (int unit, struct isdn_diagnostic_request*);
269 void (*N_MGMT_COMMAND) (int unit, int cmd, void *);
270 } ctrl_desc_t;
271
272 extern ctrl_desc_t ctrl_desc[MAX_CONTROLLERS];
273
274 #endif /* _I4B_Q931_H_ */
Cache object: 5c2e1e41546e59a450956b8dd27d7628
|