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
This commit is contained in:
Kinsey Moore
2014-08-06 12:55:28 +00:00
parent ac5c75b45d
commit f1036f40dc
39 changed files with 708 additions and 73 deletions

View File

@@ -273,6 +273,15 @@ struct stasis_message_vtable {
struct stasis_message *message);
};
/*!
* \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.
*
@@ -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
@@ -297,6 +309,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.
*
@@ -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; \
})
/*!