lcr work (soon done :)
[lcr.git] / mISDN.cpp
index 41b2122..b44049f 100644 (file)
--- a/mISDN.cpp
+++ b/mISDN.cpp
@@ -1613,14 +1613,14 @@ int PmISDN::handler(void)
                        }
 
                        /* send data */
-                       if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
+                       if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE && ISDN_LOAD-p_m_load-tosend > 0)
                        {
 #ifdef SOCKET_MISDN
                                frm->prim = PH_DATA_REQ;
                                frm->id = 0;
                                ret = sendto(p_m_mISDNport->b_socket[p_m_b_index], buf, MISDN_HEADER_LEN+ISDN_LOAD-p_m_load-tosend, 0, NULL, 0);
                                if (ret <= 0)
-                                       PERROR("Failed to send to socket %d\n", p_m_mISDNport->b_socket[p_m_b_index]);
+                                       PERROR("Failed to send to socket %d (samples = %d)\n", p_m_mISDNport->b_socket[p_m_b_index], ISDN_LOAD-p_m_load-tosend);
 #else
                                frm->prim = DL_DATA | REQUEST; 
                                frm->addr = p_m_mISDNport->b_addr[p_m_b_index] | FLG_MSG_DOWN;
@@ -1746,11 +1746,8 @@ void PmISDN::bchannel_receive(iframe_t *frm)
 #endif
                {
 #ifndef OLD_MISDN
-#ifdef SOCKET_MISDN
-                       case DSP_TX_DATA:
-#else
+#ifndef SOCKET_MISDN
                        case CMX_TX_DATA:
-#endif
                        if (!p_m_txdata)
                        {
                                /* if tx is off, it may happen that fifos send us pending informations, we just ignore them */
@@ -1766,6 +1763,7 @@ void PmISDN::bchannel_receive(iframe_t *frm)
                                record(data, len, 1); // from up
                        break;
 #endif
+#endif
 
                        default:
                        chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN);
@@ -1779,6 +1777,23 @@ void PmISDN::bchannel_receive(iframe_t *frm)
                return;
        }
 #ifdef SOCKET_MISDN
+       if (hh->prim == PH_DATA_REQ || hh->prim == DL_DATA_REQ)
+       {
+               if (!p_m_txdata)
+               {
+                       /* if tx is off, it may happen that fifos send us pending informations, we just ignore them */
+                       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)
+                       return;
+//             printf(".");fflush(stdout);return;
+               if (p_record)
+                       record(data, len, 1); // from up
+               return;
+       }
        if (hh->prim != PH_DATA_IND && hh->prim != DL_DATA_IND)
        {
                PERROR("Bchannel received unknown primitve: 0x%x\n", hh->prim);
@@ -2365,6 +2380,7 @@ int mISDN_handler(void)
 
                                case MT_L2ESTABLISH:
                                l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_IND, DIRECTION_IN);
+                               add_trace("tei", NULL, "%d", l3m->pid);
                                end_trace();
                                if ((!mISDNport->ntmode || mISDNport->ptp) && l3m->pid < 127)
                                {
@@ -2379,6 +2395,7 @@ int mISDN_handler(void)
 
                                case MT_L2RELEASE:
                                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)
                                {
@@ -2418,6 +2435,7 @@ 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);
                                        l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT);
+                                       add_trace("tei", NULL, "%d", 0);
                                        end_trace();
                                        time(&mISDNport->l2establish);
                                        return(1);
@@ -2557,6 +2575,7 @@ int mISDN_handler(void)
                                                mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
                                        }
                                        l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT);
+                                       add_trace("tei", NULL, "%d", 0);
                                        end_trace();
                                        time(&mISDNport->l2establish);
                                        return(1);
@@ -3338,6 +3357,7 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
        {
                mISDNport->ml3->to_layer3(mISDNport->ml3, MT_L2ESTABLISH, 0, NULL);
                l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT);
+               add_trace("tei", NULL, "%d", 0);
                end_trace();
                time(&mISDNport->l2establish);
        }