[sr-dev] git:master: modules_k/nathelper: core sdp parser integration for nat_uac_test()

Ovidiu Sas osas at voipembedded.com
Tue Nov 9 00:51:53 CET 2010


Module: sip-router
Branch: master
Commit: 06986b23ad72b648a28f614ab47d8cbc727823cf
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=06986b23ad72b648a28f614ab47d8cbc727823cf

Author: Ovidiu Sas <osas at voipembedded.com>
Committer: Ovidiu Sas <osas at voipembedded.com>
Date:   Mon Nov  8 19:04:24 2010 -0500

modules_k/nathelper: core sdp parser integration for nat_uac_test()

---

 modules_k/nathelper/nathelper.c |   40 +++++++++++++++++++++++++++++---------
 1 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/modules_k/nathelper/nathelper.c b/modules_k/nathelper/nathelper.c
index 82c6528..51c1086 100644
--- a/modules_k/nathelper/nathelper.c
+++ b/modules_k/nathelper/nathelper.c
@@ -1134,21 +1134,41 @@ contact_1918(struct sip_msg* msg)
 static int
 sdp_1918(struct sip_msg* msg)
 {
-	str body, ip;
+	str *ip;
 	int pf;
+	int sdp_session_num, sdp_stream_num;
+	sdp_session_cell_t* sdp_session;
+	sdp_stream_cell_t* sdp_stream;
 
-	if (extract_body(msg, &body) == -1) {
-		LM_ERR("cannot extract body from msg!\n");
-		return 0;
-	}
-	if (extract_mediaip(&body, &ip, &pf,"c=") == -1) {
-		LM_ERR("can't extract media IP from the SDP\n");
+	if(0 != parse_sdp(msg)) {
+		LM_ERR("Unable to parse sdp\n");
 		return 0;
 	}
-	if (pf != AF_INET || isnulladdr(&ip, pf))
-		return 0;
 
-	return (is1918addr(&ip) == 1) ? 1 : 0;
+	sdp_session_num = 0;
+	for(;;) {
+		sdp_session = get_sdp_session(msg, sdp_session_num);
+		if(!sdp_session) break;
+		sdp_stream_num = 0;
+		for(;;) {
+			sdp_stream = get_sdp_stream(msg, sdp_session_num, sdp_stream_num);
+			if(!sdp_stream) break;
+			if (sdp_stream->ip_addr.s && sdp_stream->ip_addr.len) {
+				ip = &(sdp_stream->ip_addr);
+				pf = sdp_stream->pf;
+			} else {
+				ip = &(sdp_session->ip_addr);
+				pf = sdp_session->pf;
+			}
+			if (pf != AF_INET || isnulladdr(ip, pf))
+				break;
+			if (is1918addr(ip) == 1)
+				return 1;
+			sdp_stream_num++;
+		}
+		sdp_session_num++;
+	}
+	return 0;
 }
 
 /*




More information about the sr-dev mailing list