Sat Apr 26 2014 22:02:47

Asterisk developer's documentation


event.c File Reference

Internal generic event system. More...

#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/event.h"
#include "asterisk/linkedlists.h"
#include "asterisk/dlinkedlists.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
#include "asterisk/unaligned.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/astobj2.h"
#include "asterisk/cli.h"
Include dependency graph for event.c:

Go to the source code of this file.

Data Structures

struct  ast_ev_check_list
 Subscription event check list. More...
struct  ast_event
 An event. More...
struct  ast_event_ie
 An event information element. More...
struct  ast_event_ie_str_payload
 The payload for a string information element. More...
struct  ast_event_ie_val
struct  ast_event_ref
 A holder for an event. More...
struct  ast_event_sub
 Event subscription. More...
struct  ast_event_sub_list
 Event subscriptions The event subscribers are indexed by which event they are subscribed to. More...
struct  ie_map
 IE payload types and names. More...

Defines

#define MAX_CACHE_ARGS   8
#define NUM_CACHE_BUCKETS   563

Functions

static int _ast_event_queue (struct ast_event *event, unsigned int cache)
static struct ast_event_refalloc_event_ref (void)
int ast_event_append_eid (struct ast_event **event)
 Append the global EID IE.
int ast_event_append_ie_bitflags (struct ast_event **event, enum ast_event_ie_type ie_type, uint32_t flags)
 Append an information element that has a bitflags payload.
int ast_event_append_ie_raw (struct ast_event **event, enum ast_event_ie_type ie_type, const void *data, size_t data_len)
 Append an information element that has a raw payload.
int ast_event_append_ie_str (struct ast_event **event, enum ast_event_ie_type ie_type, const char *str)
 Append an information element that has a string payload.
int ast_event_append_ie_uint (struct ast_event **event, enum ast_event_ie_type ie_type, uint32_t data)
 Append an information element that has an integer payload.
enum ast_event_subscriber_res ast_event_check_subscriber (enum ast_event_type type,...)
 Check if subscribers exist.
static int ast_event_cmp (void *obj, void *arg, int flags)
void ast_event_destroy (struct ast_event *event)
 Destroy an event.
void ast_event_dump_cache (const struct ast_event_sub *event_sub)
 Dump the event cache for the subscribed event type.
static struct ast_eventast_event_dup (const struct ast_event *event)
struct ast_eventast_event_get_cached (enum ast_event_type type,...)
 Retrieve an event from the cache.
uint32_t ast_event_get_ie_bitflags (const struct ast_event *event, enum ast_event_ie_type ie_type)
 Get the value of an information element that has a bitflags payload.
enum ast_event_ie_pltype ast_event_get_ie_pltype (enum ast_event_ie_type ie_type)
 Get the payload type for a given information element type.
const void * ast_event_get_ie_raw (const struct ast_event *event, enum ast_event_ie_type ie_type)
 Get the value of an information element that has a raw payload.
uint16_t ast_event_get_ie_raw_payload_len (const struct ast_event *event, enum ast_event_ie_type ie_type)
 Get the length of the raw payload for a particular IE.
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.
uint32_t ast_event_get_ie_str_hash (const struct ast_event *event, enum ast_event_ie_type ie_type)
 Get the hash for the string payload of an IE.
const char * ast_event_get_ie_type_name (enum ast_event_ie_type ie_type)
 Get the string representation of an information element type.
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.
size_t ast_event_get_size (const struct ast_event *event)
 Get the size of an event.
enum ast_event_type ast_event_get_type (const struct ast_event *event)
 Get the type for an event.
const char * ast_event_get_type_name (const struct ast_event *event)
 Get the string representation of the type of the given event.
static int ast_event_hash (const void *obj, const int flags)
static int ast_event_hash_devstate (const void *obj, const int flags)
static int ast_event_hash_devstate_change (const void *obj, const int flags)
static int ast_event_hash_mwi (const void *obj, const int flags)
static int ast_event_hash_presence_state_change (const void *obj, const int flags)
static void ast_event_ie_val_destroy (struct ast_event_ie_val *ie_val)
int ast_event_init (void)
uint32_t ast_event_iterator_get_ie_bitflags (struct ast_event_iterator *iterator)
 Get the value of the current IE in the iterator as a bitflags payload.
void * ast_event_iterator_get_ie_raw (struct ast_event_iterator *iterator)
 Get the value of the current IE in the iterator instance that has a raw payload.
uint16_t ast_event_iterator_get_ie_raw_payload_len (struct ast_event_iterator *iterator)
 Get the length of the raw payload for the current IE for an iterator.
const char * ast_event_iterator_get_ie_str (struct ast_event_iterator *iterator)
 Get the value of the current IE in the iterator as a string payload.
enum ast_event_ie_type ast_event_iterator_get_ie_type (struct ast_event_iterator *iterator)
 Get the type of the current IE in the iterator instance.
uint32_t ast_event_iterator_get_ie_uint (struct ast_event_iterator *iterator)
 Get the value of the current IE in the iterator as an integer payload.
int ast_event_iterator_init (struct ast_event_iterator *iterator, const struct ast_event *event)
 Initialize an event iterator instance.
int ast_event_iterator_next (struct ast_event_iterator *iterator)
 Move iterator instance to next IE.
size_t ast_event_minimum_length (void)
 Get the minimum length of an ast_event.
struct ast_eventast_event_new (enum ast_event_type type,...)
 Create a new event.
int ast_event_queue (struct ast_event *event)
 Queue an event.
int ast_event_queue_and_cache (struct ast_event *event)
 Queue and cache an event.
static void ast_event_ref_destroy (void *obj)
void ast_event_report_subs (const struct ast_event_sub *event_sub)
 Send AST_EVENT_SUB events to this subscriber of ... subscriber events.
int ast_event_str_to_event_type (const char *str, enum ast_event_type *event_type)
 Convert a string into an event type.
int ast_event_str_to_ie_type (const char *str, enum ast_event_ie_type *ie_type)
 Convert a string to an IE type.
int ast_event_sub_activate (struct ast_event_sub *sub)
 Activate a dynamically built subscription.
int ast_event_sub_append_ie_bitflags (struct ast_event_sub *sub, enum ast_event_ie_type ie_type, uint32_t flags)
 Append a bitflags parameter to a subscription.
int ast_event_sub_append_ie_exists (struct ast_event_sub *sub, enum ast_event_ie_type ie_type)
 Append an 'exists' parameter to a subscription.
int ast_event_sub_append_ie_raw (struct ast_event_sub *sub, enum ast_event_ie_type ie_type, void *data, size_t raw_datalen)
 Append a raw parameter to a subscription.
int ast_event_sub_append_ie_str (struct ast_event_sub *sub, enum ast_event_ie_type ie_type, const char *str)
 Append a string parameter to a subscription.
int ast_event_sub_append_ie_uint (struct ast_event_sub *sub, enum ast_event_ie_type ie_type, uint32_t unsigned_int)
 Append a uint parameter to a subscription.
void ast_event_sub_destroy (struct ast_event_sub *sub)
 Destroy an allocated subscription.
struct ast_event_subast_event_subscribe (enum ast_event_type type, ast_event_cb_t cb, const char *description, void *userdata,...)
 Subscribe to events.
struct ast_event_subast_event_subscribe_new (enum ast_event_type type, ast_event_cb_t cb, void *userdata)
 Allocate a subscription, but do not activate it.
const char * ast_event_subscriber_get_description (struct ast_event_sub *sub)
 Get description for a subscription.
struct ast_event_subast_event_unsubscribe (struct ast_event_sub *sub)
 Un-subscribe from events.
