X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=interface.c;h=28ad88c7603cecd5af18175cfaa3e80c38d1647a;hp=98a87ace9c5b5e074d8ab0477f2504beccb42be8;hb=57549529c86785b7ecf5f56d2a3ff42b5e519755;hpb=b95114936f9fc12816035db92beb3def4b5b0506 diff --git a/interface.c b/interface.c index 98a87ac..28ad88c 100644 --- a/interface.c +++ b/interface.c @@ -208,6 +208,29 @@ static int inter_nt(struct interface *interface, char *filename, int line, char ifport->nt = 1; return(0); } +static int inter_tespecial(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; + /* add value */ + if (value[0]) + { + SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expects no value.\n", filename, line, parameter); + return(-1); + } + ifport->tespecial = 1; + return(0); +} static int inter_tones(struct interface *interface, char *filename, int line, char *parameter, char *value) { if (!strcasecmp(value, "yes")) @@ -304,8 +327,66 @@ static int inter_portnum(struct interface *interface, char *filename, int line, } static int inter_portname(struct interface *interface, char *filename, int line, char *parameter, char *value) { - SPRINT(interface_error, "Error in %s (line %d): parameter '%s' not implemented yet.\n", filename, line, parameter); - return(-1); + struct interface_port *ifport, **ifportp; + struct interface *searchif; + + /* check for port already assigned */ + searchif = interface_newlist; + 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++; + ifport->interface = interface; + /* set value */ + ifport->portnum = -1; // disable until resolved + SCPY(ifport->portname, value); + /* tail port */ + ifportp = &interface->ifport; + while(*ifportp) + ifportp = &((*ifportp)->next); + *ifportp = ifport; + return(0); +} +static int inter_l1hold(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; + if (!strcmp(value, "yes")) + { + ifport->l1hold = 1; + } else + if (!strcmp(value, "no")) + { + ifport->l1hold = 0; + } else + { + SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expecting parameter 'yes' or 'no'.\n", filename, line, parameter); + return(-1); + } + return(0); } static int inter_l2hold(struct interface *interface, char *filename, int line, char *parameter, char *value) { @@ -845,6 +926,23 @@ static int inter_filter(struct interface *interface, char *filename, int line, c } return(0); } +static int inter_dialmax(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->dialmax = atoi(value); + return(0); +} /* @@ -866,8 +964,8 @@ struct interface_param interface_param[] = { ""}, {"portnum", &inter_portnum, "", "Give exactly one port for this interface.\nTo give multiple ports, add more lines with port parameters."}, - {"portname", &inter_portname, "", - "Give exactly one port for this interface.\nTo give multiple ports, add more lines with port parameters."}, + {"portname", &inter_portname, "", + "Same as 'portnum', but the name is given instead.\nUse 'isdninfo' to list all available ports and names."}, {"block", &inter_block, "", "If keyword is given, calls on this interface are blocked.\n" @@ -890,6 +988,19 @@ struct interface_param interface_param[] = { "This is required on interfaces that support both NT-mode and TE-mode.\n" "This parameter must follow a 'port' parameter."}, + {"te-special", &inter_tespecial, "", + "The given port uses a modified TE-mode.\n" + "All information elements that are allowed Network->User will then be\n" + "transmitted User->Network also. This is usefull to pass all informations\n" + "between two interconnected LCRs, like 'redirected number' or 'display'.\n" + "Note that this is not compliant with ISDN protocol.\n" + "This parameter must follow a 'port' parameter."}, + + {"layer1hold", &inter_l1hold, "yes | no", + "The given port will not release layer 1 after layer 2 is down.\n" + "It is required to keep layer 1 of telephones up, to solve activation problems.\n" + "This parameter must follow a 'port' parameter."}, + {"layer2hold", &inter_l2hold, "yes | no", "The given port will continuously try to establish layer 2 link and hold it.\n" "It is required for PTP links in most cases, therefore it is default.\n" @@ -947,6 +1058,9 @@ struct interface_param interface_param[] = { "pipeline - Sets echo cancelation pipeline.\n" "blowfish - Adds encryption. Key must be 4-56 bytes (8-112 hex characters."}, + {"dialmax", &inter_dialmax, "", + "Limits the number of digits in setup/information message."}, + {NULL, NULL, NULL, NULL} }; @@ -972,7 +1086,7 @@ struct interface *read_interfaces(void) if (interface_newlist != NULL) FATAL("list is not empty.\n"); interface_error[0] = '\0'; - SPRINT(filename, "%s/interface.conf", INSTALL_DATA); + SPRINT(filename, "%s/interface.conf", CONFIG_DATA); if (!(fp = fopen(filename,"r"))) { @@ -1240,8 +1354,11 @@ void relink_interfaces(void) mISDNport = mISDNport_first; while(mISDNport) { + if (!strcmp(mISDNport->name, ifport->portname)) + ifport->portnum = mISDNport->portnum; /* same name, so we use same number */ if (mISDNport->portnum == ifport->portnum) { + PDEBUG(DEBUG_ISDN, "Port %d:%s relinking!\n", mISDNport->portnum); ifport->mISDNport = mISDNport; mISDNport->ifport = ifport; set_defaults(ifport); @@ -1295,12 +1412,16 @@ void load_port(struct interface_port *ifport) struct mISDNport *mISDNport; /* open new port */ - mISDNport = mISDNport_open(ifport->portnum, ifport->ptp, ifport->nt, ifport->l2hold, ifport->interface); + mISDNport = mISDNport_open(ifport->portnum, ifport->portname, ifport->ptp, ifport->nt, ifport->tespecial, ifport->l1hold, ifport->l2hold, ifport->interface); if (mISDNport) { /* link port */ ifport->mISDNport = mISDNport; mISDNport->ifport = ifport; + /* set number and name */ + ifport->portnum = mISDNport->portnum; + SCPY(ifport->portname, mISDNport->name); + /* set defaults */ set_defaults(ifport); } else { @@ -1368,13 +1489,13 @@ void do_screen(int out, char *id, int idsize, int *type, int *present, struct in } if (ifmsn) { - start_trace(0, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, DIRECTION_IN, 0, 0, "SCREEN (found in MSN list)"); + start_trace(-1, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, DIRECTION_IN, 0, 0, "SCREEN (found in MSN list)"); add_trace("msn", NULL, "%s", id); end_trace(); } if (!ifmsn && msn1) // not in list, first msn given { - start_trace(0, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, DIRECTION_IN, 0, 0, "SCREEN (not found in MSN list)"); + start_trace(-1, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, DIRECTION_IN, 0, 0, "SCREEN (not found in MSN list)"); add_trace("msn", "given", "%s", id); add_trace("msn", "used", "%s", msn1); end_trace(); @@ -1407,7 +1528,7 @@ void do_screen(int out, char *id, int idsize, int *type, int *present, struct in } if (ifscreen) // match { - start_trace(0, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, out?DIRECTION_OUT:DIRECTION_IN, 0, 0, "SCREEN (found in screen list)"); + start_trace(-1, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, out?DIRECTION_OUT:DIRECTION_IN, 0, 0, "SCREEN (found in screen list)"); switch(*type) { case INFO_NTYPE_UNKNOWN: