gsm->network must be set != NULL, to make it work correctly
[lcr.git] / chan_lcr.h
1 /*****************************************************************************\
2 **                                                                           **
3 ** Linux Call Router                                                         **
4 **                                                                           **
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg                                              **
7 **                                                                           **
8 ** Asterisk socket client header                                             **
9 **                                                                           **
10 \*****************************************************************************/
11
12 /* structure for all calls */
13 struct bchannel;
14 struct chan_call {
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 */
18         int                     ref_was_assigned;
19         void                    *ast;   /* current asterisk channel */
20         int                     pbx_started;
21                                         /* indicates if pbx que is available */
22         struct bchannel         *bchannel;
23                                         /* reference to bchannel, if set */
24         int                     audiopath;
25                                         /* audio is available */
26         int                     cause, location;
27                                         /* store cause from lcr */
28         char                    dialque[64];
29                                         /* queue dialing prior setup ack */
30         char                    oad[64];/* caller id in number format */
31
32         struct caller_info      callerinfo;
33         struct redir_info       redirinfo;
34         struct connect_info     connectinfo;
35                                         /* store connectinfo form lcr */
36         int                     bridge_id;
37                                         /* current ID or 0 */
38         struct chan_call        *bridge_call;
39                                         /* remote instance or NULL */
40         int                     pipe[2];
41                                         /* pipe for receive data */
42         unsigned char           read_buff[1024];
43                                         /* read buffer for frame */
44         struct ast_frame        read_fr;
45                                         /* frame for read */
46         char                    interface[32];
47                                         /* LCR interface name for setup */
48         char                    dialstring[64];
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 */
54 #endif
55         char                    display[128];
56                                         /* display for setup */
57         int                     dsp_dtmf;
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
62                                              to asterisk */
63
64         int                     framepos; /* send only 160 bytes frames to asterisk */
65         
66         int                     on_hold; /* track hold management, since
67                                             sip phones sometimes screw it up */
68         char                    pipeline[256];
69                                         /* echo cancel pipeline by option */
70         int                     tx_gain, rx_gain;
71                                         /* gain by option */
72         int                     keypad;
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 */
82         int                     has_pattern;
83                                         /* pattern are available, PROGRESS has been indicated */
84                 
85 };
86
87 enum {
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,
102 };
103
104 #define CHAN_LCR_STATE static const struct chan_lcr_state { \
105         char *name; \
106         char *meaning; \
107 } chan_lcr_state[] = { \
108         { "IN_PREPARE", \
109           "New call from ISDN is waiting for setup." }, \
110         { "IN_SETUP", \
111           "Call from ISDN is currently set up." }, \
112         { "IN_DIALING", \
113           "Call from ISDN is currently waiting for digits to be dialed." }, \
114         { "IN_PROCEEDING", \
115           "Call from ISDN is complete and proceeds to ring." }, \
116         { "IN_ALERTING", \
117           "Call from ISDN is ringing." }, \
118         { "OUT_PREPARE", \
119           "New call to ISDN is wating for setup." }, \
120         { "OUT_SETUP", \
121           "Call to ISDN is currently set up." }, \
122         { "OUT_DIALING", \
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." }, \
126         { "OUT_ALERTING", \
127           "Call to ISDN is ringing." }, \
128         { "CONNECT", \
129           "Call has been answered." }, \
130         { "IN_DISCONNECT", \
131           "Call has been hung up on ISDN side." }, \
132         { "OUT_DISCONNECT", \
133           "Call has been hung up on Asterisk side." }, \
134         { "RELEASE", \
135           "Call is waiting for complete release." }, \
136 };
137
138
139 #define SOCKET_RETRY_TIMER      5
140
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);