static int dump_cache_cb (void *obj, void *arg, int flags)
static void dump_raw_ie (struct ast_event_iterator *i, struct ast_cli_args *a)
static char * event_dump_cache (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int event_dump_cli (void *obj, void *arg, int flags)
static void event_shutdown (void)
static void event_update_cache (struct ao2_container *cache, struct ast_event *event)
static struct ast_eventgen_sub_event (struct ast_event_sub *sub)
static int handle_event (void *data)
static int match_ie_val (const struct ast_event *event, const struct ast_event_ie_val *ie_val, const struct ast_event *event2)
static int match_sub_ie_val_to_event (const struct ast_event_ie_val *sub_ie_val, const struct ast_ev_check_list *check_ie_vals)

Variables

struct {
   enum ast_event_ie_type   cache_args [MAX_CACHE_ARGS]
 Information Elements used for caching.
   struct ao2_container *   container
 Container of cached events.
   ao2_hash_fn *   hash_fn
 Event type specific hash function.
ast_event_cache [AST_EVENT_TOTAL]
 Event types that are kept in the cache.
static struct ast_event_sub_list ast_event_subs [AST_EVENT_TOTAL]
static const char *const cached_event_types [] = { "MWI", "DeviceState", "DeviceStateChange", NULL }
 Names of cached event types, for CLI tab completion.
static struct ast_cli_entry event_cli []
static struct ast_taskprocessorevent_dispatcher
static const char *const event_names [AST_EVENT_TOTAL]
 Event Names.
static struct ie_map ie_maps [AST_EVENT_IE_TOTAL]
static uint32_t sub_uniqueid

Detailed Description

Internal generic event system.

Author:
Russell Bryant <russell@digium.com>

Definition in file event.c.


Define Documentation

#define MAX_CACHE_ARGS   8

Definition at line 153 of file event.c.

#define NUM_CACHE_BUCKETS   563

Definition at line 150 of file event.c.

Referenced by ast_event_init().


Function Documentation

static int _ast_event_queue ( struct ast_event event,
unsigned int  cache 
) [static]

Definition at line 1530 of file event.c.

References alloc_event_ref(), ao2_ref, ast_event_check_subscriber(), ast_event_destroy(), AST_EVENT_IE_END, AST_EVENT_SUB_NONE, ast_log(), ast_taskprocessor_push(), cache, ast_event_ref::cache, ast_event_ref::event, handle_event(), LOG_WARNING, and ast_event::type.

Referenced by ast_event_queue(), and ast_event_queue_and_cache().

{
   struct ast_event_ref *event_ref;
   uint16_t host_event_type;
   int res;

   host_event_type = ntohs(event->type);

   /* Invalid type */
   if (host_event_type >= AST_EVENT_TOTAL) {
      ast_log(LOG_WARNING, "Someone tried to queue an event of invalid "
         "type '%d'!\n", host_event_type);
      return -1;
   }

   /* If nobody has subscribed to this event type, throw it away now */
   if (ast_event_check_subscriber(host_event_type, AST_EVENT_IE_END)
         == AST_EVENT_SUB_NONE) {
      ast_event_destroy(event);
      return 0;
   }

   if (!(event_ref = alloc_event_ref())) {
      return -1;
   }

   event_ref->event = event;
   event_ref->cache = cache;

   res = ast_taskprocessor_push(event_dispatcher, handle_event, event_ref);
   if (res) {
      event_ref->event = NULL;
      ao2_ref(event_ref, -1);
   }
   return res;
}
static struct ast_event_ref* alloc_event_ref ( void  ) [static, read]

Definition at line 1439 of file event.c.

References ao2_alloc, and ast_event_ref_destroy().

Referenced by _ast_event_queue(), and event_update_cache().

{
   return ao2_alloc(sizeof(struct ast_event_ref), ast_event_ref_destroy);
}
int ast_event_append_eid ( struct ast_event **  event)

Append the global EID IE.

Parameters:
eventthe event to append IE to
Note:
For ast_event_new() that includes IEs, this is done automatically for you.
Return values:
0success
-1failure

Definition at line 1328 of file event.c.

References ast_eid_default, ast_event_append_ie_raw(), and AST_EVENT_IE_EID.

Referenced by ast_event_new().

int ast_event_append_ie_bitflags ( struct ast_event **  event,
enum ast_event_ie_type  ie_type,
uint32_t  bitflags 
)

Append an information element that has a bitflags payload.

Parameters:
eventthe event that the IE will be appended to
ie_typethe type of IE to append
bitflagsthe flags that are the payload of the IE
Return values:
0success
-1failure
Since:
1.8

The pointer to the event will get updated with the new location for the event that now contains the appended information element. If the re-allocation of the memory for this event fails, it will be set to NULL.

Definition at line 1189 of file event.c.

References ast_event_append_ie_raw().

Referenced by ast_event_get_cached(), ast_event_new(), and gen_sub_event().

{
   flags = htonl(flags);
   return ast_event_append_ie_raw(event, ie_type, &flags, sizeof(flags));
}
int ast_event_append_ie_raw ( struct ast_event **  event,
enum ast_event_ie_type  ie_type,
const void *  data,
size_t  data_len 
)

Append an information element that has a raw payload.

Parameters:
eventthe event that the IE will be appended to
ie_typethe type of IE to append
dataA pointer to the raw data for the payload of the IE
data_lenThe amount of data to copy into the payload
Return values:
0success
-1failure

The pointer to the event will get updated with the new location for the event that now contains the appended information element. If the re-allocation of the memory for this event fails, it will be set to NULL.

Definition at line 1196 of file event.c.

References ast_free, ast_realloc, ast_event::event_len, ast_event_ie::ie_payload, ast_event_ie::ie_payload_len, and ast_event_ie::ie_type.

Referenced by ast_event_append_eid(), ast_event_append_ie_bitflags(), ast_event_append_ie_str(), ast_event_append_ie_uint(), ast_event_get_cached(), ast_event_new(), and gen_sub_event().

{
   struct ast_event_ie *ie;
   struct ast_event *old_event;
   unsigned int extra_len;
   uint16_t event_len;

   event_len = ntohs((*event)->event_len);
   extra_len = sizeof(*ie) + data_len;

   old_event = *event;
   *event = ast_realloc(*event, event_len + extra_len);
   if (!*event) {
      ast_free(old_event);
      return -1;
   }

   ie = (struct ast_event_ie *) ( ((char *) *event) + event_len );
   ie->ie_type = htons(ie_type);
   ie->ie_payload_len = htons(data_len);
   memcpy(ie->ie_payload, data, data_len);

   (*event)->event_len = htons(event_len + extra_len);

   return 0;
}
int ast_event_append_ie_str ( struct ast_event **  event,
enum ast_event_ie_type  ie_type,
const char *  str 
)

Append an information element that has a string payload.

Parameters:
eventthe event that the IE will be appended to
ie_typethe type of IE to append
strThe string for the payload of the IE
Return values:
0success
-1failure

The pointer to the event will get updated with the new location for the event that now contains the appended information element. If the re-allocation of the memory for this event fails, it will be set to NULL.

Definition at line 1161 of file event.c.

References ast_alloca, ast_event_append_ie_raw(), AST_EVENT_IE_DEVICE, ast_str_hash(), ast_tech_to_upper(), ast_event_ie_str_payload::hash, and ast_event_ie_str_payload::str.

Referenced by add_ie(), add_ip_ie(), add_timeval_ie(), ast_event_get_cached(), ast_event_new(), and gen_sub_event().

{
   struct ast_event_ie_str_payload *str_payload;
   size_t payload_len;

   payload_len = sizeof(*str_payload) + strlen(str);
   str_payload = ast_alloca(payload_len);

   strcpy(str_payload->str, str);
   if (ie_type == AST_EVENT_IE_DEVICE) {
      char *uppertech = ast_strdupa(str);
      ast_tech_to_upper(uppertech);
      str_payload->hash = ast_str_hash(uppertech);
   } else {
      str_payload->hash = ast_str_hash(str);
   }

   return ast_event_append_ie_raw(event, ie_type, str_payload, payload_len);
}
int ast_event_append_ie_uint ( struct ast_event **  event,
enum ast_event_ie_type  ie_type,
uint32_t  data 
)

Append an information element that has an integer payload.

Parameters:
eventthe event that the IE will be appended to
ie_typethe type of IE to append
dataThe integer for the payload of the IE
Return values:
0success
-1failure

The pointer to the event will get updated with the new location for the event that now contains the appended information element. If the re-allocation of the memory for this event fails, it will be set to NULL.

Definition at line 1182 of file event.c.

References ast_event_append_ie_raw().

Referenced by add_ie(), ast_event_get_cached(), ast_event_new(), and gen_sub_event().

{
   data = htonl(data);
   return ast_event_append_ie_raw(event, ie_type, &data, sizeof(data));
}

Check if subscribers exist.

Parameters:
event_typeThis is the type of event that the caller would like to check for subscribers to.

The rest of the arguments to this function specify additional parameters for checking for subscriptions to subsets of an event type. The arguments must in sets of:

    <enum ast_event_ie_type>, [enum ast_event_ie_pltype, [payload] ]

and must end with AST_EVENT_IE_END.

If the ie_type specified is *not* AST_EVENT_IE_END, then it must be followed by a valid IE payload type. If the payload type specified is AST_EVENT_IE_PLTYPE_EXISTS, then the 3rd argument should not be provided. Otherwise, a payload must also be specified.

Returns:
This returns one of the values defined in the ast_event_subscriber_res enum which will indicate if subscribers exist that match the given criteria.

Example usage:

This example will check if there are any subscribers to MWI events for the mailbox defined in the "mailbox" variable.

Definition at line 466 of file event.c.

References ARRAY_LEN, ast_alloca, AST_EVENT_ALL, AST_EVENT_IE_END, AST_EVENT_IE_PLTYPE_BITFLAGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_PLTYPE_RAW, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_IE_PLTYPE_UNKNOWN, AST_EVENT_SUB_EXISTS, AST_EVENT_SUB_NONE, ast_event_subs, AST_LIST_HEAD_NOLOCK_INIT_VALUE, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_log(), AST_RWDLLIST_RDLOCK, AST_RWDLLIST_TRAVERSE, AST_RWDLLIST_UNLOCK, AST_RWLIST_FIRST, event_types, ast_event_ie_val::ie_pltype, ast_event_ie_val::ie_type, ast_event_sub::ie_vals, ast_ev_check_list::ie_vals, LOG_ERROR, LOG_WARNING, match_sub_ie_val_to_event(), ast_event_ie_val::payload, ast_event_ie_val::raw, ast_event_ie_val::raw_datalen, ast_event_ie_val::str, sub, ast_event_sub::type, and ast_event_ie_val::uint.

Referenced by _ast_event_queue(), ast_event_sub_activate(), and ast_event_unsubscribe().

{
   va_list ap;
   enum ast_event_ie_type ie_type;
   enum ast_event_subscriber_res res = AST_EVENT_SUB_NONE;
   struct ast_event_ie_val *ie_val;
   struct ast_event_sub *sub;
   struct ast_ev_check_list check_ie_vals = {
      .ie_vals = AST_LIST_HEAD_NOLOCK_INIT_VALUE
   };
   const enum ast_event_type event_types[] = { type, AST_EVENT_ALL };
   int i;
   int want_specific_event;/* TRUE if looking for subscribers wanting specific parameters. */

   if (type >= AST_EVENT_TOTAL) {
      ast_log(LOG_ERROR, "%u is an invalid type!\n", type);
      return res;
   }

   want_specific_event = 0;
   va_start(ap, type);
   for (ie_type = va_arg(ap, enum ast_event_ie_type);
      ie_type != AST_EVENT_IE_END;
      ie_type = va_arg(ap, enum ast_event_ie_type))
   {
      struct ast_event_ie_val *ie_value = ast_alloca(sizeof(*ie_value));
      int insert = 0;

      memset(ie_value, 0, sizeof(*ie_value));
      ie_value->ie_type = ie_type;
      ie_value->ie_pltype = va_arg(ap, enum ast_event_ie_pltype);
      switch (ie_value->ie_pltype) {
      case AST_EVENT_IE_PLTYPE_UINT:
         ie_value->payload.uint = va_arg(ap, uint32_t);
         insert = 1;
         break;
      case AST_EVENT_IE_PLTYPE_BITFLAGS:
         ie_value->payload.uint = va_arg(ap, uint32_t);
         insert = 1;
         break;
      case AST_EVENT_IE_PLTYPE_STR:
         ie_value->payload.str = va_arg(ap, const char *);
         insert = 1;
         break;
      case AST_EVENT_IE_PLTYPE_RAW:
      {
         void *data = va_arg(ap, void *);
         size_t datalen = va_arg(ap, size_t);

         ie_value->payload.raw = ast_alloca(datalen);
         memcpy(ie_value->payload.raw, data, datalen);
         ie_value->raw_datalen = datalen;
         insert = 1;
         break;
      }
      case AST_EVENT_IE_PLTYPE_UNKNOWN:
      case AST_EVENT_IE_PLTYPE_EXISTS:
         /* Unsupported payload type. */
         break;
      }

      if (insert) {
         want_specific_event = 1;
         AST_LIST_INSERT_TAIL(&check_ie_vals.ie_vals, ie_value, entry);
      } else {
         ast_log(LOG_WARNING, "Unsupported PLTYPE(%d)\n", ie_value->ie_pltype);
      }
   }
   va_end(ap);

   for (i = 0; i < ARRAY_LEN(event_types); i++) {
      AST_RWDLLIST_RDLOCK(&ast_event_subs[event_types[i]]);
      if (want_specific_event) {
         AST_RWDLLIST_TRAVERSE(&ast_event_subs[event_types[i]], sub, entry) {
            AST_LIST_TRAVERSE(&sub->ie_vals, ie_val, entry) {
               if (!match_sub_ie_val_to_event(ie_val, &check_ie_vals)) {
                  /* The current subscription ie did not match an event ie. */
                  break;
               }
            }
            if (!ie_val) {
               /* Everything matched.  A subscriber is looking for this event. */
               break;
            }
         }
      } else {
         /* Just looking to see if there are ANY subscribers to the event type. */
         sub = AST_RWLIST_FIRST(&ast_event_subs[event_types[i]]);
      }
      AST_RWDLLIST_UNLOCK(&ast_event_subs[event_types[i]]);
      if (sub) {
         break;
      }
   }

   return sub ? AST_EVENT_SUB_EXISTS : AST_EVENT_SUB_NONE;
}
static int ast_event_cmp ( void *  obj,
void *  arg,
int  flags 
) [static]

Definition at line 1668 of file event.c.

References ARRAY_LEN, ast_event_cache, ast_event_get_ie_pltype(), ast_event_get_type(), cache_args, CMP_MATCH, ast_event_ref::event, ast_event_ie_val::ie_pltype, and match_ie_val().

Referenced by ast_event_init(), and event_update_cache().

{
   struct ast_event_ref *event_ref, *event_ref2;
   struct ast_event *event, *event2;
   int res = CMP_MATCH;
   int i;
   enum ast_event_ie_type *cache_args;

   event_ref = obj;
   event = event_ref->event;

   event_ref2 = arg;
   event2 = event_ref2->event;

   cache_args = ast_event_cache[ast_event_get_type(event)].cache_args;

   for (i = 0; i < ARRAY_LEN(ast_event_cache[0].cache_args) && cache_args[i]; i++) {
      struct ast_event_ie_val ie_val = {
         .ie_pltype = ast_event_get_ie_pltype(cache_args[i]),
         .ie_type = cache_args[i],
      };

      if (!match_ie_val(event, &ie_val, event2)) {
         res = 0;
         break;
      }
   }

   return res;
}
void ast_event_destroy ( struct ast_event event)

Destroy an event.

Parameters:
eventthe event to destroy
Returns:
Nothing
Note:
Events that have been queued should *not* be destroyed by the code that created the event. It will be automatically destroyed after being dispatched to the appropriate subscribers.

Definition at line 1334 of file event.c.

References ast_free.

Referenced by _ast_event_queue(), ast_cel_report_event(), ast_event_get_cached(), ast_event_ref_destroy(), ast_event_report_subs(), ast_event_sub_activate(), ast_event_unsubscribe(), devstate_cached(), event_update_cache(), get_cached_mwi(), handle_security_event(), has_voicemail(), presence_state_cached(), process_collection(), push_acl_change_event(), sig_pri_mwi_cache_update(), stun_monitor_request(), unistim_send_mwi_to_peer(), and update_registry().

{
   ast_free(event);
}
void ast_event_dump_cache ( const struct ast_event_sub event_sub)

Dump the event cache for the subscribed event type.

Dump the event cache for the subscriber.

Definition at line 672 of file event.c.

References ao2_callback, ast_event_cache, dump_cache_cb(), OBJ_NODATA, and ast_event_sub::type.

Referenced by aji_init_event_distribution(), cpg_confchg_cb(), handle_devstate_change(), and xmpp_init_event_distribution().

{
   if (!ast_event_cache[event_sub->type].container) {
      return;
   }

   ao2_callback(ast_event_cache[event_sub->type].container, OBJ_NODATA,
         dump_cache_cb, (void *) event_sub);
}
static struct ast_event* ast_event_dup ( const struct ast_event event) [static, read]

Definition at line 1346 of file event.c.

References ast_calloc, ast_event_get_size(), and ast_event::event_len.

Referenced by ast_event_get_cached(), and event_update_cache().

{
   struct ast_event *dup_event;
   uint16_t event_len;

   event_len = ast_event_get_size(event);

   if (!(dup_event = ast_calloc(1, event_len))) {
      return NULL;
   }

   memcpy(dup_event, event, event_len);

   return dup_event;
}
struct ast_event* ast_event_get_cached ( enum  ast_event_type,
  ... 
) [read]

Retrieve an event from the cache.

Parameters:
ast_event_typeThe type of event to retrieve from the cache

The rest of the arguments to this function specify information elements to match for retrieving events from the cache. They are specified in the form:

and must end with AST_EVENT_IE_END.

If the ie_type specified is *not* AST_EVENT_IE_END, then it must be followed by a valid IE payload type. If the payload type specified is AST_EVENT_IE_PLTYPE_EXISTS, then the 3rd argument should not be provided. Otherwise, a payload must also be specified.

Returns:
A reference to an event retrieved from the cache. If no event was found that matches the specified criteria, then NULL will be returned.
Note:
If more than one event in the cache matches the specified criteria, only one will be returned, and it is undefined which one it will be.
The caller of this function *must* call ast_event_destroy() on the returned event after it is done using it.

Example Usage:

This example will check for an MWI event in the cache that matches the specified mailbox. This would be the way to find out the last known state of a mailbox without having to poll the mailbox directly.

Definition at line 1362 of file event.c.

References ao2_find, ao2_ref, ast_event_append_ie_bitflags(), ast_event_append_ie_raw(), ast_event_append_ie_str(), ast_event_append_ie_uint(), ast_event_cache, ast_event_destroy(), ast_event_dup(), AST_EVENT_IE_END, AST_EVENT_IE_PLTYPE_BITFLAGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_PLTYPE_RAW, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_IE_PLTYPE_UNKNOWN, ast_event_new(), ast_log(), container, ast_event_ref::event, LOG_ERROR, LOG_WARNING, and OBJ_POINTER.

Referenced by devstate_cached(), get_cached_mwi(), has_voicemail(), presence_state_cached(), process_collection(), sig_pri_mwi_cache_update(), unistim_send_mwi_to_peer(), and update_registry().

{
   va_list ap;
   enum ast_event_ie_type ie_type;
   struct ast_event *dup_event = NULL;
   struct ast_event_ref *cached_event_ref;
   struct ast_event *cache_arg_event;
   struct ast_event_ref tmp_event_ref = {
      .event = NULL,
   };
   struct ao2_container *container = NULL;

   if (type >= AST_EVENT_TOTAL) {
      ast_log(LOG_ERROR, "%u is an invalid type!\n", type);
      return NULL;
   }

   if (!(container = ast_event_cache[type].container)) {
      ast_log(LOG_ERROR, "%u is not a cached event type\n", type);
      return NULL;
   }

   if (!(cache_arg_event = ast_event_new(type, AST_EVENT_IE_END))) {
      return NULL;
   }

   va_start(ap, type);
   for (ie_type = va_arg(ap, enum ast_event_ie_type);
      ie_type != AST_EVENT_IE_END;
      ie_type = va_arg(ap, enum ast_event_ie_type))
   {
      enum ast_event_ie_pltype ie_pltype;

      ie_pltype = va_arg(ap, enum ast_event_ie_pltype);

      switch (ie_pltype) {
      case AST_EVENT_IE_PLTYPE_UINT:
         ast_event_append_ie_uint(&cache_arg_event, ie_type, va_arg(ap, uint32_t));
         break;
      case AST_EVENT_IE_PLTYPE_BITFLAGS:
         ast_event_append_ie_bitflags(&cache_arg_event, ie_type, va_arg(ap, uint32_t));
         break;
      case AST_EVENT_IE_PLTYPE_STR:
         ast_event_append_ie_str(&cache_arg_event, ie_type, va_arg(ap, const char *));
         break;
      case AST_EVENT_IE_PLTYPE_RAW:
      {
         void *data = va_arg(ap, void *);
         size_t datalen = va_arg(ap, size_t);
         ast_event_append_ie_raw(&cache_arg_event, ie_type, data, datalen);
         break;
      }
      case AST_EVENT_IE_PLTYPE_EXISTS:
         ast_log(LOG_WARNING, "PLTYPE_EXISTS not supported by this function\n");
         break;
      case AST_EVENT_IE_PLTYPE_UNKNOWN:
         break;
      }
   }
   va_end(ap);

   tmp_event_ref.event = cache_arg_event;

   cached_event_ref = ao2_find(container, &tmp_event_ref, OBJ_POINTER);

   ast_event_destroy(cache_arg_event);
   cache_arg_event = NULL;

   if (cached_event_ref) {
      dup_event = ast_event_dup(cached_event_ref->event);
      ao2_ref(cached_event_ref, -1);
      cached_event_ref = NULL;
   }

   return dup_event;
}
uint32_t ast_event_get_ie_bitflags ( const struct ast_event event,
enum ast_event_ie_type  ie_type 
)

Get the value of an information element that has a bitflags payload.

Parameters:
eventThe event to get the IE from
ie_typethe type of information element to retrieve
Returns:
This returns the payload of the information element with the given type. However, an IE with a payload of 0, and the case where no IE is found yield the same return value.

Definition at line 1106 of file event.c.

References ast_event_get_ie_raw(), and get_unaligned_uint32().

Referenced by append_ie(), and match_ie_val().

{
   const uint32_t *ie_val;

   ie_val = ast_event_get_ie_raw(event, ie_type);

   return ie_val ? ntohl(get_unaligned_uint32(ie_val)) : 0;
}

Get the payload type for a given information element type.

Parameters:
ie_typethe information element type to get the payload type of
Returns:
the payload type for the provided IE type
Since:
1.6.1

Definition at line 332 of file event.c.

References ARRAY_LEN, AST_EVENT_IE_PLTYPE_UNKNOWN, ast_log(), ie_maps, ie_map::ie_pltype, and LOG_ERROR.

Referenced by append_ie(), ast_event_cmp(), and event_dump_cli().

{
   if (ie_type <= 0 || ie_type >= ARRAY_LEN(ie_maps)) {
      ast_log(LOG_ERROR, "Invalid IE type - '%d'\n", ie_type);
      return AST_EVENT_IE_PLTYPE_UNKNOWN;
   }

   return ie_maps[ie_type].ie_pltype;
}
const void* ast_event_get_ie_raw ( const struct ast_event event,
enum ast_event_ie_type  ie_type 
)

Get the value of an information element that has a raw payload.

Parameters:
eventThe event to get the IE from
ie_typethe type of information element to retrieve
Returns:
This returns the payload of the information element with the given type. If the information element isn't found, NULL will be returned.

Definition at line 1133 of file event.c.

References ast_event_iterator_get_ie_raw(), ast_event_iterator_get_ie_type(), ast_event_iterator_init(), and ast_event_iterator_next().

Referenced by aji_devstate_cb(), aji_mwi_cb(), ast_event_cb(), ast_event_get_ie_bitflags(), ast_event_get_ie_str(), ast_event_get_ie_str_hash(), ast_event_get_ie_uint(), ast_event_new(), cpg_deliver_cb(), devstate_cache_cb(), devstate_change_collector_cb(), ie_is_present(), match_ie_val(), xmpp_pubsub_devstate_cb(), and xmpp_pubsub_mwi_cb().

{
   struct ast_event_iterator iterator;
   int res;

   for (res = ast_event_iterator_init(&iterator, event); !res; res = ast_event_iterator_next(&iterator)) {
      if (ast_event_iterator_get_ie_type(&iterator) == ie_type) {
         return ast_event_iterator_get_ie_raw(&iterator);
      }
   }

   return NULL;
}
uint16_t ast_event_get_ie_raw_payload_len ( const struct ast_event event,
enum ast_event_ie_type  ie_type 
)

Get the length of the raw payload for a particular IE.

Parameters:
eventThe event to get the IE payload length from
ie_typethe type of information element to get the length of
Returns:
If an IE of type ie_type is found, its payload length is returned. Otherwise, 0 is returned.

Definition at line 1147 of file event.c.

References ast_event_iterator_get_ie_raw_payload_len(), ast_event_iterator_get_ie_type(), ast_event_iterator_init(), and ast_event_iterator_next().

Referenced by match_ie_val().

{
   struct ast_event_iterator iterator;
   int res;

   for (res = ast_event_iterator_init(&iterator, event); !res; res = ast_event_iterator_next(&iterator)) {
      if (ast_event_iterator_get_ie_type(&iterator) == ie_type) {
         return ast_event_iterator_get_ie_raw_payload_len(&iterator);
      }
   }

   return 0;
}
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.

Parameters:
eventThe event to get the IE from
ie_typethe type of information element to retrieve
Returns:
This returns the payload of the information element with the given type. If the information element isn't found, NULL will be returned.

Definition at line 1124 of file event.c.

References ast_event_get_ie_raw(), and ast_event_ie_str_payload::str.

Referenced by aji_devstate_cb(), aji_mwi_cb(), append_ie(), ast_cel_fill_record(), ast_event_hash_devstate(), ast_event_hash_devstate_change(), ast_event_hash_mwi(), ast_event_hash_presence_state_change(), device_state_cb(), devstate_change_collector_cb(), generic_monitor_devstate_cb(), match_ie_val(), mwi_sub_event_cb(), presence_state_cached(), presence_state_cb(), print_cel_sub(), sig_pri_mwi_event_cb(), xmpp_pubsub_devstate_cb(), and xmpp_pubsub_mwi_cb().

{
   const struct ast_event_ie_str_payload *str_payload;

   str_payload = ast_event_get_ie_raw(event, ie_type);

   return str_payload ? str_payload->str : NULL;
}
uint32_t ast_event_get_ie_str_hash ( const struct ast_event event,
enum ast_event_ie_type  ie_type 
)

Get the hash for the string payload of an IE.

Parameters:
eventThe event to get the IE from
ie_typethe type of information element to retrieve the hash for
Returns:
This function returns the hash value as calculated by ast_str_hash() for the string payload. This is stored in the event to avoid unnecessary string comparisons.

Definition at line 1115 of file event.c.

References ast_event_get_ie_raw(), and ast_event_ie_str_payload::hash.

Referenced by match_ie_val().

{
   const struct ast_event_ie_str_payload *str_payload;

   str_payload = ast_event_get_ie_raw(event, ie_type);

   return str_payload ? str_payload->hash : 0;
}
const char* ast_event_get_ie_type_name ( enum ast_event_ie_type  ie_type)

Get the string representation of an information element type.

Parameters:
ie_typethe information element type to get the string representation of
Returns:
the string representation of the information element type
Since:
1.6.1

Definition at line 322 of file event.c.

References ARRAY_LEN, ast_log(), ie_maps, LOG_ERROR, and ie_map::name.

Referenced by append_ie(), dump_raw_ie(), event_dump_cache(), event_dump_cli(), and security_event_cb().

{
   if (ie_type <= 0 || ie_type >= ARRAY_LEN(ie_maps)) {
      ast_log(LOG_ERROR, "Invalid IE type - '%d'\n", ie_type);
      return "";
   }

   return ie_maps[ie_type].name;
}
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.

Parameters:
eventThe event to get the IE from
ie_typethe type of information element to retrieve
Returns:
This returns the payload of the information element with the given type. However, an IE with a payload of 0, and the case where no IE is found yield the same return value.

Definition at line 1097 of file event.c.

References ast_event_get_ie_raw(), and get_unaligned_uint32().

Referenced by aji_devstate_cb(), aji_mwi_cb(), append_ie(), ast_cel_fill_record(), device_state_cb(), devstate_cache_cb(), devstate_cached(), devstate_change_collector_cb(), generic_agent_devstate_cb(), generic_monitor_devstate_cb(), get_cached_mwi(), has_voicemail(), match_ie_val(), mwi_event_cb(), mwi_sub_event_cb(), mwi_unsub_event_cb(), presence_state_cached(), presence_state_cb(), process_collection(), security_event_cb(), sig_pri_mwi_cache_update(), sig_pri_mwi_event_cb(), unistim_send_mwi_to_peer(), update_registry(), xmpp_pubsub_devstate_cb(), and xmpp_pubsub_mwi_cb().

{
   const uint32_t *ie_val;

   ie_val = ast_event_get_ie_raw(event, ie_type);

   return ie_val ? ntohl(get_unaligned_uint32(ie_val)) : 0;
}
size_t ast_event_get_size ( const struct ast_event event)

Get the size of an event.

Parameters:
eventthe event to get the size of
Returns:
the number of bytes contained in the event
Since:
1.6.1

Definition at line 358 of file event.c.

References ast_event::event_len.

Referenced by ast_event_cb(), ast_event_dup(), and ast_event_iterator_init().

{
   size_t res;

   res = ntohs(event->event_len);

   return res;
}
enum ast_event_type ast_event_get_type ( const struct ast_event event)

Get the type for an event.

Parameters:
eventthe event to get the type for
Returns:
the event type as represented by one of the values in the ast_event_type enum

Definition at line 1092 of file event.c.

References ast_event::type.

Referenced by ast_event_cb(), ast_event_cmp(), ast_event_get_type_name(), ast_event_hash(), cpg_deliver_cb(), handle_event(), mwi_sub_event_cb(), and mwi_unsub_event_cb().

{
   return ntohs(event->type);
}
const char* ast_event_get_type_name ( const struct ast_event event)

Get the string representation of the type of the given event.

  • event the event to get the type of
Returns:
the string representation of the event type of the provided event
Since:
1.6.1

Definition at line 292 of file event.c.

References ARRAY_LEN, ast_event_get_type(), ast_log(), event_names, LOG_ERROR, and ast_event_sub::type.

Referenced by event_dump_cli().

{
   enum ast_event_type type;

   type = ast_event_get_type(event);

   if (type < 0 || type >= ARRAY_LEN(event_names)) {
      ast_log(LOG_ERROR, "Invalid event type - '%d'\n", type);
      return "";
   }

   return event_names[type];
}
static int ast_event_hash ( const void *  obj,
const int  flags 
) [static]

Definition at line 1634 of file event.c.

References ast_event_cache, ast_event_get_type(), ast_event_ref::event, and hash_fn.

Referenced by ast_event_init().

{
   const struct ast_event_ref *event_ref;
   const struct ast_event *event;
   ao2_hash_fn *hash_fn;

   event_ref = obj;
   event = event_ref->event;

   if (!(hash_fn = ast_event_cache[ast_event_get_type(event)].hash_fn)) {
      return 0;
   }

   return hash_fn(event, flags);
}
static int ast_event_hash_devstate ( const void *  obj,
const int  flags 
) [static]

Definition at line 1595 of file event.c.

References ast_event_get_ie_str(), AST_EVENT_IE_DEVICE, and ast_str_hash().

{
   const struct ast_event *event = obj;

   return ast_str_hash(ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE));
}
static int ast_event_hash_devstate_change ( const void *  obj,
const int  flags 
) [static]

Definition at line 1611 of file event.c.

References ast_event_get_ie_str(), AST_EVENT_IE_DEVICE, and ast_str_hash().

{
   const struct ast_event *event = obj;

   return ast_str_hash(ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE));
}
static int ast_event_hash_mwi ( const void *  obj,
const int  flags 
) [static]

