Channel Event Logging API. More...
#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/cel.h"
#include "asterisk/logger.h"
#include "asterisk/linkedlists.h"
#include "asterisk/utils.h"
#include "asterisk/config.h"
#include "asterisk/cli.h"
#include "asterisk/astobj2.h"
Go to the source code of this file.
Data Structures | |
struct | cel_linkedid |
Macros | |
#define | CEL_DEFAULT_EVENTS 0 |
Track no events by default. More... | |
#define | CEL_ENABLED_DEFAULT 0 |
CEL is off by default. More... | |
#define | CEL_MAX_EVENT_IDS 64 |
Maximum possible CEL event IDs. More... | |
#define | NUM_APP_BUCKETS 97 |
Number of buckets for the appset container. More... | |
Functions | |
static int | app_cmp (void *obj, void *arg, int flags) |
static int | app_hash (const void *obj, const int flags) |
unsigned int | ast_cel_check_enabled (void) |
Check to see if CEL is enabled. More... | |
void | ast_cel_check_retire_linkedid (struct ast_channel *chan) |
Check and potentially retire a Linked ID. More... | |
int | ast_cel_engine_init (void) |
int | ast_cel_engine_reload (void) |
static void | ast_cel_engine_term (void) |
struct ast_channel * | ast_cel_fabricate_channel_from_event (const struct ast_event *event) |
Create a fake channel from data in a CEL event. More... | |
int | ast_cel_fill_record (const struct ast_event *e, struct ast_cel_event_record *r) |
Fill in an ast_cel_event_record from a CEL event. More... | |
const char * | ast_cel_get_ama_flag_name (enum ast_cel_ama_flag flag) |
Convert AMA flag to printable string. More... | |
const char * | ast_cel_get_type_name (enum ast_cel_event_type type) |
Get the name of a CEL event type. More... | |
int | ast_cel_linkedid_ref (const char *linkedid) |
Inform CEL that a new linkedid is being used. More... | |
int | ast_cel_report_event (struct ast_channel *chan, enum ast_cel_event_type event_type, const char *userdefevname, const char *extra, struct ast_channel *peer2) |
Report a channel event. More... | |
enum ast_cel_event_type | ast_cel_str_to_event_type (const char *name) |
Get the event type from a string. More... | |
static int | ast_cel_track_event (enum ast_cel_event_type et) |
static int | do_reload (int is_reload) |
static char * | handle_cli_status (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | lid_cmp (void *obj, void *arg, int flags) |
static int | lid_hash (const void *obj, const int flags) |
static void | parse_apps (const char *val) |
static void | parse_events (const char *val) |
static void | print_cel_sub (const struct ast_event *event, void *data) |
static void | set_defaults (void) |
Variables | |
static struct ao2_container * | appset |
Container of Asterisk application names. More... | |
static const char *const | cel_ama_flags [AST_CEL_AMA_FLAG_TOTAL] |
Map of ast_cel_ama_flags to strings. More... | |
static const char | cel_conf_file [] = "cel.conf" |
static char | cel_dateformat [256] |
Configured date format for event timestamps. More... | |
static unsigned char | cel_enabled |
static const char *const | cel_event_types [CEL_MAX_EVENT_IDS] |
Map of ast_cel_event_type to strings. More... | |
static struct ast_cli_entry | cli_status = AST_CLI_DEFINE(handle_cli_status, "Display the CEL status") |
static int64_t | eventset |
which events we want to track More... | |
static struct ast_datastore_info | fabricated_channel_datastore |
static struct ao2_container * | linkedids |
Container of channel references to a linkedid for CEL purposes. More... | |
static ast_mutex_t | reload_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } |
Lock protecting CEL. More... | |
Channel Event Logging API.
Definition in file cel.c.
#define CEL_DEFAULT_EVENTS 0 |
#define CEL_ENABLED_DEFAULT 0 |
#define CEL_MAX_EVENT_IDS 64 |
#define NUM_APP_BUCKETS 97 |
Number of buckets for the appset container.
Definition at line 80 of file cel.c.
Referenced by ast_cel_engine_init().
|
static |
Definition at line 812 of file cel.c.
References app1, app2, and CMP_MATCH.
Referenced by ast_cel_engine_init().
|
static |
Definition at line 807 of file cel.c.
References ast_str_case_hash().
Referenced by ast_cel_engine_init().
unsigned int ast_cel_check_enabled | ( | void | ) |
Check to see if CEL is enabled.
zero | not enabled |
non-zero | enabled |
Definition at line 164 of file cel.c.
References cel_enabled.
void ast_cel_check_retire_linkedid | ( | struct ast_channel * | chan | ) |
Check and potentially retire a Linked ID.
chan | channel that is being destroyed or its linkedid is changing |
If at least one CEL backend is looking for CEL_LINKEDID_END events, this function will check if the given channel is the last active channel with that linkedid, and if it is, emit a CEL_LINKEDID_END event.
Definition at line 429 of file cel.c.
References ao2_find, ao2_ref, ao2_unlink, AST_CEL_LINKEDID_END, ast_cel_report_event(), ast_cel_track_event(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero(), cel_linkedid::count, cel_linkedid::id, ast_channel::linkedid, LOG_ERROR, OBJ_POINTER, and reload_lock.
Referenced by ast_channel_change_linkedid(), and ast_channel_destructor().
int ast_cel_engine_init | ( | void | ) |
Provided by cel.c
Definition at line 860 of file cel.c.
References ao2_container_alloc, app_cmp(), app_hash(), ast_cel_engine_term(), ast_cli_register(), ast_register_atexit(), do_reload(), lid_cmp(), lid_hash(), and NUM_APP_BUCKETS.
Referenced by main().
int ast_cel_engine_reload | ( | void | ) |
|
static |
Definition at line 841 of file cel.c.
References ao2_ref, ast_cli_unregister(), ast_mutex_lock, ast_mutex_unlock, and reload_lock.
Referenced by ast_cel_engine_init().
struct ast_channel* ast_cel_fabricate_channel_from_event | ( | const struct ast_event * | event | ) |
Create a fake channel from data in a CEL event.
event | the CEL event |
Definition at line 486 of file cel.c.
References ast_cel_event_record::account_code, accountcode, ast_cel_event_record::amaflag, ast_channel::amaflags, ast_party_caller::ani, ast_channel::appl, ast_cel_event_record::application_data, ast_cel_event_record::application_name, AST_CEL_EVENT_RECORD_VERSION, ast_cel_fill_record(), ast_channel_datastore_add(), ast_channel_unref, ast_copy_string(), ast_datastore_alloc(), ast_datastore_free(), ast_dummy_channel_alloc(), AST_LIST_INSERT_HEAD, ast_localtime(), ast_malloc, ast_strdup, ast_strftime(), ast_string_field_set, ast_strlen_zero(), ast_var_assign(), ast_channel::caller, ast_cel_event_record::caller_id_ani, ast_cel_event_record::caller_id_dnid, ast_cel_event_record::caller_id_name, ast_cel_event_record::caller_id_num, ast_cel_event_record::caller_id_rdnis, ast_cel_event_record::channel_name, ast_cel_event_record::context, ast_channel::context, ast_datastore::data, ast_channel::data, ast_channel::dialed, ast_cel_event_record::event_name, ast_cel_event_record::event_time, ast_channel::exten, ast_cel_event_record::extension, ast_cel_event_record::extra, ast_party_redirecting::from, ast_party_caller::id, ast_cel_event_record::linked_id, name, ast_party_id::name, ast_party_id::number, ast_party_dialed::number, ast_cel_event_record::peer, ast_cel_event_record::peer_account, ast_channel::redirecting, ast_party_name::str, ast_party_number::str, ast_party_dialed::str, ast_cel_event_record::unique_id, ast_cel_event_record::user_defined_name, ast_cel_event_record::user_field, ast_party_name::valid, ast_party_number::valid, ast_channel::varshead, and ast_cel_event_record::version.
int ast_cel_fill_record | ( | const struct ast_event * | event, |
struct ast_cel_event_record * | r | ||
) |
Fill in an ast_cel_event_record from a CEL event.
[in] | event | the CEL event |
[out] | r | the ast_cel_event_record to fill in |
0 | success |
non-zero | failure |
Definition at line 762 of file cel.c.
References ast_cel_event_record::account_code, ast_cel_event_record::amaflag, ast_cel_event_record::application_data, ast_cel_event_record::application_name, AST_CEL_EVENT_RECORD_VERSION, ast_cel_get_type_name(), AST_CEL_USER_DEFINED, ast_event_get_ie_str(), ast_event_get_ie_uint(), AST_EVENT_IE_CEL_ACCTCODE, AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_CEL_APPDATA, AST_EVENT_IE_CEL_APPNAME, AST_EVENT_IE_CEL_CHANNAME, AST_EVENT_IE_CEL_CIDANI, AST_EVENT_IE_CEL_CIDDNID, AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_CEL_CIDNUM, AST_EVENT_IE_CEL_CIDRDNIS, AST_EVENT_IE_CEL_CONTEXT, AST_EVENT_IE_CEL_EVENT_TIME, AST_EVENT_IE_CEL_EVENT_TIME_USEC, AST_EVENT_IE_CEL_EVENT_TYPE, AST_EVENT_IE_CEL_EXTEN, AST_EVENT_IE_CEL_EXTRA, AST_EVENT_IE_CEL_LINKEDID, AST_EVENT_IE_CEL_PEER, AST_EVENT_IE_CEL_UNIQUEID, AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_CEL_USERFIELD, ast_log(), ast_cel_event_record::caller_id_ani, ast_cel_event_record::caller_id_dnid, ast_cel_event_record::caller_id_name, ast_cel_event_record::caller_id_num, ast_cel_event_record::caller_id_rdnis, ast_cel_event_record::channel_name, ast_cel_event_record::context, ast_cel_event_record::event_name, ast_cel_event_record::event_time, ast_cel_event_record::event_type, ast_cel_event_record::extension, ast_cel_event_record::extra, ast_cel_event_record::linked_id, LOG_ERROR, ast_cel_event_record::peer, ast_cel_event_record::peer_account, S_OR, ast_cel_event_record::unique_id, ast_cel_event_record::user_defined_name, ast_cel_event_record::user_field, and ast_cel_event_record::version.
Referenced by ast_cel_fabricate_channel_from_event().
const char* ast_cel_get_ama_flag_name | ( | enum ast_cel_ama_flag | flag | ) |
Convert AMA flag to printable string.
[in] | flag | the flag to convert to a string |
Definition at line 417 of file cel.c.
References ARRAY_LEN, ast_log(), LOG_WARNING, and S_OR.
const char* ast_cel_get_type_name | ( | enum ast_cel_event_type | type | ) |
Get the name of a CEL event type.
type | the type to get the name of |
Definition at line 412 of file cel.c.
References S_OR.
Referenced by ast_cel_fill_record(), and handle_cli_status().
int ast_cel_linkedid_ref | ( | const char * | linkedid | ) |
Inform CEL that a new linkedid is being used.
-1 | error |
0 | success |
Definition at line 597 of file cel.c.
References ao2_alloc, ao2_find, ao2_link, ao2_ref, AST_CEL_LINKEDID_END, ast_cel_track_event(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero(), cel_linkedid::count, cel_linkedid::id, LOG_ERROR, OBJ_POINTER, and reload_lock.
Referenced by ast_cel_report_event(), and ast_channel_change_linkedid().
int ast_cel_report_event | ( | struct ast_channel * | chan, |
enum ast_cel_event_type | event_type, | ||
const char * | userdefevname, | ||
const char * | extra, | ||
struct ast_channel * | peer2 | ||
) |
Report a channel event.
chan | This argument is required. This is the primary channel associated with this channel event. |
event_type | This is the type of call event being reported. |
userdefevname | This is an optional custom name for the call event. |
extra | This is an optional opaque field that will go into the "CEL_EXTRA" information element of the call event. |
peer2 | All CEL events contain a "peer name" information element. The first place the code will look to get a peer name is from the bridged channel to chan. If chan has no bridged channel and peer2 is specified, then the name of peer2 will go into the "peer name" field. If neither are available, the peer name field will be blank. |
0 | success |
non-zero | failure |
Definition at line 645 of file cel.c.
References ast_channel::accountcode, ast_channel::amaflags, ast_party_caller::ani, ao2_find, ao2_ref, app, ast_channel::appl, ast_bridged_channel(), AST_CEL_APP_END, AST_CEL_APP_START, AST_CEL_CHANNEL_START, AST_CEL_LINKEDID_END, ast_cel_linkedid_ref(), ast_cel_track_event(), ast_channel_lock, ast_channel_ref, ast_channel_unlock, ast_channel_unref, AST_EVENT_CEL, ast_event_destroy(), AST_EVENT_IE_CEL_ACCTCODE, AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_CEL_APPDATA, AST_EVENT_IE_CEL_APPNAME, AST_EVENT_IE_CEL_CHANNAME, AST_EVENT_IE_CEL_CIDANI, AST_EVENT_IE_CEL_CIDDNID, AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_CEL_CIDNUM, AST_EVENT_IE_CEL_CIDRDNIS, AST_EVENT_IE_CEL_CONTEXT, AST_EVENT_IE_CEL_EVENT_TIME, AST_EVENT_IE_CEL_EVENT_TIME_USEC, AST_EVENT_IE_CEL_EVENT_TYPE, AST_EVENT_IE_CEL_EXTEN, AST_EVENT_IE_CEL_EXTRA, AST_EVENT_IE_CEL_LINKEDID, AST_EVENT_IE_CEL_PEER, AST_EVENT_IE_CEL_PEERACCT, AST_EVENT_IE_CEL_UNIQUEID, AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_CEL_USERFIELD, AST_EVENT_IE_END, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_IE_PLTYPE_UINT, ast_event_new(), ast_event_queue(), ast_mutex_lock, ast_mutex_unlock, ast_strdupa, ast_tvnow(), ast_channel::caller, ast_channel::context, ast_channel::data, ast_channel::dialed, ast_channel::exten, ast_party_redirecting::from, ast_party_caller::id, ast_channel::linkedid, ast_party_id::name, ast_channel::name, ast_party_id::number, ast_party_dialed::number, OBJ_POINTER, ast_channel::peeraccount, ast_channel::redirecting, reload_lock, S_COR, S_OR, ast_party_name::str, ast_party_number::str, ast_party_dialed::str, ast_channel::uniqueid, ast_channel::userfield, ast_party_name::valid, and ast_party_number::valid.
Referenced by __ast_channel_alloc_ap(), __ast_read(), analog_attempt_transfer(), ast_bridge_call(), ast_cel_check_retire_linkedid(), ast_channel_destructor(), ast_do_masquerade(), ast_do_pickup(), ast_hangup(), ast_raw_answer(), builtin_atxfer(), builtin_blindtransfer(), celgenuserevent_exec(), do_forward(), handle_invite_replaces(), handle_request_refer(), local_attended_transfer(), manage_parked_call(), park_call_full(), parked_call_exec(), pbx_exec(), and wait_for_answer().
enum ast_cel_event_type ast_cel_str_to_event_type | ( | const char * | name | ) |
Get the event type from a string.
name | the event type name as a string |
Definition at line 254 of file cel.c.
References ARRAY_LEN.
Referenced by parse_events().
|
static |
Definition at line 271 of file cel.c.
Referenced by ast_cel_check_retire_linkedid(), ast_cel_linkedid_ref(), ast_cel_report_event(), and parse_apps().
|
static |
Definition at line 342 of file cel.c.
References ast_config_destroy(), ast_config_load2(), ast_copy_string(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_true(), ast_variable_retrieve(), ast_verb, config, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, LOG_WARNING, parse_apps(), parse_events(), reload_lock, and set_defaults().
Referenced by ast_cel_engine_init(), and ast_cel_engine_reload().
|
static |
Definition at line 177 of file cel.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, app, ast_cli_args::argc, ast_cel_get_type_name(), ast_cli(), AST_EVENT_CEL, AST_EVENT_IE_EVENTTYPE, ast_event_report_subs(), AST_EVENT_SUB, ast_event_sub_append_ie_uint(), ast_event_sub_destroy(), ast_event_subscribe_new(), ast_mutex_lock, ast_mutex_unlock, CLI_FAILURE, CLI_GENERATE, CLI_HANDLER, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, eventset, ast_cli_args::fd, name, print_cel_sub(), reload_lock, and ast_cli_entry::usage.
|
static |
Definition at line 830 of file cel.c.
References CMP_MATCH, and cel_linkedid::id.
Referenced by ast_cel_engine_init().
|
static |
Definition at line 820 of file cel.c.
References ast_str_case_hash(), and cel_linkedid::id.
Referenced by ast_cel_engine_init().
|
static |
Definition at line 303 of file cel.c.
References ao2_alloc, ao2_link, ao2_ref, app, AST_CEL_APP_END, AST_CEL_APP_START, ast_cel_track_event(), ast_log(), ast_strdupa, ast_strip(), ast_strlen_zero(), LOG_WARNING, and strsep().
Referenced by do_reload().
|
static |
Definition at line 276 of file cel.c.
References ast_cel_str_to_event_type(), ast_log(), ast_strdupa, ast_strip(), ast_strlen_zero(), events, LOG_WARNING, and strsep().
Referenced by do_reload().
|
static |
Definition at line 169 of file cel.c.
References ast_cli(), ast_event_get_ie_str(), AST_EVENT_IE_DESCRIPTION, and ast_cli_args::fd.
Referenced by handle_cli_status().
|
static |
Definition at line 334 of file cel.c.
References ao2_callback, CEL_DEFAULT_EVENTS, CEL_ENABLED_DEFAULT, OBJ_MULTIPLE, OBJ_NODATA, and OBJ_UNLINK.
Referenced by do_reload().
|
static |
Container of Asterisk application names.
The apps in this container are the applications that were specified in the configuration as applications that CEL events should be generated for when they start and end on a channel.
|
static |
|
static |
|
static |
|
static |
Is the CEL subsystem enabled ?
Definition at line 54 of file cel.c.
Referenced by ast_cel_check_enabled().
|
static |
|
static |
|
static |
which events we want to track
Definition at line 64 of file cel.c.
Referenced by handle_cli_status().
|
static |
|
static |
|
static |
Lock protecting CEL.
Definition at line 88 of file cel.c.
Referenced by ast_cel_check_retire_linkedid(), ast_cel_engine_term(), ast_cel_linkedid_ref(), ast_cel_report_event(), do_reload(), and handle_cli_status().