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 #ifndef AST_PARTY_CALLER
49 char cid_num[64]; /* cached cid for setup */
50 char cid_name[64]; /* cached cid for setup */
51 char cid_rdnis[64]; /* cached cid for setup */
54 /* display for setup */
56 /* decode dtmf by dsp */
57 int inband_dtmf; /* generate dtmf tones, if
58 requested by asterisk */
59 int rebuffer; /* send only 160 bytes frames
62 int framepos; /* send only 160 bytes frames to asterisk */
64 int on_hold; /* track hold management, since
65 sip phones sometimes screw it up */
67 /* echo cancel pipeline by option */
71 /* use keypad to dial number */
72 unsigned char bf_key[56];
73 int bf_len; /* blowfish crypt key */
74 struct ast_dsp *dsp; /* ast dsp processor for fax/tone detection */
75 struct ast_trans_pvt *trans; /* Codec translation path as fax/tone detection requires slin */
76 int nodsp, nodsp_queue, hdlc, faxdetect;
77 /* flags for bchannel mode */
78 char queue_string[64];
79 /* queue for asterisk */
81 /* pattern are available, PROGRESS has been indicated */
86 CHAN_LCR_STATE_IN_PREPARE = 0,
87 CHAN_LCR_STATE_IN_SETUP,
88 CHAN_LCR_STATE_IN_DIALING,
89 CHAN_LCR_STATE_IN_PROCEEDING,
90 CHAN_LCR_STATE_IN_ALERTING,
91 CHAN_LCR_STATE_OUT_PREPARE,
92 CHAN_LCR_STATE_OUT_SETUP,
93 CHAN_LCR_STATE_OUT_DIALING,
94 CHAN_LCR_STATE_OUT_PROCEEDING,
95 CHAN_LCR_STATE_OUT_ALERTING,
96 CHAN_LCR_STATE_CONNECT,
97 CHAN_LCR_STATE_IN_DISCONNECT,
98 CHAN_LCR_STATE_OUT_DISCONNECT,
99 CHAN_LCR_STATE_RELEASE,
102 #define CHAN_LCR_STATE static const struct chan_lcr_state { \
105 } chan_lcr_state[] = { \
107 "New call from ISDN is waiting for setup." }, \
109 "Call from ISDN is currently set up." }, \
111 "Call from ISDN is currently waiting for digits to be dialed." }, \
113 "Call from ISDN is complete and proceeds to ring." }, \
115 "Call from ISDN is ringing." }, \
117 "New call to ISDN is wating for setup." }, \
119 "Call to ISDN is currently set up." }, \
121 "Call to ISDN is currently waiting for digits to be dialed." }, \
122 { "OUT_PROCEEDING", \
123 "Call to ISDN is complete and proceeds to ring." }, \
125 "Call to ISDN is ringing." }, \
127 "Call has been answered." }, \
129 "Call has been hung up on ISDN side." }, \
130 { "OUT_DISCONNECT", \
131 "Call has been hung up on Asterisk side." }, \
133 "Call is waiting for complete release." }, \
137 #define SOCKET_RETRY_TIMER 5
139 #define CERROR(call, ast, arg...) chan_lcr_log(__LOG_ERROR, __FILE__, __LINE__, __FUNCTION__, call, ast, ##arg)
140 #define CDEBUG(call, ast, arg...) chan_lcr_log(__LOG_NOTICE, __FILE__, __LINE__, __FUNCTION__, call, ast, ##arg)
141 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, ...);
142 extern unsigned char flip_bits[256];
143 void lcr_in_dtmf(struct chan_call *call, int val);