1 /*****************************************************************************\
3 ** Linux Call Router **
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
8 ** message types and parameters **
10 \*****************************************************************************/
12 enum { /* interface types */
13 INFO_ITYPE_ISDN, /* call from external */
14 INFO_ITYPE_ISDN_EXTENSION, /* call from internal extension */
19 enum { /* number types */
20 INFO_NTYPE_NOTPRESENT = 0,
22 INFO_NTYPE_SUBSCRIBER,
24 INFO_NTYPE_INTERNATIONAL
27 enum { /* number presentation */
28 INFO_PRESENT_NOTAVAIL,
30 INFO_PRESENT_RESTRICTED
33 enum { /* number presentation */
34 INFO_SCREEN_USER, /* user provided */
35 INFO_SCREEN_USER_VERIFIED_PASSED,
36 INFO_SCREEN_USER_VERIFIED_FAILED,
37 INFO_SCREEN_NETWORK /* network provided */
40 enum { /* redirection reason */
41 INFO_REDIR_UNKNOWN = 0,
43 INFO_REDIR_NORESPONSE,
44 INFO_REDIR_UNCONDITIONAL,
45 INFO_REDIR_OUTOFORDER,
46 INFO_REDIR_CALLDEFLECT
49 #define INFO_NOTIFY_NONE 0x00
50 #define INFO_NOTIFY_USER_SUSPENDED 0x80
51 #define INFO_NOTIFY_USER_RESUMED 0x81
52 #define INFO_NOTIFY_BEARER_SERVICE_CHANGED 0x82
53 #define INFO_NOTIFY_CALL_COMPLETION_DELAY 0x83
54 #define INFO_NOTIFY_CONFERENCE_ESTABLISHED 0xc2
55 #define INFO_NOTIFY_CONFERENCE_DISCONNECTED 0xc3
56 #define INFO_NOTIFY_OTHER_PARTY_ADDED 0xc4
57 #define INFO_NOTIFY_ISOLATED 0xc5
58 #define INFO_NOTIFY_REATTACHED 0xc6
59 #define INFO_NOTIFY_OTHER_PARTY_ISOLATED 0xc7
60 #define INFO_NOTIFY_OTHER_PARTY_REATTACHED 0xc8
61 #define INFO_NOTIFY_OTHER_PARTY_SPLIT 0xc9
62 #define INFO_NOTIFY_OTHER_PARTY_DISCONNECTED 0xca
63 #define INFO_NOTIFY_CONFERENCE_FLOATING 0xcb
64 #define INFO_NOTIFY_CONFERENCE_DISCONNECTED_P 0xcc /* preemted */
65 #define INFO_NOTIFY_CONFERENCE_FLOATING_S_U_P 0xcf /* served user preemted */
66 #define INFO_NOTIFY_CALL_IS_A_WAITING_CALL 0xe0
67 #define INFO_NOTIFY_DIVERSION_ACTIVATED 0xe8
68 #define INFO_NOTIFY_RESERVED_CT_1 0xe9
69 #define INFO_NOTIFY_RESERVED_CT_2 0xea
70 #define INFO_NOTIFY_REVERSE_CHARGING 0xee
71 #define INFO_NOTIFY_REMOTE_HOLD 0xf9
72 #define INFO_NOTIFY_REMOTE_RETRIEVAL 0xfa
73 #define INFO_NOTIFY_CALL_IS_DIVERTING 0xfb
75 enum { /* diversion types */
82 /* bearer capabilities */
83 #define INFO_BC_SPEECH 0x00
84 #define INFO_BC_DATAUNRESTRICTED 0x08
85 #define INFO_BC_DATARESTRICTED 0x09
86 #define INFO_BC_AUDIO 0x10
87 #define INFO_BC_DATAUNRESTRICTED_TONES 0x11
88 #define INFO_BC_VIDEO 0x18
91 #define INFO_BMODE_CIRCUIT 0
92 #define INFO_BMODE_PACKET 2
95 #define INFO_INFO1_NONE 0x00
96 #define INFO_INFO1_V110 0x81
97 #define INFO_INFO1_ULAW 0x82
98 #define INFO_INFO1_ALAW 0x83
99 #define INFO_INFO1_G721 0x84
100 #define INFO_INFO1_H221H242 0x85
101 #define INFO_INFO1_NONCCITT 0x87
102 #define INFO_INFO1_V120 0x88
103 #define INFO_INFO1_X31HDLC 0x89
106 #define INFO_HLC_NONE 0x00
107 #define INFO_HLC_TELEPHONY 0x81
108 #define INFO_HLC_FAXG2G3 0x84
109 #define INFO_HLC_FAXG4 0xa1
110 #define INFO_HLC_TELETEX1 0xa4
111 #define INFO_HLC_TELETEX2 0xa8
112 #define INFO_HLC_TELETEX3 0xb1
113 #define INFO_HLC_VIDEOTEX1 0xb2
114 #define INFO_HLC_VIDEOTEX2 0xb3
115 #define INFO_HLC_TELEX 0xb5
116 #define INFO_HLC_MHS 0xb8
117 #define INFO_HLC_OSI 0xc1
118 #define INFO_HLC_MAINTENANCE 0xde
119 #define INFO_HLC_MANAGEMENT 0xdf
120 #define INFO_HLC_AUDIOVISUAL 0xe0
122 enum { /* isdnsignal */
123 mISDNSIGNAL_VOLUME, /* change volume */
124 mISDNSIGNAL_CONF, /* joint/split conference */
125 mISDNSIGNAL_ECHO, /* enable/disable echoe */
126 mISDNSIGNAL_DELAY, /* use delay or adaptive jitter */
130 B_STATE_IDLE, /* not open */
131 B_STATE_ACTIVATING, /* DL_ESTABLISH sent */
132 B_STATE_ACTIVE, /* channel active */
133 B_STATE_DEACTIVATING, /* DL_RELEASE sent */
137 B_MODE_TRANSPARENT, /* normal transparent audio */
138 B_MODE_HDLC, /* hdlc data mode */
150 /* rtp-info structure */
152 int payloads; /* number of payloads offered */
153 unsigned char payload_types[32];/* rtp payload types */
154 int media_types[32]; /* media type of given payload */
155 unsigned int ip; /* peer's IP */
156 unsigned short port; /* peer's port */
159 /* call-info structure CALLER */
161 char id[32]; /* id of caller (user number) */
162 char extension[32]; /* internal id */
164 int isdn_port; /* internal/external port (if call is isdn) */
165 char interface[32]; /* interface name the call was from */
166 int itype; /* type of interface */
167 int ntype; /* type of number */
168 int present; /* presentation */
169 int screen; /* who provided the number */
170 char display[84]; /* display information */
171 char id2[32]; /* second callerid */
172 int ntype2; /* second type of number */
173 int present2; /* second presentation */
174 int screen2; /* second who provided the number */
175 char imsi[16]; /* IMSI for gsm originated calls */
178 /* call-info structure DIALING */
179 struct dialing_info {
180 char id[256]; /* number dialing (so far) */
181 char interfaces[128]; /* interfaces for extenal calls */
182 int itype; /* type of interface */
183 int ntype; /* type of number */
184 int sending_complete; /* end of dialing */
185 char display[84]; /* display information */
186 char keypad[33]; /* send keypad facility */
187 char context[32]; /* asterisk context */
190 /* call-info structure CONNECT */
191 struct connect_info {
192 char id[32]; /* id of caller (user number) */
193 char extension[32]; /* internal id */
195 int isdn_port; /* internal/external port (if call is isdn) */
196 char interface[128]; /* interface for extenal calls */
197 int itype; /* type of interface */
198 int ntype; /* type of number */
199 int present; /* presentation */
200 int screen; /* who provided the number */
201 char display[84]; /* display information */
202 char imsi[16]; /* IMSI for gsm terminated calls */
203 struct rtp_info rtpinfo; /* info about RTP peer */
206 /* call-info structure DISCONNECT */
207 struct disconnect_info {
208 int cause; /* reason for disconnect */
209 int location; /* disconnect location */
210 char display[84]; /* optional display information */
211 int force; /* special flag to release imediately */
214 /* call-info structure REDIR */
216 char id[32]; /* id of caller (user number) */
217 char extension[32]; /* internal id */
218 int isdn_port; /* internal/external port (if call is isdn) */
219 int itype; /* type of interface */
220 int ntype; /* type of number */
221 int present; /* presentation */
222 int screen; /* who provided the number */
223 int reason; /* reason for redirecing */
226 /* call-info structure capability */
228 int source_mode; /* forward mode */
229 int bearer_capa; /* capability */
230 int bearer_mode; /* circuit/packet */
231 int bearer_info1; /* alaw,ulaw,... */
232 int hlc; /* hlc capability */
233 int exthlc; /* extendet hlc */
236 /* call-info structure NOTIFY */
238 int notify; /* notifications (see INFO_NOTIFY_*) */
239 char id[32]; /* redirection id (user number) */
240 char extension[32]; /* internal id */
241 int isdn_port; /* internal/external port (if call is isdn) */
242 int itype; /* type of interface */
243 int ntype; /* type of number */
244 int present; /* redirection presentation */
245 char display[84]; /* display information */
246 int local; /* if set, endpoints gets information about audio channel (open/close) */
249 /* call-info structure PROGRESS */
250 struct progress_info {
251 int progress; /* progress indicator */
252 int location; /* progress location */
253 struct rtp_info rtpinfo; /* info about RTP peer */
256 /* call-info structure FACILITY */
257 struct facility_info {
258 char data[256]; /* data info about facility */
259 int len; /* length of facility content */
262 /* call-info structure USERUSER */
263 struct useruser_info {
266 unsigned char data[128]; /* user-user info (not a sting!)*/
269 /* call-info structure SETUP */
270 struct message_setup {
271 int isdn_port; /* card number 1...n (only on calls from isdn port) */
272 int port_type; /* type of port (only required if message is port -> epoint) */
273 int partyline; /* if set, call will be a conference room */
274 int partyline_jingle; /* if set, the jingle will be played on conference join */
275 struct caller_info callerinfo; /* information about the caller */
276 struct dialing_info dialinginfo; /* information about dialing */
277 struct redir_info redirinfo; /* info on redirection (to the calling user) */
278 struct capa_info capainfo; /* info on l2,l3 capability */
279 struct useruser_info useruser; /* user-user */
280 struct progress_info progress; /* info on call progress */
281 struct rtp_info rtpinfo; /* info about RTP peer */
284 /* call-info structure PARK */
291 char file[512]; /* file name */
292 int offset; /* offset to start file at (in seconds) */
296 char dir[128]; /* directory */
297 char name[128]; /* file name */
300 struct param_counter {
301 int current; /* current counter in seconds */
302 int max; /* total size of file (0=no info) */
305 struct param_mISDNsignal {
315 /* encryption control structure CRYPT */
317 int type; /* see messages in crypt.h */
319 unsigned char data[512+32]; /* a block of 512 byte + some overhead */
323 char application[32]; /* name of remote application */
326 struct param_bchannel {
327 int type; /* BCHANNEL_* */
328 unsigned int handle; /* bchannel stack/portid */
329 int isloopback; /* in this case the application behaves like an interface, dsp should not be used */
330 int tx_gain, rx_gain;
332 unsigned char crypt[128];
334 int crypt_type; /* 1 = blowfish */
337 struct param_newref {
338 int direction; /* who requests a refe? */
339 char interface[32]; /* interface name for selecting remote interface */
342 struct param_traffic {
343 int len; /* how much data */
344 unsigned char data[160]; /* 20ms */
349 int invoke, result, error;
350 unsigned char invoke_id;
353 /* structure of message parameter */
355 struct param_tone tone; /* MESSAGE_TONE */
356 char dtmf; /* MESSAGE_DTMF */
357 struct message_setup setup; /* MESSAGE_SETUP */
358 struct dialing_info information; /* MESSAGE_INFO */
359 struct connect_info connectinfo; /* CONNECT INFO */
360 struct disconnect_info disconnectinfo; /* DISCONNECT INFO */
361 struct notify_info notifyinfo; /* some notifications */
362 struct progress_info progressinfo; /* some progress */
363 struct facility_info facilityinfo; /* some notifications */
364 struct park_info parkinfo; /* MESSAGE_SUSPEND, MESSAGE_RESUME */
365 int state; /* MESSAGE_TIMEOUT */
366 int knock; /* MESSAGE_KNOCK 0=off !0=on */
367 int audiopath; /* MESSAGE_audiopath see RELATION_CHANNEL_* (join.h) */
368 struct param_play play; /* MESSAGE_VBOX_PLAY */
369 int speed; /* MESSAGE_VBOX_PLAY_SPEED */
370 struct param_counter counter; /* MESSAGE_TONE_COUNTER */
371 struct param_mISDNsignal mISDNsignal; /* MESSAGE_mISDNSIGNAL */
372 struct extension ext; /* tell port about extension information */
373 struct param_crypt crypt; /* MESSAGE_CRYPT */
374 struct param_hello hello; /* MESSAGE_HELLO */
375 struct param_bchannel bchannel; /* MESSAGE_BCHANNEL */
376 struct param_newref newref; /* MESSAGE_NEWREF */
377 unsigned int bridge_id; /* MESSAGE_BRIDGE */
378 struct param_traffic traffic; /* MESSAGE_TRAFFIC */
379 struct param_3pty threepty; /* MESSAGE_TRAFFIC */
380 unsigned int queue; /* MESSAGE_DISABLE_DEJITTER */
383 enum { /* message flow */
390 /* message structure */
392 struct lcr_msg *next;
393 int type; /* type of message */
394 int flow; /* from where to where */
395 unsigned int id_from; /* in case of flow==PORT_TO_EPOINT: id_from is the port's serial, id_to is the epoint's serial */
398 union parameter param;
401 enum { /* messages between entities */
402 MESSAGE_NONE, /* no message */
403 MESSAGE_TONE, /* set information tone (to isdn port) */
404 MESSAGE_DTMF, /* dtmf digit (from isdn port) */
405 MESSAGE_ENABLEKEYPAD, /* remote application requests keypad/dtmf */
406 MESSAGE_mISDNSIGNAL, /* special mixer command (down to isdn port) */
407 MESSAGE_SETUP, /* setup message */
408 MESSAGE_INFORMATION, /* additional digit information */
409 MESSAGE_OVERLAP, /* call accepted, send more information */
410 MESSAGE_PROCEEDING, /* proceeding */
411 MESSAGE_ALERTING, /* ringing */
412 MESSAGE_CONNECT, /* connect */
413 MESSAGE_DISCONNECT, /* disconnect with cause */
414 MESSAGE_RELEASE, /* release with cause */
415 MESSAGE_TIMEOUT, /* protocol state has timed out (port->epoint) */
416 MESSAGE_NOTIFY, /* used to send notify info */
417 MESSAGE_PROGRESS, /* used to send progress info */
418 MESSAGE_FACILITY, /* used to facility infos, like aocd */
419 MESSAGE_SUSPEND, /* suspend port */
420 MESSAGE_RESUME, /* resume port */
421 MESSAGE_AUDIOPATH, /* set status of audio path to endpoint (to call, audio is also set) */
422 MESSAGE_PATTERN, /* pattern information tones available */
423 MESSAGE_NOPATTERN, /* pattern information tones unavailable */
424 MESSAGE_CRYPT, /* encryption message */
425 MESSAGE_VBOX_PLAY, /* play recorded file */
426 MESSAGE_VBOX_PLAY_SPEED,/* change speed of file */
427 MESSAGE_VBOX_TONE, /* set answering VBOX tone */
428 MESSAGE_TONE_COUNTER, /* tone counter (for VBOX tone use) */
429 MESSAGE_TONE_EOF, /* tone is end of file */
430 MESSAGE_BCHANNEL, /* request/assign/remove bchannel */
431 MESSAGE_HELLO, /* hello message for remote application */
432 MESSAGE_NEWREF, /* special message to create and inform ref */
433 MESSAGE_BRIDGE, /* control port bridge */
434 MESSAGE_TRAFFIC, /* exchange bchannel traffic */
435 MESSAGE_3PTY, /* 3PTY call invoke */
436 MESSAGE_DISABLE_DEJITTER/* tell (mISDN) port not to dejitter */
439 #define MESSAGES static const char *messages_txt[] = { \
443 "MESSAGE_ENABLEKEYPAD", \
444 "MESSAGE_mISDNSIGNAL", \
446 "MESSAGE_INFORMATION", \
448 "MESSAGE_PROCEEDING", \
449 "MESSAGE_ALERTING", \
451 "MESSAGE_DISCONNECT", \
455 "MESSAGE_PROGRESS", \
456 "MESSAGE_FACILITY", \
459 "MESSAGE_AUDIOPATH", \
461 "MESSAGE_NOPATTERN", \
463 "MESSAGE_VBOX_PLAY", \
464 "MESSAGE_VBOX_PLAY_SPEED", \
465 "MESSAGE_VBOX_TONE", \
466 "MESSAGE_TONE_COUNTER", \
467 "MESSAGE_TONE_EOF", \
468 "MESSAGE_BCHANNEL", \
474 "MESSAGE_DISABLE_DEJITTER", \
478 struct lcr_msg *message_create(int id_from, int id_to, int flow, int type);
479 #define message_put(m) _message_put(m, __FILE__, __LINE__)
480 void _message_put(struct lcr_msg *message, const char *file, int line);
481 struct lcr_msg *message_forward(int id_from, int id_to, int flow, union parameter *param);
482 struct lcr_msg *message_get(void);
483 void message_free(struct lcr_msg *message);
484 void init_message(void);
485 void cleanup_message(void);