[asterisk-commits] res pjsip exten state: Check if body generator is available. (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 29 14:33:01 CDT 2016


Joshua Colp has submitted this change and it was merged.

Change subject: res_pjsip_exten_state: Check if body generator is available.
......................................................................


res_pjsip_exten_state: Check if body generator is available.

When starting the extension state publishers, check if the requested
message body generator is available.  If not available give error message
and skip starting that publisher.

* res_pjsip_pubsub.c: Create new API if type/subtype generator
registered.

* res_pjsip_exten_state.c: Use new body generator API for validation.

ASTERISK-25922

Change-Id: I4ad69200666e3cc909d4619e3c81042d7f9db25c
---
M include/asterisk/res_pjsip_pubsub.h
M res/res_pjsip_exten_state.c
M res/res_pjsip_pubsub.c
3 files changed, 24 insertions(+), 0 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, approved; Verified
  George Joseph: Looks good to me, but someone else must approve



diff --git a/include/asterisk/res_pjsip_pubsub.h b/include/asterisk/res_pjsip_pubsub.h
index 84d86fb..72a3053 100644
--- a/include/asterisk/res_pjsip_pubsub.h
+++ b/include/asterisk/res_pjsip_pubsub.h
@@ -649,6 +649,19 @@
 		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 1f8b121..e84a25c 100644
--- a/res/res_pjsip_exten_state.c
+++ b/res/res_pjsip_exten_state.c
@@ -680,6 +680,12 @@
 		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 141c2fc..dca2e31 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -3086,6 +3086,11 @@
 	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;

-- 
To view, visit https://gerrit.asterisk.org/2732
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4ad69200666e3cc909d4619e3c81042d7f9db25c
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-commits mailing list