Definition at line 1577 of file event.c.

References ast_event_get_ie_str(), AST_EVENT_IE_CONTEXT, AST_EVENT_IE_MAILBOX, ast_str_hash(), ast_str_hash_add(), context, and mailbox.

{
   const struct ast_event *event = obj;
   const char *mailbox = ast_event_get_ie_str(event, AST_EVENT_IE_MAILBOX);
   const char *context = ast_event_get_ie_str(event, AST_EVENT_IE_CONTEXT);

   return ast_str_hash_add(context, ast_str_hash(mailbox));
}
static int ast_event_hash_presence_state_change ( const void *  obj,
const int  flags 
) [static]

Definition at line 1627 of file event.c.

References ast_event_get_ie_str(), AST_EVENT_IE_PRESENCE_PROVIDER, and ast_str_hash().

{
   const struct ast_event *event = obj;

   return ast_str_hash(ast_event_get_ie_str(event, AST_EVENT_IE_PRESENCE_PROVIDER));
}
int ast_event_init ( void  )

Provided by event.c

Definition at line 1859 of file event.c.

References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_event_cache, ast_event_cmp(), ast_event_hash(), ast_event_subs, AST_EVENT_TOTAL, ast_register_atexit(), AST_RWDLLIST_HEAD_INIT, ast_taskprocessor_get(), container, event_cli, event_shutdown(), hash_fn, and NUM_CACHE_BUCKETS.

