X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=apppbx.cpp;h=fff80ce106829dc0ca46f3adeaccab47d63a6d04;hp=6836715a9f0dcf76d7886d68880a82c77de09e9b;hb=a5846418d9ac518e7bc5e1328b71a19609c0dd1d;hpb=5b5923141c3ac53d3e63395d9197080d087342f3 diff --git a/apppbx.cpp b/apppbx.cpp index 6836715..fff80ce 100644 --- a/apppbx.cpp +++ b/apppbx.cpp @@ -829,7 +829,7 @@ foundif: * ports will be created and a setup is sent if everything is ok. otherwhise * the endpoint is destroyed. */ -void EndpointAppPBX::out_setup(void) +void EndpointAppPBX::out_setup(int cfnr) { struct dialing_info dialinginfo; class Port *port; @@ -851,6 +851,7 @@ void EndpointAppPBX::out_setup(void) int channel = 0; int earlyb; int mode = B_MODE_TRANSPARENT; + struct admin_list *admin; /* set bchannel mode */ mode = e_capainfo.source_mode; @@ -938,7 +939,7 @@ void EndpointAppPBX::out_setup(void) p = e_ext.cfnr; if (*p) { /* when cfnr is done, out_setup() will setup the call */ - if (e_cfnr_call_timeout.active) { + if (cfnr) { /* present to forwarded party */ if (e_ext.anon_ignore && e_callerinfo.id[0]) { e_callerinfo.present = INFO_PRESENT_ALLOWED; @@ -979,16 +980,34 @@ void EndpointAppPBX::out_setup(void) port = ss5_hunt_line(mISDNport); else #endif - if (!mISDNport->gsm) - port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); +#ifdef WITH_GSM_BS + if (mISDNport->gsm_bs) + port = new Pgsm_bs(PORT_TYPE_GSM_BS_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); + else +#endif +#ifdef WITH_GSM_MS + if (mISDNport->gsm_ms) + port = new Pgsm_ms(PORT_TYPE_GSM_MS_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); else -#ifdef WITH_GSM - port = new Pgsm(PORT_TYPE_GSM_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); -#else - port = NULL; #endif + if (mISDNport->ifport->remote) { + admin = admin_first; + while(admin) { + if (admin->remote_name[0] && !strcmp(admin->remote_name, mISDNport->ifport->remote_app)) + break; + admin = admin->next; + } + if (!admin) { + trace_header("INTERFACE (remote not connected)", DIRECTION_NONE); + add_trace("application", NULL, "%s", mISDNport->ifport->remote_app); + end_trace(); + continue; + } + port = new Premote(PORT_TYPE_REMOTE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode, admin->sock); + } else + port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); if (!port) - FATAL("No memory for Port instance\n"); + FATAL("Failed to create Port instance\n"); PDEBUG(DEBUG_EPOINT, "EPOINT(%d) got port %s\n", ea_endpoint->ep_serial, port->p_name); memset(&dialinginfo, 0, sizeof(dialinginfo)); SCPY(dialinginfo.id, e_dialinginfo.id); @@ -1195,14 +1214,32 @@ void EndpointAppPBX::out_setup(void) port = ss5_hunt_line(mISDNport); else #endif - if (!mISDNport->gsm) - port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); +#ifdef WITH_GSM_BS + if (mISDNport->gsm_bs) + port = new Pgsm_bs(PORT_TYPE_GSM_BS_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); else -#ifdef WITH_GSM - port = new Pgsm(PORT_TYPE_GSM_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); -#else - port = NULL; #endif +#ifdef WITH_GSM_MS + if (mISDNport->gsm_ms) + port = new Pgsm_ms(PORT_TYPE_GSM_MS_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); + else +#endif + if (mISDNport->ifport->remote) { + admin = admin_first; + while(admin) { + if (admin->remote_name[0] && !strcmp(admin->remote_name, mISDNport->ifport->remote_app)) + break; + admin = admin->next; + } + if (!admin) { + trace_header("INTERFACE (remote not connected)", DIRECTION_NONE); + add_trace("application", NULL, "%s", mISDNport->ifport->remote_app); + end_trace(); + continue; + } + port = new Premote(PORT_TYPE_REMOTE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode, admin->sock); + } else + port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); if (!port) FATAL("No memory for Port instance\n"); earlyb = mISDNport->earlyb; @@ -1297,7 +1334,7 @@ int redial_timeout(struct lcr_timer *timer, void *instance, int index) ea->new_state(EPOINT_STATE_OUT_SETUP); /* call special setup routine */ - ea->out_setup(); + ea->out_setup(0); return 0; } @@ -1356,7 +1393,7 @@ int cfnr_call_timeout(struct lcr_timer *timer, void *instance, int index) class EndpointAppPBX *ea = (class EndpointAppPBX *)instance; PDEBUG(DEBUG_EPOINT, "EPOINT(%d) call-forward-busy time has expired, calling the forwarded number: %s.\n", ea->ea_endpoint->ep_serial, ea->e_ext.cfnr); - ea->out_setup(); + ea->out_setup(1); return 0; } @@ -1369,7 +1406,7 @@ int callback_timeout(struct lcr_timer *timer, void *instance, int index) /* epoint is idle, check callback */ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) starting callback.\n", ea->ea_endpoint->ep_serial); ea->new_state(EPOINT_STATE_OUT_SETUP); - ea->out_setup(); + ea->out_setup(0); } return 0; @@ -1612,6 +1649,8 @@ void EndpointAppPBX::port_setup(struct port_list *portlist, int message_type, un /* port MESSAGE_INFORMATION */ void EndpointAppPBX::port_information(struct port_list *portlist, int message_type, union parameter *param) { + struct lcr_msg *message; + logmessage(message_type, param, portlist->port_id, DIRECTION_IN); /* ignore information message without digit information */ @@ -1648,7 +1687,13 @@ void EndpointAppPBX::port_information(struct port_list *portlist, int message_ty /* keypad when connected */ if (e_state == EPOINT_STATE_CONNECT || e_state == EPOINT_STATE_IN_ALERTING) { - if (e_ext.keypad || e_enablekeypad) { + if (e_enablekeypad) { + message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, message_type); + memcpy(&message->param, param, sizeof(union parameter)); + message_put(message); + return; + } + if (e_ext.keypad) { PDEBUG(DEBUG_EPOINT, "EPOINT(%d) keypad information received during connect: %s.\n", ea_endpoint->ep_serial, param->information.id); /* processing keypad function */ if (param->information.id[0] == '0') { @@ -1696,6 +1741,7 @@ void EndpointAppPBX::port_information(struct port_list *portlist, int message_ty void EndpointAppPBX::port_dtmf(struct port_list *portlist, int message_type, union parameter *param) { time_t now; + struct lcr_msg *message; time(&now); @@ -1726,6 +1772,12 @@ NOTE: vbox is now handled due to overlap state /* check for *X# sequence */ if (e_state == EPOINT_STATE_CONNECT || e_state == EPOINT_STATE_IN_ALERTING) { + if (e_enablekeypad) { + message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, message_type); + memcpy(&message->param, param, sizeof(union parameter)); + message_put(message); + return; + } if (e_dtmf_time+3 < now) { /* the last digit was too far in the past to be a sequence */ if (param->dtmf == '*') @@ -2027,7 +2079,8 @@ void EndpointAppPBX::port_connect(struct port_list *portlist, int message_type, /* other calls with no caller id (or not available for the extension) and force colp */ if ((e_connectinfo.id[0]=='\0' || (e_connectinfo.present==INFO_PRESENT_RESTRICTED && !e_ext.anon_ignore))&& e_ext.colp==COLP_FORCE) { e_connectinfo.ntype = INFO_NTYPE_NOTPRESENT; - if (portlist->port_type==PORT_TYPE_DSS1_TE_OUT || portlist->port_type==PORT_TYPE_DSS1_NT_OUT || portlist->port_type==PORT_TYPE_GSM_OUT) { /* external extension answered */ + if ((portlist->port_type & PORT_CLASS_DIR_MASK) == PORT_CLASS_DIR_OUT) { + /* external extension answered */ port = find_port_id(portlist->port_id); if (port) { SCPY(e_connectinfo.id, nationalize_callerinfo(port->p_dialinginfo.id, &e_connectinfo.ntype, options.national, options.international)); @@ -2469,6 +2522,25 @@ void EndpointAppPBX::port_notify(struct port_list *portlist, int message_type, u } +/* port MESSAGE_PROGRESS */ +void EndpointAppPBX::port_progress(struct port_list *portlist, int message_type, union parameter *param) +{ + logmessage(message_type, param, portlist->port_id, DIRECTION_IN); + + struct lcr_msg *message; + + /* signal to call tool */ + admin_call_response(e_adminid, ADMIN_CALL_PROGRESS, "", 0, param->progressinfo.location, param->progressinfo.progress); + + /* send progress to call if available */ + if (ea_endpoint->ep_join_id) { + message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_PROGRESS); + memcpy(&message->param.progressinfo, ¶m->progressinfo, sizeof(struct progress_info)); + message_put(message); + } + +} + /* port MESSAGE_FACILITY */ void EndpointAppPBX::port_facility(struct port_list *portlist, int message_type, union parameter *param) { @@ -2507,6 +2579,18 @@ void EndpointAppPBX::port_resume(struct port_list *portlist, int message_type, u } +/* port MESSAGE_ENABLEKEYPAD */ +void EndpointAppPBX::port_enablekeypad(struct port_list *portlist, int message_type, union parameter *param) +{ + struct lcr_msg *message; + + logmessage(message_type, param, portlist->port_id, DIRECTION_IN); + + message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_ENABLEKEYPAD); + memcpy(&message->param, param, sizeof(union parameter)); + message_put(message); +} + /* port sends message to the endpoint */ @@ -2665,6 +2749,12 @@ void EndpointAppPBX::ea_message_port(unsigned int port_id, int message_type, uni port_notify(portlist, message_type, param); break; + /* PORT sends a PROGRESS message */ + case MESSAGE_PROGRESS: + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received progress.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); + port_progress(portlist, message_type, param); + break; + /* PORT sends a SUSPEND message */ case MESSAGE_SUSPEND: PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received suspend.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); @@ -2688,6 +2778,12 @@ void EndpointAppPBX::ea_message_port(unsigned int port_id, int message_type, uni break; #endif + /* PORT requests DTMF */ + case MESSAGE_ENABLEKEYPAD: + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') requests DTMF/KEYPAD.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); + port_enablekeypad(portlist, message_type, param); + break; + default: PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received a wrong message: %d\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, message_type); @@ -3113,7 +3209,7 @@ void EndpointAppPBX::join_setup(struct port_list *portlist, int message_type, un new_state(EPOINT_STATE_OUT_SETUP); /* call special setup routine */ - out_setup(); + out_setup(0); } /* join MESSAGE_mISDNSIGNAL */ @@ -3183,6 +3279,19 @@ void EndpointAppPBX::join_notify(struct port_list *portlist, int message_type, u } } +/* join MESSAGE_DTMF */ +void EndpointAppPBX::join_dtmf(struct port_list *portlist, int message_type, union parameter *param) +{ + struct lcr_msg *message; + + while(portlist) { + message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_DTMF); + memcpy(&message->param, param, sizeof(union parameter)); + message_put(message); + portlist = portlist->next; + } +} + /* JOIN sends messages to the endpoint */ void EndpointAppPBX::ea_message_join(unsigned int join_id, int message_type, union parameter *param) @@ -3375,6 +3484,12 @@ void EndpointAppPBX::ea_message_join(unsigned int join_id, int message_type, uni end_trace(); break; + /* JOIN sends a DTMF message */ + case MESSAGE_DTMF: + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received dtmf.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); + join_dtmf(portlist, message_type, param); + break; + default: PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received a wrong message: #%d\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, message_type); } @@ -3394,7 +3509,7 @@ int match_list(char *list, char *item) while(42) { /* eliminate white spaces */ - while (*list <= ' ') + while (*list > '\0' && *list <= ' ') list++; if (*list == ',') { list++; @@ -3444,7 +3559,7 @@ void EndpointAppPBX::pick_join(char *extensions) break; } } - if ((port->p_type==PORT_TYPE_DSS1_NT_OUT || port->p_type==PORT_TYPE_DSS1_TE_OUT || port->p_type==PORT_TYPE_GSM_OUT) + if ((portlist->port_type & PORT_CLASS_DIR_MASK) == PORT_CLASS_DIR_OUT && port->p_state==PORT_STATE_OUT_ALERTING) if (match_list(extensions, eapp->e_ext.number)) { found = eapp; @@ -3636,7 +3751,7 @@ void EndpointAppPBX::join_join(void) PDEBUG(DEBUG_EPOINT, "EPOINT(%d) cannot join: our port doesn't exist anymore.\n", ea_endpoint->ep_serial); return; } - if ((our_port->p_type&PORT_CLASS_mISDN_MASK) != PORT_CLASS_mISDN_DSS1) { + if ((our_port->p_type & PORT_CLASS_mISDN_MASK) != PORT_CLASS_DSS1) { PDEBUG(DEBUG_EPOINT, "EPOINT(%d) cannot join: our port is not isdn.\n", ea_endpoint->ep_serial); return; } @@ -3834,7 +3949,7 @@ int EndpointAppPBX::check_external(const char **errstr, class Port **port) *errstr = "No Call"; return(1); } - if (((*port)->p_type&PORT_CLASS_mISDN_MASK)!=PORT_CLASS_mISDN_DSS1) { /* port is not external isdn */ + if (((*port)->p_type & PORT_CLASS_mISDN_MASK) != PORT_CLASS_DSS1) { /* port is not external isdn */ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) 2nd endpoint has not an external port.\n", ea_endpoint->ep_serial); *errstr = "No Ext Call"; return(1); @@ -4108,6 +4223,65 @@ void EndpointAppPBX::logmessage(int message_type, union parameter *param, unsign end_trace(); break; + case MESSAGE_PROGRESS: + switch(param->progressinfo.progress) { + case 0x01: + logtext = "Call is not end to end ISDN"; + break; + case 0x02: + logtext = "Destination address is non-ISDN"; + break; + case 0x03: + logtext = "Origination address is non-ISDN"; + break; + case 0x04: + logtext = "Call has returned to the ISDN"; + break; + case 0x08: + logtext = "In-band info or pattern available"; + break; + default: + SPRINT(buffer, "%d", param->progressinfo.progress); + logtext = buffer; + + } + trace_header("PROGRESS", dir); + if (dir == DIRECTION_OUT) + add_trace("to", NULL, "CH(%lu)", port_id); + if (dir == DIRECTION_IN) + add_trace("from", NULL, "CH(%lu)", port_id); + add_trace("indicator", NULL, "%s", logtext); + switch(param->progressinfo.location) { + case LOCATION_USER: + add_trace("cause", "location", "0-User"); + break; + case LOCATION_PRIVATE_LOCAL: + add_trace("cause", "location", "1-Local-PBX"); + break; + case LOCATION_PUBLIC_LOCAL: + add_trace("cause", "location", "2-Local-Exchange"); + break; + case LOCATION_TRANSIT: + add_trace("cause", "location", "3-Transit"); + break; + case LOCATION_PUBLIC_REMOTE: + add_trace("cause", "location", "4-Remote-Exchange"); + break; + case LOCATION_PRIVATE_REMOTE: + add_trace("cause", "location", "5-Remote-PBX"); + break; + case LOCATION_INTERNATIONAL: + add_trace("cause", "location", "7-International-Exchange"); + break; + case LOCATION_BEYOND: + add_trace("cause", "location", "10-Beyond-Interworking"); + break; + default: + add_trace("cause", "location", "%d", param->progressinfo.location); + } + end_trace(); + break; + case MESSAGE_INFORMATION: trace_header("INFORMATION", dir); if (dir == DIRECTION_OUT)