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 caller_info callerinfo;
33 struct redir_info redirinfo;
34 struct connect_info connectinfo;
35 /* store connectinfo form lcr */
38 struct chan_call *bridge_call;
39 /* remote instance or NULL */
41 /* pipe for receive data */
42 unsigned char read_buff[1024];
43 /* read buffer for frame */
44 struct ast_frame read_fr;
47 /* LCR interface name for setup */
49 /* cached dial string for setup */
50 #ifndef AST_PARTY_CALLER
51 char cid_num[64]; /* cached cid for setup */
52 char cid_name[64]; /* cached cid for setup */
53 char cid_rdnis[64]; /* cached cid for setup */
56 /* display for setup */
58 /* decode dtmf by dsp */
59 int inband_dtmf; /* generate dtmf tones, if
60 requested by asterisk */
61 int rebuffer; /* send only 160 bytes frames
64 int framepos; /* send only 160 bytes frames to asterisk */
66 int on_hold; /* track hold management, since
67 sip phones sometimes screw it up */
69 /* echo cancel pipeline by option */
73 /* use keypad to dial number */
74 unsigned char bf_key[56];
75 int bf_len; /* blowfish crypt key */
76 struct ast_dsp *dsp; /* ast dsp processor for fax/tone detection */
77 struct ast_trans_pvt *trans; /* Codec translation path as fax/tone detection requires slin */
78 int nodsp, nodsp_queue, hdlc, faxdetect;
79 /* flags for bchannel mode */
80 char queue_string[64];
81 /* queue for asterisk */
83 /* pattern are available, PROGRESS has been indicated */
88 CHAN_LCR_STATE_IN_PREPARE = 0,
89 CHAN_LCR_STATE_IN_SETUP,
90 CHAN_LCR_STATE_IN_DIALING,
91 CHAN_LCR_STATE_IN_PROCEEDING,
92 CHAN_LCR_STATE_IN_ALERTING,
93 CHAN_LCR_STATE_OUT_PREPARE,
94 CHAN_LCR_STATE_OUT_SETUP,
95 CHAN_LCR_STATE_OUT_DIALING,
96 CHAN_LCR_STATE_OUT_PROCEEDING,
97 CHAN_LCR_STATE_OUT_ALERTING,
98 CHAN_LCR_STATE_CONNECT,
99 CHAN_LCR_STATE_IN_DISCONNECT,
100 CHAN_LCR_STATE_OUT_DISCONNECT,
101 CHAN_LCR_STATE_RELEASE,
104 #define CHAN_LCR_STATE static const struct chan_lcr_state { \
107 } chan_lcr_state[] = { \
109 "New call from ISDN is waiting for setup." }, \
111 "Call from ISDN is currently set up." }, \
113 "Call from ISDN is currently waiting for digits to be dialed." }, \
115 "Call from ISDN is complete and proceeds to ring." }, \
117 "Call from ISDN is ringing." }, \
119 "New call to ISDN is wating for setup." }, \
121 "Call to ISDN is currently set up." }, \
123 "Call to ISDN is currently waiting for digits to be dialed." }, \
124 { "OUT_PROCEEDING", \
125 "Call to ISDN is complete and proceeds to ring." }, \
127 "Call to ISDN is ringing." }, \
129 "Call has been answered." }, \
131 "Call has been hung up on ISDN side." }, \
132 { "OUT_DISCONNECT", \
133 "Call has been hung up on Asterisk side." }, \
135 "Call is waiting for complete release." }, \
139 #define SOCKET_RETRY_TIMER 5
141 #define CERROR(call, ast, arg...) chan_lcr_log(__LOG_ERROR, __FILE__, __LINE__, __FUNCTION__, call, ast, ##arg)
142 #define CDEBUG(call, ast, arg...) chan_lcr_log(__LOG_NOTICE, __FILE__, __LINE__, __FUNCTION__, call, ast, ##arg)
143 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, ...);
144 extern unsigned char flip_bits[256];
145 void lcr_in_dtmf(struct chan_call *call, int val);