work on chan_lcr
[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 long           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         struct connect_info     connectinfo;
31                                         /* store connectinfo form lcr */
32         int                     bridge_id;
33                                         /* current ID or 0 */
34         struct chan_call        *bridge_call;
35                                         /* remote instance or NULL */
36         int                     pipe[2];
37                                         /* pipe for receive data */
38         unsigned char           read_buff[1024];
39                                         /* read buffer for frame */
40         struct ast_frame        read_fr;
41                                         /* frame for read */
42 };
43
44 enum {
45         CHAN_LCR_STATE_IN_PREPARE = 0,
46         CHAN_LCR_STATE_IN_SETUP,
47         CHAN_LCR_STATE_IN_DIALING,
48         CHAN_LCR_STATE_IN_PROCEEDING,
49         CHAN_LCR_STATE_IN_ALERTING,
50         CHAN_LCR_STATE_OUT_PREPARE,
51         CHAN_LCR_STATE_OUT_SETUP,
52         CHAN_LCR_STATE_OUT_DIALING,
53         CHAN_LCR_STATE_OUT_PROCEEDING,
54         CHAN_LCR_STATE_OUT_ALERTING,
55         CHAN_LCR_STATE_CONNECT,
56         CHAN_LCR_STATE_IN_DISCONNECT,
57         CHAN_LCR_STATE_OUT_DISCONNECT,
58         CHAN_LCR_STATE_RELEASE,
59 };
60
61 #define CHAN_LCR_STATE static const struct chan_lcr_state { \
62         char *name; \
63         char *meaning; \
64 } chan_lcr_state[] = { \
65         { "IN_PREPARE", \
66           "New call from ISDN is waiting for setup." }, \
67         { "IN_SETUP", \
68           "Call from ISDN is currently set up." }, \
69         { "IN_DIALING", \
70           "Call from ISDN is currently waiting for digits to be dialed." }, \
71         { "IN_PROCEEDING", \
72           "Call from ISDN is complete and proceeds to ring." }, \
73         { "IN_ALERTING", \
74           "Call from ISDN is ringing." }, \
75         { "OUT_PREPARE", \
76           "New call to ISDN is wating for setup." }, \
77         { "OUT_SETUP", \
78           "Call to ISDN is currently set up." }, \
79         { "OUT_DIALING", \
80           "Call to ISDN is currently waiting for digits to be dialed." }, \
81         { "OUT_PROCEEDING", \
82           "Call to ISDN is complete and proceeds to ring." }, \
83         { "OUT_ALERTING", \
84           "Call to ISDN is ringing." }, \
85         { "CONNECT", \
86           "Call has been answered." }, \
87         { "IN_DISCONNECT", \
88           "Call has been hung up on ISDN side." }, \
89         { "OUT_DISCONNECT", \
90           "Call has been hung up on Asterisk side." }, \
91         { "RELEASE", \
92           "Call is waiting for complete release." }, \
93 };
94
95
96 #define CERROR(call, ast, arg...) chan_lcr_log(__LOG_ERROR, __FILE__, __LINE__, call, ast, ##arg)
97 #define CDEBUG(call, ast, arg...) chan_lcr_log(__LOG_DEBUG, __FILE__, __LINE__, call, ast, ##arg)
98 void chan_lcr_log(int type, const char *file, int line, struct chan_call *call, struct ast_channel *ast, const char *fmt, ...);
99