]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_exten_state: Check if body generator is available. 32/2732/1
authorRichard Mudgett <rmudgett@digium.com>
Tue, 26 Apr 2016 21:10:26 +0000 (16:10 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Thu, 28 Apr 2016 22:14:44 +0000 (17:14 -0500)
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

include/asterisk/res_pjsip_pubsub.h
res/res_pjsip_exten_state.c
res/res_pjsip_pubsub.c

index 84d86fb9ef4bf719860916c028424aecf81c4afa..72a3053f27edfce126459eeb67ca5c35a2c61b70 100644 (file)
@@ -648,6 +648,19 @@ struct ast_sip_pubsub_body_supplement {
 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.
index 1f8b121e85f256a2b4206d41b84d6b75c7d5b3ea..e84a25c6ae4a4439fd3a8bd1a8778d5b00d996e9 100644 (file)
@@ -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;
index 141c2fcf4051963ecc843fc1baaf5f0187f5d95c..dca2e3109722b3e79423c5541b20dcc2a0487112 100644 (file)
@@ -3086,6 +3086,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;