- if (mISDNport->ntmode)
- {
- PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link NT portnum=%d.\n", mISDNport->portnum);
- time(&mISDNport->l2establish);
- /* establish */
- dmsg = create_l2msg(DL_ESTABLISH | REQUEST, 0, 0);
- if (mISDNport->nst.manager_l3(&mISDNport->nst, dmsg))
- free_msg(dmsg);
- } else {
- PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link TE portnum=%d.\n", mISDNport->portnum);
- time(&mISDNport->l2establish);
- /* establish */
- iframe_t act;
- act.prim = DL_ESTABLISH | REQUEST;
- act.addr = (mISDNport->upper_id & ~LAYER_ID_MASK) | 3 | FLG_MSG_DOWN;
- act.dinfo = 0;
- act.len = 0;
- mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
+
+ PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link portnum=%d.\n", mISDNport->portnum);
+#warning SOCKET TBD
+// mISDNport->ml3->to_layer2(mISDNport->ml3, DL_ESTABLISH_REQ);
+// l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT);
+// end_trace();
+ return(1);
+ }
+ }
+
+
+ mISDNport = mISDNport->next;
+ }
+
+ /* if we received at least one b-frame, we will return 1 */
+ return(work);
+}
+#else
+int mISDN_handler(void)
+{
+ int ret;
+ struct mISDNport *mISDNport;
+ class PmISDN *isdnport;
+ int i;
+ msg_t *msg;
+ iframe_t *frm;
+ msg_t *dmsg;
+ mISDNuser_head_t *hh;
+ net_stack_t *nst;
+
+ /* the que avoids loopbacks when replying to stack after receiving
+ * from stack. */
+ mISDNport = mISDNport_first;
+ while(mISDNport)
+ {
+ /* process turning on/off rx */
+ i = 0;
+ while(i < mISDNport->b_num)
+ {
+ /* process timer events for bchannel handling */
+ if (mISDNport->b_timer[i])
+ {
+ if (mISDNport->b_timer[i] <= now_d)
+ bchannel_event(mISDNport, i, B_EVENT_TIMEOUT);
+ }
+ isdnport=mISDNport->b_port[i];
+ if (isdnport)
+ {
+ /* call bridges in user space OR crypto OR recording */
+ if (isdnport->p_m_joindata || isdnport->p_m_crypt_msg_loops || isdnport->p_m_crypt_listen || isdnport->p_record)
+ {
+ /* rx IS required */
+ if (isdnport->p_m_rxoff)
+ {
+ /* turn on RX */
+ isdnport->p_m_rxoff = 0;
+ PDEBUG(DEBUG_BCHANNEL, "%s: receive data is required, so we turn them on\n");
+ if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE)
+ ph_control(mISDNport, isdnport, mISDNport->b_addr[isdnport->p_m_b_index], CMX_RECEIVE_ON, 0, "DSP-RXOFF", 0);
+ return(1);
+ }
+ } else
+ {
+ /* rx NOT required */
+ if (!isdnport->p_m_rxoff)
+ {
+ /* turn off RX */
+ isdnport->p_m_rxoff = 1;
+ PDEBUG(DEBUG_BCHANNEL, "%s: receive data is not required, so we turn them off\n");
+ if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE)
+ ph_control(mISDNport, isdnport, mISDNport->b_addr[isdnport->p_m_b_index], CMX_RECEIVE_OFF, 0, "DSP-RXOFF", 1);
+ return(1);
+ }
+ }
+ /* recording */
+ if (isdnport->p_record)
+ {
+ /* txdata IS required */
+ if (!isdnport->p_m_txdata)
+ {
+ /* turn on RX */
+ isdnport->p_m_txdata = 1;
+ PDEBUG(DEBUG_BCHANNEL, "%s: transmit data is required, so we turn them on\n");
+#ifndef OLD_MISDN
+ if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE)
+ ph_control(mISDNport, isdnport, mISDNport->b_addr[isdnport->p_m_b_index], CMX_TXDATA_ON, 0, "DSP-TXDATA", 1);
+#endif
+ return(1);
+ }
+ } else
+ {
+ /* txdata NOT required */
+ if (isdnport->p_m_txdata)
+ {
+ /* turn off RX */
+ isdnport->p_m_txdata = 0;
+ PDEBUG(DEBUG_BCHANNEL, "%s: transmit data is not required, so we turn them off\n");
+#ifndef OLD_MISDN
+ if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE)
+ ph_control(mISDNport, isdnport, mISDNport->b_addr[isdnport->p_m_b_index], CMX_TXDATA_OFF, 0, "DSP-TXDATA", 0);
+#endif
+ return(1);
+ }
+ }
+ }
+ i++;
+ }
+#if 0
+ if (mISDNport->l1timeout && now>mISDNport->l1timeout)
+ { ---}
+ PDEBUG(DEBUG_ISDN, "the L1 establish timer expired, we release all pending messages.\n", mISDNport->portnum);
+ mISDNport->l1timeout = 0;
+#endif
+
+ if (mISDNport->l2establish)
+ {
+ if (now-mISDNport->l2establish > 5)
+ {
+ if (mISDNport->ntmode)
+ {
+ PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link NT portnum=%d.\n", mISDNport->portnum);
+ time(&mISDNport->l2establish);
+ /* establish */
+ dmsg = create_l2msg(DL_ESTABLISH | REQUEST, 0, 0);
+ if (mISDNport->nst.manager_l3(&mISDNport->nst, dmsg))
+ free_msg(dmsg);
+ } else {
+ iframe_t act;
+
+ PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link TE portnum=%d.\n", mISDNport->portnum);
+ time(&mISDNport->l2establish);
+ /* establish */
+ act.prim = DL_ESTABLISH | REQUEST;
+ act.addr = (mISDNport->upper_id & ~LAYER_ID_MASK) | 3 | FLG_MSG_DOWN;
+ act.dinfo = 0;
+ act.len = 0;
+ mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);