X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=apppbx.cpp;h=1b119b24e1ee63bfa8be753bd066b2a68b14f8fb;hp=87e4f41264ef598f4d827f106899d5fbf1ef89ee;hb=877a2dfd52782f72ba2d28483212166f2326b1fa;hpb=108a0eb48201fe46572ecf565183e2c19959b5ec diff --git a/apppbx.cpp b/apppbx.cpp index 87e4f41..1b119b2 100644 --- a/apppbx.cpp +++ b/apppbx.cpp @@ -851,6 +851,7 @@ void EndpointAppPBX::out_setup(int cfnr) int channel = 0; int earlyb; int mode = B_MODE_TRANSPARENT; + struct admin_list *admin; /* set bchannel mode */ mode = e_capainfo.source_mode; @@ -989,6 +990,26 @@ void EndpointAppPBX::out_setup(int cfnr) port = new Pgsm_ms(PORT_TYPE_GSM_MS_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); else #endif +#ifdef WITH_SIP + if (mISDNport->ifport->interface->sip) + port = new Psip(PORT_TYPE_SIP_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode, mISDNport->ifport->interface); + 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("Failed to create Port instance\n"); @@ -1208,6 +1229,26 @@ void EndpointAppPBX::out_setup(int cfnr) port = new Pgsm_ms(PORT_TYPE_GSM_MS_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode); else #endif +#ifdef WITH_SIP + if (mISDNport->ifport->interface->sip) + port = new Psip(PORT_TYPE_SIP_OUT, mISDNport, portname, &port_settings, channel, mISDNport->ifport->channel_force, mode, mISDNport->ifport->interface); + 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"); @@ -2048,10 +2089,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_BS_OUT - || portlist->port_type==PORT_TYPE_GSM_MS_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)); @@ -2582,17 +2621,6 @@ void EndpointAppPBX::ea_message_port(unsigned int port_id, int message_type, uni // PDEBUG(DEBUG_EPOINT, "received message %d (terminal %s, caller id %s)\n", message, e_ext.number, e_callerinfo.id); switch(message_type) { - case MESSAGE_DATA: /* data from port */ - /* check if there is a call */ - if (!ea_endpoint->ep_join_id) - break; - /* continue if only one portlist */ - if (ea_endpoint->ep_portlist->next != NULL) - break; - /* forward message */ - message_forward(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, param); - break; - case MESSAGE_TONE_EOF: /* tone is end of file */ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) current tone is now end of file.\n", ea_endpoint->ep_serial); if (e_action) { @@ -3196,6 +3224,19 @@ void EndpointAppPBX::join_mISDNsignal(struct port_list *portlist, int message_ty } } +/* join MESSAGE_BRIDE */ +void EndpointAppPBX::join_bridge(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_BRIDGE); + memcpy(&message->param, param, sizeof(union parameter)); + message_put(message); + portlist = portlist->next; + } +} + /* join MESSAGE_NOTIFY */ void EndpointAppPBX::join_notify(struct port_list *portlist, int message_type, union parameter *param) { @@ -3277,21 +3318,6 @@ void EndpointAppPBX::ea_message_join(unsigned int join_id, int message_type, uni portlist = ea_endpoint->ep_portlist; - /* send MESSAGE_DATA to port */ - if (message_type == MESSAGE_DATA) { - if (join_id == ea_endpoint->ep_join_id) { // still linked with JOIN - /* skip if no port relation */ - if (!portlist) - return; - /* skip if more than one port relation */ - if (portlist->next) - return; - /* forward audio data to port */ - message_forward(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, param); - return; - } - } - // PDEBUG(DEBUG_EPOINT, "EPOINT(%d) received message %d for active JOIN (terminal %s, caller id %s state=%d)\n", ea_endpoint->ep_serial, message, e_ext.number, e_callerinfo.id, e_state); switch(message_type) { /* JOIN SENDS TONE message */ @@ -3381,23 +3407,11 @@ void EndpointAppPBX::ea_message_join(unsigned int join_id, int message_type, uni join_mISDNsignal(portlist, message_type, param); break; -#if 0 - kann nach dem test gelöscht werden, da eine direkte funktion im join und im mISDN zum austausch der message existiert - /* JOIN requests bchannel */ - case MESSAGE_BCHANNEL: /* indicates the need of own bchannel access */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received bchannel assignment %d from join.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, param->bchannel.type); - /* only one port is expected to be connected to bchannel */ - if (!portlist) - break; - if (portlist->next) - break; - e_join_pattern = 1; - SCPY(e_tone, ""); - set_tone(portlist, NULL); - message = message_forward(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, param); - logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT); + /* JOIN sends bridge message */ + case MESSAGE_BRIDGE: /* bride message to port */ + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received bridge message.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); + join_bridge(portlist, message_type, param); break; -#endif /* JOIN has pattern available */ case MESSAGE_PATTERN: /* indicating pattern available */ @@ -3480,7 +3494,7 @@ int match_list(char *list, char *item) while(42) { /* eliminate white spaces */ - while (*list <= ' ') + while (*list > '\0' && *list <= ' ') list++; if (*list == ',') { list++; @@ -3530,10 +3544,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_BS_OUT - || port->p_type==PORT_TYPE_GSM_MS_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;