diff --git a/apps/app_queue.c b/apps/app_queue.c index a3dce7e9515a5c74463d7e72bc16910daf98ae5d..aa960252114ab08e1c743171b3086ea1e3047b2e 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -96,7 +96,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/astdb.h" #include "asterisk/devicestate.h" #include "asterisk/stringfields.h" -#include "asterisk/event.h" #include "asterisk/astobj2.h" #include "asterisk/strings.h" #include "asterisk/global_datastores.h" diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index a258e6a0a082d3ebace0afb277c031156f8ebcd1..1f048a283687a15429465cee4e98cdfeab6c0335 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -131,7 +131,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/strings.h" #include "asterisk/smdi.h" #include "asterisk/astobj2.h" -#include "asterisk/event.h" #include "asterisk/taskprocessor.h" #include "asterisk/test.h" diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index b694ecf9455cbd815b1c53ae3cc0ec7cc357b156..f2af6d918b4a76c11a2d32114617bd0b625bc3b1 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -119,7 +119,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/abstract_jb.h" #include "asterisk/smdi.h" #include "asterisk/astobj.h" -#include "asterisk/event.h" #include "asterisk/devicestate.h" #include "asterisk/paths.h" #include "asterisk/ccss.h" diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 786b4617b980ecc2d46171faa14b80abc396bd08..1b910a14a0d04bd59c58483c37d3d386699ec120 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -105,7 +105,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/netsock.h" #include "asterisk/stringfields.h" #include "asterisk/linkedlists.h" -#include "asterisk/event.h" #include "asterisk/astobj2.h" #include "asterisk/timing.h" #include "asterisk/taskprocessor.h" diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 07d8434cb23e02bbc6e7e9e9947b2cbd2742d945..0bb102b63f6075d5119f47263ca9f079d2add451 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -79,7 +79,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/devicestate.h" #include "asterisk/stringfields.h" #include "asterisk/abstract_jb.h" -#include "asterisk/event.h" #include "asterisk/chanvars.h" #include "asterisk/pktccops.h" #include "asterisk/stasis.h" diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 79e8211751619cdf23ec56d42ae9865b5acc990b..36291d1ac31e4fad0f276e20e44aaefaadaf80a4 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -276,7 +276,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/threadstorage.h" #include "asterisk/translate.h" #include "asterisk/ast_version.h" -#include "asterisk/event.h" #include "asterisk/data.h" #include "asterisk/aoc.h" #include "asterisk/message.h" diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 35da7bf8a52957fea18b50bbb05ecce251f75438..78e34450ff596a3a0af9a2d8aeb812d06e43b38b 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -77,7 +77,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/abstract_jb.h" #include "asterisk/threadstorage.h" #include "asterisk/devicestate.h" -#include "asterisk/event.h" #include "asterisk/indications.h" #include "asterisk/linkedlists.h" #include "asterisk/stasis_endpoints.h" diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c index e712d7684cf1c7713b84dd9ed7d5bd1c4aee38b0..adb5cb9c836a68218848bd4a8fc23be47cfbe9af 100644 --- a/channels/chan_unistim.c +++ b/channels/chan_unistim.c @@ -63,7 +63,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/config.h" #include "asterisk/module.h" #include "asterisk/pbx.h" -#include "asterisk/event.h" #include "asterisk/rtp_engine.h" #include "asterisk/netsock2.h" #include "asterisk/acl.h" diff --git a/channels/sig_pri.c b/channels/sig_pri.c index 3b3902f3439068033756dc1f9cf6cdc6ee8003ae..8a63600bf90b2b6220b1c524767383d5cdb68830 100644 --- a/channels/sig_pri.c +++ b/channels/sig_pri.c @@ -8884,8 +8884,10 @@ static void sig_pri_send_mwi_indication(struct sig_pri_span *pri, const char *vm * \brief MWI subscription event callback. * \since 1.8 * - * \param event the event being passed to the subscriber - * \param userdata the data provider in the call to ast_event_subscribe() + * \param userdata the data provider in the call to stasis_subscribe() + * \param sub the subscription to which the message was delivered for this callback + * \param topic the topic on which the message was published + * \param msg the message being passed to the subscriber * * \return Nothing */ diff --git a/channels/sig_pri.h b/channels/sig_pri.h index 62e0dc9631f26250a1dc437046105b5656a62733..a46bca637f1ded3beeb7a56c66d513ec9c7d300b 100644 --- a/channels/sig_pri.h +++ b/channels/sig_pri.h @@ -27,7 +27,6 @@ #include "asterisk/channel.h" #include "asterisk/frame.h" -#include "asterisk/event.h" #include "asterisk/ccss.h" #include <libpri.h> #include <dahdi/user.h> diff --git a/funcs/func_presencestate.c b/funcs/func_presencestate.c index 3bf4a81b31370b38f845b3ef36443b5db24ca9f2..75cef8a549b91a4dee29626c73695999f64d9885 100644 --- a/funcs/func_presencestate.c +++ b/funcs/func_presencestate.c @@ -41,7 +41,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/app.h" #ifdef TEST_FRAMEWORK #include "asterisk/test.h" -#include "asterisk/event.h" #include <semaphore.h> #endif diff --git a/include/asterisk/devicestate.h b/include/asterisk/devicestate.h index cda8a5d98c42edca8b093a301eb1a4e57fc0c725..a3267387f9925f29e2f7e8c653ef5c534fa37f40 100644 --- a/include/asterisk/devicestate.h +++ b/include/asterisk/devicestate.h @@ -19,7 +19,7 @@ /*! \file * \brief Device state management * - * To subscribe to device state changes, use the generic ast_event_subscribe + * To subscribe to device state changes, use the stasis_subscribe * method. For an example, see apps/app_queue.c. * * \todo Currently, when the state of a device changes, the device state provider diff --git a/include/asterisk/event.h b/include/asterisk/event.h index 90e27b2f6c6932ee3cbe5c65011aca47d2034d88..7d78207209c2c19c861bbbd54028089e66bf08ea 100644 --- a/include/asterisk/event.h +++ b/include/asterisk/event.h @@ -90,9 +90,7 @@ typedef void (*ast_event_cb_t)(const struct ast_event *event, void *userdata); * 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. + * by a valid IE payload type. A payload must also be specified. * * \return This returns a reference to the subscription for use with * un-subscribing later. If there is a failure in creating the @@ -159,20 +157,6 @@ void ast_event_sub_destroy(struct ast_event_sub *sub); int ast_event_sub_append_ie_uint(struct ast_event_sub *sub, enum ast_event_ie_type ie_type, uint32_t uint); -/*! - * \brief Append a bitflags parameter to a subscription - * - * \param sub the dynamic subscription allocated with ast_event_subscribe_new() - * \param ie_type the information element type for the parameter - * \param flags the flags that must be present in the event to match this subscription - * - * \retval 0 success - * \retval non-zero failure - * \since 1.8 - */ -int ast_event_sub_append_ie_bitflags(struct ast_event_sub *sub, - enum ast_event_ie_type ie_type, uint32_t flags); - /*! * \brief Append a string parameter to a subscription * @@ -202,20 +186,6 @@ int ast_event_sub_append_ie_str(struct ast_event_sub *sub, 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); -/*! - * \brief Append an 'exists' parameter to a subscription - * - * \param sub the dynamic subscription allocated with ast_event_subscribe_new() - * \param ie_type the information element type that must be present in the event - * for it to match this subscription. - * - * \retval 0 success - * \retval non-zero failure - * \since 1.6.1 - */ -int ast_event_sub_append_ie_exists(struct ast_event_sub *sub, - enum ast_event_ie_type ie_type); - /*! * \brief Activate a dynamically built subscription * @@ -245,15 +215,6 @@ int ast_event_sub_activate(struct ast_event_sub *sub); */ struct ast_event_sub *ast_event_unsubscribe(struct ast_event_sub *event_sub); -/*! - * \brief Get description for a subscription - * - * \param sub subscription - * - * \return string description of the subscription - */ -const char *ast_event_subscriber_get_description(struct ast_event_sub *sub); - /*! * \brief Check if subscribers exist * @@ -269,9 +230,7 @@ const char *ast_event_subscriber_get_description(struct ast_event_sub *sub); * 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. + * by a valid IE payload type. A payload must also be specified. * * \return This returns one of the values defined in the ast_event_subscriber_res * enum which will indicate if subscribers exist that match the given @@ -309,12 +268,6 @@ enum ast_event_subscriber_res ast_event_check_subscriber(enum ast_event_type eve */ void ast_event_report_subs(const struct ast_event_sub *sub); -/*! - * \brief Dump the event cache for the subscriber - * \since 1.6.1 - */ -void ast_event_dump_cache(const struct ast_event_sub *event_sub); - /*! * \brief Create a new event * @@ -328,8 +281,7 @@ void ast_event_dump_cache(const struct ast_event_sub *event_sub); * 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 + * by a valid IE payload type. A payload must also be specified * after the IE payload type. * * \note The EID IE will be appended automatically when this function is used @@ -384,63 +336,6 @@ void ast_event_destroy(struct ast_event *event); */ int ast_event_queue(struct ast_event *event); -/*! - * \brief Queue and cache an event - * - * \param event the event to be queued and cached - * - * \details - * 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. - * - * \retval 0 success - * \retval non-zero failure. - */ -int ast_event_queue_and_cache(struct ast_event *event); - -/*! - * \brief Retrieve an event from the cache - * - * \param 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: - * \code - * <enum ast_event_ie_type>, [enum ast_event_ie_pltype, [payload] ] - * \endcode - * 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. - * - * \return 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. - * - * \note The caller of this function *must* call ast_event_destroy() on the - * returned event after it is done using it. - * - * Example Usage: - * - * \code - * event = ast_event_get_cached(AST_EVENT_MWI, - * AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox, - * AST_EVENT_IE_END); - * \endcode - * - * 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. - */ -struct ast_event *ast_event_get_cached(enum ast_event_type, ...); - /*! * \brief Append an information element that has a string payload * @@ -475,55 +370,6 @@ int ast_event_append_ie_str(struct ast_event **event, enum ast_event_ie_type ie_ int ast_event_append_ie_uint(struct ast_event **event, enum ast_event_ie_type ie_type, uint32_t data); -/*! - * \brief Append an information element that has a bitflags payload - * - * \param event the event that the IE will be appended to - * \param ie_type the type of IE to append - * \param bitflags the flags that are the payload of the IE - * - * \retval 0 success - * \retval -1 failure - * \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. - */ -int ast_event_append_ie_bitflags(struct ast_event **event, enum ast_event_ie_type ie_type, - uint32_t bitflags); - -/*! - * \brief Append an information element that has a raw payload - * - * \param event the event that the IE will be appended to - * \param ie_type the type of IE to append - * \param data A pointer to the raw data for the payload of the IE - * \param data_len The amount of data to copy into the payload - * - * \retval 0 success - * \retval -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. - */ -int ast_event_append_ie_raw(struct ast_event **event, enum ast_event_ie_type ie_type, - const void *data, size_t data_len); - -/*! - * \brief Append the global EID IE - * - * \param event the event to append IE to - * - * \note For ast_event_new() that includes IEs, this is done automatically - * for you. - * - * \retval 0 success - * \retval -1 failure - */ -int ast_event_append_eid(struct ast_event **event); - /*! * \brief Get the value of an information element that has an integer payload * @@ -536,18 +382,6 @@ int ast_event_append_eid(struct ast_event **event); */ uint32_t ast_event_get_ie_uint(const struct ast_event *event, enum ast_event_ie_type ie_type); -/*! - * \brief Get the value of an information element that has a bitflags payload - * - * \param event The event to get the IE from - * \param ie_type the type of information element to retrieve - * - * \return 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. - */ -uint32_t ast_event_get_ie_bitflags(const struct ast_event *event, enum ast_event_ie_type ie_type); - /*! * \brief Get the value of an information element that has a string payload * @@ -559,40 +393,6 @@ uint32_t ast_event_get_ie_bitflags(const struct ast_event *event, enum ast_event */ const char *ast_event_get_ie_str(const struct ast_event *event, enum ast_event_ie_type ie_type); -/*! - * \brief Get the hash for the string payload of an IE - * - * \param event The event to get the IE from - * \param ie_type the type of information element to retrieve the hash for - * - * \return 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. - */ -uint32_t ast_event_get_ie_str_hash(const struct ast_event *event, enum ast_event_ie_type ie_type); - -/*! - * \brief Get the value of an information element that has a raw payload - * - * \param event The event to get the IE from - * \param ie_type the type of information element to retrieve - * - * \return This returns the payload of the information element with the given type. - * If the information element isn't found, NULL will be returned. - */ -const void *ast_event_get_ie_raw(const struct ast_event *event, enum ast_event_ie_type ie_type); - -/*! - * \brief Get the length of the raw payload for a particular IE - * - * \param event The event to get the IE payload length from - * \param ie_type the type of information element to get the length of - * - * \return If an IE of type ie_type is found, its payload length is returned. - * Otherwise, 0 is returned. - */ -uint16_t ast_event_get_ie_raw_payload_len(const struct ast_event *event, enum ast_event_ie_type ie_type); - /*! * \brief Get the string representation of an information element type * @@ -623,28 +423,6 @@ enum ast_event_ie_pltype ast_event_get_ie_pltype(enum ast_event_ie_type ie_type) */ enum ast_event_type ast_event_get_type(const struct ast_event *event); -/*! - * \brief Get the string representation of the type of the given event - * - * \arg event the event to get the type of - * - * \return the string representation of the event type of the provided event - * \since 1.6.1 - */ -const char *ast_event_get_type_name(const struct ast_event *event); - -/*! - * \brief Convert a string into an event type - * - * \param str the string to convert - * \param event_type an output parameter for the event type - * - * \retval 0 success - * \retval non-zero failure - * \since 1.6.1 - */ -int ast_event_str_to_event_type(const char *str, enum ast_event_type *event_type); - /*! * \brief Convert a string to an IE type * @@ -707,15 +485,6 @@ enum ast_event_ie_type ast_event_iterator_get_ie_type(struct ast_event_iterator */ uint32_t ast_event_iterator_get_ie_uint(struct ast_event_iterator *iterator); -/*! - * \brief Get the value of the current IE in the iterator as a bitflags payload - * - * \param iterator The iterator instance - * - * \return This returns the payload of the information element as bitflags. - */ -uint32_t ast_event_iterator_get_ie_bitflags(struct ast_event_iterator *iterator); - /*! * \brief Get the value of the current IE in the iterator as a string payload * @@ -725,31 +494,6 @@ uint32_t ast_event_iterator_get_ie_bitflags(struct ast_event_iterator *iterator) */ const char *ast_event_iterator_get_ie_str(struct ast_event_iterator *iterator); -/*! - * \brief Get the value of the current IE in the iterator instance that has a raw payload - * - * \param iterator The iterator instance - * - * \return This returns the payload of the information element as type raw. - */ -void *ast_event_iterator_get_ie_raw(struct ast_event_iterator *iterator); - -/*! - * \brief Get the length of the raw payload for the current IE for an iterator - * - * \param iterator The IE iterator - * - * \return The payload length of the current IE - */ -uint16_t ast_event_iterator_get_ie_raw_payload_len(struct ast_event_iterator *iterator); - -/*! - * \brief Get the minimum length of an ast_event. - * - * \return minimum amount of memory that will be consumed by any ast_event. - */ -size_t ast_event_minimum_length(void); - #if defined(__cplusplus) || defined(c_plusplus) } #endif diff --git a/include/asterisk/event_defs.h b/include/asterisk/event_defs.h index 7a4b064d0c1382f2a73314fee0c6e2f35bc34e74..e25908e29f9c8b2a04b2cb44f95bf0150e2f310c 100644 --- a/include/asterisk/event_defs.h +++ b/include/asterisk/event_defs.h @@ -26,7 +26,7 @@ #define AST_EVENT_DEFS_H /*! \brief Event types - * \note These values can *never* change. */ + * \note These values no longer go over the wire and can change when items are removed. */ enum ast_event_type { /*! Reserved to provide the ability to subscribe to all events. A specific * event should never have a payload of 0. */ @@ -36,32 +36,12 @@ enum ast_event_type { * \note There are no "custom" IE types, because IEs only have to be * unique to the event itself, not necessarily across all events. */ AST_EVENT_CUSTOM = 0x01, - /*! Voicemail message waiting indication */ - AST_EVENT_MWI = 0x02, /*! Someone has subscribed to events */ - AST_EVENT_SUB = 0x03, - /*! Someone has unsubscribed from events */ - AST_EVENT_UNSUB = 0x04, - /*! The aggregate state of a device across all servers configured to be - * a part of a device state cluster has changed. */ - AST_EVENT_DEVICE_STATE = 0x05, - /*! The state of a device has changed on _one_ server. This should not be used - * directly, in general. Use AST_EVENT_DEVICE_STATE instead. */ - AST_EVENT_DEVICE_STATE_CHANGE = 0x06, + AST_EVENT_SUB = 0x02, /*! Channel Event Logging events */ - AST_EVENT_CEL = 0x07, - /*! A report of a security related event (see security_events.h) */ - AST_EVENT_SECURITY = 0x08, - /*! Used by res_stun_monitor to alert listeners to an exernal network address change. */ - AST_EVENT_NETWORK_CHANGE = 0x09, - /*! The presence state for a presence provider */ - AST_EVENT_PRESENCE_STATE = 0x0a, - /*! Used to alert listeners when a named ACL has been changed. */ - AST_EVENT_ACL_CHANGE = 0x0b, - /*! Send out a ping for debugging distributed events */ - AST_EVENT_PING = 0x0c, + AST_EVENT_CEL = 0x03, /*! Number of event types. This should be the last event type + 1 */ - AST_EVENT_TOTAL = 0x0d, + AST_EVENT_TOTAL = 0x04, }; /*! \brief Event Information Element types */ @@ -69,243 +49,199 @@ enum ast_event_ie_type { /*! Used to terminate the arguments to event functions */ AST_EVENT_IE_END = -1, - /*! - * \brief Number of new messages - * Used by: AST_EVENT_MWI - * Payload type: UINT - */ - AST_EVENT_IE_NEWMSGS = 0x0001, - /*! - * \brief Number of - * Used by: AST_EVENT_MWI - * Payload type: UINT - */ - AST_EVENT_IE_OLDMSGS = 0x0002, - /*! - * \brief Mailbox name \verbatim (mailbox[@context]) \endverbatim - * Used by: AST_EVENT_MWI - * Payload type: STR - */ - AST_EVENT_IE_MAILBOX = 0x0003, /*! * \brief Unique ID * Used by: AST_EVENT_SUB, AST_EVENT_UNSUB * Payload type: UINT */ - AST_EVENT_IE_UNIQUEID = 0x0004, + AST_EVENT_IE_UNIQUEID = 0x0001, /*! * \brief Event type * Used by: AST_EVENT_SUB, AST_EVENT_UNSUB * Payload type: UINT */ - AST_EVENT_IE_EVENTTYPE = 0x0005, + AST_EVENT_IE_EVENTTYPE = 0x0002, /*! * \brief Hint that someone cares that an IE exists * Used by: AST_EVENT_SUB * Payload type: UINT (ast_event_ie_type) */ - AST_EVENT_IE_EXISTS = 0x0006, - /*! - * \brief Device Name - * Used by AST_EVENT_DEVICE_STATE_CHANGE - * Payload type: STR - */ - AST_EVENT_IE_DEVICE = 0x0007, - /*! - * \brief Generic State IE - * Used by AST_EVENT_DEVICE_STATE_CHANGE - * Payload type: UINT - * The actual state values depend on the event which - * this IE is a part of. - */ - AST_EVENT_IE_STATE = 0x0008, + AST_EVENT_IE_EXISTS = 0x0003, /*! * \brief Context IE * Used by AST_EVENT_MWI * Payload type: str */ - AST_EVENT_IE_CONTEXT = 0x0009, + AST_EVENT_IE_CONTEXT = 0x0004, /*! * \brief Channel Event Type * Used by: AST_EVENT_CEL * Payload type: UINT */ - AST_EVENT_IE_CEL_EVENT_TYPE = 0x000a, + AST_EVENT_IE_CEL_EVENT_TYPE = 0x0005, /*! * \brief Channel Event Time (seconds) * Used by: AST_EVENT_CEL * Payload type: UINT */ - AST_EVENT_IE_CEL_EVENT_TIME = 0x000b, + AST_EVENT_IE_CEL_EVENT_TIME = 0x0006, /*! * \brief Channel Event Time (micro-seconds) * Used by: AST_EVENT_CEL * Payload type: UINT */ - AST_EVENT_IE_CEL_EVENT_TIME_USEC = 0x000c, + AST_EVENT_IE_CEL_EVENT_TIME_USEC = 0x0007, /*! * \brief Channel Event User Event Name * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_USEREVENT_NAME = 0x000d, + AST_EVENT_IE_CEL_USEREVENT_NAME = 0x0008, /*! * \brief Channel Event CID name * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_CIDNAME = 0x000e, + AST_EVENT_IE_CEL_CIDNAME = 0x0009, /*! * \brief Channel Event CID num * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_CIDNUM = 0x000f, + AST_EVENT_IE_CEL_CIDNUM = 0x000a, /*! * \brief Channel Event extension name * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_EXTEN = 0x0010, + AST_EVENT_IE_CEL_EXTEN = 0x000b, /*! * \brief Channel Event context name * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_CONTEXT = 0x0011, + AST_EVENT_IE_CEL_CONTEXT = 0x000c, /*! * \brief Channel Event channel name * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_CHANNAME = 0x0012, + AST_EVENT_IE_CEL_CHANNAME = 0x000d, /*! * \brief Channel Event app name * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_APPNAME = 0x0013, + AST_EVENT_IE_CEL_APPNAME = 0x000e, /*! * \brief Channel Event app args/data * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_APPDATA = 0x0014, + AST_EVENT_IE_CEL_APPDATA = 0x000f, /*! * \brief Channel Event AMA flags * Used by: AST_EVENT_CEL * Payload type: UINT */ - AST_EVENT_IE_CEL_AMAFLAGS = 0x0015, + AST_EVENT_IE_CEL_AMAFLAGS = 0x0010, /*! * \brief Channel Event AccountCode * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_ACCTCODE = 0x0016, + AST_EVENT_IE_CEL_ACCTCODE = 0x0011, /*! * \brief Channel Event UniqueID * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_UNIQUEID = 0x0017, + AST_EVENT_IE_CEL_UNIQUEID = 0x0012, /*! * \brief Channel Event Userfield * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_USERFIELD = 0x0018, + AST_EVENT_IE_CEL_USERFIELD = 0x0013, /*! * \brief Channel Event CID ANI field * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_CIDANI = 0x0019, + AST_EVENT_IE_CEL_CIDANI = 0x0014, /*! * \brief Channel Event CID RDNIS field * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_CIDRDNIS = 0x001a, + AST_EVENT_IE_CEL_CIDRDNIS = 0x0015, /*! * \brief Channel Event CID dnid * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_CIDDNID = 0x001b, + AST_EVENT_IE_CEL_CIDDNID = 0x0016, /*! * \brief Channel Event Peer -- for Things involving multiple channels, like BRIDGE * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_PEER = 0x001c, + AST_EVENT_IE_CEL_PEER = 0x0017, /*! * \brief Channel Event LinkedID * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_LINKEDID = 0x001d, + AST_EVENT_IE_CEL_LINKEDID = 0x0018, /*! * \brief Channel Event peeraccount * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_PEERACCT = 0x001e, + AST_EVENT_IE_CEL_PEERACCT = 0x0019, /*! * \brief Channel Event extra data * Used by: AST_EVENT_CEL * Payload type: STR */ - AST_EVENT_IE_CEL_EXTRA = 0x001f, + AST_EVENT_IE_CEL_EXTRA = 0x001a, /*! * \brief Description * Used by: AST_EVENT_SUB, AST_EVENT_UNSUB * Payload type: STR */ - AST_EVENT_IE_DESCRIPTION = 0x0020, + AST_EVENT_IE_DESCRIPTION = 0x001b, /*! * \brief Entity ID * Used by All events * Payload type: RAW * This IE indicates which server the event originated from */ - AST_EVENT_IE_EID = 0x0021, - AST_EVENT_IE_SECURITY_EVENT = 0x0022, - AST_EVENT_IE_EVENT_VERSION = 0x0023, - AST_EVENT_IE_SERVICE = 0x0024, - AST_EVENT_IE_MODULE = 0x0025, - AST_EVENT_IE_ACCOUNT_ID = 0x0026, - AST_EVENT_IE_SESSION_ID = 0x0027, - AST_EVENT_IE_SESSION_TV = 0x0028, - AST_EVENT_IE_ACL_NAME = 0x0029, - AST_EVENT_IE_LOCAL_ADDR = 0x002a, - AST_EVENT_IE_REMOTE_ADDR = 0x002b, - AST_EVENT_IE_EVENT_TV = 0x002c, - AST_EVENT_IE_REQUEST_TYPE = 0x002d, - AST_EVENT_IE_REQUEST_PARAMS = 0x002e, - AST_EVENT_IE_AUTH_METHOD = 0x002f, - AST_EVENT_IE_SEVERITY = 0x0030, - AST_EVENT_IE_EXPECTED_ADDR = 0x0031, - AST_EVENT_IE_CHALLENGE = 0x0032, - AST_EVENT_IE_RESPONSE = 0x0033, - AST_EVENT_IE_EXPECTED_RESPONSE = 0x0034, - AST_EVENT_IE_RECEIVED_CHALLENGE = 0x0035, - AST_EVENT_IE_RECEIVED_HASH = 0x0036, - AST_EVENT_IE_USING_PASSWORD = 0x0037, - AST_EVENT_IE_ATTEMPTED_TRANSPORT = 0x0038, - AST_EVENT_IE_PRESENCE_PROVIDER = 0x0039, - AST_EVENT_IE_PRESENCE_STATE = 0x003a, - AST_EVENT_IE_PRESENCE_SUBTYPE = 0x003b, - AST_EVENT_IE_PRESENCE_MESSAGE = 0x003c, + AST_EVENT_IE_EVENT_VERSION = 0x001c, + AST_EVENT_IE_SERVICE = 0x001d, + AST_EVENT_IE_MODULE = 0x001e, + AST_EVENT_IE_ACCOUNT_ID = 0x001f, + AST_EVENT_IE_SESSION_ID = 0x0020, + AST_EVENT_IE_SESSION_TV = 0x0021, + AST_EVENT_IE_ACL_NAME = 0x0022, + AST_EVENT_IE_LOCAL_ADDR = 0x0023, + AST_EVENT_IE_REMOTE_ADDR = 0x0024, + AST_EVENT_IE_EVENT_TV = 0x0025, + AST_EVENT_IE_REQUEST_TYPE = 0x0026, + AST_EVENT_IE_REQUEST_PARAMS = 0x0027, + AST_EVENT_IE_AUTH_METHOD = 0x0028, + AST_EVENT_IE_SEVERITY = 0x0029, + AST_EVENT_IE_EXPECTED_ADDR = 0x002a, + AST_EVENT_IE_CHALLENGE = 0x002b, + AST_EVENT_IE_RESPONSE = 0x002c, + AST_EVENT_IE_EXPECTED_RESPONSE = 0x002e, + AST_EVENT_IE_RECEIVED_CHALLENGE = 0x002f, + AST_EVENT_IE_RECEIVED_HASH = 0x0030, + AST_EVENT_IE_USING_PASSWORD = 0x0031, + AST_EVENT_IE_ATTEMPTED_TRANSPORT = 0x0032, - /*! - * \brief Event non-cachability flag - * Used by: All events - * Payload type: UINT - */ - AST_EVENT_IE_CACHABLE = 0x003d, /*! \brief Must be the last IE value +1 */ - AST_EVENT_IE_TOTAL = 0x003e, + AST_EVENT_IE_TOTAL = 0x0033, }; /*! @@ -313,16 +249,12 @@ enum ast_event_ie_type { */ enum ast_event_ie_pltype { AST_EVENT_IE_PLTYPE_UNKNOWN = -1, - /*! Just check if it exists, not the value */ - AST_EVENT_IE_PLTYPE_EXISTS, /*! Unsigned Integer (Can be used for signed, too ...) */ AST_EVENT_IE_PLTYPE_UINT, /*! String */ AST_EVENT_IE_PLTYPE_STR, /*! Raw data, compared with memcmp */ AST_EVENT_IE_PLTYPE_RAW, - /*! Bit flags (unsigned integer, compared using boolean logic) */ - AST_EVENT_IE_PLTYPE_BITFLAGS, }; /*! diff --git a/include/asterisk/security_events_defs.h b/include/asterisk/security_events_defs.h index 6f32dae31bff74614133bc44dcbe49eb69b7a107..30a7136064f29681fafcb77e4936d89e86bb5c8f 100644 --- a/include/asterisk/security_events_defs.h +++ b/include/asterisk/security_events_defs.h @@ -36,11 +36,6 @@ extern "C" { /*! * \brief Security event types - * - * AST_EVENT_SECURITY is the event type of an ast_event generated as a security - * event. The event will have an information element of type - * AST_EVENT_IE_SECURITY_EVENT which identifies the security event sub-type. - * This enum defines the possible values for this sub-type. */ enum ast_security_event_type { /*! diff --git a/main/ccss.c b/main/ccss.c index 61e89187baefdecfc641765c6cf55ded9740cc0f..061c45a7ca269a41ece5d5e91b8a0e1ffa20fc44 100644 --- a/main/ccss.c +++ b/main/ccss.c @@ -45,7 +45,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/pbx.h" #include "asterisk/utils.h" #include "asterisk/taskprocessor.h" -#include "asterisk/event.h" #include "asterisk/devicestate.h" #include "asterisk/module.h" #include "asterisk/app.h" diff --git a/main/devicestate.c b/main/devicestate.c index c16a0628b38fed8c3d6875078e3e3de00b8bad80..bcf07ff0b2d57ab58b75409c97dee006420ebcf0 100644 --- a/main/devicestate.c +++ b/main/devicestate.c @@ -131,7 +131,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/app.h" #include "asterisk/astobj2.h" #include "asterisk/stasis.h" -#include "asterisk/event.h" #include "asterisk/devicestate.h" #define DEVSTATE_TOPIC_BUCKETS 57 diff --git a/main/event.c b/main/event.c index 323407cdf82d28f1f4272953bbb9266442a843c8..787f3bc51cb530073161be2d9079cb5af018d1b1 100644 --- a/main/event.c +++ b/main/event.c @@ -45,6 +45,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/cli.h" static struct ast_taskprocessor *event_dispatcher; +static int event_append_ie_raw(struct ast_event **event, enum ast_event_ie_type ie_type, + const void *data, size_t data_len); +static const void *event_get_ie_raw(const struct ast_event *event, enum ast_event_ie_type ie_type); +static uint16_t event_get_ie_raw_payload_len(const struct ast_event *event, enum ast_event_ie_type ie_type); +static uint32_t event_get_ie_str_hash(const struct ast_event *event, enum ast_event_ie_type ie_type); /*! * \brief An event information element @@ -92,20 +97,6 @@ struct ast_event { } __attribute__((packed)); -/*! - * \brief A holder for an event - * - * \details This struct used to have more of a purpose than it does now. - * It is used to hold events in the event cache. It can be completely removed - * if one of these two things is done: - * - ast_event gets changed such that it never has to be realloc()d - * - astobj2 is updated so that you can realloc() an astobj2 object - */ -struct ast_event_ref { - struct ast_event *event; - unsigned int cache; -}; - struct ast_event_ie_val { AST_LIST_ENTRY(ast_event_ie_val) entry; enum ast_event_ie_type ie_type; @@ -138,84 +129,6 @@ static uint32_t sub_uniqueid; * The event subscribers are indexed by which event they are subscribed to */ static AST_RWDLLIST_HEAD(ast_event_sub_list, ast_event_sub) ast_event_subs[AST_EVENT_TOTAL]; -static int ast_event_cmp(void *obj, void *arg, int flags); -static int ast_event_hash_mwi(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); - -#ifdef LOW_MEMORY -#define NUM_CACHE_BUCKETS 17 -#else -#define NUM_CACHE_BUCKETS 563 -#endif - -#define MAX_CACHE_ARGS 8 - -struct cache_events { - /*! - * \brief Container of cached events - * - * \details This gets allocated in ast_event_init() when Asterisk starts - * for the event types declared as using the cache. - */ - struct ao2_container *container; - /*! \brief Event type specific hash function */ - ao2_hash_fn *hash_fn; - /*! - * \brief Information Elements used for caching - * - * \details 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. - */ - enum ast_event_ie_type cache_args[MAX_CACHE_ARGS]; -}; - -/*! - * \brief Event types that are kept in the cache. - */ -static struct cache_events ast_event_cache[AST_EVENT_TOTAL] = { - [AST_EVENT_MWI] = { - .hash_fn = ast_event_hash_mwi, - .cache_args = { AST_EVENT_IE_MAILBOX, AST_EVENT_IE_CONTEXT }, - }, - [AST_EVENT_DEVICE_STATE] = { - .hash_fn = ast_event_hash_devstate, - .cache_args = { AST_EVENT_IE_DEVICE, }, - }, - [AST_EVENT_DEVICE_STATE_CHANGE] = { - .hash_fn = ast_event_hash_devstate_change, - .cache_args = { AST_EVENT_IE_DEVICE, AST_EVENT_IE_EID, }, - }, -}; - -/*! - * \brief Names of cached event types, for CLI tab completion - * - * \note These names must match what is in the event_names array. - */ -static const char * const cached_event_types[] = { "MWI", "DeviceState", "DeviceStateChange", NULL }; - -/*! - * \brief Event Names - */ -static const char * const event_names[AST_EVENT_TOTAL] = { - [AST_EVENT_ALL] = "All", - [AST_EVENT_CUSTOM] = "Custom", - [AST_EVENT_MWI] = "MWI", - [AST_EVENT_SUB] = "Subscription", - [AST_EVENT_UNSUB] = "Unsubscription", - [AST_EVENT_DEVICE_STATE] = "DeviceState", - [AST_EVENT_DEVICE_STATE_CHANGE] = "DeviceStateChange", - [AST_EVENT_CEL] = "CEL", - [AST_EVENT_SECURITY] = "Security", - [AST_EVENT_NETWORK_CHANGE] = "NetworkChange", - [AST_EVENT_PRESENCE_STATE] = "PresenceState", - [AST_EVENT_ACL_CHANGE] = "ACLChange", - [AST_EVENT_PING] = "Ping", -}; - struct ie_map { enum ast_event_ie_pltype ie_pltype; const char *name; @@ -225,16 +138,10 @@ struct ie_map { * \brief IE payload types and names */ static const struct ie_map ie_maps[AST_EVENT_IE_TOTAL] = { - [AST_EVENT_IE_NEWMSGS] = { AST_EVENT_IE_PLTYPE_UINT, "NewMessages" }, - [AST_EVENT_IE_OLDMSGS] = { AST_EVENT_IE_PLTYPE_UINT, "OldMessages" }, - [AST_EVENT_IE_MAILBOX] = { AST_EVENT_IE_PLTYPE_STR, "Mailbox" }, [AST_EVENT_IE_UNIQUEID] = { AST_EVENT_IE_PLTYPE_UINT, "UniqueID" }, [AST_EVENT_IE_EVENTTYPE] = { AST_EVENT_IE_PLTYPE_UINT, "EventType" }, [AST_EVENT_IE_EXISTS] = { AST_EVENT_IE_PLTYPE_UINT, "Exists" }, - [AST_EVENT_IE_DEVICE] = { AST_EVENT_IE_PLTYPE_STR, "Device" }, - [AST_EVENT_IE_STATE] = { AST_EVENT_IE_PLTYPE_UINT, "State" }, [AST_EVENT_IE_CONTEXT] = { AST_EVENT_IE_PLTYPE_STR, "Context" }, - [AST_EVENT_IE_EID] = { AST_EVENT_IE_PLTYPE_RAW, "EntityID" }, [AST_EVENT_IE_CEL_EVENT_TYPE] = { AST_EVENT_IE_PLTYPE_UINT, "CELEventType" }, [AST_EVENT_IE_CEL_EVENT_TIME] = { AST_EVENT_IE_PLTYPE_UINT, "CELEventTime" }, [AST_EVENT_IE_CEL_EVENT_TIME_USEC] = { AST_EVENT_IE_PLTYPE_UINT, "CELEventTimeUSec" }, @@ -257,7 +164,6 @@ static const struct ie_map ie_maps[AST_EVENT_IE_TOTAL] = { [AST_EVENT_IE_CEL_LINKEDID] = { AST_EVENT_IE_PLTYPE_STR, "CELLinkedID" }, [AST_EVENT_IE_CEL_PEERACCT] = { AST_EVENT_IE_PLTYPE_STR, "CELPeerAcct" }, [AST_EVENT_IE_CEL_EXTRA] = { AST_EVENT_IE_PLTYPE_STR, "CELExtra" }, - [AST_EVENT_IE_SECURITY_EVENT] = { AST_EVENT_IE_PLTYPE_STR, "SecurityEvent" }, [AST_EVENT_IE_EVENT_VERSION] = { AST_EVENT_IE_PLTYPE_UINT, "EventVersion" }, [AST_EVENT_IE_SERVICE] = { AST_EVENT_IE_PLTYPE_STR, "Service" }, [AST_EVENT_IE_MODULE] = { AST_EVENT_IE_PLTYPE_STR, "Module" }, @@ -280,43 +186,8 @@ static const struct ie_map ie_maps[AST_EVENT_IE_TOTAL] = { [AST_EVENT_IE_RECEIVED_HASH] = { AST_EVENT_IE_PLTYPE_STR, "ReceivedHash" }, [AST_EVENT_IE_USING_PASSWORD] = { AST_EVENT_IE_PLTYPE_UINT, "UsingPassword" }, [AST_EVENT_IE_ATTEMPTED_TRANSPORT] = { AST_EVENT_IE_PLTYPE_STR, "AttemptedTransport" }, - [AST_EVENT_IE_CACHABLE] = { AST_EVENT_IE_PLTYPE_UINT, "Cachable" }, - [AST_EVENT_IE_PRESENCE_PROVIDER] = { AST_EVENT_IE_PLTYPE_STR, "PresenceProvider" }, - [AST_EVENT_IE_PRESENCE_STATE] = { AST_EVENT_IE_PLTYPE_UINT, "PresenceState" }, - [AST_EVENT_IE_PRESENCE_SUBTYPE] = { AST_EVENT_IE_PLTYPE_STR, "PresenceSubtype" }, - [AST_EVENT_IE_PRESENCE_MESSAGE] = { AST_EVENT_IE_PLTYPE_STR, "PresenceMessage" }, }; -const char *ast_event_get_type_name(const struct ast_event *event) -{ - 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]; -} - -int ast_event_str_to_event_type(const char *str, enum ast_event_type *event_type) -{ - 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; -} - const char *ast_event_get_ie_type_name(enum ast_event_ie_type ie_type) { if (ie_type <= 0 || ie_type >= ARRAY_LEN(ie_maps)) { @@ -337,22 +208,6 @@ enum ast_event_ie_pltype ast_event_get_ie_pltype(enum ast_event_ie_type ie_type) return ie_maps[ie_type].ie_pltype; } -int ast_event_str_to_ie_type(const char *str, enum ast_event_ie_type *ie_type) -{ - 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; -} - size_t ast_event_get_size(const struct ast_event *event) { size_t res; @@ -372,8 +227,6 @@ static void ast_event_ie_val_destroy(struct ast_event_ie_val *ie_val) ast_free(ie_val->payload.raw); break; case AST_EVENT_IE_PLTYPE_UINT: - case AST_EVENT_IE_PLTYPE_BITFLAGS: - case AST_EVENT_IE_PLTYPE_EXISTS: case AST_EVENT_IE_PLTYPE_UNKNOWN: break; } @@ -412,10 +265,6 @@ static int match_sub_ie_val_to_event(const struct ast_event_ie_val *sub_ie_val, } 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; } @@ -424,21 +273,10 @@ static int match_sub_ie_val_to_event(const struct ast_event_ie_val *sub_ie_val, 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; } @@ -447,9 +285,6 @@ static int match_sub_ie_val_to_event(const struct ast_event_ie_val *sub_ie_val, && !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 @@ -497,10 +332,6 @@ enum ast_event_subscriber_res ast_event_check_subscriber(enum ast_event_type typ 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; @@ -517,7 +348,6 @@ enum ast_event_subscriber_res ast_event_check_subscriber(enum ast_event_type typ break; } case AST_EVENT_IE_PLTYPE_UNKNOWN: - case AST_EVENT_IE_PLTYPE_EXISTS: /* Unsupported payload type. */ break; } @@ -583,24 +413,13 @@ static int match_ie_val(const struct ast_event *event, 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)) { + hash = event2 ? event_get_ie_str_hash(event2, ie_val->ie_type) : ie_val->payload.hash; + if (hash != event_get_ie_str_hash(event, ie_val->ie_type)) { return 0; } @@ -610,11 +429,6 @@ static int match_ie_val(const struct ast_event *event, 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; } @@ -625,17 +439,12 @@ static int match_ie_val(const struct ast_event *event, 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; + const void *buf = event2 ? event_get_ie_raw(event2, ie_val->ie_type) : ie_val->payload.raw; + uint16_t ie_payload_len = event2 ? 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; + && ie_payload_len == event_get_ie_raw_payload_len(event, ie_val->ie_type) + && !memcmp(buf, event_get_ie_raw(event, ie_val->ie_type), ie_payload_len)) ? 1 : 0; } case AST_EVENT_IE_PLTYPE_UNKNOWN: @@ -645,38 +454,6 @@ static int match_ie_val(const struct ast_event *event, return 0; } -static int dump_cache_cb(void *obj, void *arg, int flags) -{ - 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; -} - -/*! \brief Dump the event cache for the subscribed event type */ -void ast_event_dump_cache(const struct ast_event_sub *event_sub) -{ - 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 *gen_sub_event(struct ast_event_sub *sub) { struct ast_event_ie_val *ie_val; @@ -694,20 +471,14 @@ static struct ast_event *gen_sub_event(struct ast_event_sub *sub) 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); + event_append_ie_raw(&event, ie_val->ie_type, ie_val->payload.raw, ie_val->raw_datalen); break; } if (!event) @@ -800,49 +571,6 @@ int ast_event_sub_append_ie_uint(struct ast_event_sub *sub, return 0; } -int ast_event_sub_append_ie_bitflags(struct ast_event_sub *sub, - enum ast_event_ie_type ie_type, uint32_t flags) -{ - 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) -{ - 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_str(struct ast_event_sub *sub, enum ast_event_ie_type ie_type, const char *str) { @@ -864,13 +592,7 @@ int ast_event_sub_append_ie_str(struct ast_event_sub *sub, 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); - } + ie_val->payload.hash = ast_str_hash(str); AST_LIST_INSERT_TAIL(&sub->ie_vals, ie_val, entry); @@ -957,12 +679,6 @@ struct ast_event_sub *ast_event_subscribe(enum ast_event_type type, ast_event_cb 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 *); @@ -976,9 +692,6 @@ struct ast_event_sub *ast_event_subscribe(enum ast_event_type type, ast_event_cb 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); @@ -999,33 +712,13 @@ void ast_event_sub_destroy(struct ast_event_sub *sub) ast_free(sub); } -const char *ast_event_subscriber_get_description(struct ast_event_sub *sub) -{ - return sub ? sub->description : NULL; -} - struct ast_event_sub *ast_event_unsubscribe(struct ast_event_sub *sub) { - struct ast_event *event; AST_RWDLLIST_WRLOCK(&ast_event_subs[sub->type]); AST_DLLIST_REMOVE(&ast_event_subs[sub->type], sub, entry); AST_RWDLLIST_UNLOCK(&ast_event_subs[sub->type]); - if (ast_event_check_subscriber(AST_EVENT_UNSUB, - AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_UINT, sub->type, - AST_EVENT_IE_END) != AST_EVENT_SUB_NONE) { - - event = ast_event_new(AST_EVENT_UNSUB, - 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 && ast_event_queue(event)) { - ast_event_destroy(event); - } - } - ast_event_sub_destroy(sub); return NULL; @@ -1063,11 +756,6 @@ uint32_t ast_event_iterator_get_ie_uint(struct ast_event_iterator *iterator) return ntohl(get_unaligned_uint32(iterator->ie->ie_payload)); } -uint32_t ast_event_iterator_get_ie_bitflags(struct ast_event_iterator *iterator) -{ - return ntohl(get_unaligned_uint32(iterator->ie->ie_payload)); -} - const char *ast_event_iterator_get_ie_str(struct ast_event_iterator *iterator) { const struct ast_event_ie_str_payload *str_payload; @@ -1077,12 +765,12 @@ const char *ast_event_iterator_get_ie_str(struct ast_event_iterator *iterator) return str_payload ? str_payload->str : NULL; } -void *ast_event_iterator_get_ie_raw(struct ast_event_iterator *iterator) +static void *event_iterator_get_ie_raw(struct ast_event_iterator *iterator) { return iterator->ie->ie_payload; } -uint16_t ast_event_iterator_get_ie_raw_payload_len(struct ast_event_iterator *iterator) +static uint16_t event_iterator_get_ie_raw_payload_len(struct ast_event_iterator *iterator) { return ntohs(iterator->ie->ie_payload_len); } @@ -1096,25 +784,16 @@ uint32_t ast_event_get_ie_uint(const struct ast_event *event, enum ast_event_ie_ { const uint32_t *ie_val; - ie_val = ast_event_get_ie_raw(event, ie_type); + ie_val = event_get_ie_raw(event, ie_type); return ie_val ? ntohl(get_unaligned_uint32(ie_val)) : 0; } -uint32_t ast_event_get_ie_bitflags(const struct ast_event *event, enum ast_event_ie_type ie_type) -{ - 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; -} - -uint32_t ast_event_get_ie_str_hash(const struct ast_event *event, enum ast_event_ie_type ie_type) +static uint32_t event_get_ie_str_hash(const struct ast_event *event, enum ast_event_ie_type ie_type) { const struct ast_event_ie_str_payload *str_payload; - str_payload = ast_event_get_ie_raw(event, ie_type); + str_payload = event_get_ie_raw(event, ie_type); return str_payload ? str_payload->hash : 0; } @@ -1123,33 +802,33 @@ const char *ast_event_get_ie_str(const struct ast_event *event, enum ast_event_i { const struct ast_event_ie_str_payload *str_payload; - str_payload = ast_event_get_ie_raw(event, ie_type); + str_payload = event_get_ie_raw(event, ie_type); return str_payload ? str_payload->str : NULL; } -const void *ast_event_get_ie_raw(const struct ast_event *event, enum ast_event_ie_type ie_type) +static const void *event_get_ie_raw(const struct ast_event *event, enum ast_event_ie_type ie_type) { 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 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) +static uint16_t event_get_ie_raw_payload_len(const struct ast_event *event, enum ast_event_ie_type ie_type) { 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 event_iterator_get_ie_raw_payload_len(&iterator); } } @@ -1166,32 +845,19 @@ int ast_event_append_ie_str(struct ast_event **event, enum ast_event_ie_type ie_ 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); - } + str_payload->hash = ast_str_hash(str); - return ast_event_append_ie_raw(event, ie_type, str_payload, payload_len); + return 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) { data = htonl(data); - return ast_event_append_ie_raw(event, ie_type, &data, sizeof(data)); + return event_append_ie_raw(event, ie_type, &data, sizeof(data)); } -int ast_event_append_ie_bitflags(struct ast_event **event, enum ast_event_ie_type ie_type, - uint32_t flags) -{ - 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, +static int event_append_ie_raw(struct ast_event **event, enum ast_event_ie_type ie_type, const void *data, size_t data_len) { struct ast_event_ie *ie; @@ -1246,10 +912,6 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...) 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; @@ -1265,7 +927,6 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...) break; } case AST_EVENT_IE_PLTYPE_UNKNOWN: - case AST_EVENT_IE_PLTYPE_EXISTS: break; } @@ -1292,14 +953,10 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...) 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, + 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; } @@ -1310,199 +967,31 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...) } } - 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_append_eid(struct ast_event **event) -{ - return ast_event_append_ie_raw(event, AST_EVENT_IE_EID, - &ast_eid_default, sizeof(ast_eid_default)); -} - void ast_event_destroy(struct ast_event *event) { ast_free(event); } -static void ast_event_ref_destroy(void *obj) -{ - struct ast_event_ref *event_ref = obj; - - ast_event_destroy(event_ref->event); -} - -static struct ast_event *ast_event_dup(const struct ast_event *event) -{ - 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 type, ...) -{ - 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; -} - -static struct ast_event_ref *alloc_event_ref(void) -{ - return ao2_alloc(sizeof(struct ast_event_ref), ast_event_ref_destroy); -} - -/*! - * \internal - * \brief Update the given event cache with the new event. - * \since 1.8 - * - * \param cache Event cache container to update. - * \param event New event to put in the cache. - * - * \return Nothing - */ -static void event_update_cache(struct ao2_container *cache, struct ast_event *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 int handle_event(void *data) { - struct ast_event_ref *event_ref = data; + struct ast_event *event = data; struct ast_event_sub *sub; const enum ast_event_type event_types[] = { - ntohs(event_ref->event->type), + ntohs(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)) { + if (!match_ie_val(event, ie_val, NULL)) { /* The current subscription ie did not match an event ie. */ break; } @@ -1511,19 +1000,18 @@ static int handle_event(void *data) /* The event did not match this subscription. */ continue; } - sub->cb(event_ref->event, sub->userdata); + sub->cb(event, sub->userdata); } AST_RWDLLIST_UNLOCK(&ast_event_subs[event_types[i]]); } - ao2_ref(event_ref, -1); + ast_event_destroy(event); return 0; } -static int _ast_event_queue(struct ast_event *event, unsigned int cache) +int ast_event_queue(struct ast_event *event) { - struct ast_event_ref *event_ref; uint16_t host_event_type; int res; @@ -1543,271 +1031,19 @@ static int _ast_event_queue(struct ast_event *event, unsigned int cache) 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); + res = ast_taskprocessor_push(event_dispatcher, handle_event, event); if (res) { - event_ref->event = NULL; - ao2_ref(event_ref, -1); - } - return res; -} - -int ast_event_queue(struct ast_event *event) -{ - return _ast_event_queue(event, 0); -} - -int ast_event_queue_and_cache(struct ast_event *event) -{ - return _ast_event_queue(event, 1); -} - -static int ast_event_hash_mwi(const void *obj, const int flags) -{ - 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)); -} - -/*! - * \internal - * \brief Hash function for AST_EVENT_DEVICE_STATE - * - * \param[in] obj an ast_event - * \param[in] flags unused - * - * \return hash value - */ -static int ast_event_hash_devstate(const void *obj, const int flags) -{ - const struct ast_event *event = obj; - - return ast_str_hash(ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE)); -} - -/*! - * \internal - * \brief Hash function for AST_EVENT_DEVICE_STATE_CHANGE - * - * \param[in] obj an ast_event - * \param[in] flags unused - * - * \return hash value - */ -static int ast_event_hash_devstate_change(const void *obj, const int flags) -{ - 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(const void *obj, const int flags) -{ - 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); -} - -/*! - * \internal - * \brief Compare two events - * - * \param[in] obj the first event, as an ast_event_ref - * \param[in] arg the second event, as an ast_event_ref - * \param[in] flags unused - * - * \pre Both events must be the same type. - * \pre The event type must be declared as a cached event type in ast_event_cache - * - * \details This function takes two events, and determines if they are considered - * equivalent. The values of information elements specified in the cache arguments - * for the event type are used to determine if the events are equivalent. - * - * \retval 0 No match - * \retval CMP_MATCH The events are considered equivalent based on the cache arguments - */ -static int ast_event_cmp(void *obj, void *arg, int flags) -{ - 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; - } + ast_event_destroy(event); } - return res; } -static void dump_raw_ie(struct ast_event_iterator *i, struct ast_cli_args *a) -{ - 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 int event_dump_cli(void *obj, void *arg, int flags) -{ - 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 char *event_dump_cache(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - 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 struct ast_cli_entry event_cli[] = { - AST_CLI_DEFINE(event_dump_cache, "Dump the internal event cache (for debugging)"), -}; - /*! \internal \brief Clean up resources on Asterisk shutdown */ static void event_shutdown(void) { 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); } @@ -1823,15 +1059,6 @@ static void event_shutdown(void) 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); - } - } } int ast_event_init(void) @@ -1842,24 +1069,10 @@ int ast_event_init(void) 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; @@ -1869,7 +1082,3 @@ event_init_cleanup: return -1; } -size_t ast_event_minimum_length(void) -{ - return sizeof(struct ast_event); -} diff --git a/main/manager.c b/main/manager.c index 3302e8c308443807cb873700a1f864aeeb2e0ba1..d4d7f71b6b32e4a21128418f7c100340f569bb86 100644 --- a/main/manager.c +++ b/main/manager.c @@ -87,7 +87,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/astobj2.h" #include "asterisk/features.h" #include "asterisk/security_events.h" -#include "asterisk/event.h" #include "asterisk/aoc.h" #include "asterisk/strings.h" #include "asterisk/stringfields.h" diff --git a/main/pbx.c b/main/pbx.c index 6bd6261cb58bf3b8894bb9626b0232c65f3d91a1..d5a46a5fdedfb339a7afa57d3dd572c3f493f06c 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -64,7 +64,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/app.h" #include "asterisk/devicestate.h" #include "asterisk/presencestate.h" -#include "asterisk/event.h" #include "asterisk/hashtab.h" #include "asterisk/module.h" #include "asterisk/indications.h" @@ -5181,7 +5180,7 @@ static void device_state_cb(void *unused, struct stasis_subscription *sub, struc ao2_iterator_destroy(&cb_iter); /* For extension callbacks */ - /* extended callbacks are called when the state changed or when AST_EVENT_RINGING is + /* extended callbacks are called when the state changed or when AST_STATE_RINGING is * included. Normal callbacks are only called when the state changed. */ cb_iter = ao2_iterator_init(hint->callbacks, 0); diff --git a/main/presencestate.c b/main/presencestate.c index 3f394b635555bdae604da04b1f87c07f6d930449..b0a1959c0fb3b44dbdc74df27dc238b3ff4ab337 100644 --- a/main/presencestate.c +++ b/main/presencestate.c @@ -36,7 +36,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/presencestate.h" #include "asterisk/pbx.h" #include "asterisk/app.h" -#include "asterisk/event.h" /*! \brief Device state strings for printing */ static const struct { diff --git a/main/security_events.c b/main/security_events.c index eb2dae2fe72c931fe0ebd87fc1c70ebc9c652c5e..d115472917e9dd243bde4b99b348de68019b132c 100644 --- a/main/security_events.c +++ b/main/security_events.c @@ -657,13 +657,11 @@ static struct ast_json *alloc_security_event_json_object(const struct ast_securi * This is true even if ast_json_object_set fails. */ - /* AST_EVENT_IE_SECURITY_EVENT */ json_temp = ast_json_integer_create(sec->event_type); - if (!json_temp || ast_json_object_set(json_object, ast_event_get_ie_type_name(AST_EVENT_IE_SECURITY_EVENT), json_temp)) { + if (!json_temp || ast_json_object_set(json_object, "SecurityEvent", json_temp)) { return NULL; } - /* AST_EVENT_IE_EVENT_VERSION */ json_temp = ast_json_stringf("%d", sec->version); if (!json_temp || ast_json_object_set(json_object, ast_event_get_ie_type_name(AST_EVENT_IE_EVENT_VERSION), json_temp)) { return NULL; diff --git a/res/parking/parking_applications.c b/res/parking/parking_applications.c index 67605c2f7adef3227b22c2ccc0eaa90612fcd421..4b854759dcee95ea2a22d77b52f32e7f7fa639f3 100644 --- a/res/parking/parking_applications.c +++ b/res/parking/parking_applications.c @@ -30,7 +30,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "res_parking.h" #include "asterisk/config.h" #include "asterisk/config_options.h" -#include "asterisk/event.h" #include "asterisk/utils.h" #include "asterisk/astobj2.h" #include "asterisk/features.h" diff --git a/res/parking/parking_manager.c b/res/parking/parking_manager.c index f952ff23a03af2bec710bb2264511993728ccdcd..dac19109091917090044392ab3b6793ae9c62380 100644 --- a/res/parking/parking_manager.c +++ b/res/parking/parking_manager.c @@ -30,7 +30,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "res_parking.h" #include "asterisk/config.h" #include "asterisk/config_options.h" -#include "asterisk/event.h" #include "asterisk/utils.h" #include "asterisk/module.h" #include "asterisk/cli.h" diff --git a/res/parking/parking_ui.c b/res/parking/parking_ui.c index 2f54e8637e0fff6423587882b47012918de34a7b..55b2d5b45ec09674d59c2e6c28fb09961c0a9960 100644 --- a/res/parking/parking_ui.c +++ b/res/parking/parking_ui.c @@ -30,7 +30,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "res_parking.h" #include "asterisk/config.h" #include "asterisk/config_options.h" -#include "asterisk/event.h" #include "asterisk/utils.h" #include "asterisk/module.h" #include "asterisk/cli.h" diff --git a/res/res_jabber.c b/res/res_jabber.c index 0e373e5e7dcea7abadd31a0f623839fd9b06d993..0e41cdf7782a2408ccfc3491582b0d1edcf170b2 100644 --- a/res/res_jabber.c +++ b/res/res_jabber.c @@ -70,7 +70,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/astobj.h" #include "asterisk/astdb.h" #include "asterisk/manager.h" -#include "asterisk/event.h" #include "asterisk/devicestate.h" #include "asterisk/message.h" @@ -3335,7 +3334,6 @@ static int aji_handle_pubsub_event(void *data, ikspak *pak) int oldmsgs, newmsgs; iks *item, *item_content; struct ast_eid pubsub_eid; - struct ast_event *event; unsigned int cachable = AST_DEVSTATE_CACHABLE; item = iks_find(iks_find(iks_find(pak->x, "event"), "items"), "item"); @@ -3374,12 +3372,6 @@ static int aji_handle_pubsub_event(void *data, ikspak *pak) return IKS_FILTER_EAT; } - if (cachable == AST_DEVSTATE_CACHABLE) { - ast_event_queue_and_cache(event); - } else { - ast_event_queue(event); - } - return IKS_FILTER_EAT; } diff --git a/res/res_parking.c b/res/res_parking.c index c7156fbe05c27a21bc035a086a311a49c8294a8b..3cd10a1dd2ad0980d9d8d986a3e397d32d1775d3 100644 --- a/res/res_parking.c +++ b/res/res_parking.c @@ -184,7 +184,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "parking/res_parking.h" #include "asterisk/config.h" #include "asterisk/config_options.h" -#include "asterisk/event.h" #include "asterisk/utils.h" #include "asterisk/module.h" #include "asterisk/cli.h" diff --git a/res/res_security_log.c b/res/res_security_log.c index 1a4f379a109e7de0ed389f084821cd19a50e7562..9e87acf12357a918b354a50db392c9a4c8196c8f 100644 --- a/res/res_security_log.c +++ b/res/res_security_log.c @@ -105,8 +105,7 @@ static void security_event_stasis_cb(struct ast_json *json) return; } - ast_str_set(&str, 0, "%s=\"%s\"", - ast_event_get_ie_type_name(AST_EVENT_IE_SECURITY_EVENT), + ast_str_set(&str, 0, "SecurityEvent=\"%s\"", ast_security_event_get_name(event_type)); append_json(&str, json, diff --git a/res/res_xmpp.c b/res/res_xmpp.c index 3be8aa458fdb1ef8075373b796b69316b691b3d4..1a3ccd3a6b9ffac64c35de9d1af1a00c5df31e3b 100644 --- a/res/res_xmpp.c +++ b/res/res_xmpp.c @@ -59,7 +59,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/app.h" #include "asterisk/message.h" #include "asterisk/manager.h" -#include "asterisk/event.h" #include "asterisk/cli.h" #include "asterisk/config_options.h" @@ -1455,7 +1454,6 @@ static int xmpp_pubsub_handle_event(void *data, ikspak *pak) int oldmsgs, newmsgs; iks *item, *item_content; struct ast_eid pubsub_eid; - struct ast_event *event; unsigned int cachable = AST_DEVSTATE_CACHABLE; item = iks_find(iks_find(iks_find(pak->x, "event"), "items"), "item"); if (!item) { @@ -1493,12 +1491,6 @@ static int xmpp_pubsub_handle_event(void *data, ikspak *pak) return IKS_FILTER_EAT; } - if (cachable == AST_DEVSTATE_CACHABLE) { - ast_event_queue_and_cache(event); - } else { - ast_event_queue(event); - } - return IKS_FILTER_EAT; } diff --git a/tests/test_cel.c b/tests/test_cel.c index 2b36937685eeb00a7dcd10d628a7866840f40d4a..2bf4f29e5b8b029fbae0e1c642ca4a46b611b068 100644 --- a/tests/test_cel.c +++ b/tests/test_cel.c @@ -1730,12 +1730,6 @@ static int match_ie_val( case AST_EVENT_IE_PLTYPE_STR: { const char *str; - uint32_t hash; - - hash = ast_event_get_ie_str_hash(event2, type); - if (hash != ast_event_get_ie_str_hash(event1, type)) { - return 0; - } str = ast_event_get_ie_str(event2, type); if (str) { @@ -1743,11 +1737,6 @@ static int match_ie_val( e1str = ast_event_get_ie_str(event1, type); e2str = str; - if (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; } @@ -1773,10 +1762,8 @@ static int events_are_equal(struct ast_test *test, struct ast_event *received, s for (res = ast_event_iterator_init(&iterator, received); !res; res = ast_event_iterator_next(&iterator)) { /* XXX ignore sec/usec for now */ - /* ignore EID */ int ie_type = ast_event_iterator_get_ie_type(&iterator); if (ie_type != AST_EVENT_IE_CEL_EVENT_TIME_USEC - && ie_type != AST_EVENT_IE_EID && ie_type != AST_EVENT_IE_CEL_EVENT_TIME && !match_ie_val(received, expected, ie_type)) { ast_test_status_update(test, "Failed matching on field %s\n", ast_event_get_ie_type_name(ie_type)); @@ -1796,7 +1783,7 @@ static int dump_event(struct ast_test *test, struct ast_event *event) return 0; } - ast_test_status_update(test, "Event: %s %s\n", ast_event_get_type_name(event), + ast_test_status_update(test, "Event: %s\n", ast_cel_get_type_name(ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE))); do { @@ -1810,9 +1797,6 @@ static int dump_event(struct ast_test *test, struct ast_event *event) switch (ie_pltype) { case AST_EVENT_IE_PLTYPE_UNKNOWN: - case AST_EVENT_IE_PLTYPE_EXISTS: - ast_test_status_update(test, "%s\n", ie_type_name); - break; case AST_EVENT_IE_PLTYPE_STR: ast_test_status_update(test, "%.30s: %s\n", ie_type_name, ast_event_iterator_get_ie_str(&i)); @@ -1821,9 +1805,6 @@ static int dump_event(struct ast_test *test, struct ast_event *event) ast_test_status_update(test, "%.30s: %u\n", ie_type_name, ast_event_iterator_get_ie_uint(&i)); break; - case AST_EVENT_IE_PLTYPE_BITFLAGS: - ast_test_status_update(test, "%.30s: %u\n", ie_type_name, - ast_event_iterator_get_ie_bitflags(&i)); default: break; } diff --git a/tests/test_event.c b/tests/test_event.c index 9a4c2419fa6eee982ab88040187c8e615d5dcd01..10282b5cce50c4f2450f5850e9c8000b9a749685 100644 --- a/tests/test_event.c +++ b/tests/test_event.c @@ -25,21 +25,14 @@ * \ingroup tests * * \todo API Calls not yet touched by a test: XXX TODO - * - ast_event_queue_and_cache() - * - ast_event_get_cached() * - ast_event_report_subs() - * - ast_event_dump_cache() * - ast_event_get_ie_type_name() * - ast_event_get_ie_pltype() - * - ast_event_str_to_event_type() - * - ast_event_str_to_ie_type() * - ast_event_iterator_init() * - ast_event_iterator_next() * - ast_event_iterator_get_ie_type() * - ast_event_iterator_get_ie_uint() - * - ast_event_iterator_get_ie_bitflags() * - ast_event_iterator_get_ie_str() - * - ast_event_iterator_get_ie_raw() */ /*** MODULEINFO @@ -58,7 +51,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") static int check_event(struct ast_event *event, struct ast_test *test, enum ast_event_type expected_type, const char *type_name, - const char *str, uint32_t uint, uint32_t bitflags) + const char *str, uint32_t uint) { enum ast_event_type type; const void *foo; @@ -71,46 +64,27 @@ static int check_event(struct ast_event *event, struct ast_test *test, return -1; } - /* Check #2: Check string representation of event type */ - if (strcmp(type_name, ast_event_get_type_name(event))) { - ast_test_status_update(test, "Didn't get expected type name: '%s' != '%s'\n", - type_name, ast_event_get_type_name(event)); - return -1; - } - - /* Check #3: Check for automatically included EID */ - if (memcmp(&ast_eid_default, ast_event_get_ie_raw(event, AST_EVENT_IE_EID), sizeof(ast_eid_default))) { - ast_test_status_update(test, "Failed to get EID\n"); - return -1; - } - /* Check #4: Check for the string IE */ - if (strcmp(str, ast_event_get_ie_str(event, AST_EVENT_IE_MAILBOX))) { + if (strcmp(str, ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME))) { ast_test_status_update(test, "Failed to get string IE.\n"); return -1; } /* Check #5: Check for the uint IE */ - if (uint != ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS)) { + if (uint != ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_AMAFLAGS)) { ast_test_status_update(test, "Failed to get uint IE.\n"); return -1; } - /* Check #6: Check for the bitflags IE */ - if (bitflags != ast_event_get_ie_bitflags(event, AST_EVENT_IE_OLDMSGS)) { - ast_test_status_update(test, "Failed to get bitflags IE.\n"); - return -1; - } - - /* Check #7: Check if a check for a str IE that isn't there works */ - if ((foo = ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE))) { - ast_test_status_update(test, "DEVICE IE check returned non-NULL %p\n", foo); + /* Check #6: Check if a check for a str IE that isn't there works */ + if ((foo = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNAME))) { + ast_test_status_update(test, "CEL_CIDNAME IE check returned non-NULL %p\n", foo); return -1; } - /* Check #8: Check if a check for a uint IE that isn't there returns 0 */ - if (ast_event_get_ie_uint(event, AST_EVENT_IE_STATE)) { - ast_test_status_update(test, "OLDMSGS IE should be 0\n"); + /* Check #7: Check if a check for a uint IE that isn't there returns 0 */ + if (ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC)) { + ast_test_status_update(test, "UNIQUEID IE should be 0\n"); return -1; } @@ -130,7 +104,6 @@ AST_TEST_DEFINE(event_new_test) static const enum ast_event_type type = AST_EVENT_CUSTOM; static const char str[] = "SIP/alligatormittens"; static const uint32_t uint = 0xb00bface; - static const uint32_t bitflags = 0x12488421; switch (cmd) { case TEST_INIT: @@ -160,34 +133,27 @@ AST_TEST_DEFINE(event_new_test) goto return_cleanup; } - if (ast_event_append_ie_str(&event, AST_EVENT_IE_MAILBOX, str)) { + if (ast_event_append_ie_str(&event, AST_EVENT_IE_CEL_USEREVENT_NAME, str)) { ast_test_status_update(test, "Failed to append str IE\n"); res = AST_TEST_FAIL; goto return_cleanup; } - if (ast_event_append_ie_uint(&event, AST_EVENT_IE_NEWMSGS, uint)) { + if (ast_event_append_ie_uint(&event, AST_EVENT_IE_CEL_AMAFLAGS, uint)) { ast_test_status_update(test, "Failed to append uint IE\n"); res = AST_TEST_FAIL; goto return_cleanup; } - if (ast_event_append_ie_bitflags(&event, AST_EVENT_IE_OLDMSGS, bitflags)) { - ast_test_status_update(test, "Failed to append bitflags IE\n"); - res = AST_TEST_FAIL; - goto return_cleanup; - } - - if (check_event(event, test, type, "Custom", str, uint, bitflags)) { + if (check_event(event, test, type, "Custom", str, uint)) { ast_test_status_update(test, "Dynamically generated event broken\n"); res = AST_TEST_FAIL; goto return_cleanup; } event2 = ast_event_new(type, - AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, str, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, uint, - AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_BITFLAGS, bitflags, + AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_PLTYPE_STR, str, + AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, uint, AST_EVENT_IE_END); if (!event2) { @@ -196,7 +162,7 @@ AST_TEST_DEFINE(event_new_test) goto return_cleanup; } - if (check_event(event2, test, type, "Custom", str, uint, bitflags)) { + if (check_event(event2, test, type, "Custom", str, uint)) { ast_test_status_update(test, "Statically generated event broken\n"); res = AST_TEST_FAIL; goto return_cleanup; @@ -240,7 +206,6 @@ enum test_subs_class_type { TEST_SUBS_CUSTOM_STR, TEST_SUBS_CUSTOM_RAW, TEST_SUBS_CUSTOM_UINT, - TEST_SUBS_CUSTOM_BITFLAGS, TEST_SUBS_CUSTOM_EXISTS, TEST_SUBS_CUSTOM_DYNAMIC, TEST_SUBS_CUSTOM_ANY, @@ -268,8 +233,6 @@ static const char *test_subs_class_type_str(enum test_subs_class_type val) return "TEST_SUBS_CUSTOM_RAW"; case TEST_SUBS_CUSTOM_UINT: return "TEST_SUBS_CUSTOM_UINT"; - case TEST_SUBS_CUSTOM_BITFLAGS: - return "TEST_SUBS_CUSTOM_BITFLAGS"; case TEST_SUBS_CUSTOM_EXISTS: return "TEST_SUBS_CUSTOM_EXISTS"; case TEST_SUBS_CUSTOM_DYNAMIC: @@ -312,9 +275,6 @@ AST_TEST_DEFINE(event_sub_test) [TEST_SUBS_CUSTOM_UINT] = { .expected_count = 1, }, - [TEST_SUBS_CUSTOM_BITFLAGS] = { - .expected_count = 4, - }, [TEST_SUBS_CUSTOM_EXISTS] = { .expected_count = 2, }, @@ -322,7 +282,7 @@ AST_TEST_DEFINE(event_sub_test) .expected_count = 1, }, [TEST_SUBS_CUSTOM_ANY] = { - .expected_count = 6, + .expected_count = 5, }, }; @@ -351,12 +311,12 @@ AST_TEST_DEFINE(event_sub_test) /* * Subscription TEST_SUBS_CUSTOM_STR: * - allocate normally - * - subscribe to CUSTOM events with a DEVICE STR IE check + * - subscribe to CUSTOM events with a CEL_CIDNAME STR IE check */ ast_test_status_update(test, "Adding TEST_SUBS_CUSTOM_STR subscription\n"); test_subs[TEST_SUBS_CUSTOM_STR].sub = ast_event_subscribe(AST_EVENT_CUSTOM, event_sub_cb, test_subs_class_type_str(TEST_SUBS_CUSTOM_STR), &test_subs[TEST_SUBS_CUSTOM_STR].data, - AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "FOO/bar", + AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_PLTYPE_STR, "FOO/bar", AST_EVENT_IE_END); if (!test_subs[TEST_SUBS_CUSTOM_STR].sub) { ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_STR subscription\n"); @@ -364,14 +324,6 @@ AST_TEST_DEFINE(event_sub_test) goto return_cleanup; } - if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_STR].sub), - test_subs_class_type_str(TEST_SUBS_CUSTOM_STR))) { - ast_test_status_update(test, - "Unexpected subscription description on TEST_SUBS_CUSTOM_STR subscription\n"); - res = AST_TEST_FAIL; - goto return_cleanup; - } - ast_test_status_update(test, "Check that a CUSTOM subscriber exists\n"); sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM, AST_EVENT_IE_END); @@ -384,12 +336,12 @@ AST_TEST_DEFINE(event_sub_test) /* * Subscription TEST_SUBS_ALL_STR: * - allocate normally - * - subscribe to ALL events with a DEVICE STR IE check + * - subscribe to ALL events with a CEL_CIDNAME STR IE check */ ast_test_status_update(test, "Adding TEST_SUBS_ALL_STR subscription\n"); test_subs[TEST_SUBS_ALL_STR].sub = ast_event_subscribe(AST_EVENT_ALL, event_sub_cb, test_subs_class_type_str(TEST_SUBS_ALL_STR), &test_subs[TEST_SUBS_ALL_STR].data, - AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "FOO/bar", + AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_PLTYPE_STR, "FOO/bar", AST_EVENT_IE_END); if (!test_subs[TEST_SUBS_ALL_STR].sub) { ast_test_status_update(test, "Failed to create TEST_SUBS_ALL_STR subscription\n"); @@ -397,23 +349,15 @@ AST_TEST_DEFINE(event_sub_test) goto return_cleanup; } - if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_ALL_STR].sub), - test_subs_class_type_str(TEST_SUBS_ALL_STR))) { - ast_test_status_update(test, - "Unexpected subscription description on TEST_SUBS_ALL_STR subscription\n"); - res = AST_TEST_FAIL; - goto return_cleanup; - } - /* * Subscription TEST_SUBS_CUSTOM_RAW: * - allocate normally - * - subscribe to CUSTOM events with a MAILBOX RAW IE check + * - subscribe to CUSTOM events with a CEL_USEREVENT_NAME RAW IE check */ ast_test_status_update(test, "Adding TEST_SUBS_CUSTOM_RAW subscription\n"); test_subs[TEST_SUBS_CUSTOM_RAW].sub = ast_event_subscribe(AST_EVENT_CUSTOM, event_sub_cb, test_subs_class_type_str(TEST_SUBS_CUSTOM_RAW), &test_subs[TEST_SUBS_CUSTOM_RAW].data, - AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar"), + AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar"), AST_EVENT_IE_END); if (!test_subs[TEST_SUBS_CUSTOM_RAW].sub) { ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_RAW subscription\n"); @@ -421,23 +365,15 @@ AST_TEST_DEFINE(event_sub_test) goto return_cleanup; } - if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_RAW].sub), - test_subs_class_type_str(TEST_SUBS_CUSTOM_RAW))) { - ast_test_status_update(test, - "Unexpected subscription description on TEST_SUBS_CUSTOM_RAW subscription\n"); - res = AST_TEST_FAIL; - goto return_cleanup; - } - /* * Subscription TEST_SUBS_CUSTOM_UINT: * - allocate normally - * - subscribe to CUSTOM events with a NEWMSGS UINT IE check + * - subscribe to CUSTOM events with a CEL_AMAFLAGS UINT IE check */ ast_test_status_update(test, "Adding TEST_SUBS_CUSTOM_UINT subscription\n"); test_subs[TEST_SUBS_CUSTOM_UINT].sub = ast_event_subscribe(AST_EVENT_CUSTOM, event_sub_cb, test_subs_class_type_str(TEST_SUBS_CUSTOM_UINT), &test_subs[TEST_SUBS_CUSTOM_UINT].data, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, 5, + AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, 5, AST_EVENT_IE_END); if (!test_subs[TEST_SUBS_CUSTOM_UINT].sub) { ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_UINT subscription\n"); @@ -445,48 +381,15 @@ AST_TEST_DEFINE(event_sub_test) goto return_cleanup; } - if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_UINT].sub), - test_subs_class_type_str(TEST_SUBS_CUSTOM_UINT))) { - ast_test_status_update(test, - "Unexpected subscription description on TEST_SUBS_CUSTOM_UINT subscription\n"); - res = AST_TEST_FAIL; - goto return_cleanup; - } - - /* - * Subscription TEST_SUBS_CUSTOM_BITFLAGS: - * - allocate normally - * - subscribe to CUSTOM events with a NEWMSGS BITFLAGS IE check - */ - ast_test_status_update(test, "Adding TEST_SUBS_CUSTOM_BITFLAGS subscription\n"); - test_subs[TEST_SUBS_CUSTOM_BITFLAGS].sub = ast_event_subscribe(AST_EVENT_CUSTOM, event_sub_cb, - test_subs_class_type_str(TEST_SUBS_CUSTOM_BITFLAGS), &test_subs[TEST_SUBS_CUSTOM_BITFLAGS].data, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_BITFLAGS, 0x06, - AST_EVENT_IE_END); - if (!test_subs[TEST_SUBS_CUSTOM_BITFLAGS].sub) { - ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_BITFLAGS subscription\n"); - res = AST_TEST_FAIL; - goto return_cleanup; - } - - if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_BITFLAGS].sub), - test_subs_class_type_str(TEST_SUBS_CUSTOM_BITFLAGS))) { - ast_test_status_update(test, - "Unexpected subscription description on TEST_SUBS_CUSTOM_BITFLAGS subscription\n"); - res = AST_TEST_FAIL; - goto return_cleanup; - } - /* * Subscription TEST_SUBS_CUSTOM_EXISTS: * - allocate normally - * - subscribe to CUSTOM events with a NEWMSGS UINT and OLDMSGS EXISTS IE check + * - subscribe to CUSTOM events with a CEL_AMAFLAGS UINT and UNIQUEID EXISTS IE check */ ast_test_status_update(test, "Adding TEST_SUBS_CUSTOM_EXISTS subscription\n"); test_subs[TEST_SUBS_CUSTOM_EXISTS].sub = ast_event_subscribe(AST_EVENT_CUSTOM, event_sub_cb, test_subs_class_type_str(TEST_SUBS_CUSTOM_EXISTS), &test_subs[TEST_SUBS_CUSTOM_EXISTS].data, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, 4, - AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_EXISTS, + AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, 4, AST_EVENT_IE_END); if (!test_subs[TEST_SUBS_CUSTOM_EXISTS].sub) { ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_EXISTS subscription\n"); @@ -494,14 +397,6 @@ AST_TEST_DEFINE(event_sub_test) goto return_cleanup; } - if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_EXISTS].sub), - test_subs_class_type_str(TEST_SUBS_CUSTOM_EXISTS))) { - ast_test_status_update(test, - "Unexpected subscription description on TEST_SUBS_CUSTOM_EXISTS subscription\n"); - res = AST_TEST_FAIL; - goto return_cleanup; - } - /* For the sake of exercising destruction before activation */ test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = ast_event_subscribe_new(AST_EVENT_CUSTOM, event_sub_cb, &test_subs[TEST_SUBS_CUSTOM_DYNAMIC].data); @@ -527,17 +422,7 @@ AST_TEST_DEFINE(event_sub_test) goto return_cleanup; } - if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub), - "")) { - ast_event_sub_destroy(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub); - test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = NULL; - ast_test_status_update(test, - "Unexpected subscription description on TEST_SUBS_CUSTOM_DYNAMIC subscription\n"); - res = AST_TEST_FAIL; - goto return_cleanup; - } - - if (ast_event_sub_append_ie_uint(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub, AST_EVENT_IE_NEWMSGS, 4)) { + if (ast_event_sub_append_ie_uint(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub, AST_EVENT_IE_CEL_AMAFLAGS, 4)) { ast_event_sub_destroy(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub); test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = NULL; ast_test_status_update(test, "Failed to append UINT IE to TEST_SUBS_CUSTOM_DYNAMIC subscription\n"); @@ -545,15 +430,7 @@ AST_TEST_DEFINE(event_sub_test) goto return_cleanup; } - if (ast_event_sub_append_ie_bitflags(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub, AST_EVENT_IE_OLDMSGS, 1)) { - ast_event_sub_destroy(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub); - test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = NULL; - ast_test_status_update(test, "Failed to append BITFLAGS IE to TEST_SUBS_CUSTOM_DYNAMIC subscription\n"); - res = AST_TEST_FAIL; - goto return_cleanup; - } - - if (ast_event_sub_append_ie_str(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub, AST_EVENT_IE_DEVICE, "FOO/bar")) { + if (ast_event_sub_append_ie_str(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub, AST_EVENT_IE_CEL_CIDNAME, "FOO/bar")) { ast_event_sub_destroy(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub); test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = NULL; ast_test_status_update(test, "Failed to append STR IE to TEST_SUBS_CUSTOM_DYNAMIC subscription\n"); @@ -561,7 +438,7 @@ AST_TEST_DEFINE(event_sub_test) goto return_cleanup; } - if (ast_event_sub_append_ie_raw(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub, AST_EVENT_IE_MAILBOX, "800 km", + if (ast_event_sub_append_ie_raw(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub, AST_EVENT_IE_CEL_USEREVENT_NAME, "800 km", strlen("800 km"))) { ast_event_sub_destroy(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub); test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = NULL; @@ -570,14 +447,6 @@ AST_TEST_DEFINE(event_sub_test) goto return_cleanup; } - if (ast_event_sub_append_ie_exists(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub, AST_EVENT_IE_STATE)) { - ast_event_sub_destroy(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub); - test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = NULL; - ast_test_status_update(test, "Failed to append EXISTS IE to TEST_SUBS_CUSTOM_DYNAMIC subscription\n"); - res = AST_TEST_FAIL; - goto return_cleanup; - } - if (ast_event_sub_activate(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub)) { ast_event_sub_destroy(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub); test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = NULL; @@ -593,34 +462,15 @@ AST_TEST_DEFINE(event_sub_test) /* Check STR matching. */ sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM, - AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "FOO/bar", + AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_PLTYPE_STR, "FOO/bar", AST_EVENT_IE_END); if (sub_res != AST_EVENT_SUB_EXISTS) { ast_test_status_update(test, "Str FOO/bar subscription did not exist\n"); res = AST_TEST_FAIL; } - /* Make sure that the tech portion of the device string is case-insensitive */ - sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM, - AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "foo/bar", - AST_EVENT_IE_END); - if (sub_res != AST_EVENT_SUB_EXISTS) { - ast_test_status_update(test, "Str FOO/bar subscription lacks proper case-sensitivity for device strings\n"); - res = AST_TEST_FAIL; - } - - /* Make sure that the non-tech portion of the device string is case-sensitive - * and fails to match appropriately */ - sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM, - AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "FOO/BAR", - AST_EVENT_IE_END); - if (sub_res == AST_EVENT_SUB_EXISTS) { - ast_test_status_update(test, "Str FOO/bar subscription lacks proper case-sensitivity for device strings\n"); - res = AST_TEST_FAIL; - } - sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM, - AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "Money", + AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_PLTYPE_STR, "Money", AST_EVENT_IE_END); if (sub_res != AST_EVENT_SUB_NONE) { ast_test_status_update(test, "Str Money subscription should not exist! (%d)\n", @@ -630,7 +480,7 @@ AST_TEST_DEFINE(event_sub_test) /* Check RAW matching. */ sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM, - AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar"), + AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar"), AST_EVENT_IE_END); if (sub_res != AST_EVENT_SUB_EXISTS) { ast_test_status_update(test, "Raw FOO/bar subscription did not exist\n"); @@ -638,7 +488,7 @@ AST_TEST_DEFINE(event_sub_test) } sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM, - AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar") - 1, + AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar") - 1, AST_EVENT_IE_END); if (sub_res != AST_EVENT_SUB_NONE) { ast_test_status_update(test, "Raw FOO/bar-1 subscription should not exist! (%d)\n", @@ -647,7 +497,7 @@ AST_TEST_DEFINE(event_sub_test) } sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM, - AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_RAW, "Monkeys", sizeof("Monkeys"), + AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_PLTYPE_RAW, "Monkeys", sizeof("Monkeys"), AST_EVENT_IE_END); if (sub_res != AST_EVENT_SUB_NONE) { ast_test_status_update(test, "Raw Monkeys subscription should not exist! (%d)\n", @@ -657,7 +507,7 @@ AST_TEST_DEFINE(event_sub_test) /* Check UINT matching. */ sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, 5, + AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, 5, AST_EVENT_IE_END); if (sub_res != AST_EVENT_SUB_EXISTS) { ast_test_status_update(test, "UINT=5 subscription did not exist\n"); @@ -665,7 +515,7 @@ AST_TEST_DEFINE(event_sub_test) } sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, 1, + AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, 1, AST_EVENT_IE_END); if (sub_res != AST_EVENT_SUB_NONE) { ast_test_status_update(test, "UINT=1 subscription should not exist! (%d)\n", @@ -673,43 +523,6 @@ AST_TEST_DEFINE(event_sub_test) res = AST_TEST_FAIL; } - /* Check BITFLAGS matching. */ - sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_BITFLAGS, 2, - AST_EVENT_IE_END); - if (sub_res != AST_EVENT_SUB_EXISTS) { - ast_test_status_update(test, "BITFLAGS=2 subscription did not exist\n"); - res = AST_TEST_FAIL; - } - - sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_BITFLAGS, 8, - AST_EVENT_IE_END); - if (sub_res != AST_EVENT_SUB_NONE) { - ast_test_status_update(test, "BITFLAGS=8 subscription should not exist! (%d)\n", - sub_res); - res = AST_TEST_FAIL; - } - - /* Check EXISTS matching. */ - sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, 4, - AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, 100, - AST_EVENT_IE_END); - if (sub_res != AST_EVENT_SUB_EXISTS) { - ast_test_status_update(test, "EXISTS subscription did not exist\n"); - res = AST_TEST_FAIL; - } - - sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, 4, - AST_EVENT_IE_END); - if (sub_res != AST_EVENT_SUB_NONE) { - ast_test_status_update(test, "EXISTS subscription should not exist! (%d)\n", - sub_res); - res = AST_TEST_FAIL; - } - ast_test_status_update(test, "Special event posting test\n"); /* @@ -719,8 +532,8 @@ AST_TEST_DEFINE(event_sub_test) * TEST_SUBS_CUSTOM_RAW */ event = ast_event_new(AST_EVENT_CUSTOM, - AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "Mula", - AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar"), + AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_PLTYPE_STR, "Mula", + AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar"), AST_EVENT_IE_END); if (!event) { ast_test_status_update(test, "Failed to create event\n"); @@ -753,14 +566,6 @@ AST_TEST_DEFINE(event_sub_test) goto return_cleanup; } - if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_ANY].sub), - test_subs_class_type_str(TEST_SUBS_CUSTOM_ANY))) { - ast_test_status_update(test, - "Unexpected subscription description on TEST_SUBS_CUSTOM_ANY subscription\n"); - res = AST_TEST_FAIL; - goto return_cleanup; - } - /* * Fire off some events and track what was received in the callback */ @@ -775,8 +580,8 @@ AST_TEST_DEFINE(event_sub_test) * TEST_SUBS_CUSTOM_ANY */ event = ast_event_new(AST_EVENT_CUSTOM, - AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar") - 1, - AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "FOO/bar", + AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar") - 1, + AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_PLTYPE_STR, "FOO/bar", AST_EVENT_IE_END); if (!event) { ast_test_status_update(test, "Failed to create event\n"); @@ -799,8 +604,8 @@ AST_TEST_DEFINE(event_sub_test) * TEST_SUBS_CUSTOM_ANY */ event = ast_event_new(AST_EVENT_CUSTOM, - AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "Misery", - AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar"), + AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_PLTYPE_STR, "Misery", + AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar"), AST_EVENT_IE_END); if (!event) { ast_test_status_update(test, "Failed to create event\n"); @@ -820,34 +625,10 @@ AST_TEST_DEFINE(event_sub_test) * * Matching subscriptions: * TEST_SUBS_CUSTOM_UINT - * TEST_SUBS_CUSTOM_BITFLAGS - * TEST_SUBS_CUSTOM_ANY - */ - event = ast_event_new(AST_EVENT_CUSTOM, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, 5, - AST_EVENT_IE_END); - if (!event) { - ast_test_status_update(test, "Failed to create event\n"); - res = AST_TEST_FAIL; - goto return_cleanup; - } - if (ast_event_queue(event)) { - ast_event_destroy(event); - event = NULL; - ast_test_status_update(test, "Failed to queue event\n"); - res = AST_TEST_FAIL; - goto return_cleanup; - } - - /* - * Event to check BITFLAGS matching. - * - * Matching subscriptions: - * TEST_SUBS_CUSTOM_BITFLAGS * TEST_SUBS_CUSTOM_ANY */ event = ast_event_new(AST_EVENT_CUSTOM, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, 4, + AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, 5, AST_EVENT_IE_END); if (!event) { ast_test_status_update(test, "Failed to create event\n"); @@ -867,12 +648,11 @@ AST_TEST_DEFINE(event_sub_test) * * Matching subscriptions: * TEST_SUBS_CUSTOM_EXISTS - * TEST_SUBS_CUSTOM_BITFLAGS * TEST_SUBS_CUSTOM_ANY */ event = ast_event_new(AST_EVENT_CUSTOM, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, 4, - AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, 4, + AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, 4, + AST_EVENT_IE_UNIQUEID, AST_EVENT_IE_PLTYPE_UINT, 4, AST_EVENT_IE_END); if (!event) { ast_test_status_update(test, "Failed to create event\n"); @@ -892,18 +672,17 @@ AST_TEST_DEFINE(event_sub_test) * * Matching subscriptions: * TEST_SUBS_CUSTOM_DYNAMIC - * TEST_SUBS_CUSTOM_BITFLAGS * TEST_SUBS_CUSTOM_EXISTS * TEST_SUBS_ALL_STR * TEST_SUBS_CUSTOM_STR * TEST_SUBS_CUSTOM_ANY */ event = ast_event_new(AST_EVENT_CUSTOM, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, 4, - AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, 5, - AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_RAW, "800 km", strlen("800 km"), - AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "FOO/bar", - AST_EVENT_IE_STATE, AST_EVENT_IE_PLTYPE_UINT, 5, + AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, 4, + AST_EVENT_IE_UNIQUEID, AST_EVENT_IE_PLTYPE_UINT, 5, + AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_PLTYPE_RAW, "800 km", strlen("800 km"), + AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_PLTYPE_STR, "FOO/bar", + AST_EVENT_IE_CEL_EVENT_TIME_USEC, AST_EVENT_IE_PLTYPE_UINT, 5, AST_EVENT_IE_END); if (!event) { ast_test_status_update(test, "Failed to create event\n");