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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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, "", NULL);
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_dialinginfo.sending_complete = 0;
1591 e_extdialing = e_dialinginfo.id;
1593 /* remove digits that are required to match the rule */
1594 if ((rparam = routeparam(e_action, PARAM_STRIP))) {
1596 SCPY(e_dialinginfo.id, e_extdialing);
1597 e_extdialing = e_dialinginfo.id;
1600 if ((rparam = routeparam(e_action, PARAM_PREFIX))) {
1601 char extdialing[256];
1602 SCPY(extdialing, e_extdialing);
1603 SPRINT(e_dialinginfo.id, "%s%s", rparam->string_value, extdialing);
1604 e_extdialing = e_dialinginfo.id;
1610 trace_header("ACTION goto/menu (change to)", DIRECTION_NONE);
1611 add_trace("ruleset", NULL, "%s", e_ruleset->name);
1612 if (e_dialinginfo.id[0]) {
1613 add_trace("dialing", NULL, "%s", e_dialinginfo.id);
1615 if ((rparam = routeparam(e_action, PARAM_SAMPLE))) {
1616 add_trace("sample", NULL, "%s", rparam->string_value);
1618 set_tone(ea_endpoint->ep_portlist, rparam->string_value);
1623 /* do dialing with new ruleset */
1628 /* process dialing goto
1630 void EndpointAppPBX::action_dialing_goto(void)
1632 _action_goto_menu(0);
1635 /* process dialing menu
1637 void EndpointAppPBX::action_dialing_menu(void)
1639 _action_goto_menu(1);
1644 * process dialing disconnect
1646 void EndpointAppPBX::action_dialing_disconnect(void)
1648 struct route_param *rparam;
1649 struct port_list *portlist = ea_endpoint->ep_portlist;
1650 struct lcr_msg *message;
1651 int cause = CAUSE_NORMAL; /* normal call clearing */
1652 int location = LOCATION_PRIVATE_LOCAL;
1653 char cause_string[256] = "", display[84] = "";
1655 /* check cause parameter */
1656 if ((rparam = routeparam(e_action, PARAM_CAUSE))) {
1657 cause = rparam->integer_value;
1658 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): 'cause' is given: %d\n", ea_endpoint->ep_serial, cause);
1660 if ((rparam = routeparam(e_action, PARAM_LOCATION))) {
1661 location = rparam->integer_value;
1662 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): 'location' is given: %d\n", ea_endpoint->ep_serial, location);
1666 /* use cause as sample, if not given later */
1667 SPRINT(cause_string, "cause_%02x", cause);
1669 /* check sample parameter */
1670 if ((rparam = routeparam(e_action, PARAM_SAMPLE))) {
1671 SCPY(cause_string, rparam->string_value);
1672 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): 'sample' is given: %s\n", ea_endpoint->ep_serial, cause_string);
1676 if ((rparam = routeparam(e_action, PARAM_DISPLAY))) {
1677 SCPY(display, rparam->string_value);
1678 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): 'display' is given: %s\n", ea_endpoint->ep_serial, display);
1681 /* disconnect only if connect parameter is not given */
1682 trace_header("ACTION disconnect", DIRECTION_NONE);
1683 add_trace("cause", "value", "%d", cause);
1684 add_trace("cause", "location", "%d", location);
1685 if (cause_string[0])
1686 add_trace("sample", NULL, "%s", cause_string);
1688 add_trace("display", NULL, "%s", display);
1690 new_state(EPOINT_STATE_OUT_DISCONNECT);
1691 set_tone(portlist, cause_string);
1692 if (!(rparam = routeparam(e_action, PARAM_CONNECT))) {
1693 message_disconnect_port(portlist, cause, location, display, NULL);
1695 message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY);
1696 SCPY(message->param.notifyinfo.display, display);
1697 message_put(message);
1698 logmessage(message->type, &message->param, ea_endpoint->ep_portlist->port_id, DIRECTION_OUT);
1705 * process dialing release
1707 void EndpointAppPBX::action_dialing_release(void)
1709 struct route_param *rparam;
1710 int cause = CAUSE_NORMAL; /* normal call clearing */
1711 int location = LOCATION_PRIVATE_LOCAL;
1712 char cause_string[256] = "", display[84] = "";
1714 /* check cause parameter */
1715 if ((rparam = routeparam(e_action, PARAM_CAUSE))) {
1716 cause = rparam->integer_value;
1717 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): 'cause' is given: %d\n", ea_endpoint->ep_serial, cause);
1719 if ((rparam = routeparam(e_action, PARAM_LOCATION))) {
1720 location = rparam->integer_value;
1721 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): 'location' is given: %d\n", ea_endpoint->ep_serial, location);
1725 /* use cause as sample, if not given later */
1726 SPRINT(cause_string, "cause_%02x", cause);
1729 if ((rparam = routeparam(e_action, PARAM_DISPLAY))) {
1730 SCPY(display, rparam->string_value);
1731 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): 'display' is given: %s\n", ea_endpoint->ep_serial, display);
1734 /* disconnect only if connect parameter is not given */
1735 trace_header("ACTION release", DIRECTION_NONE);
1736 add_trace("cause", "value", "%d", cause);
1737 add_trace("cause", "location", "%d", location);
1739 add_trace("display", NULL, "%s", display);
1742 release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, location, cause, 1);
1747 * process dialing help
1749 void EndpointAppPBX::action_dialing_help(void)
1751 /* show all things that would match */
1753 struct numbering *numbering = numbering_int;
1754 char dialing[sizeof(e_dialinginfo.id)];
1756 struct lcr_msg *message;
1757 struct route_param *rparam;
1759 /* in case we have no menu (this should never happen) */
1764 if (strchr(e_dialinginfo.id,'*')) {
1766 e_dialinginfo.id[0] = '\0';
1768 if (strchr(e_dialinginfo.id,'#')) {
1770 e_dialinginfo.id[0] = '\0';
1773 /* get position in menu */
1775 /* get last menu position */
1777 while(numbering->next) {
1779 numbering = numbering->next;
1782 /* get menu position */
1785 numbering = numbering->next;
1788 numbering = numbering_int;
1795 /* if we dial something else we need to add the prefix and change the action */
1796 if (e_dialinginfo.id[0]) {
1797 e_action = NUMB_ACTION_NONE;
1798 SCPY(dialing, numbering->prefix);
1799 //we ignore the first digit after selecting
1800 //SCAT(dialing, e_dialinginfo.id);
1801 SCPY(e_dialinginfo.id, dialing);
1802 e_extdialing = e_dialinginfo.id+strlen(numbering->prefix);
1803 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);
1809 /* send display message to port */
1810 message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY);
1811 SPRINT(message->param.notifyinfo.display, ">%s %s%s%s", numbering->prefix, numb_actions[numbering->action], (numbering->param[0])?" ":"", numbering->param);
1812 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);
1813 message_put(message);
1814 logmessage(message->type, message->paramea_endpoint->ep_portlist->port_id, DIRECTION_OUT);
1820 * process dialing deflect
1822 void EndpointAppPBX::action_dialing_deflect(void)
1828 * process dialing setforward
1830 void EndpointAppPBX::action_dialing_setforward(void)
1835 * process init 'execute'
1837 void EndpointAppPBX::action_init_execute(void)
1839 struct route_param *rparam;
1840 int executeon = INFO_ON_HANGUP; /* Use Hangup as a default for compatibility */
1842 /* Get the execute on parameter */
1843 if ((rparam = routeparam(e_action, PARAM_ON)))
1844 executeon = rparam->integer_value;
1846 /* Execute this action if init was specified */
1847 if (executeon == INFO_ON_INIT) {
1848 trace_header("ACTION execute ON init", DIRECTION_NONE);
1855 * process hangup 'execute'
1857 void EndpointAppPBX::action_hangup_execute(void)
1859 struct route_param *rparam;
1860 int executeon = INFO_ON_HANGUP; /* Use Hangup as a default for compatibility */
1862 /* Get the execute on parameter */
1863 if ((rparam = routeparam(e_action, PARAM_ON)))
1864 executeon = rparam->integer_value;
1866 /* Execute this action if init was specified */
1867 if (executeon == INFO_ON_HANGUP) {
1868 trace_header("ACTION execute ON hangup", DIRECTION_NONE);
1875 * process 'execute' from action_init_execute or action_hangup_execute
1877 void EndpointAppPBX::action_execute(void)
1879 struct route_param *rparam;
1883 char *command = (char *)"";
1885 char *argv[12]; /* check also number of args below */
1888 /* get script / command */
1889 if ((rparam = routeparam(e_action, PARAM_EXECUTE)))
1890 command = rparam->string_value;
1891 if (command[0] == '\0') {
1892 trace_header("ACTION execute (no parameter given)", DIRECTION_NONE);
1897 argv[i++] = (char *)"/bin/sh";
1898 argv[i++] = (char *)"-c";
1899 argv[i++] = command;
1901 argv[i++] = command;
1902 if ((rparam = routeparam(e_action, PARAM_PARAM))) {
1903 argv[i++] = rparam->string_value;
1905 argv[i++] = e_extdialing;
1906 argv[i++] = (char *)numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype, options.national, options.international);
1907 argv[i++] = e_callerinfo.extension;
1908 argv[i++] = e_callerinfo.name;
1909 SPRINT(isdn_port, "%d", e_callerinfo.isdn_port);
1910 argv[i++] = isdn_port;
1911 argv[i++] = e_callerinfo.imsi;
1912 argv[i++] = NULL; /* check also number of args above */
1913 switch (pid = fork ()) {
1915 trace_header("ACTION execute (fork failed)", DIRECTION_NONE);
1919 /* To be shure there are no zombies created double fork */
1920 if ((pid2 = fork()) == 0) {
1921 execve(command, argv, environ);
1923 /* Exit immediately and release the waiting parent. The subprocess falls to init because the parent died */
1927 trace_header("ACTION execute", DIRECTION_NONE);
1928 add_trace("command", NULL, "%s", command);
1931 /* Wait for the pid. The forked process will exit immediately so there is no problem waiting. */
1932 waitpid(pid, &iWaitStatus, 0);
1939 * process hangup 'file'
1941 void EndpointAppPBX::action_hangup_file(void)
1943 struct route_param *rparam;
1944 const char *file, *content, *mode;
1947 /* get file / content */
1948 if (!(rparam = routeparam(e_action, PARAM_FILE)))
1949 file = rparam->string_value;
1952 if (!(rparam = routeparam(e_action, PARAM_CONTENT)))
1953 content = rparam->string_value;
1955 content = e_extdialing;
1956 if (!(rparam = routeparam(e_action, PARAM_APPEND)))
1960 if (file[0] == '\0') {
1961 trace_header("ACTION file (no filename given)", DIRECTION_NONE);
1965 if (!(fp = fopen(file, mode))) {
1966 trace_header("ACTION file (failed to open)", DIRECTION_NONE);
1967 add_trace("file", "name", "%s", file);
1968 add_trace("file", "mode", "%s", (mode[0]=='w')?"write":"append");
1972 trace_header("ACTION file", DIRECTION_NONE);
1973 add_trace("file", "name", "%s", file);
1974 add_trace("file", "mode", "%s", (mode[0]=='w')?"write":"append");
1975 add_trace("content", NULL, "%s", content);
1977 fprintf(fp, "%s\n", content);
1983 * process init 'pick'
1985 void EndpointAppPBX::action_init_pick(void)
1987 struct route_param *rparam;
1988 char *extensions = NULL;
1990 if ((rparam = routeparam(e_action, PARAM_EXTENSIONS)))
1991 extensions = rparam->string_value;
1993 trace_header("ACTION pick", DIRECTION_NONE);
1994 if (extensions) if (extensions[0])
1995 add_trace("extensions", NULL, "%s", extensions);
1997 pick_join(extensions);
2002 * process dialing 'password'
2004 void EndpointAppPBX::action_dialing_password(void)
2006 struct port_list *portlist = ea_endpoint->ep_portlist;
2008 /* prompt for password */
2009 if (e_extdialing[0] == '\0') {
2010 /* give password tone */
2011 set_tone(portlist, "password");
2013 if (e_extdialing[1] == '\0') {
2014 /* give password tone */
2015 set_tone(portlist, "dialing");
2018 /* wait until all digits are dialed */
2019 if (strlen(e_ext.password) != strlen(e_extdialing))
2020 return; /* more digits needed */
2022 /* check the password */
2023 if (e_ext.password[0]=='\0' || (strlen(e_ext.password)==strlen(e_extdialing) && !!strcmp(e_ext.password,e_extdialing))) {
2024 trace_header("ACTION password_write (wrong password)", DIRECTION_NONE);
2025 add_trace("dialed", NULL, "%s", e_extdialing);
2027 e_connectedmode = 0;
2029 new_state(EPOINT_STATE_OUT_DISCONNECT);
2030 message_disconnect_port(portlist, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, "", NULL);
2031 set_tone(portlist, "cause_10");
2035 /* write caller id if ACTION_PASSWORD_WRITE was selected */
2037 if (e_action->index == ACTION_PASSWORD_WRITE) {
2038 append_callbackauth(e_ext.number, &e_callbackinfo);
2039 trace_header("ACTION password_write (written)", DIRECTION_NONE);
2040 add_trace("dialed", NULL, "%s", e_extdialing);
2044 /* make call state */
2045 new_state(EPOINT_STATE_IN_OVERLAP);
2046 e_ruleset = ruleset_main;
2048 e_rule = e_ruleset->rule_first;
2050 e_dialinginfo.id[0] = '\0';
2051 e_extdialing = e_dialinginfo.id;
2052 set_tone(portlist, "dialpbx");
2055 void EndpointAppPBX::action_dialing_password_wr(void)
2057 action_dialing_password();
2061 /* process pots-retrieve
2063 void EndpointAppPBX::action_init_pots_retrieve(void)
2065 #ifdef ISDN_P_FXS_POTS
2066 struct route_param *rparam;
2067 struct port_list *portlist = ea_endpoint->ep_portlist;
2069 class Pfxs *ourfxs, *fxs;
2071 class Endpoint *epoint;
2073 /* check given call */
2074 if (!(rparam = routeparam(e_action, PARAM_POTS_CALL))) {
2075 trace_header("ACTION pots-retrieve (no call given)", DIRECTION_NONE);
2079 new_state(EPOINT_STATE_OUT_DISCONNECT);
2080 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "", NULL);
2081 set_tone(portlist, "cause_3f");
2087 port = find_port_id(portlist->port_id);
2090 if ((port->p_type & PORT_CLASS_POTS_MASK) != PORT_CLASS_POTS_FXS) {
2091 trace_header("ACTION pots-retrieve (call not of FXS type)", DIRECTION_NONE);
2095 ourfxs = (class Pfxs *)port;
2099 if ((port->p_type & PORT_CLASS_POTS_MASK) == PORT_CLASS_POTS_FXS) {
2100 fxs = (class Pfxs *)port;
2101 if (fxs->p_m_mISDNport == ourfxs->p_m_mISDNport && fxs != ourfxs) {
2103 if (count == rparam->integer_value)
2110 trace_header("ACTION pots-retrieve (call # does not exist)", DIRECTION_NONE);
2115 /* release our call */
2116 ourfxs->hangup_ind(0);
2118 /* retrieve selected call */
2119 fxs->retrieve_ind(0);
2121 /* split if selected call is member of a 3pty */
2122 epoint = find_epoint_id(ACTIVE_EPOINT(fxs->p_epointlist));
2123 if (epoint && epoint->ep_app_type == EAPP_TYPE_PBX) {
2124 PDEBUG(DEBUG_EPOINT, "EPOINT(%d) try spliting 3pty. this may fail because we don't have a 3pty.\n", epoint->ep_serial);
2125 ((class EndpointAppPBX *)epoint->ep_app)->split_3pty();
2131 /* process pots-release
2133 void EndpointAppPBX::action_init_pots_release(void)
2135 #ifdef ISDN_P_FXS_POTS
2136 struct route_param *rparam;
2137 struct port_list *portlist = ea_endpoint->ep_portlist;
2139 class Pfxs *ourfxs, *fxs;
2142 /* check given call */
2143 if (!(rparam = routeparam(e_action, PARAM_POTS_CALL))) {
2144 trace_header("ACTION pots-release (no call given)", DIRECTION_NONE);
2148 new_state(EPOINT_STATE_OUT_DISCONNECT);
2149 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "", NULL);
2150 set_tone(portlist, "cause_3f");
2156 port = find_port_id(portlist->port_id);
2159 if ((port->p_type & PORT_CLASS_POTS_MASK) != PORT_CLASS_POTS_FXS) {
2160 trace_header("ACTION pots-release (call not of FXS type)", DIRECTION_NONE);
2164 ourfxs = (class Pfxs *)port;
2168 if ((port->p_type & PORT_CLASS_POTS_MASK) == PORT_CLASS_POTS_FXS) {
2169 fxs = (class Pfxs *)port;
2170 if (fxs->p_m_mISDNport == ourfxs->p_m_mISDNport && fxs != ourfxs) {
2172 if (count == rparam->integer_value)
2179 trace_header("ACTION pots-release (call # does not exist)", DIRECTION_NONE);
2185 /* disconnect our call */
2186 new_state(EPOINT_STATE_OUT_DISCONNECT);
2187 message_disconnect_port(portlist, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, "", NULL);
2188 set_tone(portlist, "hangup");
2192 /* release selected call */
2195 /* indicate timeout, so next action will be processed */
2201 /* process pots-reject
2203 void EndpointAppPBX::action_init_pots_reject(void)
2205 #ifdef ISDN_P_FXS_POTS
2206 struct port_list *portlist = ea_endpoint->ep_portlist;
2208 class Pfxs *ourfxs, *fxs;
2211 port = find_port_id(portlist->port_id);
2214 if ((port->p_type & PORT_CLASS_POTS_MASK) != PORT_CLASS_POTS_FXS) {
2215 trace_header("ACTION pots-reject (call not of FXS type)", DIRECTION_NONE);
2218 new_state(EPOINT_STATE_OUT_DISCONNECT);
2219 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "", NULL);
2220 set_tone(portlist, "cause_3f");
2224 ourfxs = (class Pfxs *)port;
2228 if ((port->p_type & PORT_CLASS_POTS_MASK) == PORT_CLASS_POTS_FXS) {
2229 fxs = (class Pfxs *)port;
2230 if (fxs->p_m_mISDNport == ourfxs->p_m_mISDNport && fxs != ourfxs) {
2231 if (fxs->p_state == PORT_STATE_OUT_ALERTING)
2238 trace_header("ACTION pots-reject (no call waiting)", DIRECTION_NONE);
2243 /* reject alerting call */
2246 /* indicate timeout, so next action will be processed */
2252 /* process pots-answer
2254 void EndpointAppPBX::action_init_pots_answer(void)
2256 #ifdef ISDN_P_FXS_POTS
2257 struct port_list *portlist = ea_endpoint->ep_portlist;
2259 class Pfxs *ourfxs, *fxs;
2262 port = find_port_id(portlist->port_id);
2265 if ((port->p_type & PORT_CLASS_POTS_MASK) != PORT_CLASS_POTS_FXS) {
2266 trace_header("ACTION pots-answer (call not of FXS type)", DIRECTION_NONE);
2269 new_state(EPOINT_STATE_OUT_DISCONNECT);
2270 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "", NULL);
2271 set_tone(portlist, "cause_3f");
2275 ourfxs = (class Pfxs *)port;
2279 if ((port->p_type & PORT_CLASS_POTS_MASK) == PORT_CLASS_POTS_FXS) {
2280 fxs = (class Pfxs *)port;
2281 if (fxs->p_m_mISDNport == ourfxs->p_m_mISDNport && fxs != ourfxs) {
2282 if (fxs->p_state == PORT_STATE_OUT_ALERTING)
2289 trace_header("ACTION pots-answer (no call waiting)", DIRECTION_NONE);
2294 /* release our call */
2295 ourfxs->hangup_ind(0);
2297 /* answer alerting call */
2303 /* process pots-3pty
2305 void EndpointAppPBX::action_init_pots_3pty(void)
2307 #ifdef ISDN_P_FXS_POTS
2308 struct port_list *portlist = ea_endpoint->ep_portlist;
2310 class Pfxs *ourfxs, *fxs, *fxs1 = NULL, *fxs2 = NULL;
2311 class Endpoint *epoint;
2315 port = find_port_id(portlist->port_id);
2318 if ((port->p_type & PORT_CLASS_POTS_MASK) != PORT_CLASS_POTS_FXS) {
2319 trace_header("ACTION pots-3pty (call not of FXS type)", DIRECTION_NONE);
2322 new_state(EPOINT_STATE_OUT_DISCONNECT);
2323 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "", NULL);
2324 set_tone(portlist, "cause_3f");
2328 ourfxs = (class Pfxs *)port;
2332 if ((port->p_type & PORT_CLASS_POTS_MASK) == PORT_CLASS_POTS_FXS) {
2333 fxs = (class Pfxs *)port;
2334 if (fxs->p_m_mISDNport == ourfxs->p_m_mISDNport && fxs != ourfxs) {
2345 trace_header("ACTION pots-3pty (exactly two calls don't exist)", DIRECTION_NONE);
2350 /* release our call */
2351 ourfxs->hangup_ind(0);
2353 /* retrieve latest active call */
2354 if (fxs2->p_m_fxs_age > fxs1->p_m_fxs_age) {
2355 fxs2->retrieve_ind(0);
2356 epoint = find_epoint_id(ACTIVE_EPOINT(fxs2->p_epointlist));
2358 fxs1->retrieve_ind(0);
2359 epoint = find_epoint_id(ACTIVE_EPOINT(fxs2->p_epointlist));
2363 trace_header("ACTION pots-3pty (interal error: no endpoint)", DIRECTION_NONE);
2368 if (epoint->ep_app_type != EAPP_TYPE_PBX) {
2369 trace_header("ACTION pots-3pty (interal error: endpoint not PBX type)", DIRECTION_NONE);
2375 if (((class EndpointAppPBX *)epoint->ep_app)->join_3pty_fxs()) {
2376 trace_header("ACTION pots-3pty (interal error: join_3pty_fsx failed)", DIRECTION_NONE);
2383 /* process pots-transfer
2385 void EndpointAppPBX::action_init_pots_transfer(void)
2387 #ifdef ISDN_P_FXS_POTS
2388 struct route_param *rparam;
2389 struct port_list *portlist = ea_endpoint->ep_portlist;
2391 class Pfxs *ourfxs, *fxs, *fxs1 = NULL, *fxs2 = NULL;
2394 /* check given call */
2395 if (!(rparam = routeparam(e_action, PARAM_POTS_CALL))) {
2396 trace_header("ACTION pots-transfer (no call given)", DIRECTION_NONE);
2400 new_state(EPOINT_STATE_OUT_DISCONNECT);
2401 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "", NULL);
2402 set_tone(portlist, "cause_3f");
2408 port = find_port_id(portlist->port_id);
2411 if ((port->p_type & PORT_CLASS_POTS_MASK) != PORT_CLASS_POTS_FXS) {
2412 trace_header("ACTION pots-transfer (call not of FXS type)", DIRECTION_NONE);
2416 ourfxs = (class Pfxs *)port;
2420 if ((port->p_type & PORT_CLASS_POTS_MASK) == PORT_CLASS_POTS_FXS) {
2421 fxs = (class Pfxs *)port;
2422 if (fxs->p_m_mISDNport == ourfxs->p_m_mISDNport && fxs != ourfxs) {
2433 trace_header("ACTION pots-transfer (exactly two calls don't exist)", DIRECTION_NONE);
2439 if (fxs2->p_m_fxs_age > fxs1->p_m_fxs_age)
2440 fxs2->retrieve_ind(0);
2442 fxs1->retrieve_ind(0);
2449 /* general process dialing of incoming call
2450 * depending on the detected prefix, subfunctions above (action_*) will be
2453 void EndpointAppPBX::process_dialing(int timeout)
2455 struct port_list *portlist = ea_endpoint->ep_portlist;
2456 struct lcr_msg *message;
2457 struct route_param *rparam;
2458 struct timeval current_time;
2460 /* set if timeout is active, or if timeout value was given due to timeout action */
2461 if (e_action_timeout.active)
2464 //#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.
2465 //PDEBUG(~0, "HANG-BUG-DEBUGGING: entered porcess_dialing\n");
2466 portlist = ea_endpoint->ep_portlist;
2467 /* check if we have a port instance linked to our epoint */
2470 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);
2471 unsched_timer(&e_action_timeout);
2472 unsched_timer(&e_match_timeout);
2475 if (portlist->next) {
2476 goto portlist_error;
2479 /* check nesting levels */
2480 if (++e_rule_nesting > RULE_NESTING) {
2481 trace_header("ACTION (nesting too deep)", DIRECTION_NONE);
2482 add_trace("max-levels", NULL, "%d", RULE_NESTING);
2484 new_state(EPOINT_STATE_OUT_DISCONNECT);
2485 message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, "", NULL);
2486 set_tone(portlist, "cause_3f");
2487 unsched_timer(&e_action_timeout);
2488 unsched_timer(&e_match_timeout);
2492 //PDEBUG(~0, "HANG-BUG-DEBUGGING: before action-timeout processing\n");
2493 /* process timeout */
2494 if (e_action && timeout) { /* e_action may be NULL, but e_action_timeout may still be set and must be ignored */
2495 unsched_timer(&e_action_timeout);
2496 if (e_state == EPOINT_STATE_CONNECT) {
2497 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);
2500 if (e_action->index == ACTION_DISCONNECT
2501 || e_state == EPOINT_STATE_OUT_DISCONNECT) {
2502 /* release after disconnect */
2503 release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, 0);
2506 release(RELEASE_JOIN, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, 0, 0, 0);
2507 e_action = e_action->next;
2509 /* nothing more, so we release */
2510 PDEBUG(DEBUG_ROUTE|DEBUG_EPOINT, "EPOINT(%d): action timed out, and we have no next action, so we disconnect.\n", ea_endpoint->ep_serial);
2511 new_state(EPOINT_STATE_OUT_DISCONNECT);
2512 message_disconnect_port(portlist, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, "", NULL);
2513 set_tone(portlist, "cause_3f");
2516 goto action_timeout;
2519 //PDEBUG(~0, "HANG-BUG-DEBUGGING: before setup/overlap state checking\n");
2520 if (e_state!=EPOINT_STATE_IN_SETUP
2521 && e_state!=EPOINT_STATE_IN_OVERLAP) {
2522 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);
2523 unsched_timer(&e_match_timeout);
2528 /* check if we do menu selection */
2529 if (e_action==NUMB_ACTION_NONE && (e_dialinginfo.id[0]=='*' || e_dialinginfo.id[0]=='#'))
2530 /* do menu selection */
2531 if (e_ext.display_menu) {
2532 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 */
2533 e_dialinginfo.id[0] = '\0';
2534 e_action = NUMB_ACTION_MENU;
2537 unsched_timer(&e_match_timeout);
2540 /* invalid dialing */
2541 message_disconnect_port(portlist, CAUSE_INCALID, LOCATION_PRIVATE_LOCAL, "", NULL);
2542 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_DISCONNECT);
2543 message->param.disconnectinfo.cause = CAUSE_INVALID;
2544 message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
2546 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY);
2547 SCPY(message->param.notifyinfo.display,get_isdn_cause(LOCATION_PRIVATE_LOCAL, epoint->e_ext.display_cause, param->disconnectinfo.location, param->disconnectinfo.cause));
2549 message_put(message);
2550 logmessage(message->type, message->param, portlist->port_id, DIRECTION_OUT);
2552 new_state(EPOINT_STATE_OUT_DISCONNECT);
2553 set_tone(portlist,"cause_1c");
2554 unsched_timer(&e_match_timeout);
2559 //PDEBUG(~0, "HANG-BUG-DEBUGGING: before e_action==NULL\n");
2560 /* if no action yet, we will call try to find a matching rule */
2562 /* be sure that all selectors are initialized */
2565 /* check for external call */
2566 if (!strncmp(e_dialinginfo.id, "extern:", 7)) {
2567 e_extdialing = e_dialinginfo.id+7;
2568 e_action = &action_external;
2569 goto process_action;
2571 /* check for internal call */
2572 if (!strncmp(e_dialinginfo.id, "intern:", 7)) {
2573 e_extdialing = e_dialinginfo.id+7;
2574 e_action = &action_internal;
2575 goto process_action;
2577 /* check for vbox call */
2578 if (!strncmp(e_dialinginfo.id, "vbox:", 5)) {
2579 e_extdialing = e_dialinginfo.id+5;
2580 e_action = &action_vbox;
2581 goto process_action;
2584 gettimeofday(¤t_time, NULL);
2585 if (e_match_to_action && TIME_SMALLER(&e_match_timeout.timeout, ¤t_time)) {
2586 /* return timeout rule */
2587 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);
2588 unsched_timer(&e_match_timeout);
2589 e_action = e_match_to_action;
2590 e_match_to_action = NULL;
2591 e_extdialing = e_match_to_extdialing;
2592 trace_header("ROUTING (timeout)", DIRECTION_NONE);
2593 add_trace("action", NULL, "%s", action_defs[e_action->index].name);
2594 add_trace("line", NULL, "%d", e_action->line);
2597 //PDEBUG(~0, "HANG-BUG-DEBUGGING: before routing\n");
2598 /* check for matching rule */
2599 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);
2601 e_action = route(e_ruleset);
2603 trace_header("ACTION (match)", DIRECTION_NONE);
2604 add_trace("action", NULL, "%s", action_defs[e_action->index].name);
2605 add_trace("line", NULL, "%d", e_action->line);
2609 e_action = &action_disconnect;
2611 trace_header("ACTION (no main ruleset, disconnecting)", DIRECTION_NONE);
2615 //PDEBUG(~0, "HANG-BUG-DEBUGGING: after routing\n");
2618 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): no rule within the current ruleset matches yet.\n", ea_endpoint->ep_serial, e_ext.number);
2623 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): a rule with action '%s' matches.\n", ea_endpoint->ep_serial, action_defs[e_action->index].name);
2628 unsched_timer(&e_action_timeout);
2629 if (e_action->timeout) {
2630 schedule_timer(&e_action_timeout, e_action->timeout, 0);
2631 PDEBUG(DEBUG_ROUTE|DEBUG_EPOINT, "EPOINT(%d): action has a timeout of %d secods.\n", ea_endpoint->ep_serial, e_action->timeout);
2635 /* check param proceeding / alerting / connect */
2636 if ((rparam = routeparam(e_action, PARAM_CONNECT))) {
2637 /* NOTE: we may not change our state to connect, because dialing will then not possible */
2639 memset(&e_connectinfo, 0, sizeof(e_connectinfo));
2640 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT);
2641 message_put(message);
2642 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
2644 if ((rparam = routeparam(e_action, PARAM_ALERTING))) {
2645 /* NOTE: we may not change our state to alerting, because dialing will then not possible */
2646 memset(&e_connectinfo, 0, sizeof(e_connectinfo));
2647 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_ALERTING);
2648 message_put(message);
2649 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
2651 if ((rparam = routeparam(e_action, PARAM_PROCEEDING))) {
2652 /* NOTE: we may not change our state to proceeding, because dialing will then not possible */
2653 memset(&e_connectinfo, 0, sizeof(e_connectinfo));
2654 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_PROCEEDING);
2655 message_put(message);
2656 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
2659 if (action_defs[e_action->index].init_func) {
2660 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);
2661 (this->*(action_defs[e_action->index].init_func))();
2663 if (e_state!=EPOINT_STATE_IN_SETUP
2664 && e_state!=EPOINT_STATE_IN_OVERLAP) {
2665 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);
2666 goto display_action;
2670 /* show what we are doing */
2671 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);
2672 /* go to action's dialing function */
2673 if (action_defs[e_action->index].dialing_func) {
2674 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);
2675 (this->*(action_defs[e_action->index].dialing_func))();
2678 /* display selected dialing action if enabled and still in setup state */
2681 if (e_action->index==ACTION_MENU
2682 || e_action->index==ACTION_REDIAL
2683 || e_action->index==ACTION_REPLY
2684 || e_action->index==ACTION_TIMER
2685 || e_action->index==ACTION_CALCULATOR
2686 || e_action->index==ACTION_TEST)
2690 if (!e_ext.display_dialing)
2692 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*/)
2693 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 */
2694 message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY);
2697 SPRINT(message->param.notifyinfo.display, "> %s", e_dialinginfo.id);
2699 SPRINT(message->param.notifyinfo.display, "%s%s%s", action_defs[e_action->index].name, (e_extdialing[0])?" ":"", e_extdialing);
2702 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s displaying interpreted dialing '%s'\n", ea_endpoint->ep_serial, e_ext.number, message->param.notifyinfo.display);
2703 message_put(message);
2704 logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT);
2713 /* some services store information after hangup */
2714 void EndpointAppPBX::process_hangup(int cause, int location)
2716 char callertext[256], dialingtext[256];
2717 int writeext = 0, i;
2719 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s'\n", ea_endpoint->ep_serial, e_ext.number);
2720 if (e_ext.number[0]) {
2721 if (read_extension(&e_ext, e_ext.number))
2730 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);
2731 switch(e_dialinginfo.itype) {
2732 case INFO_ITYPE_CHAN:
2733 SPRINT(dialingtext, "chan:%s", e_dialinginfo.id);
2735 case INFO_ITYPE_ISDN_EXTENSION:
2736 SPRINT(dialingtext, "intern:%s", e_dialinginfo.id);
2738 case INFO_ITYPE_VBOX:
2739 SPRINT(dialingtext, "vbox:%s", e_dialinginfo.id);
2742 SPRINT(dialingtext, "%s", e_dialinginfo.id);
2745 if (e_callerinfo.id[0])
2746 SPRINT(callertext, "%s", numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype, options.national, options.international));
2748 SPRINT(callertext, "unknown");
2749 /* allpy restriction */
2750 if (!e_ext.anon_ignore && e_callerinfo.present==INFO_PRESENT_RESTRICTED)
2751 SPRINT(callertext, "anonymous");
2752 if (e_callerinfo.extension[0]) /* add intern if present */
2753 UNPRINT(strchr(callertext,'\0'), sizeof(callertext)-1+strlen(callertext), " (intern %s)", e_callerinfo.extension);
2754 write_log(e_ext.number, callertext, dialingtext, e_start, e_stop, 0, cause, location);
2756 /* store last received call for reply-list */
2757 if (e_origin == 1) // outgoing to phone is incoming for user
2758 if (e_callerinfo.id[0] || e_callerinfo.extension[0])
2759 if (e_ext.anon_ignore || e_callerinfo.present!=INFO_PRESENT_RESTRICTED) {
2760 if (e_callerinfo.extension[0])
2761 SPRINT(callertext, "intern:%s", e_callerinfo.extension);
2763 SPRINT(callertext, "extern:%s", numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype, options.national, options.international));
2764 if (!!strcmp(callertext, e_ext.last_in[0])) {
2767 UCPY(e_ext.last_in[i], e_ext.last_in[i-1]);
2770 SCPY(e_ext.last_in[0], callertext);
2771 writeext |= 1; /* store extension later */
2772 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]);
2774 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);
2777 /* store last made call for reply-list */
2778 if (e_origin == 0) // incoming from phone is outgoing for user
2779 if (e_dialinginfo.id[0]) {
2780 if (!!strcmp(e_dialinginfo.id, e_ext.last_out[0])) {
2783 UCPY(e_ext.last_out[i], e_ext.last_out[i-1]);
2786 SCPY(e_ext.last_out[0], e_dialinginfo.id);
2787 writeext |= 1; /* store extension later */
2788 PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing last number '%s'.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id);
2790 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);
2793 /* write extension if needed */
2794 if (writeext == 0x11)
2795 write_extension(&e_ext, e_ext.number);
2798 if (action_defs[e_action->index].hangup_func) {
2799 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);
2800 (this->*(action_defs[e_action->index].hangup_func))();