38 #include "asterisk/_private.h"
57 #define CEL_ENABLED_DEFAULT 0
70 #define CEL_MAX_EVENT_IDS 64
75 #define CEL_DEFAULT_EVENTS 0
80 #define NUM_APP_BUCKETS 97
173 ast_cli(a->
fd,
"CEL Event Subscriber: %s\n",
184 e->
command =
"cel show status";
186 "Usage: cel show status\n"
187 " Displays the Channel Event Logging system status.\n";
199 ast_cli(a->
fd,
"CEL Logging: %s\n", cel_enabled ?
"Enabled" :
"Disabled");
205 for (i = 0; i < (
sizeof(
eventset) * 8); i++) {
208 if (!(eventset & ((int64_t) 1 << i))) {
213 if (strcasecmp(name,
"Unknown")) {
214 ast_cli(a->
fd,
"CEL Tracking Event: %s\n", name);
232 ast_cli(a->
fd,
"CEL Tracking Application: %s\n", app);
258 for (i = 0; i <
ARRAY_LEN(cel_event_types); i++) {
259 if (!cel_event_types[i]) {
263 if (!strcasecmp(name, cel_event_types[i])) {
273 return (eventset & ((int64_t) 1 << et));
281 while ((cur_event =
strsep(&events,
","))) {
291 if (event_type == 0) {
293 eventset = (int64_t) -1;
294 }
else if (event_type == -1) {
298 eventset |= ((int64_t) 1 << event_type);
313 while ((cur_app =
strsep(&apps,
","))) {
322 app =
ao2_alloc(strlen(cur_app) + 1, NULL);
326 strcpy(app, cur_app);
338 *cel_dateformat =
'\0';
345 const char *enabled_value;
380 cel_enabled =
ast_true(enabled_value);
401 ast_verb(3,
"CEL logging %sabled.\n", cel_enabled ?
"en" :
"dis");
414 return S_OR(cel_event_types[type],
"Unknown");
419 if (flag < 0 || flag >=
ARRAY_LEN(cel_ama_flags)) {
424 return S_OR(cel_ama_flags[flag],
"Unknown");
431 const char *linkedid = chan->
linkedid;
452 find_lid.
id = linkedid;
462 ast_log(
LOG_ERROR,
"Something weird happened, couldn't find linkedid %s\n", linkedid);
482 .
type =
"CEL fabricated channel",
517 snprintf(timebuf,
sizeof(timebuf),
"%ld.%06ld", (
long) record.
event_time.tv_sec,
522 ast_strftime(timebuf,
sizeof(timebuf), cel_dateformat, &tm);
591 datastore->
data = app_data;
621 find_lid.
id = linkedid;
628 lid =
ao2_alloc(
sizeof(*lid) + strlen(linkedid) + 1, NULL);
633 lid->
id = (
char *) (lid + 1);
634 strcpy((
char *) lid->
id, linkedid);
646 const char *userdefevname,
const char *extra,
struct ast_channel *peer2)
648 struct timeval eventtime;
650 const char *peername =
"";
706 if (!userdefevname) {
766 "Please ensure all modules were compiled for "
767 "this version of Asterisk.\n");
814 const char *
app1 = obj;
815 const char *
app2 = arg;
817 return !strcasecmp(app1, app2) ?
CMP_MATCH : 0;
830 static int lid_cmp(
void *obj,
void *arg,
int flags)
const ast_string_field peeraccount
const char * account_code
the last channel with the given linkedid is retired
channel enters a conference
const char * caller_id_name
#define NUM_APP_BUCKETS
Number of buckets for the appset container.
Helper struct for getting the fields out of a CEL event.
static char accountcode[AST_MAX_ACCOUNT_CODE]
Channel Event CID name Used by: AST_EVENT_CEL Payload type: STR.
Channel Event app name Used by: AST_EVENT_CEL Payload type: STR.
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
#define CEL_MAX_EVENT_IDS
Maximum possible CEL event IDs.
#define AST_CLI_DEFINE(fn, txt,...)
char * str
Subscriber phone number (Malloced)
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_link(arg1, arg2)
static int do_reload(int is_reload)
static int app_cmp(void *obj, void *arg, int flags)
static struct ast_cli_entry cli_status
const char * ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable)
Gets a variable.
static const char config[]
char * str
Subscriber phone number (Malloced)
struct ast_party_caller caller
Channel Caller ID information.
char * strsep(char **str, const char *delims)
const ast_string_field uniqueid
static int ast_cel_track_event(enum ast_cel_event_type et)
int ast_cli_register(struct ast_cli_entry *e)
Registers a command or an array of commands.
Channel Event extra data Used by: AST_EVENT_CEL Payload type: STR.
void ast_cel_check_retire_linkedid(struct ast_channel *chan)
Check and potentially retire a Linked ID.
#define ast_channel_unref(c)
Decrease channel reference count.
int ast_cel_engine_reload(void)
struct ast_party_name name
Subscriber name.
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
static int app_hash(const void *obj, const int flags)
struct ast_var_t * ast_var_assign(const char *name, const char *value)
const char * user_defined_name
char context[AST_MAX_CONTEXT]
#define ao2_iterator_next(arg1)
void ast_event_report_subs(const struct ast_event_sub *sub)
Report current subscriptions to a subscription subscriber.
int ast_cli_unregister(struct ast_cli_entry *e)
Unregisters a command or an array of commands.
descriptor for a cli entry.
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.
const char * application_data
#define ao2_callback(c, flags, cb_fn, arg)
const char * application_name
Channel Event channel name Used by: AST_EVENT_CEL Payload type: STR.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
Channel Event UniqueID Used by: AST_EVENT_CEL Payload type: STR.
Channel Event context name Used by: AST_EVENT_CEL Payload type: STR.
Channel Event app args/data Used by: AST_EVENT_CEL Payload type: STR.
Channel Event peeraccount Used by: AST_EVENT_CEL Payload type: STR.
Channel Event Time (micro-seconds) Used by: AST_EVENT_CEL Payload type: UINT.
Channel Event CID dnid Used by: AST_EVENT_CEL Payload type: STR.
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Description Used by: AST_EVENT_SUB, AST_EVENT_UNSUB Payload type: STR.
Structure for a data store type.
Configuration File Parser.
char * str
Subscriber name (Malloced)
unsigned int ast_cel_check_enabled(void)
Check to see if CEL is enabled.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
const char * caller_id_num
#define ast_mutex_lock(a)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags)
Create an iterator for a container.
Structure for a data store object.
static const char *const cel_event_types[CEL_MAX_EVENT_IDS]
Map of ast_cel_event_type to strings.
void ast_event_sub_destroy(struct ast_event_sub *sub)
Destroy an allocated subscription.
void ast_cli(int fd, const char *fmt,...)
const ast_string_field linkedid
void ast_free_ptr(void *ptr)
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
#define ast_verb(level,...)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Channel Event Type Used by: AST_EVENT_CEL Payload type: UINT.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
static void ast_cel_engine_term(void)
static int64_t eventset
which events we want to track
static ast_mutex_t reload_lock
Lock protecting CEL.
static void print_cel_sub(const struct ast_event *event, void *data)
Channel Event Time (seconds) Used by: AST_EVENT_CEL Payload type: UINT.
static struct ao2_container * appset
Container of Asterisk application names.
Channel Event CID num Used by: AST_EVENT_CEL Payload type: STR.
const char * ast_cel_get_type_name(enum ast_cel_event_type type)
Get the name of a CEL event type.
int ast_cel_engine_init(void)
struct ast_party_id id
Caller party ID.
#define CEL_ENABLED_DEFAULT
CEL is off by default.
a masquerade happened to alter the participants on a bridge
Channel Event extension name Used by: AST_EVENT_CEL Payload type: STR.
int ast_event_queue(struct ast_event *event)
Queue an event.
const char * ast_cel_get_ama_flag_name(enum ast_cel_ama_flag flag)
Convert AMA flag to printable string.
static char cel_dateformat[256]
Configured date format for event timestamps.
struct ast_party_id ani
Automatic Number Identification (ANI)
General Asterisk PBX channel definitions.
static void parse_apps(const char *val)
struct ast_party_dialed::@155 number
Dialed/Called number.
static int lid_hash(const void *obj, const int flags)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
static const char *const cel_ama_flags[AST_CEL_AMA_FLAG_TOTAL]
Map of ast_cel_ama_flags to strings.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
#define ao2_ref(o, delta)
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
uint32_t version
struct ABI version
Channel Event Userfield Used by: AST_EVENT_CEL Payload type: STR.
A set of macros to manage forward-linked lists.
hangup terminates connection
int ast_cel_linkedid_ref(const char *linkedid)
Inform CEL that a new linkedid is being used.
Channel Event CID RDNIS field Used by: AST_EVENT_CEL Payload type: STR.
static const char cel_conf_file[]
Core PBX routines and definitions.
a 3-way conference, usually part of a transfer
Event type Used by: AST_EVENT_SUB, AST_EVENT_UNSUB Payload type: UINT.
a 3-way conference, usually part of a transfer
enum ast_cel_event_type event_type
struct ast_party_dialed dialed
Dialed/Called information.
#define ast_strdupa(s)
duplicate a string in memory from the stack
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Channel Event User Event Name Used by: AST_EVENT_CEL Payload type: STR.
static void parse_events(const char *val)
const char * caller_id_rdnis
static struct ast_datastore_info fabricated_channel_datastore
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
const ast_string_field name
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
#define ao2_alloc(data_size, destructor_fn)
struct ast_datastore * ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
static void set_defaults(void)
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define ao2_find(arg1, arg2, arg3)
#define ast_channel_unlock(chan)
a 3-way conference, usually part of a transfer
static int lid_cmp(void *obj, void *arg, int flags)
struct ast_channel * ast_cel_fabricate_channel_from_event(const struct ast_event *event)
Create a fake channel from data in a CEL event.
static struct ao2_container * linkedids
Container of channel references to a linkedid for CEL purposes.
Channel Event Peer – for Things involving multiple channels, like BRIDGE Used by: AST_EVENT_CEL Paylo...
Channel Event CID ANI field Used by: AST_EVENT_CEL Payload type: STR.
int ast_event_sub_append_ie_uint(struct ast_event_sub *sub, enum ast_event_ie_type ie_type, uint32_t uint)
Append a uint parameter to a subscription.
channel exits a conference
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
const ast_string_field userfield
const char * caller_id_ani
Channel Event AMA flags Used by: AST_EVENT_CEL Payload type: UINT.
void ao2_iterator_destroy(struct ao2_iterator *i)
Destroy a container iterator.
#define AST_CEL_EVENT_RECORD_VERSION
struct ABI version
Structure used to handle boolean flags.
Support for logging to various files, console and syslog Configuration in file logger.conf.
uint32_t ast_event_get_ie_uint(const struct ast_event *event, enum ast_event_ie_type ie_type)
Get the value of an information element that has an integer payload.
const char * peer_account
enum ast_cel_event_type ast_cel_str_to_event_type(const char *name)
Get the event type from a string.
Channel Event LinkedID Used by: AST_EVENT_CEL Payload type: STR.
void ast_event_destroy(struct ast_event *event)
Destroy an event.
#define ast_channel_ref(c)
Increase channel reference count.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Standard Command Line Interface.
struct ast_event * ast_event_new(enum ast_event_type event_type,...)
Create a new event.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define ao2_container_alloc(arg1, arg2, arg3)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
A ringing phone is answered.
const ast_string_field accountcode
a user-defined event, the event name field should be set
ast_cel_event_type
CEL event types.
const char * caller_id_dnid
const char * channel_name
static struct adsi_event events[]
unsigned char valid
TRUE if the name information is valid/present.
ast_cel_ama_flag
AMA Flags.
#define CONFIG_STATUS_FILEINVALID
const char * ast_event_get_ie_str(const struct ast_event *event, enum ast_event_ie_type ie_type)
Get the value of an information element that has a string payload.
struct ast_channel * ast_dummy_channel_alloc(void)
Create a fake channel structure.
#define CEL_DEFAULT_EVENTS
Track no events by default.
static char * handle_cli_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static unsigned char cel_enabled
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
struct timeval event_time
a directed pickup was performed on this channel
unsigned char valid
TRUE if the number information is valid/present.
struct ast_event_sub * ast_event_subscribe_new(enum ast_event_type type, ast_event_cb_t cb, void *userdata)
Allocate a subscription, but do not activate it.
#define ao2_unlink(arg1, arg2)
this call was forwarded somewhere else
char exten[AST_MAX_EXTENSION]
#define AST_MUTEX_DEFINE_STATIC(mutex)
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
Channel Event AccountCode Used by: AST_EVENT_CEL Payload type: STR.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
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.
#define CONFIG_STATUS_FILEUNCHANGED
#define ast_mutex_unlock(a)
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
struct ast_party_number number
Subscriber phone number.