Referenced by main().

{
   int i;

   for (i = 0; i < AST_EVENT_TOTAL; i++) {
      AST_RWDLLIST_HEAD_INIT(&ast_event_subs[i]);
   }

   for (i = 0; i < AST_EVENT_TOTAL; i++) {
      if (!ast_event_cache[i].hash_fn) {
         /* This event type is not cached. */
         continue;
      }

      if (!(ast_event_cache[i].container = ao2_container_alloc(NUM_CACHE_BUCKETS,
            ast_event_hash, ast_event_cmp))) {
         goto event_init_cleanup;
      }
   }

   if (!(event_dispatcher = ast_taskprocessor_get("core_event_dispatcher", 0))) {
      goto event_init_cleanup;
   }

   ast_cli_register_multiple(event_cli, ARRAY_LEN(event_cli));

   ast_register_atexit(event_shutdown);

   return 0;

event_init_cleanup:
   event_shutdown();
   return -1;
}
uint32_t ast_event_iterator_get_ie_bitflags ( struct ast_event_iterator iterator)

Get the value of the current IE in the iterator as a bitflags payload.

Parameters:
iteratorThe iterator instance
Returns:
This returns the payload of the information element as bitflags.

Definition at line 1068 of file event.c.

References get_unaligned_uint32(), ast_event_iterator::ie, and ast_event_ie::ie_payload.

Referenced by event_dump_cli().

{
   return ntohl(get_unaligned_uint32(iterator->ie->ie_payload));
}
void* ast_event_iterator_get_ie_raw ( struct ast_event_iterator iterator)

Get the value of the current IE in the iterator instance that has a raw payload.

Parameters:
iteratorThe iterator instance
Returns:
This returns the payload of the information element as type raw.

Definition at line 1082 of file event.c.

References ast_event_iterator::ie, and ast_event_ie::ie_payload.

Referenced by ast_event_get_ie_raw(), and dump_raw_ie().

{
   return iterator->ie->ie_payload;
}

Get the length of the raw payload for the current IE for an iterator.

Parameters:
iteratorThe IE iterator
Returns:
The payload length of the current IE

Definition at line 1087 of file event.c.

References ast_event_iterator::ie, and ast_event_ie::ie_payload_len.

Referenced by ast_event_get_ie_raw_payload_len().

{
   return ntohs(iterator->ie->ie_payload_len);
}
const char* ast_event_iterator_get_ie_str ( struct ast_event_iterator iterator)

Get the value of the current IE in the iterator as a string payload.

Parameters:
iteratorThe iterator instance
Returns:
This returns the payload of the information element as a string.

Definition at line 1073 of file event.c.

References ast_event_iterator::ie, ast_event_ie::ie_payload, and ast_event_ie_str_payload::str.

Referenced by event_dump_cli().

{
   const struct ast_event_ie_str_payload *str_payload;

   str_payload = (struct ast_event_ie_str_payload *) iterator->ie->ie_payload;

   return str_payload ? str_payload->str : NULL;
}

Get the type of the current IE in the iterator instance.

Parameters:
iteratorThe iterator instance
Returns:
the ie type as represented by one of the value sin the ast_event_ie_type enum

Definition at line 1058 of file event.c.

References ast_event_iterator::ie, and ast_event_ie::ie_type.

Referenced by ast_event_get_ie_raw(), ast_event_get_ie_raw_payload_len(), dump_raw_ie(), and event_dump_cli().

{
   return ntohs(iterator->ie->ie_type);
}
uint32_t ast_event_iterator_get_ie_uint ( struct ast_event_iterator iterator)

Get the value of the current IE in the iterator as an integer payload.

Parameters:
iteratorThe iterator instance
Returns:
This returns the payload of the information element as a uint.

Definition at line 1063 of file event.c.

References get_unaligned_uint32(), ast_event_iterator::ie, and ast_event_ie::ie_payload.

Referenced by event_dump_cli().

{
   return ntohl(get_unaligned_uint32(iterator->ie->ie_payload));
}
int ast_event_iterator_init ( struct ast_event_iterator iterator,
const struct ast_event event 
)

Initialize an event iterator instance.

Parameters:
iteratorThe iterator instance to initialize
eventThe event that will be iterated through
Return values:
0Success, there are IEs available to iterate
-1Failure, there are no IEs in the event to iterate

Definition at line 1036 of file event.c.

References ast_event_get_size(), ast_event_iterator::event, ast_event_iterator::event_len, and ast_event_iterator::ie.

Referenced by ast_event_get_ie_raw(), ast_event_get_ie_raw_payload_len(), and event_dump_cli().

{
   int res = 0;

   iterator->event_len = ast_event_get_size(event);
   iterator->event = event;
   if (iterator->event_len >= sizeof(*event) + sizeof(struct ast_event_ie)) {
      iterator->ie = (struct ast_event_ie *) ( ((char *) event) + sizeof(*event) );
   } else {
      iterator->ie = NULL;
      res = -1;
   }

   return res;
}
int ast_event_iterator_next ( struct ast_event_iterator iterator)

Move iterator instance to next IE.

Parameters:
iteratorThe iterator instance
Return values:
0on success
-1if end is reached

Definition at line 1052 of file event.c.

References ast_event_iterator::event, ast_event_iterator::event_len, ast_event_iterator::ie, and ast_event_ie::ie_payload_len.

Referenced by ast_event_get_ie_raw(), ast_event_get_ie_raw_payload_len(), and event_dump_cli().

{
   iterator->ie = (struct ast_event_ie *) ( ((char *) iterator->ie) + sizeof(*iterator->ie) + ntohs(iterator->ie->ie_payload_len));
   return ((iterator->event_len <= (((char *) iterator->ie) - ((char *) iterator->event))) ? -1 : 0);
}
size_t ast_event_minimum_length ( void  )

Get the minimum length of an ast_event.

Returns:
minimum amount of memory that will be consumed by any ast_event.

Definition at line 1894 of file event.c.

Referenced by cpg_deliver_cb().

{
   return sizeof(struct ast_event);
}
struct ast_event* ast_event_new ( enum ast_event_type  event_type,
  ... 
) [read]

Create a new event.

Parameters:
event_typeThe type of event to create

The rest of the arguments to this function specify information elements to add to the event. They are specified in the form:

and must end with AST_EVENT_IE_END.

If the ie_type specified is *not* AST_EVENT_IE_END, then it must be followed by a valid IE payload type. The payload type, EXISTS, should not be used here because it makes no sense to do so. So, a payload must also be specified after the IE payload type.

Note:
The EID IE will be appended automatically when this function is used with at least one IE specified.
Returns:
This returns the event that has been created. If there is an error creating the event, NULL will be returned.

Example usage:

This creates a MWI event with 3 information elements, a mailbox which is a string, and the number of new and old messages, specified as integers.

Definition at line 1224 of file event.c.

