SS5: Special feature to mute only when also respoinding with a tone
[lcr.git] / mISDN.cpp
index cdc24ef..179646b 100644 (file)
--- a/mISDN.cpp
+++ b/mISDN.cpp
@@ -63,7 +63,6 @@ static struct mi_ext_fn_s myfn;
 int mISDN_initialize(void)
 {
        char filename[256];
-       int ver;
 
        /* try to open raw socket to check kernel */
        mISDNsocket = socket(PF_ISDN, SOCK_RAW, ISDN_P_BASE);
@@ -76,7 +75,7 @@ int mISDN_initialize(void)
        // set debug printout function
        myfn.prt_debug = my_mISDNlib_debug;
 
-       ver = init_layer3(4, &myfn); // buffer of 4
+       init_layer3(4, &myfn); // buffer of 4
 
        /* open debug, if enabled and not only stack debugging */
        if (options.deb) {
@@ -147,6 +146,7 @@ PmISDN::PmISDN(int type, mISDNport *mISDNport, char *portname, struct port_setti
        p_m_inband_send_on = 0;
        p_m_inband_receive_on = 0;
        p_m_dtmf = !mISDNport->ifport->nodtmf;
+       p_m_dtmf_threshold = mISDNport->ifport->dtmf_threshold;
        memset(&p_m_timeout, 0, sizeof(p_m_timeout));
        add_timer(&p_m_timeout, mISDN_timeout, this, 0);
        SCPY(p_m_pipeline, mISDNport->ifport->interface->pipeline);
@@ -348,15 +348,20 @@ void ph_control(struct mISDNport *mISDNport, class PmISDN *isdnport, int sock, u
        struct mISDNhead *ctrl = (struct mISDNhead *)buffer;
        unsigned int *d = (unsigned int *)(buffer+MISDN_HEADER_LEN);
        int ret;
+       int len = 8;
 
        if (sock < 0)
                return;
 
+       if (c1 == DTMF_TONE_START && c2 == 0) {
+               len = 4;
+       }
+
        ctrl->prim = PH_CONTROL_REQ;
        ctrl->id = 0;
        *d++ = c1;
        *d++ = c2;
-       ret = sendto(sock, buffer, MISDN_HEADER_LEN+sizeof(int)*2, 0, NULL, 0);
+       ret = sendto(sock, buffer, MISDN_HEADER_LEN+len, 0, NULL, 0);
        if (ret <= 0)
                PERROR("Failed to send to socket %d\n", sock);
        chan_trace_header(mISDNport, isdnport, "BCHANNEL control", DIRECTION_OUT);
@@ -507,7 +512,7 @@ static void _bchannel_configure(struct mISDNport *mISDNport, int i)
 //     if (port->p_m_txmix && mode == B_MODE_TRANSPARENT)
 //             ph_control(mISDNport, port, handle, DSP_MIX_ON, 0, "DSP-MIX", 1);
        if (port->p_m_dtmf && mode == B_MODE_TRANSPARENT)
-               ph_control(mISDNport, port, handle, DTMF_TONE_START, 0, "DSP-DTMF", 1);
+               ph_control(mISDNport, port, handle, DTMF_TONE_START, port->p_m_dtmf_threshold, "DSP-DTMF", 1);
        if (port->p_m_crypt && mode == B_MODE_TRANSPARENT)
                ph_control_block(mISDNport, port, handle, DSP_BF_ENABLE_KEY, port->p_m_crypt_key, port->p_m_crypt_key_len, "DSP-CRYPT", port->p_m_crypt_key_len);
 }
@@ -598,6 +603,7 @@ void bchannel_event(struct mISDNport *mISDNport, int i, int event)
        class PmISDN *b_port = mISDNport->b_port[i];
        int state = mISDNport->b_state[i];
        int timer = -1; // no change
+#if 0
        int p_m_tx_gain = 0;
        int p_m_rx_gain = 0;
        char *p_m_pipeline = NULL;
@@ -613,6 +619,7 @@ void bchannel_event(struct mISDNport *mISDNport, int i, int event)
                p_m_crypt_key_len = b_port->p_m_crypt_key_len;
                p_m_crypt_key_type = /*b_port->p_m_crypt_key_type*/1;
        }
+#endif
 
        switch(event) {
                case B_EVENT_USE:
@@ -1060,7 +1067,7 @@ void PmISDN::bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len
                        if (p_type == PORT_TYPE_POTS_FXS_IN && p_state == PORT_STATE_IN_OVERLAP) {
                                class Pfxs *pfxs = (class Pfxs *)this;
                                if (!pfxs->p_m_fxs_allow_dtmf) {
-                                       PDEBUG(DEBUG_PORT, "PmISDN(%s) DTMF for FXS not yet allowed\n", p_name);
+                                       PDEBUG(DEBUG_PORT, "PmISDN(%s) DTMF for FXS currently disabled\n", p_name);
                                        return;
                                }
                                SCCAT(p_dialinginfo.id, cont & DTMF_TONE_MASK);
@@ -1527,7 +1534,7 @@ static int mISDN_upqueue(struct lcr_fd *fd, unsigned int what, void *instance, i
        struct mbuffer *mb;
        struct l3_msg *l3m;
        char byte;
-       int ret;
+       int __attribute__((__unused__)) ret;
 
        /* unset global semaphore */
        upqueue_avail = 0;
@@ -1763,7 +1770,7 @@ int do_layer3(struct mlayer3 *ml3, unsigned int cmd, unsigned int pid, struct l3
                // this is no problem.
                upqueue_avail = 1;
                char byte = 0;
-               int ret;
+               int __attribute__((__unused__)) ret;
                ret = write(upqueue_pipe[1], &byte, 1);
        }
        return 0;
@@ -1790,6 +1797,7 @@ int mISDN_getportbyname(int sock, int cnt, char *portname)
        return (port);
 }
 
+#ifdef ISDN_P_FXS_POTS
 /* handle frames from pots */
 static int pots_sock_callback(struct lcr_fd *fd, unsigned int what, void *instance, int i)
 {
@@ -1826,6 +1834,7 @@ static int pots_sock_callback(struct lcr_fd *fd, unsigned int what, void *instan
 
        return 0;
 }
+#endif
 
 /*
  * global function to add a new card (port)