Asterisk - The Open Source Telephony Project
21.4.1
|
Channel Event Logging API. More...
#include "asterisk.h"
#include "asterisk/module.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/config_options.h"
#include "asterisk/cli.h"
#include "asterisk/astobj2.h"
#include "asterisk/stasis_message_router.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/stasis_bridges.h"
#include "asterisk/bridge.h"
#include "asterisk/parking.h"
#include "asterisk/pickup.h"
#include "asterisk/core_local.h"
#include "asterisk/taskprocessor.h"
Go to the source code of this file.
Data Structures | |
struct | cel_backend |
struct | cel_config |
A container that holds all config-related information. More... | |
struct | cel_dialstatus |
struct | cel_linkedid |
Macros | |
#define | BACKEND_BUCKETS 13 |
#define | CEL_MAX_EVENT_IDS 64 |
Maximum possible CEL event IDs. More... | |
#define | NUM_APP_BUCKETS 97 |
Number of buckets for the appset container. | |
#define | NUM_DIALSTATUS_BUCKETS 251 |
Number of buckets for the dialstatus container. | |
Typedefs | |
typedef void(* | cel_channel_snapshot_monitor) (struct ast_channel_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot, const struct timeval *event_time) |
Typedef for callbacks that get called on channel snapshot updates. | |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static | AO2_GLOBAL_OBJ_STATIC (cel_backends) |
static | AO2_GLOBAL_OBJ_STATIC (cel_dialstatus_store) |
static | AO2_GLOBAL_OBJ_STATIC (cel_linkedids) |
static | AO2_GLOBAL_OBJ_STATIC (cel_configs) |
static int | apps_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
int | ast_cel_backend_register (const char *name, ast_cel_backend_cb backend_callback) |
Register a CEL backend. More... | |
int | ast_cel_backend_unregister (const char *name) |
Unregister a CEL backend. More... | |
unsigned int | ast_cel_check_enabled (void) |
Hashing function for cel_backend. More... | |
struct ast_event * | ast_cel_create_event (struct ast_channel_snapshot *snapshot, enum ast_cel_event_type event_type, const char *userdefevname, struct ast_json *extra, const char *peer) |
Allocate and populate a CEL event structure. More... | |
struct ast_event * | ast_cel_create_event_with_time (struct ast_channel_snapshot *snapshot, enum ast_cel_event_type event_type, const struct timeval *event_time, const char *userdefevname, struct ast_json *extra, const char *peer) |
Allocate and populate a CEL event structure. More... | |
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... | |
void * | ast_cel_general_config_alloc (void) |
Allocate a CEL configuration object. More... | |
struct ast_cel_general_config * | ast_cel_get_config (void) |
Obtain the current CEL configuration. More... | |
const char * | ast_cel_get_type_name (enum ast_cel_event_type type) |
Get the name of a CEL event type. More... | |
void | ast_cel_publish_event (struct ast_channel *chan, enum ast_cel_event_type event_type, struct ast_json *blob) |
Publish a CEL event. More... | |
void | ast_cel_publish_user_event (struct ast_channel *chan, const char *event, const char *extra) |
Publish a CEL user event. More... | |
void | ast_cel_set_config (struct ast_cel_general_config *config) |
Set the current CEL configuration. More... | |
enum ast_cel_event_type | ast_cel_str_to_event_type (const char *name) |
Get the event type from a string. More... | |
struct stasis_topic * | ast_cel_topic (void) |
Get the CEL topic. More... | |
static int | ast_cel_track_event (enum ast_cel_event_type et) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static void | cel_attended_transfer_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static int | cel_backend_send_cb (void *obj, void *arg, int flags) |
static void | cel_blind_transfer_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static void | cel_bridge_enter_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static void | cel_bridge_leave_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static void | cel_channel_app_change (struct ast_channel_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot, const struct timeval *event_time) |
static void | cel_channel_linkedid_change (struct ast_channel_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot, const struct timeval *event_time) |
static void | cel_channel_state_change (struct ast_channel_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot, const struct timeval *event_time) |
Handle channel state changes. | |
static void * | cel_config_alloc (void) |
static void | cel_config_dtor (void *obj) |
Destructor for cel_config. | |
static void | cel_dial_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static int | cel_filter_channel_snapshot (struct ast_channel_snapshot *snapshot) |
static void | cel_general_config_dtor (void *obj) |
Destructor for cel_config. | |
static struct ast_str * | cel_generate_peer_str (struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *chan) |
static void | cel_generic_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
struct stasis_message_type * | cel_generic_type (void) |
static int | cel_linkedid_ref (const char *linkedid) |
static void | cel_local_optimization_begin_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static void | cel_local_optimization_cb_helper (void *data, struct stasis_subscription *sub, struct stasis_message *message, enum ast_cel_event_type event_type) |
static void | cel_local_optimization_end_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static void | cel_parking_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static void | cel_pickup_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static int | cel_pre_apply_config (void) |
static int | cel_report_event (struct ast_channel_snapshot *snapshot, enum ast_cel_event_type event_type, const struct timeval *event_time, const char *userdefevname, struct ast_json *extra, const char *peer_str) |
static void | cel_snapshot_update_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static int | cel_track_app (const char *const_app) |
static void | check_retire_linkedid (struct ast_channel_snapshot *snapshot, const struct timeval *event_time) |
CONFIG_INFO_CORE ("cel", cel_cfg_info, cel_configs, cel_config_alloc,.files=ACO_FILES(&cel_conf),.pre_apply_config=cel_pre_apply_config,) | |
static int | create_routes (void) |
Create the Stasis message router and routes for CEL. | |
static int | create_subscriptions (void) |
Create the Stasis subscriptions for CEL. | |
static void | destroy_routes (void) |
static void | destroy_subscriptions (void) |
static int | events_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static const char * | get_blob_variable (struct ast_multi_channel_blob *blob, const char *varname) |
static struct cel_dialstatus * | get_dialstatus (const char *uniqueid) |
static char * | handle_cli_status (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | is_valid_dialstatus (struct ast_multi_channel_blob *blob) |
static int | load_module (void) |
static int | reload_module (void) |
static void | save_dialstatus (struct ast_multi_channel_blob *blob, struct ast_channel_snapshot *snapshot) |
STASIS_MESSAGE_TYPE_DEFN (cel_generic_type) | |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "CEL Engine" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "da6642af068ee5e6490c5b1d2cc1d238" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, .requires = "extconfig", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct stasis_topic * | cel_aggregation_topic |
static struct stasis_forward * | cel_bridge_forwarder |
static struct stasis_forward * | cel_cel_forwarder |
static struct stasis_forward * | cel_channel_forwarder |
cel_channel_snapshot_monitor | cel_channel_monitors [] |
Handlers for channel snapshot changes. More... | |
static struct aco_file | cel_conf |
The config file to be processed for the module. More... | |
static const char *const | cel_event_types [CEL_MAX_EVENT_IDS] |
Map of ast_cel_event_type to strings. | |
static struct stasis_forward * | cel_parking_forwarder |
static struct stasis_message_router * | cel_state_router |
static struct stasis_topic * | cel_topic |
static struct ast_cli_entry | cli_status = { .handler = handle_cli_status , .summary = "Display the CEL status" ,} |
static const struct ast_datastore_info | fabricated_channel_datastore |
static struct aco_type | general_option |
An aco_type structure to link the "general" category to the ast_cel_general_config type. | |
static struct aco_type * | general_options [] = ACO_TYPES(&general_option) |
static const char * | ignore_categories [] |
static struct aco_type | ignore_option |
Channel Event Logging API.
Definition in file cel.c.
#define BACKEND_BUCKETS 13 |
#define CEL_MAX_EVENT_IDS 64 |
|
static |
Container for CEL backend information
|
static |
Container for dial end multichannel blobs for holding on to dial statuses
|
static |
Container of channel references to a linkedid for CEL purposes.
int ast_cel_backend_register | ( | const char * | name, |
ast_cel_backend_cb | backend_callback | ||
) |
Register a CEL backend.
name | Name of backend to register |
backend_callback | Callback to register |
zero | on success |
non-zero | on failure |
Definition at line 1781 of file cel.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_global_obj_ref, ao2_link, ao2_ref, cel_backend::callback, cel_backend::name, and RAII_VAR.
int ast_cel_backend_unregister | ( | const char * | name | ) |
Unregister a CEL backend.
name | Name of backend to unregister |
zero | on success |
non-zero | on failure |
Definition at line 1769 of file cel.c.
References ao2_global_obj_ref, ao2_ref, OBJ_NODATA, OBJ_SEARCH_KEY, and OBJ_UNLINK.
unsigned int ast_cel_check_enabled | ( | void | ) |
Hashing function for cel_backend.
Check to see if CEL is enabled.
Comparator function for cel_backend
Hashing function for dialstatus container
Comparator function for dialstatus container
Definition at line 345 of file cel.c.
References ao2_global_obj_ref, ast_cel_general_config::enable, and enabled.
Referenced by ast_cel_set_config().
struct ast_event* ast_cel_create_event | ( | struct ast_channel_snapshot * | snapshot, |
enum ast_cel_event_type | event_type, | ||
const char * | userdefevname, | ||
struct ast_json * | extra, | ||
const char * | peer_str | ||
) |
Allocate and populate a CEL event structure.
snapshot | An ast_channel_snapshot of the primary channel associated with this channel event. |
event_type | The type of call event being reported. |
userdefevname | Custom name for the call event. (optional) |
extra | An event-specific opaque JSON blob to be rendered and placed in the "CEL_EXTRA" information element of the call event. (optional) |
peer_str | A list of comma-separated peer channel names. (optional) |
The | created ast_event structure |
NULL | on failure |
Definition at line 519 of file cel.c.
References ast_cel_create_event_with_time(), and ast_tvnow().
struct ast_event* ast_cel_create_event_with_time | ( | struct ast_channel_snapshot * | snapshot, |
enum ast_cel_event_type | event_type, | ||
const struct timeval * | event_time, | ||
const char * | userdefevname, | ||
struct ast_json * | extra, | ||
const char * | peer_str | ||
) |
Allocate and populate a CEL event structure.
snapshot | An ast_channel_snapshot of the primary channel associated with this channel event. |
event_type | The type of call event being reported. |
event_time | The time at which the event occurred. |
userdefevname | Custom name for the call event. (optional) |
extra | An event-specific opaque JSON blob to be rendered and placed in the "CEL_EXTRA" information element of the call event. (optional) |
peer_str | A list of comma-separated peer channel names. (optional) |
The | created ast_event structure |
NULL | on failure |
Definition at line 529 of file cel.c.
References ast_channel_snapshot_peer::account, ast_channel_snapshot_base::accountcode, ast_channel_snapshot::amaflags, ast_channel_snapshot_caller::ani, ast_channel_snapshot_dialplan::appl, AST_EVENT_CEL, 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_json_dump_string, ast_json_free(), ast_channel_snapshot::base, ast_channel_snapshot::caller, ast_channel_snapshot_dialplan::context, ast_channel_snapshot_dialplan::data, ast_channel_snapshot::dialplan, ast_channel_snapshot_caller::dnid, ast_channel_snapshot_dialplan::exten, ast_channel_snapshot_peer::linkedid, ast_channel_snapshot_caller::name, ast_channel_snapshot_base::name, ast_channel_snapshot_caller::number, ast_channel_snapshot::peer, RAII_VAR, ast_channel_snapshot_caller::rdnis, S_OR, ast_channel_snapshot_base::uniqueid, and ast_channel_snapshot_base::userfield.
Referenced by ast_cel_create_event().
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 662 of file cel.c.
References ast_party_caller::ani, ao2_global_obj_ref, AST_CEL_EVENT_RECORD_VERSION, ast_cel_fill_record(), AST_CEL_USER_DEFINED, ast_channel_amaflags_set(), ast_channel_datastore_add(), ast_channel_internal_set_fake_ids(), ast_channel_unref, ast_datastore_free(), ast_dummy_channel_alloc, AST_LIST_INSERT_HEAD, ast_localtime(), ast_malloc, ast_strdup, ast_strftime(), ast_datastore::data, ast_party_redirecting::from, ast_party_caller::id, ast_party_id::name, ast_party_id::number, ast_party_dialed::number, RAII_VAR, ast_party_name::str, ast_party_number::str, ast_party_dialed::str, ast_party_name::valid, ast_party_number::valid, 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 821 of file cel.c.
References 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_PEERACCT, AST_EVENT_IE_CEL_UNIQUEID, AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_CEL_USERFIELD, S_OR, and ast_cel_event_record::version.
Referenced by ast_cel_fabricate_channel_from_event().
void* ast_cel_general_config_alloc | ( | void | ) |
Allocate a CEL configuration object.
NULL | on error |
The | new CEL configuration object |
Definition at line 189 of file cel.c.
References ao2_ref, ast_str_container_alloc, ast_string_field_init, cel_general_config_dtor(), NUM_APP_BUCKETS, and RAII_VAR.
struct ast_cel_general_config* ast_cel_get_config | ( | void | ) |
Obtain the current CEL configuration.
NULL | on error |
The | current CEL configuration |
Definition at line 1731 of file cel.c.
References ao2_global_obj_ref, ao2_ref, and RAII_VAR.
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 493 of file cel.c.
References S_OR.
Referenced by ast_cel_fill_record().
void ast_cel_publish_event | ( | struct ast_channel * | chan, |
enum ast_cel_event_type | event_type, | ||
struct ast_json * | blob | ||
) |
Publish a CEL event.
chan | This is the primary channel associated with this channel event. |
event_type | This is the type of call event being reported. |
blob | This contains any additional parameters that need to be conveyed for this event. |
Definition at line 1707 of file cel.c.
References ast_cel_topic(), ast_channel_blob_create_from_cache(), ast_json_pack(), ast_json_ref(), ast_json_unref(), and stasis_publish().
Referenced by ast_cel_publish_user_event().
void ast_cel_publish_user_event | ( | struct ast_channel * | chan, |
const char * | event, | ||
const char * | extra | ||
) |
Publish a CEL user event.
chan | This is the primary channel associated with this channel event. |
event | This is the user event being reported. |
extra | This contains any extra parameters that need to be conveyed for this event. |
Definition at line 1692 of file cel.c.
References ast_cel_publish_event(), AST_CEL_USER_DEFINED, ast_json_pack(), ast_json_unref(), RAII_VAR, and S_OR.
void ast_cel_set_config | ( | struct ast_cel_general_config * | config | ) |
Set the current CEL configuration.
config | The new CEL configuration |
Definition at line 1743 of file cel.c.
References ao2_bump, ao2_global_obj_ref, ao2_ref, ast_cel_check_enabled(), create_routes(), and is_enabled().
enum ast_cel_event_type ast_cel_str_to_event_type | ( | const char * | name | ) |
struct stasis_topic* ast_cel_topic | ( | void | ) |
Get the CEL topic.
The | CEL topic |
NULL | if not allocated |
Definition at line 1726 of file cel.c.
References cel_topic.
Referenced by ast_cel_publish_event(), and create_subscriptions().
|
static |
|
static |
|
static |
|
static |
cel_channel_snapshot_monitor cel_channel_monitors[] |
Handlers for channel snapshot changes.
|
static |
The config file to be processed for the module.
|
static |
|
static |
|
static |
Topic for CEL-specific messages
Definition at line 118 of file cel.c.
Referenced by ast_cel_topic().
|
static |