made callerid handling work in call from asterisk
[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         void                    *ast;   /* current asterisk channel */
19         int                     pbx_started;
20                                         /* indicates if pbx que is available */
21         struct bchannel         *bchannel;
22                                         /* reference to bchannel, if set */
23         int                     audiopath;
24                                         /* audio is available */
25         int                     cause, location;
26                                         /* store cause from lcr */
27         unsigned char           dialque[64];
28                                         /* queue dialing prior setup ack */
29         char                    oad[64];/* caller id in number format */
30
31         struct connect_info     connectinfo;
32                                         /* store connectinfo form lcr */
33         int                     bridge_id;
34                                         /* current ID or 0 */
35         struct chan_call        *bridge_call;
36                                         /* remote instance or NULL */
37         int                     pipe[2];
38                                         /* pipe for receive data */
39         unsigned char           read_buff[1024];
40                                         /* read buffer for frame */
41         struct ast_frame        read_fr;
42                                         /* frame for read */
43         char                    interface[32];
44                                         /* LCR interface name for setup */
45         char                    dialstring[64];
46                                         /* cached dial string for setup */
47         char                    cid_num[64]; /* cached cid for setup */
48         char                    cid_name[64]; /* cached cid for setup */
49         char                    cid_rdnis[64]; /* cached cid for setup */
50         char                    display[128];
51                                         /* display for setup */
52         int                     dtmf;
53                                         /* shall dtmf be enabled */
54         int                     no_dtmf;
55                                         /* dtmf disabled by option */
56         char                    pipeline[256];
57                                         /* echo cancel pipeline by option */
58         int                     tx_gain, rx_gain;
59                                         /* gain by option */
60         unsigned char           bf_key[56];
61         int                     bf_len; /* blowfish crypt key */
62         int                     transparent, hdlc;
63                                         /* flags for bchannel mode */
64                 
65 };
66
67 enum {
68         CHAN_LCR_STATE_IN_PREPARE = 0,
69         CHAN_LCR_STATE_IN_SETUP,
70         CHAN_LCR_STATE_IN_DIALING,
71         CHAN_LCR_STATE_IN_PROCEEDING,
72         CHAN_LCR_STATE_IN_ALERTING,
73         CHAN_LCR_STATE_OUT_PREPARE,
74         CHAN_LCR_STATE_OUT_SETUP,
75         CHAN_LCR_STATE_OUT_DIALING,
76         CHAN_LCR_STATE_OUT_PROCEEDING,
77         CHAN_LCR_STATE_OUT_ALERTING,
78         CHAN_LCR_STATE_CONNECT,
79         CHAN_LCR_STATE_IN_DISCONNECT,
80         CHAN_LCR_STATE_OUT_DISCONNECT,
81         CHAN_LCR_STATE_RELEASE,
82 };
83
84 #define CHAN_LCR_STATE static const struct chan_lcr_state { \
85         char *name; \
86         char *meaning; \
87 } chan_lcr_state[] = { \
88         { "IN_PREPARE", \
89           "New call from ISDN is waiting for setup." }, \
90         { "IN_SETUP", \
91           "Call from ISDN is currently set up." }, \
92         { "IN_DIALING", \
93           "Call from ISDN is currently waiting for digits to be dialed." }, \
94         { "IN_PROCEEDING", \
95           "Call from ISDN is complete and proceeds to ring." }, \
96         { "IN_ALERTING", \
97           "Call from ISDN is ringing." }, \
98         { "OUT_PREPARE", \
99           "New call to ISDN is wating for setup." }, \
100         { "OUT_SETUP", \
101           "Call to ISDN is currently set up." }, \
102         { "OUT_DIALING", \
103           "Call to ISDN is currently waiting for digits to be dialed." }, \
104         { "OUT_PROCEEDING", \
105           "Call to ISDN is complete and proceeds to ring." }, \
106         { "OUT_ALERTING", \
107           "Call to ISDN is ringing." }, \
108         { "CONNECT", \
109           "Call has been answered." }, \
110         { "IN_DISCONNECT", \
111           "Call has been hung up on ISDN side." }, \
112         { "OUT_DISCONNECT", \
113           "Call has been hung up on Asterisk side." }, \
114         { "RELEASE", \
115           "Call is waiting for complete release." }, \
116 };
117
118
119 #define CERROR(call, ast, arg...) chan_lcr_log(__LOG_ERROR, __FILE__, __LINE__,  __FUNCTION__, call, ast, ##arg)
120 #define CDEBUG(call, ast, arg...) chan_lcr_log(__LOG_NOTICE, __FILE__, __LINE__,  __FUNCTION__, call, ast, ##arg)
121 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, ...);
122 extern unsigned char flip_bits[256];
123 void lcr_in_dtmf(struct chan_call *call, int val);