From b95114936f9fc12816035db92beb3def4b5b0506 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sat, 6 Sep 2008 13:59:48 +0200 Subject: [PATCH] changed port attribute to "portnum". modified: bchannel.c modified: default/interface.conf modified: interface.c modified: mISDN.cpp modified: route.c --- bchannel.c | 4 ++-- default/interface.conf | 46 +++++++++++++++++++++++----------------------- interface.c | 24 +++++++++++++++++++++--- mISDN.cpp | 14 +++++++------- route.c | 4 ++-- 5 files changed, 55 insertions(+), 37 deletions(-) diff --git a/bchannel.c b/bchannel.c index eb1ad88..3625eba 100644 --- a/bchannel.c +++ b/bchannel.c @@ -164,12 +164,12 @@ int bchannel_create(struct bchannel *bchannel, int mode) /* bind socket to bchannel */ addr.family = AF_ISDN; - addr.dev = (bchannel->handle>>8)-1; + addr.dev = (bchannel->handle>>8); addr.channel = bchannel->handle & 0xff; ret = bind(bchannel->b_sock, (struct sockaddr *)&addr, sizeof(addr)); if (ret < 0) { - CERROR(bchannel->call, NULL, "Failed to bind bchannel-socket for handle 0x%x with mISDN-DSP layer. (port %d, channel %d) Did you load mISDNdsp.ko?\n", bchannel->handle, addr.dev + 1, addr.channel); + CERROR(bchannel->call, NULL, "Failed to bind bchannel-socket for handle 0x%x with mISDN-DSP layer. (port %d, channel %d) Did you load mISDNdsp.ko?\n", bchannel->handle, addr.dev, addr.channel); close(bchannel->b_sock); bchannel->b_sock = -1; return(0); diff --git a/default/interface.conf b/default/interface.conf index 3a8b74d..db5af49 100644 --- a/default/interface.conf +++ b/default/interface.conf @@ -2,45 +2,45 @@ ################ -# Example of an ISDN interface on port 1 +# Example of an ISDN interface on port 0 #[Ext] -#port 1 +#portnum 0 -# Example of a multilink ISDN interface (Anlagenanschluss) on port 3 -# and 4 +# Example of a multilink ISDN interface (Anlagenanschluss) on port 2 +# and 3 #[Ext] -#port 3 -#port 4 +#portnum 2 +#portnum 3 -# Example of an PTP ISDN interface on port 1 +# Example of an PTP ISDN interface on port 0 # Layer-2-Hold is required to keep link alive. #[Ext] -#port 1 +#portnum 0 #ptp #layer2hold yes -# Example of an internal ISDN interface on port 2, which accepts all extensions +# Example of an internal ISDN interface on port 1, which accepts all extensions #[Int] #extension -#port 2 +#portnum 1 #nt -# Example of an ISDN interface on port 2, which accepts only extensions +# Example of an ISDN interface on port 1, which accepts only extensions # 201, 202 and 203 #[Int] #extension #msn 201,202,203 -#port 2 +#portnum 1 #nt -# Example of three ISDN interfaces on port 2, 3 and 4, which accept +# Example of three ISDN interfaces on port 1, 2 and 3, which accept # extension 201 on all interfaces, and extension 202 and 203 on the first port # only. # Hint: To make extension ring on all three interfaces parallel, use @@ -49,23 +49,23 @@ #[Int1] #extension #msn 201,202,203 -#port 2 +#portnum 1 #nt #[Int2] #extension #msn 201 -#port 3 +#portnum 2 #nt #[Int3] #extension #msn 201 -#port 4 +#portnum 3 #nt -# Example of an ISDN interface on port 1 that requires screening of caller IDs. +# Example of an ISDN interface on port 0 that requires screening of caller IDs. # This is required if the connected line doesn't screen caller IDs. # Also this interface will connect bchannel during call setup, so tones are # required. @@ -73,10 +73,10 @@ #screen-out unknown 300 national 21250993300 #screen-out unknown 2* national 212509932* #tones yes -#port 1 +#portnum 0 -# Example of an ISDN PRI interface on port 1 that has directed channels. +# Example of an ISDN PRI interface on port 0 that has directed channels. # 10 channels (channel 1-10) are incomming only. # 10 channels (channel 11-15,17-21) are outgoing only. # 10 channels (channel 22-31) are both way. @@ -84,7 +84,7 @@ # Outgoing calls on both-way-channels shall be indicated as "any channel". # (Siemens EWSD will select bot-way-channels when indicated that way.) #[Ext] -#port 1 +#portnum 0 #layer2hold #channel-in 1,2,3,4,5,6,7,8,9,10,22,23,24,25,26,27,28,29,30,31 #channel-out force,11,12,13,14,15,17,18,19,20,21,any @@ -95,7 +95,7 @@ # Additinally the timeout values for the different call states are adjusted to 60 seconds. # They are: setup, dialing, proceeding, alerting, disconnect #[PBX] -#port 5 +#portnum 4 #nt #layer2hold yes #earlyb yes @@ -108,13 +108,13 @@ [Ext] -port 1 +portnum 0 [Int] extension msn 200,201,202,203 -port 2 +portnum 1 nt diff --git a/interface.c b/interface.c index 1adc838..98a87ac 100644 --- a/interface.c +++ b/interface.c @@ -258,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; @@ -297,6 +302,11 @@ 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) +{ + SPRINT(interface_error, "Error in %s (line %d): parameter '%s' not implemented yet.\n", filename, line, parameter); + return(-1); +} static int inter_l2hold(struct interface *interface, char *filename, int line, char *parameter, char *value) { struct interface_port *ifport; @@ -853,6 +863,10 @@ 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, "", "Give exactly one port for this interface.\nTo give multiple ports, add more lines with port parameters."}, {"block", &inter_block, "", @@ -1308,15 +1322,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++; } } diff --git a/mISDN.cpp b/mISDN.cpp index 3582f9f..281ef2a 100644 --- a/mISDN.cpp +++ b/mISDN.cpp @@ -199,7 +199,7 @@ PmISDN::~PmISDN() void chan_trace_header(struct mISDNport *mISDNport, class PmISDN *port, const char *msgtext, int direction) { /* init trace with given values */ - start_trace(mISDNport?mISDNport->portnum:0, + start_trace(mISDNport?mISDNport->portnum:-1, (mISDNport)?((mISDNport->ifport)?mISDNport->ifport->interface:NULL):NULL, port?numberrize_callerinfo(port->p_callerinfo.id, port->p_callerinfo.ntype, options.national, options.international):NULL, port?port->p_dialinginfo.id:NULL, @@ -301,7 +301,7 @@ void l1l2l3_trace_header(struct mISDNport *mISDNport, class PmISDN *port, unsign } /* init trace with given values */ - start_trace(mISDNport?mISDNport->portnum:0, + start_trace(mISDNport?mISDNport->portnum:-1, mISDNport?(mISDNport->ifport?mISDNport->ifport->interface:NULL):NULL, port?numberrize_callerinfo(port->p_callerinfo.id, port->p_callerinfo.ntype, options.national, options.international):NULL, port?port->p_dialinginfo.id:NULL, @@ -401,7 +401,7 @@ static int _bchannel_create(struct mISDNport *mISDNport, int i) /* bind socket to bchannel */ addr.family = AF_ISDN; - addr.dev = mISDNport->portnum-1; + addr.dev = mISDNport->portnum; addr.channel = i+1+(i>=15); ret = bind(mISDNport->b_socket[i], (struct sockaddr *)&addr, sizeof(addr)); if (ret < 0) @@ -2140,14 +2140,14 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st PERROR_RUNTIME("Found no card. Please be sure to load card drivers.\n"); return(NULL); } - if (port>cnt || port<1) + if (port>cnt || port<0) { - PERROR_RUNTIME("Port (%d) given at 'ports' (options.conf) is out of existing port range (%d-%d)\n", port, 1, cnt); + PERROR_RUNTIME("Port (%d) given at 'ports' (options.conf) is out of existing port range (%d-%d)\n", port, 0, cnt); return(NULL); } pri = bri = pots = nt = te = 0; - devinfo.id = port - 1; + devinfo.id = port; ret = ioctl(mISDNsocket, IMGETDEVINFO, &devinfo); if (ret < 0) { @@ -2263,7 +2263,7 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st prop |= (1 << MISDN_FLG_L2_HOLD); /* queue must be initializes, because l3-thread may send messages during open_layer3() */ mqueue_init(&mISDNport->upqueue); - mISDNport->ml3 = open_layer3(port-1, protocol, prop , do_layer3, mISDNport); + mISDNport->ml3 = open_layer3(port, protocol, prop , do_layer3, mISDNport); if (!mISDNport->ml3) { mqueue_purge(&mISDNport->upqueue); diff --git a/route.c b/route.c index 13ead05..7022ae2 100644 --- a/route.c +++ b/route.c @@ -1954,7 +1954,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) struct route_rule *rule = ruleset->rule_first; struct route_cond *cond; struct route_action *action = NULL; - unsigned int comp_len; + unsigned long comp_len; int j, jj; char callerid[64], redirid[64]; int integer; @@ -2270,7 +2270,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) match_string_prefix: comp_len = strlen(cond->string_value); /* because we must reach value's length */ /* we must have greater or equal length to values */ - if ((unsigned int)strlen(string) < comp_len) + if ((unsigned long)strlen(string) < comp_len) { /* special case for unfinished dialing */ if (cond->match == MATCH_DIALING) -- 2.13.6