References ast_alloca, ast_calloc, ast_event_append_eid(), ast_event_append_ie_bitflags(), ast_event_append_ie_raw(), ast_event_append_ie_str(), ast_event_append_ie_uint(), ast_event_get_ie_raw(), AST_EVENT_IE_EID, AST_EVENT_IE_END, AST_EVENT_IE_PLTYPE_BITFLAGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_PLTYPE_RAW, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_IE_PLTYPE_UNKNOWN, AST_LIST_HEAD_NOLOCK_STATIC, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_log(), ast_event_ie_val::ie_pltype, ast_event_ie_val::ie_type, LOG_WARNING, ast_event_ie_val::payload, ast_event_ie_val::raw, ast_event_ie_val::raw_datalen, ast_event_ie_val::str, and ast_event_ie_val::uint.

Referenced by aji_handle_pubsub_event(), alloc_event(), ast_cel_report_event(), ast_event_get_cached(), ast_event_unsubscribe(), corosync_ping(), devstate_event(), gen_sub_event(), handle_request_notify(), notify_message(), presence_state_event(), process_collection(), push_acl_change_event(), queue_mwi_event(), stun_monitor_request(), and xmpp_pubsub_handle_event().

{
   va_list ap;
   struct ast_event *event;
   enum ast_event_ie_type ie_type;
   struct ast_event_ie_val *ie_val;
   AST_LIST_HEAD_NOLOCK_STATIC(ie_vals, ast_event_ie_val);

   /* Invalid type */
   if (type >= AST_EVENT_TOTAL) {
      ast_log(LOG_WARNING, "Someone tried to create an event of invalid "
         "type '%d'!\n", type);
      return NULL;
   }

   va_start(ap, type);
   for (ie_type = va_arg(ap, enum ast_event_ie_type);
      ie_type != AST_EVENT_IE_END;
      ie_type = va_arg(ap, enum ast_event_ie_type))
   {
      struct ast_event_ie_val *ie_value = ast_alloca(sizeof(*ie_value));
      int insert = 0;

      memset(ie_value, 0, sizeof(*ie_value));
      ie_value->ie_type = ie_type;
      ie_value->ie_pltype = va_arg(ap, enum ast_event_ie_pltype);
      switch (ie_value->ie_pltype) {
      case AST_EVENT_IE_PLTYPE_UINT:
         ie_value->payload.uint = va_arg(ap, uint32_t);
         insert = 1;
         break;
      case AST_EVENT_IE_PLTYPE_BITFLAGS:
         ie_value->payload.uint = va_arg(ap, uint32_t);
         insert = 1;
         break;
      case AST_EVENT_IE_PLTYPE_STR:
         ie_value->payload.str = va_arg(ap, const char *);
         insert = 1;
         break;
      case AST_EVENT_IE_PLTYPE_RAW:
      {
         void *data = va_arg(ap, void *);
         size_t datalen = va_arg(ap, size_t);
         ie_value->payload.raw = ast_alloca(datalen);
         memcpy(ie_value->payload.raw, data, datalen);
         ie_value->raw_datalen = datalen;
         insert = 1;
         break;
      }
      case AST_EVENT_IE_PLTYPE_UNKNOWN:
      case AST_EVENT_IE_PLTYPE_EXISTS:
         break;
      }

      if (insert) {
         AST_LIST_INSERT_TAIL(&ie_vals, ie_value, entry);
      } else {
         ast_log(LOG_WARNING, "Unsupported PLTYPE(%d)\n", ie_value->ie_pltype);
      }
   }
   va_end(ap);

   if (!(event = ast_calloc(1, sizeof(*event)))) {
      return NULL;
   }

   event->type = htons(type);
   event->event_len = htons(sizeof(*event));

   AST_LIST_TRAVERSE(&ie_vals, ie_val, entry) {
      switch (ie_val->ie_pltype) {
      case AST_EVENT_IE_PLTYPE_STR:
         ast_event_append_ie_str(&event, ie_val->ie_type, ie_val->payload.str);
         break;
      case AST_EVENT_IE_PLTYPE_UINT:
         ast_event_append_ie_uint(&event, ie_val->ie_type, ie_val->payload.uint);
         break;
      case AST_EVENT_IE_PLTYPE_BITFLAGS:
         ast_event_append_ie_bitflags(&event, ie_val->ie_type, ie_val->payload.uint);
         break;
      case AST_EVENT_IE_PLTYPE_RAW:
         ast_event_append_ie_raw(&event, ie_val->ie_type,
               ie_val->payload.raw, ie_val->raw_datalen);
         break;
      case AST_EVENT_IE_PLTYPE_EXISTS:
      case AST_EVENT_IE_PLTYPE_UNKNOWN:
         break;
      }

      /* realloc inside one of the append functions failed */
      if (!event) {
         return NULL;
      }
   }

   if (!ast_event_get_ie_raw(event, AST_EVENT_IE_EID)) {
      /* If the event is originating on this server, add the server's
       * entity ID to the event. */
      ast_event_append_eid(&event);
   }

   return event;
}
int ast_event_queue ( struct ast_event event)

Queue an event.

Parameters:
eventthe event to be queued
Return values:
zerosuccess
non-zerofailure. Note that the caller of this function is responsible for destroying the event in the case of a failure.

This function queues an event to be dispatched to all of the appropriate subscribers. This function will not block while the event is being dispatched because the event is queued up for a dispatching thread to handle.

Definition at line 1567 of file event.c.

References _ast_event_queue().

Referenced by aji_handle_pubsub_event(), ast_cel_report_event(), ast_event_sub_activate(), ast_event_unsubscribe(), corosync_ping(), cpg_deliver_cb(), devstate_event(), handle_security_event(), process_collection(), push_acl_change_event(), stun_monitor_request(), and xmpp_pubsub_handle_event().

{
   return _ast_event_queue(event, 0);
}
int ast_event_queue_and_cache ( struct ast_event event)

Queue and cache an event.

Parameters:
eventthe event to be queued and cached

The purpose of caching events is so that the core can retain the last known information for events that represent some sort of state. That way, when code needs to find out the current state, it can query the cache.

The event API already knows which events can be cached and how to cache them.

Return values:
0success
non-zerofailure.

Definition at line 1572 of file event.c.

References _ast_event_queue().

Referenced by aji_handle_pubsub_event(), cpg_deliver_cb(), devstate_event(), handle_request_notify(), notify_message(), presence_state_event(), process_collection(), queue_mwi_event(), and xmpp_pubsub_handle_event().

{
   return _ast_event_queue(event, 1);
}
static void ast_event_ref_destroy ( void *  obj) [static]

Definition at line 1339 of file event.c.

References ast_event_destroy(), and ast_event_ref::event.

Referenced by alloc_event_ref().

{
   struct ast_event_ref *event_ref = obj;

   ast_event_destroy(event_ref->event);
}
void ast_event_report_subs ( const struct ast_event_sub event_sub)

Send AST_EVENT_SUB events to this subscriber of ... subscriber events.

Report current subscriptions to a subscription subscriber.

Definition at line 723 of file event.c.

References ast_event_destroy(), AST_EVENT_IE_EVENTTYPE, AST_EVENT_SUB, ast_event_subs, AST_LIST_TRAVERSE, AST_RWDLLIST_RDLOCK, AST_RWDLLIST_TRAVERSE, AST_RWDLLIST_UNLOCK, ast_event_sub::cb, gen_sub_event(), ast_event_ie_val::ie_type, ast_event_sub::ie_vals, ast_event_ie_val::payload, sub, ast_event_sub::type, ast_event_ie_val::uint, and ast_event_sub::userdata.

Referenced by handle_cli_status(), and start_poll_thread().

{
   struct ast_event *event;
   struct ast_event_sub *sub;
   enum ast_event_type event_type = -1;
   struct ast_event_ie_val *ie_val;

   if (event_sub->type != AST_EVENT_SUB)
      return;

   AST_LIST_TRAVERSE(&event_sub->ie_vals, ie_val, entry) {
      if (ie_val->ie_type == AST_EVENT_IE_EVENTTYPE) {
         event_type = ie_val->payload.uint;
         break;
      }
   }

   if (event_type == -1)
      return;

   AST_RWDLLIST_RDLOCK(&ast_event_subs[event_type]);
   AST_RWDLLIST_TRAVERSE(&ast_event_subs[event_type], sub, entry) {
      if (event_sub == sub) {
         continue;
      }

      event = gen_sub_event(sub);
      if (!event) {
         continue;
      }

      event_sub->cb(event, event_sub->userdata);

      ast_event_destroy(event);
   }
   AST_RWDLLIST_UNLOCK(&ast_event_subs[event_type]);
}
int ast_event_str_to_event_type ( const char *  str,
enum ast_event_type event_type 
)

Convert a string into an event type.

Parameters:
strthe string to convert
event_typean output parameter for the event type
Return values:
0success
non-zerofailure
Since:
1.6.1

Definition at line 306 of file event.c.

References ARRAY_LEN, ast_strlen_zero(), and event_names.

Referenced by event_dump_cache().

{
   int i;

   for (i = 0; i < ARRAY_LEN(event_names); i++) {
      if (ast_strlen_zero(event_names[i]) || strcasecmp(event_names[i], str)) {
         continue;
      }

      *event_type = i;
      return 0;
   }

   return -1;
}
int ast_event_str_to_ie_type ( const char *  str,
enum ast_event_ie_type ie_type 
)

Convert a string to an IE type.

Parameters:
strthe string to convert
ie_typean output parameter for the IE type
Return values:
0success
non-zerofailure
Since:
1.6.1

Definition at line 342 of file event.c.

References ARRAY_LEN, ie_maps, and name.

{
   int i;

   for (i = 0; i < ARRAY_LEN(ie_maps); i++) {
      if (strcasecmp(ie_maps[i].name, str)) {
         continue;
      }

      *ie_type = i;
      return 0;
   }

   return -1;
}
int ast_event_sub_activate ( struct ast_event_sub sub)

Activate a dynamically built subscription.

Parameters:
subthe subscription to activate that was allocated using ast_event_subscribe_new()

Once a dynamically built subscription has had all of the parameters added to it, it should be activated using this function.

Return values:
0success
non-zerofailure
Since:
1.6.1

Definition at line 911 of file event.c.

References ast_event_check_subscriber(), ast_event_destroy(), AST_EVENT_IE_END, AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_UINT, ast_event_queue(), AST_EVENT_SUB, AST_EVENT_SUB_NONE, ast_event_subs, AST_RWDLLIST_INSERT_TAIL, AST_RWDLLIST_UNLOCK, AST_RWDLLIST_WRLOCK, gen_sub_event(), and ast_event_sub::type.

Referenced by ast_event_subscribe().

int ast_event_sub_append_ie_bitflags ( struct ast_event_sub sub,
enum ast_event_ie_type  ie_type,
uint32_t  flags 
)

Append a bitflags parameter to a subscription.

Parameters:
subthe dynamic subscription allocated with ast_event_subscribe_new()
ie_typethe information element type for the parameter
flagsthe flags that must be present in the event to match this subscription
Return values:
0success
non-zerofailure
Since:
1.8

Definition at line 805 of file event.c.

References ast_calloc, AST_EVENT_IE_PLTYPE_BITFLAGS, AST_EVENT_IE_TOTAL, AST_LIST_INSERT_TAIL, ast_event_ie_val::ie_pltype, ast_event_ie_val::ie_type, ast_event_sub::ie_vals, ast_event_ie_val::payload, and ast_event_ie_val::uint.

Referenced by ast_event_subscribe().

{
   struct ast_event_ie_val *ie_val;

   if (ie_type <= 0 || ie_type >= AST_EVENT_IE_TOTAL) {
      return -1;
   }

   if (!(ie_val = ast_calloc(1, sizeof(*ie_val)))) {
      return -1;
   }

   ie_val->ie_type = ie_type;
   ie_val->payload.uint = flags;
   ie_val->ie_pltype = AST_EVENT_IE_PLTYPE_BITFLAGS;

   AST_LIST_INSERT_TAIL(&sub->ie_vals, ie_val, entry);

   return 0;
}
int ast_event_sub_append_ie_exists ( struct ast_event_sub sub,
enum ast_event_ie_type  ie_type 
)

Append an 'exists' parameter to a subscription.

Parameters:
subthe dynamic subscription allocated with ast_event_subscribe_new()
ie_typethe information element type that must be present in the event for it to match this subscription.
Return values:
0success
non-zerofailure
Since:
1.6.1

