[svn-commits] mmichelson: branch mmichelson/udptl-v6 r278016 - in /team/mmichelson/udptl-v6...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jul 19 16:51:47 CDT 2010


Author: mmichelson
Date: Mon Jul 19 16:51:43 2010
New Revision: 278016

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=278016
Log:
Initial conversion of chan_sip's udptl usage.


Modified:
    team/mmichelson/udptl-v6/channels/chan_sip.c
    team/mmichelson/udptl-v6/channels/sip/include/sip.h

Modified: team/mmichelson/udptl-v6/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/udptl-v6/channels/chan_sip.c?view=diff&rev=278016&r1=278015&r2=278016
==============================================================================
--- team/mmichelson/udptl-v6/channels/chan_sip.c (original)
+++ team/mmichelson/udptl-v6/channels/chan_sip.c Mon Jul 19 16:51:43 2010
@@ -4783,11 +4783,8 @@
 	dialog->capability = peer->capability;
 	dialog->prefs = peer->prefs;
 	if (ast_test_flag(&dialog->flags[1], SIP_PAGE2_T38SUPPORT)) {
-		struct sockaddr_in bindaddr_tmp;
-
 		/* t38pt_udptl was enabled in the peer and not in [general] */
-		ast_sockaddr_to_sin(&bindaddr, &bindaddr_tmp);
-		if (dialog->udptl || (!dialog->udptl && (dialog->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, bindaddr_tmp.sin_addr)))) {
+		if (dialog->udptl || (!dialog->udptl && (dialog->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, &bindaddr)))) {
 			dialog->t38_maxdatagram = peer->t38_maxdatagram;
 			set_t38_capabilities(dialog);
 		} else {
@@ -7061,10 +7058,7 @@
 
 	if (sip_methods[intended_method].need_rtp) {
 		if (ast_test_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT)) {
-			struct sockaddr_in bindaddr_tmp;
-
-			ast_sockaddr_to_sin(&bindaddr, &bindaddr_tmp);
-			if ((p->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, bindaddr_tmp.sin_addr))) {
+			if ((p->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, &bindaddr))) {
 				ast_udptl_setqos(p->udptl, global_tos_audio, global_cos_audio);
 				p->t38_maxdatagram = global_t38_maxdatagram;
 			} else {
@@ -8266,26 +8260,16 @@
 	/* Setup image address and port */
 	if (p->udptl) {
 		if (udptlportno > 0) {
-			isin.sin_family = AF_INET;
-			isin.sin_port = htons(udptlportno);
 			if (ast_test_flag(&p->flags[1], SIP_PAGE2_SYMMETRICRTP) && ast_test_flag(&p->flags[1], SIP_PAGE2_UDPTL_DESTINATION)) {
-				struct sockaddr_in remote_address = { 0, };
-				struct ast_sockaddr remote_address_tmp;
-
 				ast_rtp_instance_get_remote_address(p->rtp,
-								    &remote_address_tmp);
-				ast_sockaddr_to_sin(&remote_address_tmp,
-						    &remote_address);
-				if (remote_address.sin_addr.s_addr) {
-					memcpy(&isin, &remote_address, sizeof(isin));
+								    isa);
+				if (!ast_sockaddr_isnull(isa)) {
 					if (debug) {
 						ast_log(LOG_DEBUG, "Peer T.38 UDPTL is set behind NAT and with destination, destination address now %s\n", ast_inet_ntoa(isin.sin_addr));
 					}
 				}
-			} else {
-				ast_sockaddr_to_sin(isa, &isin);
-			}
-			ast_udptl_set_peer(p->udptl, &isin);
+			}
+			ast_udptl_set_peer(p->udptl, isa);
 			if (debug)
 				ast_debug(1,"Peer T.38 UDPTL is at port %s:%d\n", ast_inet_ntoa(isin.sin_addr), ntohs(isin.sin_port));
 
@@ -10155,12 +10139,11 @@
 	struct ast_sockaddr addr = { {0,} };
 	struct ast_sockaddr vaddr = { {0,} };
 	struct ast_sockaddr taddr = { {0,} };
+	struct ast_sockaddr udptladdr = { {0,} };
 	struct ast_sockaddr dest = { {0,} };
 	struct ast_sockaddr vdest = { {0,} };
 	struct ast_sockaddr tdest = { {0,} };
-	struct sockaddr_in dest_tmp;
-	struct sockaddr_in udptlsin = { 0, };
-	struct sockaddr_in udptldest = { 0, };
+	struct ast_sockaddr udptldest = { {0,} };
 
 	/* SDP fields */
 	char *version = 	"v=0\r\n";		/* Protocol version */
@@ -10395,29 +10378,29 @@
 
 	if (add_t38) {
 		/* Our T.38 end is */
-		ast_udptl_get_us(p->udptl, &udptlsin);
+		ast_udptl_get_us(p->udptl, &udptladdr);
 
 		/* Determine T.38 UDPTL destination */
-		if (p->udptlredirip.sin_addr.s_addr) {
-			udptldest.sin_port = p->udptlredirip.sin_port;
-			udptldest.sin_addr = p->udptlredirip.sin_addr;
+		if (!ast_sockaddr_isnull(&p->udptlredirip)) {
+			ast_sockaddr_copy(&udptldest, &p->udptlredirip);
 		} else {
-			ast_sockaddr_to_sin(&p->ourip, &udptldest);
-			udptldest.sin_port = udptlsin.sin_port;
+			ast_sockaddr_copy(&udptldest, &p->ourip);
+			ast_sockaddr_set_port(&udptldest, ast_sockaddr_port(&udptladdr));
 		}
 
 		if (debug) {
-			ast_debug(1, "T.38 UDPTL is at %s port %d\n", ast_sockaddr_stringify_addr(&p->ourip), ntohs(udptlsin.sin_port));
+			ast_debug(1, "T.38 UDPTL is at %s port %d\n", ast_sockaddr_stringify_addr(&p->ourip), ast_sockaddr_port(&udptladdr));
 		}
 
 		/* We break with the "recommendation" and send our IP, in order that our
 		   peer doesn't have to ast_gethostbyname() us */
 
-		ast_str_append(&m_modem, 0, "m=image %d udptl t38\r\n", ntohs(udptldest.sin_port));
-
-		ast_sockaddr_to_sin(&dest, &dest_tmp);
-		if (udptldest.sin_addr.s_addr != dest_tmp.sin_addr.s_addr) {
-			ast_str_append(&m_modem, 0, "c=IN IP4 %s\r\n", ast_inet_ntoa(udptldest.sin_addr));
+		ast_str_append(&m_modem, 0, "m=image %d udptl t38\r\n", ast_sockaddr_port(&udptldest));
+
+		if (!ast_sockaddr_cmp(&udptldest, &dest)) {
+			ast_str_append(&m_modem, 0, "c=IN %s %s\r\n",
+					(ast_sockaddr_is_ipv6(&dest) && !ast_sockaddr_is_ipv4_mapped(&dest)) ?
+					"IP6" : "IP4", ast_sockaddr_stringify_addr(&udptldest));
 		}
 
 		ast_str_append(&a_modem, 0, "a=T38FaxVersion:%d\r\n", p->t38.our_parms.version);
@@ -21116,10 +21099,7 @@
 		}
 		/* If T38 is needed but not present, then make it magically appear */
 		if (ast_test_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT) && !p->udptl) {
-			struct sockaddr_in bindaddr_sin_tmp;
-
-			ast_sockaddr_to_sin(&bindaddr, &bindaddr_sin_tmp);
-			if ((p->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, bindaddr_sin_tmp.sin_addr))) {
+			if ((p->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, &bindaddr))) {
 				p->t38_maxdatagram = global_t38_maxdatagram;
 				set_t38_capabilities(p);
 			} else {
@@ -27228,14 +27208,13 @@
 		memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
 	}
 	if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
-		struct sockaddr_in ourip_sin;
-		ast_sockaddr_to_sin(&p->ourip, &ourip_sin);
 		if (!p->pendinginvite) {
-			ast_debug(3, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : ourip_sin.sin_addr), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
-
+			ast_debug(3, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s\n",
+					p->callid, ast_sockaddr_stringify(udptl ? &p->udptlredirip : &p->ourip));
 			transmit_reinvite_with_sdp(p, TRUE, FALSE);
 		} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
-			ast_debug(3, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : ourip_sin.sin_addr), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
+			ast_debug(3, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s\n",
+					p->callid, ast_sockaddr_stringify(udptl ? &p->udptlredirip : &p->ourip));
 			ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
 		}
 	}

Modified: team/mmichelson/udptl-v6/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/udptl-v6/channels/sip/include/sip.h?view=diff&rev=278016&r1=278015&r2=278016
==============================================================================
--- team/mmichelson/udptl-v6/channels/sip/include/sip.h (original)
+++ team/mmichelson/udptl-v6/channels/sip/include/sip.h Mon Jul 19 16:51:43 2010
@@ -1001,7 +1001,7 @@
 	int authtries;                        /*!< Times we've tried to authenticate */
 	struct sip_proxy *outboundproxy;      /*!< Outbound proxy for this dialog. Use ref_proxy to set this instead of setting it directly*/
 	struct t38properties t38;             /*!< T38 settings */
-	struct sockaddr_in udptlredirip;      /*!< Where our T.38 UDPTL should be going if not to us */
+	struct ast_sockaddr udptlredirip;     /*!< Where our T.38 UDPTL should be going if not to us */
 	struct ast_udptl *udptl;              /*!< T.38 UDPTL session */
 	int callingpres;                      /*!< Calling presentation */
 	int expiry;                         /*!< How long we take to expire */




More information about the svn-commits mailing list