aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/act2000/capi.h
blob: 01ccdecd43f76920435b17365c7a5e950d4edf65 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
/* $Id: capi.h,v 1.6.6.2 2001/09/23 22:24:32 kai Exp $
 *
 * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000.
 *
 * Author       Fritz Elfert
 * Copyright    by Fritz Elfert      <fritz@isdn4linux.de>
 *
 * This software may be used and distributed according to the terms
 * of the GNU General Public License, incorporated herein by reference.
 *
 * Thanks to Friedemann Baitinger and IBM Germany
 *
 */

#ifndef CAPI_H
#define CAPI_H

/* Command-part of a CAPI message */
typedef struct actcapi_msgcmd {
	__u8 cmd;
	__u8 subcmd;
} actcapi_msgcmd;

/* CAPI message header */
typedef struct actcapi_msghdr {
	__u16 len;
	__u16 applicationID;
	actcapi_msgcmd cmd;
	__u16 msgnum;
} actcapi_msghdr;

/* CAPI message description (for debugging) */
typedef struct actcapi_msgdsc {
	actcapi_msgcmd cmd;
	char *description;
} actcapi_msgdsc;

/* CAPI Address */
typedef struct actcapi_addr {
	__u8 len;                            /* Length of element            */
	__u8 tnp;                            /* Type/Numbering Plan          */
	__u8 num[20];                        /* Caller ID                    */
} actcapi_addr;

/* CAPI INFO element mask */
typedef  union actcapi_infonr {              /* info number                  */
	__u16 mask;                          /* info-mask field              */
	struct bmask {                       /* bit definitions              */
		unsigned  codes:3;           /* code set                     */
		unsigned  rsvd:5;            /* reserved                     */
		unsigned  svind:1;           /* single, variable length ind. */
		unsigned  wtype:7;           /* W-element type               */
	} bmask;
} actcapi_infonr;

/* CAPI INFO element */
typedef union  actcapi_infoel {              /* info element                 */
	__u8 len;                            /* length of info element       */
	__u8 display[40];                    /* display contents             */
	__u8 uuinfo[40];                     /* User-user info field         */
	struct cause {                       /* Cause information            */
		unsigned ext2:1;             /* extension                    */
		unsigned cod:2;              /* coding standard              */
		unsigned spare:1;            /* spare                        */
		unsigned loc:4;              /* location                     */
		unsigned ext1:1;             /* extension                    */
		unsigned cval:7;             /* Cause value                  */
	} cause;
	struct charge {                      /* Charging information         */
		__u8 toc;                    /* type of charging info        */
		__u8 unit[10];               /* charging units               */
	} charge;
	__u8 date[20];                       /* date fields                  */
	__u8 stat;                           /* state of remote party        */
} actcapi_infoel;

/* Message for EAZ<->MSN Mapping */
typedef struct actcapi_msn {
	__u8 eaz;
	__u8 len;                            /* Length of MSN                */
	__u8 msn[15];
}  __attribute__((packed)) actcapi_msn;

typedef struct actcapi_dlpd {
	__u8 len;                            /* Length of structure          */
	__u16 dlen;                          /* Data Length                  */
	__u8 laa;                            /* Link Address A               */
	__u8 lab;                            /* Link Address B               */
	__u8 modulo;                         /* Modulo Mode                  */
	__u8 win;                            /* Window size                  */
	__u8 xid[100];                       /* XID Information              */
} __attribute__((packed)) actcapi_dlpd;

typedef struct actcapi_ncpd {
	__u8   len;                          /* Length of structure          */
	__u16  lic;
	__u16  hic;
	__u16  ltc;
	__u16  htc;
	__u16  loc;
	__u16  hoc;
	__u8   modulo;
} __attribute__((packed)) actcapi_ncpd;
#define actcapi_ncpi actcapi_ncpd

/*
 * Layout of NCCI field in a B3 DATA CAPI message is different from
 * standard at act2000:
 *
 * Bit 0-4  = PLCI
 * Bit 5-7  = Controller
 * Bit 8-15 = NCCI
 */
#define MAKE_NCCI(plci, contr, ncci)					\
	((plci & 0x1f) | ((contr & 0x7) << 5) | ((ncci & 0xff) << 8))

