1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
8 ** all actions (and hangup) are processed here **
10 \*****************************************************************************/
14 extern char **environ;
18 * process init 'internal' / 'external' / 'vbox-record' / 'partyline'...
20 void EndpointAppPBX::action_init_call(void)
24 /* a created call, this should never happen */
25 if (ea_endpoint->ep_join_id) {
26 if (options.deb & DEBUG_EPOINT)
27 PERROR("EPOINT(%d): We already have a call instance, this should never happen!\n", ea_endpoint->ep_serial);
32 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): Creating new join instance.\n", ea_endpoint->ep_serial);
33 join = new JoinPBX(ea_endpoint);
35 FATAL("No memoy for Join instance.\n");
36 ea_endpoint->ep_join_id = join->j_serial;
41 * process dialing 'internal'
43 void EndpointAppPBX::action_dialing_internal(void)
45 struct capa_info capainfo;
46 struct caller_info callerinfo;
47 struct redir_info redirinfo;
48 struct rtp_info rtpinfo;
49 struct dialing_info dialinginfo;
50 struct port_list *portlist = ea_endpoint->ep_portlist;
51 struct lcr_msg *message;
53 struct route_param *rparam;
55 /* send proceeding, because number is complete */
56 set_tone(portlist, "proceeding");
57 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_PROCEEDING);
59 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
60 new_state(EPOINT_STATE_IN_PROCEEDING);
62 /* create bearer/caller/dialinginfo */
63 memcpy(&capainfo, &e_capainfo, sizeof(capainfo));
64 memcpy(&callerinfo, &e_callerinfo, sizeof(callerinfo));
65 memcpy(&redirinfo, &e_redirinfo, sizeof(redirinfo));
66 memcpy(&rtpinfo, &e_rtpinfo, sizeof(rtpinfo));
67 memset(&dialinginfo, 0, sizeof(dialinginfo));
68 dialinginfo.itype = INFO_ITYPE_ISDN_EXTENSION;
69 SCPY(dialinginfo.id, e_dialinginfo.id);
71 /* process extension */
72 if ((rparam = routeparam(e_action, PARAM_EXTENSION)))
73 SCPY(dialinginfo.id, rparam->string_value);
75 /* process number type */
76 if ((rparam = routeparam(e_action, PARAM_TYPE)))
77 dialinginfo.ntype = rparam->integer_value;
80 if ((rparam = routeparam(e_action, PARAM_CAPA))) {
81 capainfo.bearer_capa = rparam->integer_value;
82 if (capainfo.bearer_capa != INFO_BC_SPEECH
83 && capainfo.bearer_capa != INFO_BC_AUDIO) {
84 capainfo.bearer_mode = INFO_BMODE_PACKET;
86 capainfo.bearer_info1 = INFO_INFO1_NONE;
87 capainfo.hlc = INFO_HLC_NONE;
88 capainfo.exthlc = INFO_HLC_NONE;
90 if ((rparam = routeparam(e_action, PARAM_BMODE))) {
91 capainfo.bearer_mode = rparam->integer_value;
93 if ((rparam = routeparam(e_action, PARAM_INFO1))) {
94 capainfo.bearer_info1 = rparam->integer_value;
96 if ((rparam = routeparam(e_action, PARAM_HLC))) {
97 capainfo.hlc = rparam->integer_value;
99 if ((rparam = routeparam(e_action, PARAM_EXTHLC))) {
100 capainfo.exthlc = rparam->integer_value;
103 /* process presentation */
104 if ((rparam = routeparam(e_action, PARAM_PRESENT))) {
105 callerinfo.present = (rparam->integer_value)?INFO_PRESENT_ALLOWED:INFO_PRESENT_RESTRICTED;
108 /* check if extension exists AND only if not multiple extensions */
109 if (!strchr(dialinginfo.id,',') && !read_extension(&ext, dialinginfo.id)) {
110 trace_header("ACTION extension (extension doesn't exist)", DIRECTION_NONE);
111 add_trace("extension", NULL, dialinginfo.id);
113 release(RELEASE_JOIN, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, 0, 0, 0);
114 new_state(EPOINT_STATE_OUT_DISCONNECT);
115 message_disconnect_port(portlist, CAUSE_UNALLOCATED, LOCATION_PRIVATE_LOCAL, "");
116 set_tone(portlist, "cause_86");
119 /* check if internal calls are denied */
120 if (e_ext.rights < 1) {
121 trace_header("ACTION extension (dialing to extension denied)", DIRECTION_NONE);
122 add_trace("extension", NULL, dialinginfo.id);
124 new_state(EPOINT_STATE_OUT_DISCONNECT);
125 release(RELEASE_JOIN, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, 0, 0, 0);
126 message_disconnect_port(portlist, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, "");
127 set_tone(portlist, "cause_81");
131 /* add or update internal call */
132 trace_header("ACTION extension (calling)", DIRECTION_NONE);
133 add_trace("extension", NULL, dialinginfo.id);
135 message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_SETUP);
136 memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info));
137 memcpy(&message->param.setup.redirinfo, &redirinfo, sizeof(struct redir_info));
138 memcpy(&message->param.setup.callerinfo, &callerinfo, sizeof(struct caller_info));
139 memcpy(&message->param.setup.capainfo, &capainfo, sizeof(struct capa_info));
140 memcpy(&message->param.setup.rtpinfo, &rtpinfo, sizeof(struct rtp_info));
141 message_put(message);
144 /* process dialing external
146 void EndpointAppPBX::action_dialing_external(void)
148 struct capa_info capainfo;
149 struct caller_info callerinfo;
150 struct redir_info redirinfo;
151 struct rtp_info rtpinfo;
152 struct dialing_info dialinginfo;
154 struct port_list *portlist = ea_endpoint->ep_portlist;
155 struct lcr_msg *message;
156 struct route_param *rparam;
158 /* special processing of delete characters '*' and '#' */
159 if (e_ext.delete_ext) {
160 /* dialing a # causes a clearing of complete number */
161 if (strchr(e_extdialing, '#')) {
162 e_extdialing[0] = '\0';
163 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): '#' detected: terminal '%s' selected caller id '%s' and continues dialing: '%s'\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, e_extdialing);
165 /* eliminate digits before '*', which is a delete digit
167 if (strchr(e_extdialing, '*')) {
169 while((p=strchr(e_extdialing, '*'))) {
170 if (p > e_extdialing) { /* only if there is a digit in front */
174 UCPY(p, p+1); /* remove '*' */
176 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s deleted digits and got new string: %s\n", ea_endpoint->ep_serial, e_ext.number, e_extdialing);
180 /* create bearer/caller/dialinginfo */
181 memcpy(&capainfo, &e_capainfo, sizeof(capainfo));
182 memcpy(&callerinfo, &e_callerinfo, sizeof(callerinfo));
183 memcpy(&redirinfo, &e_redirinfo, sizeof(redirinfo));
184 memcpy(&rtpinfo, &e_rtpinfo, sizeof(rtpinfo));
185 memset(&dialinginfo, 0, sizeof(dialinginfo));
186 dialinginfo.itype = INFO_ITYPE_ISDN;
187 // dialinginfo.sending_complete = 0;
188 SCPY(dialinginfo.id, e_extdialing);
191 if ((rparam = routeparam(e_action, PARAM_PREFIX)))
192 SPRINT(dialinginfo.id, "%s%s", rparam->string_value, e_extdialing);
194 if ((rparam = routeparam(e_action, PARAM_CONTEXT)))
195 SCPY(dialinginfo.context, rparam->string_value);
198 if ((rparam = routeparam(e_action, PARAM_KEYPAD))) {
199 SCPY(dialinginfo.keypad, dialinginfo.id);
200 dialinginfo.id[0] = '\0';
203 /* process number complete */
204 if ((rparam = routeparam(e_action, PARAM_COMPLETE)))
205 dialinginfo.sending_complete = 1;
207 /* process number type */
208 if ((rparam = routeparam(e_action, PARAM_TYPE)))
209 dialinginfo.ntype = rparam->integer_value;
211 /* process service */
212 if ((rparam = routeparam(e_action, PARAM_CAPA))) {
213 capainfo.bearer_capa = rparam->integer_value;
214 if (capainfo.bearer_capa != INFO_BC_SPEECH
215 && capainfo.bearer_capa != INFO_BC_AUDIO) {
216 capainfo.bearer_mode = INFO_BMODE_PACKET;
218 capainfo.bearer_info1 = INFO_INFO1_NONE;
219 capainfo.hlc = INFO_HLC_NONE;
220 capainfo.exthlc = INFO_HLC_NONE;
222 if ((rparam = routeparam(e_action, PARAM_BMODE))) {
223 capainfo.bearer_mode = rparam->integer_value;
225 if ((rparam = routeparam(e_action, PARAM_INFO1))) {
226 capainfo.bearer_info1 = rparam->integer_value;
228 if ((rparam = routeparam(e_action, PARAM_HLC))) {
229 capainfo.hlc = rparam->integer_value;
231 if ((rparam = routeparam(e_action, PARAM_EXTHLC))) {
232 capainfo.exthlc = rparam->integer_value;
236 /* process callerid */
237 if ((rparam = routeparam(e_action, PARAM_CALLERID))) {
238 SCPY(callerinfo.id, rparam->string_value);
240 if ((rparam = routeparam(e_action, PARAM_CALLERIDTYPE))) {
241 callerinfo.ntype = rparam->integer_value;
244 /* process presentation */
245 if ((rparam = routeparam(e_action, PARAM_PRESENT))) {
246 callerinfo.present = (rparam->integer_value)?INFO_PRESENT_ALLOWED:INFO_PRESENT_RESTRICTED;
249 /* process interfaces */
250 if ((rparam = routeparam(e_action, PARAM_INTERFACES)))
251 SCPY(dialinginfo.interfaces, rparam->string_value);
253 /* check if local calls are denied */
254 if (e_ext.rights < 2) {
255 trace_header("ACTION extern (calling denied)", DIRECTION_NONE);
257 release(RELEASE_JOIN, LOCATION_PRIVATE_LOCAL, CAUSE_REJECTED, 0, 0, 0);
258 set_tone(portlist, "cause_82");
260 message_disconnect_port(portlist, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, "");
261 new_state(EPOINT_STATE_OUT_DISCONNECT);
265 if (!strncmp(dialinginfo.id, options.national, strlen(options.national))
266 || dialinginfo.ntype == INFO_NTYPE_NATIONAL
267 || dialinginfo.ntype == INFO_NTYPE_INTERNATIONAL) {
268 /* check if national calls are denied */
269 if (e_ext.rights < 3) {
270 trace_header("ACTION extern (national calls denied)", DIRECTION_NONE);
272 release(RELEASE_JOIN, LOCATION_PRIVATE_LOCAL, CAUSE_REJECTED, 0, 0, 0);
273 set_tone(portlist, "cause_83");
278 if (!strncmp(dialinginfo.id, options.international, strlen(options.international))
279 || dialinginfo.ntype == INFO_NTYPE_INTERNATIONAL) {
280 /* check if international calls are denied */
281 if (e_ext.rights < 4) {
282 trace_header("ACTION extern (international calls denied)", DIRECTION_NONE);
284 release(RELEASE_JOIN, LOCATION_PRIVATE_LOCAL, CAUSE_REJECTED, 0, 0, 0);
285 set_tone(portlist, "cause_84");
290 /* add or update outgoing call */
291 trace_header("ACTION extern (calling)", DIRECTION_NONE);
292 add_trace("number", NULL, dialinginfo.id);
293 if (dialinginfo.sending_complete)
294 add_trace("number", "complete", "yes");
295 if (dialinginfo.interfaces[0])
296 add_trace("interfaces", NULL, dialinginfo.interfaces);
298 message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_SETUP);
299 memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info));
300 memcpy(&message->param.setup.redirinfo, &redirinfo, sizeof(struct redir_info));
301 memcpy(&message->param.setup.callerinfo, &callerinfo, sizeof(struct caller_info));
302 memcpy(&message->param.setup.capainfo, &capainfo, sizeof(struct capa_info));
303 memcpy(&message->param.setup.rtpinfo, &rtpinfo, sizeof(struct rtp_info));
304 message_put(message);
309 * process dialing the "am" and record
311 void EndpointAppPBX::action_dialing_vbox_record(void)
313 struct dialing_info dialinginfo;
314 struct port_list *portlist = ea_endpoint->ep_portlist;
315 struct lcr_msg *message;
316 struct extension ext;
317 struct route_param *rparam;
319 portlist = ea_endpoint->ep_portlist;
321 /* check for given extension */
322 if (!(rparam = routeparam(e_action, PARAM_EXTENSION))) {
323 trace_header("ACTION vbox-record (no extension given by parameter)", DIRECTION_NONE);
326 new_state(EPOINT_STATE_OUT_DISCONNECT);
327 message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, "");
328 set_tone(portlist, "cause_3f");
332 /* check if extension exists */
333 if (!read_extension(&ext, rparam->string_value)) {
334 trace_header("ACTION vbox-record (given extension does not exists)", DIRECTION_NONE);
335 add_trace("extension", NULL, "%s", rparam->string_value);
337 new_state(EPOINT_STATE_OUT_DISCONNECT);
338 message_disconnect_port(portlist, CAUSE_UNALLOCATED, LOCATION_PRIVATE_LOCAL, "");
339 set_tone(portlist, "cause_86");
343 /* check if internal calls are denied */
344 if (e_ext.rights < 1) {
345 trace_header("ACTION vbox-record (internal calls are denied)", DIRECTION_NONE);
347 new_state(EPOINT_STATE_OUT_DISCONNECT);
348 message_disconnect_port(portlist, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, "");
349 set_tone(portlist, "cause_81");
353 set_tone(portlist, "proceeding");
354 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_PROCEEDING);
355 message_put(message);
356 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
357 new_state(EPOINT_STATE_IN_PROCEEDING);
359 memset(&dialinginfo, 0, sizeof(dialinginfo));
360 dialinginfo.itype = INFO_ITYPE_VBOX;
361 dialinginfo.sending_complete = 1;
362 SCPY(dialinginfo.id, rparam->string_value);
364 /* append special announcement (if given) */
365 if ((rparam = routeparam(e_action, PARAM_ANNOUNCEMENT)))
366 if (rparam->string_value[0]) {
367 SCAT(dialinginfo.id, ",");
368 SCAT(dialinginfo.id, rparam->string_value);
371 /* add or update internal call */
372 trace_header("ACTION vbox-record (calling)", DIRECTION_NONE);
373 add_trace("extension", NULL, "%s", dialinginfo.id);
375 message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_SETUP);
376 memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info));
377 memcpy(&message->param.setup.redirinfo, &e_redirinfo, sizeof(struct redir_info));
378 memcpy(&message->param.setup.callerinfo, &e_callerinfo, sizeof(struct caller_info));
379 memcpy(&message->param.setup.capainfo, &e_capainfo, sizeof(struct capa_info));
380 message_put(message);
387 void EndpointAppPBX::action_init_partyline(void)
390 class JoinPBX *joinpbx;
391 struct port_list *portlist = ea_endpoint->ep_portlist;
392 struct lcr_msg *message;
393 struct route_param *rparam;
394 int partyline, jingle = 0;
395 struct join_relation *relation;
397 portlist = ea_endpoint->ep_portlist;
399 /* check for given extension */
400 if (!(rparam = routeparam(e_action, PARAM_ROOM))) {
401 trace_header("ACTION partyline (no room parameter)", DIRECTION_NONE);
404 new_state(EPOINT_STATE_OUT_DISCONNECT);
405 message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, "");
406 set_tone(portlist, "cause_3f");
409 if (rparam->integer_value <= 0) {
410 trace_header("ACTION partyline (illegal room parameter)", DIRECTION_NONE);
411 add_trace("room", NULL, "%d", rparam->integer_value);
413 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): invalid value for 'room'.\n", ea_endpoint->ep_serial);
416 partyline = rparam->integer_value;
417 if ((rparam = routeparam(e_action, PARAM_JINGLE)))
420 /* don't create join if partyline exists */
423 if (join->j_type == JOIN_TYPE_PBX) {
424 joinpbx = (class JoinPBX *)join;
425 if (joinpbx->j_partyline == partyline)
432 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): Creating new join instance.\n", ea_endpoint->ep_serial);
433 if (!(join = new JoinPBX(ea_endpoint)))
434 FATAL("No memory for join object\n");
436 //NOTE: joinpbx must be set here
437 /* add relation to existing join */
438 if (!(relation=joinpbx->add_relation()))
439 FATAL("No memory for join relation\n");
440 relation->type = RELATION_TYPE_SETUP;
441 relation->channel_state = 1;
442 relation->rx_state = NOTIFY_STATE_ACTIVE;
443 relation->tx_state = NOTIFY_STATE_ACTIVE;
444 relation->epoint_id = ea_endpoint->ep_serial;
447 ea_endpoint->ep_join_id = join->j_serial;
449 set_tone(portlist, "proceeding");
450 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_PROCEEDING);
451 message_put(message);
452 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
453 new_state(EPOINT_STATE_IN_PROCEEDING);
455 /* send setup to join */
456 trace_header("ACTION partyline (calling)", DIRECTION_NONE);
457 add_trace("room", NULL, "%d", partyline);
458 add_trace("jingle", NULL, (jingle)?"on":"off");
460 message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_SETUP);
461 message->param.setup.partyline = partyline;
462 message->param.setup.partyline_jingle = jingle;
463 memcpy(&message->param.setup.dialinginfo, &e_dialinginfo, sizeof(struct dialing_info));
464 memcpy(&message->param.setup.redirinfo, &e_redirinfo, sizeof(struct redir_info));
465 memcpy(&message->param.setup.callerinfo, &e_callerinfo, sizeof(struct caller_info));
466 memcpy(&message->param.setup.capainfo, &e_capainfo, sizeof(struct capa_info));
467 message_put(message);
472 * process hangup of all calls
474 void EndpointAppPBX::action_hangup_call(void)
476 trace_header("ACTION hangup", DIRECTION_NONE);
482 * process dialing 'login'
484 void EndpointAppPBX::action_dialing_login(void)
486 struct port_list *portlist = ea_endpoint->ep_portlist;
487 struct lcr_msg *message;
489 struct route_param *rparam;
491 /* extension parameter */
492 if ((rparam = routeparam(e_action, PARAM_EXTENSION))) {
493 /* extension is given by parameter */
494 extension = rparam->string_value;
495 if (extension[0] == '\0')
497 if (!read_extension(&e_ext, extension)) {
498 trace_header("ACTION login (extension doesn't exist)", DIRECTION_NONE);
499 add_trace("extension", NULL, "%s", extension);
501 /* extension doesn't exist */
502 new_state(EPOINT_STATE_OUT_DISCONNECT);
503 message_disconnect_port(portlist, CAUSE_UNALLOCATED, LOCATION_PRIVATE_LOCAL, "");
504 set_tone(portlist, "cause_86");
508 /* extension must be given by dialstring */
509 extension = e_extdialing;
510 if (extension[0] == '\0')
512 if (!read_extension(&e_ext, extension)) {
513 trace_header("ACTION login (extension incomplete or does not exist)", DIRECTION_NONE);
514 add_trace("extension", NULL, "%s", extension);
520 /* we changed our extension */
521 SCPY(e_ext.number, extension);
522 new_state(EPOINT_STATE_CONNECT);
526 /* send connect with extension's caller id (COLP) */
527 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT);
528 SCPY(message->param.connectinfo.id, e_ext.callerid);
529 message->param.connectinfo.ntype = e_ext.callerid_type;
530 if (e_ext.callerid_present==INFO_PRESENT_ALLOWED && e_callerinfo.present==INFO_PRESENT_RESTRICTED)
531 message->param.connectinfo.present = INFO_PRESENT_RESTRICTED;
532 else message->param.connectinfo.present = e_ext.callerid_present;
533 /* handle restricted caller ids */
534 apply_callerid_restriction(&e_ext, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name);
535 /* display callerid if desired for extension */
536 SCPY(message->param.connectinfo.display, apply_callerid_display(message->param.connectinfo.id, message->param.connectinfo.itype, message->param.connectinfo.ntype, message->param.connectinfo.present, message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name));
537 message->param.connectinfo.ntype = e_ext.callerid_type;
538 message_put(message);
539 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
541 /* set our caller id */
542 SCPY(e_callerinfo.id, e_ext.callerid);
543 e_callerinfo.ntype = e_ext.callerid_type;
544 e_callerinfo.present = e_ext.callerid_present;
546 /* enable connectedmode */
550 if (!(rparam = routeparam(e_action, PARAM_NOPASSWORD))) {
551 /* make call state to enter password */
552 trace_header("ACTION login (ask for password)", DIRECTION_NONE);
553 add_trace("extension", NULL, "%s", e_ext.number);
555 new_state(EPOINT_STATE_IN_OVERLAP);
558 e_action = &action_password;
559 unsched_timer(&e_match_timeout);
560 e_match_to_action = NULL;
561 e_dialinginfo.id[0] = '\0';
562 e_extdialing = strchr(e_dialinginfo.id, '\0');
565 schedule_timer(&e_password_timeout, 20, 0);
570 /* make call state */
571 new_state(EPOINT_STATE_IN_OVERLAP);
572 e_ruleset = ruleset_main;
574 e_rule = e_ruleset->rule_first;
576 e_dialinginfo.id[0] = '\0';
577 e_extdialing = e_dialinginfo.id;
578 set_tone(portlist, "dialpbx");
584 * process init 'change_callerid'
586 void EndpointAppPBX::action_init_change_callerid(void)
588 struct port_list *portlist = ea_endpoint->ep_portlist;
590 if (!e_ext.change_callerid) {
591 /* service not available */
592 trace_header("ACTION change-callerid (denied for this caller)", DIRECTION_NONE);
594 message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, "");
595 new_state(EPOINT_STATE_OUT_DISCONNECT);
596 set_tone(portlist,"cause_87");
601 /* process dialing callerid
603 void EndpointAppPBX::_action_callerid_calleridnext(int next)
605 struct port_list *portlist = ea_endpoint->ep_portlist;
606 struct route_param *rparam;
607 char buffer[64], *callerid;
608 char old_id[64] = "", new_id[64] = "";
609 int old_type=0, new_type=0, old_present=0, new_present=0;
611 if ((rparam = routeparam(e_action, PARAM_CALLERID))) {
612 /* the caller ID is given by parameter */
613 callerid = rparam->string_value;
615 /* caller ID is dialed */
616 if (!strchr(e_extdialing, '#')) {
617 /* no complete ID yet */
620 *strchr(e_extdialing, '#') = '\0';
621 callerid = e_extdialing;
624 /* given callerid type */
625 if ((rparam = routeparam(e_action, PARAM_CALLERIDTYPE)))
626 switch(rparam->integer_value) {
627 case INFO_NTYPE_SUBSCRIBER:
628 SPRINT(buffer, "s%s", callerid);
631 case INFO_NTYPE_NATIONAL:
632 SPRINT(buffer, "n%s", callerid);
635 case INFO_NTYPE_INTERNATIONAL:
636 SPRINT(buffer, "i%s", callerid);
640 SPRINT(buffer, "%s", callerid);
645 /* caller id complete, dialing with new caller id */
646 /* write new parameters */
647 if (read_extension(&e_ext, e_ext.number)) {
648 old_present = (!next)?e_ext.callerid_present:e_ext.id_next_call_present;
649 old_type = (!next)?e_ext.callerid_type:e_ext.id_next_call_type;
650 SCPY(old_id, (!next)?e_ext.callerid:e_ext.id_next_call);
651 if (callerid[0] == '\0') {
653 (!next)?e_ext.callerid_present:e_ext.id_next_call_present = INFO_PRESENT_RESTRICTED;
656 (!next)?e_ext.callerid_present:e_ext.id_next_call_present = INFO_PRESENT_ALLOWED;
657 if ((rparam = routeparam(e_action, PARAM_PRESENT))) if (rparam->integer_value == 0)
658 (!next)?e_ext.callerid_present:e_ext.id_next_call_present = INFO_PRESENT_RESTRICTED;
659 if (e_ext.callerid_type == INFO_NTYPE_UNKNOWN) /* if callerid is unknown, the given id is not nationalized */ {
660 SCPY((!next)?e_ext.callerid:e_ext.id_next_call, callerid);
661 (!next)?e_ext.callerid_type:e_ext.id_next_call_type = INFO_NTYPE_UNKNOWN;
663 SCPY((!next)?e_ext.callerid:e_ext.id_next_call, nationalize_callerinfo(callerid,&((!next)?e_ext.callerid_type:e_ext.id_next_call_type), options.national, options.international));
665 if (!next) e_ext.id_next_call_type = -1;
666 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): nationalized callerid: '%s' type=%d\n", ea_endpoint->ep_serial, (!next)?e_ext.callerid:e_ext.id_next_call, (!next)?e_ext.callerid_type:e_ext.id_next_call_type);
668 new_present = (!next)?e_ext.callerid_present:e_ext.id_next_call_present;
669 new_type = (!next)?e_ext.callerid_type:e_ext.id_next_call_type;
670 SCPY(new_id, (!next)?e_ext.callerid:e_ext.id_next_call);
671 write_extension(&e_ext, e_ext.number);
674 /* function activated */
676 trace_header("ACTION change-callerid (only next call)", DIRECTION_NONE);
678 trace_header("ACTION change-callerid (all future calls)", DIRECTION_NONE);
679 add_trace("old", "caller id", "%s", numberrize_callerinfo(old_id, old_type, options.national, options.international));
680 add_trace("old", "present", "%s", (old_present==INFO_PRESENT_RESTRICTED)?"restricted":"allowed");
681 add_trace("new", "caller id", "%s", numberrize_callerinfo(new_id, new_type, options.national, options.international));
682 add_trace("new", "present", "%s", (new_present==INFO_PRESENT_RESTRICTED)?"restricted":"allowed");
684 message_disconnect_port(portlist, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, "");
685 new_state(EPOINT_STATE_OUT_DISCONNECT);
686 set_tone(portlist,"activated");
689 /* process dialing callerid for all call
691 void EndpointAppPBX::action_dialing_callerid(void)
693 _action_callerid_calleridnext(0);
696 /* process dialing callerid for next call
698 void EndpointAppPBX::action_dialing_calleridnext(void)
700 _action_callerid_calleridnext(1);
705 * process init 'change_forward'
707 void EndpointAppPBX::action_init_change_forward(void)
709 struct port_list *portlist = ea_endpoint->ep_portlist;
711 if (!e_ext.change_forward) {
712 trace_header("ACTION change-forward (denied for this caller)", DIRECTION_NONE);
714 /* service not available */
715 message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, "");
716 new_state(EPOINT_STATE_OUT_DISCONNECT);
717 set_tone(portlist,"cause_87");
722 /* process dialing forwarding
724 void EndpointAppPBX::action_dialing_forward(void)
726 struct port_list *portlist = ea_endpoint->ep_portlist;
727 int diversion = INFO_DIVERSION_CFU;
728 char *dest = e_extdialing;
729 struct route_param *rparam;
731 /* if diversion type is given */
732 if ((rparam = routeparam(e_action, PARAM_DIVERSION)))
733 diversion = rparam->integer_value;
735 if ((rparam = routeparam(e_action, PARAM_DEST))) {
736 /* if destination is given */
737 dest = rparam->string_value;
739 if (!strchr(e_extdialing, '#'))
741 *strchr(e_extdialing, '#') = '\0';
745 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing forwarding to '%s'.\n", ea_endpoint->ep_serial, e_ext.number, dest);
746 if (read_extension(&e_ext, e_ext.number)) {
748 case INFO_DIVERSION_CFU:
749 trace_header("ACTION change-forward (new CFU=unconditional)", DIRECTION_NONE);
750 add_trace("destin'", NULL, "%s", dest);
752 SCPY(e_ext.cfu, dest);
754 case INFO_DIVERSION_CFB:
755 trace_header("ACTION change-forward (new CFB=busy)", DIRECTION_NONE);
756 add_trace("destin'", NULL, "%s", dest);
758 SCPY(e_ext.cfb, dest);
760 case INFO_DIVERSION_CFNR:
761 if ((rparam = routeparam(e_action, PARAM_DELAY)))
762 e_ext.cfnr_delay = rparam->integer_value;
763 trace_header("ACTION change-forward (new CFNR=no response)", DIRECTION_NONE);
764 add_trace("destin'", NULL, "%s", dest);
765 add_trace("delay", NULL, "%s", e_ext.cfnr_delay);
767 SCPY(e_ext.cfnr, dest);
769 case INFO_DIVERSION_CFP:
770 trace_header("ACTION change-forward (new CFP=parallel)", DIRECTION_NONE);
771 add_trace("destin'", NULL, "%s", dest);
773 SCPY(e_ext.cfp, dest);
776 write_extension(&e_ext, e_ext.number);
778 /* function (de)activated */
779 message_disconnect_port(portlist, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, "");
780 new_state(EPOINT_STATE_OUT_DISCONNECT);
782 set_tone(portlist,"activated");
784 set_tone(portlist,"deactivated");
788 /* process dialing redial
790 void EndpointAppPBX::action_init_redial_reply(void)
792 struct port_list *portlist = ea_endpoint->ep_portlist;
795 if (!e_ext.last_out[0]) {
796 trace_header("ACTION redial/reply (no last number stored)", DIRECTION_NONE);
798 new_state(EPOINT_STATE_OUT_DISCONNECT);
799 message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, "");
800 set_tone(portlist, "cause_3f");
805 /* process dialing redial
807 void EndpointAppPBX::_action_redial_reply(int in)
809 struct lcr_msg *message;
811 struct route_param *rparam;
813 last = (in)?e_ext.last_in[0]:e_ext.last_out[0];
815 /* if no display is available */
816 if (!e_ext.display_menu)
818 if (ea_endpoint->ep_portlist->port_type!=PORT_TYPE_DSS1_NT_IN && ea_endpoint->ep_portlist->port_type!=PORT_TYPE_DSS1_NT_OUT)
821 /* if select is not given */
822 if (!(rparam = routeparam(e_action, PARAM_SELECT)))
826 if (e_extdialing[0]=='*' || e_extdialing[0]=='1') {
827 /* find prev entry */
833 if (e_extdialing[0]=='#' || e_extdialing[0]=='3') {
834 /* find next entry */
836 if (e_select >= MAX_REMEMBER) {
839 if (e_ext.last_in[e_select][0] == '\0')
842 if (e_ext.last_out[e_select][0] == '\0')
847 last = (in)?e_ext.last_in[e_select]:e_ext.last_out[e_select];
848 if (e_extdialing[0]=='0' || e_extdialing[0]=='2') {
851 trace_header("ACTION reply (dialing)", DIRECTION_NONE);
853 trace_header("ACTION redial (dialing)", DIRECTION_NONE);
854 add_trace("number", NULL, "%s", last);
855 add_trace("last but", NULL, "%d", e_select);
857 SCPY(e_dialinginfo.id, last);
858 e_extdialing = e_dialinginfo.id;
863 e_extdialing[0] = '\0';
865 /* send display message to port */
866 message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY);
867 if (!strncmp(last, "extern:", 7))
868 SPRINT(message->param.notifyinfo.display, "(%d) %s ext", e_select+1, last+7);
870 if (!strncmp(last, "intern:", 7))
871 SPRINT(message->param.notifyinfo.display, "(%d) %s int", e_select+1, last+7);
873 if (!strncmp(last, "chan:", 4))
874 SPRINT(message->param.notifyinfo.display, "(%d) %s chan", e_select+1, last+5);
876 if (!strncmp(last, "vbox:", 5))
877 SPRINT(message->param.notifyinfo.display, "(%d) %s vbox", e_select+1, last+5);
879 SPRINT(message->param.notifyinfo.display, "(%d) %s", e_select+1, (last[0])?last:"- empty -");
880 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s sending display:%s\n", ea_endpoint->ep_serial, e_ext.number, message->param.notifyinfo.display);
881 message_put(message);
882 logmessage(message->type, &message->param, ea_endpoint->ep_portlist->port_id, DIRECTION_OUT);
885 /* process dialing redial
887 void EndpointAppPBX::action_dialing_redial(void)
889 _action_redial_reply(0);
892 /* process dialing reply
894 void EndpointAppPBX::action_dialing_reply(void)
896 _action_redial_reply(1);
900 /* dialing powerdialing delay
902 void EndpointAppPBX::action_dialing_powerdial(void)
904 struct port_list *portlist = ea_endpoint->ep_portlist;
905 struct lcr_msg *message;
906 struct route_param *rparam;
908 /* power dialing only possible if we have a last dialed number */
909 if (!e_ext.last_out[0]) {
910 trace_header("ACTION powerdial (no last number stored)", DIRECTION_NONE);
912 new_state(EPOINT_STATE_OUT_DISCONNECT);
913 message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, "");
914 set_tone(portlist, "cause_3f");
919 if ((rparam = routeparam(e_action, PARAM_LIMIT))) {
920 e_powerlimit = rparam->integer_value;
926 if ((rparam = routeparam(e_action, PARAM_DELAY))) {
927 e_powerdelay = rparam->integer_value;
929 /* delay incomplete */
930 if (!strchr(e_extdialing, '#'))
932 *strchr(e_extdialing, '#') = '\0';
933 e_powerdelay = e_extdialing[0]?atoi(e_extdialing): 0;
936 if (e_powerdelay < 1)
938 trace_header("ACTION powerdial (dialing)", DIRECTION_NONE);
939 add_trace("number", NULL, "%s", e_ext.last_out[0]);
940 add_trace("delay", NULL, "%d", e_powerdelay);
943 /* send connect to avoid overlap timeout */
944 // new_state(EPOINT_STATE_CONNECT); connect may prevent further dialing
947 memset(&e_connectinfo, 0, sizeof(e_connectinfo));
948 message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT);
949 message_put(message);
950 logmessage(message->type, &message->param, ea_endpoint->ep_portlist->port_id, DIRECTION_OUT);
953 SCPY(e_dialinginfo.id, e_ext.last_out[0]);
954 e_powerdial_on = 1; /* indicates the existence of powerdialing but no redial time given */
963 void EndpointAppPBX::action_dialing_callback(void)
965 struct port_list *portlist = ea_endpoint->ep_portlist;
966 struct route_param *rparam;
967 struct extension cbext;
969 portlist = ea_endpoint->ep_portlist;
971 /* check given extension */
972 if (!(rparam = routeparam(e_action, PARAM_EXTENSION))) {
974 trace_header("ACTION callback (no extension defined)", DIRECTION_NONE);
978 new_state(EPOINT_STATE_OUT_DISCONNECT);
979 message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, "");
980 set_tone(portlist, "cause_3f");
982 e_cbcaller[0] = e_cbdialing[0] = '\0';
986 /* if extension is given */
987 SCPY(e_cbcaller, rparam->string_value);
988 if (e_cbcaller[0] == '\0')
991 /* read callback extension */
992 memset(&cbext, 0, sizeof(cbext));
993 if (!read_extension(&cbext, e_cbcaller)) {
994 trace_header("ACTION callback (extension doesn't exist)", DIRECTION_NONE);
995 add_trace("extension", NULL, "%s", e_cbcaller);
1000 /* if password is not given */
1001 if (cbext.password[0] == '\0') {
1002 trace_header("ACTION callback (no password set)", DIRECTION_NONE);
1003 add_trace("extension", NULL, "%s", e_cbcaller);
1008 /* callback only possible if callerid exists OR it is given */
1009 if ((rparam = routeparam(e_action, PARAM_CALLTO)))
1010 SCPY(e_cbto, rparam->string_value);
1012 trace_header("ACTION callback (alternative caller id)", DIRECTION_NONE);
1013 add_trace("extension", NULL, "%s", e_cbcaller);
1014 add_trace("callerid", NULL, "%s", e_cbto);
1016 SCPY(e_callerinfo.id, e_cbto);
1017 e_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
1018 e_callerinfo.present = INFO_PRESENT_ALLOWED;
1020 if (e_callerinfo.id[0]=='\0' || e_callerinfo.present==INFO_PRESENT_NOTAVAIL) {
1021 trace_header("ACTION callback (no caller ID available)", DIRECTION_NONE);
1022 add_trace("extension", NULL, "%s", e_cbcaller);
1027 e_callerinfo.present = INFO_PRESENT_ALLOWED;
1032 * process hangup 'callback'
1034 void EndpointAppPBX::action_hangup_callback(void)
1036 struct route_param *rparam;
1040 delay = 2; /* default value */
1041 if ((rparam = routeparam(e_action, PARAM_DELAY)))
1042 if (rparam->integer_value>0)
1043 delay = rparam->integer_value;
1045 /* dialing after callback */
1046 if ((rparam = routeparam(e_action, PARAM_PREFIX)))
1047 SCPY(e_cbdialing, rparam->string_value);
1049 SCPY(e_cbdialing, e_extdialing);
1051 trace_header("ACTION callback (dialing)", DIRECTION_NONE);
1052 add_trace("extension", NULL, "%s", e_cbcaller);
1053 add_trace("caller id", NULL, "%s", e_callerinfo.id);
1054 add_trace("delay", NULL, "%d", delay);
1055 add_trace("dialing", NULL, "%s", e_cbdialing);
1058 /* set time to callback */
1059 schedule_timer(&e_callback_timeout, delay, 0);
1064 * dialing action abbreviation
1066 void EndpointAppPBX::action_dialing_abbrev(void)
1068 struct port_list *portlist = ea_endpoint->ep_portlist;
1069 char *abbrev, *phone, *name;
1072 portlist = ea_endpoint->ep_portlist;
1074 /* abbrev dialing is only possible if we have a caller defined */
1075 if (!e_ext.number[0]) {
1076 trace_header("ACTION abbreviation (only for extension)", DIRECTION_NONE);
1078 new_state(EPOINT_STATE_OUT_DISCONNECT);
1079 message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, "");
1080 set_tone(portlist, "cause_3f");
1084 /* check abbreviation */
1085 abbrev = e_extdialing;
1088 result = parse_phonebook(e_ext.number, &abbrev, &phone, &name);
1090 trace_header("ACTION abbreviation (not found)", DIRECTION_NONE);
1091 add_trace("abbrev", NULL, "%s", abbrev);
1093 new_state(EPOINT_STATE_OUT_DISCONNECT);
1094 message_disconnect_port(portlist, CAUSE_UNALLOCATED, LOCATION_PRIVATE_LOCAL, "");
1095 set_tone(portlist, "cause_01");
1098 if (result == -1) { /* may match if more digits are dialed */
1102 /* dial abbreviation */
1103 trace_header("ACTION abbreviation (dialing)", DIRECTION_NONE);
1104 add_trace("abbrev", NULL, "%s", abbrev);
1105 add_trace("number", NULL, "%s", phone);
1106 if (name) if (name[0])
1107 add_trace("name", NULL, "%s", name);
1109 SCPY(e_dialinginfo.id, phone);
1110 e_extdialing = e_dialinginfo.id;
1116 /* process dialing 'test'
1118 void EndpointAppPBX::action_dialing_test(void)
1122 struct port_list *portlist = ea_endpoint->ep_portlist;
1123 struct lcr_msg *message;
1125 char testcode[32] = "";
1126 struct route_param *rparam;
1128 /* given testcode */
1129 if ((rparam = routeparam(e_action, PARAM_PREFIX)))
1130 SCPY(testcode, rparam->string_value);
1131 SCAT(testcode, e_extdialing);
1133 switch(testcode[0]) {
1135 trace_header("ACTION test", DIRECTION_NONE);
1136 add_trace("test", NULL, "proceeding");
1138 new_state(EPOINT_STATE_IN_PROCEEDING);
1139 set_tone(portlist, "proceeding");
1140 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_PROCEEDING);
1141 message_put(message);
1142 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
1146 trace_header("ACTION test", DIRECTION_NONE);
1147 add_trace("test", NULL, "alerting");
1149 new_state(EPOINT_STATE_IN_ALERTING);
1150 set_tone(portlist, "ringpbx");
1151 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_ALERTING);
1152 message_put(message);
1153 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
1157 trace_header("ACTION test", DIRECTION_NONE);
1158 add_trace("test", NULL, "echo");
1160 new_state(EPOINT_STATE_CONNECT);
1161 if (e_ext.number[0])
1163 set_tone(portlist, NULL);
1164 memset(&e_connectinfo, 0, sizeof(e_connectinfo));
1165 SCPY(e_connectinfo.id, e_callerinfo.id);
1166 SCPY(e_connectinfo.extension, e_callerinfo.extension);
1167 e_connectinfo.itype = e_callerinfo.itype;
1168 e_connectinfo.ntype = e_callerinfo.ntype;
1169 e_connectinfo.present = e_callerinfo.present;
1170 e_connectinfo.screen = e_callerinfo.screen;
1171 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT);
1172 memcpy(&message->param.connectinfo, &e_connectinfo, sizeof(struct connect_info));
1173 /* handle restricted caller ids */
1174 apply_callerid_restriction(&e_ext, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name);
1175 /* display callerid if desired for extension */
1176 SCPY(message->param.connectinfo.display, apply_callerid_display(message->param.connectinfo.id, message->param.connectinfo.itype, message->param.connectinfo.ntype, message->param.connectinfo.present, message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name));
1177 message_put(message);
1178 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
1180 port = find_port_id(portlist->port_id);
1182 port->set_echotest(1);
1187 trace_header("ACTION test", DIRECTION_NONE);
1188 add_trace("test", NULL, "tone");
1190 new_state(EPOINT_STATE_CONNECT);
1191 if (e_ext.number[0])
1193 memset(&e_connectinfo, 0, sizeof(e_connectinfo));
1194 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT);
1195 message_put(message);
1196 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
1197 set_tone(portlist, "test");
1201 trace_header("ACTION test", DIRECTION_NONE);
1202 add_trace("test", NULL, "hold music");
1204 new_state(EPOINT_STATE_CONNECT);
1205 if (e_ext.number[0])
1207 memset(&e_connectinfo, 0, sizeof(e_connectinfo));
1208 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT);
1209 message_put(message);
1210 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
1211 set_tone(portlist, "hold");
1215 if (strlen(testcode) < 4)
1218 cause = atoi(testcode+1);
1221 trace_header("ACTION test", DIRECTION_NONE);
1222 add_trace("test", NULL, "announcement");
1223 add_trace("cause", NULL, "%d", cause);
1225 new_state(EPOINT_STATE_CONNECT);
1226 if (e_ext.number[0])
1228 SPRINT(causestr,"cause_%02x",cause);
1229 memset(&e_connectinfo, 0, sizeof(e_connectinfo));
1230 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT);
1231 message_put(message);
1232 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
1233 set_tone(portlist, causestr);
1237 if (strlen(testcode) < 4)
1240 cause = atoi(testcode+1);
1243 trace_header("ACTION test", DIRECTION_NONE);
1244 add_trace("test", NULL, "disconnect");
1245 add_trace("cause", NULL, "%d", cause);
1247 new_state(EPOINT_STATE_OUT_DISCONNECT);
1248 SPRINT(causestr,"cause_%02x",cause);
1249 message_disconnect_port(portlist, cause, LOCATION_PRIVATE_LOCAL, "");
1250 set_tone(portlist, causestr);
1253 case '8': /* release */
1254 trace_header("ACTION test", DIRECTION_NONE);
1255 add_trace("test", NULL, "release");
1256 add_trace("cause", NULL, "16");
1258 new_state(EPOINT_STATE_OUT_DISCONNECT);
1259 message_disconnect_port(portlist, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, "");
1260 set_tone(portlist, "release");
1263 case '9': /* text callerid test */
1264 trace_header("ACTION test", DIRECTION_NONE);
1265 add_trace("test", NULL, "callerid");
1267 new_state(EPOINT_STATE_CONNECT);
1268 if (e_ext.number[0])
1270 memset(&e_connectinfo, 0, sizeof(e_connectinfo));
1271 SCPY(e_connectinfo.id, "12345678");
1272 SCPY(e_connectinfo.name, "Welcome to LCR");
1273 SCPY(e_connectinfo.display, "Welcome to LCR");
1274 e_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
1275 e_connectinfo.present = INFO_PRESENT_ALLOWED;
1276 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT);
1277 memcpy(&message->param.connectinfo, &e_connectinfo, sizeof(message->param.connectinfo));
1278 message_put(message);
1279 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
1280 set_tone(portlist, "hold");
1286 /* process init play
1288 void EndpointAppPBX::action_init_play(void)
1290 struct route_param *rparam;
1291 struct port_list *portlist = ea_endpoint->ep_portlist;
1293 /* check given sample */
1294 if (!(rparam = routeparam(e_action, PARAM_SAMPLE))) {
1295 trace_header("ACTION play (no sample given)", DIRECTION_NONE);
1299 new_state(EPOINT_STATE_OUT_DISCONNECT);
1300 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "");
1301 set_tone(portlist, "cause_3f");
1306 /* if sample is given */
1307 if (rparam->string_value[0] == '\0') {
1308 trace_header("ACTION play (no sample given)", DIRECTION_NONE);
1313 if (e_ext.number[0])
1316 set_tone(ea_endpoint->ep_portlist, rparam->string_value);
1321 * action_*_vbox_play is implemented in "action_vbox.cpp"
1326 * process dialing of calculator
1328 void EndpointAppPBX::action_dialing_calculator(void)
1330 struct port_list *portlist = ea_endpoint->ep_portlist;
1331 struct lcr_msg *message;
1332 double value1, value2, v, sign1;
1333 int komma1, komma2, k, state, mode = 0, first;
1336 portlist = ea_endpoint->ep_portlist;
1338 /* remove error message */
1339 if (!strncmp(e_extdialing, "Error", 5)) {
1340 UCPY(e_extdialing, e_extdialing+5);
1342 if (!strncmp(e_extdialing, "inf", 3)) {
1343 UCPY(e_extdialing, e_extdialing+3);
1345 if (!strncmp(e_extdialing, "-inf", 4)) {
1346 UCPY(e_extdialing, e_extdialing+4);
1349 /* process dialing */
1361 if (*p>='0' && *p<='9') {
1367 if ((p[-1]<'0' || p[-1]>'0') && p[-1]!='.') {
1374 case 0: /* first number */
1376 value1 = value1*10 + (*p-'0');
1385 case 1: /* second number */
1387 value2 = value2*10 + (*p-'0');
1401 UCPY(e_extdialing, "Error");
1404 /* if there is a multiplication, we change to / */
1412 /* if there is a division, we change to + */
1420 /* if there is a addition, we change to - */
1428 /* if there is a substraction and a comma, we change to * */
1429 if (p[-1]=='-' && komma1) {
1436 /* if there is a substraction and no comma and the first or second value, we change to , */
1444 /* if there is a komma and we are at the first value, we change to * */
1445 if (p[-1]=='.' && state==0) {
1453 /* if there is a komma and we are at the second value, we display error */
1454 if (komma2 && state==1) {
1455 UCPY(e_extdialing, "Error");
1458 /* if we are at state 1, we write a comma */
1464 /* we assume multiplication */
1471 /* if just a number is displayed, the input is cleared */
1473 *e_extdialing = '\0';
1476 /* calculate the result */
1478 case 0: /* multiply */
1479 UNPRINT(e_extdialing, sizeof(e_dialinginfo.id)-strlen(e_dialinginfo.id), "%.8f", sign1*value1*value2);
1481 case 1: /* divide */
1482 UNPRINT(e_extdialing, sizeof(e_dialinginfo.id)-strlen(e_dialinginfo.id), "%.8f", sign1*value1/value2);
1485 UNPRINT(e_extdialing, sizeof(e_dialinginfo.id)-strlen(e_dialinginfo.id), "%.8f", sign1*value1+value2);
1487 case 3: /* substract */
1488 UNPRINT(e_extdialing, sizeof(e_dialinginfo.id)-strlen(e_dialinginfo.id), "%.8f", sign1*value1-value2);
1491 e_dialinginfo.id[sizeof(e_dialinginfo.id)-1] = '\0';
1492 if (strchr(e_extdialing, '.')) { /* remove zeroes */
1493 while (e_extdialing[strlen(e_extdialing)-1] == '0')
1494 e_extdialing[strlen(e_extdialing)-1] = '\0';
1495 if (e_extdialing[strlen(e_extdialing)-1] == '.')
1496 e_extdialing[strlen(e_extdialing)-1] = '\0'; /* and remove dot */
1498 p = strchr(e_extdialing,'\0')-1;
1530 UCPY(e_extdialing, "Error");
1539 /* display dialing */
1540 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY);
1541 SPRINT(message->param.notifyinfo.display, ">%s", e_extdialing);
1542 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s displaying interpreted dialing '%s' internal values: %f %f\n", ea_endpoint->ep_serial, e_ext.number, e_extdialing, value1, value2);
1543 message_put(message);
1544 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
1549 * process dialing of timer
1551 void EndpointAppPBX::action_dialing_timer(void)
1557 * process 'goto' or 'menu'
1559 void EndpointAppPBX::_action_goto_menu(int mode)
1561 struct port_list *portlist = ea_endpoint->ep_portlist;
1562 struct route_param *rparam;
1564 /* check given ruleset */
1565 if (!(rparam = routeparam(e_action, PARAM_RULESET))) {
1567 trace_header("ACTION goto/menu (no ruleset given)", DIRECTION_NONE);
1571 new_state(EPOINT_STATE_OUT_DISCONNECT);
1572 message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, "");
1573 set_tone(portlist, "cause_3f");
1577 if (rparam->string_value[0] == '\0')
1579 e_ruleset = getrulesetbyname(rparam->string_value);
1581 trace_header("ACTION goto/menu (ruleset not found)", DIRECTION_NONE);
1582 add_trace("ruleset", NULL, "%s", rparam->string_value);
1587 /* if the 'menu' was selected, we will flush all digits */
1589 e_dialinginfo.id[0] = 0;
1590 e_extdialing = e_dialinginfo.id;
1592 /* remove digits that are required to match the rule */
1593 if ((rparam = routeparam(e_action, PARAM_STRIP))) {
1595 SCPY(e_dialinginfo.id, e_extdialing);
1596 e_extdialing = e_dialinginfo.id;
1601 trace_header("ACTION goto/menu (change to)", DIRECTION_NONE);
1602 add_trace("ruleset", NULL, "%s", e_ruleset->name);
1603 if (e_dialinginfo.id[0]) {
1604 add_trace("dialing", NULL, "%s", e_dialinginfo.id);
1606 if ((rparam = routeparam(e_action, PARAM_SAMPLE))) {
1607 add_trace("sample", NULL, "%s", rparam->string_value);
1609 set_tone(ea_endpoint->ep_portlist, rparam->string_value);
1614 /* do dialing with new ruleset */
1619 /* process dialing goto
1621 void EndpointAppPBX::action_dialing_goto(void)
1623 _action_goto_menu(0);
1626 /* process dialing menu
1628 void EndpointAppPBX::action_dialing_menu(void)
1630 _action_goto_menu(1);
1635 * process dialing disconnect
1637 void EndpointAppPBX::action_dialing_disconnect(void)
1639 struct route_param *rparam;
1640 struct port_list *portlist = ea_endpoint->ep_portlist;
1641 struct lcr_msg *message;
1642 int cause = CAUSE_NORMAL; /* normal call clearing */
1643 int location = LOCATION_PRIVATE_LOCAL;
1644 char cause_string[256] = "", display[84] = "";
1646 /* check cause parameter */
1647 if ((rparam = routeparam(e_action, PARAM_CAUSE))) {
1648 cause = rparam->integer_value;
1649 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): 'cause' is given: %d\n", ea_endpoint->ep_serial, cause);
1651 if ((rparam = routeparam(e_action, PARAM_LOCATION))) {
1652 location = rparam->integer_value;
1653 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): 'location' is given: %d\n", ea_endpoint->ep_serial, location);
1657 /* use cause as sample, if not given later */
1658 SPRINT(cause_string, "cause_%02x", cause);
1660 /* check sample parameter */
1661 if ((rparam = routeparam(e_action, PARAM_SAMPLE))) {
1662 SCPY(cause_string, rparam->string_value);
1663 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): 'sample' is given: %s\n", ea_endpoint->ep_serial, cause_string);
1667 if ((rparam = routeparam(e_action, PARAM_DISPLAY))) {
1668 SCPY(display, rparam->string_value);
1669 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): 'display' is given: %s\n", ea_endpoint->ep_serial, display);
1672 /* disconnect only if connect parameter is not given */
1673 trace_header("ACTION disconnect", DIRECTION_NONE);
1674 add_trace("cause", "value", "%d", cause);
1675 add_trace("cause", "location", "%d", location);
1676 if (cause_string[0])
1677 add_trace("sample", NULL, "%s", cause_string);
1679 add_trace("display", NULL, "%s", display);
1681 new_state(EPOINT_STATE_OUT_DISCONNECT);
1682 set_tone(portlist, cause_string);
1683 if (!(rparam = routeparam(e_action, PARAM_CONNECT))) {
1684 message_disconnect_port(portlist, cause, location, display);
1686 message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY);
1687 SCPY(message->param.notifyinfo.display, display);
1688 message_put(message);
1689 logmessage(message->type, &message->param, ea_endpoint->ep_portlist->port_id, DIRECTION_OUT);
1696 * process dialing release
1698 void EndpointAppPBX::action_dialing_release(void)
1700 struct route_param *rparam;
1701 int cause = CAUSE_NORMAL; /* normal call clearing */
1702 int location = LOCATION_PRIVATE_LOCAL;
1703 char cause_string[256] = "", display[84] = "";
1705 /* check cause parameter */
1706 if ((rparam = routeparam(e_action, PARAM_CAUSE))) {
1707 cause = rparam->integer_value;
1708 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): 'cause' is given: %d\n", ea_endpoint->ep_serial, cause);
1710 if ((rparam = routeparam(e_action, PARAM_LOCATION))) {
1711 location = rparam->integer_value;
1712 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): 'location' is given: %d\n", ea_endpoint->ep_serial, location);
1716 /* use cause as sample, if not given later */
1717 SPRINT(cause_string, "cause_%02x", cause);
1720 if ((rparam = routeparam(e_action, PARAM_DISPLAY))) {
1721 SCPY(display, rparam->string_value);
1722 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): 'display' is given: %s\n", ea_endpoint->ep_serial, display);
1725 /* disconnect only if connect parameter is not given */
1726 trace_header("ACTION release", DIRECTION_NONE);
1727 add_trace("cause", "value", "%d", cause);
1728 add_trace("cause", "location", "%d", location);
1730 add_trace("display", NULL, "%s", display);
1733 release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, location, cause, 1);
1738 * process dialing help
1740 void EndpointAppPBX::action_dialing_help(void)
1742 /* show all things that would match */
1744 struct numbering *numbering = numbering_int;
1745 char dialing[sizeof(e_dialinginfo.id)];
1747 struct lcr_msg *message;
1748 struct route_param *rparam;
1750 /* in case we have no menu (this should never happen) */
1755 if (strchr(e_dialinginfo.id,'*')) {
1757 e_dialinginfo.id[0] = '\0';
1759 if (strchr(e_dialinginfo.id,'#')) {
1761 e_dialinginfo.id[0] = '\0';
1764 /* get position in menu */
1766 /* get last menu position */
1768 while(numbering->next) {
1770 numbering = numbering->next;
1773 /* get menu position */
1776 numbering = numbering->next;
1779 numbering = numbering_int;
1786 /* if we dial something else we need to add the prefix and change the action */
1787 if (e_dialinginfo.id[0]) {
1788 e_action = NUMB_ACTION_NONE;
1789 SCPY(dialing, numbering->prefix);
1790 //we ignore the first digit after selecting
1791 //SCAT(dialing, e_dialinginfo.id);
1792 SCPY(e_dialinginfo.id, dialing);
1793 e_extdialing = e_dialinginfo.id+strlen(numbering->prefix);
1794 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s selected a new menu '%s' dialing: %s\n", ea_endpoint->ep_serial, e_ext.number, numb_actions[numbering->action], e_dialinginfo.id);
1800 /* send display message to port */
1801 message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY);
1802 SPRINT(message->param.notifyinfo.display, ">%s %s%s%s", numbering->prefix, numb_actions[numbering->action], (numbering->param[0])?" ":"", numbering->param);
1803 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s selected a new menu '%s' sending display:%s\n", ea_endpoint->ep_serial, e_ext.number, numb_actions[numbering->action], message->param.notifyinfo.display);
1804 message_put(message);
1805 logmessage(message->type, message->paramea_endpoint->ep_portlist->port_id, DIRECTION_OUT);
1811 * process dialing deflect
1813 void EndpointAppPBX::action_dialing_deflect(void)
1819 * process dialing setforward
1821 void EndpointAppPBX::action_dialing_setforward(void)
1826 * process init 'execute'
1828 void EndpointAppPBX::action_init_execute(void)
1830 struct route_param *rparam;
1831 int executeon = INFO_ON_HANGUP; /* Use Hangup as a default for compatibility */
1833 /* Get the execute on parameter */
1834 if ((rparam = routeparam(e_action, PARAM_ON)))
1835 executeon = rparam->integer_value;
1837 /* Execute this action if init was specified */
1838 if (executeon == INFO_ON_INIT) {
1839 trace_header("ACTION execute ON init", DIRECTION_NONE);
1846 * process hangup 'execute'
1848 void EndpointAppPBX::action_hangup_execute(void)
1850 struct route_param *rparam;
1851 int executeon = INFO_ON_HANGUP; /* Use Hangup as a default for compatibility */
1853 /* Get the execute on parameter */
1854 if ((rparam = routeparam(e_action, PARAM_ON)))
1855 executeon = rparam->integer_value;
1857 /* Execute this action if init was specified */
1858 if (executeon == INFO_ON_HANGUP) {
1859 trace_header("ACTION execute ON hangup", DIRECTION_NONE);
1866 * process 'execute' from action_init_execute or action_hangup_execute
1868 void EndpointAppPBX::action_execute(void)
1870 struct route_param *rparam;
1874 char *command = (char *)"";
1876 char *argv[12]; /* check also number of args below */
1879 /* get script / command */
1880 if ((rparam = routeparam(e_action, PARAM_EXECUTE)))
1881 command = rparam->string_value;
1882 if (command[0] == '\0') {
1883 trace_header("ACTION execute (no parameter given)", DIRECTION_NONE);
1888 argv[i++] = (char *)"/bin/sh";
1889 argv[i++] = (char *)"-c";
1890 argv[i++] = command;
1892 argv[i++] = command;
1893 if ((rparam = routeparam(e_action, PARAM_PARAM))) {
1894 argv[i++] = rparam->string_value;
1896 argv[i++] = e_extdialing;
1897 argv[i++] = (char *)numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype, options.national, options.international);
1898 argv[i++] = e_callerinfo.extension;
1899 argv[i++] = e_callerinfo.name;
1900 SPRINT(isdn_port, "%d", e_callerinfo.isdn_port);
1901 argv[i++] = isdn_port;
1902 argv[i++] = e_callerinfo.imsi;
1903 argv[i++] = NULL; /* check also number of args above */
1904 switch (pid = fork ()) {
1906 trace_header("ACTION execute (fork failed)", DIRECTION_NONE);
1910 /* To be shure there are no zombies created double fork */
1911 if ((pid2 = fork()) == 0) {
1912 execve(command, argv, environ);
1914 /* Exit immediately and release the waiting parent. The subprocess falls to init because the parent died */
1918 trace_header("ACTION execute", DIRECTION_NONE);
1919 add_trace("command", NULL, "%s", command);
1922 /* Wait for the pid. The forked process will exit immediately so there is no problem waiting. */
1923 waitpid(pid, &iWaitStatus, 0);
1930 * process hangup 'file'
1932 void EndpointAppPBX::action_hangup_file(void)
1934 struct route_param *rparam;
1935 const char *file, *content, *mode;
1938 /* get file / content */
1939 if (!(rparam = routeparam(e_action, PARAM_FILE)))
1940 file = rparam->string_value;
1943 if (!(rparam = routeparam(e_action, PARAM_CONTENT)))
1944 content = rparam->string_value;
1946 content = e_extdialing;
1947 if (!(rparam = routeparam(e_action, PARAM_APPEND)))
1951 if (file[0] == '\0') {
1952 trace_header("ACTION file (no filename given)", DIRECTION_NONE);
1956 if (!(fp = fopen(file, mode))) {
1957 trace_header("ACTION file (failed to open)", DIRECTION_NONE);
1958 add_trace("file", "name", "%s", file);
1959 add_trace("file", "mode", "%s", (mode[0]=='w')?"write":"append");
1963 trace_header("ACTION file", DIRECTION_NONE);
1964 add_trace("file", "name", "%s", file);
1965 add_trace("file", "mode", "%s", (mode[0]=='w')?"write":"append");
1966 add_trace("content", NULL, "%s", content);
1968 fprintf(fp, "%s\n", content);
1974 * process init 'pick'
1976 void EndpointAppPBX::action_init_pick(void)
1978 struct route_param *rparam;
1979 char *extensions = NULL;
1981 if ((rparam = routeparam(e_action, PARAM_EXTENSIONS)))
1982 extensions = rparam->string_value;
1984 trace_header("ACTION pick", DIRECTION_NONE);
1985 if (extensions) if (extensions[0])
1986 add_trace("extensions", NULL, "%s", extensions);
1988 pick_join(extensions);
1993 * process dialing 'password'
1995 void EndpointAppPBX::action_dialing_password(void)
1997 struct port_list *portlist = ea_endpoint->ep_portlist;
1999 /* prompt for password */
2000 if (e_extdialing[0] == '\0') {
2001 /* give password tone */
2002 set_tone(portlist, "password");
2004 if (e_extdialing[1] == '\0') {
2005 /* give password tone */
2006 set_tone(portlist, "dialing");
2009 /* wait until all digits are dialed */
2010 if (strlen(e_ext.password) != strlen(e_extdialing))
2011 return; /* more digits needed */
2013 /* check the password */
2014 if (e_ext.password[0]=='\0' || (strlen(e_ext.password)==strlen(e_extdialing) && !!strcmp(e_ext.password,e_extdialing))) {
2015 trace_header("ACTION password_write (wrong password)", DIRECTION_NONE);
2016 add_trace("dialed", NULL, "%s", e_extdialing);
2018 e_connectedmode = 0;
2020 new_state(EPOINT_STATE_OUT_DISCONNECT);
2021 message_disconnect_port(portlist, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, "");
2022 set_tone(portlist, "cause_10");
2026 /* write caller id if ACTION_PASSWORD_WRITE was selected */
2028 if (e_action->index == ACTION_PASSWORD_WRITE) {
2029 append_callbackauth(e_ext.number, &e_callbackinfo);
2030 trace_header("ACTION password_write (written)", DIRECTION_NONE);
2031 add_trace("dialed", NULL, "%s", e_extdialing);
2035 /* make call state */
2036 new_state(EPOINT_STATE_IN_OVERLAP);
2037 e_ruleset = ruleset_main;
2039 e_rule = e_ruleset->rule_first;
2041 e_dialinginfo.id[0] = '\0';
2042 e_extdialing = e_dialinginfo.id;
2043 set_tone(portlist, "dialpbx");
2046 void EndpointAppPBX::action_dialing_password_wr(void)
2048 action_dialing_password();
2052 /* process pots-retrieve
2054 void EndpointAppPBX::action_init_pots_retrieve(void)
2056 #ifdef ISDN_P_FXS_POTS
2057 struct route_param *rparam;
2058 struct port_list *portlist = ea_endpoint->ep_portlist;
2060 class Pfxs *ourfxs, *fxs;
2062 class Endpoint *epoint;
2064 /* check given call */
2065 if (!(rparam = routeparam(e_action, PARAM_POTS_CALL))) {
2066 trace_header("ACTION pots-retrieve (no call given)", DIRECTION_NONE);
2070 new_state(EPOINT_STATE_OUT_DISCONNECT);
2071 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "");
2072 set_tone(portlist, "cause_3f");
2078 port = find_port_id(portlist->port_id);
2081 if ((port->p_type & PORT_CLASS_POTS_MASK) != PORT_CLASS_POTS_FXS) {
2082 trace_header("ACTION pots-retrieve (call not of FXS type)", DIRECTION_NONE);
2086 ourfxs = (class Pfxs *)port;
2090 if ((port->p_type & PORT_CLASS_POTS_MASK) == PORT_CLASS_POTS_FXS) {
2091 fxs = (class Pfxs *)port;
2092 if (fxs->p_m_mISDNport == ourfxs->p_m_mISDNport && fxs != ourfxs) {
2094 if (count == rparam->integer_value)
2101 trace_header("ACTION pots-retrieve (call # does not exist)", DIRECTION_NONE);
2106 /* release our call */
2107 ourfxs->hangup_ind(0);
2109 /* retrieve selected call */
2110 fxs->retrieve_ind(0);
2112 /* split if selected call is member of a 3pty */
2113 epoint = find_epoint_id(ACTIVE_EPOINT(fxs->p_epointlist));
2114 if (epoint && epoint->ep_app_type == EAPP_TYPE_PBX) {
2115 PDEBUG(DEBUG_EPOINT, "EPOINT(%d) try spliting 3pty. this may fail because we don't have a 3pty.\n", epoint->ep_serial);
2116 ((class EndpointAppPBX *)epoint->ep_app)->split_3pty();
2122 /* process pots-release
2124 void EndpointAppPBX::action_init_pots_release(void)
2126 #ifdef ISDN_P_FXS_POTS
2127 struct route_param *rparam;
2128 struct port_list *portlist = ea_endpoint->ep_portlist;
2130 class Pfxs *ourfxs, *fxs;
2133 /* check given call */
2134 if (!(rparam = routeparam(e_action, PARAM_POTS_CALL))) {
2135 trace_header("ACTION pots-release (no call given)", DIRECTION_NONE);
2139 new_state(EPOINT_STATE_OUT_DISCONNECT);
2140 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "");
2141 set_tone(portlist, "cause_3f");
2147 port = find_port_id(portlist->port_id);
2150 if ((port->p_type & PORT_CLASS_POTS_MASK) != PORT_CLASS_POTS_FXS) {
2151 trace_header("ACTION pots-release (call not of FXS type)", DIRECTION_NONE);
2155 ourfxs = (class Pfxs *)port;
2159 if ((port->p_type & PORT_CLASS_POTS_MASK) == PORT_CLASS_POTS_FXS) {
2160 fxs = (class Pfxs *)port;
2161 if (fxs->p_m_mISDNport == ourfxs->p_m_mISDNport && fxs != ourfxs) {
2163 if (count == rparam->integer_value)
2170 trace_header("ACTION pots-release (call # does not exist)", DIRECTION_NONE);
2176 /* disconnect our call */
2177 new_state(EPOINT_STATE_OUT_DISCONNECT);
2178 message_disconnect_port(portlist, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, "");
2179 set_tone(portlist, "hangup");
2183 /* release selected call */
2186 /* indicate timeout, so next action will be processed */
2192 /* process pots-reject
2194 void EndpointAppPBX::action_init_pots_reject(void)
2196 #ifdef ISDN_P_FXS_POTS
2197 struct port_list *portlist = ea_endpoint->ep_portlist;
2199 class Pfxs *ourfxs, *fxs;
2202 port = find_port_id(portlist->port_id);
2205 if ((port->p_type & PORT_CLASS_POTS_MASK) != PORT_CLASS_POTS_FXS) {
2206 trace_header("ACTION pots-reject (call not of FXS type)", DIRECTION_NONE);
2209 new_state(EPOINT_STATE_OUT_DISCONNECT);
2210 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "");
2211 set_tone(portlist, "cause_3f");
2215 ourfxs = (class Pfxs *)port;
2219 if ((port->p_type & PORT_CLASS_POTS_MASK) == PORT_CLASS_POTS_FXS) {
2220 fxs = (class Pfxs *)port;
2221 if (fxs->p_m_mISDNport == ourfxs->p_m_mISDNport && fxs != ourfxs) {
2222 if (fxs->p_state == PORT_STATE_OUT_ALERTING)
2229 trace_header("ACTION pots-reject (no call waiting)", DIRECTION_NONE);
2234 /* reject alerting call */
2237 /* indicate timeout, so next action will be processed */
2243 /* process pots-answer
2245 void EndpointAppPBX::action_init_pots_answer(void)
2247 #ifdef ISDN_P_FXS_POTS
2248 struct port_list *portlist = ea_endpoint->ep_portlist;
2250 class Pfxs *ourfxs, *fxs;
2253 port = find_port_id(portlist->port_id);
2256 if ((port->p_type & PORT_CLASS_POTS_MASK) != PORT_CLASS_POTS_FXS) {
2257 trace_header("ACTION pots-answer (call not of FXS type)", DIRECTION_NONE);
2260 new_state(EPOINT_STATE_OUT_DISCONNECT);
2261 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "");
2262 set_tone(portlist, "cause_3f");
2266 ourfxs = (class Pfxs *)port;
2270 if ((port->p_type & PORT_CLASS_POTS_MASK) == PORT_CLASS_POTS_FXS) {
2271 fxs = (class Pfxs *)port;
2272 if (fxs->p_m_mISDNport == ourfxs->p_m_mISDNport && fxs != ourfxs) {
2273 if (fxs->p_state == PORT_STATE_OUT_ALERTING)
2280 trace_header("ACTION pots-answer (no call waiting)", DIRECTION_NONE);
2285 /* release our call */
2286 ourfxs->hangup_ind(0);
2288 /* answer alerting call */
2294 /* process pots-3pty
2296 void EndpointAppPBX::action_init_pots_3pty(void)
2298 #ifdef ISDN_P_FXS_POTS
2299 struct port_list *portlist = ea_endpoint->ep_portlist;
2301 class Pfxs *ourfxs, *fxs, *fxs1 = NULL, *fxs2 = NULL;
2302 class Endpoint *epoint;
2306 port = find_port_id(portlist->port_id);
2309 if ((port->p_type & PORT_CLASS_POTS_MASK) != PORT_CLASS_POTS_FXS) {
2310 trace_header("ACTION pots-3pty (call not of FXS type)", DIRECTION_NONE);
2313 new_state(EPOINT_STATE_OUT_DISCONNECT);
2314 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "");
2315 set_tone(portlist, "cause_3f");
2319 ourfxs = (class Pfxs *)port;
2323 if ((port->p_type & PORT_CLASS_POTS_MASK) == PORT_CLASS_POTS_FXS) {
2324 fxs = (class Pfxs *)port;
2325 if (fxs->p_m_mISDNport == ourfxs->p_m_mISDNport && fxs != ourfxs) {
2336 trace_header("ACTION pots-3pty (exactly two calls don't exist)", DIRECTION_NONE);
2341 /* release our call */
2342 ourfxs->hangup_ind(0);
2344 /* retrieve latest active call */
2345 if (fxs2->p_m_fxs_age > fxs1->p_m_fxs_age) {
2346 fxs2->retrieve_ind(0);
2347 epoint = find_epoint_id(ACTIVE_EPOINT(fxs2->p_epointlist));
2349 fxs1->retrieve_ind(0);
2350 epoint = find_epoint_id(ACTIVE_EPOINT(fxs2->p_epointlist));
2354 trace_header("ACTION pots-3pty (interal error: no endpoint)", DIRECTION_NONE);
2359 if (epoint->ep_app_type != EAPP_TYPE_PBX) {
2360 trace_header("ACTION pots-3pty (interal error: endpoint not PBX type)", DIRECTION_NONE);
2366 if (((class EndpointAppPBX *)epoint->ep_app)->join_3pty_fxs()) {
2367 trace_header("ACTION pots-3pty (interal error: join_3pty_fsx failed)", DIRECTION_NONE);
2374 /* process pots-transfer
2376 void EndpointAppPBX::action_init_pots_transfer(void)
2378 #ifdef ISDN_P_FXS_POTS
2379 struct route_param *rparam;
2380 struct port_list *portlist = ea_endpoint->ep_portlist;
2382 class Pfxs *ourfxs, *fxs, *fxs1 = NULL, *fxs2 = NULL;
2385 /* check given call */
2386 if (!(rparam = routeparam(e_action, PARAM_POTS_CALL))) {
2387 trace_header("ACTION pots-transfer (no call given)", DIRECTION_NONE);
2391 new_state(EPOINT_STATE_OUT_DISCONNECT);
2392 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "");
2393 set_tone(portlist, "cause_3f");
2399 port = find_port_id(portlist->port_id);
2402 if ((port->p_type & PORT_CLASS_POTS_MASK) != PORT_CLASS_POTS_FXS) {
2403 trace_header("ACTION pots-transfer (call not of FXS type)", DIRECTION_NONE);
2407 ourfxs = (class Pfxs *)port;
2411 if ((port->p_type & PORT_CLASS_POTS_MASK) == PORT_CLASS_POTS_FXS) {
2412 fxs = (class Pfxs *)port;
2413 if (fxs->p_m_mISDNport == ourfxs->p_m_mISDNport && fxs != ourfxs) {
2424 trace_header("ACTION pots-transfer (exactly two calls don't exist)", DIRECTION_NONE);
2430 if (fxs2->p_m_fxs_age > fxs1->p_m_fxs_age)
2431 fxs2->retrieve_ind(0);
2433 fxs1->retrieve_ind(0);
2440 /* general process dialing of incoming call
2441 * depending on the detected prefix, subfunctions above (action_*) will be
2444 void EndpointAppPBX::process_dialing(int timeout)
2446 struct port_list *portlist = ea_endpoint->ep_portlist;
2447 struct lcr_msg *message;
2448 struct route_param *rparam;
2449 struct timeval current_time;
2451 /* set if timeout is active, or if timeout value was given due to timeout action */
2452 if (e_action_timeout.active)
2455 //#warning Due to HANG-BUG somewhere here, I added some HANG-BUG-DEBUGGING output that cannot be disabled. after bug has been found, this will be removed.
2456 //PDEBUG(~0, "HANG-BUG-DEBUGGING: entered porcess_dialing\n");
2457 portlist = ea_endpoint->ep_portlist;
2458 /* check if we have a port instance linked to our epoint */
2461 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): note: dialing call requires exactly one port object to process dialing. this case could happen due to a parked call. we end dialing here.\n", ea_endpoint->ep_serial, e_ext.number);
2462 unsched_timer(&e_action_timeout);
2463 unsched_timer(&e_match_timeout);
2466 if (portlist->next) {
2467 goto portlist_error;
2470 /* check nesting levels */
2471 if (++e_rule_nesting > RULE_NESTING) {
2472 trace_header("ACTION (nesting too deep)", DIRECTION_NONE);
2473 add_trace("max-levels", NULL, "%d", RULE_NESTING);
2475 new_state(EPOINT_STATE_OUT_DISCONNECT);
2476 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "");
2477 set_tone(portlist, "cause_3f");
2478 unsched_timer(&e_action_timeout);
2479 unsched_timer(&e_match_timeout);
2483 //PDEBUG(~0, "HANG-BUG-DEBUGGING: before action-timeout processing\n");
2484 /* process timeout */
2485 if (e_action && timeout) { /* e_action may be NULL, but e_action_timeout may still be set and must be ignored */
2486 unsched_timer(&e_action_timeout);
2487 if (e_state == EPOINT_STATE_CONNECT) {
2488 PDEBUG(DEBUG_ROUTE|DEBUG_EPOINT, "EPOINT(%d): action timed out, but we already have connected, so we stop timer and continue.\n", ea_endpoint->ep_serial);
2491 if (e_action->index == ACTION_DISCONNECT
2492 || e_state == EPOINT_STATE_OUT_DISCONNECT) {
2493 /* release after disconnect */
2494 release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, 0);
2497 release(RELEASE_JOIN, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, 0, 0, 0);
2498 e_action = e_action->next;
2500 /* nothing more, so we release */
2501 PDEBUG(DEBUG_ROUTE|DEBUG_EPOINT, "EPOINT(%d): action timed out, and we have no next action, so we disconnect.\n", ea_endpoint->ep_serial);
2502 new_state(EPOINT_STATE_OUT_DISCONNECT);
2503 message_disconnect_port(portlist, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, "");
2504 set_tone(portlist, "cause_3f");
2507 goto action_timeout;
2510 //PDEBUG(~0, "HANG-BUG-DEBUGGING: before setup/overlap state checking\n");
2511 if (e_state!=EPOINT_STATE_IN_SETUP
2512 && e_state!=EPOINT_STATE_IN_OVERLAP) {
2513 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): we are not in incoming setup/overlap state, so we ignore init/dialing process.\n", ea_endpoint->ep_serial, e_rule_nesting);
2514 unsched_timer(&e_match_timeout);
2519 /* check if we do menu selection */
2520 if (e_action==NUMB_ACTION_NONE && (e_dialinginfo.id[0]=='*' || e_dialinginfo.id[0]=='#'))
2521 /* do menu selection */
2522 if (e_ext.display_menu) {
2523 if (portlist->port_type==PORT_TYPE_DSS1_NT_IN || portlist->port_type==PORT_TYPE_DSS1_NT_OUT) { /* only if the dialing terminal is an isdn telephone connected to an internal port */
2524 e_dialinginfo.id[0] = '\0';
2525 e_action = NUMB_ACTION_MENU;
2528 unsched_timer(&e_match_timeout);
2531 /* invalid dialing */
2532 message_disconnect_port(portlist, CAUSE_INCALID, LOCATION_PRIVATE_LOCAL, "");
2533 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_DISCONNECT);
2534 message->param.disconnectinfo.cause = CAUSE_INVALID;
2535 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
2537 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY);
2538 SCPY(message->param.notifyinfo.display,get_isdn_cause(LOCATION_PRIVATE_LOCAL, epoint->e_ext.display_cause, param->disconnectinfo.location, param->disconnectinfo.cause));
2540 message_put(message);
2541 logmessage(message->type, message->param, portlist->port_id, DIRECTION_OUT);
2543 new_state(EPOINT_STATE_OUT_DISCONNECT);
2544 set_tone(portlist,"cause_1c");
2545 unsched_timer(&e_match_timeout);
2550 //PDEBUG(~0, "HANG-BUG-DEBUGGING: before e_action==NULL\n");
2551 /* if no action yet, we will call try to find a matching rule */
2553 /* be sure that all selectors are initialized */
2556 /* check for external call */
2557 if (!strncmp(e_dialinginfo.id, "extern:", 7)) {
2558 e_extdialing = e_dialinginfo.id+7;
2559 e_action = &action_external;
2560 goto process_action;
2562 /* check for internal call */
2563 if (!strncmp(e_dialinginfo.id, "intern:", 7)) {
2564 e_extdialing = e_dialinginfo.id+7;
2565 e_action = &action_internal;
2566 goto process_action;
2568 /* check for vbox call */
2569 if (!strncmp(e_dialinginfo.id, "vbox:", 5)) {
2570 e_extdialing = e_dialinginfo.id+5;
2571 e_action = &action_vbox;
2572 goto process_action;
2575 gettimeofday(¤t_time, NULL);
2576 if (e_match_to_action && TIME_SMALLER(&e_match_timeout.timeout, ¤t_time)) {
2577 /* return timeout rule */
2578 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s' dialing: '%s', timeout in ruleset '%s'\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id, e_ruleset->name);
2579 unsched_timer(&e_match_timeout);
2580 e_action = e_match_to_action;
2581 e_match_to_action = NULL;
2582 e_extdialing = e_match_to_extdialing;
2583 trace_header("ROUTING (timeout)", DIRECTION_NONE);
2584 add_trace("action", NULL, "%s", action_defs[e_action->index].name);
2585 add_trace("line", NULL, "%d", e_action->line);
2588 //PDEBUG(~0, "HANG-BUG-DEBUGGING: before routing\n");
2589 /* check for matching rule */
2590 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s' dialing: '%s', checking matching rule of ruleset '%s'\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id, e_ruleset->name);
2592 e_action = route(e_ruleset);
2594 trace_header("ACTION (match)", DIRECTION_NONE);
2595 add_trace("action", NULL, "%s", action_defs[e_action->index].name);
2596 add_trace("line", NULL, "%d", e_action->line);
2600 e_action = &action_disconnect;
2602 trace_header("ACTION (no main ruleset, disconnecting)", DIRECTION_NONE);
2606 //PDEBUG(~0, "HANG-BUG-DEBUGGING: after routing\n");
2609 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): no rule within the current ruleset matches yet.\n", ea_endpoint->ep_serial, e_ext.number);
2614 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): a rule with action '%s' matches.\n", ea_endpoint->ep_serial, action_defs[e_action->index].name);
2619 unsched_timer(&e_action_timeout);
2620 if (e_action->timeout) {
2621 schedule_timer(&e_action_timeout, e_action->timeout, 0);
2622 PDEBUG(DEBUG_ROUTE|DEBUG_EPOINT, "EPOINT(%d): action has a timeout of %d secods.\n", ea_endpoint->ep_serial, e_action->timeout);
2626 /* check param proceeding / alerting / connect */
2627 if ((rparam = routeparam(e_action, PARAM_CONNECT))) {
2628 /* NOTE: we may not change our state to connect, because dialing will then not possible */
2630 memset(&e_connectinfo, 0, sizeof(e_connectinfo));
2631 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT);
2632 message_put(message);
2633 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
2635 if ((rparam = routeparam(e_action, PARAM_ALERTING))) {
2636 /* NOTE: we may not change our state to alerting, because dialing will then not possible */
2637 memset(&e_connectinfo, 0, sizeof(e_connectinfo));
2638 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_ALERTING);
2639 message_put(message);
2640 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
2642 if ((rparam = routeparam(e_action, PARAM_PROCEEDING))) {
2643 /* NOTE: we may not change our state to proceeding, because dialing will then not possible */
2644 memset(&e_connectinfo, 0, sizeof(e_connectinfo));
2645 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_PROCEEDING);
2646 message_put(message);
2647 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
2650 if (action_defs[e_action->index].init_func) {
2651 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: current action '%s' has a init function, so we call it...\n", ea_endpoint->ep_serial, e_ext.number, action_defs[e_action->index].name);
2652 (this->*(action_defs[e_action->index].init_func))();
2654 if (e_state!=EPOINT_STATE_IN_SETUP
2655 && e_state!=EPOINT_STATE_IN_OVERLAP) {
2656 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): AFTER init process: we are not in incoming setup/overlap state anymore, so we ignore further dialing process.\n", ea_endpoint->ep_serial, e_rule_nesting);
2657 goto display_action;
2661 /* show what we are doing */
2662 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s' action: %s (dialing '%s')\n", ea_endpoint->ep_serial, e_ext.number, action_defs[e_action->index].name, e_extdialing);
2663 /* go to action's dialing function */
2664 if (action_defs[e_action->index].dialing_func) {
2665 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: current action '%s' has a dialing function, so we call it...\n", ea_endpoint->ep_serial, e_ext.number, action_defs[e_action->index].name);
2666 (this->*(action_defs[e_action->index].dialing_func))();
2669 /* display selected dialing action if enabled and still in setup state */
2672 if (e_action->index==ACTION_MENU
2673 || e_action->index==ACTION_REDIAL
2674 || e_action->index==ACTION_REPLY
2675 || e_action->index==ACTION_TIMER
2676 || e_action->index==ACTION_CALCULATOR
2677 || e_action->index==ACTION_TEST)
2681 if (!e_ext.display_dialing)
2683 if (e_state==EPOINT_STATE_IN_OVERLAP || e_state==EPOINT_STATE_IN_PROCEEDING || e_state==EPOINT_STATE_IN_ALERTING || e_state==EPOINT_STATE_CONNECT/* || e_state==EPOINT_STATE_IN_DISCONNECT || e_state==EPOINT_STATE_OUT_DISCONNECT*/)
2684 if (portlist->port_type==PORT_TYPE_DSS1_NT_IN || portlist->port_type==PORT_TYPE_DSS1_NT_OUT) { /* only if the dialing terminal is an isdn telephone connected to an internal port */
2685 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY);
2688 SPRINT(message->param.notifyinfo.display, "> %s", e_dialinginfo.id);
2690 SPRINT(message->param.notifyinfo.display, "%s%s%s", action_defs[e_action->index].name, (e_extdialing[0])?" ":"", e_extdialing);
2693 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s displaying interpreted dialing '%s'\n", ea_endpoint->ep_serial, e_ext.number, message->param.notifyinfo.display);
2694 message_put(message);
2695 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
2704 /* some services store information after hangup */
2705 void EndpointAppPBX::process_hangup(int cause, int location)
2707 char callertext[256], dialingtext[256];
2708 int writeext = 0, i;
2710 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s'\n", ea_endpoint->ep_serial, e_ext.number);
2711 if (e_ext.number[0]) {
2712 if (read_extension(&e_ext, e_ext.number))
2721 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): writing connect from %s to %s into logfile of %s\n", ea_endpoint->ep_serial, e_callerinfo.id, e_dialinginfo.id, e_ext.number);
2722 switch(e_dialinginfo.itype) {
2723 case INFO_ITYPE_CHAN:
2724 SPRINT(dialingtext, "chan:%s", e_dialinginfo.id);
2726 case INFO_ITYPE_ISDN_EXTENSION:
2727 SPRINT(dialingtext, "intern:%s", e_dialinginfo.id);
2729 case INFO_ITYPE_VBOX:
2730 SPRINT(dialingtext, "vbox:%s", e_dialinginfo.id);
2733 SPRINT(dialingtext, "%s", e_dialinginfo.id);
2736 if (e_callerinfo.id[0])
2737 SPRINT(callertext, "%s", numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype, options.national, options.international));
2739 SPRINT(callertext, "unknown");
2740 /* allpy restriction */
2741 if (!e_ext.anon_ignore && e_callerinfo.present==INFO_PRESENT_RESTRICTED)
2742 SPRINT(callertext, "anonymous");
2743 if (e_callerinfo.extension[0]) /* add intern if present */
2744 UNPRINT(strchr(callertext,'\0'), sizeof(callertext)-1+strlen(callertext), " (intern %s)", e_callerinfo.extension);
2745 write_log(e_ext.number, callertext, dialingtext, e_start, e_stop, 0, cause, location);
2747 /* store last received call for reply-list */
2748 if (e_origin == 1) // outgoing to phone is incoming for user
2749 if (e_callerinfo.id[0] || e_callerinfo.extension[0])
2750 if (e_ext.anon_ignore || e_callerinfo.present!=INFO_PRESENT_RESTRICTED) {
2751 if (e_callerinfo.extension[0])
2752 SPRINT(callertext, "intern:%s", e_callerinfo.extension);
2754 SPRINT(callertext, "extern:%s", numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype, options.national, options.international));
2755 if (!!strcmp(callertext, e_ext.last_in[0])) {
2758 UCPY(e_ext.last_in[i], e_ext.last_in[i-1]);
2761 SCPY(e_ext.last_in[0], callertext);
2762 writeext |= 1; /* store extension later */
2763 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing last received caller id '%s'.\n", ea_endpoint->ep_serial, e_ext.number, e_ext.last_in[0]);
2765 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last received id '%s' because it is identical with the last one.\n", ea_endpoint->ep_serial, e_ext.number, callertext);
2768 /* store last made call for reply-list */
2769 if (e_origin == 0) // incoming from phone is outgoing for user
2770 if (e_dialinginfo.id[0]) {
2771 if (!!strcmp(e_dialinginfo.id, e_ext.last_out[0])) {
2774 UCPY(e_ext.last_out[i], e_ext.last_out[i-1]);
2777 SCPY(e_ext.last_out[0], e_dialinginfo.id);
2778 writeext |= 1; /* store extension later */
2779 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing last number '%s'.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id);
2781 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last number '%s' because it is identical with the last one.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id);
2784 /* write extension if needed */
2785 if (writeext == 0x11)
2786 write_extension(&e_ext, e_ext.number);
2789 if (action_defs[e_action->index].hangup_func) {
2790 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: current action '%s' has a hangup function, so we call it...\n", ea_endpoint->ep_serial, e_ext.number, action_defs[e_action->index].name);
2791 (this->*(action_defs[e_action->index].hangup_func))();