fixed trace bug
[lcr.git] / mISDN.cpp
index e120c80..df550ae 100644 (file)
--- a/mISDN.cpp
+++ b/mISDN.cpp
@@ -2001,16 +2001,20 @@ int mISDN_handler(void)
                                break;
 
                                case MT_L2RELEASE:
-                               l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_IND, DIRECTION_IN);
-                               add_trace("tei", NULL, "%d", l3m->pid);
-                               end_trace();
+                               if (!mISDNport->l2establish)
+                               {
+                                       l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_IND, DIRECTION_IN);
+                                       add_trace("tei", NULL, "%d", l3m->pid);
+                                       end_trace();
+                               }
                                if ((!mISDNport->ntmode || mISDNport->ptp) && l3m->pid < 127)
                                {
                                        mISDNport->l2link = 0;
-                                       if (mISDNport->l2hold)
+                                       if (!mISDNport->l2establish && mISDNport->l2hold)
                                        {
+                                               PDEBUG(DEBUG_ISDN, "set timer and establish.\n");
                                                time(&mISDNport->l2establish);
-                                               PDEBUG(DEBUG_ISDN, "because we are ptp, we set a l2establish timer.\n");
+                                               mISDNport->ml3->to_layer3(mISDNport->ml3, MT_L2ESTABLISH, 0, NULL);
                                        }
                                }
                                break;
@@ -2041,12 +2045,6 @@ int mISDN_handler(void)
 
                                        PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link portnum=%d.\n", mISDNport->portnum);
                                        mISDNport->ml3->to_layer3(mISDNport->ml3, MT_L2ESTABLISH, 0, NULL);
-#if 0
-no L2 establish trace on every timeout
-                                       l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT);
-                                       add_trace("tei", NULL, "%d", 0);
-                                       end_trace();
-#endif
                                        time(&mISDNport->l2establish);
                                        return(1);
                                }
@@ -2217,6 +2215,7 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
        while(*mISDNportp)
                mISDNportp = &((*mISDNportp)->next);
        mISDNport = (struct mISDNport *)MALLOC(sizeof(struct mISDNport));
+       mISDNport->l1link = -1;
        pmemuse++;
        *mISDNportp = mISDNport;
 
@@ -2425,138 +2424,6 @@ void mISDNport_close(struct mISDNport *mISDNport)
 
 
 /*
- * global function to show all available isdn ports
- */
-void mISDN_port_info(void)
-{
-       int ret;
-       int i, ii;
-       int useable, nt, te, pri, bri, pots;
-       struct mISDN_devinfo devinfo;
-       int sock;
-
-       /* open mISDN */
-       sock = socket(PF_ISDN, SOCK_RAW, ISDN_P_BASE);
-       if (sock < 0)
-       {
-               fprintf(stderr, "Cannot open mISDN due to %s. (Does your Kernel support socket based mISDN?)\n", strerror(errno));
-               exit(EXIT_FAILURE);
-       }
-
-       /* get number of stacks */
-       i = 1;
-       ret = ioctl(sock, IMGETCOUNT, &ii);
-       if (ret < 0)
-       {
-               fprintf(stderr, "Cannot get number of mISDN devices. (ioctl IMGETCOUNT failed ret=%d)\n", ret);
-               goto done;
-       }
-       printf("\n");
-       if (ii <= 0)
-       {
-               printf("Found no card. Please be sure to load card drivers.\n");
-               goto done;
-       }
-
-       /* loop the number of cards and get their info */
-       while(i <= ii)
-       {
-               nt = te = bri = pri = pots = 0;
-               useable = 0;
-
-               devinfo.id = i - 1;
-               ret = ioctl(sock, IMGETDEVINFO, &devinfo);
-               if (ret < 0)
-               {
-                       fprintf(stderr, "Cannot get device information for port %d. (ioctl IMGETDEVINFO failed ret=%d)\n", i, ret);
-                       break;
-               }
-
-               /* output the port info */
-               printf("Port %2d name='%s': ", i, devinfo.name);
-               if (devinfo.Dprotocols & (1 << ISDN_P_TE_S0))
-               {
-                       bri = 1;
-                       te = 1;
-               }
-               if (devinfo.Dprotocols & (1 << ISDN_P_NT_S0))
-               {
-                       bri = 1;
-                       nt = 1;
-               }
-               if (devinfo.Dprotocols & (1 << ISDN_P_TE_E1))
-               {
-                       pri = 1;
-                       te = 1;
-               }
-               if (devinfo.Dprotocols & (1 << ISDN_P_NT_E1))
-               {
-                       pri = 1;
-                       nt = 1;
-               }
-#ifdef ISDN_P_FXS
-               if (devinfo.Dprotocols & (1 << ISDN_P_FXS))
-               {
-                       pots = 1;
-                       te = 1;
-               }
-#endif
-#ifdef ISDN_P_FXO
-               if (devinfo.Dprotocols & (1 << ISDN_P_FXO))
-               {
-                       pots = 1;
-                       nt = 1;
-               }
-#endif
-               if ((te || nt) && (bri || pri || pots))
-                       useable = 1;
-
-               if (te && nt && bri)
-                       printf("TE/NT-mode BRI S/T (for phone lines & phones)");
-               if (te && !nt && bri)
-                       printf("TE-mode    BRI S/T (for phone lines)");
-               if (nt && !te && bri)
-                       printf("NT-mode    BRI S/T (for phones)");
-               if (te && nt && pri)
-                       printf("TE/NT-mode PRI E1  (for phone lines & E1 devices)");
-               if (te && !nt && pri)
-                       printf("TE-mode    PRI E1  (for phone lines)");
-               if (nt && !te && pri)
-                       printf("NT-mode    PRI E1  (for E1 devices)");
-               if (te && nt && pots)
-                       printf("FXS/FXO    POTS    (for analog lines & phones)");
-               if (te && !nt && pots)
-                       printf("FXS        POTS    (for analog lines)");
-               if (nt && !te && pots)
-                       printf("FXO        POTS    (for analog phones)");
-               if (pots)
-               {
-                       useable = 0;
-                       printf("\n -> Analog interfaces are not supported.");
-               } else
-               if (!useable)
-               {
-                       printf("unsupported interface protocol bits 0x%016x", devinfo.Dprotocols);
-               }
-               printf("\n");
-
-               printf("  - %d B-channels\n", devinfo.nrbchan);
-
-               if (!useable)
-                       printf(" * Port NOT useable for LCR\n");
-
-               printf("--------\n");
-
-               i++;
-       }
-       printf("\n");
-
-done:
-       close(sock);
-}
-
-
-/*
  * enque data from upper buffer
  */
 void PmISDN::txfromup(unsigned char *data, int length)