#define EVAL_NCCI(fakencci, plci, contr, ncci) {	\
		plci  = fakencci & 0x1f;		\
		contr = (fakencci >> 5) & 0x7;		\
		ncci  = (fakencci >> 8) & 0xff;		\
	}

/*
 * Layout of PLCI field in a B3 DATA CAPI message is different from
 * standard at act2000:
 *
 * Bit 0-4  = PLCI
 * Bit 5-7  = Controller
 * Bit 8-15 = reserved (must be 0)
 */
#define MAKE_PLCI(plci, contr)			\
	((plci & 0x1f) | ((contr & 0x7) << 5))

#define EVAL_PLCI(fakeplci, plci, contr) {	\
		plci  = fakeplci & 0x1f;	\
		contr = (fakeplci >> 5) & 0x7;	\
	}

typedef struct actcapi_msg {
	actcapi_msghdr hdr;
	union {
		__u16 manuf_msg;
		struct manufacturer_req_net {
			__u16 manuf_msg;
			__u16 controller;
			__u8  nettype;
		} manufacturer_req_net;
		struct manufacturer_req_v42 {
			__u16 manuf_msg;
			__u16 controller;
			__u32 v42control;
		} manufacturer_req_v42;
		struct manufacturer_conf_v42 {
			__u16 manuf_msg;
			__u16 controller;
		} manufacturer_conf_v42;
		struct manufacturer_req_err {
			__u16 manuf_msg;
			__u16 controller;
		} manufacturer_req_err;
		struct manufacturer_ind_err {
			__u16 manuf_msg;
			__u16 controller;
			__u32 errcode;
			__u8  errstring; /* actually up to 160 */
		} manufacturer_ind_err;
		struct manufacturer_req_msn {
			__u16 manuf_msg;
			__u16 controller;
			actcapi_msn msnmap;
		} __attribute ((packed)) manufacturer_req_msn;
		/* TODO: TraceInit-req/conf/ind/resp and
		 *       TraceDump-req/conf/ind/resp
		 */
		struct connect_req {
			__u8  controller;
			__u8  bchan;
			__u32 infomask;
			__u8  si1;
			__u8  si2;
			__u8  eaz;
			actcapi_addr addr;
		} __attribute__ ((packed)) connect_req;
		struct connect_conf {
			__u16 plci;
			__u16 info;
		} connect_conf;
		struct connect_ind {
			__u16 plci;
			__u8  controller;
			__u8  si1;
			__u8  si2;
			__u8  eaz;
			actcapi_addr addr;
		} __attribute__ ((packed)) connect_ind;
		struct connect_resp {
			__u16 plci;
			__u8  rejectcause;
		} connect_resp;
		struct connect_active_ind {
			__u16 plci;
			actcapi_addr addr;
		} __attribute__ ((packed)) connect_active_ind;
		struct connect_active_resp {
			__u16 plci;
		} connect_active_resp;
		struct connect_b3_req {
			__u16 plci;
			actcapi_ncpi ncpi;
		} __attribute__ ((packed)) connect_b3_req;
		struct connect_b3_conf {
			__u16 plci;
			__u16 ncci;
			__u16 info;
		} connect_b3_conf;
		struct connect_b3_ind {
			__u16 ncci;
			__u16 plci;
			actcapi_ncpi ncpi;
		} __attribute__ ((packed)) connect_b3_ind;
		struct connect_b3_resp {
			__u16 ncci;
			__u8  rejectcause;
			actcapi_ncpi ncpi;
		} __attribute__ ((packed)) connect_b3_resp;
		struct disconnect_req {
			__u16 plci;
			__u8  cause;
		} disconnect_req;
		struct disconnect_conf {
			__u16 plci;
			__u16 info;
		} disconnect_conf;
		struct disconnect_ind {
			__u16 plci;
			__u16 info;
		} disconnect_ind;
		struct disconnect_resp {
			__u16 plci;
		} disconnect_resp;
		struct connect_b3_active_ind {
			__u16 ncci;
			actcapi_ncpi ncpi;
		} __attribute__ ((packed)) connect_b3_active_ind;
		struct connect_b3_active_resp {
			__u16 ncci;
		} connect_b3_active_resp;
		struct disconnect_b3_req {
			__u16 ncci;
			actcapi_ncpi ncpi;
		} __attribute__ ((packed)) disconnect_b3_req;
		struct disconnect_b3_conf {
			__u16 ncci;
			__u16 info;
		} disconnect_b3_conf;
		struct disconnect_b3_ind {
			__u16 ncci;
			__u16 info;
			actcapi_ncpi ncpi;
		} __attribute__ ((packed)) disconnect_b3_ind;
		struct disconnect_b3_resp {
			__u16 ncci;
		} disconnect_b3_resp;
		struct info_ind {
			__u16 plci;
			actcapi_infonr nr;
			actcapi_infoel el;
		} __attribute__ ((packed)) info_ind;
		struct info_resp {
			__u16 plci;
		} info_resp;
		struct listen_b3_req {
			__u16 plci;
		} listen_b3_req;
		struct listen_b3_conf {
			__u16 plci;
			__u16 info;
		} listen_b3_conf;
		struct select_b2_protocol_req {
			__u16 plci;
			__u8  protocol;
			actcapi_dlpd dlpd;
		} __attribute__ ((packed)) select_b2_protocol_req;
		struct select_b2_protocol_conf {
			__u16 plci;
			__u16 info;
		} select_b2_protocol_conf;
		struct select_b3_protocol_req {
			__u16 plci;
			__u8  protocol;
			actcapi_ncpd ncpd;
		} __attribute__ ((packed)) select_b3_protocol_req;
		struct select_b3_protocol_conf {
			__u16 plci;
			__u16 info;
		} select_b3_protocol_conf;
		struct listen_req {
			__u8  controller;
			__u32 infomask;
			__u16 eazmask;
			__u16 simask;
		} __attribute__ ((packed)) listen_req;
		struct listen_conf {
			__u8  controller;
			__u16 info;
		} __attribute__ ((packed)) listen_conf;
		struct data_b3_req {
			__u16 fakencci;
			__u16 datalen;
			__u32 unused;
			__u8  blocknr;
			__u16 flags;
		} __attribute ((packed)) data_b3_req;
		struct data_b3_ind {
			__u16 fakencci;
			__u16 datalen;
			__u32 unused;
			__u8  blocknr;
			__u16 flags;
		} __attribute__ ((packed)) data_b3_ind;
		struct data_b3_resp {
			__u16 ncci;
			__u8  blocknr;
		} __attribute__ ((packed)) data_b3_resp;
		struct data_b3_conf {
			__u16 ncci;
			__u8  blocknr;
			__u16 info;
		} __attribute__ ((packed)) data_b3_conf;
	} msg;
} __attribute__ ((packed)) actcapi_msg;

