<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/6565">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip: Use ast_sip_is_content_type() where appropriate<br><br>Change-Id: If3ab0d73d79ac4623308bd48508af2bfd554937d<br>---<br>M res/res_pjsip_messaging.c<br>M res/res_pjsip_publish_asterisk.c<br>M res/res_pjsip_pubsub.c<br>M res/res_pjsip_session.c<br>4 files changed, 13 insertions(+), 17 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/65/6565/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c<br>index d31e101..b6e7a64 100644<br>--- a/res/res_pjsip_messaging.c<br>+++ b/res/res_pjsip_messaging.c<br>@@ -69,8 +69,8 @@<br> &rdata->msg_info.msg->body->content_type, "text", "plain");<br> } else {<br> res = rdata->msg_info.ctype &&<br>- !pj_strcmp2(&rdata->msg_info.ctype->media.type, "text") &&<br>- !pj_strcmp2(&rdata->msg_info.ctype->media.subtype, "plain");<br>+ ast_sip_is_content_type(<br>+ &rdata->msg_info.ctype->media, "text", "plain");<br> }<br> <br> return res ? PJSIP_SC_OK : PJSIP_SC_UNSUPPORTED_MEDIA_TYPE;<br>diff --git a/res/res_pjsip_publish_asterisk.c b/res/res_pjsip_publish_asterisk.c<br>index 7e87762..fa5e4ce 100644<br>--- a/res/res_pjsip_publish_asterisk.c<br>+++ b/res/res_pjsip_publish_asterisk.c<br>@@ -605,8 +605,7 @@<br> }<br> <br> /* We only accept JSON for content */<br>- if (pj_strcmp2(&body->content_type.type, "application") ||<br>- pj_strcmp2(&body->content_type.subtype, "json")) {<br>+ if (!ast_sip_is_content_type(&body->content_type, "application", "json")) {<br> ast_debug(2, "Received unsupported content type for Asterisk event on resource '%s'\n",<br> ast_sorcery_object_get_id(config));<br> return -1;<br>@@ -697,8 +696,7 @@<br> }<br> <br> /* We only accept JSON for content */<br>- if (pj_strcmp2(&body->content_type.type, "application") ||<br>- pj_strcmp2(&body->content_type.subtype, "json")) {<br>+ if (!ast_sip_is_content_type(&body->content_type, "application", "json")) {<br> ast_debug(2, "Received unsupported content type for Asterisk event on resource '%s'\n",<br> ast_sorcery_object_get_id(config));<br> return -1;<br>diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c<br>index b0365d9..bcf8677 100644<br>--- a/res/res_pjsip_pubsub.c<br>+++ b/res/res_pjsip_pubsub.c<br>@@ -516,6 +516,8 @@<br> AST_RWLIST_HEAD_STATIC(body_generators, ast_sip_pubsub_body_generator);<br> AST_RWLIST_HEAD_STATIC(body_supplements, ast_sip_pubsub_body_supplement);<br> <br>+static pjsip_media_type rlmi_media_type;<br>+<br> static void pubsub_on_evsub_state(pjsip_evsub *sub, pjsip_event *event);<br> static void pubsub_on_rx_refresh(pjsip_evsub *sub, pjsip_rx_data *rdata,<br> int *p_st_code, pj_str_t **p_st_text, pjsip_hdr *res_hdr, pjsip_msg_body **p_body);<br>@@ -2022,8 +2024,6 @@<br> static pjsip_multipart_part *build_rlmi_body(pj_pool_t *pool, struct ast_sip_subscription *sub,<br> struct body_part_list *body_parts, unsigned int full_state)<br> {<br>- static const pj_str_t rlmi_type = { "application", 11 };<br>- static const pj_str_t rlmi_subtype = { "rlmi+xml", 8 };<br> pj_xml_node *rlmi;<br> pj_xml_node *name;<br> pjsip_multipart_part *rlmi_part;<br>@@ -2054,9 +2054,7 @@<br> rlmi_part = pjsip_multipart_create_part(pool);<br> <br> rlmi_part->body = PJ_POOL_ZALLOC_T(pool, pjsip_msg_body);<br>- pj_strdup(pool, &rlmi_part->body->content_type.type, &rlmi_type);<br>- pj_strdup(pool, &rlmi_part->body->content_type.subtype, &rlmi_subtype);<br>- pj_list_init(&rlmi_part->body->content_type.param);<br>+ pjsip_media_type_cp(pool, &rlmi_part->body->content_type, &rlmi_media_type);<br> <br> rlmi_part->body->data = pj_xml_clone(pool, rlmi);<br> rlmi_part->body->clone_data = rlmi_clone_data;<br>@@ -3524,12 +3522,11 @@<br> return PJ_TRUE;<br> }<br> <br>-static pjsip_media_type simple_message_summary;<br>-<br> static pj_bool_t pubsub_on_rx_notify_request(pjsip_rx_data *rdata)<br> {<br> if (rdata->msg_info.msg->body &&<br>- pjsip_media_type_cmp(&rdata->msg_info.msg->body->content_type, &simple_message_summary, 0) == 0) {<br>+ ast_sip_is_content_type(&rdata->msg_info.msg->body->content_type,<br>+ "application", "simple-message-summary")) {<br> return pubsub_on_rx_mwi_notify_request(rdata);<br> }<br> return PJ_FALSE;<br>@@ -5365,7 +5362,7 @@<br> return AST_MODULE_LOAD_DECLINE;<br> }<br> <br>- pjsip_media_type_init2(&simple_message_summary, "application", "simple-message-summary");<br>+ pjsip_media_type_init2(&rlmi_media_type, "application", "rlmi+xml");<br> <br> if (ast_sched_start_thread(sched)) {<br> ast_log(LOG_ERROR, "Could not start scheduler thread for publication expiration\n");<br>diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c<br>index 93810b8..496c476 100644<br>--- a/res/res_pjsip_session.c<br>+++ b/res/res_pjsip_session.c<br>@@ -3213,8 +3213,9 @@<br> int stream;<br> <br> /* SDP produced by us directly will never be multipart */<br>- if (!transport_state || hook || !tdata->msg->body || pj_stricmp2(&tdata->msg->body->content_type.type, "application") ||<br>- pj_stricmp2(&tdata->msg->body->content_type.subtype, "sdp") || ast_strlen_zero(transport->external_media_address)) {<br>+ if (!transport_state || hook || !tdata->msg->body ||<br>+ !ast_sip_is_content_type(&tdata->msg->body->content_type, "application", "sdp") ||<br>+ ast_strlen_zero(transport->external_media_address)) {<br> return;<br> }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6565">change 6565</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/6565"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 14 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: If3ab0d73d79ac4623308bd48508af2bfd554937d </div>
<div style="display:none"> Gerrit-Change-Number: 6565 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>