diff options
author | Kevin P. Fleming <kpfleming@digium.com> | 2009-05-03 14:28:59 +0000 |
---|---|---|
committer | Kevin P. Fleming <kpfleming@digium.com> | 2009-05-03 14:28:59 +0000 |
commit | 73743b77b0644be36f8712d0a94289de0263aaf8 (patch) | |
tree | 08c6ed6c14fc54caf70ece336f9f0ab9cc2f272a /include/asterisk | |
parent | 7b24f998084f8f2545815b36fcf521eb50107308 (diff) |
Add 'bitflags'-style information elements to event framework
This patch add a new payload type for information elements, a set
of bit flags. The payload is transported as a 32-bit unsigned integer
but when matching is performed between events and subscribers,
the matching is done by using a bitwise AND instead of numeric value
comparison.
Review: http://reviewboard.asterisk.org/r/242/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@191919 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk')
-rw-r--r-- | include/asterisk/event.h | 55 | ||||
-rw-r--r-- | include/asterisk/event_defs.h | 2 |
2 files changed, 56 insertions, 1 deletions
diff --git a/include/asterisk/event.h b/include/asterisk/event.h index ac42e5942..b9de22dd2 100644 --- a/include/asterisk/event.h +++ b/include/asterisk/event.h @@ -157,6 +157,20 @@ 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.6.3 + */ +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 * * \param sub the dynamic subscription allocated with ast_event_subscribe_new() @@ -446,6 +460,24 @@ int ast_event_append_ie_uint(struct ast_event **event, enum ast_event_ie_type ie 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 flags the flags that are the payload of the IE + * + * \retval 0 success + * \retval -1 failure + * \since 1.6.3 + * + * 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 @@ -476,6 +508,18 @@ int ast_event_append_ie_raw(struct ast_event **event, enum ast_event_ie_type ie_ 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 * * \param event The event to get the IE from @@ -614,7 +658,7 @@ int ast_event_iterator_next(struct ast_event_iterator *iterator); enum ast_event_ie_type ast_event_iterator_get_ie_type(struct ast_event_iterator *iterator); /*! - * \brief Get the value of the current IE in the ierator as an integer payload + * \brief Get the value of the current IE in the iterator as an integer payload * * \param iterator The iterator instance * @@ -623,6 +667,15 @@ 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 * * \param iterator The iterator instance diff --git a/include/asterisk/event_defs.h b/include/asterisk/event_defs.h index 3f1e3bd15..9bebfb69d 100644 --- a/include/asterisk/event_defs.h +++ b/include/asterisk/event_defs.h @@ -137,6 +137,8 @@ enum ast_event_ie_pltype { 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, }; /*! |