OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [isdn/] [avmb1/] [capiutil.h] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1626 jcastillo
/*
2
 * $Id: capiutil.h,v 1.1 2005-12-20 10:16:58 jcastillo 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: not supported by cvs2svn $
10
 * Revision 1.1.1.1  2001/09/10 07:44:18  simons
11
 * Initial import
12
 *
13
 * Revision 1.1.1.1  2001/07/02 17:58:32  simons
14
 * Initial revision
15
 *
16
 * Revision 1.2  1997/05/18 09:24:19  calle
17
 * added verbose disconnect reason reporting to avmb1.
18
 * some fixes in capi20 interface.
19
 * changed info messages for B1-PCI
20
 *
21
 * Revision 1.1  1997/03/04 21:50:35  calle
22
 * Frirst version in isdn4linux
23
 *
24
 * Revision 2.2  1997/02/12 09:31:39  calle
25
 * new version
26
 *
27
 * Revision 1.1  1997/01/31 10:32:20  calle
28
 * Initial revision
29
 *
30
 *
31
 */
32
#ifndef __CAPIUTIL_H__
33
#define __CAPIUTIL_H__
34
 
35
#include <asm/types.h>
36
 
37
#define CAPIMSG_LEN(m)          (m[0] | (m[1] << 8))
38
#define CAPIMSG_APPID(m)        (m[2] | (m[3] << 8))
39
#define CAPIMSG_COMMAND(m)      (m[4])
40
#define CAPIMSG_SUBCOMMAND(m)   (m[5])
41
#define CAPIMSG_MSGID(m)        (m[6] | (m[7] << 8))
42
#define CAPIMSG_CONTROLLER(m)   (m[8] & 0x7f)
43
#define CAPIMSG_CONTROL(m)      (m[8]|(m[9]<<8)|(m[10]<<16)|(m[11]<<24))
44
#define CAPIMSG_NCCI(m)         CAPIMSG_CONTROL(m)
45
#define CAPIMSG_DATA(m)         (m[12]|(m[13]<<8)|(m[14]<<16)|(m[15]<<24))
46
#define CAPIMSG_DATALEN(m)      (m[16] | (m[17]<<8))
47
 
48
#define CAPIMSG_SETAPPID(m, applid) \
49
        do { \
50
                ((__u8 *)m)[2] = (__u16)(applid) & 0xff; \
51
                ((__u8 *)m)[3] = ((__u16)(applid) >> 8) & 0xff; \
52
        } while (0)
53
 
54
#define CAPIMSG_SETDATA(m, data) \
55
        do { \
56
                ((__u8 *)m)[12] = (__u32)(data) & 0xff; \
57
                ((__u8 *)m)[13] = ((__u32)(data) >> 8) & 0xff; \
58
                ((__u8 *)m)[14] = ((__u32)(data) >> 16) & 0xff; \
59
                ((__u8 *)m)[15] = ((__u32)(data) >> 24) & 0xff; \
60
        } while (0)
61
 
62
/*----- basic-type definitions -----*/
63
 
64
typedef __u8 *_cstruct;
65
 
66
typedef enum {
67
        CAPI_COMPOSE,
68
        CAPI_DEFAULT
69
} _cmstruct;
70
 
71
/*
72
   The _cmsg structure contains all possible CAPI 2.0 parameter.
73
   All parameters are stored here first. The function CAPI_CMSG_2_MESSAGE
74
   assembles the parameter and builds CAPI2.0 conform messages.
75
   CAPI_MESSAGE_2_CMSG disassembles CAPI 2.0 messages and stores the
76
   parameter in the _cmsg structure
77
 */
78
 
