removed some usleep debugging, so audioprocessing will not hang
[lcr.git] / dss1.cpp
index 9a6a922..18eb511 100644 (file)
--- a/dss1.cpp
+++ b/dss1.cpp
@@ -22,7 +22,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 extern "C" {
-#include <net_l2.h>
+#include <mISDNuser/net_l2.h>
 }
 
 //#define CENTREX
@@ -164,7 +164,7 @@ int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int ex
                end_trace();
 
                /* activate our exclusive channel */
-               bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE, p_m_exportremote);
+               bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
        } else
        if (p_m_b_channel)
        {
@@ -185,7 +185,7 @@ int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int ex
                        add_trace("connect", "channel", "%d", p_m_b_channel);
                        end_trace();
                        p_m_b_exclusive = 1; // we are done
-                       bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE, p_m_exportremote);
+                       bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
                        return(0);
                }
 
@@ -212,7 +212,7 @@ int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int ex
                end_trace();
 
                /* activate channel given by remote */
-               bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE, p_m_exportremote);
+               bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
        } else
        if (p_m_b_reserve)
        {
@@ -248,7 +248,7 @@ int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int ex
                end_trace();
 
                /* activate channel given by remote */
-               bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE, p_m_exportremote);
+               bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
        } else
        {
                /*** we sent 'no channel available' ***/
@@ -277,7 +277,7 @@ int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int ex
                        p_m_b_exclusive = 1; // we are done
 
                        /* activate channel given by remote */
-                       bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE, p_m_exportremote);
+                       bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
                        return(0);
                }
                
@@ -312,7 +312,7 @@ int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int ex
                p_m_b_exclusive = 1; // we are done
 
                /* activate channel given by remote */
-               bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE, p_m_exportremote);
+               bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
        }
        return(0);
 
@@ -731,7 +731,7 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data)
                p_m_delete = 1;
                return;
        }
-       bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE, p_m_exportremote);
+       bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
 
        /* create endpoint */
        if (p_epointlist)
@@ -1185,7 +1185,6 @@ void Pdss1::disconnect_ind_i(unsigned long prim, unsigned long dinfo, void *data
                add_trace("old-cause", "value", "%d", p_m_d_collect_cause);
        }
        dec_ie_cause(disconnect->CAUSE, (Q931_info_t *)((unsigned long)data+headerlen), &location, &cause);
-       end_trace();
        if (location == LOCATION_PRIVATE_LOCAL)
                location = LOCATION_PRIVATE_REMOTE;
 
@@ -1193,6 +1192,7 @@ void Pdss1::disconnect_ind_i(unsigned long prim, unsigned long dinfo, void *data
        collect_cause(&p_m_d_collect_cause, &p_m_d_collect_location, cause, location);
        add_trace("new-cause", "location", "%d", p_m_d_collect_location);
        add_trace("new-cause", "value", "%d", p_m_d_collect_cause);
+       end_trace();
 
 }
 
@@ -1473,7 +1473,7 @@ void Pdss1::retrieve_ind(unsigned long prim, unsigned long dinfo, void *data)
                cause = -ret;
                goto reject;
        }
-       bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE, p_m_exportremote);
+       bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
 
        /* set hold state */
        p_m_hold = 0;
@@ -1645,7 +1645,7 @@ void Pdss1::resume_ind(unsigned long prim, unsigned long dinfo, void *data)
                p_m_delete = 1;
                return;
        }
-       bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE, p_m_exportremote);
+       bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
 
        /* create endpoint */
        if (p_epointlist)
@@ -1979,8 +1979,8 @@ int Pdss1::handler(void)
 {
        int ret;
 
-if (p_m_delete && p_m_d_l3id==0)
-       printf("ping! %d", p_serial);
+//if (p_m_delete && p_m_d_l3id==0)
+//     printf("ping! %d", p_serial);
        if ((ret = PmISDN::handler()))
                return(ret);
 
@@ -3069,21 +3069,40 @@ int stack2manager_nt(void *dat, void *arg)
                        /* check out correct stack */
                        if (pdss1->p_m_mISDNport == mISDNport)
                        /* check out correct id */
-                       if ((hh->dinfo&0xffff0000) == (pdss1->p_m_d_l3id&0xffff0000))
+                       if ((pdss1->p_m_d_l3id&0x0000ff00) != 0x000ff00)
                        {
-                               /* found port, the message belongs to */
-                               break;
+                               /* a single process */
+                               if (hh->dinfo == pdss1->p_m_d_l3id)
+                               {
+                                       /* found port, the message belongs to */
+                                       break;
+                               }
+                       } else
+                       {
+                               /* a broadcast process */
+                               if ((hh->dinfo&0xffff0000) == (pdss1->p_m_d_l3id&0xffff0000))
+                               {
+                                       /* found port, the message belongs to */
+                                       break;
+                               }
                        }
                }
                port = port->next;
        }
        if (port)
        {
+//printf("%x %x\n", hh->dinfo, pdss1->p_m_d_l3id);
                /* if process id is master process, but a child disconnects */
-               if ((hh->dinfo&0x0000ff00)!=0x0000ff00 && (pdss1->p_m_d_l3id&0x0000ff00)==0x0000ff00 && hh->prim==(CC_DISCONNECT|INDICATION))
+               if ((hh->dinfo&0x0000ff00)!=0x0000ff00 && (pdss1->p_m_d_l3id&0x0000ff00)==0x0000ff00)
                {
-                       /* send special indication for child disconnect */
-                       pdss1->disconnect_ind_i(hh->prim, hh->dinfo, msg->data);
+                       if (hh->prim == (CC_DISCONNECT|INDICATION))
+                       {
+                               /* send special indication for child disconnect */
+                               pdss1->disconnect_ind_i(hh->prim, hh->dinfo, msg->data);
+                               free_msg(msg);
+                               return(0);
+                       }
+                       // ignoring other messages from child processes
                        free_msg(msg);
                        return(0);
                }
@@ -3166,11 +3185,28 @@ int stack2manager_nt(void *dat, void *arg)
                PERROR("unhandled message from stack: call ref released (l3id=0x%x)\n", hh->dinfo);
                break;
 
-               case CC_DISCONNECT | INDICATION:
+               case CC_RELEASE_COMPLETE | INDICATION:
+               break;
+
+               case CC_FACILITY | INDICATION:
+               break;
 
-               // fall throug
                default:
                PERROR("unhandled message: prim(0x%x) dinfo(0x%x) msg->len(%d)\n", hh->prim, hh->dinfo, msg->len);
+               port = port_first;
+               while(port)
+               {
+                       if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT)
+                       {
+                               pdss1 = (class Pdss1 *)port;
+       //PDEBUG(DEBUG_ISDN, "comparing dinfo = 0x%x with l3id 0x%x\n", hh->dinfo, pdss1->p_m_d_l3id);
+                               /* check out correct stack */
+                               if (pdss1->p_m_mISDNport == mISDNport)
+                               /* check out correct id */
+                               PERROR("unhandled message: dinfo=%x is not associated with port-dinfo=%x\n",hh->dinfo,pdss1->p_m_d_l3id);
+                       }
+                       port = port->next;
+               }
                return(-EINVAL);
        }
        free_msg(msg);