<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17701">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cdr: allow disabling CDR by default on new channels<br><br>Adds a new option, defaultenabled, to the CDR core to<br>control whether or not CDR is enabled on a newly created<br>channel. This allows CDR to be disabled by default on<br>new channels and require the user to explicitly enable<br>CDR if desired. Existing behavior remains unchanged.<br><br>ASTERISK-29808 #close<br><br>Change-Id: Ibb78c11974bda229bbb7004b64761980e0b2c6d1<br>---<br>A doc/CHANGES-staging/cdr_disable.txt<br>M include/asterisk/cdr.h<br>M main/cdr.c<br>3 files changed, 29 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/01/17701/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/cdr_disable.txt b/doc/CHANGES-staging/cdr_disable.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..59e77f3</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/cdr_disable.txt</span><br><span>@@ -0,0 +1,6 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: cdr</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+A new CDR option, defaultenabled, allows controlling</span><br><span style="color: hsl(120, 100%, 40%);">+whether CDR is enabled or disabled by default on</span><br><span style="color: hsl(120, 100%, 40%);">+newly created channels. The default behavior remains</span><br><span style="color: hsl(120, 100%, 40%);">+unchanged from previous versions of Asterisk.</span><br><span>diff --git a/include/asterisk/cdr.h b/include/asterisk/cdr.h</span><br><span>index e2a5a90..907c40f 100644</span><br><span>--- a/include/asterisk/cdr.h</span><br><span>+++ b/include/asterisk/cdr.h</span><br><span>@@ -224,6 +224,7 @@</span><br><span>  CDR_END_BEFORE_H_EXTEN = 1 << 4,    /*!< End the CDR before the 'h' extension runs */</span><br><span>       CDR_INITIATED_SECONDS = 1 << 5,     /*!< Include microseconds into the billing time */</span><br><span>      CDR_DEBUG = 1 << 6,                 /*!< Enables extra debug statements */</span><br><span style="color: hsl(120, 100%, 40%);">+   CDR_DEFAULT_ENABLED = 1 << 7,             /*!< Whether CDR is enabled for each channel by default */</span><br><span> };</span><br><span> </span><br><span> /*! \brief CDR Batch Mode settings */</span><br><span>diff --git a/main/cdr.c b/main/cdr.c</span><br><span>index 5558092..dc64ce0 100644</span><br><span>--- a/main/cdr.c</span><br><span>+++ b/main/cdr.c</span><br><span>@@ -96,6 +96,21 @@</span><br><span>                                   any loading of backend CDR modules.  Default is "yes".</para></span><br><span>                                        </description></span><br><span>                                 </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+                         <configOption name="defaultenabled"></span><br><span style="color: hsl(120, 100%, 40%);">+                                  <synopsis>Whether CDR is enabled on a channel by default</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+                                       <description><para>Define whether or not CDR should be enabled on a channel by default.</span><br><span style="color: hsl(120, 100%, 40%);">+                                   Setting this to "yes" will enable CDR on every channel unless it is explicitly disabled.</span><br><span style="color: hsl(120, 100%, 40%);">+                                    Setting this to "no" will disable CDR on every channel unless it is explicitly enabled.</span><br><span style="color: hsl(120, 100%, 40%);">+                                     Default is "yes".</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                      <para>Note that CDR must still be globally enabled (<literal>enable = yes</literal>) for this</span><br><span style="color: hsl(120, 100%, 40%);">+                                       option to have any effect. This only applies to whether CDR is enabled or disabled on</span><br><span style="color: hsl(120, 100%, 40%);">+                                 newly created channels, which can be changed in the dialplan during a call.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                      <para>If this is set to "yes", you should use <literal>Set(CDR_PROP(disable)=1)</literal></span><br><span style="color: hsl(120, 100%, 40%);">+                                 to disable CDR for a call.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                       <para>If this is set to "no", you should use <literal>Set(CDR_PROP(disable)=0)</literal></span><br><span style="color: hsl(120, 100%, 40%);">+                                  to undisable (enable) CDR for a call.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                    </description></span><br><span style="color: hsl(120, 100%, 40%);">+                          </configOption></span><br><span>                                <configOption name="unanswered"></span><br><span>                                     <synopsis>Log calls that are never answered and don't set an outgoing party.</synopsis></span><br><span>                                      <description><para></span><br><span>@@ -192,6 +207,7 @@</span><br><span> #define DEFAULT_CONGESTION "0"</span><br><span> #define DEFAULT_END_BEFORE_H_EXTEN "1"</span><br><span> #define DEFAULT_INITIATED_SECONDS "0"</span><br><span style="color: hsl(120, 100%, 40%);">+#define DEFAULT_CHANNEL_ENABLED "1"</span><br><span> </span><br><span> #define DEFAULT_BATCH_SIZE "100"</span><br><span> #define MAX_BATCH_SIZE 1000</span><br><span>@@ -2287,6 +2303,11 @@</span><br><span>            }</span><br><span>            cdr->is_root = 1;</span><br><span>                 ao2_link(active_cdrs_master, cdr);</span><br><span style="color: hsl(120, 100%, 40%);">+            /* If CDR should be disabled unless enabled on a per-channel basis, then disable</span><br><span style="color: hsl(120, 100%, 40%);">+                      CDR, right from the get go */</span><br><span style="color: hsl(120, 100%, 40%);">+         if (!CDR_DEFAULT_ENABLED) {</span><br><span style="color: hsl(120, 100%, 40%);">+                   ast_set_flag(&cdr->flags, AST_CDR_FLAG_DISABLE_ALL);</span><br><span style="color: hsl(120, 100%, 40%);">+           }</span><br><span>    } else {</span><br><span>             cdr = ao2_find(active_cdrs_master, update->new_snapshot->base->uniqueid, OBJ_SEARCH_KEY);</span><br><span>   }</span><br><span>@@ -4348,6 +4369,7 @@</span><br><span>            aco_option_register(&cfg_info, "safeshutdown", ACO_EXACT, general_options, DEFAULT_BATCH_SAFE_SHUTDOWN, OPT_BOOLFLAG_T, 1, FLDSET(struct ast_cdr_config, batch_settings.settings), BATCH_MODE_SAFE_SHUTDOWN);</span><br><span>          aco_option_register(&cfg_info, "size", ACO_EXACT, general_options, DEFAULT_BATCH_SIZE, OPT_UINT_T, PARSE_IN_RANGE, FLDSET(struct ast_cdr_config, batch_settings.size), 0, MAX_BATCH_SIZE);</span><br><span>             aco_option_register(&cfg_info, "time", ACO_EXACT, general_options, DEFAULT_BATCH_TIME, OPT_UINT_T, PARSE_IN_RANGE, FLDSET(struct ast_cdr_config, batch_settings.time), 1, MAX_BATCH_TIME);</span><br><span style="color: hsl(120, 100%, 40%);">+              aco_option_register(&cfg_info, "defaultenabled", ACO_EXACT, general_options, DEFAULT_CHANNEL_ENABLED, OPT_BOOLFLAG_T, 1, FLDSET(struct ast_cdr_config, settings), CDR_DEFAULT_ENABLED);</span><br><span>        }</span><br><span> </span><br><span>        if (aco_process_config(&cfg_info, reload) == ACO_PROCESS_ERROR) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17701">change 17701</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/+/17701"/><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: Ibb78c11974bda229bbb7004b64761980e0b2c6d1 </div>
<div style="display:none"> Gerrit-Change-Number: 17701 </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>