0a56b9811ce4501083f5aaff481af0f7d4368e4a
[lcr.git] / message.h
1 /*****************************************************************************\
2 **                                                                           **
3 ** PBX4Linux                                                                 **
4 **                                                                           **
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg                                              **
7 **                                                                           **
8 ** message types and parameters                                              **
9 **                                                                           **
10 \*****************************************************************************/ 
11
12 enum { /* interface types */
13         INFO_ITYPE_ISDN,
14         INFO_ITYPE_ISDN_EXTENSION, /* call from internal extension */
15         INFO_ITYPE_CHAN,
16         INFO_ITYPE_VBOX,
17 };
18
19 enum { /* number types */
20         INFO_NTYPE_UNKNOWN,
21         INFO_NTYPE_SUBSCRIBER,
22         INFO_NTYPE_NATIONAL,
23         INFO_NTYPE_INTERNATIONAL,
24 };
25
26 enum { /* number presentation */
27         INFO_PRESENT_NULL,
28         INFO_PRESENT_ALLOWED,
29         INFO_PRESENT_RESTRICTED,
30         INFO_PRESENT_NOTAVAIL,
31 };
32
33 enum { /* number presentation */
34         INFO_SCREEN_USER, /* user provided */
35         INFO_SCREEN_NETWORK, /* network provided */
36 };
37
38 enum { /* redirection reason */
39         INFO_REDIR_UNKNOWN,
40         INFO_REDIR_BUSY,
41         INFO_REDIR_NORESPONSE,
42         INFO_REDIR_UNCONDITIONAL,
43         INFO_REDIR_OUTOFORDER,
44         INFO_REDIR_CALLDEFLECT,
45 };
46
47 #define INFO_NOTIFY_NONE                        0x00
48 #define INFO_NOTIFY_USER_SUSPENDED              0x80    
49 #define INFO_NOTIFY_USER_RESUMED                0x81
50 #define INFO_NOTIFY_BEARER_SERVICE_CHANGED      0x82
51 #define INFO_NOTIFY_CALL_COMPLETION_DELAY       0x83
52 #define INFO_NOTIFY_CONFERENCE_ESTABLISHED      0xc2
53 #define INFO_NOTIFY_CONFERENCE_DISCONNECTED     0xc3
54 #define INFO_NOTIFY_OTHER_PARTY_ADDED           0xc4
55 #define INFO_NOTIFY_ISOLATED                    0xc5
56 #define INFO_NOTIFY_REATTACHED                  0xc6
57 #define INFO_NOTIFY_OTHER_PARTY_ISOLATED        0xc7
58 #define INFO_NOTIFY_OTHER_PARTY_REATTACHED      0xc8
59 #define INFO_NOTIFY_OTHER_PARTY_SPLIT           0xc9
60 #define INFO_NOTIFY_OTHER_PARTY_DISCONNECTED    0xca
61 #define INFO_NOTIFY_CONFERENCE_FLOATING         0xcb
62 #define INFO_NOTIFY_CONFERENCE_DISCONNECTED_P   0xcc /* preemted */
63 #define INFO_NOTIFY_CONFERENCE_FLOATING_S_U_P   0xcf /* served user preemted */
64 #define INFO_NOTIFY_CALL_IS_A_WAITING_CALL      0xe0
65 #define INFO_NOTIFY_DIVERSION_ACTIVATED         0xe8
66 #define INFO_NOTIFY_RESERVED_CT_1               0xe9
67 #define INFO_NOTIFY_RESERVED_CT_2               0xea
68 #define INFO_NOTIFY_REVERSE_CHARGING            0xee
69 #define INFO_NOTIFY_REMOTE_HOLD                 0xf9
70 #define INFO_NOTIFY_REMOTE_RETRIEVAL            0xfa
71 #define INFO_NOTIFY_CALL_IS_DIVERTING           0xfb
72
73 enum { /* diversion types */
74         INFO_DIVERSION_CFU,
75         INFO_DIVERSION_CFNR,
76         INFO_DIVERSION_CFB,
77         INFO_DIVERSION_CFP,
78 };
79
80 /* bearer capabilities */
81 #define INFO_BC_SPEECH                                  0x00
82 #define INFO_BC_DATAUNRESTRICTED                        0x08
83 #define INFO_BC_DATARESTRICTED                          0x09
84 #define INFO_BC_AUDIO                                   0x10
85 #define INFO_BC_DATAUNRESTRICTED_TONES                  0x11
86 #define INFO_BC_VIDEO                                   0x18
87
88 /* bearer mode */
89 #define INFO_BMODE_CIRCUIT                              0
90 #define INFO_BMODE_PACKET                               2
91
92 /* bearer user l1 */
93 #define INFO_INFO1_NONE                                 0x00
94 #define INFO_INFO1_V110                                 0x81
95 #define INFO_INFO1_ULAW                                 0x82
96 #define INFO_INFO1_ALAW                                 0x83
97 #define INFO_INFO1_G721                                 0x84
98 #define INFO_INFO1_H221H242                             0x85
99 #define INFO_INFO1_NONCCITT                             0x87
100 #define INFO_INFO1_V120                                 0x88
101 #define INFO_INFO1_X31HDLC                              0x89
102
103 /* hlc */
104 #define INFO_HLC_NONE                                   0x00
105 #define INFO_HLC_TELEPHONY                              0x81
106 #define INFO_HLC_FAXG2G3                                0x84
107 #define INFO_HLC_FAXG4                                  0xa1
108 #define INFO_HLC_TELETEX1                               0xa4
109 #define INFO_HLC_TELETEX2                               0xa8
110 #define INFO_HLC_TELETEX3                               0xb1
111 #define INFO_HLC_VIDEOTEX1                              0xb2
112 #define INFO_HLC_VIDEOTEX2                              0xb3
113 #define INFO_HLC_TELEX                                  0xb5
114 #define INFO_HLC_MHS                                    0xb8
115 #define INFO_HLC_OSI                                    0xc1
116 #define INFO_HLC_MAINTENANCE                            0xde
117 #define INFO_HLC_MANAGEMENT                             0xdf
118 #define INFO_HLC_AUDIOVISUAL                            0xe0
119
120 enum { /* isdnsignal */
121         mISDNSIGNAL_VOLUME,
122         mISDNSIGNAL_CONF,
123         mISDNSIGNAL_NODATA,             /* no data required */
124         mISDNSIGNAL_ECHO,
125 };
126
127 /* call-info structure CALLER */
128 struct caller_info {
129         char id[32];                    /* id of caller (user number) */
130         char voip[64];                  /* URI of voip (or gateway) */
131         char intern[32];                /* internal id */
132         char name[16];
133         int isdn_port;                  /* internal/external port (if call is isdn) */
134         char interface[32];             /* interface name the call was from */
135         int itype;                      /* type of interface */
136         int ntype;                      /* type of number */
137         int present;                    /* presentation */
138         int screen;                     /* who provided the number */
139         char display[84];               /* display information */
140 };
141
142 /* call-info structure DIALING */
143 struct dialing_info {
144         char number[256];               /* number dialing (so far) */
145         char interfaces[128];           /* interfaces for extenal calls */
146         int itype;                      /* type of interface */
147         int ntype;                      /* type of number */
148         int sending_complete;           /* end of dialing */
149 };
150
151 /* call-info structure CONNECT */
152 struct connect_info {
153         char id[32];                    /* id of caller (user number) */
154         char voip[64];                  /* URI of voip (or gateway) */
155         char intern[32];                /* internal id */
156         char name[16];
157         int isdn_port;                  /* internal/external port (if call is isdn) */
158         char interfaces[128];           /* interfaces for extenal calls */
159         int itype;                      /* type of interface */
160         int ntype;                      /* type of number */
161         int present;                    /* presentation */
162         int screen;                     /* who provided the number */
163         char display[84];               /* display information */
164 };
165
166 /* call-info structure DISCONNECT */
167 struct disconnect_info {
168         int cause;                      /* reason for disconnect */
169         int location;                   /* disconnect location */
170         char display[84];               /* optional display information */
171 };
172
173 /* call-info structure REDIR */
174 struct redir_info {
175         char id[32];                    /* id of caller (user number) */
176         char voip[64];                  /* host of voip (or gateway) */
177         char intern[32];                /* internal id */
178         int isdn_port;                  /* internal/external port (if call is isdn) */
179         int itype;                      /* type of interface */
180         int ntype;                      /* type of number */
181         int present;                    /* presentation */
182         int screen;                     /* who provided the number */
183         int reason;                     /* reason for redirecing */
184 };
185
186 /* call-info structure capability */
187 struct capa_info {
188         int bearer_capa;                /* capability */
189         int bearer_mode;                /* circuit/packet */
190         int bearer_info1;               /* alaw,ulaw,... */
191         int hlc;                        /* hlc capability */
192         int exthlc;                     /* extendet hlc */
193 };
194
195 /* call-info structure NOTIFY */
196 struct notify_info {
197         int notify;                     /* notifications (see INFO_NOTIFY_*) */
198         char id[32];                    /* redirection id (user number) */
199         char voip[64];                  /* host of voip (or gateway) */
200         char intern[32];                /* internal id */
201         int isdn_port;                  /* internal/external port (if call is isdn) */
202         int itype;                      /* type of interface */
203         int ntype;                      /* type of number */
204         int present;                    /* redirection presentation */
205         char display[84];               /* display information */
206         int local;                      /* if set, endpoints gets information about audio channel (open/close) */
207 };
208
209 /* call-info structure FACILITY */
210 struct facility_info {
211         char data[256];                 /* data info about facility */
212         int len;                        /* length of facility content */
213 };
214
215 /* call-info structure USERUSER */
216 struct useruser_info {
217         int protocol;
218         int len;
219         unsigned char data[128];        /* user-user info (not a sting!)*/
220 };
221
222 /* call-info structure SETUP */ 
223 struct message_setup {
224         int isdn_port; /* card number 1...n (only on calls from internal isdn port) */
225         int port_type; /* type of port (only required if message is port -> epoint) */
226         int dtmf; /* used to enabled dtmf dialing at setup state */
227         int partyline; /* if set, call will be a conference room */
228         struct caller_info callerinfo;          /* information about the caller */
229         struct dialing_info dialinginfo;        /* information about dialing */
230         struct redir_info redirinfo;            /* info on redirection (to the calling user) */
231         struct capa_info capainfo;              /* info on l2,l3 capability */
232         struct useruser_info useruser;          /* user-user */
233 };
234
235 /* call-info structure PARK */
236 struct park_info {
237         char callid[8];
238         int len;
239 };
240
241 /* DATA */
242 struct param_data {
243         unsigned char data[512]; /* audio/hdlc data */
244         int len; /* audio/hdlc data */
245         int compressed; /* 0 for law-data, 1 for 16-bit data */
246         unsigned long port_id; /* to identify the source of this data */
247         int port_type; /* type of the source's port  */
248 };
249
250 struct param_play {
251         char file[512]; /* file name */
252         int offset; /* offset to start file at (in seconds) */
253 };
254
255 struct param_tone {
256         char dir[128]; /* directory */
257         char name[128]; /* file name */
258 };
259
260 struct param_counter {
261         int current; /* current counter in seconds */
262         int max; /* total size of file (0=no info) */
263 };
264
265 struct param_mISDNsignal {
266         int message;
267         int rxvol;
268         int txvol;
269         int conf;
270         int nodata;
271         int tone;
272         int echo;
273 };
274
275 /* encryption control structure CRYPT */
276 struct param_crypt {
277         int type; /* see messages in crypt.h */
278         int len;
279         unsigned char data[512+32]; /* a block of 512 byte + some overhead */
280 };
281
282 /* structure of message parameter */
283 union parameter {
284         struct param_tone tone; /* MESSAGE_TONE */
285         char dtmf; /* MESSAGE_DTMF */
286         struct message_setup setup; /* MESSAGE_SETUP */
287         struct dialing_info information; /* MESSAGE_INFO */
288         struct connect_info connectinfo; /* CONNECT INFO */
289         struct disconnect_info disconnectinfo; /* DISCONNECT INFO */
290         struct notify_info notifyinfo; /* some notifications */
291         struct facility_info facilityinfo; /* some notifications */
292         struct park_info parkinfo; /* MESSAGE_SUSPEND, MESSAGE_RESUME */
293         int state; /* MESSAGE_TIMEOUT */
294         int knock; /* MESSAGE_KNOCK 0=off !0=on */
295         int channel; /* MESSAGE_CHANNEL see RELATION_CHANNEL_* (call.h) */
296         struct param_data data; /* MESSAGE_DATA */
297         struct param_play play; /* MESSAGE_VBOX_PLAY */
298         int speed; /* MESSAGE_VBOX_PLAY_SPEED */
299         struct param_counter counter; /* MESSAGE_TONE_COUNTER */
300         struct param_mISDNsignal mISDNsignal; /* MESSAGE_mISDNSIGNAL */
301         struct extension ext; /* tell port about extension information */
302         struct param_crypt crypt; /* MESSAGE_CRYPT */
303 };
304
305 enum { /* message flow */
306         PORT_TO_EPOINT,
307         EPOINT_TO_CALL,
308         CALL_TO_EPOINT,
309         EPOINT_TO_PORT,
310 };
311
312 /* message structure */
313 struct message {
314         struct message *next;
315         int type; /* type of message */
316         int flow; /* from where to where */
317         unsigned long id_from; /* in case of flow==PORT_TO_EPOINT: id_from is the port's serial, id_to is the epoint's serial */
318         unsigned long id_to;
319         union parameter param;
320 };
321
322 enum { /* messages between entities */
323         MESSAGE_NONE,           /* no message */
324         MESSAGE_TONE,           /* set information tone (to isdn port) */
325         MESSAGE_DTMF,           /* dtmf digit (from isdn port) */
326         MESSAGE_mISDNSIGNAL,    /* special mixer command (down to isdn port) */
327
328         MESSAGE_SETUP,          /* setup message */
329         MESSAGE_INFORMATION,    /* additional digit information */
330         MESSAGE_OVERLAP,        /* call accepted, send more information */
331         MESSAGE_PROCEEDING,     /* proceeding */
332         MESSAGE_ALERTING,       /* ringing */
333         MESSAGE_CONNECT,        /* connect */
334         MESSAGE_DISCONNECT,     /* disconnect with cause */
335         MESSAGE_RELEASE,        /* release with cause */
336         MESSAGE_TIMEOUT,        /* protocol state has timed out (port->epoint) */
337         MESSAGE_NOTIFY,         /* used to send progress and notify infos */
338         MESSAGE_FACILITY,       /* used to facility infos, like aocd */
339
340         MESSAGE_SUSPEND,        /* suspend port */
341         MESSAGE_RESUME,         /* resume port */
342
343         MESSAGE_CHANNEL,        /* set status of audio path to endpoint (to call, audio is also set) */
344         MESSAGE_REMOTE_AUDIO,   /* tell remote to set audio status */
345         MESSAGE_PATTERN,        /* pattern information tones available */
346         MESSAGE_NOPATTERN,      /* pattern information tones unavailable */
347         MESSAGE_CRYPT,          /* encryption message */
348
349         MESSAGE_DATA,           /* audio/hdlc data */
350
351         MESSAGE_VBOX_PLAY,      /* play recorded file */
352         MESSAGE_VBOX_PLAY_SPEED,/* change speed of file */
353         MESSAGE_VBOX_TONE,      /* set answering VBOX tone */
354         MESSAGE_TONE_COUNTER,   /* tone counter (for VBOX tone use) */
355         MESSAGE_TONE_EOF,       /* tone is end of file */
356         MESSAGE_VBOX_RECORD,    /* tell endpoint to start recording */
357 };
358
359 #define MESSAGES static const char *messages_txt[] = { \
360         "MESSAGE_NONE", \
361         "MESSAGE_TONE", \
362         "MESSAGE_DTMF", \
363         "MESSAGE_mISDNSIGNAL", \
364         "MESSAGE_SETUP", \
365         "MESSAGE_INFORMATION", \
366         "MESSAGE_OVERLAP", \
367         "MESSAGE_PROCEEDING", \
368         "MESSAGE_ALERTING", \
369         "MESSAGE_CONNECT", \
370         "MESSAGE_DISCONNECT", \
371         "MESSAGE_RELEASE", \
372         "MESSAGE_TIMEOUT", \
373         "MESSAGE_NOTIFY", \
374         "MESSAGE_FACILITY", \
375         "MESSAGE_SUSPEND", \
376         "MESSAGE_RESUME", \
377         "MESSAGE_CHANNEL", \
378         "MESSAGE_REMOTE_AUDIO", \
379         "MESSAGE_PATTERN", \
380         "MESSAGE_NOPATTERN", \
381         "MESSAGE_CRYPT", \
382         "MESSAGE_DATA", \
383         "MESSAGE_VBOX_PLAY", \
384         "MESSAGE_VBOX_PLAY_SPEED", \
385         "MESSAGE_VBOX_TONE", \
386         "MESSAGE_TONE_COUNTER", \
387         "MESSAGE_TONE_EOF", \
388         "MESSAGE_VBOX_RECORD", \
389 };
390
391
392 struct message *message_create(int id_from, int id_to, int flow, int type);
393 void message_put(struct message *message);
394 struct message *message_get(void);
395 void message_free(struct message *message);
396
397
398