79
typedef struct {
80
        /* Header */
81
        __u16 ApplId;
82
        __u8 Command;
83
        __u8 Subcommand;
84
        __u16 Messagenumber;
85
 
86
        /* Parameter */
87
        union {
88
                __u32 adrController;
89
                __u32 adrPLCI;
90
                __u32 adrNCCI;
91
        } adr;
92
 
93
        _cmstruct AdditionalInfo;
94
        _cstruct B1configuration;
95
        __u16 B1protocol;
96
        _cstruct B2configuration;
97
        __u16 B2protocol;
98
        _cstruct B3configuration;
99
        __u16 B3protocol;
100
        _cstruct BC;
101
        _cstruct BChannelinformation;
102
        _cmstruct BProtocol;
103
        _cstruct CalledPartyNumber;
104
        _cstruct CalledPartySubaddress;
105
        _cstruct CallingPartyNumber;
106
        _cstruct CallingPartySubaddress;
107
        __u32 CIPmask;
108
        __u32 CIPmask2;
109
        __u16 CIPValue;
110
        __u32 Class;
111
        _cstruct ConnectedNumber;
112
        _cstruct ConnectedSubaddress;
113
        __u32 Data;
114
        __u16 DataHandle;
115
        __u16 DataLength;
116
        _cstruct FacilityConfirmationParameter;
117
        _cstruct Facilitydataarray;
118
        _cstruct FacilityIndicationParameter;
119
        _cstruct FacilityRequestParameter;
120
        __u16 FacilitySelector;
121
        __u16 Flags;
122
        __u32 Function;
123
        _cstruct HLC;
124
        __u16 Info;
125
        _cstruct InfoElement;
126
        __u32 InfoMask;
127
        __u16 InfoNumber;
128
        _cstruct Keypadfacility;
129
        _cstruct LLC;
130
        _cstruct ManuData;
131
        __u32 ManuID;
132
        _cstruct NCPI;
133
        __u16 Reason;
134
        __u16 Reason_B3;
135
        __u16 Reject;
136
        _cstruct Useruserdata;
137
 
138
        /* intern */
139
        unsigned l, p;
140
        unsigned char *par;
141
        __u8 *m;
142
 
143
        /* buffer to construct message */
144
        __u8 buf[180];
145
 
146
} _cmsg;
147
 
148
/*
149
 * capi_cmsg2message() assembles the parameter from _cmsg to a CAPI 2.0
150
 * conform message
151
 */
152
unsigned capi_cmsg2message(_cmsg * cmsg, __u8 * msg);
153
 
154
/*
155
 *  capi_message2cmsg disassembles a CAPI message an writes the parameter
156
 *  into _cmsg for easy access
157
 */
158
unsigned capi_message2cmsg(_cmsg * cmsg, __u8 * msg);
159
 
160
/*
161
 * capi_cmsg_header() fills the _cmsg structure with default values, so only
162
 * parameter with non default values must be changed before sending the
163
 * message.
164
 */
165
unsigned capi_cmsg_header(_cmsg * cmsg, __u16 _ApplId,
166
                          __u8 _Command, __u8 _Subcommand,
167
                          __u16 _Messagenumber, __u32 _Controller);
168
 
169
/*
170
 * capi_info2str generated a readable string for Capi2.0 reasons.
171
 */
172
char *capi_info2str(__u16 reason);
173
 
174
/*-----------------------------------------------------------------------*/
175
 
176
/*
177
 * Debugging / Tracing functions
178
 */
179
char *capi_cmd2str(__u8 cmd, __u8 subcmd);
180
char *capi_cmsg2str(_cmsg * cmsg);
181
char *capi_message2str(__u8 * msg);
182
 
183
/*-----------------------------------------------------------------------*/
184
 
185
static inline void capi_cmsg_answer(_cmsg * cmsg)
186
{
187
        cmsg->Subcommand |= 0x01;
188
}
189
 
190
/*-----------------------------------------------------------------------*/
191
 
192
static inline void capi_fill_CONNECT_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
193
                                            __u32 adr,
194
                                            _cstruct NCPI)
195
{
196
        capi_cmsg_header(cmsg, ApplId, 0x82, 0x80, Messagenumber, adr);
197
        cmsg->NCPI = NCPI;
198
}
199
 
200
static inline void capi_fill_FACILITY_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
201
                                          __u32 adr,
202
                                          __u16 FacilitySelector,
203
                                       _cstruct FacilityRequestParameter)
204
{
205
        capi_cmsg_header(cmsg, ApplId, 0x80, 0x80, Messagenumber, adr);
206
        cmsg->FacilitySelector = FacilitySelector;
207
        cmsg->FacilityRequestParameter = FacilityRequestParameter;
208
}
209
 
