[Asterisk-code-review] cdr: allow disabling CDR by default on new channels (asterisk[master])
N A
asteriskteam at digium.com
Wed Dec 15 12:38:55 CST 2021
N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/17701 )
Change subject: cdr: allow disabling CDR by default on new channels
......................................................................
cdr: allow disabling CDR by default on new channels
Adds a new option, defaultenabled, to the CDR core to
control whether or not CDR is enabled on a newly created
channel. This allows CDR to be disabled by default on
new channels and require the user to explicitly enable
CDR if desired. Existing behavior remains unchanged.
ASTERISK-29808 #close
Change-Id: Ibb78c11974bda229bbb7004b64761980e0b2c6d1
---
A doc/CHANGES-staging/cdr_disable.txt
M include/asterisk/cdr.h
M main/cdr.c
3 files changed, 29 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/01/17701/1
diff --git a/doc/CHANGES-staging/cdr_disable.txt b/doc/CHANGES-staging/cdr_disable.txt
new file mode 100644
index 0000000..59e77f3
--- /dev/null
+++ b/doc/CHANGES-staging/cdr_disable.txt
@@ -0,0 +1,6 @@
+Subject: cdr
+
+A new CDR option, defaultenabled, allows controlling
+whether CDR is enabled or disabled by default on
+newly created channels. The default behavior remains
+unchanged from previous versions of Asterisk.
diff --git a/include/asterisk/cdr.h b/include/asterisk/cdr.h
index e2a5a90..907c40f 100644
--- a/include/asterisk/cdr.h
+++ b/include/asterisk/cdr.h
@@ -224,6 +224,7 @@
CDR_END_BEFORE_H_EXTEN = 1 << 4, /*!< End the CDR before the 'h' extension runs */
CDR_INITIATED_SECONDS = 1 << 5, /*!< Include microseconds into the billing time */
CDR_DEBUG = 1 << 6, /*!< Enables extra debug statements */
+ CDR_DEFAULT_ENABLED = 1 << 7, /*!< Whether CDR is enabled for each channel by default */
};
/*! \brief CDR Batch Mode settings */
diff --git a/main/cdr.c b/main/cdr.c
index 5558092..dc64ce0 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -96,6 +96,21 @@
any loading of backend CDR modules. Default is "yes".</para>
</description>
</configOption>
+ <configOption name="defaultenabled">
+ <synopsis>Whether CDR is enabled on a channel by default</synopsis>
+ <description><para>Define whether or not CDR should be enabled on a channel by default.
+ Setting this to "yes" will enable CDR on every channel unless it is explicitly disabled.
+ Setting this to "no" will disable CDR on every channel unless it is explicitly enabled.
+ Default is "yes".</para>
+ <para>Note that CDR must still be globally enabled (<literal>enable = yes</literal>) for this
+ option to have any effect. This only applies to whether CDR is enabled or disabled on
+ newly created channels, which can be changed in the dialplan during a call.</para>
+ <para>If this is set to "yes", you should use <literal>Set(CDR_PROP(disable)=1)</literal>
+ to disable CDR for a call.</para>
+ <para>If this is set to "no", you should use <literal>Set(CDR_PROP(disable)=0)</literal>
+ to undisable (enable) CDR for a call.</para>
+ </description>
+ </configOption>
<configOption name="unanswered">
<synopsis>Log calls that are never answered and don't set an outgoing party.</synopsis>
<description><para>
@@ -192,6 +207,7 @@
#define DEFAULT_CONGESTION "0"
#define DEFAULT_END_BEFORE_H_EXTEN "1"
#define DEFAULT_INITIATED_SECONDS "0"
+#define DEFAULT_CHANNEL_ENABLED "1"
#define DEFAULT_BATCH_SIZE "100"
#define MAX_BATCH_SIZE 1000
@@ -2287,6 +2303,11 @@
}
cdr->is_root = 1;
ao2_link(active_cdrs_master, cdr);
+ /* If CDR should be disabled unless enabled on a per-channel basis, then disable
+ CDR, right from the get go */
+ if (!CDR_DEFAULT_ENABLED) {
+ ast_set_flag(&cdr->flags, AST_CDR_FLAG_DISABLE_ALL);
+ }
} else {
cdr = ao2_find(active_cdrs_master, update->new_snapshot->base->uniqueid, OBJ_SEARCH_KEY);
}
@@ -4348,6 +4369,7 @@
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);
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);
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);
+ 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);
}
if (aco_process_config(&cfg_info, reload) == ACO_PROCESS_ERROR) {
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/17701
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ibb78c11974bda229bbb7004b64761980e0b2c6d1
Gerrit-Change-Number: 17701
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211215/2bed0bdf/attachment-0001.html>
More information about the asterisk-code-review
mailing list