X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=interface.c;h=c70222cf043dc587d4ca8f154ddb503a8830681d;hp=6ac2871bf31bc15be042bb0c09ab59995da61bb6;hb=b2a665f8f1cdeb7d02c3f665d95e6a80297e21d1;hpb=1bfbfbf903777d13df3107fbc89bdaeb2af9f2d6 diff --git a/interface.c b/interface.c index 6ac2871..c70222c 100644 --- a/interface.c +++ b/interface.c @@ -187,7 +187,6 @@ static int inter_ptmp(struct interface *interface, char *filename, int line, cha #endif static int inter_nt(struct interface *interface, char *filename, int line, char *parameter, char *value) { -#ifdef SOCKET_MISDN struct interface_port *ifport; /* port in chain ? */ @@ -207,7 +206,6 @@ static int inter_nt(struct interface *interface, char *filename, int line, char return(-1); } ifport->nt = 1; -#endif return(0); } static int inter_tones(struct interface *interface, char *filename, int line, char *parameter, char *value) @@ -260,6 +258,11 @@ static int inter_hunt(struct interface *interface, char *filename, int line, cha } static int inter_port(struct interface *interface, char *filename, int line, char *parameter, char *value) { + SPRINT(interface_error, "Error in %s (line %d): parameter '%s' is outdated.\nPlease use 'portnum' and decrease port number by 1! Ports are counted from 0 now.\n", filename, line, parameter); + return(-1); +} +static int inter_portnum(struct interface *interface, char *filename, int line, char *parameter, char *value) +{ struct interface_port *ifport, **ifportp; struct interface *searchif; int val; @@ -299,6 +302,41 @@ static int inter_port(struct interface *interface, char *filename, int line, cha *ifportp = ifport; return(0); } +static int inter_portname(struct interface *interface, char *filename, int line, char *parameter, char *value) +{ + 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_l2hold(struct interface *interface, char *filename, int line, char *parameter, char *value) { struct interface_port *ifport; @@ -855,7 +893,11 @@ struct interface_param interface_param[] = { "Select the algorithm for selecting port with free channel."}, {"port", &inter_port, "", + ""}, + {"portnum", &inter_portnum, "", "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" @@ -875,11 +917,7 @@ struct interface_param interface_param[] = { {"nt", &inter_nt, "", "The given port above is opened in NT-mode.\n" -#ifdef SOCKET_MISDN "This is required on interfaces that support both NT-mode and TE-mode.\n" -#else - "This parameter is only required for socket based mISDN driver.\n" -#endif "This parameter must follow a 'port' parameter."}, {"layer2hold", &inter_l2hold, "yes | no", @@ -1287,12 +1325,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->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 { @@ -1314,15 +1356,19 @@ void doc_interface(void) ifparam = interface_param; while(ifparam->name) { - printf("%s %s\n", ifparam->name, ifparam->usage); + if (ifparam->name[0]) + printf("%s %s\n", ifparam->name, ifparam->usage); ifparam++; } ifparam = interface_param; while(ifparam->name) { - printf("\nParameter: %s %s\n", ifparam->name, ifparam->usage); - printf("%s\n", ifparam->help); + if (ifparam->name[0]) + { + printf("\nParameter: %s %s\n", ifparam->name, ifparam->usage); + printf("%s\n", ifparam->help); + } ifparam++; } } @@ -1356,13 +1402,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), NULL, DIRECTION_IN, 0, 0, "SCREEN (found in MSN list)"); + start_trace(0, 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), NULL, DIRECTION_IN, 0, 0, "SCREEN (not found in MSN list)"); + start_trace(0, 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(); @@ -1395,7 +1441,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), NULL, out?DIRECTION_OUT:DIRECTION_IN, 0, 0, "SCREEN (found in screen list)"); + 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)"); switch(*type) { case INFO_NTYPE_UNKNOWN: