~ubuntu-branches/debian/squeeze/asterisk-chan-capi/squeeze

« back to all changes in this revision

Viewing changes to chan_capi.h

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell, Kilian Krause
  • Date: 2007-11-30 15:54:46 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20071130155446-09q50fizvzsrkind
Tags: 1.0.2-1
* Extremadura release ;-)

[ Kilian Krause ]
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * (CAPI*)
3
3
 *
4
 
 * An implementation of Common ISDN API 2.0 for
5
 
 * Asterisk / OpenPBX.org
 
4
 * An implementation of Common ISDN API 2.0 for Asterisk
6
5
 *
7
6
 * Copyright (C) 2005-2007 Cytronics & Melware
8
7
 *
16
15
 * This program is free software and may be modified and 
17
16
 * distributed under the terms of the GNU Public License.
18
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#ifdef CC_AST_HAS_VERSION_1_4
 
22
#include <asterisk.h>
 
23
#endif
 
24
 
 
25
#include <asterisk/lock.h>
 
26
#include <asterisk/frame.h>
 
27
#include <asterisk/channel.h>
 
28
#include <asterisk/logger.h>
 
29
#include <asterisk/module.h>
 
30
#include <asterisk/pbx.h>
 
31
#include <asterisk/config.h>
 
32
#include <asterisk/options.h>
 
33
#include <asterisk/features.h>
 
34
#include <asterisk/utils.h>
 
35
#include <asterisk/cli.h>
 
36
#include <asterisk/rtp.h>
 
37
#include <asterisk/causes.h>
 
38
#include <asterisk/strings.h>
 
39
#include <asterisk/dsp.h>
 
40
#include <asterisk/devicestate.h>
 
41
#ifdef CC_AST_HAS_VERSION_1_4
 
42
#include "asterisk/abstract_jb.h"
 
43
#include "asterisk/musiconhold.h"
 
44
#endif
19
45
 
20
46
#ifndef _PBX_CAPI_H
21
47
#define _PBX_CAPI_H
37
63
 
38
64
#define CAPI_MAX_FACILITYDATAARRAY_SIZE 300
39
65
 
40
 
#ifndef CONNECT_RESP_GLOBALCONFIGURATION
41
 
#define CC_HAVE_NO_GLOBALCONFIGURATION
42
 
#warning If you dont update your libcapi20, some fax features are not available
43
 