210
static inline void capi_fill_INFO_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
211
                                      __u32 adr,
212
                                      _cstruct CalledPartyNumber,
213
                                      _cstruct BChannelinformation,
214
                                      _cstruct Keypadfacility,
215
                                      _cstruct Useruserdata,
216
                                      _cstruct Facilitydataarray)
217
{
218
        capi_cmsg_header(cmsg, ApplId, 0x08, 0x80, Messagenumber, adr);
219
        cmsg->CalledPartyNumber = CalledPartyNumber;
220
        cmsg->BChannelinformation = BChannelinformation;
221
        cmsg->Keypadfacility = Keypadfacility;
222
        cmsg->Useruserdata = Useruserdata;
223
        cmsg->Facilitydataarray = Facilitydataarray;
224
}
225
 
226
static inline void capi_fill_LISTEN_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
227
                                        __u32 adr,
228
                                        __u32 InfoMask,
229
                                        __u32 CIPmask,
230
                                        __u32 CIPmask2,
231
                                        _cstruct CallingPartyNumber,
232
                                        _cstruct CallingPartySubaddress)
233
{
234
        capi_cmsg_header(cmsg, ApplId, 0x05, 0x80, Messagenumber, adr);
235
        cmsg->InfoMask = InfoMask;
236
        cmsg->CIPmask = CIPmask;
237
        cmsg->CIPmask2 = CIPmask2;
238
        cmsg->CallingPartyNumber = CallingPartyNumber;
239
        cmsg->CallingPartySubaddress = CallingPartySubaddress;
240
}
241
 
242
static inline void capi_fill_ALERT_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
243
                                       __u32 adr,
244
                                       _cstruct BChannelinformation,
245
                                       _cstruct Keypadfacility,
246
                                       _cstruct Useruserdata,
247
                                       _cstruct Facilitydataarray)
248
{
249
        capi_cmsg_header(cmsg, ApplId, 0x01, 0x80, Messagenumber, adr);
250
        cmsg->BChannelinformation = BChannelinformation;
251
        cmsg->Keypadfacility = Keypadfacility;
252
        cmsg->Useruserdata = Useruserdata;
253
        cmsg->Facilitydataarray = Facilitydataarray;
254
}
255
 
256
static inline void capi_fill_CONNECT_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
257
                                         __u32 adr,
258
                                         __u16 CIPValue,
259
                                         _cstruct CalledPartyNumber,
260
                                         _cstruct CallingPartyNumber,
261
                                         _cstruct CalledPartySubaddress,
262
                                         _cstruct CallingPartySubaddress,
263
                                         __u16 B1protocol,
264
                                         __u16 B2protocol,
265
                                         __u16 B3protocol,
266
                                         _cstruct B1configuration,
267
                                         _cstruct B2configuration,
268
                                         _cstruct B3configuration,
269
                                         _cstruct BC,
270
                                         _cstruct LLC,
271
                                         _cstruct HLC,
272
                                         _cstruct BChannelinformation,
273
                                         _cstruct Keypadfacility,
274
                                         _cstruct Useruserdata,
275
                                         _cstruct Facilitydataarray)
276
{
277
 
278
        capi_cmsg_header(cmsg, ApplId, 0x02, 0x80, Messagenumber, adr);
279
        cmsg->CIPValue = CIPValue;
280
        cmsg->CalledPartyNumber = CalledPartyNumber;
281
        cmsg->CallingPartyNumber = CallingPartyNumber;
282
        cmsg->CalledPartySubaddress = CalledPartySubaddress;
283
        cmsg->CallingPartySubaddress = CallingPartySubaddress;
284
        cmsg->B1protocol = B1protocol;
285
        cmsg->B2protocol = B2protocol;
286
        cmsg->B3protocol = B3protocol;
287
        cmsg->B1configuration = B1configuration;
288
        cmsg->B2configuration = B2configuration;
289
        cmsg->B3configuration = B3configuration;
290
        cmsg->BC = BC;
291
        cmsg->LLC = LLC;
292
        cmsg->HLC = HLC;
293
        cmsg->BChannelinformation = BChannelinformation;
294
        cmsg->Keypadfacility = Keypadfacility;
295
        cmsg->Useruserdata = Useruserdata;
296
        cmsg->Facilitydataarray = Facilitydataarray;
297
}
298
 
