From 6d3d13def341dcddb6fe4336d18ce2ac9b996029 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sun, 14 Sep 2008 14:37:51 +0200 Subject: [PATCH] fixed some layer 2 link issues modified: README modified: apppbx.cpp modified: lcradmin.c modified: mISDN.cpp modified: route.c --- README | 1 + apppbx.cpp | 2 +- lcradmin.c | 7 +++++-- mISDN.cpp | 14 +++++++++----- route.c | 6 +++--- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README b/README index 1f3cde9..377e863 100644 --- a/README +++ b/README @@ -447,4 +447,5 @@ Changes in Version 1.1 Fixes in current Version - Changed isdninfo to misdn_info. - Fixed some trace bugs. +- Fixed some layer2-link issues. diff --git a/apppbx.cpp b/apppbx.cpp index c19865b..3132417 100644 --- a/apppbx.cpp +++ b/apppbx.cpp @@ -672,7 +672,7 @@ foundif: } /* see if link is up on PTP*/ - if (mISDNport->l2hold && !mISDNport->l2link) + if (mISDNport->l2hold && mISDNport->l2link<1) { trace_header("CHANNEL SELECTION (port's layer 2 is down, skipping)", DIRECTION_NONE); add_trace("port", NULL, "%d", ifport->portnum); diff --git a/lcradmin.c b/lcradmin.c index a63cb1c..1459aeb 100644 --- a/lcradmin.c +++ b/lcradmin.c @@ -681,8 +681,11 @@ const char *admin_state(int sock, char *argv[]) addstr(buffer); if (m[i].u.i.ptp || !m[i].u.i.ntmode) { - color((m[i].u.i.l2link)?green:red); - addstr((m[i].u.i.l2link)?" L2 UP":" L2 down"); + color((m[i].u.i.l2link > 0)?green:red); + if (m[i].u.i.l2link < 0) + addstr(" L2 unknown"); + else + addstr((m[i].u.i.l2link)?" L2 UP":" L2 down"); } color((m[i].u.i.l1link > 0)?green:blue); if (m[i].u.i.l1link < 0) diff --git a/mISDN.cpp b/mISDN.cpp index 0b4c8b0..88950b9 100644 --- a/mISDN.cpp +++ b/mISDN.cpp @@ -406,7 +406,7 @@ static int _bchannel_create(struct mISDNport *mISDNport, int i) ret = bind(mISDNport->b_socket[i], (struct sockaddr *)&addr, sizeof(addr)); if (ret < 0) { - PERROR("Error: Failed to bind bchannel-socket for index %d with mISDN-DSP layer. Did you load mISDN_dsp.ko?\n", i); + PERROR("Error: Failed to bind bchannel-socket for index %d with mISDN-DSP layer (errno=%d). Did you load mISDN_dsp.ko?\n", i, errno); close(mISDNport->b_socket[i]); mISDNport->b_socket[i] = -1; return(0); @@ -2006,6 +2006,7 @@ int mISDN_handler(void) l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_IND, DIRECTION_IN); add_trace("tei", NULL, "%d", l3m->pid); end_trace(); + mISDNport->l2link = 1; if ((!mISDNport->ntmode || mISDNport->ptp) && l3m->pid < 127) { if (mISDNport->l2establish) @@ -2013,7 +2014,6 @@ int mISDN_handler(void) mISDNport->l2establish = 0; PDEBUG(DEBUG_ISDN, "the link became active before l2establish timer expiry.\n"); } - mISDNport->l2link = 1; } break; @@ -2023,10 +2023,12 @@ int mISDN_handler(void) l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_IND, DIRECTION_IN); add_trace("tei", NULL, "%d", l3m->pid); end_trace(); + /* down if not nt-ptmp */ + if (!mISDNport->ntmode || mISDNport->ptp) + mISDNport->l2link = 0; } if ((!mISDNport->ntmode || mISDNport->ptp) && l3m->pid < 127) { - mISDNport->l2link = 0; if (!mISDNport->l2establish && mISDNport->l2hold) { PDEBUG(DEBUG_ISDN, "set timer and establish.\n"); @@ -2276,6 +2278,7 @@ struct mISDNport *mISDNport_open(int port, char *portname, int ptp, int force_nt mISDNportp = &((*mISDNportp)->next); mISDNport = (struct mISDNport *)MALLOC(sizeof(struct mISDNport)); mISDNport->l1link = -1; + mISDNport->l2link = -1; pmemuse++; *mISDNportp = mISDNport; @@ -2372,8 +2375,9 @@ struct mISDNport *mISDNport_open(int port, char *portname, int ptp, int force_nt time(&mISDNport->l2establish); } - /* initially, we assume that the link is down, exept for nt-ptmp */ - mISDNport->l2link = (mISDNport->ntmode && !mISDNport->ptp)?1:0; + /* for nt-mode ptmp the link is always up */ + if (mISDNport->ntmode && !mISDNport->ptp) + mISDNport->l2link = 1; PDEBUG(DEBUG_BCHANNEL, "using 'mISDN_dsp.o' module\n"); diff --git a/route.c b/route.c index 7022ae2..ce5d226 100644 --- a/route.c +++ b/route.c @@ -2147,7 +2147,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) if (mISDNport->ifport) if (strlen(mISDNport->ifport->interface->name) == comp_len) if (!strncasecmp(mISDNport->ifport->interface->name, cond->string_value, comp_len)) - if (!mISDNport->l2hold || mISDNport->l2link) + if (!mISDNport->l2hold || mISDNport->l2link>0) { j = 0; jj = mISDNport->b_num; @@ -2179,7 +2179,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) { if (mISDNport->ifport) if (!strcasecmp(mISDNport->ifport->interface->name, cond->string_value)) - if (!mISDNport->l2hold || mISDNport->l2link) + if (!mISDNport->l2hold || mISDNport->l2link>0) break; mISDNport = mISDNport->next; } @@ -2193,7 +2193,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) { if (mISDNport->ifport) if (!strcasecmp(mISDNport->ifport->interface->name, cond->string_value)) - if (!mISDNport->l2hold || mISDNport->l2link) + if (!mISDNport->l2hold || mISDNport->l2link>0) break; mISDNport = mISDNport->next; -- 2.13.6