#endif
44
 
 
45
66
/* some helper functions */
46
67
static inline void write_capi_word(void *m, unsigned short val)
47
68
{
83
104
#define cc_pbx_verbose(x...)      ast_verbose(x)
84
105
#define cc_copy_string(dst, src, size)  ast_copy_string(dst, src, size)
85
106
 
86
 
#ifdef PBX_IS_OPBX
87
 
#define CC_CHANNEL_PVT(c) (c)->tech_pvt
88
 
 
89
 
#else /* PBX_IS_OPBX */
90
 
 
91
107
#ifndef AST_MUTEX_DEFINE_STATIC
92
108
#define AST_MUTEX_DEFINE_STATIC(mutex)          \
93
109
        static cc_mutex_t mutex = AST_MUTEX_INITIALIZER
99
115
#define CC_CHANNEL_PVT(c) (c)->tech_pvt
100
116
#define CC_BRIDGE_RETURN enum ast_bridge_result
101
117
 
102
 
#endif /* PBX_IS_OPBX */
103
 
 
104
 
/*
105
 
 * prototypes
106
 
 */
107
 
extern unsigned capi_ApplID;
108
 
extern MESSAGE_EXCHANGE_ERROR _capi_put_cmsg(_cmsg *CMSG);
109
 
extern _cword get_capi_MessageNumber(void);
110
 
extern void cc_verbose(int o_v, int c_d, char *text, ...);
 
118
/* */
 
119
#define return_on_no_interface(x)                                       \
 
120
        if (!i) {                                                       \
 
121
                cc_verbose(4, 1, "CAPI: %s no interface for PLCI=%#x\n", x, PLCI);   \
 
122
                return;                                                 \
 
123
        }
111
124
 
112
125
/*
113
126
 * B protocol settings
157
170
#define FACILITYSELECTOR_FAX_OVER_IP       0x00fd
158
171
#define FACILITYSELECTOR_VOICE_OVER_IP     0x00fe
159
172
 
 
173
#define EC_FUNCTION_ENABLE              1   
 
174
#define EC_FUNCTION_DISABLE             2
 
175
#define EC_FUNCTION_FREEZE              3   
 
176
#define EC_FUNCTION_RESUME              4
 
177
#define EC_FUNCTION_RESET               5   
 
178
#define EC_OPTION_DISABLE_NEVER         0   
 
179
#define EC_OPTION_DISABLE_G165          (1<<2)
 
180
#define EC_OPTION_DISABLE_G164_OR_G165  (1<<1 | 1<<2)
 
181
#define EC_DEFAULT_TAIL                 0 /* maximum */
 
182
 
160
183
#define CC_HOLDTYPE_LOCAL               0
161
184
#define CC_HOLDTYPE_HOLD                1
162
185
#define CC_HOLDTYPE_NOTIFY              2
218
241
#define CAPI_ISDN_STATE_EC            0x00002000
219
242
#define CAPI_ISDN_STATE_DTMF          0x00004000
220
243
#define CAPI_ISDN_STATE_B3_SELECT     0x00008000
221
 
#define CAPI_ISDN_STATE_3PTY          0x10000000
 
244
#define CAPI_ISDN_STATE_STAYONLINE    0x00010000
 
245
#define CAPI_ISDN_STATE_ISDNPROGRESS  0x00020000
 
246
#define CAPI_ISDN_STATE_3PTY          0x10000000
222
247
#define CAPI_ISDN_STATE_PBX_DONT      0x40000000
223
248
#define CAPI_ISDN_STATE_PBX           0x80000000
224
249
 
225
250
#define CAPI_CHANNELTYPE_B            0
226
251
#define CAPI_CHANNELTYPE_D            1
227
 
#define CAPI_CHANNELTYPE_NONE         2
 
252
#define CAPI_CHANNELTYPE_NULL         2
228
253
 
229
254
/* the lower word is reserved for capi commands */
230
255
#define CAPI_WAITEVENT_B3_UP          0x00010000
231
256
#define CAPI_WAITEVENT_B3_DOWN        0x00020000
232
257
#define CAPI_WAITEVENT_ANSWER_FINISH  0x00030000
233
258
 
 
259
/* Private qsig data for capi device */
 
260
struct cc_qsig_data {
 
261
        int calltransfer_active;
 
262
        int calltransfer;
 
263
        int calltransfer_onring;
 
264
        unsigned int callmark;
 
265
        
 
266
        char *dnameid;
 
267
 
 
268
        /* Path Replacement */
 
269
        int pr_propose_sendback; /* send back an prior received PR PROPOSE on Connect */
 
270
        int pr_propose_sentback; /* set to 1 after sending an PR PROPOSE */
 
271
        int pr_propose_active;
 
272
        int pr_propose_doinboundbridge; /* We have to to bridge a call back to asterisk */
 
273
        char *pr_propose_cid;   /* Call identity */
 
274
        char *pr_propose_pn;    /* Party Number */
 
275
        
 
276
        char if_pr_propose_pn[AST_MAX_EXTENSION];       /* configured interface Party Number */
 
277
        
 
278
        /* Partner Channel - needed for many features */
 
279
        struct capi_pvt *partner_ch;
 
280
        unsigned int partner_plci;
 
281
        ast_cond_t event_trigger;
 
282
        unsigned int waitevent;
 
283
};
 
284
 
234
285
/* ! Private data for a capi device */
235
286
struct capi_pvt {
236
287
        cc_mutex_t lock;
247
298
        char vname[CAPI_MAX_STRING];
248
299
        unsigned char tmpbuf[CAPI_MAX_STRING];
249
300
 
 
301
        /*! Channel who used us, possibly NULL */
 
302
        struct ast_channel *used;               
250
303
        /*! Channel we belong to, possibly NULL */
251
304
        struct ast_channel *owner;              
 
305
        /*! Channel who called us, possibly NULL */
 
306
        struct ast_channel *peer;               
252
307
        
253
308
        /* capi message number */
254
309
        _cword MessageNumber;   
274
329
 
275
330
        /* which b-protocol is active */
276
331
        int bproto;
277
 
        
 
332
 
278
333
        char context[AST_MAX_EXTENSION];
279
334
        /*! Multiple Subscriber Number we listen to (, seperated list) */
280
335
        char incomingmsn[CAPI_MAX_STRING];      
335
390
 
336
391
        /* Common ISDN Profile (CIP) */
337
392
        int cip;
 
393
        unsigned short transfercapability;
338
394
        
339
395
        /* if not null, receiving a fax */
340
396
        FILE *fFax;
341
397
        /* Fax status */
342
398
        unsigned int FaxState;
343
399
 
 
400
        /* handle for CCBS/CCNR callback */
 
401
        unsigned int ccbsnrhandle;
 
402
 
344
403
        /* not all codecs supply frames in nice 160 byte chunks */
345
404
        struct ast_smoother *smoother;
346
405
 
369
428
        unsigned int reason;
370
429
        unsigned int reasonb3;
371
430
 
 
431
        /* deferred tasks */
 
432
        time_t whentohangup;
 
433
        time_t whentoqueuehangup;
 
434
 
372
435
        /* RTP */
373
436
        struct ast_rtp *rtp;
374
437
        int capability;
378
441
 
379
442
        /* Q.SIG features */
380
443
        int qsigfeat;
381
 
 
 
444
        struct cc_qsig_data qsig_data;
 
445
        
382
446
        /*! Next channel in list */
383
447
        struct capi_pvt *next;
384
448
};
397
461
        unsigned int manufacturer[5];
398
462
} __attribute__((__packed__));
399
463
 
 
464
struct cc_capi_qsig_conf {
 
465
        char if_pr_propose_pn[AST_MAX_EXTENSION];
 
466
};
 