299
static inline void capi_fill_DATA_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
300
                                         __u32 adr,
301
                                         __u32 Data,
302
                                         __u16 DataLength,
303
                                         __u16 DataHandle,
304
                                         __u16 Flags)
305
{
306
 
307
        capi_cmsg_header(cmsg, ApplId, 0x86, 0x80, Messagenumber, adr);
308
        cmsg->Data = Data;
309
        cmsg->DataLength = DataLength;
310
        cmsg->DataHandle = DataHandle;
311
        cmsg->Flags = Flags;
312
}
313
 
314
static inline void capi_fill_DISCONNECT_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
315
                                            __u32 adr,
316
                                            _cstruct BChannelinformation,
317
                                            _cstruct Keypadfacility,
318
                                            _cstruct Useruserdata,
319
                                            _cstruct Facilitydataarray)
320
{
321
 
322
        capi_cmsg_header(cmsg, ApplId, 0x04, 0x80, Messagenumber, adr);
323
        cmsg->BChannelinformation = BChannelinformation;
324
        cmsg->Keypadfacility = Keypadfacility;
325
        cmsg->Useruserdata = Useruserdata;
326
        cmsg->Facilitydataarray = Facilitydataarray;
327
}
328
 
329
static inline void capi_fill_DISCONNECT_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
330
                                               __u32 adr,
331
                                               _cstruct NCPI)
332
{
333
 
334
        capi_cmsg_header(cmsg, ApplId, 0x84, 0x80, Messagenumber, adr);
335
        cmsg->NCPI = NCPI;
336
}
337
 
338
static inline void capi_fill_MANUFACTURER_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
339
                                              __u32 adr,
340
                                              __u32 ManuID,
341
                                              __u32 Class,
342
                                              __u32 Function,
343
                                              _cstruct ManuData)
344
{
345
 
346
        capi_cmsg_header(cmsg, ApplId, 0xff, 0x80, Messagenumber, adr);
347
        cmsg->ManuID = ManuID;
348
        cmsg->Class = Class;
349
        cmsg->Function = Function;
350
        cmsg->ManuData = ManuData;
351
}
352
 
353
static inline void capi_fill_RESET_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
354
                                          __u32 adr,
355
                                          _cstruct NCPI)
356
{
357
 
358
        capi_cmsg_header(cmsg, ApplId, 0x87, 0x80, Messagenumber, adr);
359
        cmsg->NCPI = NCPI;
360
}
361
 
362
static inline void capi_fill_SELECT_B_PROTOCOL_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
363
                                                   __u32 adr,
364
                                                   __u16 B1protocol,
365
                                                   __u16 B2protocol,
366
                                                   __u16 B3protocol,
367
                                                _cstruct B1configuration,
368
                                                _cstruct B2configuration,
369
                                                _cstruct B3configuration)
370
{
371
 
372
        capi_cmsg_header(cmsg, ApplId, 0x41, 0x80, Messagenumber, adr);
373
        cmsg->B1protocol = B1protocol;
374
        cmsg->B2protocol = B2protocol;
375
        cmsg->B3protocol = B3protocol;
376
        cmsg->B1configuration = B1configuration;
377
        cmsg->B2configuration = B2configuration;
378
        cmsg->B3configuration = B3configuration;
379
}
380
 
381
static inline void capi_fill_CONNECT_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
382
                                          __u32 adr,
383
                                          __u16 Reject,
384
                                          __u16 B1protocol,
385
                                          __u16 B2protocol,
386
                                          __u16 B3protocol,
387
                                          _cstruct B1configuration,
388
                                          _cstruct B2configuration,
389
                                          _cstruct B3configuration,
390
                                          _cstruct ConnectedNumber,
391
                                          _cstruct ConnectedSubaddress,
392
                                          _cstruct LLC,
393
                                          _cstruct BChannelinformation,
394
                                          _cstruct Keypadfacility,
395
                                          _cstruct Useruserdata,
396
                                          _cstruct Facilitydataarray)
