<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18304">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_dahdi: Add dialmode option for FXS lines.<br><br>Currently, both pulse and tone dialing are always enabled<br>on all FXS lines, with no way of disabling one or the other.<br><br>In some circumstances, it is desirable or necessary to<br>disable one of these, and this behavior can be problematic.<br><br>A new "dialmode" option is added which allows setting the<br>methods to support on a per channel basis for FXS (FXO<br>signalled lines). The four options are "both", "pulse",<br>"dtmf"/"tone", and "none".<br><br>Additionally, integration with the CHANNEL function is<br>added so that this setting can be updated for a channel<br>during a call.<br><br>ASTERISK-29992 #close<br><br>Change-Id: Id3fb3fbf031ef8d5e8c867836f226f8e9023cd26<br>---<br>M channels/chan_dahdi.c<br>M channels/chan_dahdi.h<br>M channels/sig_analog.c<br>M channels/sig_analog.h<br>M configs/samples/chan_dahdi.conf.sample<br>5 files changed, 102 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/04/18304/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c</span><br><span>index ad7a8e5..b9416e5 100644</span><br><span>--- a/channels/chan_dahdi.c</span><br><span>+++ b/channels/chan_dahdi.c</span><br><span>@@ -232,6 +232,17 @@</span><br><span>                                   completely disabled)</para></span><br><span>                            <para>    <literal>voice</literal>    Voice mode (returns from FAX mode, reverting the changes that were made)</para></span><br><span>                        </enum></span><br><span style="color: hsl(120, 100%, 40%);">+                 <enum name="dialmode"></span><br><span style="color: hsl(120, 100%, 40%);">+                                <para>R/W Pulse and tone dialing mode of the channel.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                              <para>If set, overrides the setting in <literal>chan_dahdi.conf</literal> for that channel.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                            <enumlist></span><br><span style="color: hsl(120, 100%, 40%);">+                                      <enum name="both" /></span><br><span style="color: hsl(120, 100%, 40%);">+                                  <enum name="pulse" /></span><br><span style="color: hsl(120, 100%, 40%);">+                                 <enum name="dtmf" /></span><br><span style="color: hsl(120, 100%, 40%);">+                                  <enum name="tone" /></span><br><span style="color: hsl(120, 100%, 40%);">+                                  <enum name="none" /></span><br><span style="color: hsl(120, 100%, 40%);">+                          </enumlist></span><br><span style="color: hsl(120, 100%, 40%);">+                     </enum></span><br><span>                </enumlist></span><br><span>    </info></span><br><span>        <manager name="DAHDITransfer" language="en_US"></span><br><span>@@ -952,6 +963,7 @@</span><br><span>                      .mohsuggest = "",</span><br><span>                  .parkinglot = "",</span><br><span>                  .transfertobusy = 1,</span><br><span style="color: hsl(120, 100%, 40%);">+                  .dialmode = 0,</span><br><span> </span><br><span>                   .ani_info_digits = 2,</span><br><span>                        .ani_wink_time = 1000,</span><br><span>@@ -6834,6 +6846,30 @@</span><br><span>              }</span><br><span>            ast_mutex_unlock(&p->lock);</span><br><span> #endif    /* defined(HAVE_PRI) */</span><br><span style="color: hsl(120, 100%, 40%);">+       } else if (!strcasecmp(data, "dialmode")) {</span><br><span style="color: hsl(120, 100%, 40%);">+         struct analog_pvt *analog_p = p->sig_pvt;</span><br><span style="color: hsl(120, 100%, 40%);">+          if (analog_p) {</span><br><span style="color: hsl(120, 100%, 40%);">+                       ast_mutex_lock(&p->lock);</span><br><span style="color: hsl(120, 100%, 40%);">+                      switch (analog_p->dialmode) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      case ANALOG_DIALMODE_BOTH:</span><br><span style="color: hsl(120, 100%, 40%);">+                            ast_copy_string(buf, "both", len);</span><br><span style="color: hsl(120, 100%, 40%);">+                          break;</span><br><span style="color: hsl(120, 100%, 40%);">+                        case ANALOG_DIALMODE_PULSE:</span><br><span style="color: hsl(120, 100%, 40%);">+                           ast_copy_string(buf, "pulse", len);</span><br><span style="color: hsl(120, 100%, 40%);">+                         break;</span><br><span style="color: hsl(120, 100%, 40%);">+                        case ANALOG_DIALMODE_DTMF:</span><br><span style="color: hsl(120, 100%, 40%);">+                            ast_copy_string(buf, "dtmf", len);</span><br><span style="color: hsl(120, 100%, 40%);">+                          break;</span><br><span style="color: hsl(120, 100%, 40%);">+                        case ANALOG_DIALMODE_NONE:</span><br><span style="color: hsl(120, 100%, 40%);">+                            ast_copy_string(buf, "none", len);</span><br><span style="color: hsl(120, 100%, 40%);">+                          break;</span><br><span style="color: hsl(120, 100%, 40%);">+                        }</span><br><span style="color: hsl(120, 100%, 40%);">+                     ast_mutex_unlock(&p->lock);</span><br><span style="color: hsl(120, 100%, 40%);">+            } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                      ast_log(LOG_WARNING, "%s only supported on analog channels\n", data);</span><br><span style="color: hsl(120, 100%, 40%);">+                       *buf = '\0';</span><br><span style="color: hsl(120, 100%, 40%);">+                  res = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+             }</span><br><span>    } else {</span><br><span>             *buf = '\0';</span><br><span>                 res = -1;</span><br><span>@@ -6939,6 +6975,27 @@</span><br><span>                   ast_log(LOG_WARNING, "Unsupported value '%s' provided for '%s' item.\n", value, data);</span><br><span>                     res = -1;</span><br><span>            }</span><br><span style="color: hsl(120, 100%, 40%);">+     } else if (!strcasecmp(data, "dialmode")) {</span><br><span style="color: hsl(120, 100%, 40%);">+         struct analog_pvt *analog_p = p->sig_pvt;</span><br><span style="color: hsl(120, 100%, 40%);">+          if (!analog_p) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      ast_log(LOG_WARNING, "%s only supported on analog channels\n", data);</span><br><span style="color: hsl(120, 100%, 40%);">+                       return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span style="color: hsl(120, 100%, 40%);">+             ast_mutex_lock(&p->lock);</span><br><span style="color: hsl(120, 100%, 40%);">+              /* analog pvt is used for pulse dialing, so update both */</span><br><span style="color: hsl(120, 100%, 40%);">+            if (!strcasecmp(value, "pulse")) {</span><br><span style="color: hsl(120, 100%, 40%);">+                  p->dialmode = analog_p->dialmode = ANALOG_DIALMODE_PULSE;</span><br><span style="color: hsl(120, 100%, 40%);">+               } else if (!strcasecmp(value, "dtmf") || !strcasecmp(value, "tone")) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    p->dialmode = analog_p->dialmode = ANALOG_DIALMODE_DTMF;</span><br><span style="color: hsl(120, 100%, 40%);">+                } else if (!strcasecmp(value, "none")) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    p->dialmode = analog_p->dialmode = ANALOG_DIALMODE_NONE;</span><br><span style="color: hsl(120, 100%, 40%);">+                } else if (!strcasecmp(value, "both")) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    p->dialmode = analog_p->dialmode = ANALOG_DIALMODE_BOTH;</span><br><span style="color: hsl(120, 100%, 40%);">+                } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                      ast_log(LOG_WARNING, "'%s' is an invalid setting for %s\n", value, data);</span><br><span style="color: hsl(120, 100%, 40%);">+                   res = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+             }</span><br><span style="color: hsl(120, 100%, 40%);">+             ast_mutex_unlock(&p->lock);</span><br><span>   } else {</span><br><span>             res = -1;</span><br><span>    }</span><br><span>@@ -8815,6 +8872,13 @@</span><br><span>                   } else {</span><br><span>                             dahdi_handle_dtmf(ast, idx, &f);</span><br><span>                         }</span><br><span style="color: hsl(120, 100%, 40%);">+                     if (!(p->dialmode == ANALOG_DIALMODE_BOTH || p->dialmode == ANALOG_DIALMODE_DTMF)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                            if (f->frametype == AST_FRAME_DTMF_END) { /* only show this message when the key is let go of */</span><br><span style="color: hsl(120, 100%, 40%);">+                                   ast_debug(1, "Dropping DTMF digit '%c' because tone dialing is disabled\n", f->subclass.integer);</span><br><span style="color: hsl(120, 100%, 40%);">+                                }</span><br><span style="color: hsl(120, 100%, 40%);">+                             f->frametype = AST_FRAME_NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+                             f->subclass.integer = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+                   }</span><br><span>                    break;</span><br><span>               case AST_FRAME_VOICE:</span><br><span>                        if (p->cidspill || p->cid_suppress_expire) {</span><br><span>@@ -12597,6 +12661,7 @@</span><br><span> #endif</span><br><span>               tmp->immediate = conf->chan.immediate;</span><br><span>                 tmp->transfertobusy = conf->chan.transfertobusy;</span><br><span style="color: hsl(120, 100%, 40%);">+                tmp->dialmode = conf->chan.dialmode;</span><br><span>           if (chan_sig & __DAHDI_SIG_FXS) {</span><br><span>                        tmp->mwimonitor_fsk = conf->chan.mwimonitor_fsk;</span><br><span>                       tmp->mwimonitor_neon = conf->chan.mwimonitor_neon;</span><br><span>@@ -12930,6 +12995,7 @@</span><br><span>                           analog_p->threewaycalling = conf->chan.threewaycalling;</span><br><span>                                analog_p->transfer = conf->chan.transfer;</span><br><span>                              analog_p->transfertobusy = conf->chan.transfertobusy;</span><br><span style="color: hsl(120, 100%, 40%);">+                           analog_p->dialmode = conf->chan.dialmode;</span><br><span>                              analog_p->use_callerid = tmp->use_callerid;</span><br><span>                            analog_p->usedistinctiveringdetection = tmp->usedistinctiveringdetection;</span><br><span>                              analog_p->use_smdi = tmp->use_smdi;</span><br><span>@@ -18121,6 +18187,16 @@</span><br><span>                         confp->chan.immediate = ast_true(v->value);</span><br><span>            } else if (!strcasecmp(v->name, "transfertobusy")) {</span><br><span>                    confp->chan.transfertobusy = ast_true(v->value);</span><br><span style="color: hsl(120, 100%, 40%);">+                } else if (!strcasecmp(v->name, "dialmode")) {</span><br><span style="color: hsl(120, 100%, 40%);">+                   if (!strcasecmp(v->value, "pulse")) {</span><br><span style="color: hsl(120, 100%, 40%);">+                            confp->chan.dialmode = ANALOG_DIALMODE_PULSE;</span><br><span style="color: hsl(120, 100%, 40%);">+                      } else if (!strcasecmp(v->value, "dtmf") || !strcasecmp(v->value, "tone")) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                confp->chan.dialmode = ANALOG_DIALMODE_DTMF;</span><br><span style="color: hsl(120, 100%, 40%);">+                       } else if (!strcasecmp(v->value, "none")) {</span><br><span style="color: hsl(120, 100%, 40%);">+                              confp->chan.dialmode = ANALOG_DIALMODE_NONE;</span><br><span style="color: hsl(120, 100%, 40%);">+                       } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                              confp->chan.dialmode = ANALOG_DIALMODE_BOTH;</span><br><span style="color: hsl(120, 100%, 40%);">+                       }</span><br><span>            } else if (!strcasecmp(v->name, "mwimonitor")) {</span><br><span>                        confp->chan.mwimonitor_neon = 0;</span><br><span>                  confp->chan.mwimonitor_fsk = 0;</span><br><span>diff --git a/channels/chan_dahdi.h b/channels/chan_dahdi.h</span><br><span>index de813f2..8f16687 100644</span><br><span>--- a/channels/chan_dahdi.h</span><br><span>+++ b/channels/chan_dahdi.h</span><br><span>@@ -146,6 +146,7 @@</span><br><span>     * \note Set to a couple of nonzero values but it is only tested like a boolean.</span><br><span>      */</span><br><span>  int radio;</span><br><span style="color: hsl(120, 100%, 40%);">+    int dialmode;                                   /*!< Dialing Modes Allowed (Pulse/Tone) */</span><br><span>        int outsigmod;                                  /*!< Outbound Signalling style (modifier) */</span><br><span>      int oprmode;                                    /*!< "Operator Services" mode */</span><br><span>        struct dahdi_pvt *oprpeer;                              /*!< "Operator Services" peer tech_pvt ptr */</span><br><span>diff --git a/channels/sig_analog.c b/channels/sig_analog.c</span><br><span>index 64f1114..2b9da10 100644</span><br><span>--- a/channels/sig_analog.c</span><br><span>+++ b/channels/sig_analog.c</span><br><span>@@ -2768,9 +2768,13 @@</span><br><span>                 analog_set_pulsedial(p, (res & ANALOG_EVENT_PULSEDIGIT) ? 1 : 0);</span><br><span>                ast_debug(1, "Detected %sdigit '%c'\n", (res & ANALOG_EVENT_PULSEDIGIT) ? "pulse ": "", res & 0xff);</span><br><span>           analog_confmute(p, 0);</span><br><span style="color: hsl(0, 100%, 40%);">-          p->subs[idx].f.frametype = AST_FRAME_DTMF_END;</span><br><span style="color: hsl(0, 100%, 40%);">-               p->subs[idx].f.subclass.integer = res & 0xff;</span><br><span style="color: hsl(0, 100%, 40%);">-            analog_handle_dtmf(p, ast, idx, &f);</span><br><span style="color: hsl(120, 100%, 40%);">+              if (p->dialmode == ANALOG_DIALMODE_BOTH || p->dialmode == ANALOG_DIALMODE_PULSE) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      p->subs[idx].f.frametype = AST_FRAME_DTMF_END;</span><br><span style="color: hsl(120, 100%, 40%);">+                     p->subs[idx].f.subclass.integer = res & 0xff;</span><br><span style="color: hsl(120, 100%, 40%);">+                  analog_handle_dtmf(p, ast, idx, &f);</span><br><span style="color: hsl(120, 100%, 40%);">+              } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                      ast_debug(1, "Dropping pulse digit '%c' because pulse dialing disabled on channel %d\n", res & 0xff, p->channel);</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span>            return f;</span><br><span>    }</span><br><span> </span><br><span>diff --git a/channels/sig_analog.h b/channels/sig_analog.h</span><br><span>index 488be36..3c27105 100644</span><br><span>--- a/channels/sig_analog.h</span><br><span>+++ b/channels/sig_analog.h</span><br><span>@@ -116,6 +116,13 @@</span><br><span>        ANALOG_DIGITMODE_MF,</span><br><span> };</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+enum analog_dialmode {</span><br><span style="color: hsl(120, 100%, 40%);">+        ANALOG_DIALMODE_BOTH = 0,</span><br><span style="color: hsl(120, 100%, 40%);">+     ANALOG_DIALMODE_PULSE,</span><br><span style="color: hsl(120, 100%, 40%);">+        ANALOG_DIALMODE_DTMF,</span><br><span style="color: hsl(120, 100%, 40%);">+ ANALOG_DIALMODE_NONE,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> enum analog_cid_start {</span><br><span>       ANALOG_CID_START_POLARITY = 1,</span><br><span>       ANALOG_CID_START_POLARITY_IN,</span><br><span>@@ -308,6 +315,7 @@</span><br><span>  int channel;                                    /*!< Channel Number */</span><br><span> </span><br><span>        enum analog_sigtype outsigmod;</span><br><span style="color: hsl(120, 100%, 40%);">+        enum analog_dialmode dialmode;  /*!< Which of pulse and/or tone dialing to support */</span><br><span>     int echotraining;</span><br><span>    int cid_signalling;                             /*!< Asterisk callerid type we're using */</span><br><span>    int polarityonanswerdelay;</span><br><span>diff --git a/configs/samples/chan_dahdi.conf.sample b/configs/samples/chan_dahdi.conf.sample</span><br><span>index 5c3af43..1e75318 100644</span><br><span>--- a/configs/samples/chan_dahdi.conf.sample</span><br><span>+++ b/configs/samples/chan_dahdi.conf.sample</span><br><span>@@ -1126,10 +1126,19 @@</span><br><span> ;</span><br><span> ; For FXO (FXS signalled) devices, whether to use pulse dial instead of DTMF</span><br><span> ; Pulse digits from phones (FXS devices, FXO signalling) are always</span><br><span style="color: hsl(0, 100%, 40%);">-; detected.</span><br><span style="color: hsl(120, 100%, 40%);">+; detected, unless the dialmode setting has been changed from the default.</span><br><span> ;</span><br><span> ;pulsedial=yes</span><br><span> ;</span><br><span style="color: hsl(120, 100%, 40%);">+; For FXS (FXO signalled) devices, the dialing modes to support for the channel.</span><br><span style="color: hsl(120, 100%, 40%);">+; By default, both pulse and tone (DTMF) dialing are always detected.</span><br><span style="color: hsl(120, 100%, 40%);">+; May be set to "pulse" if you only want to allow pulse dialing on a line.</span><br><span style="color: hsl(120, 100%, 40%);">+; May be set to "dtmf" or "tone" to only allow tone dialing on a line.</span><br><span style="color: hsl(120, 100%, 40%);">+; May be set to "none" to prevent dialing entirely.</span><br><span style="color: hsl(120, 100%, 40%);">+; You can also change this during a call using the CHANNEL function in the dialplan.</span><br><span style="color: hsl(120, 100%, 40%);">+;</span><br><span style="color: hsl(120, 100%, 40%);">+;dialmode=both</span><br><span style="color: hsl(120, 100%, 40%);">+;</span><br><span> ; For fax detection, uncomment one of the following lines.  The default is *OFF*</span><br><span> ;</span><br><span> ;faxdetect=both</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18304">change 18304</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/18304"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Id3fb3fbf031ef8d5e8c867836f226f8e9023cd26 </div>
<div style="display:none"> Gerrit-Change-Number: 18304 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>