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