File: /usr/src/linux/drivers/isdn/act2000/capi.h
1 /* $Id: capi.h,v 1.6.6.1 2001/02/16 16:43:23 kai Exp $
2 *
3 * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000.
4 *
5 * Copyright 1998 by Fritz Elfert (fritz@isdn4linux.de)
6 * Thanks to Friedemann Baitinger and IBM Germany
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */
23
24 #ifndef CAPI_H
25 #define CAPI_H
26
27 /* Command-part of a CAPI message */
28 typedef struct actcapi_msgcmd {
29 __u8 cmd;
30 __u8 subcmd;
31 } actcapi_msgcmd;
32
33 /* CAPI message header */
34 typedef struct actcapi_msghdr {
35 __u16 len;
36 __u16 applicationID;
37 actcapi_msgcmd cmd;
38 __u16 msgnum;
39 } actcapi_msghdr;
40
41 /* CAPI message description (for debugging) */
42 typedef struct actcapi_msgdsc {
43 actcapi_msgcmd cmd;
44 char *description;
45 } actcapi_msgdsc;
46
47 /* CAPI Address */
48 typedef struct actcapi_addr {
49 __u8 len; /* Length of element */
50 __u8 tnp; /* Type/Numbering Plan */
51 __u8 num[20]; /* Caller ID */
52 } actcapi_addr;
53
54 /* CAPI INFO element mask */
55 typedef union actcapi_infonr { /* info number */
56 __u16 mask; /* info-mask field */
57 struct bmask { /* bit definitions */
58 unsigned codes : 3; /* code set */
59 unsigned rsvd : 5; /* reserved */
60 unsigned svind : 1; /* single, variable length ind. */
61 unsigned wtype : 7; /* W-element type */
62 } bmask;
63 } actcapi_infonr;
64
65 /* CAPI INFO element */
66 typedef union actcapi_infoel { /* info element */
67 __u8 len; /* length of info element */
68 __u8 display[40]; /* display contents */
69 __u8 uuinfo[40]; /* User-user info field */
70 struct cause { /* Cause information */
71 unsigned ext2 : 1; /* extension */
72 unsigned cod : 2; /* coding standard */
73 unsigned spare : 1; /* spare */
74 unsigned loc : 4; /* location */
75 unsigned ext1 : 1; /* extension */
76 unsigned cval : 7; /* Cause value */
77 } cause;
78 struct charge { /* Charging information */
79 __u8 toc; /* type of charging info */
80 __u8 unit[10]; /* charging units */
81 } charge;
82 __u8 date[20]; /* date fields */
83 __u8 stat; /* state of remote party */
84 } actcapi_infoel;
85
86 /* Message for EAZ<->MSN Mapping */
87 typedef struct actcapi_msn {
88 __u8 eaz;
89 __u8 len; /* Length of MSN */
90 __u8 msn[15] __attribute__ ((packed));
91 } actcapi_msn;
92
93 typedef struct actcapi_dlpd {
94 __u8 len; /* Length of structure */
95 __u16 dlen __attribute__ ((packed)); /* Data Length */
96 __u8 laa __attribute__ ((packed)); /* Link Address A */
97 __u8 lab; /* Link Address B */
98 __u8 modulo; /* Modulo Mode */
99 __u8 win; /* Window size */
100 __u8 xid[100]; /* XID Information */
101 } actcapi_dlpd;
102
103 typedef struct actcapi_ncpd {
104 __u8 len; /* Length of structure */
105 __u16 lic __attribute__ ((packed));
106 __u16 hic __attribute__ ((packed));
107 __u16 ltc __attribute__ ((packed));
108 __u16 htc __attribute__ ((packed));
109 __u16 loc __attribute__ ((packed));
110 __u16 hoc __attribute__ ((packed));
111 __u8 modulo __attribute__ ((packed));
112 } actcapi_ncpd;
113 #define actcapi_ncpi actcapi_ncpd
114
115 /*
116 * Layout of NCCI field in a B3 DATA CAPI message is different from
117 * standard at act2000:
118 *
119 * Bit 0-4 = PLCI
120 * Bit 5-7 = Controller
121 * Bit 8-15 = NCCI
122 */
123 #define MAKE_NCCI(plci,contr,ncci) \
124 ((plci & 0x1f) | ((contr & 0x7) << 5) | ((ncci & 0xff) << 8))
125
126 #define EVAL_NCCI(fakencci,plci,contr,ncci) { \
127 plci = fakencci & 0x1f; \
128 contr = (fakencci >> 5) & 0x7; \
129 ncci = (fakencci >> 8) & 0xff; \
130 }
131
132 /*
133 * Layout of PLCI field in a B3 DATA CAPI message is different from
134 * standard at act2000:
135 *
136 * Bit 0-4 = PLCI
137 * Bit 5-7 = Controller
138 * Bit 8-15 = reserved (must be 0)
139 */
140 #define MAKE_PLCI(plci,contr) \
141 ((plci & 0x1f) | ((contr & 0x7) << 5))
142
143 #define EVAL_PLCI(fakeplci,plci,contr) { \
144 plci = fakeplci & 0x1f; \
145 contr = (fakeplci >> 5) & 0x7; \
146 }
147
148 typedef struct actcapi_msg {
149 actcapi_msghdr hdr;
150 union msg {
151 __u16 manuf_msg;
152 struct manufacturer_req_net {
153 __u16 manuf_msg;
154 __u16 controller;
155 __u8 nettype;
156 } manufacturer_req_net;
157 struct manufacturer_req_v42 {
158 __u16 manuf_msg;
159 __u16 controller;
160 __u32 v42control;
161 } manufacturer_req_v42;
162 struct manufacturer_conf_v42 {
163 __u16 manuf_msg;
164 __u16 controller;
165 } manufacturer_conf_v42;
166 struct manufacturer_req_err {
167 __u16 manuf_msg;
168 __u16 controller;
169 } manufacturer_req_err;
170 struct manufacturer_ind_err {
171 __u16 manuf_msg;
172 __u16 controller;
173 __u32 errcode;
174 __u8 errstring; /* actually up to 160 */
175 } manufacturer_ind_err;
176 struct manufacturer_req_msn {
177 __u16 manuf_msg;
178 __u16 controller;
179 actcapi_msn msnmap;
180 } manufacturer_req_msn;
181 /* TODO: TraceInit-req/conf/ind/resp and
182 * TraceDump-req/conf/ind/resp
183 */
184 struct connect_req {
185 __u8 controller;
186 __u8 bchan;
187 __u32 infomask __attribute__ ((packed));
188 __u8 si1;
189 __u8 si2;
190 __u8 eaz;
191 actcapi_addr addr;
192 } connect_req;
193 struct connect_conf {
194 __u16 plci;
195 __u16 info;
196 } connect_conf;
197 struct connect_ind {
198 __u16 plci;
199 __u8 controller;
200 __u8 si1;
201 __u8 si2;
202 __u8 eaz;
203 actcapi_addr addr;
204 } connect_ind;
205 struct connect_resp {
206 __u16 plci;
207 __u8 rejectcause;
208 } connect_resp;
209 struct connect_active_ind {
210 __u16 plci;
211 actcapi_addr addr;
212 } connect_active_ind;
213 struct connect_active_resp {
214 __u16 plci;
215 } connect_active_resp;
216 struct connect_b3_req {
217 __u16 plci;
218 actcapi_ncpi ncpi;
219 } connect_b3_req;
220 struct connect_b3_conf {
221 __u16 plci;
222 __u16 ncci;
223 __u16 info;
224 } connect_b3_conf;
225 struct connect_b3_ind {
226 __u16 ncci;
227 __u16 plci;
228 actcapi_ncpi ncpi;
229 } connect_b3_ind;
230 struct connect_b3_resp {
231 __u16 ncci;
232 __u8 rejectcause;
233 actcapi_ncpi ncpi __attribute__ ((packed));
234 } connect_b3_resp;
235 struct disconnect_req {
236 __u16 plci;
237 __u8 cause;
238 } disconnect_req;
239 struct disconnect_conf {
240 __u16 plci;
241 __u16 info;
242 } disconnect_conf;
243 struct disconnect_ind {
244 __u16 plci;
245 __u16 info;
246 } disconnect_ind;
247 struct disconnect_resp {
248 __u16 plci;
249 } disconnect_resp;
250 struct connect_b3_active_ind {
251 __u16 ncci;
252 actcapi_ncpi ncpi;
253 } connect_b3_active_ind;
254 struct connect_b3_active_resp {
255 __u16 ncci;
256 } connect_b3_active_resp;
257 struct disconnect_b3_req {
258 __u16 ncci;
259 actcapi_ncpi ncpi;
260 } disconnect_b3_req;
261 struct disconnect_b3_conf {
262 __u16 ncci;
263 __u16 info;
264 } disconnect_b3_conf;
265 struct disconnect_b3_ind {
266 __u16 ncci;
267 __u16 info;
268 actcapi_ncpi ncpi;
269 } disconnect_b3_ind;
270 struct disconnect_b3_resp {
271 __u16 ncci;
272 } disconnect_b3_resp;
273 struct info_ind {
274 __u16 plci;
275 actcapi_infonr nr;
276 actcapi_infoel el;
277 } info_ind;
278 struct info_resp {
279 __u16 plci;
280 } info_resp;
281 struct listen_b3_req {
282 __u16 plci;
283 } listen_b3_req;
284 struct listen_b3_conf {
285 __u16 plci;
286 __u16 info;
287 } listen_b3_conf;
288 struct select_b2_protocol_req {
289 __u16 plci;
290 __u8 protocol;
291 actcapi_dlpd dlpd __attribute__ ((packed));
292 } select_b2_protocol_req;
293 struct select_b2_protocol_conf {
294 __u16 plci;
295 __u16 info;
296 } select_b2_protocol_conf;
297 struct select_b3_protocol_req {
298 __u16 plci;
299 __u8 protocol;
300 actcapi_ncpd ncpd __attribute__ ((packed));
301 } select_b3_protocol_req;
302 struct select_b3_protocol_conf {
303 __u16 plci;
304 __u16 info;
305 } select_b3_protocol_conf;
306 struct listen_req {
307 __u8 controller;
308 __u32 infomask __attribute__ ((packed));
309 __u16 eazmask __attribute__ ((packed));
310 __u16 simask __attribute__ ((packed));
311 } listen_req;
312 struct listen_conf {
313 __u8 controller;
314 __u16 info __attribute__ ((packed));
315 } listen_conf;
316 struct data_b3_req {
317 __u16 fakencci;
318 __u16 datalen;
319 __u32 unused;
320 __u8 blocknr;
321 __u16 flags __attribute__ ((packed));
322 } data_b3_req;
323 struct data_b3_ind {
324 __u16 fakencci;
325 __u16 datalen;
326 __u32 unused;
327 __u8 blocknr;
328 __u16 flags __attribute__ ((packed));
329 } data_b3_ind;
330 struct data_b3_resp {
331 __u16 ncci;
332 __u8 blocknr;
333 } data_b3_resp;
334 struct data_b3_conf {
335 __u16 ncci;
336 __u8 blocknr;
337 __u16 info __attribute__ ((packed));
338 } data_b3_conf;
339 } msg;
340 } actcapi_msg;
341
342 extern __inline__ unsigned short
343 actcapi_nextsmsg(act2000_card *card)
344 {
345 unsigned long flags;
346 unsigned short n;
347
348 save_flags(flags);
349 cli();
350 n = card->msgnum;
351 card->msgnum++;
352 card->msgnum &= 0x7fff;
353 restore_flags(flags);
354 return n;
355 }
356 #define DEBUG_MSG
357 #undef DEBUG_DATA_MSG
358 #undef DEBUG_DUMP_SKB
359
360 extern int actcapi_chkhdr(act2000_card *, actcapi_msghdr *);
361 extern int actcapi_listen_req(act2000_card *);
362 extern int actcapi_manufacturer_req_net(act2000_card *);
363 extern int actcapi_manufacturer_req_v42(act2000_card *, ulong);
364 extern int actcapi_manufacturer_req_errh(act2000_card *);
365 extern int actcapi_manufacturer_req_msn(act2000_card *);
366 extern int actcapi_connect_req(act2000_card *, act2000_chan *, char *, char, int, int);
367 extern void actcapi_select_b2_protocol_req(act2000_card *, act2000_chan *);
368 extern void actcapi_disconnect_b3_req(act2000_card *, act2000_chan *);
369 extern void actcapi_connect_resp(act2000_card *, act2000_chan *, __u8);
370 extern void actcapi_dispatch(act2000_card *);
371 #ifdef DEBUG_MSG
372 extern void actcapi_debug_msg(struct sk_buff *skb, int);
373 #else
374 #define actcapi_debug_msg(skb, len)
375 #endif
376 #endif
377