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

Subversion Repositories or1k

[/] [or1k/] [tags/] [before_ORP/] [uclinux/] [uClinux-2.0.x/] [drivers/] [isdn/] [avmb1/] [capiutil.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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