fixed some layer 2 link issues
authorAndreas Eversberg <andreas@eversberg.eu>
Sun, 14 Sep 2008 12:37:51 +0000 (14:37 +0200)
committerAndreas Eversberg <andreas@eversberg.eu>
Sun, 14 Sep 2008 12:37:51 +0000 (14:37 +0200)
modified:   README
modified:   apppbx.cpp
modified:   lcradmin.c
modified:   mISDN.cpp
modified:   route.c

README
apppbx.cpp
lcradmin.c
mISDN.cpp
route.c

diff --git a/README b/README
index 1f3cde9..377e863 100644 (file)
--- 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.
 
index c19865b..3132417 100644 (file)
@@ -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);
index a63cb1c..1459aeb 100644 (file)
@@ -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)
index 0b4c8b0..88950b9 100644 (file)
--- 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 (file)
--- 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;