467
 
400
468
struct cc_capi_conf {
401
469
        char name[CAPI_MAX_STRING];     
402
470
        char language[MAX_LANGUAGE];
421
489
        int bridge;
422
490
        int amaflags;
423
491
        int qsigfeat;
 
492
        struct cc_capi_qsig_conf qsigconf;
424
493
        unsigned int faxsetting;
425
494
        ast_group_t callgroup;
426
495
        ast_group_t pickupgroup;
512
581
#define PRI_TRANS_CAP_DIGITAL_W_TONES           0x11
513
582
#define PRI_TRANS_CAP_VIDEO                     0x18
514
583
 
 
584
/*
 
585
 * prototypes
 
586
 */
 
587
extern const struct ast_channel_tech capi_tech;
 
588
extern int capi_capability;
 
589
extern unsigned capi_ApplID;
 
590
extern struct capi_pvt *capi_iflist;
 
591
extern void cc_start_b3(struct capi_pvt *i);
 
592
extern unsigned char capi_tcap_is_digital(unsigned short tcap);
 
593
extern void capi_queue_cause_control(struct capi_pvt *i, int control);
 
594
extern void capidev_handle_connection_conf(struct capi_pvt **i, unsigned int PLCI,
 
595
    unsigned short wInfo, unsigned short wMsgNum);
 
596
extern void capi_wait_for_answered(struct capi_pvt *i);
 
597
extern int capi_wait_for_b3_up(struct capi_pvt *i);
 
598
extern void capi_activehangup(struct capi_pvt *i, int state);
 
599
extern void capi_gains(struct cc_capi_gains *g, float rxgain, float txgain);
 
600
 
515
601
#endif