summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2016-04-29 14:33:01 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2016-04-29 14:33:01 -0500
commitbc19d9a2b0361f1aa5b3f8426bacfaf1300a1193 (patch)
treea4acdbd0fe393ea01cd1747be31b86a9f12d1e9a
parentd57847a7c792e0d12919e542076ef4818252fc39 (diff)
parent0b5292525cce32e9944b02b17748c4c7ec89ede3 (diff)
Merge "res_pjsip_exten_state: Check if body generator is available."
-rw-r--r--include/asterisk/res_pjsip_pubsub.h13
-rw-r--r--res/res_pjsip_exten_state.c6
-rw-r--r--res/res_pjsip_pubsub.c5
3 files changed, 24 insertions, 0 deletions
diff --git a/include/asterisk/res_pjsip_pubsub.h b/include/asterisk/res_pjsip_pubsub.h
index 94576d38b..4f9a7633a 100644
--- a/include/asterisk/res_pjsip_pubsub.h
+++ b/include/asterisk/res_pjsip_pubsub.h
@@ -649,6 +649,19 @@ int ast_sip_pubsub_generate_body_content(const char *content_type,
const char *content_subtype, struct ast_sip_body_data *data, struct ast_str **str);
/*!
+ * \brief Is a body generator registered for the given type/subtype.
+ * \since 14.0.0
+ *
+ * \param type The content type of the body
+ * \param subtype The content subtype of the body
+ *
+ * \note In "plain/text", "plain" is the type and "text" is the subtype.
+ *
+ * \retval non-zero if a generator is registered.
+ */
+int ast_sip_pubsub_is_body_generator_registered(const char *type, const char *subtype);
+
+/*!
* \since 13.0.0
* \brief Register a body generator with the pubsub core.
*
diff --git a/res/res_pjsip_exten_state.c b/res/res_pjsip_exten_state.c
index 555402469..6b4e758d3 100644
--- a/res/res_pjsip_exten_state.c
+++ b/res/res_pjsip_exten_state.c
@@ -680,6 +680,12 @@ static int publisher_start(struct ast_sip_outbound_publish *configuration, struc
return -1;
}
+ if (!ast_sip_pubsub_is_body_generator_registered(body_type, body_subtype)) {
+ ast_log(LOG_ERROR, "Outbound extension state publisher '%s': '%s' body generator not registered\n",
+ name, body_full);
+ return -1;
+ }
+
name_size = strlen(name) + 1;
body_type_size = strlen(body_type) + 1;
body_subtype_size = strlen(body_subtype) + 1;
diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c
index dc49a5fd3..755a154a5 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -3094,6 +3094,11 @@ const char *ast_sip_publication_get_event_configuration(const struct ast_sip_pub
return pub->event_configuration_name;
}
+int ast_sip_pubsub_is_body_generator_registered(const char *type, const char *subtype)
+{
+ return !!find_body_generator_type_subtype(type, subtype);
+}
+
int ast_sip_pubsub_register_body_generator(struct ast_sip_pubsub_body_generator *generator)
{
struct ast_sip_pubsub_body_generator *existing;