Call Detail Record API. More...
#include "asterisk.h"
#include <signal.h>
#include "asterisk/lock.h"
#include "asterisk/channel.h"
#include "asterisk/cdr.h"
#include "asterisk/callerid.h"
#include "asterisk/manager.h"
#include "asterisk/causes.h"
#include "asterisk/linkedlists.h"
#include "asterisk/utils.h"
#include "asterisk/sched.h"
#include "asterisk/config.h"
#include "asterisk/cli.h"
#include "asterisk/stringfields.h"
#include "asterisk/data.h"
Go to the source code of this file.
Data Structures | |
struct | ast_cdr_batch |
struct | ast_cdr_batch_item |
struct | ast_cdr_beitem |
struct | be_list |
Functions | |
struct ast_cdr * | ast_cdr_alloc (void) |
Allocate a CDR record. More... | |
int | ast_cdr_amaflags2int (const char *flag) |
Convert a string to a detail record AMA flag. More... | |
void | ast_cdr_answer (struct ast_cdr *cdr) |
Answer a call. More... | |
struct ast_cdr * | ast_cdr_append (struct ast_cdr *cdr, struct ast_cdr *newcdr) |
int | ast_cdr_appenduserfield (struct ast_channel *chan, const char *userfield) |
Append to CDR user field for channel (stored in CDR) More... | |
void | ast_cdr_busy (struct ast_cdr *cdr) |
Busy a call. More... | |
int | ast_cdr_copy_vars (struct ast_cdr *to_cdr, struct ast_cdr *from_cdr) |
int | ast_cdr_data_add_structure (struct ast_data *tree, struct ast_cdr *cdr, int recur) |
void | ast_cdr_detach (struct ast_cdr *cdr) |
Detaches the detail record for posting (and freeing) either now or at a later time in bulk with other records during batch mode operation. More... | |
void | ast_cdr_discard (struct ast_cdr *cdr) |
the same as a cdr_free call, only with no checks; just get rid of it More... | |
char * | ast_cdr_disp2str (int disposition) |
Disposition to a string. More... | |
int | ast_cdr_disposition (struct ast_cdr *cdr, int cause) |
Save the result of the call based on the AST_CAUSE_*. More... | |
struct ast_cdr * | ast_cdr_dup (struct ast_cdr *cdr) |
Duplicate a record. More... | |
struct ast_cdr * | ast_cdr_dup_unique (struct ast_cdr *cdr) |
Duplicate a record and increment the sequence number. More... | |
struct ast_cdr * | ast_cdr_dup_unique_swap (struct ast_cdr *cdr) |
Duplicate a record and increment the sequence number of the old record. More... | |
void | ast_cdr_end (struct ast_cdr *cdr) |
End a call. More... | |
int | ast_cdr_engine_init (void) |
Load the configuration file cdr.conf and possibly start the CDR scheduling thread. More... | |
int | ast_cdr_engine_reload (void) |
Reload the configuration file cdr.conf and start/stop CDR scheduling thread. More... | |
void | ast_cdr_engine_term (void) |
void | ast_cdr_failed (struct ast_cdr *cdr) |
Fail a call. More... | |
char * | ast_cdr_flags2str (int flag) |
void | ast_cdr_free (struct ast_cdr *cdr) |
Free a CDR record. More... | |
void | ast_cdr_free_vars (struct ast_cdr *cdr, int recur) |
void | ast_cdr_getvar (struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int recur, int raw) |
static const char * | ast_cdr_getvar_internal (struct ast_cdr *cdr, const char *name, int recur) |
int | ast_cdr_init (struct ast_cdr *cdr, struct ast_channel *c) |
Initialize based on a channel. More... | |
int | ast_cdr_isset_unanswered (void) |
void | ast_cdr_merge (struct ast_cdr *to, struct ast_cdr *from) |
Move the non-null data from the "from" cdr to the "to" cdr. More... | |
void | ast_cdr_noanswer (struct ast_cdr *cdr) |
A call wasn't answered. More... | |
int | ast_cdr_register (const char *name, const char *desc, ast_cdrbe be) |
Register a CDR driver. Each registered CDR driver generates a CDR. More... | |
void | ast_cdr_reset (struct ast_cdr *cdr, struct ast_flags *_flags) |
Reset the detail record, optionally posting it first. More... | |
int | ast_cdr_serialize_variables (struct ast_cdr *cdr, struct ast_str **buf, char delim, char sep, int recur) |
int | ast_cdr_setaccount (struct ast_channel *chan, const char *account) |
Set account code, will generate AMI event. More... | |
int | ast_cdr_setamaflags (struct ast_channel *chan, const char *flag) |
Set AMA flags for channel. More... | |
void | ast_cdr_setanswer (struct ast_cdr *cdr, struct timeval t) |
Set the answer time for a call. More... | |
void | ast_cdr_setapp (struct ast_cdr *cdr, const char *app, const char *data) |
Set the last executed application. More... | |
int | ast_cdr_setcid (struct ast_cdr *cdr, struct ast_channel *c) |
Initialize based on a channel. More... | |
void | ast_cdr_setdestchan (struct ast_cdr *cdr, const char *chann) |
Set the destination channel, if there was one. More... | |
void | ast_cdr_setdisposition (struct ast_cdr *cdr, long int disposition) |
Set the disposition for a call. More... | |
int | ast_cdr_setpeeraccount (struct ast_channel *chan, const char *account) |
Set the peer account. More... | |
int | ast_cdr_setuserfield (struct ast_channel *chan, const char *userfield) |
Set CDR user field for channel (stored in CDR) More... | |
int | ast_cdr_setvar (struct ast_cdr *cdr, const char *name, const char *value, int recur) |
void | ast_cdr_specialized_reset (struct ast_cdr *cdr, struct ast_flags *_flags) |
void | ast_cdr_start (struct ast_cdr *cdr) |
Start a call. More... | |
void | ast_cdr_submit_batch (int do_shutdown) |
Spawns (possibly) a new thread to submit a batch of CDRs to the backend engines. More... | |
void | ast_cdr_unregister (const char *name) |
Unregister a CDR handling engine. More... | |
int | ast_cdr_update (struct ast_channel *c) |
Update CDR on a channel. More... | |
static void | cdr_engine_shutdown (void) |
static void | cdr_get_tv (struct timeval when, const char *fmt, char *buf, int bufsize) |
static void | cdr_merge_vars (struct ast_cdr *to, struct ast_cdr *from) |
static int | cdr_seq_inc (struct ast_cdr *cdr) |
int | check_cdr_enabled (void) |
Return TRUE if CDR subsystem is enabled. More... | |
static void | check_post (struct ast_cdr *cdr) |
print a warning if cdr already posted More... | |
static void * | do_batch_backend_process (void *data) |
static void * | do_cdr (void *data) |
static void | do_reload (int reload) |
static char * | handle_cli_status (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_submit (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | init_batch (void) |
static void | post_cdr (struct ast_cdr *cdr) |
static void | reset_batch (void) |
static void | set_one_cid (struct ast_cdr *cdr, struct ast_channel *c) |
static int | submit_scheduled_batch (const void *data) |
static void | submit_unscheduled_batch (void) |
Variables | |
char | ast_default_accountcode [AST_MAX_ACCOUNT_CODE] |
int | ast_default_amaflags = AST_CDR_DOCUMENTATION |
static struct ast_cdr_batch * | batch = NULL |
static const int | BATCH_SAFE_SHUTDOWN_DEFAULT = 1 |
static const int | BATCH_SCHEDULER_ONLY_DEFAULT = 0 |
static const int | BATCH_SIZE_DEFAULT = 100 |
static const int | BATCH_TIME_DEFAULT = 300 |
static int | batchmode |
static const int | BATCHMODE_DEFAULT = 0 |
static int | batchsafeshutdown |
static int | batchscheduleronly |
static int | batchsize |
static int | batchtime |
static struct be_list | be_list = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, 1 } , } |
static ast_mutex_t | cdr_batch_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } |
static ast_cond_t | cdr_pending_cond |
static ast_mutex_t | cdr_pending_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } |
static const char *const | cdr_readonly_vars [] |
static int | cdr_sched = -1 |
static ast_mutex_t | cdr_sched_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } |
static int | cdr_sequence = 0 |
static pthread_t | cdr_thread = AST_PTHREADT_NULL |
static struct ast_cli_entry | cli_status = AST_CLI_DEFINE(handle_cli_status, "Display the CDR status") |
static struct ast_cli_entry | cli_submit = AST_CLI_DEFINE(handle_cli_submit, "Posts all pending batched CDR data") |
static int | enabled |
static const int | ENABLED_DEFAULT = 1 |
static struct sched_context * | sched |
static int | unanswered |
static const int | UNANSWERED_DEFAULT = 0 |
Call Detail Record API.
Definition in file cdr.c.
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 499 of file cdr.c.
References ast_calloc, ast_log(), and LOG_ERROR.
Referenced by __agent_start_monitoring(), __ast_channel_alloc_ap(), __ast_request_and_dial(), ast_bridge_call(), ast_cdr_dup(), ast_pbx_outgoing_cdr_failed(), builtin_blindtransfer(), clear_caller(), findmeexec(), and start_monitor_exec().
int ast_cdr_amaflags2int | ( | const char * | flag | ) |
Convert a string to a detail record AMA flag.
flag | string form of flag Converts the string form of the flag to the binary form. |
Definition at line 1105 of file cdr.c.
References AST_CDR_BILLING, AST_CDR_DOCUMENTATION, and AST_CDR_OMIT.
Referenced by ast_cdr_setamaflags(), build_device(), build_gateway(), build_peer(), build_user(), config_parse_variables(), process_dahdi(), and set_config().
void ast_cdr_answer | ( | struct ast_cdr * | cdr | ) |
Answer a call.
cdr | the cdr you wish to associate with the call Starts all CDR stuff necessary for doing CDR when answering a call |
Definition at line 737 of file cdr.c.
References ast_cdr::answer, AST_CDR_ANSWERED, AST_CDR_FLAG_ANSLOCKED, AST_CDR_FLAG_DONT_TOUCH, AST_CDR_FLAG_LOCKED, ast_test_flag, ast_tvnow(), ast_tvzero(), check_post(), ast_cdr::disposition, and ast_cdr::next.
Referenced by __ast_request_and_dial(), ast_bridge_call(), and ast_raw_answer().
Definition at line 1216 of file cdr.c.
References ast_cdr::next.
Referenced by ast_cdr_fork(), ast_cdr_merge(), and try_calling().
int ast_cdr_appenduserfield | ( | struct ast_channel * | chan, |
const char * | userfield | ||
) |
Append to CDR user field for channel (stored in CDR)
Definition at line 1069 of file cdr.c.
References AST_CDR_FLAG_LOCKED, ast_copy_string(), ast_test_flag, ast_channel::cdr, len(), ast_cdr::next, and ast_cdr::userfield.
Referenced by ast_bridge_call().
void ast_cdr_busy | ( | struct ast_cdr * | cdr | ) |
Busy a call.
cdr | the cdr you wish to associate with the call Marks the channel disposition as "BUSY" Will skip CDR's in chain with ANS_LOCK bit set. (see forkCDR() application. Returns nothing |
Definition at line 753 of file cdr.c.
References AST_CDR_BUSY, AST_CDR_FLAG_LOCKED, ast_test_flag, check_post(), ast_cdr::disposition, and ast_cdr::next.
Referenced by __ast_request_and_dial(), ast_cdr_disposition(), handle_cause(), pbx_builtin_busy(), and ring_entry().
Definition at line 383 of file cdr.c.
References AST_LIST_INSERT_HEAD, AST_LIST_TRAVERSE, ast_strlen_zero(), ast_var_assign(), ast_var_name(), ast_var_value(), var, and ast_cdr::varshead.
Referenced by ast_bridge_call(), and ast_cdr_dup().
[in] | tree | Where to insert the cdr. |
[in] | cdr | The cdr structure to insert in 'tree'. |
[in] | recur | Go throw all the cdr levels. |
<0 | on error. |
0 | on success. |
Definition at line 1674 of file cdr.c.
References ast_cdr_getvar(), ast_data_add_int(), ast_data_add_node(), ast_data_add_str(), AST_LIST_TRAVERSE, ast_strlen_zero(), ast_var_name(), ast_var_value(), cdr_readonly_vars, ast_var_t::entries, ast_cdr::next, var, and ast_cdr::varshead.
Referenced by ast_channel_data_add_structure().
void ast_cdr_detach | ( | struct ast_cdr * | cdr | ) |
Detaches the detail record for posting (and freeing) either now or at a later time in bulk with other records during batch mode operation.
cdr | Which CDR to detach from the channel thread Prevents the channel thread from blocking on the CDR handling Returns nothing |
Definition at line 1328 of file cdr.c.
References ast_calloc, AST_CDR_FLAG_POST_DISABLED, ast_cdr_free(), ast_debug, ast_mutex_lock, ast_mutex_unlock, ast_set_flag, batch, batchmode, batchsize, ast_cdr_batch_item::cdr, cdr_batch_lock, enabled, ast_cdr_batch::head, init_batch(), ast_cdr_batch_item::next, post_cdr(), ast_cdr_batch::size, submit_unscheduled_batch(), and ast_cdr_batch::tail.
Referenced by ast_bridge_call(), ast_cdr_reset(), ast_hangup(), and ast_pbx_outgoing_cdr_failed().
void ast_cdr_discard | ( | struct ast_cdr * | cdr | ) |
the same as a cdr_free call, only with no checks; just get rid of it
Discard and free a CDR record.
Definition at line 488 of file cdr.c.
References ast_cdr_free_vars(), ast_free, and ast_cdr::next.
Referenced by ast_async_goto(), ast_bridge_call(), ast_cdr_merge(), ast_channel_destructor(), and ast_dummy_channel_destructor().
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 959 of file cdr.c.
References AST_CDR_ANSWERED, AST_CDR_BUSY, AST_CDR_FAILED, AST_CDR_NOANSWER, and AST_CDR_NULL.
Referenced by ast_cdr_getvar(), build_csv_record(), build_radius_record(), csv_log(), execute_cb(), manager_log(), and tds_log().
int ast_cdr_disposition | ( | struct ast_cdr * | cdr, |
int | cause | ||
) |
Save the result of the call based on the AST_CAUSE_*.
cdr | the cdr you wish to associate with the call |
cause | the AST_CAUSE_* Returns nothing |
Definition at line 790 of file cdr.c.
References AST_CAUSE_BUSY, AST_CAUSE_NO_ANSWER, AST_CAUSE_NORMAL, ast_cdr_busy(), ast_cdr_noanswer(), and ast_cdr::next.
Referenced by __ast_request_and_dial(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), clear_caller(), and findmeexec().
Duplicate a record.
Duplicate a CDR record
Definition at line 213 of file cdr.c.
References ast_cdr_alloc(), ast_cdr_copy_vars(), ast_cdr::next, and ast_cdr::varshead.
Referenced by ast_async_goto(), ast_cdr_dup_unique(), ast_cdr_dup_unique_swap(), ast_cdr_merge(), custom_log(), manager_log(), syslog_log(), and try_calling().
Duplicate a record and increment the sequence number.
cdr | the record to duplicate |
a | malloc'd ast_cdr structure, |
NULL | on error (malloc failure) |
Definition at line 190 of file cdr.c.
References ast_cdr_dup(), and cdr_seq_inc().
Referenced by ast_cdr_fork().
Duplicate a record and increment the sequence number of the old record.
cdr | the record to duplicate |
a | malloc'd ast_cdr structure, |
NULL | on error (malloc failure) |
Definition at line 200 of file cdr.c.
References ast_cdr_dup(), and cdr_seq_inc().
Referenced by ast_bridge_call(), and ast_cdr_reset().
void ast_cdr_end | ( | struct ast_cdr * | cdr | ) |
End a call.
cdr | the cdr you have associated the call with Registers the end of call time in the cdr structure. Returns nothing |
Definition at line 933 of file cdr.c.
References ast_cdr::answer, AST_CDR_ANSWERED, AST_CDR_FAILED, AST_CDR_FLAG_DONT_TOUCH, AST_CDR_FLAG_LOCKED, ast_log(), AST_OPT_FLAG_INITIATED_SECONDS, ast_options, ast_test_flag, ast_tvnow(), ast_tvzero(), ast_cdr::billsec, ast_cdr::channel, check_post(), ast_cdr::disposition, ast_cdr::duration, ast_cdr::end, LOG_WARNING, ast_cdr::next, S_OR, and ast_cdr::start.
Referenced by __ast_pbx_run(), __ast_request_and_dial(), ast_bridge_call(), ast_cdr_fork(), ast_cdr_reset(), ast_hangup(), ast_pbx_outgoing_cdr_failed(), clear_caller(), and findmeexec().
int ast_cdr_engine_init | ( | void | ) |
Load the configuration file cdr.conf and possibly start the CDR scheduling thread.
Definition at line 1646 of file cdr.c.
References ast_cli_register(), ast_log(), ast_register_atexit(), cdr_engine_shutdown(), cli_status, do_reload(), LOG_ERROR, and sched_context_create().
Referenced by main().
int ast_cdr_engine_reload | ( | void | ) |
Reload the configuration file cdr.conf and start/stop CDR scheduling thread.
Definition at line 1668 of file cdr.c.
References do_reload().
void ast_cdr_engine_term | ( | void | ) |
Submit any remaining CDRs and prepare for shutdown
Definition at line 1663 of file cdr.c.
References ast_cdr_submit_batch(), and batchsafeshutdown.
Referenced by can_safely_quit(), and do_reload().
void ast_cdr_failed | ( | struct ast_cdr * | cdr | ) |
Fail a call.
cdr | the cdr you wish to associate with the call Marks the channel disposition as "FAILED" Will skip CDR's in chain with ANS_LOCK bit set. (see forkCDR() application. Returns nothing |
Definition at line 764 of file cdr.c.
References AST_CDR_FAILED, AST_CDR_FLAG_LOCKED, ast_test_flag, check_post(), ast_cdr::disposition, and ast_cdr::next.
Referenced by __ast_request_and_dial(), ast_pbx_outgoing_app(), ast_pbx_outgoing_cdr_failed(), ast_pbx_outgoing_exten(), clear_caller(), findmeexec(), handle_cause(), try_calling(), and wait_for_answer().
char* ast_cdr_flags2str | ( | int | flag | ) |
Converts AMA flag to printable string
Definition at line 977 of file cdr.c.
References AST_CDR_BILLING, AST_CDR_DOCUMENTATION, and AST_CDR_OMIT.
Referenced by _sip_show_peer(), _skinny_show_line(), ast_cdr_getvar(), ast_channel_data_add_structure(), build_csv_record(), build_radius_record(), csv_log(), manager_log(), peers_data_provider_get(), sip_show_user(), tds_log(), and users_data_provider_get().
void ast_cdr_free | ( | struct ast_cdr * | cdr | ) |
Free a CDR record.
cdr | ast_cdr structure to free Returns nothing |
Definition at line 475 of file cdr.c.
References ast_cdr_free_vars(), ast_free, and ast_cdr::next.
Referenced by ast_cdr_detach(), and do_batch_backend_process().
void ast_cdr_free_vars | ( | struct ast_cdr * | cdr, |
int | recur | ||
) |
Definition at line 454 of file cdr.c.
References AST_LIST_REMOVE_HEAD, ast_var_delete(), ast_cdr::next, and ast_cdr::varshead.
Referenced by ast_cdr_discard(), ast_cdr_fork(), ast_cdr_free(), and ast_cdr_reset().
void ast_cdr_getvar | ( | struct ast_cdr * | cdr, |
const char * | name, | ||
char ** | ret, | ||
char * | workspace, | ||
int | workspacelen, | ||
int | recur, | ||
int | raw | ||
) |
CDR channel variable retrieval
Definition at line 264 of file cdr.c.
References ast_cdr::accountcode, ast_cdr::amaflags, ast_cdr::answer, ast_cdr_disp2str(), ast_cdr_flags2str(), ast_cdr_getvar_internal(), ast_copy_string(), ast_strlen_zero(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), ast_cdr::billsec, 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, ast_cdr::peeraccount, ast_cdr::sequence, ast_cdr::src, ast_cdr::start, ast_cdr::uniqueid, and ast_cdr::userfield.
Referenced by ast_cdr_data_add_structure(), ast_cdr_serialize_variables(), cdr_handler(), cdr_read(), odbc_log(), and pgsql_log().
|
static |
Definition at line 232 of file cdr.c.
References AST_LIST_TRAVERSE, ast_strlen_zero(), ast_var_name(), ast_var_value(), ast_cdr::next, and ast_cdr::varshead.
Referenced by ast_cdr_getvar().
int ast_cdr_init | ( | struct ast_cdr * | cdr, |
struct ast_channel * | chan | ||
) |
Initialize based on a channel.
cdr | Call Detail Record to use for channel |
chan | Channel to bind CDR with Initializes a CDR and associates it with a particular channel |
Definition at line 897 of file cdr.c.
References ast_channel::_state, ast_cdr::accountcode, ast_channel::accountcode, ast_cdr::amaflags, ast_channel::amaflags, AST_CDR_ANSWERED, AST_CDR_FLAG_LOCKED, AST_CDR_NOANSWER, ast_copy_string(), ast_default_amaflags, AST_STATE_UP, ast_test_flag, cdr_seq_inc(), ast_cdr::channel, ast_channel::context, ast_cdr::dcontext, ast_cdr::disposition, ast_cdr::dst, ast_channel::exten, ast_cdr::linkedid, ast_channel::linkedid, ast_channel::macrocontext, ast_channel::macroexten, ast_channel::name, ast_cdr::next, ast_cdr::peeraccount, ast_channel::peeraccount, S_OR, set_one_cid(), ast_cdr::uniqueid, and ast_channel::uniqueid.
Referenced by __ast_channel_alloc_ap(), __ast_request_and_dial(), ast_pbx_outgoing_cdr_failed(), builtin_blindtransfer(), clear_caller(), findmeexec(), and try_calling().
int ast_cdr_isset_unanswered | ( | void | ) |
Definition at line 185 of file cdr.c.
References unanswered.
Referenced by ring_entry(), and try_calling().
Move the non-null data from the "from" cdr to the "to" cdr.
to | the cdr to get the goodies |
from | the cdr to give the goodies |
Definition at line 543 of file cdr.c.
References ast_cdr::accountcode, ast_cdr::amaflags, ast_cdr::answer, ast_cdr_append(), ast_cdr_discard(), AST_CDR_DOCUMENTATION, ast_cdr_dup(), AST_CDR_FLAG_CHILD, AST_CDR_FLAG_KEEP_VARS, AST_CDR_FLAG_LOCKED, AST_CDR_FLAG_POST_DISABLED, AST_CDR_FLAG_POSTED, AST_CDR_NOANSWER, ast_copy_string(), ast_log(), ast_set_flag, ast_strlen_zero(), ast_test_flag, ast_tv(), ast_tvcmp(), ast_tvzero(), ast_cdr::billsec, cdr_merge_vars(), 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, LOG_WARNING, ast_cdr::next, ast_cdr::peeraccount, ast_cdr::src, ast_cdr::start, and ast_cdr::userfield.
void ast_cdr_noanswer | ( | struct ast_cdr * | cdr | ) |
A call wasn't answered.
cdr | the cdr you wish to associate with the call Marks the channel disposition as "NO ANSWER" Will skip CDR's in chain with ANS_LOCK bit set. (see forkCDR() application. |
Definition at line 776 of file cdr.c.
References AST_CDR_FLAG_LOCKED, AST_CDR_NOANSWER, ast_test_flag, check_post(), ast_cdr::disposition, and ast_cdr::next.
Referenced by ast_cdr_disposition(), handle_cause(), and wait_for_answer().
int ast_cdr_register | ( | const char * | name, |
const char * | desc, | ||
ast_cdrbe | be | ||
) |
Register a CDR driver. Each registered CDR driver generates a CDR.
Register a CDR handling engine.
0 | on success. |
-1 | on error |
Definition at line 130 of file cdr.c.
References ast_calloc, ast_copy_string(), ast_log(), AST_RWLIST_INSERT_HEAD, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_cdr_beitem::be, ast_cdr_beitem::desc, LOG_WARNING, and ast_cdr_beitem::name.
Referenced by load_config(), load_module(), odbc_load_module(), and unload_module().
Reset the detail record, optionally posting it first.
cdr | which cdr to act upon |
flags | |AST_CDR_FLAG_POSTED whether or not to post the cdr first before resetting it |AST_CDR_FLAG_LOCKED whether or not to reset locked CDR's |
Definition at line 1149 of file cdr.c.
References ast_cdr::answer, ast_cdr_detach(), ast_cdr_dup_unique_swap(), ast_cdr_end(), AST_CDR_FLAG_KEEP_VARS, AST_CDR_FLAG_LOCKED, AST_CDR_FLAG_POST_DISABLED, AST_CDR_FLAG_POST_ENABLE, AST_CDR_FLAG_POSTED, ast_cdr_free_vars(), AST_CDR_NOANSWER, ast_cdr_start(), ast_clear_flag, ast_copy_flags, AST_FLAGS_ALL, ast_set_flag, ast_test_flag, ast_cdr::billsec, ast_cdr::disposition, ast_cdr::duration, ast_cdr::end, ast_cdr::next, and ast_cdr::start.
Referenced by ast_cdr_fork(), dial_exec_full(), disa_exec(), pbx_builtin_resetcdr(), and try_calling().
int ast_cdr_serialize_variables | ( | struct ast_cdr * | cdr, |
struct ast_str ** | buf, | ||
char | delim, | ||
char | sep, | ||
int | recur | ||
) |
Definition at line 409 of file cdr.c.
References ast_cdr_getvar(), AST_LIST_TRAVERSE, ast_log(), ast_str_append(), ast_str_reset(), ast_var_name(), ast_var_value(), cdr_readonly_vars, ast_var_t::entries, LOG_ERROR, ast_cdr::next, S_OR, total, var, and ast_cdr::varshead.
Referenced by handle_showchan().
int ast_cdr_setaccount | ( | struct ast_channel * | chan, |
const char * | account | ||
) |
Set account code, will generate AMI event.
Definition at line 990 of file cdr.c.
References ast_cdr::accountcode, accountcode, ast_channel::accountcode, AST_CDR_FLAG_LOCKED, ast_copy_string(), ast_manager_event, ast_strdupa, ast_string_field_set, ast_strlen_zero(), ast_test_flag, ast_channel::cdr, EVENT_FLAG_CALL, ast_channel::name, ast_cdr::next, and ast_channel::uniqueid.
Referenced by __ast_request_and_dial(), ast_bridge_call(), ast_call_forward(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), auth_exec(), and cdr_write().
int ast_cdr_setamaflags | ( | struct ast_channel * | chan, |
const char * | amaflags | ||
) |
Set AMA flags for channel.
Definition at line 1042 of file cdr.c.
References ast_cdr::amaflags, ast_cdr_amaflags2int(), AST_CDR_FLAG_LOCKED, ast_test_flag, ast_channel::cdr, and ast_cdr::next.
Referenced by cdr_write(), and pbx_builtin_setamaflags().
void ast_cdr_setanswer | ( | struct ast_cdr * | cdr, |
struct timeval | t | ||
) |
Set the answer time for a call.
cdr | the cdr you wish to associate with the call |
t | the answer time Starts all CDR stuff necessary for doing CDR when answering a call NULL argument is just fine. |
Definition at line 834 of file cdr.c.
References ast_cdr::answer, AST_CDR_FLAG_ANSLOCKED, AST_CDR_FLAG_DONT_TOUCH, AST_CDR_FLAG_LOCKED, ast_test_flag, check_post(), and ast_cdr::next.
Referenced by ast_bridge_call(), and dial_exec_full().
void ast_cdr_setapp | ( | struct ast_cdr * | cdr, |
const char * | app, | ||
const char * | data | ||
) |
Set the last executed application.
cdr | which cdr to act upon |
app | the name of the app you wish to change it to |
data | the data you want in the data field of app you set it to Changes the value of the last executed app Returns nothing |
Definition at line 822 of file cdr.c.
References AST_CDR_FLAG_LOCKED, ast_copy_string(), ast_test_flag, check_post(), ast_cdr::lastapp, ast_cdr::lastdata, ast_cdr::next, and S_OR.
Referenced by __ast_request_and_dial(), agi_handle_command(), clear_caller(), findmeexec(), and pbx_exec().
int ast_cdr_setcid | ( | struct ast_cdr * | cdr, |
struct ast_channel * | chan | ||
) |
Initialize based on a channel.
cdr | Call Detail Record to use for channel |
chan | Channel to bind CDR with Initializes a CDR and associates it with a particular channel |
Definition at line 883 of file cdr.c.
References AST_CDR_FLAG_LOCKED, ast_test_flag, ast_cdr::next, and set_one_cid().
Referenced by ast_bridge_call(), ast_channel_set_caller_event(), ast_set_callerid(), and callerid_write().
void ast_cdr_setdestchan | ( | struct ast_cdr * | cdr, |
const char * | chan | ||
) |
Set the destination channel, if there was one.
cdr | Which cdr it's applied to |
chan | Channel to which dest will be Sets the destination channel the CDR is applied to Returns nothing |
Definition at line 812 of file cdr.c.
References AST_CDR_FLAG_LOCKED, ast_copy_string(), ast_test_flag, check_post(), ast_cdr::dstchannel, and ast_cdr::next.
Referenced by dial_exec_full(), parked_call_exec(), ring_entry(), and try_calling().
void ast_cdr_setdisposition | ( | struct ast_cdr * | cdr, |
long int | disposition | ||
) |
Set the disposition for a call.
cdr | the cdr you wish to associate with the call |
disposition | the new disposition Set the disposition on a call. NULL argument is just fine. |
Definition at line 847 of file cdr.c.
References AST_CDR_FLAG_LOCKED, ast_test_flag, check_post(), ast_cdr::disposition, and ast_cdr::next.
Referenced by ast_bridge_call().
int ast_cdr_setpeeraccount | ( | struct ast_channel * | chan, |
const char * | account | ||
) |
Set the peer account.
Definition at line 1016 of file cdr.c.
References AST_CDR_FLAG_LOCKED, ast_copy_string(), ast_manager_event, ast_strdupa, ast_string_field_set, ast_strlen_zero(), ast_test_flag, ast_channel::cdr, EVENT_FLAG_CALL, ast_channel::name, ast_cdr::next, ast_cdr::peeraccount, ast_channel::peeraccount, and ast_channel::uniqueid.
Referenced by cdr_write().
int ast_cdr_setuserfield | ( | struct ast_channel * | chan, |
const char * | userfield | ||
) |
Set CDR user field for channel (stored in CDR)
Definition at line 1057 of file cdr.c.
References AST_CDR_FLAG_LOCKED, ast_copy_string(), ast_test_flag, ast_channel::cdr, ast_cdr::next, and ast_cdr::userfield.
Referenced by __agent_start_monitoring(), ast_bridge_call(), cdr_write(), handle_request_info(), and start_monitor_exec().
int ast_cdr_setvar | ( | struct ast_cdr * | cdr, |
const char * | name, | ||
const char * | value, | ||
int | recur | ||
) |
Set a CDR channel variable
Definition at line 343 of file cdr.c.
References AST_CDR_FLAG_DONT_TOUCH, AST_CDR_FLAG_LOCKED, AST_LIST_INSERT_HEAD, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log(), ast_test_flag, ast_var_assign(), ast_var_delete(), ast_var_name(), cdr_readonly_vars, LOG_ERROR, ast_cdr::next, and ast_cdr::varshead.
Referenced by ast_cdr_fork(), cdr_write(), and set_one_cid().
Reset the detail record times, flags
cdr | which cdr to act upon |
flags | |AST_CDR_FLAG_POSTED whether or not to post the cdr first before resetting it |AST_CDR_FLAG_LOCKED whether or not to reset locked CDR's |
Definition at line 1192 of file cdr.c.
References ast_cdr::answer, AST_CDR_FLAG_POST_DISABLED, AST_CDR_NULL, ast_cdr_start(), ast_clear_flag, ast_copy_flags, AST_FLAGS_ALL, ast_set_flag, ast_test_flag, ast_cdr::billsec, ast_cdr::disposition, ast_cdr::duration, ast_cdr::end, and ast_cdr::start.
Referenced by ast_bridge_call().
void ast_cdr_start | ( | struct ast_cdr * | cdr | ) |
Start a call.
cdr | the cdr you wish to associate with the call Starts all CDR stuff necessary for monitoring a call Returns nothing |
Definition at line 727 of file cdr.c.
References AST_CDR_FLAG_LOCKED, ast_test_flag, ast_tvnow(), check_post(), ast_cdr::next, and ast_cdr::start.
Referenced by __ast_channel_alloc_ap(), __ast_request_and_dial(), ast_bridge_call(), ast_cdr_reset(), ast_cdr_specialized_reset(), ast_pbx_outgoing_cdr_failed(), builtin_blindtransfer(), clear_caller(), and findmeexec().
void ast_cdr_submit_batch | ( | int | shutdown | ) |
Spawns (possibly) a new thread to submit a batch of CDRs to the backend engines.
shutdown | Whether or not we are shutting down Blocks the asterisk shutdown procedures until the CDR data is submitted. Returns nothing |
Definition at line 1270 of file cdr.c.
References ast_debug, ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_pthread_create_detached_background, AST_PTHREADT_NULL, batch, batchscheduleronly, cdr_batch_lock, do_batch_backend_process(), ast_cdr_batch::head, LOG_WARNING, and reset_batch().
Referenced by ast_cdr_engine_term(), and submit_scheduled_batch().
void ast_cdr_unregister | ( | const char * | name | ) |
Unregister a CDR handling engine.
unregister a CDR driver
Definition at line 165 of file cdr.c.
References ast_free, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, and ast_cdr_beitem::name.
Referenced by load_config(), odbc_load_module(), reload(), tds_unload_module(), and unload_module().
int ast_cdr_update | ( | struct ast_channel * | chan | ) |
Update CDR on a channel.
Definition at line 1083 of file cdr.c.
References ast_cdr::accountcode, ast_channel::accountcode, AST_CDR_FLAG_LOCKED, ast_copy_string(), ast_test_flag, ast_channel::cdr, ast_channel::context, ast_cdr::dcontext, ast_cdr::dst, ast_channel::exten, ast_cdr::linkedid, ast_channel::linkedid, ast_channel::macrocontext, ast_channel::macroexten, ast_cdr::next, ast_cdr::peeraccount, ast_channel::peeraccount, S_OR, and set_one_cid().
Referenced by __ast_pbx_run(), __ast_request_and_dial(), ast_bridge_call(), cb_events(), clear_caller(), findmeexec(), and local_call().
|
static |
Definition at line 1627 of file cdr.c.
References ast_cli_unregister(), ast_cond_destroy, ast_free, AST_PTHREADT_NULL, batch, cdr_pending_cond, cdr_thread, cli_status, cli_submit, and sched_context_destroy().
Referenced by ast_cdr_engine_init().
|
static |
Definition at line 249 of file cdr.c.
References ast_localtime(), and ast_strftime().
Referenced by ast_cdr_getvar().
Definition at line 508 of file cdr.c.
References AST_LIST_MOVE_CURRENT, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log(), ast_var_name(), ast_var_value(), LOG_NOTICE, and ast_cdr::varshead.
Referenced by ast_cdr_merge().
|
static |
Definition at line 892 of file cdr.c.
References ast_atomic_fetchadd_int(), cdr_sequence, and ast_cdr::sequence.
Referenced by ast_cdr_dup_unique(), ast_cdr_dup_unique_swap(), and ast_cdr_init().
int check_cdr_enabled | ( | void | ) |
Return TRUE if CDR subsystem is enabled.
Definition at line 120 of file cdr.c.
References enabled.
Referenced by action_coresettings(), and handle_show_settings().
|
static |
print a warning if cdr already posted
Definition at line 467 of file cdr.c.
References AST_CDR_FLAG_POSTED, ast_log(), ast_test_flag, ast_cdr::channel, LOG_NOTICE, and S_OR.
Referenced by ast_cdr_answer(), ast_cdr_busy(), ast_cdr_end(), ast_cdr_failed(), ast_cdr_noanswer(), ast_cdr_setanswer(), ast_cdr_setapp(), ast_cdr_setdestchan(), ast_cdr_setdisposition(), ast_cdr_start(), and post_cdr().
|
static |
Definition at line 1253 of file cdr.c.
References ast_cdr_free(), ast_free, ast_cdr_batch_item::cdr, ast_cdr_batch_item::next, and post_cdr().
Referenced by ast_cdr_submit_batch().
|
static |
Definition at line 1389 of file cdr.c.
References ast_cond_timedwait, ast_debug, ast_mutex_lock, ast_mutex_unlock, ast_samp2tv(), ast_sched_runq(), ast_sched_wait(), ast_tvadd(), ast_tvnow(), cdr_pending_cond, and cdr_pending_lock.
Referenced by do_reload().
|
static |
Definition at line 1497 of file cdr.c.
References ast_cdr_engine_term(), ast_cli_register(), ast_cli_unregister(), ast_cond_destroy, ast_cond_init, ast_config_destroy(), ast_config_load2(), ast_log(), ast_mutex_lock, ast_mutex_unlock, AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN, AST_OPT_FLAG_INITIATED_SECONDS, ast_options, ast_pthread_create_background, AST_PTHREADT_NULL, ast_register_atexit(), ast_sched_add(), AST_SCHED_DEL, ast_set2_flag, ast_true(), ast_unregister_atexit(), ast_variable_retrieve(), BATCH_SAFE_SHUTDOWN_DEFAULT, BATCH_SCHEDULER_ONLY_DEFAULT, BATCH_SIZE_DEFAULT, BATCH_TIME_DEFAULT, batchmode, BATCHMODE_DEFAULT, batchsafeshutdown, batchscheduleronly, batchsize, batchtime, cdr_batch_lock, cdr_pending_cond, cdr_sched, cdr_sched_lock, cdr_thread, cli_submit, config, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, do_cdr(), enabled, ENABLED_DEFAULT, EVENT_FLAG_SYSTEM, LOG_ERROR, LOG_NOTICE, LOG_WARNING, manager_event, submit_scheduled_batch(), unanswered, and UNANSWERED_DEFAULT.
Referenced by ast_cdr_engine_init(), and ast_cdr_engine_reload().
|
static |
Definition at line 1415 of file cdr.c.
References ast_cli_args::argc, ast_cli(), AST_RWLIST_EMPTY, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_sched_when(), batch, batchmode, batchsafeshutdown, batchscheduleronly, batchsize, batchtime, cdr_sched, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, enabled, ESS, ast_cli_args::fd, ast_cdr_beitem::name, ast_cdr_batch::size, unanswered, and ast_cli_entry::usage.
|
static |
Definition at line 1473 of file cdr.c.
References ast_cli_args::argc, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, submit_unscheduled_batch(), and ast_cli_entry::usage.
|
static |
Definition at line 1242 of file cdr.c.
References ast_malloc, batch, and reset_batch().
Referenced by ast_cdr_detach().
|
static |
Definition at line 1118 of file cdr.c.
References AST_CDR_ANSWERED, AST_CDR_FLAG_DIALED, AST_CDR_FLAG_ORIGINATED, AST_CDR_FLAG_POST_DISABLED, AST_CDR_FLAG_POSTED, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_set_flag, ast_strlen_zero(), ast_test_flag, ast_cdr_beitem::be, ast_cdr::channel, check_post(), ast_cdr::disposition, ast_cdr::dstchannel, ast_cdr::next, and unanswered.
Referenced by ast_cdr_detach(), and do_batch_backend_process().
|
static |
Definition at line 1234 of file cdr.c.
References batch, ast_cdr_batch::head, ast_cdr_batch::size, and ast_cdr_batch::tail.
Referenced by ast_cdr_submit_batch(), and init_batch().
|
static |
Definition at line 859 of file cdr.c.
References ast_party_caller::ani, ast_callerid_merge(), ast_cdr_setvar(), ast_copy_string(), ast_channel::caller, ast_cdr::clid, ast_channel::dialed, ast_party_caller::id, ast_party_id::name, ast_party_id::number, ast_party_dialed::number, S_COR, S_OR, ast_cdr::src, ast_party_name::str, ast_party_number::str, ast_party_subaddress::str, ast_party_dialed::str, ast_party_id::subaddress, ast_party_dialed::subaddress, ast_party_name::valid, ast_party_number::valid, and ast_party_subaddress::valid.
Referenced by ast_cdr_init(), ast_cdr_setcid(), and ast_cdr_update().
|
static |
Definition at line 1300 of file cdr.c.
References ast_cdr_submit_batch(), ast_mutex_lock, ast_mutex_unlock, ast_sched_add(), batchtime, cdr_sched, and cdr_sched_lock.
Referenced by do_reload(), and submit_unscheduled_batch().
|
static |
Do not hold the batch lock while calling this function
Definition at line 1312 of file cdr.c.
References ast_cond_signal, ast_mutex_lock, ast_mutex_unlock, ast_sched_add(), AST_SCHED_DEL, cdr_pending_cond, cdr_pending_lock, cdr_sched, cdr_sched_lock, and submit_scheduled_batch().
Referenced by ast_cdr_detach(), and handle_cli_submit().
char ast_default_accountcode[AST_MAX_ACCOUNT_CODE] |
Definition at line 60 of file cdr.c.
Referenced by __ast_channel_alloc_ap().
int ast_default_amaflags = AST_CDR_DOCUMENTATION |
Default AMA flag for billing records (CDR's)
Definition at line 59 of file cdr.c.
Referenced by __ast_channel_alloc_ap(), ast_bridge_call(), and ast_cdr_init().
|
static |
Referenced by ast_cdr_detach(), ast_cdr_submit_batch(), cdr_engine_shutdown(), handle_cli_status(), init_batch(), and reset_batch().
|
static |
Definition at line 110 of file cdr.c.
Referenced by do_reload().
|
static |
Definition at line 107 of file cdr.c.
Referenced by do_reload().
|
static |
Definition at line 101 of file cdr.c.
Referenced by do_reload().
|
static |
Definition at line 104 of file cdr.c.
Referenced by do_reload().
|
static |
Definition at line 94 of file cdr.c.
Referenced by ast_cdr_detach(), do_reload(), and handle_cli_status().
|
static |
Definition at line 95 of file cdr.c.
Referenced by do_reload().
|
static |
Definition at line 109 of file cdr.c.
Referenced by ast_cdr_engine_term(), do_reload(), and handle_cli_status().
|
static |
Definition at line 106 of file cdr.c.
Referenced by ast_cdr_submit_batch(), do_reload(), and handle_cli_status().
|
static |
Definition at line 100 of file cdr.c.
Referenced by ast_cdr_detach(), do_reload(), and handle_cli_status().
|
static |
Definition at line 103 of file cdr.c.
Referenced by do_reload(), handle_cli_status(), and submit_scheduled_batch().
|
static |
|
static |
Definition at line 114 of file cdr.c.
Referenced by ast_cdr_detach(), ast_cdr_submit_batch(), and do_reload().
|
static |
Definition at line 118 of file cdr.c.
Referenced by cdr_engine_shutdown(), do_cdr(), do_reload(), and submit_unscheduled_batch().
|
static |
Definition at line 117 of file cdr.c.
Referenced by do_cdr(), and submit_unscheduled_batch().
|
static |
Definition at line 336 of file cdr.c.
Referenced by ast_cdr_data_add_structure(), ast_cdr_serialize_variables(), and ast_cdr_setvar().
|
static |
Definition at line 88 of file cdr.c.
Referenced by do_reload(), handle_cli_status(), submit_scheduled_batch(), and submit_unscheduled_batch().
|
static |
Definition at line 112 of file cdr.c.
Referenced by do_reload(), submit_scheduled_batch(), and submit_unscheduled_batch().
|
static |
Definition at line 83 of file cdr.c.
Referenced by cdr_seq_inc().
|
static |
Definition at line 89 of file cdr.c.
Referenced by cdr_engine_shutdown(), and do_reload().
|
static |
Definition at line 1495 of file cdr.c.
Referenced by ast_cdr_engine_init(), and cdr_engine_shutdown().
|
static |
Definition at line 1494 of file cdr.c.
Referenced by cdr_engine_shutdown(), and do_reload().
|
static |
Definition at line 91 of file cdr.c.
Referenced by ast_cdr_detach(), check_cdr_enabled(), do_reload(), handle_cli_refresh(), handle_cli_status(), and internal_dnsmgr_lookup().
|
static |
Definition at line 92 of file cdr.c.
Referenced by do_reload().
|
static |
|
static |
Definition at line 97 of file cdr.c.
Referenced by ast_cdr_isset_unanswered(), do_reload(), handle_cli_status(), and post_cdr().
|
static |
Definition at line 98 of file cdr.c.
Referenced by do_reload().