* add p cc
[mascara-docs.git] / i386 / linux / linux-2.3.21 / drivers / isdn / avmb1 / capiutil.h
blob38209212dbd91512cb3744ab5afce6eef0d678e1
1 /*
2 * $Id: capiutil.h,v 1.2 1997/05/18 09:24:19 calle Exp $
3 *
4 * CAPI 2.0 defines & types
5 *
6 * From CAPI 2.0 Development Kit AVM 1995 (capi20.h)
7 * Rewritten for Linux 1996 by Carsten Paeth (calle@calle.in-berlin.de)
8 *
9 * $Log: capiutil.h,v $
10 * Revision 1.2 1997/05/18 09:24:19 calle
11 * added verbose disconnect reason reporting to avmb1.
12 * some fixes in capi20 interface.
13 * changed info messages for B1-PCI
15 * Revision 1.1 1997/03/04 21:50:35 calle
16 * Frirst version in isdn4linux
18 * Revision 2.2 1997/02/12 09:31:39 calle
19 * new version
21 * Revision 1.1 1997/01/31 10:32:20 calle
22 * Initial revision
26 #ifndef __CAPIUTIL_H__
27 #define __CAPIUTIL_H__
29 #include <asm/types.h>
31 #define CAPIMSG_LEN(m) (m[0] | (m[1] << 8))
32 #define CAPIMSG_APPID(m) (m[2] | (m[3] << 8))
33 #define CAPIMSG_COMMAND(m) (m[4])
34 #define CAPIMSG_SUBCOMMAND(m) (m[5])
35 #define CAPIMSG_MSGID(m) (m[6] | (m[7] << 8))
36 #define CAPIMSG_CONTROLLER(m) (m[8] & 0x7f)
37 #define CAPIMSG_CONTROL(m) (m[8]|(m[9]<<8)|(m[10]<<16)|(m[11]<<24))
38 #define CAPIMSG_NCCI(m) CAPIMSG_CONTROL(m)
39 #define CAPIMSG_DATA(m) (m[12]|(m[13]<<8)|(m[14]<<16)|(m[15]<<24))
40 #define CAPIMSG_DATALEN(m) (m[16] | (m[17]<<8))
42 #define CAPIMSG_SETAPPID(m, applid) \
43 do { \
44 ((__u8 *)m)[2] = (__u16)(applid) & 0xff; \
45 ((__u8 *)m)[3] = ((__u16)(applid) >> 8) & 0xff; \
46 } while (0)
48 #define CAPIMSG_SETDATA(m, data) \
49 do { \
50 ((__u8 *)m)[12] = (__u32)(data) & 0xff; \
51 ((__u8 *)m)[13] = ((__u32)(data) >> 8) & 0xff; \
52 ((__u8 *)m)[14] = ((__u32)(data) >> 16) & 0xff; \
53 ((__u8 *)m)[15] = ((__u32)(data) >> 24) & 0xff; \
54 } while (0)
56 /*----- basic-type definitions -----*/
58 typedef __u8 *_cstruct;
60 typedef enum {
61 CAPI_COMPOSE,
62 CAPI_DEFAULT
63 } _cmstruct;
66 The _cmsg structure contains all possible CAPI 2.0 parameter.
67 All parameters are stored here first. The function CAPI_CMSG_2_MESSAGE
68 assembles the parameter and builds CAPI2.0 conform messages.
69 CAPI_MESSAGE_2_CMSG disassembles CAPI 2.0 messages and stores the
70 parameter in the _cmsg structure
73 typedef struct {
74 /* Header */
75 __u16 ApplId;
76 __u8 Command;
77 __u8 Subcommand;
78 __u16 Messagenumber;
80 /* Parameter */
81 union {
82 __u32 adrController;
83 __u32 adrPLCI;
84 __u32 adrNCCI;
85 } adr;
87 _cmstruct AdditionalInfo;
88 _cstruct B1configuration;
89 __u16 B1protocol;
90 _cstruct B2configuration;
91 __u16 B2protocol;
92 _cstruct B3configuration;
93 __u16 B3protocol;
94 _cstruct BC;
95 _cstruct BChannelinformation;
96 _cmstruct BProtocol;
97 _cstruct CalledPartyNumber;
98 _cstruct CalledPartySubaddress;
99 _cstruct CallingPartyNumber;
100 _cstruct CallingPartySubaddress;
101 __u32 CIPmask;
102 __u32 CIPmask2;
103 __u16 CIPValue;
104 __u32 Class;
105 _cstruct ConnectedNumber;
106 _cstruct ConnectedSubaddress;
107 __u32 Data;
108 __u16 DataHandle;
109 __u16 DataLength;
110 _cstruct FacilityConfirmationParameter;
111 _cstruct Facilitydataarray;
112 _cstruct FacilityIndicationParameter;
113 _cstruct FacilityRequestParameter;
114 __u16 FacilitySelector;
115 __u16 Flags;
116 __u32 Function;
117 _cstruct HLC;
118 __u16 Info;
119 _cstruct InfoElement;
120 __u32 InfoMask;
121 __u16 InfoNumber;
122 _cstruct Keypadfacility;
123 _cstruct LLC;
124 _cstruct ManuData;
125 __u32 ManuID;
126 _cstruct NCPI;
127 __u16 Reason;
128 __u16 Reason_B3;
129 __u16 Reject;
130 _cstruct Useruserdata;
132 /* intern */
133 unsigned l, p;
134 unsigned char *par;
135 __u8 *m;
137 /* buffer to construct message */
138 __u8 buf[180];
140 } _cmsg;
143 * capi_cmsg2message() assembles the parameter from _cmsg to a CAPI 2.0
144 * conform message
146 unsigned capi_cmsg2message(_cmsg * cmsg, __u8 * msg);
149 * capi_message2cmsg disassembles a CAPI message an writes the parameter
150 * into _cmsg for easy access
152 unsigned capi_message2cmsg(_cmsg * cmsg, __u8 * msg);
155 * capi_cmsg_header() fills the _cmsg structure with default values, so only
156 * parameter with non default values must be changed before sending the
157 * message.
159 unsigned capi_cmsg_header(_cmsg * cmsg, __u16 _ApplId,
160 __u8 _Command, __u8 _Subcommand,
161 __u16 _Messagenumber, __u32 _Controller);
164 * capi_info2str generated a readable string for Capi2.0 reasons.
166 char *capi_info2str(__u16 reason);
168 /*-----------------------------------------------------------------------*/
171 * Debugging / Tracing functions
173 char *capi_cmd2str(__u8 cmd, __u8 subcmd);
174 char *capi_cmsg2str(_cmsg * cmsg);
175 char *capi_message2str(__u8 * msg);
177 /*-----------------------------------------------------------------------*/
179 static inline void capi_cmsg_answer(_cmsg * cmsg)
181 cmsg->Subcommand |= 0x01;
184 /*-----------------------------------------------------------------------*/
186 static inline void capi_fill_CONNECT_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
187 __u32 adr,
188 _cstruct NCPI)
190 capi_cmsg_header(cmsg, ApplId, 0x82, 0x80, Messagenumber, adr);
191 cmsg->NCPI = NCPI;
194 static inline void capi_fill_FACILITY_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
195 __u32 adr,
196 __u16 FacilitySelector,
197 _cstruct FacilityRequestParameter)
199 capi_cmsg_header(cmsg, ApplId, 0x80, 0x80, Messagenumber, adr);
200 cmsg->FacilitySelector = FacilitySelector;
201 cmsg->FacilityRequestParameter = FacilityRequestParameter;
204 static inline void capi_fill_INFO_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
205 __u32 adr,
206 _cstruct CalledPartyNumber,
207 _cstruct BChannelinformation,
208 _cstruct Keypadfacility,
209 _cstruct Useruserdata,
210 _cstruct Facilitydataarray)
212 capi_cmsg_header(cmsg, ApplId, 0x08, 0x80, Messagenumber, adr);
213 cmsg->CalledPartyNumber = CalledPartyNumber;
214 cmsg->BChannelinformation = BChannelinformation;
215 cmsg->Keypadfacility = Keypadfacility;
216 cmsg->Useruserdata = Useruserdata;
217 cmsg->Facilitydataarray = Facilitydataarray;
220 static inline void capi_fill_LISTEN_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
221 __u32 adr,
222 __u32 InfoMask,
223 __u32 CIPmask,
224 __u32 CIPmask2,
225 _cstruct CallingPartyNumber,
226 _cstruct CallingPartySubaddress)
228 capi_cmsg_header(cmsg, ApplId, 0x05, 0x80, Messagenumber, adr);
229 cmsg->InfoMask = InfoMask;
230 cmsg->CIPmask = CIPmask;
231 cmsg->CIPmask2 = CIPmask2;
232 cmsg->CallingPartyNumber = CallingPartyNumber;
233 cmsg->CallingPartySubaddress = CallingPartySubaddress;
236 static inline void capi_fill_ALERT_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
237 __u32 adr,
238 _cstruct BChannelinformation,
239 _cstruct Keypadfacility,
240 _cstruct Useruserdata,
241 _cstruct Facilitydataarray)
243 capi_cmsg_header(cmsg, ApplId, 0x01, 0x80, Messagenumber, adr);
244 cmsg->BChannelinformation = BChannelinformation;
245 cmsg->Keypadfacility = Keypadfacility;
246 cmsg->Useruserdata = Useruserdata;
247 cmsg->Facilitydataarray = Facilitydataarray;
250 static inline void capi_fill_CONNECT_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
251 __u32 adr,
252 __u16 CIPValue,
253 _cstruct CalledPartyNumber,
254 _cstruct CallingPartyNumber,
255 _cstruct CalledPartySubaddress,
256 _cstruct CallingPartySubaddress,
257 __u16 B1protocol,
258 __u16 B2protocol,
259 __u16 B3protocol,
260 _cstruct B1configuration,
261 _cstruct B2configuration,
262 _cstruct B3configuration,
263 _cstruct BC,
264 _cstruct LLC,
265 _cstruct HLC,
266 _cstruct BChannelinformation,
267 _cstruct Keypadfacility,
268 _cstruct Useruserdata,
269 _cstruct Facilitydataarray)
272 capi_cmsg_header(cmsg, ApplId, 0x02, 0x80, Messagenumber, adr);
273 cmsg->CIPValue = CIPValue;
274 cmsg->CalledPartyNumber = CalledPartyNumber;
275 cmsg->CallingPartyNumber = CallingPartyNumber;
276 cmsg->CalledPartySubaddress = CalledPartySubaddress;
277 cmsg->CallingPartySubaddress = CallingPartySubaddress;
278 cmsg->B1protocol = B1protocol;
279 cmsg->B2protocol = B2protocol;
280 cmsg->B3protocol = B3protocol;
281 cmsg->B1configuration = B1configuration;
282 cmsg->B2configuration = B2configuration;
283 cmsg->B3configuration = B3configuration;
284 cmsg->BC = BC;
285 cmsg->LLC = LLC;
286 cmsg->HLC = HLC;
287 cmsg->BChannelinformation = BChannelinformation;
288 cmsg->Keypadfacility = Keypadfacility;
289 cmsg->Useruserdata = Useruserdata;
290 cmsg->Facilitydataarray = Facilitydataarray;
293 static inline void capi_fill_DATA_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
294 __u32 adr,
295 __u32 Data,
296 __u16 DataLength,
297 __u16 DataHandle,
298 __u16 Flags)
301 capi_cmsg_header(cmsg, ApplId, 0x86, 0x80, Messagenumber, adr);
302 cmsg->Data = Data;
303 cmsg->DataLength = DataLength;
304 cmsg->DataHandle = DataHandle;
305 cmsg->Flags = Flags;
308 static inline void capi_fill_DISCONNECT_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
309 __u32 adr,
310 _cstruct BChannelinformation,
311 _cstruct Keypadfacility,
312 _cstruct Useruserdata,
313 _cstruct Facilitydataarray)
316 capi_cmsg_header(cmsg, ApplId, 0x04, 0x80, Messagenumber, adr);
317 cmsg->BChannelinformation = BChannelinformation;
318 cmsg->Keypadfacility = Keypadfacility;
319 cmsg->Useruserdata = Useruserdata;
320 cmsg->Facilitydataarray = Facilitydataarray;
323 static inline void capi_fill_DISCONNECT_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
324 __u32 adr,
325 _cstruct NCPI)
328 capi_cmsg_header(cmsg, ApplId, 0x84, 0x80, Messagenumber, adr);
329 cmsg->NCPI = NCPI;
332 static inline void capi_fill_MANUFACTURER_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
333 __u32 adr,
334 __u32 ManuID,
335 __u32 Class,
336 __u32 Function,
337 _cstruct ManuData)
340 capi_cmsg_header(cmsg, ApplId, 0xff, 0x80, Messagenumber, adr);
341 cmsg->ManuID = ManuID;
342 cmsg->Class = Class;
343 cmsg->Function = Function;
344 cmsg->ManuData = ManuData;
347 static inline void capi_fill_RESET_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
348 __u32 adr,
349 _cstruct NCPI)
352 capi_cmsg_header(cmsg, ApplId, 0x87, 0x80, Messagenumber, adr);
353 cmsg->NCPI = NCPI;
356 static inline void capi_fill_SELECT_B_PROTOCOL_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
357 __u32 adr,
358 __u16 B1protocol,
359 __u16 B2protocol,
360 __u16 B3protocol,
361 _cstruct B1configuration,
362 _cstruct B2configuration,
363 _cstruct B3configuration)
366 capi_cmsg_header(cmsg, ApplId, 0x41, 0x80, Messagenumber, adr);
367 cmsg->B1protocol = B1protocol;
368 cmsg->B2protocol = B2protocol;
369 cmsg->B3protocol = B3protocol;
370 cmsg->B1configuration = B1configuration;
371 cmsg->B2configuration = B2configuration;
372 cmsg->B3configuration = B3configuration;
375 static inline void capi_fill_CONNECT_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
376 __u32 adr,
377 __u16 Reject,
378 __u16 B1protocol,
379 __u16 B2protocol,
380 __u16 B3protocol,
381 _cstruct B1configuration,
382 _cstruct B2configuration,
383 _cstruct B3configuration,
384 _cstruct ConnectedNumber,
385 _cstruct ConnectedSubaddress,
386 _cstruct LLC,
387 _cstruct BChannelinformation,
388 _cstruct Keypadfacility,
389 _cstruct Useruserdata,
390 _cstruct Facilitydataarray)
392 capi_cmsg_header(cmsg, ApplId, 0x02, 0x83, Messagenumber, adr);
393 cmsg->Reject = Reject;
394 cmsg->B1protocol = B1protocol;
395 cmsg->B2protocol = B2protocol;
396 cmsg->B3protocol = B3protocol;
397 cmsg->B1configuration = B1configuration;
398 cmsg->B2configuration = B2configuration;
399 cmsg->B3configuration = B3configuration;
400 cmsg->ConnectedNumber = ConnectedNumber;
401 cmsg->ConnectedSubaddress = ConnectedSubaddress;
402 cmsg->LLC = LLC;
403 cmsg->BChannelinformation = BChannelinformation;
404 cmsg->Keypadfacility = Keypadfacility;
405 cmsg->Useruserdata = Useruserdata;
406 cmsg->Facilitydataarray = Facilitydataarray;
409 static inline void capi_fill_CONNECT_ACTIVE_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
410 __u32 adr)
413 capi_cmsg_header(cmsg, ApplId, 0x03, 0x83, Messagenumber, adr);
416 static inline void capi_fill_CONNECT_B3_ACTIVE_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
417 __u32 adr)
420 capi_cmsg_header(cmsg, ApplId, 0x83, 0x83, Messagenumber, adr);
423 static inline void capi_fill_CONNECT_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
424 __u32 adr,
425 __u16 Reject,
426 _cstruct NCPI)
428 capi_cmsg_header(cmsg, ApplId, 0x82, 0x83, Messagenumber, adr);
429 cmsg->Reject = Reject;
430 cmsg->NCPI = NCPI;
433 static inline void capi_fill_CONNECT_B3_T90_ACTIVE_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
434 __u32 adr)
437 capi_cmsg_header(cmsg, ApplId, 0x88, 0x83, Messagenumber, adr);
440 static inline void capi_fill_DATA_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
441 __u32 adr,
442 __u16 DataHandle)
445 capi_cmsg_header(cmsg, ApplId, 0x86, 0x83, Messagenumber, adr);
446 cmsg->DataHandle = DataHandle;
449 static inline void capi_fill_DISCONNECT_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
450 __u32 adr)
453 capi_cmsg_header(cmsg, ApplId, 0x84, 0x83, Messagenumber, adr);
456 static inline void capi_fill_DISCONNECT_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
457 __u32 adr)
460 capi_cmsg_header(cmsg, ApplId, 0x04, 0x83, Messagenumber, adr);
463 static inline void capi_fill_FACILITY_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
464 __u32 adr,
465 __u16 FacilitySelector)
468 capi_cmsg_header(cmsg, ApplId, 0x80, 0x83, Messagenumber, adr);
469 cmsg->FacilitySelector = FacilitySelector;
472 static inline void capi_fill_INFO_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
473 __u32 adr)
476 capi_cmsg_header(cmsg, ApplId, 0x08, 0x83, Messagenumber, adr);
479 static inline void capi_fill_MANUFACTURER_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
480 __u32 adr,
481 __u32 ManuID,
482 __u32 Class,
483 __u32 Function,
484 _cstruct ManuData)
487 capi_cmsg_header(cmsg, ApplId, 0xff, 0x83, Messagenumber, adr);
488 cmsg->ManuID = ManuID;
489 cmsg->Class = Class;
490 cmsg->Function = Function;
491 cmsg->ManuData = ManuData;
494 static inline void capi_fill_RESET_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
495 __u32 adr)
498 capi_cmsg_header(cmsg, ApplId, 0x87, 0x83, Messagenumber, adr);
501 #endif /* __CAPIUTIL_H__ */