fixed multiplexing bug at NT-mode.
[lcr.git] / mISDN.cpp
index 2507209..0abffd6 100644 (file)
--- a/mISDN.cpp
+++ b/mISDN.cpp
@@ -28,7 +28,7 @@
 #include <mlayer3.h>
 #else
 extern "C" {
-#include <net_l2.h>
+#include <mISDNuser/net_l2.h>
 }
 #endif
 
@@ -1173,15 +1173,14 @@ seize:
  */
 void PmISDN::drop_bchannel(void)
 {
-       if (p_m_b_index < 0)
-               return;
-
        /* unreserve channel */
        if (p_m_b_reserve)
                p_m_mISDNport->b_reserved--;
        p_m_b_reserve = 0;
 
        /* if not in use */
+       if (p_m_b_index < 0)
+               return;
        if (!p_m_b_channel)
                return;
 
@@ -1265,7 +1264,7 @@ void message_bchannel_from_join(class JoinRemote *joinremote, int type, unsigned
 #ifdef SOCKET_MISDN
                                if (mISDNport->b_socket[i] == handle)
 #else
-                               if ((mISDNport->portnum<<8)+i+1+(i>=15) == handle)
+                               if ((unsigned long)(mISDNport->portnum<<8)+i+1+(i>=15) == handle)
 #endif
                                        break;
                                i++;
@@ -1416,6 +1415,7 @@ int PmISDN::handler(void)
                                        /* next loop */
                                        p_m_crypt_msg_current = 0;
                                        p_m_crypt_msg_loops--;
+//                                     puts("eine loop weniger");
                                }
 
                                /* new length */
@@ -1532,6 +1532,21 @@ void PmISDN::bchannel_receive(iframe_t *frm)
                        message_put(message);
                        break;
 
+                       default:
+                       chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN);
+                       add_trace("unknown", NULL, "0x%x", cont);
+                       end_trace();
+               }
+               return;
+       }
+#ifdef SOCKET_MISDN
+       if (hh->prim == PH_SIGNAL_IND)
+#else
+       if (frm->prim == (PH_SIGNAL | INDICATION))
+#endif
+       {
+               switch(frm->dinfo)
+               {
                        case CMX_TX_DATA:
                        if (!p_m_txdata)
                        {
@@ -1539,13 +1554,18 @@ void PmISDN::bchannel_receive(iframe_t *frm)
                                PDEBUG(DEBUG_BCHANNEL, "PmISDN(%s) ignoring tx data, because 'txdata' is turned off\n", p_name);
                                return;
                        }
+                       /* see below (same condition) */
+                       if (p_state!=PORT_STATE_CONNECT
+                                && !p_m_mISDNport->tones)
+                               break;
+//                     printf(".");fflush(stdout);return;
                        if (p_record)
-                               record((unsigned char *)(cont+1), len - 4, 1); // from up
+                               record(data, len, 1); // from up
                        break;
 
                        default:
-                       chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN);
-                       add_trace("unknown", NULL, "0x%x", cont);
+                       chan_trace_header(p_m_mISDNport, this, "BCHANNEL signal", DIRECTION_IN);
+                       add_trace("unknown", NULL, "0x%x", frm->dinfo);
                        end_trace();
                }
                return;
@@ -1561,14 +1581,13 @@ void PmISDN::bchannel_receive(iframe_t *frm)
 #endif
                return;
        }
-
        /* calls will not process any audio data unless
         * the call is connected OR interface features audio during call setup.
         */
 //printf("%d -> %d prim=%x joindata=%d tones=%d\n", p_serial, ACTIVE_EPOINT(p_epointlist), frm->prim, p_m_joindata, p_m_mISDNport->earlyb);    
 #ifndef DEBUG_COREBRIDGE
        if (p_state!=PORT_STATE_CONNECT
-        && !p_m_mISDNport->earlyb)
+        && !p_m_mISDNport->tones)
                return;
 #endif
 
@@ -1896,7 +1915,7 @@ void PmISDN::message_crypt(unsigned long epoint_id, int message_id, union parame
                        break;
                }
                p_m_crypt_msg_current = 0; /* reset */
-               p_m_crypt_msg_loops = 3; /* enable */
+               p_m_crypt_msg_loops = 6; /* enable */
 #if 0
                /* disable txmix, or we get corrupt data due to audio process */
                if (p_m_txmix && p_m_b_index>=0)
@@ -2460,6 +2479,7 @@ int mISDN_handler(void)
                        case PH_DATA | INDICATION:
                        case DL_DATA | INDICATION:
                        case PH_CONTROL | INDICATION:
+                       case PH_SIGNAL | INDICATION:
                        i = 0;
                        while(i < mISDNport->b_num)
                        {