397
{
398
        capi_cmsg_header(cmsg, ApplId, 0x02, 0x83, Messagenumber, adr);
399
        cmsg->Reject = Reject;
400
        cmsg->B1protocol = B1protocol;
401
        cmsg->B2protocol = B2protocol;
402
        cmsg->B3protocol = B3protocol;
403
        cmsg->B1configuration = B1configuration;
404
        cmsg->B2configuration = B2configuration;
405
        cmsg->B3configuration = B3configuration;
406
        cmsg->ConnectedNumber = ConnectedNumber;
407
        cmsg->ConnectedSubaddress = ConnectedSubaddress;
408
        cmsg->LLC = LLC;
409
        cmsg->BChannelinformation = BChannelinformation;
410
        cmsg->Keypadfacility = Keypadfacility;
411
        cmsg->Useruserdata = Useruserdata;
412
        cmsg->Facilitydataarray = Facilitydataarray;
413
}
414
 
415
static inline void capi_fill_CONNECT_ACTIVE_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
416
                                                 __u32 adr)
417
{
418
 
419
        capi_cmsg_header(cmsg, ApplId, 0x03, 0x83, Messagenumber, adr);
420
}
421
 
422
static inline void capi_fill_CONNECT_B3_ACTIVE_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
423
                                                    __u32 adr)
424
{
425
 
426
        capi_cmsg_header(cmsg, ApplId, 0x83, 0x83, Messagenumber, adr);
427
}
428
 
429
static inline void capi_fill_CONNECT_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
430
                                             __u32 adr,
431
                                             __u16 Reject,
432
                                             _cstruct NCPI)
433
{
434
        capi_cmsg_header(cmsg, ApplId, 0x82, 0x83, Messagenumber, adr);
435
        cmsg->Reject = Reject;
436
        cmsg->NCPI = NCPI;
437
}
438
 
439
static inline void capi_fill_CONNECT_B3_T90_ACTIVE_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
440
                                                        __u32 adr)
441
{
442
 
443
        capi_cmsg_header(cmsg, ApplId, 0x88, 0x83, Messagenumber, adr);
444
}
445
 
446
static inline void capi_fill_DATA_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
447
                                          __u32 adr,
448
                                          __u16 DataHandle)
449
{
450
 
451
        capi_cmsg_header(cmsg, ApplId, 0x86, 0x83, Messagenumber, adr);
452
        cmsg->DataHandle = DataHandle;
453
}
454
 
455
static inline void capi_fill_DISCONNECT_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
456
                                                __u32 adr)
457
{
458
 
459
        capi_cmsg_header(cmsg, ApplId, 0x84, 0x83, Messagenumber, adr);
460
}
461
 
462
static inline void capi_fill_DISCONNECT_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
463
                                             __u32 adr)
464
{
465
 
466
        capi_cmsg_header(cmsg, ApplId, 0x04, 0x83, Messagenumber, adr);
467
}
468
 
469
static inline void capi_fill_FACILITY_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
470
                                           __u32 adr,
471
                                           __u16 FacilitySelector)
472
{
473
 
474
        capi_cmsg_header(cmsg, ApplId, 0x80, 0x83, Messagenumber, adr);
475
        cmsg->FacilitySelector = FacilitySelector;
476
}
477
 
478
static inline void capi_fill_INFO_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
479
                                       __u32 adr)
480
{
481
 
482
        capi_cmsg_header(cmsg, ApplId, 0x08, 0x83, Messagenumber, adr);
483
}
484
 
485
static inline void capi_fill_MANUFACTURER_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
486
                                               __u32 adr,
487
                                               __u32 ManuID,
488
                                               __u32 Class,
489
                                               __u32 Function,
490
                                               _cstruct ManuData)
491
{
492
 
493
        capi_cmsg_header(cmsg, ApplId, 0xff, 0x83, Messagenumber, adr);
494
        cmsg->ManuID = ManuID;
495
        cmsg->Class = Class;
496
        cmsg->Function = Function;
497
        cmsg->ManuData = ManuData;
498
}
499
 
500
static inline void capi_fill_RESET_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber,
501
                                           __u32 adr)
502
{
503
 
504
        capi_cmsg_header(cmsg, ApplId, 0x87, 0x83, Messagenumber, adr);
505
}
506
 
507
#endif                          /* __CAPIUTIL_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.