16
15
* This program is free software and may be modified and
17
16
* distributed under the terms of the GNU Public License.
21
#ifdef CC_AST_HAS_VERSION_1_4
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"
20
46
#ifndef _PBX_CAPI_H
21
47
#define _PBX_CAPI_H
38
64
#define CAPI_MAX_FACILITYDATAARRAY_SIZE 300
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
45
66
/* some helper functions */
46
67
static inline void write_capi_word(void *m, unsigned short val)
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)
87
#define CC_CHANNEL_PVT(c) (c)->tech_pvt
89
#else /* PBX_IS_OPBX */
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
102
#endif /* PBX_IS_OPBX */
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, ...);
119
#define return_on_no_interface(x) \
121
cc_verbose(4, 1, "CAPI: %s no interface for PLCI=%#x\n", x, PLCI); \
113
126
* B protocol settings
157
170
#define FACILITYSELECTOR_FAX_OVER_IP 0x00fd
158
171
#define FACILITYSELECTOR_VOICE_OVER_IP 0x00fe
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 */
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
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
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
259
/* Private qsig data for capi device */
260
struct cc_qsig_data {
261
int calltransfer_active;
263
int calltransfer_onring;
264
unsigned int callmark;
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 */
276
char if_pr_propose_pn[AST_MAX_EXTENSION]; /* configured interface Party Number */
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;
234
285
/* ! Private data for a capi device */
235
286
struct capi_pvt {
247
298
char vname[CAPI_MAX_STRING];
248
299
unsigned char tmpbuf[CAPI_MAX_STRING];
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;
253
308
/* capi message number */
254
309
_cword MessageNumber;
275
330
/* which b-protocol is active */
278
333
char context[AST_MAX_EXTENSION];
279
334
/*! Multiple Subscriber Number we listen to (, seperated list) */
280
335
char incomingmsn[CAPI_MAX_STRING];
336
391
/* Common ISDN Profile (CIP) */
393
unsigned short transfercapability;
339
395
/* if not null, receiving a fax */
342
398
unsigned int FaxState;
400
/* handle for CCBS/CCNR callback */
401
unsigned int ccbsnrhandle;
344
403
/* not all codecs supply frames in nice 160 byte chunks */
345
404
struct ast_smoother *smoother;
397
461
unsigned int manufacturer[5];
398
462
} __attribute__((__packed__));
464
struct cc_capi_qsig_conf {
465
char if_pr_propose_pn[AST_MAX_EXTENSION];
400
468
struct cc_capi_conf {
401
469
char name[CAPI_MAX_STRING];
402
470
char language[MAX_LANGUAGE];
512
581
#define PRI_TRANS_CAP_DIGITAL_W_TONES 0x11
513
582
#define PRI_TRANS_CAP_VIDEO 0x18
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);