[Asterisk-code-review] pjsip_message_filter: Make multipart aware (asterisk[16])

George Joseph asteriskteam at digium.com
Mon Jan 10 07:58:24 CST 2022


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/17797 )


Change subject: pjsip_message_filter: Make multipart aware
......................................................................

pjsip_message_filter: Make multipart aware

filter_on_tx_message's multihomed check assumed the body of
the outgoing message was single-part sdp which would fail if the
body was multi-part.  It now uses the new pjsip_get_sdp_info()
function which searches for an sdp in both single- and multi- part
message bodies.

ASTERISK_29813
(not ready to close)

Change-Id: I8f5b8cfdc27f1d4bd3e7491ea9090951a4525c56
---
M res/res_pjsip/pjsip_message_filter.c
1 file changed, 19 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/97/17797/1

diff --git a/res/res_pjsip/pjsip_message_filter.c b/res/res_pjsip/pjsip_message_filter.c
index 2e3efcd..5267a27 100644
--- a/res/res_pjsip/pjsip_message_filter.c
+++ b/res/res_pjsip/pjsip_message_filter.c
@@ -230,6 +230,8 @@
 	pjsip_via_hdr *via;
 	pjsip_fromto_hdr *from;
 	pjsip_tpselector sel;
+	pjsip_sdp_info *sdp_info;
+	pjmedia_sdp_session *sdp;
 
 	sanitize_tdata(tdata);
 
@@ -325,10 +327,23 @@
 		}
 	}
 
-	/* Update the SDP if it is present */
-	if (tdata->msg->body && ast_sip_is_content_type(&tdata->msg->body->content_type, "application", "sdp") &&
-		multihomed_rewrite_sdp(tdata->msg->body->data)) {
-		struct pjmedia_sdp_session *sdp = tdata->msg->body->data;
+	/* If there's no body in the tdata we can just return here. */
+	if (!tdata->msg->body) {
+		return PJ_SUCCESS;
+	}
+
+	/*
+	 * pjsip_get_sdp_info will search for an SDP even if it's in
+	 * a multipart message body.
+	 */
+	sdp_info = pjsip_get_sdp_info(tdata->pool, tdata->msg->body, NULL, &pjsip_media_type_application_sdp);
+	if (sdp_info != PJ_SUCCESS || !sdp_info->sdp) {
+		return PJ_SUCCESS;
+	}
+
+	sdp = sdp_info->sdp;
+
+	if (multihomed_rewrite_sdp(sdp)) {
 		static const pj_str_t STR_IP4 = { "IP4", 3 };
 		static const pj_str_t STR_IP6 = { "IP6", 3 };
 		pj_str_t STR_IP;

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/17797
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I8f5b8cfdc27f1d4bd3e7491ea9090951a4525c56
Gerrit-Change-Number: 17797
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220110/26a58603/attachment-0001.html>


More information about the asterisk-code-review mailing list