[asterisk-commits] file: branch file/pimp_sip_nat r382289 - /team/file/pimp_sip_nat/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Feb 28 14:58:51 CST 2013


Author: file
Date: Thu Feb 28 14:58:48 2013
New Revision: 382289

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382289
Log:
Bind to all so that if multiple interfaces are present for ICE we can accept packets on all of them.

Modified:
    team/file/pimp_sip_nat/res/res_sip_sdp_audio.c

Modified: team/file/pimp_sip_nat/res/res_sip_sdp_audio.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_nat/res/res_sip_sdp_audio.c?view=diff&rev=382289&r1=382288&r2=382289
==============================================================================
--- team/file/pimp_sip_nat/res/res_sip_sdp_audio.c (original)
+++ team/file/pimp_sip_nat/res/res_sip_sdp_audio.c Thu Feb 28 14:58:48 2013
@@ -78,18 +78,10 @@
 /*! \brief Internal function which creates an RTP instance */
 static int audio_create_rtp(struct ast_sip_session *session, unsigned int ipv6)
 {
-	pj_sockaddr addr;
-	char hostip[PJ_INET6_ADDRSTRLEN+2];
 	struct ast_sockaddr tmp;
 	struct ast_rtp_engine_ice *ice;
 
-	if (pj_gethostip(ipv6 ? pj_AF_INET6() : pj_AF_INET(), &addr) != PJ_SUCCESS) {
-		return -1;
-	}
-
-	pj_sockaddr_print(&addr, hostip, sizeof(hostip), 2);
-
-	if (!ast_sockaddr_parse(&tmp, hostip, 0)) {
+	if (!ast_sockaddr_parse(&tmp, ipv6 ? "::" : "0.0.0.0", 0)) {
 		return -1;
 	}
 
@@ -149,6 +141,7 @@
 	static const pj_str_t STR_SENDRECV = { "sendrecv", 8 };
 	pj_pool_t *pool = session->inv_session->pool_active;
 	pjmedia_sdp_media *media;
+	char hostip[PJ_INET6_ADDRSTRLEN+2];
 	struct ast_sockaddr addr;
 	char tmp[512];
 	pj_str_t stmp;
@@ -174,11 +167,21 @@
 	media->desc.transport = STR_RTP_AVP;
 
 	/* Add connection level details */
+	if (ast_strlen_zero(session->endpoint->external_media_address)) {
+		pj_sockaddr localaddr;
+
+		if (pj_gethostip(session->endpoint->rtp_ipv6 ? pj_AF_INET6() : pj_AF_INET(), &localaddr)) {
+			return -1;
+		}
+		pj_sockaddr_print(&localaddr, hostip, sizeof(hostip), 2);
+	} else {
+		ast_copy_string(hostip, session->endpoint->external_media_address, sizeof(hostip));
+	}
+
+	media->conn->net_type = STR_IN;
+	media->conn->addr_type = session->endpoint->rtp_ipv6 ? STR_IP6 : STR_IP4;
+	pj_strdup2(pool, &media->conn->addr, hostip);
 	ast_rtp_instance_get_local_address(session->media[AST_SIP_MEDIA_AUDIO].rtp, &addr);
-	media->conn->net_type = STR_IN;
-	media->conn->addr_type = (ast_sockaddr_is_ipv6(&addr) && !ast_sockaddr_is_ipv4_mapped(&addr)) ? STR_IP6 : STR_IP4;
-	pj_strdup2(pool, &media->conn->addr, !ast_sockaddr_is_ipv6(&addr) ? S_OR(session->endpoint->external_media_address, ast_sockaddr_stringify_addr_remote(&addr)) :
-			   ast_sockaddr_stringify_addr_remote(&addr));
 	media->desc.port = (pj_uint16_t) ast_sockaddr_port(&addr);
 	media->desc.port_count = 1;
 




More information about the asterisk-commits mailing list