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