Definition at line 827 of file event.c.

References ast_calloc, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_TOTAL, AST_LIST_INSERT_TAIL, ast_event_ie_val::ie_pltype, ast_event_ie_val::ie_type, and ast_event_sub::ie_vals.

Referenced by ast_event_subscribe().

{
   struct ast_event_ie_val *ie_val;

   if (ie_type <= 0 || ie_type >= AST_EVENT_IE_TOTAL) {
      return -1;
   }

   if (!(ie_val = ast_calloc(1, sizeof(*ie_val)))) {
      return -1;
   }

   ie_val->ie_type = ie_type;
   ie_val->ie_pltype = AST_EVENT_IE_PLTYPE_EXISTS;

   AST_LIST_INSERT_TAIL(&sub->ie_vals, ie_val, entry);

   return 0;
}
int ast_event_sub_append_ie_raw ( struct ast_event_sub sub,
enum ast_event_ie_type  ie_type,
void *  data,
size_t  raw_datalen 
)

Append a raw parameter to a subscription.

Parameters:
subthe dynamic subscription allocated with ast_event_subscribe_new()
ie_typethe information element type for the parameter
datathe data that must be present in the event to match this subscription
raw_datalenlength of data
Return values:
0success
non-zerofailure
Since:
1.6.1

Definition at line 882 of file event.c.

References ast_calloc, AST_EVENT_IE_PLTYPE_RAW, AST_EVENT_IE_TOTAL, ast_free, AST_LIST_INSERT_TAIL, ast_malloc, ast_event_ie_val::ie_pltype, ast_event_ie_val::ie_type, ast_event_sub::ie_vals, ast_event_ie_val::payload, ast_event_ie_val::raw, and ast_event_ie_val::raw_datalen.

Referenced by ast_event_subscribe(), and cpg_confchg_cb().

{
   struct ast_event_ie_val *ie_val;

   if (ie_type <= 0 || ie_type >= AST_EVENT_IE_TOTAL) {
      return -1;
   }

   if (!(ie_val = ast_calloc(1, sizeof(*ie_val)))) {
      return -1;
   }

   ie_val->ie_type = ie_type;
   ie_val->ie_pltype = AST_EVENT_IE_PLTYPE_RAW;
   ie_val->raw_datalen = raw_datalen;

   if (!(ie_val->payload.raw = ast_malloc(raw_datalen))) {
      ast_free(ie_val);
      return -1;
   }

   memcpy(ie_val->payload.raw, data, raw_datalen);

   AST_LIST_INSERT_TAIL(&sub->ie_vals, ie_val, entry);

   return 0;
}
int ast_event_sub_append_ie_str ( struct ast_event_sub sub,
enum ast_event_ie_type  ie_type,
const char *  str 
)

Append a string parameter to a subscription.

Parameters:
subthe dynamic subscription allocated with ast_event_subscribe_new()
ie_typethe information element type for the parameter
strthe string that must be present in the event to match this subscription
Return values:
0success
non-zerofailure
Since:
1.6.1

Definition at line 848 of file event.c.

References ast_calloc, AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_IE_TOTAL, ast_free, AST_LIST_INSERT_TAIL, ast_str_hash(), ast_strdup, ast_tech_to_upper(), ast_event_ie_val::hash, ast_event_ie_val::ie_pltype, ast_event_ie_val::ie_type, ast_event_sub::ie_vals, ast_event_ie_val::payload, and ast_event_ie_val::str.

Referenced by ast_event_subscribe(), and handle_devstate_change().

{
   struct ast_event_ie_val *ie_val;

   if (ie_type <= 0 || ie_type >= AST_EVENT_IE_TOTAL) {
      return -1;
   }

   if (!(ie_val = ast_calloc(1, sizeof(*ie_val)))) {
      return -1;
   }

   ie_val->ie_type = ie_type;
   ie_val->ie_pltype = AST_EVENT_IE_PLTYPE_STR;

   if (!(ie_val->payload.str = ast_strdup(str))) {
      ast_free(ie_val);
      return -1;
   }

   if (ie_type == AST_EVENT_IE_DEVICE) {
      char *uppertech = ast_strdupa(str);
      ast_tech_to_upper(uppertech);
      ie_val->payload.hash = ast_str_hash(uppertech);
   } else {
      ie_val->payload.hash = ast_str_hash(str);
   }

   AST_LIST_INSERT_TAIL(&sub->ie_vals, ie_val, entry);

   return 0;
}
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.

Parameters:
subthe dynamic subscription allocated with ast_event_subscribe_new()
ie_typethe information element type for the parameter
uintthe value that must be present in the event to match this subscription
Return values:
0success
non-zerofailure
Since:
1.6.1

Definition at line 783 of file event.c.

References ast_calloc, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_IE_TOTAL, AST_LIST_INSERT_TAIL, ast_event_ie_val::ie_pltype, ast_event_ie_val::ie_type, ast_event_sub::ie_vals, ast_event_ie_val::payload, and ast_event_ie_val::uint.

Referenced by ast_event_subscribe(), and handle_cli_status().

{
   struct ast_event_ie_val *ie_val;

   if (ie_type <= 0 || ie_type >= AST_EVENT_IE_TOTAL) {
      return -1;
   }

   if (!(ie_val = ast_calloc(1, sizeof(*ie_val)))) {
      return -1;
   }

   ie_val->ie_type = ie_type;
   ie_val->payload.uint = unsigned_int;
   ie_val->ie_pltype = AST_EVENT_IE_PLTYPE_UINT;

   AST_LIST_INSERT_TAIL(&sub->ie_vals, ie_val, entry);

   return 0;
}
void ast_event_sub_destroy ( struct ast_event_sub sub)

Destroy an allocated subscription.

Parameters:
subthe subscription to destroy

This function should be used when a subscription is allocated with ast_event_subscribe_new(), but for some reason, you want to destroy it instead of activating it. This could be because of an error when reading in the configuration for the dynamically built subscription.

Since:
1.6.1

Definition at line 993 of file event.c.

References ast_event_ie_val_destroy(), ast_free, AST_LIST_REMOVE_HEAD, and ast_event_sub::ie_vals.

Referenced by ast_event_unsubscribe(), cpg_confchg_cb(), event_shutdown(), handle_cli_status(), and handle_devstate_change().

{
   struct ast_event_ie_val *ie_val;

   while ((ie_val = AST_LIST_REMOVE_HEAD(&sub->ie_vals, entry))) {
      ast_event_ie_val_destroy(ie_val);
   }

   ast_free(sub);
}
struct ast_event_sub* ast_event_subscribe ( enum ast_event_type  event_type,
ast_event_cb_t  cb,
const char *  description,
void *  userdata,
  ... 
) [read]

Subscribe to events.

Parameters:
event_typeThe type of events to subscribe to
cbThe function to be called with events
descriptionDescription of the subscription.
userdatadata to be passed to the event callback

The rest of the arguments to this function specify additional parameters for the subscription to filter which events are passed to this subscriber. The arguments must be in sets of:

and must end with AST_EVENT_IE_END.

If the ie_type specified is *not* AST_EVENT_IE_END, then it must be followed by a valid IE payload type. If the payload type specified is AST_EVENT_IE_PLTYPE_EXISTS, then the 3rd argument should not be provided. Otherwise, a payload must also be specified.

Returns:
This returns a reference to the subscription for use with un-subscribing later. If there is a failure in creating the subscription, NULL will be returned.

Example usage:

This creates a subscription to AST_EVENT_MWI events that contain an information element, AST_EVENT_IE_MAILBOX, with the same string value contained in peer->mailbox. Also, the event callback will be passed a pointer to the peer.

Note:
A NULL description will cause this function to crash, so watch out!

Definition at line 931 of file event.c.

References ast_copy_string(), AST_EVENT_IE_END, AST_EVENT_IE_PLTYPE_BITFLAGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_PLTYPE_RAW, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_IE_PLTYPE_UNKNOWN, ast_event_sub_activate(), ast_event_sub_append_ie_bitflags(), ast_event_sub_append_ie_exists(), ast_event_sub_append_ie_raw(), ast_event_sub_append_ie_str(), ast_event_sub_append_ie_uint(), ast_event_subscribe_new(), ast_event_sub::description, str, and sub.

Referenced by acl_change_event_subscribe(), add_peer_mwi_subs(), aji_init_event_distribution(), ast_enable_distributed_devstate(), build_gateway(), build_peer(), cc_generic_agent_start_monitoring(), config_line(), create_new_generic_list(), load_general_config(), load_module(), load_pbx(), mkintf(), network_change_event_subscribe(), sig_pri_start_pri(), start_poll_thread(), and xmpp_init_event_distribution().

{
   va_list ap;
   enum ast_event_ie_type ie_type;
   struct ast_event_sub *sub;

   if (!(sub = ast_event_subscribe_new(type, cb, userdata))) {
      return NULL;
   }

   ast_copy_string(sub->description, description, sizeof(sub->description));

   va_start(ap, userdata);
   for (ie_type = va_arg(ap, enum ast_event_ie_type);
      ie_type != AST_EVENT_IE_END;
      ie_type = va_arg(ap, enum ast_event_ie_type))
   {
      enum ast_event_ie_pltype ie_pltype;

      ie_pltype = va_arg(ap, enum ast_event_ie_pltype);

      switch (ie_pltype) {
      case AST_EVENT_IE_PLTYPE_UNKNOWN:
         break;
      case AST_EVENT_IE_PLTYPE_UINT:
      {
         uint32_t unsigned_int = va_arg(ap, uint32_t);
         ast_event_sub_append_ie_uint(sub, ie_type, unsigned_int);
         break;
      }
      case AST_EVENT_IE_PLTYPE_BITFLAGS:
      {
         uint32_t unsigned_int = va_arg(ap, uint32_t);
         ast_event_sub_append_ie_bitflags(sub, ie_type, unsigned_int);
         break;
      }
      case AST_EVENT_IE_PLTYPE_STR:
      {
         const char *str = va_arg(ap, const char *);
         ast_event_sub_append_ie_str(sub, ie_type, str);
         break;
      }
      case AST_EVENT_IE_PLTYPE_RAW:
      {
         void *data = va_arg(ap, void *);
         size_t data_len = va_arg(ap, size_t);
         ast_event_sub_append_ie_raw(sub, ie_type, data, data_len);
         break;
      }
      case AST_EVENT_IE_PLTYPE_EXISTS:
         ast_event_sub_append_ie_exists(sub, ie_type);
         break;
      }
   }
   va_end(ap);

   ast_event_sub_activate(sub);

   return sub;
}
struct ast_event_sub* ast_event_subscribe_new ( enum ast_event_type  type,
ast_event_cb_t  cb,
void *  userdata 
) [read]

Allocate a subscription, but do not activate it.

Parameters:
typethe event type to subscribe to
cbthe function to call when an event matches this subscription
userdatadata to pass to the provided callback

This function should be used when you want to dynamically build a subscription.

Returns:
the allocated subscription, or NULL on failure
Since:
1.6.1

Definition at line 761 of file event.c.

References ast_atomic_fetchadd_int(), ast_calloc, ast_log(), ast_event_sub::cb, LOG_ERROR, sub, ast_event_sub::type, ast_event_sub::uniqueid, and ast_event_sub::userdata.

Referenced by ast_event_subscribe(), cpg_confchg_cb(), handle_cli_status(), and handle_devstate_change().

{
   struct ast_event_sub *sub;

   if (type < 0 || type >= AST_EVENT_TOTAL) {
      ast_log(LOG_ERROR, "%u is an invalid type!\n", type);
      return NULL;
   }

   if (!(sub = ast_calloc(1, sizeof(*sub)))) {
      return NULL;
   }

   sub->type = type;
   sub->cb = cb;
   sub->userdata = userdata;
   sub->uniqueid = ast_atomic_fetchadd_int((int *) &sub_uniqueid, 1);

   return sub;
}
const char* ast_event_subscriber_get_description ( struct ast_event_sub sub)

Get description for a subscription.

Parameters:
subsubscription
Returns:
string description of the subscription

Definition at line 1004 of file event.c.

