summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2014-08-06 12:55:28 +0000
committerKinsey Moore <kmoore@digium.com>2014-08-06 12:55:28 +0000
commitf1036f40dc22c4d4b30cc2ab36199cd749ead9c5 (patch)
tree4fd17b406cb14b5eee97cf0be44382b792ccbff9 /include
parentac5c75b45d9d7fe047ccd9d1d094cb9d30df8b51 (diff)
Stasis: Allow message types to be blocked
This introduces stasis.conf and a mechanism to prevent certain message types from being published. Internally, this works by preventing the chosen message types from being created which ensures that those message types can never be published. This patch also adjusts message publishers such that message payloads are not created if the related message type is not available. ASTERISK-23943 #close Review: https://reviewboard.asterisk.org/r/3823/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@420124 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/stasis.h35
1 files changed, 28 insertions, 7 deletions
diff --git a/include/asterisk/stasis.h b/include/asterisk/stasis.h
index 4c4052c14..b8dc4c845 100644
--- a/include/asterisk/stasis.h
+++ b/include/asterisk/stasis.h
@@ -274,6 +274,15 @@ struct stasis_message_vtable {
};
/*!
+ * \brief Return code for Stasis message type creation attempts
+ */
+enum stasis_message_type_result {
+ STASIS_MESSAGE_TYPE_ERROR = -1, /*!< Message type was not created due to allocation failure */
+ STASIS_MESSAGE_TYPE_SUCCESS, /*!< Message type was created successfully */
+ STASIS_MESSAGE_TYPE_DECLINED, /*!< Message type was not created due to configuration */
+};
+
+/*!
* \brief Create a new message type.
*
* \ref stasis_message_type is an AO2 object, so ao2_cleanup() when you're done
@@ -281,12 +290,15 @@ struct stasis_message_vtable {
*
* \param name Name of the new type.
* \param vtable Virtual table of message methods. May be \c NULL.
- * \return Pointer to the new type.
- * \return \c NULL on error.
+ * \param[out] result The location where the new message type will be placed
+ *
+ * \note Stasis message type creation may be declined if the message type is disabled
+ *
+ * \returns A stasis_message_type_result enum
* \since 12
*/
-struct stasis_message_type *stasis_message_type_create(const char *name,
- struct stasis_message_vtable *vtable);
+enum stasis_message_type_result stasis_message_type_create(const char *name,
+ struct stasis_message_vtable *vtable, struct stasis_message_type **result);
/*!
* \brief Gets the name of a given message type
@@ -298,6 +310,16 @@ struct stasis_message_type *stasis_message_type_create(const char *name,
const char *stasis_message_type_name(const struct stasis_message_type *type);
/*!
+ * \brief Check whether a message type is declined
+ *
+ * \param name The name of the message type to check
+ *
+ * \retval zero The message type is not declined
+ * \retval non-zero The message type is declined
+ */
+int stasis_message_type_declined(const char *name);
+
+/*!
* \brief Create a new message.
*
* This message is an \c ao2 object, and must be ao2_cleanup()'ed when you are done
@@ -1184,9 +1206,8 @@ void stasis_log_bad_type_access(const char *name);
#define STASIS_MESSAGE_TYPE_INIT(name) \
({ \
ast_assert(_priv_ ## name == NULL); \
- _priv_ ## name = stasis_message_type_create(#name, \
- &_priv_ ## name ## _v); \
- _priv_ ## name ? 0 : -1; \
+ stasis_message_type_create(#name, \
+ &_priv_ ## name ## _v, &_priv_ ## name) == STASIS_MESSAGE_TYPE_ERROR ? 1 : 0; \
})
/*!