1 /*****************************************************************************\
3 ** Linux Call Router **
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
8 ** Asterisk socket client header **
10 \*****************************************************************************/
12 /* structure for all calls */
15 struct chan_call *next; /* link to next call instance */
16 int state; /* current call state CHAN_LCR_STATE */
17 unsigned int ref; /* callref for this channel */
19 void *ast; /* current asterisk channel */
21 /* indicates if pbx que is available */
22 struct bchannel *bchannel;
23 /* reference to bchannel, if set */
25 /* audio is available */
27 /* store cause from lcr */
29 /* queue dialing prior setup ack */
30 char oad[64];/* caller id in number format */
32 struct connect_info connectinfo;
33 /* store connectinfo form lcr */
36 struct chan_call *bridge_call;
37 /* remote instance or NULL */
39 /* pipe for receive data */
40 unsigned char read_buff[1024];
41 /* read buffer for frame */
42 struct ast_frame read_fr;
45 /* LCR interface name for setup */
47 /* cached dial string for setup */
48 char cid_num[64]; /* cached cid for setup */
49 char cid_name[64]; /* cached cid for setup */
50 char cid_rdnis[64]; /* cached cid for setup */
52 /* display for setup */
54 /* shall dtmf be enabled */
56 /* dtmf disabled by option */
57 int inband_dtmf; /* generate dtmf tones, if
58 requested by asterisk */
59 int rebuffer; /* send only 160 bytes frames
61 int on_hold; /* track hold management, since
62 sip phones sometimes screw it up */
64 /* echo cancel pipeline by option */
67 unsigned char bf_key[56];
68 int bf_len; /* blowfish crypt key */
70 /* flags for bchannel mode */
71 char queue_string[64];
72 /* queue for asterisk */
77 CHAN_LCR_STATE_IN_PREPARE = 0,
78 CHAN_LCR_STATE_IN_SETUP,
79 CHAN_LCR_STATE_IN_DIALING,
80 CHAN_LCR_STATE_IN_PROCEEDING,
81 CHAN_LCR_STATE_IN_ALERTING,
82 CHAN_LCR_STATE_OUT_PREPARE,
83 CHAN_LCR_STATE_OUT_SETUP,
84 CHAN_LCR_STATE_OUT_DIALING,
85 CHAN_LCR_STATE_OUT_PROCEEDING,
86 CHAN_LCR_STATE_OUT_ALERTING,
87 CHAN_LCR_STATE_CONNECT,
88 CHAN_LCR_STATE_IN_DISCONNECT,
89 CHAN_LCR_STATE_OUT_DISCONNECT,
90 CHAN_LCR_STATE_RELEASE,
93 #define CHAN_LCR_STATE static const struct chan_lcr_state { \
96 } chan_lcr_state[] = { \
98 "New call from ISDN is waiting for setup." }, \
100 "Call from ISDN is currently set up." }, \
102 "Call from ISDN is currently waiting for digits to be dialed." }, \
104 "Call from ISDN is complete and proceeds to ring." }, \
106 "Call from ISDN is ringing." }, \
108 "New call to ISDN is wating for setup." }, \
110 "Call to ISDN is currently set up." }, \
112 "Call to ISDN is currently waiting for digits to be dialed." }, \
113 { "OUT_PROCEEDING", \
114 "Call to ISDN is complete and proceeds to ring." }, \
116 "Call to ISDN is ringing." }, \
118 "Call has been answered." }, \
120 "Call has been hung up on ISDN side." }, \
121 { "OUT_DISCONNECT", \
122 "Call has been hung up on Asterisk side." }, \
124 "Call is waiting for complete release." }, \
128 #define CERROR(call, ast, arg...) chan_lcr_log(__LOG_ERROR, __FILE__, __LINE__, __FUNCTION__, call, ast, ##arg)
129 #define CDEBUG(call, ast, arg...) chan_lcr_log(__LOG_NOTICE, __FILE__, __LINE__, __FUNCTION__, call, ast, ##arg)
130 void chan_lcr_log(int type, const char *file, int line, const char *function, struct chan_call *call, struct ast_channel *ast, const char *fmt, ...);
131 extern unsigned char flip_bits[256];
132 void lcr_in_dtmf(struct chan_call *call, int val);