References ast_event_sub::description.

{
   return sub ? sub->description : NULL;
}
struct ast_event_sub* ast_event_unsubscribe ( struct ast_event_sub event_sub) [read]

Un-subscribe from events.

Parameters:
event_subThis is the reference to the subscription returned by ast_event_subscribe.

This function will remove a subscription and free the associated data structures.

Returns:
NULL for convenience.
Version:
1.6.1 return changed to NULL

Definition at line 1009 of file event.c.

References AST_DLLIST_REMOVE, ast_event_check_subscriber(), ast_event_destroy(), AST_EVENT_IE_DESCRIPTION, AST_EVENT_IE_END, AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_IE_UNIQUEID, ast_event_new(), ast_event_queue(), ast_event_sub_destroy(), AST_EVENT_SUB_NONE, ast_event_subs, AST_EVENT_UNSUB, AST_RWDLLIST_UNLOCK, AST_RWDLLIST_WRLOCK, ast_event_sub::description, ast_event_sub::type, and ast_event_sub::uniqueid.

Referenced by acl_change_event_unsubscribe(), add_peer_mwi_subs(), ast_xmpp_client_disconnect(), cc_generic_agent_destructor(), cleanup_module(), destroy_dahdi_pvt(), destroy_endpoint(), destroy_mailbox(), generic_agent_devstate_unsubscribe(), generic_monitor_instance_list_destructor(), load_general_config(), network_change_event_unsubscribe(), peer_destructor(), sig_pri_start_pri(), sig_pri_stop_pri(), stop_poll_thread(), unload_module(), unload_pbx(), and xmpp_init_event_distribution().

static int dump_cache_cb ( void *  obj,
void *  arg,
int  flags 
) [static]

Definition at line 650 of file event.c.

References AST_LIST_TRAVERSE, ast_event_sub::cb, ast_event_ref::event, event_sub, ast_event_sub::ie_vals, match_ie_val(), and ast_event_sub::userdata.

Referenced by ast_event_dump_cache().

{
   const struct ast_event_ref *event_ref = obj;
   const struct ast_event *event = event_ref->event;
   const struct ast_event_sub *event_sub = arg;
   struct ast_event_ie_val *ie_val = NULL;

   AST_LIST_TRAVERSE(&event_sub->ie_vals, ie_val, entry) {
      if (!match_ie_val(event, ie_val, NULL)) {
         break;
      }
   }

   if (!ie_val) {
      /* All parameters were matched on this cache entry, so dump it */
      event_sub->cb(event, event_sub->userdata);
   }

   return 0;
}
static void dump_raw_ie ( struct ast_event_iterator i,
struct ast_cli_args a 
) [static]

Definition at line 1699 of file event.c.

References ast_cli(), ast_eid_to_str(), ast_event_get_ie_type_name(), AST_EVENT_IE_EID, ast_event_iterator_get_ie_raw(), ast_event_iterator_get_ie_type(), ast_cli_args::fd, and ast_event_ie_val::ie_type.

Referenced by event_dump_cli().

{
   char eid_buf[32];
   enum ast_event_ie_type ie_type;
   const char *ie_type_name;

   ie_type = ast_event_iterator_get_ie_type(i);
   ie_type_name = ast_event_get_ie_type_name(ie_type);

   switch (ie_type) {
   case AST_EVENT_IE_EID:
      ast_eid_to_str(eid_buf, sizeof(eid_buf), ast_event_iterator_get_ie_raw(i));
      ast_cli(a->fd, "%.30s: %s\n", ie_type_name, eid_buf);
      break;
   default:
      ast_cli(a->fd, "%s\n", ie_type_name);
      break;
   }
}
static char* event_dump_cache ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 1770 of file event.c.

References ao2_callback, ast_cli_args::argc, ast_cli_entry::args, ast_cli_args::argv, ARRAY_LEN, ast_cli(), ast_cli_complete(), ast_event_cache, ast_event_get_ie_type_name(), ast_event_str_to_event_type(), cache_args, cached_event_types, CLI_GENERATE, CLI_HANDLER, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, container, event_dump_cli(), ast_cli_args::fd, ast_cli_args::n, OBJ_NODATA, ast_cli_args::pos, ast_cli_entry::usage, and ast_cli_args::word.

{
   enum ast_event_type event_type;
   enum ast_event_ie_type *cache_args;
   int i;

   switch (cmd) {
   case CLI_INIT:
      e->command = "event dump cache";
      e->usage =
         "Usage: event dump cache <event type>\n"
         "       Dump all of the cached events for the given event type.\n"
         "       This is primarily intended for debugging.\n";
      return NULL;
   case CLI_GENERATE:
      if (a->pos == 3) {
         return ast_cli_complete(a->word, cached_event_types, a->n);
      }
      return NULL;
   case CLI_HANDLER:
      break;
   }

   if (a->argc != e->args + 1) {
      return CLI_SHOWUSAGE;
   }

   if (ast_event_str_to_event_type(a->argv[e->args], &event_type)) {
      ast_cli(a->fd, "Invalid cached event type: '%s'\n", a->argv[e->args]);
      return CLI_SHOWUSAGE;
   }

   if (!ast_event_cache[event_type].container) {
      ast_cli(a->fd, "Event type '%s' has no cache.\n", a->argv[e->args]);
      return CLI_SUCCESS;
   }

   ast_cli(a->fd, "Event Type: %s\n", a->argv[e->args]);
   ast_cli(a->fd, "Cache Unique Keys:\n");
   cache_args = ast_event_cache[event_type].cache_args;
   for (i = 0; i < ARRAY_LEN(ast_event_cache[0].cache_args) && cache_args[i]; i++) {
      ast_cli(a->fd, "--> %s\n", ast_event_get_ie_type_name(cache_args[i]));
   }

   ast_cli(a->fd, "\n--- Begin Cache Dump ---\n\n");
   ao2_callback(ast_event_cache[event_type].container, OBJ_NODATA, event_dump_cli, a);
   ast_cli(a->fd, "--- End Cache Dump ---\n\n");

   return CLI_SUCCESS;
}
static int event_dump_cli ( void *  obj,
void *  arg,
int  flags 
) [static]

Definition at line 1719 of file event.c.

References ast_cli(), ast_event_get_ie_pltype(), ast_event_get_ie_type_name(), ast_event_get_type_name(), AST_EVENT_IE_PLTYPE_BITFLAGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_PLTYPE_RAW, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_IE_PLTYPE_UNKNOWN, ast_event_iterator_get_ie_bitflags(), ast_event_iterator_get_ie_str(), ast_event_iterator_get_ie_type(), ast_event_iterator_get_ie_uint(), ast_event_iterator_init(), ast_event_iterator_next(), dump_raw_ie(), ast_event_ref::event, ast_event_iterator::event, and ast_cli_args::fd.

Referenced by event_dump_cache().

{
   const struct ast_event_ref *event_ref = obj;
   const struct ast_event *event = event_ref->event;
   struct ast_cli_args *a = arg;
   struct ast_event_iterator i;

   if (ast_event_iterator_init(&i, event)) {
      ast_cli(a->fd, "Failed to initialize event iterator.  :-(\n");
      return 0;
   }

   ast_cli(a->fd, "Event: %s\n", ast_event_get_type_name(event));

   do {
      enum ast_event_ie_type ie_type;
      enum ast_event_ie_pltype ie_pltype;
      const char *ie_type_name;

      ie_type = ast_event_iterator_get_ie_type(&i);
      ie_type_name = ast_event_get_ie_type_name(ie_type);
      ie_pltype = ast_event_get_ie_pltype(ie_type);

      switch (ie_pltype) {
      case AST_EVENT_IE_PLTYPE_UNKNOWN:
      case AST_EVENT_IE_PLTYPE_EXISTS:
         ast_cli(a->fd, "%s\n", ie_type_name);
         break;
      case AST_EVENT_IE_PLTYPE_STR:
         ast_cli(a->fd, "%.30s: %s\n", ie_type_name,
               ast_event_iterator_get_ie_str(&i));
         break;
      case AST_EVENT_IE_PLTYPE_UINT:
         ast_cli(a->fd, "%.30s: %u\n", ie_type_name,
               ast_event_iterator_get_ie_uint(&i));
         break;
      case AST_EVENT_IE_PLTYPE_BITFLAGS:
         ast_cli(a->fd, "%.30s: %u\n", ie_type_name,
               ast_event_iterator_get_ie_bitflags(&i));
         break;
      case AST_EVENT_IE_PLTYPE_RAW:
         dump_raw_ie(&i, a);
         break;
      }
   } while (!ast_event_iterator_next(&i));

   ast_cli(a->fd, "\n");

   return 0;
}
static void event_shutdown ( void  ) [static]

Definition at line 1826 of file event.c.

References ao2_ref, ARRAY_LEN, ast_cli_unregister_multiple(), ast_event_cache, ast_event_sub_destroy(), ast_event_subs, AST_EVENT_TOTAL, AST_RWDLLIST_HEAD_DESTROY, AST_RWDLLIST_REMOVE_HEAD, AST_RWDLLIST_UNLOCK, AST_RWDLLIST_WRLOCK, ast_taskprocessor_unreference(), container, event_cli, hash_fn, and sub.

Referenced by ast_event_init().

{
   struct ast_event_sub *sub;
   int i;

   ast_cli_unregister_multiple(event_cli, ARRAY_LEN(event_cli));

   if (event_dispatcher) {
      event_dispatcher = ast_taskprocessor_unreference(event_dispatcher);
   }

   /* Remove any remaining subscriptions.  Note that we can't just call
    * unsubscribe, as it will attempt to lock the subscription list
    * as well */
   for (i = 0; i < AST_EVENT_TOTAL; i++) {
      AST_RWDLLIST_WRLOCK(&ast_event_subs[i]);
      while ((sub = AST_RWDLLIST_REMOVE_HEAD(&ast_event_subs[i], entry))) {
         ast_event_sub_destroy(sub);
      }
      AST_RWDLLIST_UNLOCK(&ast_event_subs[i]);
      AST_RWDLLIST_HEAD_DESTROY(&ast_event_subs[i]);
   }

   for (i = 0; i < AST_EVENT_TOTAL; i++) {
      if (!ast_event_cache[i].hash_fn) {
         continue;
      }
      if (ast_event_cache[i].container) {
         ao2_ref(ast_event_cache[i].container, -1);
      }
   }
}
static void event_update_cache ( struct ao2_container cache,
struct ast_event event 
) [static]

Definition at line 1454 of file event.c.

References alloc_event_ref(), ao2_callback, ao2_link, ao2_lock, ao2_ref, ao2_unlock, ast_event_cmp(), ast_event_destroy(), ast_event_dup(), ast_event_ref::event, OBJ_MULTIPLE, OBJ_NODATA, OBJ_POINTER, and OBJ_UNLINK.

Referenced by handle_event().

{
   struct ast_event_ref tmp_event_ref = {
      .event = event,
   };
   struct ast_event *dup_event;
   struct ast_event_ref *event_ref;

   /* Hold the cache container lock while it is updated. */
   ao2_lock(cache);

   /* Remove matches from the cache. */
   ao2_callback(cache, OBJ_POINTER | OBJ_UNLINK | OBJ_MULTIPLE | OBJ_NODATA,
      ast_event_cmp, &tmp_event_ref);

   /* Save a copy of the event in the cache. */
   dup_event = ast_event_dup(event);
   if (dup_event) {
      event_ref = alloc_event_ref();
      if (event_ref) {
         event_ref->event = dup_event;
         ao2_link(cache, event_ref);
         ao2_ref(event_ref, -1);
      } else {
         ast_event_destroy(dup_event);
      }
   }

   ao2_unlock(cache);
}
static struct ast_event* gen_sub_event ( struct ast_event_sub sub) [static, read]

Definition at line 682 of file event.c.