static inline unsigned short
actcapi_nextsmsg(act2000_card *card)
{
	unsigned long flags;
	unsigned short n;

	spin_lock_irqsave(&card->mnlock, flags);
	n = card->msgnum;
	card->msgnum++;
	card->msgnum &= 0x7fff;
	spin_unlock_irqrestore(&card->mnlock, flags);
	return n;
}
#define DEBUG_MSG
#undef DEBUG_DATA_MSG
#undef DEBUG_DUMP_SKB

extern int actcapi_chkhdr(act2000_card *, actcapi_msghdr *);
extern int actcapi_listen_req(act2000_card *);
extern int actcapi_manufacturer_req_net(act2000_card *);
extern int actcapi_manufacturer_req_errh(act2000_card *);
extern int actcapi_manufacturer_req_msn(act2000_card *);
extern int actcapi_connect_req(act2000_card *, act2000_chan *, char *, char, int, int);
extern void actcapi_select_b2_protocol_req(act2000_card *, act2000_chan *);
extern void actcapi_disconnect_b3_req(act2000_card *, act2000_chan *);
extern void actcapi_connect_resp(act2000_card *, act2000_chan *, __u8);
extern void actcapi_dispatch(struct work_struct *);
#ifdef DEBUG_MSG
extern void actcapi_debug_msg(struct sk_buff *skb, int);
#else
#define actcapi_debug_msg(skb, len)
#endif
#endif