f86036f4c9fbcb0b1e82d7c5e8bedebd91733220
[lcr.git] / admin.h
1 /*****************************************************************************\
2 **                                                                           **
3 ** PBX4Linux                                                                 **
4 **                                                                           **
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg                                              **
7 **                                                                           **
8 ** Administration tool header file                                           **
9 **                                                                           **
10 \*****************************************************************************/
11
12 #define SOCKET_NAME "/var/run/PBX4Linux.socket"
13
14 /* structures that define message between admin-tool and pbx */
15
16 enum { /* messages */
17         ADMIN_REQUEST_CMD_INTERFACE,
18         ADMIN_RESPONSE_CMD_INTERFACE,
19         ADMIN_REQUEST_CMD_ROUTE,
20         ADMIN_RESPONSE_CMD_ROUTE,
21         ADMIN_REQUEST_CMD_DIAL,
22         ADMIN_RESPONSE_CMD_DIAL,
23         ADMIN_REQUEST_CMD_RELEASE,
24         ADMIN_RESPONSE_CMD_RELEASE,
25         ADMIN_REQUEST_STATE,
26         ADMIN_RESPONSE_STATE,
27         ADMIN_RESPONSE_S_INTERFACE,
28         ADMIN_RESPONSE_S_PORT,
29         ADMIN_RESPONSE_S_EPOINT,
30         ADMIN_RESPONSE_S_CALL,
31         ADMIN_CALL_SETUP,
32         ADMIN_CALL_SETUP_ACK,
33         ADMIN_CALL_PROCEEDING,
34         ADMIN_CALL_ALERTING,
35         ADMIN_CALL_CONNECT,
36         ADMIN_CALL_DISCONNECT,
37         ADMIN_CALL_RELEASE,
38         ADMIN_CALL_NOTIFY,
39         ADMIN_TRACE_REQUEST,
40         ADMIN_TRACE_RESPONSE,
41         ADMIN_MESSAGE,
42 };
43
44 struct admin_response_cmd {
45         int             error;          /* error code 0 = ok*/
46         char            message[256];   /* info / response text */
47 };
48
49 struct admin_response_state {
50         char            version_string[64];
51         struct tm       tm;
52         char            logfile[128];
53         int             interfaces;
54         int             calls;
55         int             epoints;
56         int             ports;
57 };
58
59 struct admin_response_interface {
60         int             portnum;
61         char            interface_name[32];
62         int             ntmode;
63         int             ptp;
64         int             pri;
65         int             iftype;
66         int             use; /* number of ports that use this interface */
67         int             l1link; /* down(0) or up(1) */
68         int             l2link; /* down(0) or up(1) */
69         int             channels;
70         int             busy[256]; /* if port is idle(0) busy(1) */
71         unsigned long   port[256]; /* current port */
72 };
73
74 struct admin_response_call {
75         unsigned long   serial; /* call serial number */
76         unsigned long   partyline;
77 };
78
79 struct admin_response_epoint {
80         unsigned long   serial;
81         unsigned long   call; /* link to call */
82 //      int             call_notify; /* if relation notified on hold */
83 //      int             call_hold; /* if relation on hold */
84         int             rx_state;
85         int             tx_state;
86         int             state;
87         char            terminal[16];
88         char            callerid[64];
89         char            dialing[64];
90         char            action[32];
91         int             park; /* if parked */
92         int             park_len;
93         unsigned char   park_callid[8];
94         int             crypt; /* crypt state */
95 };
96
97 struct admin_response_port {
98         unsigned long   serial; /* port serial number */
99         char            name[64]; /* name of port */
100         unsigned long   epoint; /* link to epoint */
101         int             state;
102         int             isdn; /* if port is isdn */
103         int             isdn_chan; /* bchannel number */
104         int             isdn_hold; /* on hold */
105         int             isdn_ces; /* ces to use (>=0)*/
106 };
107
108 struct admin_call {
109         char            interface[64]; /* name of port */
110         char            callerid[64]; /* use caller id */
111         char            dialing[64]; /* number to dial */
112         int             present; /* presentation */
113         int             cause; /* cause to send */
114         int             location;
115         int             notify;
116         int             bc_capa;
117         int             bc_mode;
118         int             bc_info1;
119         int             hlc;
120         int             exthlc;
121 };
122
123 struct admin_trace_req {
124         int             detail;
125         char            category[4];
126         char            name[64];
127         int             port;
128         char            interface[64];
129         char            caller[34];
130         char            dialing[64];
131 };
132
133 struct admin_trace_rsp {
134         char            text[512];
135 };
136
137 //struct admin_msg {
138 //      int             type; /* type of message */
139 //      unsigned long   ref; /* reference to individual endpoints */
140 //      union parameter param; /* parameter union */
141 //};
142
143 struct admin_message {
144         int message; /* type of admin message */
145         union u {
146                 struct admin_response_cmd       x;
147                 struct admin_response_state     s;
148                 struct admin_response_interface i;
149                 struct admin_response_port      p;
150                 struct admin_response_epoint    e;
151                 struct admin_response_call      c;
152                 struct admin_call               call;
153 //              struct admin_msg                msg;
154                 struct admin_trace_req          trace_req;
155                 struct admin_trace_rsp          trace_rsp;
156         } u;
157 };
158
159 /* call states */
160 enum {
161         ADMIN_STATE_IDLE,
162         ADMIN_STATE_IN_SETUP,
163         ADMIN_STATE_OUT_SETUP,
164         ADMIN_STATE_IN_OVERLAP,
165         ADMIN_STATE_OUT_OVERLAP,
166         ADMIN_STATE_IN_PROCEEDING,
167         ADMIN_STATE_OUT_PROCEEDING,
168         ADMIN_STATE_IN_ALERTING,
169         ADMIN_STATE_OUT_ALERTING,
170         ADMIN_STATE_CONNECT,
171         ADMIN_STATE_IN_DISCONNECT,
172         ADMIN_STATE_OUT_DISCONNECT,
173 };