Added bridgin support for GSM and SIP
[lcr.git] / dss1.cpp
index d1430dc..f0834af 100644 (file)
--- a/dss1.cpp
+++ b/dss1.cpp
@@ -16,7 +16,9 @@
 extern "C" {
 }
 #include <mISDN/q931.h>
+#ifdef OLD_MT_ASSIGN
 extern unsigned int mt_assign_pid;
+#endif
 
 #include "ie.cpp"
 
@@ -801,6 +803,13 @@ void Pdss1::setup_acknowledge_ind(unsigned int cmd, unsigned int pid, struct l3_
        dec_ie_progress(l3m, &coding, &location, &progress);
        end_trace();
 
+       if (progress >= 0) {
+               message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROGRESS);
+               message->param.progressinfo.progress = progress;
+               message->param.progressinfo.location = location;
+               message_put(message);
+       }
+
        /* process channel */
        ret = received_first_reply_to_setup(cmd, channel, exclusive);
        if (ret < 0) {
@@ -850,6 +859,13 @@ void Pdss1::proceeding_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3
        dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
        end_trace();
 
+       if (progress >= 0) {
+               message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROGRESS);
+               message->param.progressinfo.progress = progress;
+               message->param.progressinfo.location = location;
+               message_put(message);
+       }
+
        ret = received_first_reply_to_setup(cmd, channel, exclusive);
        if (ret < 0) {
                message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
@@ -926,6 +942,13 @@ void Pdss1::alerting_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
        dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
        end_trace();
 
+       if (progress >= 0) {
+               message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROGRESS);
+               message->param.progressinfo.progress = progress;
+               message->param.progressinfo.location = location;
+               message_put(message);
+       }
+
        /* process channel */
        ret = received_first_reply_to_setup(cmd, channel, exclusive);
        if (ret < 0) {
@@ -1099,6 +1122,13 @@ void Pdss1::disconnect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3
                location = LOCATION_PRIVATE_LOCAL;
        }
 
+       if (progress >= 0) {
+               message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROGRESS);
+               message->param.progressinfo.progress = progress;
+               message->param.progressinfo.location = proglocation;
+               message_put(message);
+       }
+
        /* release if remote sends us no tones */
        if (!p_m_mISDNport->earlyb) {
                l3_msg *l3m;
@@ -1639,6 +1669,13 @@ void Pdss1::progress_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
        l1l2l3_trace_header(p_m_mISDNport, this, L3_PROGRESS_IND, DIRECTION_IN);
        dec_ie_progress(l3m, &coding, &location, &progress);
        end_trace();
+
+       if (progress >= 0) {
+               message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROGRESS);
+               message->param.progressinfo.progress = progress;
+               message->param.progressinfo.location = location;
+               message_put(message);
+       }
 }
 
 
@@ -1906,7 +1943,9 @@ void Pdss1::message_information(unsigned int epoint_id, int message_id, union pa
 void Pdss1::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
 {
        l3_msg *l3m;
+#ifdef OLD_MT_ASSIGN
        int ret;
+#endif
        int plan, type, screen, present, reason;
        int plan2, type2, screen2, present2;
        int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
@@ -1933,8 +1972,8 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete
        memcpy(&p_capainfo, &param->setup.capainfo, sizeof(p_capainfo));
        memcpy(&p_redirinfo, &param->setup.redirinfo, sizeof(p_redirinfo));
        /* screen outgoing caller id */
-       do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_m_mISDNport->ifport->interface);
-       do_screen(1, p_callerinfo.id2, sizeof(p_callerinfo.id2), &p_callerinfo.ntype2, &p_callerinfo.present2, p_m_mISDNport->ifport->interface);
+       do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_m_mISDNport->ifport->interface->name);
+       do_screen(1, p_callerinfo.id2, sizeof(p_callerinfo.id2), &p_callerinfo.ntype2, &p_callerinfo.present2, p_m_mISDNport->ifport->interface->name);
 
        /* only display at connect state: this case happens if endpoint is in connected mode */
        if (p_state==PORT_STATE_CONNECT) {
@@ -1976,10 +2015,18 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete
 
        /* creating l3id */
        l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT);
+#ifdef OLD_MT_ASSIGN
        /* see MT_ASSIGN notes at do_layer3() */
        mt_assign_pid = 0;
        ret = p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ASSIGN, 0, NULL);
-       if (mt_assign_pid == 0 || ret < 0) {
+       if (mt_assign_pid == 0 || ret < 0)
+       p_m_d_l3id = mt_assign_pid;
+       mt_assign_pid = ~0;
+#else
+       p_m_d_l3id = request_new_pid(p_m_mISDNport->ml3);
+       if (p_m_d_l3id == MISDN_PID_NONE)
+#endif
+       {
                struct lcr_msg *message;
 
                add_trace("callref", NULL, "no free id");
@@ -1992,8 +2039,10 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete
                trigger_work(&p_m_d_delete);
                return;
        }
+#ifdef OLD_MT_ASSIGN
        p_m_d_l3id = mt_assign_pid;
        mt_assign_pid = ~0;
+#endif
        add_trace("callref", "new", "0x%x", p_m_d_l3id);
        end_trace();
 
@@ -2001,7 +2050,7 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete
        l3m = create_l3msg();
        l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_REQ, DIRECTION_OUT);
        /* channel information */
-       if (channel >= 0) /* it should */
+       if (p_m_d_ntmode || channel != CHANNEL_ANY) /* only omit channel id in te-mode/any channel */
                enc_ie_channel_id(l3m, exclusive, channel);
        /* caller information */
        plan = 1;
@@ -2438,7 +2487,7 @@ void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parame
        /* copy connected information */
        memcpy(&p_connectinfo, &param->connectinfo, sizeof(p_connectinfo));
        /* screen outgoing caller id */
-       do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface);
+       do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface->name);
 
        /* only display at connect state */
        if (p_state == PORT_STATE_CONNECT)
@@ -2862,7 +2911,7 @@ int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pi
        port = port_first;
        while(port) {
                /* are we ISDN ? */
-               if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1) {
+               if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_DSS1) {
                        pdss1 = (class Pdss1 *)port;
                        /* check out correct stack and id */
                        if (pdss1->p_m_mISDNport == mISDNport) {
@@ -2952,6 +3001,11 @@ int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pi
                // facility als broadcast
                break;
 
+               case MT_L2IDLE:
+               // L2 became idle - we could sent a MT_L2RELEASE if we are the L2 master
+               PDEBUG(DEBUG_ISDN, "Got L2 idle\n");
+               break;
+
                default:
                PERROR("unhandled message: cmd(0x%x) pid(0x%x)\n", cmd, pid);
                port = port_first;