X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=interface.c;h=b9dd275f890c2143ef1c7b9941078d2033e4296b;hp=4f7e40a966e20c4d26e3de9f99d55a3e499db75a;hb=acaf278f7f616d264afe480e4f9c64768540941b;hpb=58afedec93e67db3600e2251d922fa3a4dbd7254 diff --git a/interface.c b/interface.c index 4f7e40a..b9dd275 100644 --- a/interface.c +++ b/interface.c @@ -327,7 +327,6 @@ static int inter_portname(struct interface *interface, char *filename, int line, return(-1); #else struct interface_port *ifport, **ifportp; - struct interface *searchif; /* goto end of chain */ ifport = interface->ifport; @@ -336,22 +335,6 @@ static int inter_portname(struct interface *interface, char *filename, int line, ifport = ifport->next; } - /* check for port already assigned, but not for shared loop interface */ - searchif = interface_newlist; - if (!!strcmp(value, options.loopback_lcr)) - { - while(searchif) { - ifport = searchif->ifport; - while(ifport) { - if (!strcasecmp(ifport->portname, value)) { - SPRINT(interface_error, "Error in %s (line %d): port '%s' already used above.\n", filename, line, value); - return(-1); - } - ifport = ifport->next; - } - searchif = searchif->next; - } - } /* alloc port substructure */ ifport = (struct interface_port *)MALLOC(sizeof(struct interface_port)); memuse++; @@ -943,7 +926,7 @@ static int inter_gsm_ms(struct interface *interface, char *filename, int line, c /* check if name is used multiple times */ searchif = interface_newlist; while(searchif) { - if (!strcmp(searchif->gsm_ms_name, interface->gsm_ms_name)) { + if (searchif != interface && !strcmp(searchif->gsm_ms_name, interface->gsm_ms_name)) { SPRINT(interface_error, "Error in %s (line %d): mobile '%s' already uses the given MS name '%s', choose a different one.\n", filename, line, interface->gsm_ms_name, searchif->gsm_ms_name); return(-1); } @@ -1096,7 +1079,6 @@ static int inter_ss5(struct interface *interface, char *filename, int line, char #endif static int inter_remote(struct interface *interface, char *filename, int line, char *parameter, char *value) { - struct interface_port *ifport; struct interface *searchif; if (!value[0]) { @@ -1105,28 +1087,78 @@ static int inter_remote(struct interface *interface, char *filename, int line, c } searchif = interface_newlist; while(searchif) { - ifport = searchif->ifport; - while(ifport) { - if (ifport->remote && !strcmp(ifport->remote_app, value)) { - SPRINT(interface_error, "Error in %s (line %d): port '%s' already uses remote application '%s'.\n", filename, line, ifport->portname, value); - return(-1); - } - ifport = ifport->next; + if (interface->remote && !strcmp(interface->remote_app, value)) { + SPRINT(interface_error, "Error in %s (line %d): interface '%s' already uses remote application '%s'.\n", filename, line, interface->name, value); + return(-1); } searchif = searchif->next; } - /* set portname */ - if (inter_portname(interface, filename, line, (char *)"portname", options.loopback_lcr)) + /* goto end of chain again to set application name */ + interface->remote = 1; + SCPY(interface->remote_app, value); + + return(0); +} +static int inter_context(struct interface *interface, char *filename, int line, char *parameter, char *value) +{ + if (!value[0]) { + SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expects application context as value.\n", filename, line, parameter); return(-1); + } + SCPY(interface->remote_context, value); - /* goto end of chain again to set application name */ + return(0); +} +static int inter_pots_flash(struct interface *interface, char *filename, int line, char *parameter, char *value) +{ + struct interface_port *ifport; + + /* port in chain ? */ + if (!interface->ifport) { + SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expects previous 'port' definition.\n", filename, line, parameter); + return(-1); + } + /* goto end of chain */ ifport = interface->ifport; while(ifport->next) ifport = ifport->next; - ifport->remote = 1; - SCPY(ifport->remote_app, value); + ifport->pots_flash = 1; + return(0); +} +static int inter_pots_ring(struct interface *interface, char *filename, int line, char *parameter, char *value) +{ + struct interface_port *ifport; + + /* port in chain ? */ + if (!interface->ifport) { + SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expects previous 'port' definition.\n", filename, line, parameter); + return(-1); + } + /* goto end of chain */ + ifport = interface->ifport; + while(ifport->next) + ifport = ifport->next; + + ifport->pots_ring = 1; + return(0); +} +static int inter_pots_transfer(struct interface *interface, char *filename, int line, char *parameter, char *value) +{ + struct interface_port *ifport; + + /* port in chain ? */ + if (!interface->ifport) { + SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expects previous 'port' definition.\n", filename, line, parameter); + return(-1); + } + /* goto end of chain */ + ifport = interface->ifport; + while(ifport->next) + ifport = ifport->next; + + ifport->pots_transfer = 1; return(0); } static int inter_shutdown(struct interface *interface, char *filename, int line, char *parameter, char *value) @@ -1325,6 +1357,23 @@ struct interface_param interface_param[] = { {"remote", &inter_remote, "", "Sets up an interface that communicates with the remote application.\n" "Use \"asterisk\" to use chan_lcr as remote application."}, + {"context", &inter_context, "", + "Give context for calls to application."}, + + {"pots-flash", &inter_pots_flash, "", + "Allow flash button to hold an active call and setup a new call.\n" + "Ihis parameter only appies to POTS type of interfaces\n" + "This parameter must follow a 'port' parameter.\n"}, + {"pots-ring-after-hangup", &inter_pots_ring, "", + "Allow ringing of last hold call after hangup. Other calls on hold will not be\n" + "released.\n" + "Ihis parameter only appies to POTS type of interfaces\n" + "This parameter must follow a 'port' parameter.\n"}, + {"pots-transfer-after-hangup", &inter_pots_transfer, "", + "If two calls on hold, both are connected after hangup.\n" + "If one call is on hold and another one alerting, call on hold is tranfered.\n" + "Ihis parameter only appies to POTS type of interfaces\n" + "This parameter must follow a 'port' parameter.\n"}, {"shutdown", &inter_shutdown, "", "Interface will not be loaded when processing interface.conf"}, @@ -1583,16 +1632,15 @@ void relink_interfaces(void) struct mISDNport *mISDNport; struct interface_port *ifport; #endif - struct interface *interface, *temp; - int found; + struct interface *interface, *temp, *found; interface = interface_first; while(interface) { - found = 0; + found = NULL; temp = interface_newlist; while(temp) { if (!strcmp(temp->name, interface->name)) - found = 1; + found = temp; temp = temp->next; } if (!found) { @@ -1608,17 +1656,26 @@ void relink_interfaces(void) if (interface->sip) sip_exit_inst(interface); #endif + } else { +#ifdef WITH_SIP + if (interface->sip) { + /* move sip instance, if we keep interface */ + found->sip_inst = interface->sip_inst; + interface->sip_inst = NULL; + } +#endif + ; } interface = interface->next; } interface = interface_newlist; while(interface) { - found = 0; + found = NULL; temp = interface_first; while(temp) { if (!strcmp(temp->name, interface->name)) - found = 1; + found = temp; temp = temp->next; } if (!found) {