X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=action.cpp;h=7b601268f0c96cefd1bfa10df6657e50e29b61b7;hp=1da910363ce7e4ed435a45125f7eda18b1876c1b;hb=30224b43e26f8b942da6770ac57eb3e17fcb259e;hpb=5b5923141c3ac53d3e63395d9197080d087342f3 diff --git a/action.cpp b/action.cpp index 1da9103..7b60126 100644 --- a/action.cpp +++ b/action.cpp @@ -15,55 +15,26 @@ extern char **environ; /* - * process init 'internal' / 'external' / 'remote' / 'vbox-record' / 'partyline'... + * process init 'internal' / 'external' / 'vbox-record' / 'partyline'... */ -int EndpointAppPBX::_action_init_call(char *remote) +void EndpointAppPBX::action_init_call(void) { class Join *join; - struct port_list *portlist = ea_endpoint->ep_portlist; - struct admin_list *admin; /* a created call, this should never happen */ if (ea_endpoint->ep_join_id) { if (options.deb & DEBUG_EPOINT) PERROR("EPOINT(%d): We already have a call instance, this should never happen!\n", ea_endpoint->ep_serial); - return(0); + return; } /* create join */ PDEBUG(DEBUG_EPOINT, "EPOINT(%d): Creating new join instance.\n", ea_endpoint->ep_serial); - if (remote) { - admin = admin_first; - while(admin) { - if (admin->remote_name[0] && !strcmp(admin->remote_name, remote)) - break; - admin = admin->next; - } - if (!admin) { - /* resource not available */ - trace_header("ACTION remote (not available)", DIRECTION_NONE); - add_trace("application", NULL, "%s", remote); - end_trace(); - message_disconnect_port(portlist, CAUSE_OUTOFORDER, LOCATION_PRIVATE_LOCAL, ""); - new_state(EPOINT_STATE_OUT_DISCONNECT); - set_tone(portlist,"cause_1b"); - return(0); - } - join = new JoinRemote(ea_endpoint->ep_serial, remote, admin->sock); - } - else - join = new JoinPBX(ea_endpoint); + join = new JoinPBX(ea_endpoint); if (!join) FATAL("No memoy for Join instance.\n"); ea_endpoint->ep_join_id = join->j_serial; - return(1); -} -void EndpointAppPBX::action_init_call(void) -{ - _action_init_call(NULL); -} -void EndpointAppPBX::action_init_remote(void) -{ + return; } /* @@ -74,6 +45,7 @@ void EndpointAppPBX::action_dialing_internal(void) struct capa_info capainfo; struct caller_info callerinfo; struct redir_info redirinfo; + struct rtp_info rtpinfo; struct dialing_info dialinginfo; struct port_list *portlist = ea_endpoint->ep_portlist; struct lcr_msg *message; @@ -91,6 +63,7 @@ void EndpointAppPBX::action_dialing_internal(void) memcpy(&capainfo, &e_capainfo, sizeof(capainfo)); memcpy(&callerinfo, &e_callerinfo, sizeof(callerinfo)); memcpy(&redirinfo, &e_redirinfo, sizeof(redirinfo)); + memcpy(&rtpinfo, &e_rtpinfo, sizeof(rtpinfo)); memset(&dialinginfo, 0, sizeof(dialinginfo)); dialinginfo.itype = INFO_ITYPE_ISDN_EXTENSION; SCPY(dialinginfo.id, e_dialinginfo.id); @@ -164,6 +137,7 @@ void EndpointAppPBX::action_dialing_internal(void) memcpy(&message->param.setup.redirinfo, &redirinfo, sizeof(struct redir_info)); memcpy(&message->param.setup.callerinfo, &callerinfo, sizeof(struct caller_info)); memcpy(&message->param.setup.capainfo, &capainfo, sizeof(struct capa_info)); + memcpy(&message->param.setup.rtpinfo, &rtpinfo, sizeof(struct rtp_info)); message_put(message); } @@ -174,6 +148,7 @@ void EndpointAppPBX::action_dialing_external(void) struct capa_info capainfo; struct caller_info callerinfo; struct redir_info redirinfo; + struct rtp_info rtpinfo; struct dialing_info dialinginfo; char *p; struct port_list *portlist = ea_endpoint->ep_portlist; @@ -206,6 +181,7 @@ void EndpointAppPBX::action_dialing_external(void) memcpy(&capainfo, &e_capainfo, sizeof(capainfo)); memcpy(&callerinfo, &e_callerinfo, sizeof(callerinfo)); memcpy(&redirinfo, &e_redirinfo, sizeof(redirinfo)); + memcpy(&rtpinfo, &e_rtpinfo, sizeof(rtpinfo)); memset(&dialinginfo, 0, sizeof(dialinginfo)); dialinginfo.itype = INFO_ITYPE_ISDN; // dialinginfo.sending_complete = 0; @@ -215,6 +191,9 @@ void EndpointAppPBX::action_dialing_external(void) if ((rparam = routeparam(e_action, PARAM_PREFIX))) SPRINT(dialinginfo.id, "%s%s", rparam->string_value, e_extdialing); + if ((rparam = routeparam(e_action, PARAM_CONTEXT))) + SCPY(dialinginfo.context, rparam->string_value); + /* process keypad */ if ((rparam = routeparam(e_action, PARAM_KEYPAD))) { SCPY(dialinginfo.keypad, dialinginfo.id); @@ -321,82 +300,11 @@ void EndpointAppPBX::action_dialing_external(void) memcpy(&message->param.setup.redirinfo, &redirinfo, sizeof(struct redir_info)); memcpy(&message->param.setup.callerinfo, &callerinfo, sizeof(struct caller_info)); memcpy(&message->param.setup.capainfo, &capainfo, sizeof(struct capa_info)); + memcpy(&message->param.setup.rtpinfo, &rtpinfo, sizeof(struct rtp_info)); message_put(message); } -void EndpointAppPBX::action_dialing_remote(void) -{ - struct route_param *rparam; - struct port_list *portlist = ea_endpoint->ep_portlist; - struct lcr_msg *message; - struct capa_info capainfo; - struct caller_info callerinfo; - struct redir_info redirinfo; - struct dialing_info dialinginfo; - char context[128] = ""; - char remote[32]; - - if (!ea_endpoint->ep_join_id) { - /* no join yet, sending setup */ - if (!(rparam = routeparam(e_action, PARAM_APPLICATION))) { - trace_header("ACTION remote (no application given)", DIRECTION_NONE); - end_trace(); - new_state(EPOINT_STATE_OUT_DISCONNECT); - message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, ""); - set_tone(portlist, "cause_3f"); - return; - } - SCPY(remote, rparam->string_value); - if (!_action_init_call(remote)) - return; - - /* create bearer/caller/dialinginfo */ - memcpy(&capainfo, &e_capainfo, sizeof(capainfo)); - memcpy(&callerinfo, &e_callerinfo, sizeof(callerinfo)); - memcpy(&redirinfo, &e_redirinfo, sizeof(redirinfo)); - memset(&dialinginfo, 0, sizeof(dialinginfo)); - - if ((rparam = routeparam(e_action, PARAM_CONTEXT))) { - SCPY(context, rparam->string_value); - } - if ((rparam = routeparam(e_action, PARAM_EXTEN))) { - SCPY(dialinginfo.id, rparam->string_value); - dialinginfo.ntype = INFO_NTYPE_UNKNOWN; - } else { - SCPY(dialinginfo.id, e_extdialing); - } - e_extdialing = e_dialinginfo.id + strlen(e_dialinginfo.id); - /* send setup to remote */ - trace_header("ACTION remote (setup)", DIRECTION_NONE); - add_trace("number", NULL, dialinginfo.id); - add_trace("remote", NULL, remote); - if (context[0]) - add_trace("context", NULL, context); - end_trace(); - message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_SETUP); - memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info)); - memcpy(&message->param.setup.redirinfo, &redirinfo, sizeof(struct redir_info)); - memcpy(&message->param.setup.callerinfo, &callerinfo, sizeof(struct caller_info)); - memcpy(&message->param.setup.capainfo, &capainfo, sizeof(struct capa_info)); - SCPY(message->param.setup.context, context); - message_put(message); - } else { - /* send overlap digits */ - trace_header("ACTION remote (dialing)", DIRECTION_NONE); - add_trace("number", NULL, e_extdialing); - end_trace(); - if (e_extdialing[0]) { - message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_INFORMATION); - memcpy(&message->param.information, &e_dialinginfo, sizeof(struct dialing_info)); - SCPY(message->param.information.id, e_extdialing); - e_extdialing = e_dialinginfo.id + strlen(e_dialinginfo.id); - message_put(message); - } - } -} - - /* * process dialing the "am" and record */ @@ -1965,7 +1873,7 @@ void EndpointAppPBX::action_execute(void) int iWaitStatus; char *command = (char *)""; char isdn_port[10]; - char *argv[11]; /* check also number of args below */ + char *argv[12]; /* check also number of args below */ int i = 0; /* get script / command */ @@ -1976,9 +1884,11 @@ void EndpointAppPBX::action_execute(void) end_trace(); return; } +#if 0 argv[i++] = (char *)"/bin/sh"; argv[i++] = (char *)"-c"; argv[i++] = command; +#endif argv[i++] = command; if ((rparam = routeparam(e_action, PARAM_PARAM))) { argv[i++] = rparam->string_value; @@ -1989,6 +1899,7 @@ void EndpointAppPBX::action_execute(void) argv[i++] = e_callerinfo.name; SPRINT(isdn_port, "%d", e_callerinfo.isdn_port); argv[i++] = isdn_port; + argv[i++] = e_callerinfo.imsi; argv[i++] = NULL; /* check also number of args above */ switch (pid = fork ()) { case -1: @@ -1998,12 +1909,10 @@ void EndpointAppPBX::action_execute(void) case 0: /* To be shure there are no zombies created double fork */ if ((pid2 = fork()) == 0) { - execve("/bin/sh", argv, environ); - } - else { - /* Exit immediately and release the waiting parent. The subprocess falls to init because the parent died */ - exit(0); + execve(command, argv, environ); } + /* Exit immediately and release the waiting parent. The subprocess falls to init because the parent died */ + exit(0); break; default: trace_header("ACTION execute", DIRECTION_NONE); @@ -2268,12 +2177,6 @@ void EndpointAppPBX::process_dialing(int timeout) e_action = &action_internal; goto process_action; } - /* check for chan call */ - if (!strncmp(e_dialinginfo.id, "remote:", 7)) { - e_extdialing = e_dialinginfo.id+7; - e_action = &action_remote; - goto process_action; - } /* check for vbox call */ if (!strncmp(e_dialinginfo.id, "vbox:", 5)) { e_extdialing = e_dialinginfo.id+5; @@ -2282,11 +2185,12 @@ void EndpointAppPBX::process_dialing(int timeout) } gettimeofday(¤t_time, NULL); - if (timeout && TIME_SMALLER(&e_match_timeout.timeout, ¤t_time)) { + if (e_match_to_action && TIME_SMALLER(&e_match_timeout.timeout, ¤t_time)) { /* return timeout rule */ 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); unsched_timer(&e_match_timeout); e_action = e_match_to_action; + e_match_to_action = NULL; e_extdialing = e_match_to_extdialing; trace_header("ROUTING (timeout)", DIRECTION_NONE); add_trace("action", NULL, "%s", action_defs[e_action->index].name);