X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=interface.c;h=587fc62b656d8e12eddb12938322c2948f862a02;hp=7a00735a87241bbc26a0022ad1de854f4661e1df;hb=04fc928a2c5f0262e85c09cced1ef20a9fd15f3d;hpb=f851ca0d9e22673b7cc0a7c2f539c9d51b9b77f8 diff --git a/interface.c b/interface.c index 7a00735..587fc62 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); } @@ -973,18 +956,61 @@ static int inter_sip(struct interface *interface, char *filename, int line, char SPRINT(interface_error, "Error in %s (line %d): Missing SIP remote IP.\n", filename, line); return(-1); } - SCPY(interface->sip_local_ip, value); - SCPY(interface->sip_remote_ip, p); + SCPY(interface->sip_local_peer, value); + SCPY(interface->sip_remote_peer, p); return(0); #endif } static int inter_rtp_bridge(struct interface *interface, char *filename, int line, char *parameter, char *value) { + int supported = 0; + +#ifdef WITH_GSM_BS + if (interface->gsm_bs) + supported = 1; +#endif +#ifdef WITH_SIP + if (interface->sip) + supported = 1; +#endif + if (!supported) { + SPRINT(interface_error, "Error in %s (line %d): Interface does not support RTP\n", filename, line); + return(-1); + } interface->rtp_bridge = 1; return(0); } +#if 0 +static int inter_rtp_payload(struct interface *interface, char *filename, int line, char *parameter, char *value) +{ +#ifndef WITH_GSM_BS + SPRINT(interface_error, "Error in %s (line %d): GSM BS side not compiled in.\n", filename, line); + return(-1); +#else + if (!interface->gsm_bs) { + SPRINT(interface_error, "Error in %s (line %d): This parameter only works for GSM BS side interface\n", filename, line); + return(-1); + } + if (!interface->rtp_bridge) { + SPRINT(interface_error, "Error in %s (line %d): This parameter only works here, if RTP bridging is enabled\n", filename, line); + return(-1); + } + if (!value[0]) { + SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expects one payload type\n", filename, line, parameter); + return(-1); + } + if (interface->gsm_bs_payloads == sizeof(interface->gsm_bs_payload_types)) { + SPRINT(interface_error, "Error in %s (line %d): Too many payload types defined\n", filename, line); + return(-1); + } + interface->gsm_bs_payload_types[interface->gsm_bs_payloads++] = atoi(value); + + return(0); +#endif +} +#endif static int inter_nonotify(struct interface *interface, char *filename, int line, char *parameter, char *value) { struct interface_port *ifport; @@ -1053,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]) { @@ -1062,27 +1087,26 @@ 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)) - return(-1); - /* goto end of chain again to set application name */ - ifport = interface->ifport; - while(ifport->next) - ifport = ifport->next; - ifport->remote = 1; - SCPY(ifport->remote_app, value); + 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); return(0); } @@ -1245,8 +1269,15 @@ struct interface_param interface_param[] = { "Sets up SIP interface that represents one SIP endpoint.\n" "Give SIP configuration file."}, {"rtp-bridge", &inter_rtp_bridge, "", - "Sets up SIP interface that represents one SIP endpoint.\n" - "Give SIP configuration file."}, + "Enables RTP bridging directly from this interface.\n" + "This only works, if both ends support RTP. (like gsm-bs and sip)"}, +#if 0 + not needed, since ms defines what is supports and remote (sip) tells what is selected + {"rtp-payload", &inter_rtp_payload, "", + "Define RTP payload to use. Only valid in conjuntion with gsm-bs!\n" + "If multiple payloads are defined, the first has highest priority.\n" + "If none are defined, GSM fullrate V1 (type 3) is assumed.\n"}, +#endif {"nonotify", &inter_nonotify, "", "Prevents sending notify messages to this interface. A call placed on hold will\n" "Not affect the remote end (phone or telcom switch).\n" @@ -1275,6 +1306,8 @@ 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."}, {"shutdown", &inter_shutdown, "", "Interface will not be loaded when processing interface.conf"}, @@ -1533,16 +1566,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) { @@ -1558,17 +1590,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) {