diff --git a/apppbx.cpp b/apppbx.cpp index 6cf2c92..8b936ef 100644 --- a/apppbx.cpp +++ b/apppbx.cpp @@ -609,7 +609,10 @@ void EndpointAppPBX::out_setup(int cfnr) // char allowed_ports[256]; // char exten[256]; char ifname[sizeof(e_ext.interfaces)], - number[256]; + ifname_c[sizeof(e_ext.interfaces)], + *ifname_p, + number[256], + *number_p; struct port_settings port_settings; #ifdef WITH_MISDN int channel = 0; @@ -986,20 +989,42 @@ void EndpointAppPBX::out_setup(int cfnr) PDEBUG(DEBUG_EPOINT, "EPOINT(%d) dialing external: called='%s' keypad='%s'\n", ea_endpoint->ep_serial, e_dialinginfo.id, e_dialinginfo.keypad); /* call to extenal interfaces */ if (e_dialinginfo.keypad[0]) - p = e_dialinginfo.keypad; + number_p = e_dialinginfo.keypad; else - p = e_dialinginfo.id; + number_p = e_dialinginfo.id; do { earlyb = 0; number[0] = '\0'; - while(*p!=',' && *p!='\0') - SCCAT(number, *p++); - if (*p == ',') - p++; + while(*number_p!=',' && *number_p!='\0') + SCCAT(number, *number_p++); + if (*number_p == ',') + number_p++; /* found number */ + + strncpy(ifname_c, e_dialinginfo.interfaces, sizeof(ifname_c)); + ifname_c[sizeof(ifname_c)-1] = 0; + ifname_p = ifname_c; + do { + + if (e_dialinginfo.interfaces[0] =='+') { + ifname_p=strrchr(ifname_c, ','); + if (ifname_p) { + strncpy(ifname, ifname_p+1, sizeof(ifname)); + ifname[sizeof(ifname)-1]='\0'; + *ifname_p = 0; + } else { + strncpy(ifname, ifname_c+1, sizeof(ifname)); + *ifname_c = 0; + } + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) calling to number '%s' interface '%s'\n", ea_endpoint->ep_serial, number, ifname); + } else { + strncpy(ifname, e_dialinginfo.interfaces, sizeof(ifname)); + ifname_p = 0; PDEBUG(DEBUG_EPOINT, "EPOINT(%d) calling to number '%s' interface '%s'\n", ea_endpoint->ep_serial, number, e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:"any interface"); + } /* search interface */ - interface = hunt_interface(e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:NULL); + interface = hunt_interface(ifname[0]?ifname:NULL); + if (!interface) { trace_header("INTERFACE (not found)", DIRECTION_NONE); add_trace("interface", NULL, "%s", ifname); @@ -1031,15 +1056,16 @@ void EndpointAppPBX::out_setup(int cfnr) { #ifdef WITH_MISDN /* hunt for mISDNport and create Port */ - mISDNport = hunt_port(e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:NULL, &channel); + mISDNport = hunt_port(ifname[0]?ifname:NULL, &channel); if (!mISDNport) { trace_header("INTERFACE (too busy)", DIRECTION_NONE); - add_trace("interface", NULL, "%s", e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:"any interface"); + add_trace("interface", NULL, "%s", ifname[0]?ifname:"any interface"); end_trace(); goto check_anycall_extern; } /* creating EXTERNAL port*/ SPRINT(portname, "%s-%d-out", mISDNport->ifport->interface->name, mISDNport->portnum); + #ifdef WITH_SS5 if (mISDNport->ss5) port = ss5_hunt_line(mISDNport); @@ -1105,7 +1131,9 @@ void EndpointAppPBX::out_setup(int cfnr) message_put(message); logmessage(message->type, &message->param, portlist->port_id, DIRECTION_OUT); anycall = 1; - } while(*p); + + } while (ifname_p); + } while(*number_p); check_anycall_extern: /* now we have all ports created */