#include "asterisk/event_defs.h"
Go to the source code of this file.
Typedefs | |
typedef void(* | ast_event_cb_t )(const struct ast_event *event, void *userdata) |
Subscriber event callback type. More... | |
Functions | |
int | ast_event_append_eid (struct ast_event **event) |
Append the global EID IE. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
enum ast_event_subscriber_res | ast_event_check_subscriber (enum ast_event_type event_type,...) |
Check if subscribers exist. More... | |
void | ast_event_destroy (struct ast_event *event) |
Destroy an event. More... | |
void | ast_event_dump_cache (const struct ast_event_sub *event_sub) |
Dump the event cache for the subscriber. More... | |
struct ast_event * | ast_event_get_cached (enum ast_event_type,...) |
Retrieve an event from the cache. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
const char * | ast_event_get_ie_type_name (enum ast_event_ie_type ie_type) |
Get the string representation of an information element type. More... | |
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. More... | |
size_t | ast_event_get_size (const struct ast_event *event) |
Get the size of an event. More... | |
enum ast_event_type | ast_event_get_type (const struct ast_event *event) |
Get the type for an event. More... | |
const char * | ast_event_get_type_name (const struct ast_event *event) |
Get the string representation of the type of the given event. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
int | ast_event_iterator_init (struct ast_event_iterator *iterator, const struct ast_event *event) |
Initialize an event iterator instance. More... | |
int | ast_event_iterator_next (struct ast_event_iterator *iterator) |
Move iterator instance to next IE. More... | |
size_t | ast_event_minimum_length (void) |
Get the minimum length of an ast_event. More... | |
struct ast_event * | ast_event_new (enum ast_event_type event_type,...) |
Create a new event. More... | |
int | ast_event_queue (struct ast_event *event) |
Queue an event. More... | |
int | ast_event_queue_and_cache (struct ast_event *event) |
Queue and cache an event. More... | |
void | ast_event_report_subs (const struct ast_event_sub *sub) |
Report current subscriptions to a subscription subscriber. More... | |
int | ast_event_str_to_event_type (const char *str, enum ast_event_type *event_type) |
Convert a string into an event type. More... | |
int | ast_event_str_to_ie_type (const char *str, enum ast_event_ie_type *ie_type) |
Convert a string to an IE type. More... | |
int | ast_event_sub_activate (struct ast_event_sub *sub) |
Activate a dynamically built subscription. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | ast_event_sub_destroy (struct ast_event_sub *sub) |
Destroy an allocated subscription. More... | |
struct ast_event_sub * | ast_event_subscribe (enum ast_event_type event_type, ast_event_cb_t cb, const char *description, void *userdata,...) |
Subscribe to events. More... | |
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. More... | |
const char * | ast_event_subscriber_get_description (struct ast_event_sub *sub) |
Get description for a subscription. More... | |
struct ast_event_sub * | ast_event_unsubscribe (struct ast_event_sub *event_sub) |
Un-subscribe from events. More... | |
Definition in file event.h.
typedef void(* ast_event_cb_t)(const struct ast_event *event, void *userdata) |
Subscriber event callback type.
event | the event being passed to the subscriber |
userdata | the data provider in the call to ast_event_subscribe() |
int ast_event_append_eid | ( | struct ast_event ** | event | ) |
Append the global EID IE.
event | the event to append IE to |
0 | success |
-1 | failure |
Definition at line 1308 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.
event | the event that the IE will be appended to |
ie_type | the type of IE to append |
bitflags | the flags that are the payload of the IE |
0 | success |
-1 | failure |
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 1167 of file event.c.
References ast_event_append_ie_raw().
Referenced by ast_event_get_cached(), ast_event_new(), and gen_sub_event().
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.
event | the event that the IE will be appended to |
ie_type | the type of IE to append |
data | A pointer to the raw data for the payload of the IE |
data_len | The amount of data to copy into the payload |
0 | success |
-1 | failure |
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 1174 of file event.c.
References ast_free, ast_realloc, ast_event::event_len, ast_event_ie::ie_payload, and ast_event_ie::ie_payload_len.
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().
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.
event | the event that the IE will be appended to |
ie_type | the type of IE to append |
str | The string for the payload of the IE |
0 | success |
-1 | failure |
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 1139 of file event.c.
References ast_alloca, ast_event_append_ie_raw(), AST_EVENT_IE_DEVICE, ast_str_hash(), ast_strdupa, ast_tech_to_upper(), ast_event_ie_str_payload::hash, and ast_event_ie_str_payload::str.
Referenced by add_ie(), add_ipv4_ie(), add_timeval_ie(), ast_event_get_cached(), ast_event_new(), and gen_sub_event().
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.
event | the event that the IE will be appended to |
ie_type | the type of IE to append |
data | The integer for the payload of the IE |
0 | success |
-1 | failure |
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 1160 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().
enum ast_event_subscriber_res ast_event_check_subscriber | ( | enum ast_event_type | event_type, |
... | |||
) |
Check if subscribers exist.
event_type | This 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:
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.
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 448 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, 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, ast_event_sub::type, and ast_event_ie_val::uint.
Referenced by ast_event_queue(), ast_event_sub_activate(), and ast_event_unsubscribe().
void ast_event_destroy | ( | struct ast_event * | event | ) |
Destroy an event.
event | the event to destroy |
Definition at line 1314 of file event.c.
References ast_free.
Referenced by ast_cel_report_event(), ast_event_get_cached(), ast_event_queue(), ast_event_queue_and_cache(), 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(), process_collection(), sig_pri_mwi_cache_update(), stun_monitor_request(), unistim_send_mwi_to_peer(), and update_registry().
void ast_event_dump_cache | ( | const struct ast_event_sub * | event_sub | ) |
Dump the event cache for the subscriber.
Dump the event cache for the subscriber.
Definition at line 654 of file event.c.
References ao2_callback, ast_event_cache, dump_cache_cb(), OBJ_NODATA, and ast_event_sub::type.
Referenced by add_publish_event(), aji_init_event_distribution(), ast_ais_evt_membership_changed(), and handle_devstate_change().
struct ast_event* ast_event_get_cached | ( | enum | ast_event_type, |
... | |||
) |
Retrieve an event from the cache.
ast_event_type | The 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.
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 1342 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(), process_collection(), sig_pri_mwi_cache_update(), unistim_send_mwi_to_peer(), and update_registry().
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.
event | The event to get the IE from |
ie_type | the type of information element to retrieve |
Definition at line 1084 of file event.c.
References ast_event_get_ie_raw(), and get_unaligned_uint32().
Referenced by append_ie(), and match_ie_val().
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.
ie_type | the information element type to get the payload type of |
Definition at line 314 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().
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.
event | The event to get the IE from |
ie_type | the type of information element to retrieve |
Definition at line 1111 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(), devstate_cache_cb(), devstate_change_collector_cb(), evt_event_deliver_cb(), ie_is_present(), and match_ie_val().
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.
event | The event to get the IE payload length from |
ie_type | the type of information element to get the length of |
Definition at line 1125 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().
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.
event | The event to get the IE from |
ie_type | the type of information element to retrieve |
Definition at line 1102 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(), device_state_cb(), devstate_change_collector_cb(), generic_monitor_devstate_cb(), match_ie_val(), mwi_sub_event_cb(), print_cel_sub(), and sig_pri_mwi_event_cb().
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.
event | The event to get the IE from |
ie_type | the type of information element to retrieve the hash for |
Definition at line 1093 of file event.c.
References ast_event_get_ie_raw(), and ast_event_ie_str_payload::hash.
Referenced by match_ie_val().
const char* ast_event_get_ie_type_name | ( | enum ast_event_ie_type | ie_type | ) |
Get the string representation of an information element type.
ie_type | the information element type to get the string representation of |
Definition at line 304 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().
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.
event | The event to get the IE from |
ie_type | the type of information element to retrieve |
Definition at line 1075 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(), process_collection(), security_event_cb(), sig_pri_mwi_cache_update(), sig_pri_mwi_event_cb(), unistim_send_mwi_to_peer(), and update_registry().
size_t ast_event_get_size | ( | const struct ast_event * | event | ) |
Get the size of an event.
event | the event to get the size of |
Definition at line 340 of file event.c.
References ast_event::event_len.
Referenced by ast_event_cb(), ast_event_dup(), and ast_event_iterator_init().
enum ast_event_type ast_event_get_type | ( | const struct ast_event * | event | ) |
Get the type for an event.
event | the event to get the type for |
Definition at line 1070 of file event.c.
Referenced by ast_event_cb(), ast_event_cmp(), ast_event_get_type_name(), ast_event_hash(), ast_event_queue_and_cache(), mwi_sub_event_cb(), and mwi_unsub_event_cb().
const char* ast_event_get_type_name | ( | const struct ast_event * | event | ) |
Get the string representation of the type of the given event.
Definition at line 274 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().
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.
iterator | The iterator instance |
Definition at line 1046 of file event.c.
References get_unaligned_uint32(), ast_event_iterator::ie, and ast_event_ie::ie_payload.
Referenced by event_dump_cli().
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.
iterator | The iterator instance |
Definition at line 1060 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().
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.
iterator | The IE iterator |
Definition at line 1065 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().
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.
iterator | The iterator instance |
Definition at line 1051 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().
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.
iterator | The iterator instance |
Definition at line 1036 of file event.c.
References ast_event_iterator::ie.
Referenced by ast_event_get_ie_raw(), ast_event_get_ie_raw_payload_len(), dump_raw_ie(), and event_dump_cli().
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.
iterator | The iterator instance |
Definition at line 1041 of file event.c.
References get_unaligned_uint32(), ast_event_iterator::ie, and ast_event_ie::ie_payload.
Referenced by event_dump_cli().
int ast_event_iterator_init | ( | struct ast_event_iterator * | iterator, |
const struct ast_event * | event | ||
) |
Initialize an event iterator instance.
iterator | The iterator instance to initialize |
event | The event that will be iterated through |
0 | Success, there are IEs available to iterate |
-1 | Failure, there are no IEs in the event to iterate |
Definition at line 1014 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 ast_event_iterator_next | ( | struct ast_event_iterator * | iterator | ) |
Move iterator instance to next IE.
iterator | The iterator instance |
0 | on success |
-1 | if end is reached |
Definition at line 1030 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().
size_t ast_event_minimum_length | ( | void | ) |
Get the minimum length of an ast_event.
Definition at line 1854 of file event.c.
Referenced by evt_event_deliver_cb().
struct ast_event* ast_event_new | ( | enum ast_event_type | event_type, |
... | |||
) |
Create a new event.
event_type | The 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.
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 1202 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(), devstate_event(), gen_sub_event(), handle_request_notify(), notify_message(), process_collection(), queue_mwi_event(), and stun_monitor_request().
int ast_event_queue | ( | struct ast_event * | event | ) |
Queue an event.
event | the event to be queued |
zero | success |
non-zero | failure. 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 1517 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(), ast_event_ref::event, handle_event(), and LOG_WARNING.
Referenced by aji_handle_pubsub_event(), ast_cel_report_event(), ast_event_queue_and_cache(), ast_event_sub_activate(), ast_event_unsubscribe(), devstate_event(), handle_security_event(), process_collection(), and stun_monitor_request().
int ast_event_queue_and_cache | ( | struct ast_event * | event | ) |
Queue and cache an event.
event | the 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.
0 | success |
non-zero | failure. |
Definition at line 1465 of file event.c.
References ast_event_cache, ast_event_destroy(), ast_event_get_type(), ast_event_queue(), ast_log(), container, event_update_cache(), and LOG_WARNING.
Referenced by aji_handle_pubsub_event(), devstate_event(), handle_request_notify(), notify_message(), process_collection(), queue_event(), and queue_mwi_event().
void ast_event_report_subs | ( | const struct ast_event_sub * | event_sub | ) |
Report current subscriptions to a subscription subscriber.
This reports all of the current subscribers to a subscriber of subscribers to a specific event type. (Try saying that a few times fast).
The idea here is that it is sometimes very useful for a module to know when someone subscribes to events. However, when they first subscribe, this provides that module the ability to request the event core report to them all of the subscriptions to that event type that already exist.
Report current subscriptions to a subscription subscriber.
Definition at line 701 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, ast_event_sub::type, ast_event_ie_val::uint, and ast_event_sub::userdata.
Referenced by handle_cli_status(), and start_poll_thread().
int ast_event_str_to_event_type | ( | const char * | str, |
enum ast_event_type * | event_type | ||
) |
Convert a string into an event type.
str | the string to convert |
event_type | an output parameter for the event type |
0 | success |
non-zero | failure |
Definition at line 288 of file event.c.
References ARRAY_LEN, ast_strlen_zero(), and event_names.
Referenced by event_dump_cache().
int ast_event_str_to_ie_type | ( | const char * | str, |
enum ast_event_ie_type * | ie_type | ||
) |
int ast_event_sub_activate | ( | struct ast_event_sub * | sub | ) |
Activate a dynamically built subscription.
sub | the 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.
0 | success |
non-zero | failure |
Definition at line 889 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.
sub | the dynamic subscription allocated with ast_event_subscribe_new() |
ie_type | the information element type for the parameter |
flags | the flags that must be present in the event to match this subscription |
0 | success |
non-zero | failure |
Definition at line 783 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().
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.
sub | the dynamic subscription allocated with ast_event_subscribe_new() |
ie_type | the information element type that must be present in the event for it to match this subscription. |
0 | success |
non-zero | failure |
Definition at line 805 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().
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.
sub | the dynamic subscription allocated with ast_event_subscribe_new() |
ie_type | the information element type for the parameter |
data | the data that must be present in the event to match this subscription |
raw_datalen | length of data |
0 | success |
non-zero | failure |
Definition at line 860 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().
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.
sub | the dynamic subscription allocated with ast_event_subscribe_new() |
ie_type | the information element type for the parameter |
str | the string that must be present in the event to match this subscription |
0 | success |
non-zero | failure |
Definition at line 826 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_strdupa, 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().
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.
sub | the dynamic subscription allocated with ast_event_subscribe_new() |
ie_type | the information element type for the parameter |
uint | the value that must be present in the event to match this subscription |
0 | success |
non-zero | failure |
Definition at line 761 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().
void ast_event_sub_destroy | ( | struct ast_event_sub * | sub | ) |
Destroy an allocated subscription.
sub | the 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.
Definition at line 971 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(), event_shutdown(), handle_cli_status(), and handle_devstate_change().
struct ast_event_sub* ast_event_subscribe | ( | enum ast_event_type | event_type, |
ast_event_cb_t | cb, | ||
const char * | description, | ||
void * | userdata, | ||
... | |||
) |
Subscribe to events.
event_type | The type of events to subscribe to |
cb | The function to be called with events |
description | Description of the subscription. |
userdata | data 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.
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.
Definition at line 909 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, and str.
Referenced by add_peer_mwi_subs(), add_publish_event(), aji_init_event_distribution(), ast_enable_distributed_devstate(), build_gateway(), build_peer(), cc_generic_agent_start_monitoring(), config_line(), create_new_generic_list(), load_module(), load_pbx(), mkintf(), network_change_event_subscribe(), sig_pri_start_pri(), and start_poll_thread().
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.
type | the event type to subscribe to |
cb | the function to call when an event matches this subscription |
userdata | data to pass to the provided callback |
This function should be used when you want to dynamically build a subscription.
Definition at line 739 of file event.c.
References ast_atomic_fetchadd_int(), ast_calloc, ast_log(), ast_event_sub::cb, LOG_ERROR, ast_event_sub::type, ast_event_sub::uniqueid, and ast_event_sub::userdata.
Referenced by ast_event_subscribe(), handle_cli_status(), and handle_devstate_change().
const char* ast_event_subscriber_get_description | ( | struct ast_event_sub * | sub | ) |
Get description for a subscription.
sub | subscription |
Definition at line 982 of file event.c.
References ast_event_sub::description.
struct ast_event_sub* ast_event_unsubscribe | ( | struct ast_event_sub * | event_sub | ) |
Un-subscribe from events.
event_sub | This is the reference to the subscription returned by ast_event_subscribe. |
This function will remove a subscription and free the associated data structures.
Definition at line 987 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 add_peer_mwi_subs(), cc_generic_agent_destructor(), destroy_dahdi_pvt(), destroy_endpoint(), destroy_mailbox(), generic_agent_devstate_unsubscribe(), generic_monitor_instance_list_destructor(), network_change_event_unsubscribe(), peer_destructor(), publish_event_destroy(), sig_pri_start_pri(), sig_pri_stop_pri(), stop_poll_thread(), unload_module(), and unload_pbx().