Asterisk - The Open Source Telephony Project
18.5.0
|
Call Detail Record API. More...
#include "asterisk/channel.h"
Go to the source code of this file.
Data Structures | |
struct | ast_cdr |
Responsible for call detail data. More... | |
struct | ast_cdr_config |
The global options available for CDRs. More... | |
struct | ast_cdr_config::batch_settings |
Typedefs | |
typedef int(* | ast_cdrbe) (struct ast_cdr *cdr) |
CDR backend callback. More... | |
Enumerations | |
enum | ast_cdr_batch_mode_settings { BATCH_MODE_SCHEDULER_ONLY = 1 << 0, BATCH_MODE_SAFE_SHUTDOWN = 1 << 1 } |
CDR Batch Mode settings. More... | |
enum | ast_cdr_disposition { AST_CDR_NOANSWER = 0, AST_CDR_NULL = (1 << 0), AST_CDR_FAILED = (1 << 1), AST_CDR_BUSY = (1 << 2), AST_CDR_ANSWERED = (1 << 3), AST_CDR_CONGESTION = (1 << 4) } |
CDR Flags - Disposition. More... | |
enum | ast_cdr_options { AST_CDR_FLAG_KEEP_VARS = (1 << 0), AST_CDR_FLAG_DISABLE = (1 << 1), AST_CDR_FLAG_DISABLE_ALL = (3 << 1), AST_CDR_FLAG_PARTY_A = (1 << 3), AST_CDR_FLAG_FINALIZE = (1 << 4), AST_CDR_FLAG_SET_ANSWER = (1 << 5), AST_CDR_FLAG_RESET = (1 << 6), AST_CDR_LOCK_APP = (1 << 7) } |
CDR manipulation options. Certain function calls will manipulate the state of a CDR object based on these flags. More... | |
enum | ast_cdr_settings { CDR_ENABLED = 1 << 0, CDR_BATCHMODE = 1 << 1, CDR_UNANSWERED = 1 << 2, CDR_CONGESTION = 1 << 3, CDR_END_BEFORE_H_EXTEN = 1 << 4, CDR_INITIATED_SECONDS = 1 << 5, CDR_DEBUG = 1 << 6 } |
CDR engine settings. More... | |
Functions | |
struct ast_cdr * | ast_cdr_alloc (void) |
Allocate a CDR record. More... | |
int | ast_cdr_backend_suspend (const char *name) |
Suspend a CDR backend temporarily. More... | |
int | ast_cdr_backend_unsuspend (const char *name) |
Unsuspend a CDR backend. More... | |
int | ast_cdr_clear_property (const char *channel_name, enum ast_cdr_options option) |
Clear a property on a CDR for a channel. More... | |
const char * | ast_cdr_disp2str (int disposition) |
Disposition to a string. More... | |
struct ast_cdr * | ast_cdr_dup (struct ast_cdr *cdr) |
Duplicate a public CDR. More... | |
void | ast_cdr_engine_term (void) |
int | ast_cdr_fork (const char *channel_name, struct ast_flags *options) |
Fork a CDR. More... | |
void | ast_cdr_format_var (struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int raw) |
Format a CDR variable from an already posted CDR. More... | |
void | ast_cdr_free (struct ast_cdr *cdr) |
Free a CDR record. More... | |
struct ast_cdr_config * | ast_cdr_get_config (void) |
Obtain the current CDR configuration. More... | |
int | ast_cdr_getvar (const char *channel_name, const char *name, char *value, size_t length) |
Retrieve a CDR variable from a channel's current CDR. More... | |
int | ast_cdr_is_enabled (void) |
Return TRUE if CDR subsystem is enabled. More... | |
struct stasis_message_router * | ast_cdr_message_router (void) |
Return the message router for the CDR engine. More... | |
int | ast_cdr_modifier_register (const char *name, const char *desc, ast_cdrbe be) |
Register a CDR modifier. More... | |
int | ast_cdr_modifier_unregister (const char *name) |
Unregister a CDR modifier. More... | |
int | ast_cdr_register (const char *name, const char *desc, ast_cdrbe be) |
Register a CDR handling engine. More... | |
int | ast_cdr_reset (const char *channel_name, int keep_variables) |
Reset the detail record. More... | |
int | ast_cdr_serialize_variables (const char *channel_name, struct ast_str **buf, char delim, char sep) |
Serializes all the data and variables for a current CDR record. More... | |
void | ast_cdr_set_config (struct ast_cdr_config *config) |
Set the current CDR configuration. More... | |
int | ast_cdr_set_property (const char *channel_name, enum ast_cdr_options option) |
Set a property on a CDR for a channel. More... | |
void | ast_cdr_setuserfield (const char *channel_name, const char *userfield) |
Set CDR user field for channel (stored in CDR) More... | |
int | ast_cdr_setvar (const char *channel_name, const char *name, const char *value) |
Set a variable on a CDR. More... | |
int | ast_cdr_unregister (const char *name) |
Unregister a CDR handling engine. More... | |
typedef int(* ast_cdrbe) (struct ast_cdr *cdr) |
CDR Batch Mode settings.
Enumerator | |
---|---|
BATCH_MODE_SCHEDULER_ONLY | Don't spawn a thread to handle the batches - do it on the scheduler |
BATCH_MODE_SAFE_SHUTDOWN | During safe shutdown, submit the batched CDRs |
Definition at line 230 of file cdr.h.
enum ast_cdr_disposition |
enum ast_cdr_options |
CDR manipulation options. Certain function calls will manipulate the state of a CDR object based on these flags.
Definition at line 239 of file cdr.h.
enum ast_cdr_settings |
CDR engine settings.
struct ast_cdr* ast_cdr_alloc | ( | void | ) |
Allocate a CDR record.
a | malloc'd ast_cdr structure |
NULL | on error (malloc failure) |
Definition at line 3422 of file cdr.c.
References ast_calloc.
Referenced by ast_cdr_dup().
int ast_cdr_backend_suspend | ( | const char * | name | ) |
Suspend a CDR backend temporarily.
0 | The backend is suspdended |
-1 | The backend could not be suspended |
Definition at line 2866 of file cdr.c.
References ast_debug, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, cdr_beitem::name, and NULL.
Referenced by load_config(), my_unload_module(), and odbc_load_module().
int ast_cdr_backend_unsuspend | ( | const char * | name | ) |
Unsuspend a CDR backend.
0 | The backend was unsuspended |
-1 | The back could not be unsuspended |
Definition at line 2884 of file cdr.c.
References ast_debug, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, cdr_beitem::name, and NULL.
Referenced by load_config(), my_load_module(), and odbc_load_module().
int ast_cdr_clear_property | ( | const char * | channel_name, |
enum ast_cdr_options | option | ||
) |
Clear a property on a CDR for a channel.
channel_name | The CDR's channel |
option | Option to clear from the CDR |
0 | on success |
1 | on error |
Definition at line 3575 of file cdr.c.
References ao2_cleanup, ao2_lock, ao2_unlock, ast_clear_flag, cdr_object_get_by_name(), cdr_object::flags, cdr_object::fn_table, and cdr_object::next.
Referenced by appcdr_callback(), AST_TEST_DEFINE(), and cdr_prop_write_callback().
const char* ast_cdr_disp2str | ( | int | disposition | ) |
Disposition to a string.
disposition | input binary form Converts the binary form of a disposition to string form. |
Definition at line 3430 of file cdr.c.
References AST_CDR_ANSWERED, AST_CDR_BUSY, AST_CDR_CONGESTION, AST_CDR_FAILED, AST_CDR_NOANSWER, and AST_CDR_NULL.
Referenced by ast_cdr_format_var(), beanstalk_put(), build_csv_record(), build_radius_record(), cdr_object_finalize(), cdr_read_callback(), execute_cb(), manager_log(), and tds_log().
Duplicate a public CDR.
cdr | the record to duplicate |
a | malloc'd ast_cdr structure, |
NULL | on error (malloc failure) |
Definition at line 2998 of file cdr.c.
References ast_cdr_alloc(), AST_LIST_HEAD_INIT_NOLOCK, copy_variables(), ast_cdr::next, NULL, and ast_cdr::varshead.
Referenced by custom_log(), load_values_config(), manager_log(), and syslog_log().
void ast_cdr_engine_term | ( | void | ) |
Submit any remaining CDRs and prepare for shutdown
Definition at line 4577 of file cdr.c.
References ao2_alloc, ao2_cleanup, ao2_global_obj_ref, ast_debug, ast_test_flag, BATCH_MODE_SAFE_SHUTDOWN, CDR_BATCHMODE, cdr_submit_batch(), NULL, RAII_VAR, stasis_message_create(), and stasis_message_router_publish_sync().
Referenced by can_safely_quit(), and finalize_batch_mode().
int ast_cdr_fork | ( | const char * | channel_name, |
struct ast_flags * | options | ||
) |
Fork a CDR.
channel_name | The name of the channel whose CDR should be forked |
options | Options to control how the fork occurs. |
0 | on success |
-1 | on failure |
Definition at line 3637 of file cdr.c.
References cdr_object::answer, ao2_cleanup, ao2_ref, cdr_object::appl, AST_CDR_FLAG_FINALIZE, AST_CDR_FLAG_KEEP_VARS, AST_CDR_FLAG_RESET, AST_CDR_FLAG_SET_ANSWER, AST_CDR_LOCK_APP, ast_clear_flag, ast_debug, AST_STATE_UP, ast_string_field_set, ast_test_flag, ast_tvnow(), ast_channel_snapshot::base, cdr_object::bridge, cdr_all_relink(), cdr_object_create_and_append(), cdr_object_finalize(), cdr_object_get_by_name(), cdr_object_transition_state(), context, cdr_object::context, copy_variables(), cdr_object::data, exten, cdr_object::exten, cdr_object_snapshot::flags, cdr_object::flags, cdr_object::fn_table, free_variables(), cdr_object::last, cdr_object::lastevent, lock, ast_channel_snapshot_base::name, cdr_object::next, cdr_object::party_a, cdr_object::party_b, RAII_VAR, SCOPED_AO2LOCK, cdr_object_snapshot::snapshot, cdr_object::start, ast_channel_snapshot::state, cdr_object_snapshot::userfield, and cdr_object_snapshot::variables.
Referenced by AST_TEST_DEFINE(), and forkcdr_callback().
void ast_cdr_format_var | ( | struct ast_cdr * | cdr, |
const char * | name, | ||
char ** | ret, | ||
char * | workspace, | ||
int | workspacelen, | ||
int | raw | ||
) |
Format a CDR variable from an already posted CDR.
cdr | The dispatched CDR to process |
name | The name of the variable |
ret | Pointer to the formatted buffer |
workspace | A pointer to the buffer to use to format the variable |
workspacelen | The size of workspace |
raw | If non-zero and a date/time is extraced, provide epoch seconds. Otherwise format as a date/time stamp |
Definition at line 3050 of file cdr.c.
References ast_cdr::accountcode, ast_cdr::amaflags, ast_cdr::answer, ast_cdr_disp2str(), ast_channel_amaflags2string(), ast_copy_string(), ast_strlen_zero, ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), ast_cdr::billsec, cdr_format_var_internal(), cdr_get_tv(), ast_cdr::channel, ast_cdr::clid, ast_cdr::dcontext, ast_cdr::disposition, ast_cdr::dst, ast_cdr::dstchannel, ast_cdr::duration, ast_cdr::end, ast_cdr::lastapp, ast_cdr::lastdata, ast_cdr::linkedid, NULL, ast_cdr::peeraccount, ast_cdr::sequence, ast_cdr::src, ast_cdr::start, ast_cdr::uniqueid, and ast_cdr::userfield.
Referenced by cdr_handler(), cdr_read_callback(), cdr_retrieve_time(), mysql_log(), odbc_log(), and pgsql_log().
void ast_cdr_free | ( | struct ast_cdr * | cdr | ) |
Free a CDR record.
cdr | ast_cdr structure to free Returns nothing |
Definition at line 3411 of file cdr.c.
References ast_free, free_variables(), ast_cdr::next, and ast_cdr::varshead.
Referenced by ast_channel_destructor(), ast_dummy_channel_destructor(), cdr_detach(), clear_mock_cdr_backend(), and do_batch_backend_process().
struct ast_cdr_config* ast_cdr_get_config | ( | void | ) |
Obtain the current CDR configuration.
NULL | on error |
The | current CDR configuration |
Definition at line 2826 of file cdr.c.
References ao2_bump, ao2_cleanup, ao2_global_obj_ref, module_config::general, and NULL.
Referenced by test_cdr_init_cb().
int ast_cdr_getvar | ( | const char * | channel_name, |
const char * | name, | ||
char * | value, | ||
size_t | length | ||
) |
Retrieve a CDR variable from a channel's current CDR.
channel_name | The name of the party A channel that the CDR is associated with |
name | The name of the variable to retrieve |
value | Buffer to hold the value |
length | The size of the buffer |
0 | on success |
non-zero | on failure |
Definition at line 3324 of file cdr.c.
References ao2_cleanup, ao2_lock, ao2_unlock, ast_log, AST_LOG_ERROR, ast_strlen_zero, cdr_object_format_property(), cdr_object_format_var_internal(), cdr_object_get_by_name(), and cdr_object::last.
Referenced by AST_TEST_DEFINE(), cdr_read_callback(), and cdr_retrieve_time().
int ast_cdr_is_enabled | ( | void | ) |
Return TRUE if CDR subsystem is enabled.
Definition at line 2861 of file cdr.c.
References CDR_ENABLED, and is_cdr_flag_set().
Referenced by action_coresettings(), and handle_show_settings().
struct stasis_message_router* ast_cdr_message_router | ( | void | ) |
Return the message router for the CDR engine.
This returns the stasis_message_router that the CDR engine uses for dispatching Stasis Message Bus API messages. The reference on the message router is bumped and must be released by the caller of this function.
NULL | if the CDR engine is disabled or unavailable |
the | stasis_message_router otherwise |
Definition at line 4291 of file cdr.c.
References ao2_bump, NULL, and stasis_router.
Referenced by cdr_prop_write(), cdr_read(), cdr_write(), forkcdr_exec(), load_module(), publish_app_cdr_message(), and unload_module().
int ast_cdr_modifier_register | ( | const char * | name, |
const char * | desc, | ||
ast_cdrbe | be | ||
) |
Register a CDR modifier.
name | name associated with the particular CDR modifier |
desc | description of the CDR modifier |
be | function pointer to a CDR modifier |
Used to register a Call Detail Record modifier.
This gives modules a chance to modify CDR fields before they are dispatched to registered backends (odbc, syslog, etc).
0 | on success. |
-1 | on error |
Definition at line 2948 of file cdr.c.
References cdr_generic_register().
int ast_cdr_modifier_unregister | ( | const char * | name | ) |
Unregister a CDR modifier.
name | name of CDR modifier to unregister Unregisters a CDR modifier by its name |
0 | The modifier unregistered successfully |
-1 | The modifier could not be unregistered at this time |
Definition at line 2993 of file cdr.c.
References ast_cdr_generic_unregister().
int ast_cdr_register | ( | const char * | name, |
const char * | desc, | ||
ast_cdrbe | be | ||
) |
Register a CDR handling engine.
name | name associated with the particular CDR handler |
desc | description of the CDR handler |
be | function pointer to a CDR handler Used to register a Call Detail Record handler. |
0 | on success. |
-1 | on error |
Definition at line 2943 of file cdr.c.
References cdr_generic_register().
Referenced by load_module(), load_values_config(), my_load_module(), odbc_load_module(), and unload_module().
int ast_cdr_reset | ( | const char * | channel_name, |
int | keep_variables | ||
) |
Reset the detail record.
channel_name | The channel that the CDR is associated with |
keep_variables | Keep the variables during the reset. If zero, variables are discarded during the reset. |
0 | on success |
-1 | on failure |
Definition at line 3598 of file cdr.c.
References cdr_object::answer, ao2_cleanup, ao2_lock, ao2_unlock, AST_LIST_REMOVE_HEAD, ast_tvnow(), ast_var_delete(), cdr_object_check_party_a_answer(), cdr_object_get_by_name(), cdr_object::end, cdr_object::lastevent, cdr_object::next, cdr_object::party_a, cdr_object::party_b, cdr_object_snapshot::snapshot, cdr_object::start, and cdr_object_snapshot::variables.
Referenced by appcdr_callback(), and dial_exec_full().
int ast_cdr_serialize_variables | ( | const char * | channel_name, |
struct ast_str ** | buf, | ||
char | delim, | ||
char | sep | ||
) |
Serializes all the data and variables for a current CDR record.
channel_name | The channel to get the CDR for |
buf | A buffer to use for formatting the data |
delim | A delimeter to use to separate variable keys/values |
sep | A separator to use between nestings |
the | total number of serialized variables |
Definition at line 3353 of file cdr.c.
References ao2_cleanup, ao2_lock, ao2_unlock, ast_assert, AST_LIST_TRAVERSE, ast_log, AST_LOG_ERROR, ast_str_append(), ast_str_reset(), ast_strlen_zero, ast_var_name(), ast_var_value(), CDR_ENABLED, cdr_object_format_property(), cdr_object_get_by_name(), ast_var_t::entries, is_cdr_flag_set(), LOG_ERROR, cdr_object::next, cdr_object::party_a, S_OR, total, var, and cdr_object_snapshot::variables.
Referenced by handle_showchan().
void ast_cdr_set_config | ( | struct ast_cdr_config * | config | ) |
Set the current CDR configuration.
config | The new CDR configuration |
Definition at line 2840 of file cdr.c.
References ao2_cleanup, ao2_global_obj_ref, ao2_replace, cdr_set_debug_mode, cdr_toggle_runtime_options(), and module_config::general.
Referenced by test_cdr_cleanup_cb().
int ast_cdr_set_property | ( | const char * | channel_name, |
enum ast_cdr_options | option | ||
) |
Set a property on a CDR for a channel.
channel_name | The CDR's channel |
option | Option to apply to the CDR |
0 | on success |
1 | on error |
Definition at line 3548 of file cdr.c.
References ao2_cleanup, ao2_lock, ao2_unlock, ast_set_flag, cdr_object_get_by_name(), cdr_object::flags, cdr_object::fn_table, cdr_object::next, and cdr_object::party_a.
Referenced by appcdr_callback(), AST_TEST_DEFINE(), and cdr_prop_write_callback().
void ast_cdr_setuserfield | ( | const char * | channel_name, |
const char * | userfield | ||
) |
Set CDR user field for channel (stored in CDR)
channel_name | The name of the channel that owns the CDR |
userfield | The user field to set |
Definition at line 3477 of file cdr.c.
References ao2_callback_data, ao2_cleanup, ao2_lock, ao2_unlock, ast_copy_string(), cdr_object_get_by_name(), cdr_object_update_party_b_userfield_cb(), party_b_userfield_update::channel_name, cdr_object::fn_table, cdr_object::next, NULL, OBJ_MULTIPLE, OBJ_NODATA, OBJ_SEARCH_KEY, cdr_object::party_a, cdr_object_snapshot::userfield, and party_b_userfield_update::userfield.
Referenced by AST_TEST_DEFINE(), cdr_write_callback(), handle_request_info(), and start_monitor_exec().
int ast_cdr_setvar | ( | const char * | channel_name, |
const char * | name, | ||
const char * | value | ||
) |
Set a variable on a CDR.
channel_name | The channel to set the variable on |
name | The name of the variable to set |
value | The value of the variable to set |
0 | on success |
non-zero | on failure |
Definition at line 3178 of file cdr.c.
References ao2_callback, ao2_cleanup, ao2_iterator_destroy(), ao2_iterator_next, ao2_lock, ao2_unlock, ast_log, AST_LOG_ERROR, ast_strdupa, ast_channel_snapshot::base, cdr_object_select_all_by_name_cb(), cdr_object::fn_table, LOG_ERROR, ast_channel_snapshot_base::name, cdr_object::next, NULL, OBJ_MULTIPLE, cdr_object::party_a, cdr_object::party_b, set_variable(), cdr_object_snapshot::snapshot, and cdr_object_snapshot::variables.
Referenced by AST_TEST_DEFINE(), and cdr_write_callback().
int ast_cdr_unregister | ( | const char * | name | ) |
Unregister a CDR handling engine.
name | name of CDR handler to unregister Unregisters a CDR by it's name |
0 | The backend unregistered successfully |
-1 | The backend could not be unregistered at this time |
Definition at line 2988 of file cdr.c.
References ast_cdr_generic_unregister().
Referenced by load_module(), load_values_config(), my_unload_module(), reload(), tds_unload_module(), and unload_module().