chan_lcr: forgotten commit for new ref fix
[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 connect_info     connectinfo;
33                                         /* store connectinfo form lcr */
34         int                     bridge_id;
35                                         /* current ID or 0 */
36         struct chan_call        *bridge_call;
37                                         /* remote instance or NULL */
38         int                     pipe[2];
39                                         /* pipe for receive data */
40         unsigned char           read_buff[1024];
41                                         /* read buffer for frame */
42         struct ast_frame        read_fr;
43                                         /* frame for read */
44         char                    interface[32];
45                                         /* LCR interface name for setup */
46         char                    dialstring[64];
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 */
51         char                    display[128];
52                                         /* display for setup */
53         int                     dtmf;
54                                         /* shall dtmf be enabled */
55         int                     no_dtmf;
56                                         /* dtmf disabled by option */
57         int                     rebuffer; /* send only 160 bytes frames
58                                              to asterisk */
59         int                     on_hold; /* track hold management, since
60                                             sip phones sometimes screw it up */
61         char                    pipeline[256];
62                                         /* echo cancel pipeline by option */
63         int                     tx_gain, rx_gain;
64                                         /* gain by option */
65         unsigned char           bf_key[56];
66         int                     bf_len; /* blowfish crypt key */
67         int                     nodsp, hdlc;
68                                         /* flags for bchannel mode */
69         char                    queue_string[64];
70                                         /* queue for asterisk */
71                 
72 };
73
74 enum {
75         CHAN_LCR_STATE_IN_PREPARE = 0,
76         CHAN_LCR_STATE_IN_SETUP,
77         CHAN_LCR_STATE_IN_DIALING,
78         CHAN_LCR_STATE_IN_PROCEEDING,
79         CHAN_LCR_STATE_IN_ALERTING,
80         CHAN_LCR_STATE_OUT_PREPARE,
81         CHAN_LCR_STATE_OUT_SETUP,
82         CHAN_LCR_STATE_OUT_DIALING,
83         CHAN_LCR_STATE_OUT_PROCEEDING,
84         CHAN_LCR_STATE_OUT_ALERTING,
85         CHAN_LCR_STATE_CONNECT,
86         CHAN_LCR_STATE_IN_DISCONNECT,
87         CHAN_LCR_STATE_OUT_DISCONNECT,
88         CHAN_LCR_STATE_RELEASE,
89 };
90
91 #define CHAN_LCR_STATE static const struct chan_lcr_state { \
92         char *name; \
93         char *meaning; \
94 } chan_lcr_state[] = { \
95         { "IN_PREPARE", \
96           "New call from ISDN is waiting for setup." }, \
97         { "IN_SETUP", \
98           "Call from ISDN is currently set up." }, \
99         { "IN_DIALING", \
100           "Call from ISDN is currently waiting for digits to be dialed." }, \
101         { "IN_PROCEEDING", \
102           "Call from ISDN is complete and proceeds to ring." }, \
103         { "IN_ALERTING", \
104           "Call from ISDN is ringing." }, \
105         { "OUT_PREPARE", \
106           "New call to ISDN is wating for setup." }, \
107         { "OUT_SETUP", \
108           "Call to ISDN is currently set up." }, \
109         { "OUT_DIALING", \
110           "Call to ISDN is currently waiting for digits to be dialed." }, \
111         { "OUT_PROCEEDING", \
112           "Call to ISDN is complete and proceeds to ring." }, \
113         { "OUT_ALERTING", \
114           "Call to ISDN is ringing." }, \
115         { "CONNECT", \
116           "Call has been answered." }, \
117         { "IN_DISCONNECT", \
118           "Call has been hung up on ISDN side." }, \
119         { "OUT_DISCONNECT", \
120           "Call has been hung up on Asterisk side." }, \
121         { "RELEASE", \
122           "Call is waiting for complete release." }, \
123 };
124
125
126 #define CERROR(call, ast, arg...) chan_lcr_log(__LOG_ERROR, __FILE__, __LINE__,  __FUNCTION__, call, ast, ##arg)
127 #define CDEBUG(call, ast, arg...) chan_lcr_log(__LOG_NOTICE, __FILE__, __LINE__,  __FUNCTION__, call, ast, ##arg)
128 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, ...);
129 extern unsigned char flip_bits[256];
130 void lcr_in_dtmf(struct chan_call *call, int val);