References ast_event_append_ie_bitflags(), ast_event_append_ie_raw(), ast_event_append_ie_str(), ast_event_append_ie_uint(), AST_EVENT_IE_DESCRIPTION, AST_EVENT_IE_END, AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_EXISTS, AST_EVENT_IE_PLTYPE_BITFLAGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_PLTYPE_RAW, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_IE_PLTYPE_UNKNOWN, AST_EVENT_IE_UNIQUEID, ast_event_new(), AST_EVENT_SUB, AST_LIST_TRAVERSE, ast_event_sub::description, ast_event_ie_val::ie_pltype, ast_event_ie_val::ie_type, ast_event_sub::ie_vals, ast_event_ie_val::payload, ast_event_ie_val::raw, ast_event_ie_val::raw_datalen, ast_event_ie_val::str, ast_event_sub::type, ast_event_ie_val::uint, and ast_event_sub::uniqueid.

Referenced by ast_event_report_subs(), and ast_event_sub_activate().

{
   struct ast_event_ie_val *ie_val;
   struct ast_event *event;

   event = ast_event_new(AST_EVENT_SUB,
      AST_EVENT_IE_UNIQUEID,    AST_EVENT_IE_PLTYPE_UINT, sub->uniqueid,
      AST_EVENT_IE_EVENTTYPE,   AST_EVENT_IE_PLTYPE_UINT, sub->type,
      AST_EVENT_IE_DESCRIPTION, AST_EVENT_IE_PLTYPE_STR, sub->description,
      AST_EVENT_IE_END);
   if (!event)
      return NULL;

   AST_LIST_TRAVERSE(&sub->ie_vals, ie_val, entry) {
      switch (ie_val->ie_pltype) {
      case AST_EVENT_IE_PLTYPE_UNKNOWN:
         break;
      case AST_EVENT_IE_PLTYPE_EXISTS:
         ast_event_append_ie_uint(&event, AST_EVENT_IE_EXISTS, ie_val->ie_type);
         break;
      case AST_EVENT_IE_PLTYPE_UINT:
         ast_event_append_ie_uint(&event, ie_val->ie_type, ie_val->payload.uint);
         break;
      case AST_EVENT_IE_PLTYPE_BITFLAGS:
         ast_event_append_ie_bitflags(&event, ie_val->ie_type, ie_val->payload.uint);
         break;
      case AST_EVENT_IE_PLTYPE_STR:
         ast_event_append_ie_str(&event, ie_val->ie_type, ie_val->payload.str);
         break;
      case AST_EVENT_IE_PLTYPE_RAW:
         ast_event_append_ie_raw(&event, ie_val->ie_type, ie_val->payload.raw, ie_val->raw_datalen);
         break;
      }
      if (!event)
         break;
   }

   return event;
}
static int handle_event ( void *  data) [static]

Definition at line 1485 of file event.c.

References ao2_ref, ARRAY_LEN, AST_EVENT_ALL, ast_event_cache, ast_event_get_type(), ast_event_subs, AST_LIST_TRAVERSE, ast_log(), AST_RWDLLIST_RDLOCK, AST_RWDLLIST_TRAVERSE, AST_RWDLLIST_UNLOCK, ast_event_ref::cache, ast_event_sub::cb, container, ast_event_ref::event, event_types, event_update_cache(), ast_event_sub::ie_vals, LOG_WARNING, match_ie_val(), sub, ast_event::type, and ast_event_sub::userdata.

Referenced by _ast_event_queue().

{
   struct ast_event_ref *event_ref = data;
   struct ast_event_sub *sub;
   const enum ast_event_type event_types[] = {
      ntohs(event_ref->event->type),
      AST_EVENT_ALL
   };
   int i;

   if (event_ref->cache) {
      struct ao2_container *container;
      container = ast_event_cache[ast_event_get_type(event_ref->event)].container;
      if (!container) {
         ast_log(LOG_WARNING, "cache requested for non-cached event type\n");
      } else {
         event_update_cache(container, event_ref->event);
      }
   }

   for (i = 0; i < ARRAY_LEN(event_types); i++) {
      AST_RWDLLIST_RDLOCK(&ast_event_subs[event_types[i]]);
      AST_RWDLLIST_TRAVERSE(&ast_event_subs[event_types[i]], sub, entry) {
         struct ast_event_ie_val *ie_val;

         AST_LIST_TRAVERSE(&sub->ie_vals, ie_val, entry) {
            if (!match_ie_val(event_ref->event, ie_val, NULL)) {
               /* The current subscription ie did not match an event ie. */
               break;
            }
         }
         if (ie_val) {
            /* The event did not match this subscription. */
            continue;
         }
         sub->cb(event_ref->event, sub->userdata);
      }
      AST_RWDLLIST_UNLOCK(&ast_event_subs[event_types[i]]);
   }

   ao2_ref(event_ref, -1);

   return 0;
}
static int match_ie_val ( const struct ast_event event,
const struct ast_event_ie_val ie_val,
const struct ast_event event2 
) [static]

Definition at line 577 of file event.c.

References ast_event_get_ie_bitflags(), ast_event_get_ie_raw(), ast_event_get_ie_raw_payload_len(), ast_event_get_ie_str(), ast_event_get_ie_str_hash(), ast_event_get_ie_uint(), AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_BITFLAGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_PLTYPE_RAW, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_IE_PLTYPE_UNKNOWN, ast_tech_to_upper(), ast_event_ie_val::hash, ast_event_ie_val::ie_pltype, ast_event_ie_val::ie_type, ast_event_ie_val::payload, ast_event_ie_val::raw, ast_event_ie_val::raw_datalen, ast_event_ie_val::str, str, and ast_event_ie_val::uint.

Referenced by ast_event_cmp(), dump_cache_cb(), and handle_event().

{
   switch (ie_val->ie_pltype) {
   case AST_EVENT_IE_PLTYPE_UINT:
   {
      uint32_t val = event2 ? ast_event_get_ie_uint(event2, ie_val->ie_type) : ie_val->payload.uint;

      return (val == ast_event_get_ie_uint(event, ie_val->ie_type)) ? 1 : 0;
   }

   case AST_EVENT_IE_PLTYPE_BITFLAGS:
   {
      uint32_t flags = event2 ? ast_event_get_ie_uint(event2, ie_val->ie_type) : ie_val->payload.uint;

      /*
       * If the subscriber has requested *any* of the bitflags that this event provides,
       * then it's a match.
       */
      return (flags & ast_event_get_ie_bitflags(event, ie_val->ie_type)) ? 1 : 0;
   }

   case AST_EVENT_IE_PLTYPE_STR:
   {
      const char *str;
      uint32_t hash;

      hash = event2 ? ast_event_get_ie_str_hash(event2, ie_val->ie_type) : ie_val->payload.hash;
      if (hash != ast_event_get_ie_str_hash(event, ie_val->ie_type)) {
         return 0;
      }

      str = event2 ? ast_event_get_ie_str(event2, ie_val->ie_type) : ie_val->payload.str;
      if (str) {
         const char *e1str, *e2str;
         e1str = ast_event_get_ie_str(event, ie_val->ie_type);
         e2str = str;

         if (ie_val->ie_type == AST_EVENT_IE_DEVICE) {
            e1str = ast_tech_to_upper(ast_strdupa(e1str));
            e2str = ast_tech_to_upper(ast_strdupa(e2str));
         }

         if (!strcmp(e1str, e2str)) {
            return 1;
         }
      }

      return 0;
   }

   case AST_EVENT_IE_PLTYPE_RAW:
   {
      const void *buf = event2 ? ast_event_get_ie_raw(event2, ie_val->ie_type) : ie_val->payload.raw;
      uint16_t ie_payload_len = event2 ? ast_event_get_ie_raw_payload_len(event2, ie_val->ie_type) : ie_val->raw_datalen;

      return (buf
         && ie_payload_len == ast_event_get_ie_raw_payload_len(event, ie_val->ie_type)
         && !memcmp(buf, ast_event_get_ie_raw(event, ie_val->ie_type), ie_payload_len)) ? 1 : 0;
   }

   case AST_EVENT_IE_PLTYPE_EXISTS:
   {
      return ast_event_get_ie_raw(event, ie_val->ie_type) ? 1 : 0;
   }

   case AST_EVENT_IE_PLTYPE_UNKNOWN:
      return 0;
   }

   return 0;
}
static int match_sub_ie_val_to_event ( const struct ast_event_ie_val sub_ie_val,
const struct ast_ev_check_list check_ie_vals 
) [static]

Definition at line 401 of file event.c.

References AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_BITFLAGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_PLTYPE_RAW, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_IE_PLTYPE_UNKNOWN, AST_LIST_TRAVERSE, ast_tech_to_upper(), ast_event_ie_val::ie_pltype, ast_event_ie_val::ie_type, ast_event_ie_val::payload, ast_event_ie_val::raw, ast_event_ie_val::raw_datalen, ast_event_ie_val::str, and ast_event_ie_val::uint.

Referenced by ast_event_check_subscriber().

{
   const struct ast_event_ie_val *event_ie_val;
   int res = 0;

   AST_LIST_TRAVERSE(&check_ie_vals->ie_vals, event_ie_val, entry) {
      if (sub_ie_val->ie_type == event_ie_val->ie_type) {
         break;
      }
   }
   if (!event_ie_val) {
      /* We did not find the event ie the subscriber cares about. */
      return 0;
   }

   if (sub_ie_val->ie_pltype != event_ie_val->ie_pltype) {
      if (sub_ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_EXISTS) {
         /* The subscription only cares that this ie exists. */
         return 1;
      }
      /* Payload types do not match. */
      return 0;
   }

   switch (sub_ie_val->ie_pltype) {
   case AST_EVENT_IE_PLTYPE_UINT:
      res = (sub_ie_val->payload.uint == event_ie_val->payload.uint);
      break;
   case AST_EVENT_IE_PLTYPE_BITFLAGS:
      /*
       * If the subscriber has requested *any* of the bitflags we are providing,
       * then it's a match.
       */
      res = (sub_ie_val->payload.uint & event_ie_val->payload.uint);
      break;
   case AST_EVENT_IE_PLTYPE_STR:
   {
      const char *substr = sub_ie_val->payload.str;
      const char *estr = event_ie_val->payload.str;
      if (sub_ie_val->ie_type == AST_EVENT_IE_DEVICE) {
         substr = ast_tech_to_upper(ast_strdupa(substr));
         estr = ast_tech_to_upper(ast_strdupa(estr));
      }
      res = !strcmp(substr, estr);
      break;
   }
   case AST_EVENT_IE_PLTYPE_RAW:
      res = (sub_ie_val->raw_datalen == event_ie_val->raw_datalen
         && !memcmp(sub_ie_val->payload.raw, event_ie_val->payload.raw,
            sub_ie_val->raw_datalen));
      break;
   case AST_EVENT_IE_PLTYPE_EXISTS:
      /* Should never get here since check_ie_vals cannot have this type. */
      break;
   case AST_EVENT_IE_PLTYPE_UNKNOWN:
      /*
       * Should never be in a subscription event ie val list and
       * check_ie_vals cannot have this type either.
       */
      break;
   }

   return res;
}

Variable Documentation

Information Elements used for caching.

This array is the set of information elements that will be unique among all events in the cache for this event type. When a new event gets cached, a previous event with the same values for these information elements will be replaced.

Definition at line 176 of file event.c.

Referenced by ast_event_cmp(), and event_dump_cache().

const char* const cached_event_types[] = { "MWI", "DeviceState", "DeviceStateChange", NULL } [static]

Names of cached event types, for CLI tab completion.

Note:
These names must match what is in the event_names array.

Definition at line 202 of file event.c.

Referenced by event_dump_cache().

Container of cached events.

This gets allocated in ast_event_init() when Asterisk starts for the event types declared as using the cache.

Definition at line 165 of file event.c.

struct ast_cli_entry event_cli[] [static]
Initial value:
 {
   AST_CLI_DEFINE(event_dump_cache, "Dump the internal event cache (for debugging)"),
}

Definition at line 1821 of file event.c.

Referenced by ast_event_init(), and event_shutdown().

Definition at line 47 of file event.c.

const char* const event_names[AST_EVENT_TOTAL] [static]

Event Names.

Definition at line 207 of file event.c.

Referenced by ast_event_get_type_name(), and ast_event_str_to_event_type().

Event type specific hash function.

Definition at line 167 of file event.c.

Referenced by ast_event_hash(), ast_event_init(), and event_shutdown().

uint32_t sub_uniqueid [static]

Definition at line 135 of file event.c.