summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2014-09-18 15:55:13 +0000
committerMark Michelson <mmichelson@digium.com>2014-09-18 15:55:13 +0000
commit7a35800551924018bf7edd079e101e7bfe810eb7 (patch)
treed6900c09972b8d847c7fdea8e24f76055702a3a8 /include
parenta2482acdce9cdcdbdf2b532a591992212c88cd09 (diff)
res_pjsip_pubsub: Add some type safety when generating NOTIFY bodies.
res_pjsip_pubsub has two separate checks that it makes when a SUBSCRIBE arrives. * It checks that there is a subscription handler for the Event * It checks that there are body generators for the types in the Accept header The problem is, there's nothing that ensures that these two things will actually mesh with each other. For instance, Asterisk will accept a subscription to MWI that accepts pidf+xml bodies. That doesn't make sense. With this commit, we add some type information to the mix. Subscription handlers state they generate data of type X, and body generators state that they consume data of type X. This way, Asterisk doesn't end up in some hilariously mismatched situation like the one in the previous paragraph. ASTERISK-24136 #close Reported by Mark Michelson Review: https://reviewboard.asterisk.org/r/3877 Review: https://reviewboard.asterisk.org/r/3878 ........ Merged revisions 423344 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@423348 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/res_pjsip_pubsub.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/include/asterisk/res_pjsip_pubsub.h b/include/asterisk/res_pjsip_pubsub.h
index 73b987479..aac4261c1 100644
--- a/include/asterisk/res_pjsip_pubsub.h
+++ b/include/asterisk/res_pjsip_pubsub.h
@@ -214,6 +214,21 @@ enum ast_sip_subscription_notify_reason {
AST_SIP_SUBSCRIPTION_NOTIFY_REASON_OTHER
};
+/*! Type used for conveying mailbox state */
+#define AST_SIP_EXTEN_STATE_DATA "ast_sip_exten_state_data"
+/*! Type used for extension state/presence */
+#define AST_SIP_MESSAGE_ACCUMULATOR "ast_sip_message_accumulator"
+
+/*!
+ * \brief Data used to create bodies for NOTIFY/PUBLISH requests.
+ */
+struct ast_sip_body_data {
+ /*! The type of the data */
+ const char *body_type;
+ /*! The actual data from which the body is generated */
+ void *body_data;
+};
+
struct ast_sip_notifier {
/*!
* \brief Default body type defined for the event package this notifier handles.
@@ -285,6 +300,8 @@ struct ast_sip_subscriber {
struct ast_sip_subscription_handler {
/*! The name of the event this subscriber deals with */
const char *event_name;
+ /*! Type of data used to generate NOTIFY bodies */
+ const char *body_type;
/*! The types of body this subscriber accepts. */
const char *accept[AST_SIP_MAX_ACCEPT];
/*!
@@ -359,7 +376,7 @@ struct ast_taskprocessor *ast_sip_subscription_get_serializer(struct ast_sip_sub
* \retval 0 Success
* \retval non-zero Failure
*/
-int ast_sip_subscription_notify(struct ast_sip_subscription *sub, void *notify_data, int terminate);
+int ast_sip_subscription_notify(struct ast_sip_subscription *sub, struct ast_sip_body_data *notify_data, int terminate);
/*!
* \brief Retrieve the local URI for this subscription
@@ -501,6 +518,8 @@ struct ast_sip_pubsub_body_generator {
* In "plain/text", "text" is the subtype
*/
const char *subtype;
+ /*! Type of data the body generator takes as input */
+ const char *body_type;
/*!
* \brief allocate body structure.
*
@@ -597,7 +616,7 @@ struct ast_sip_pubsub_body_supplement {
* \retval non-zero Failure
*/
int ast_sip_pubsub_generate_body_content(const char *content_type,
- const char *content_subtype, void *data, struct ast_str **str);
+ const char *content_subtype, struct ast_sip_body_data *data, struct ast_str **str);
/*!
* \since 13.0.0