[asterisk-commits] oej: trunk r65898 - in /trunk: ./ channels/chan_gtalk.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu May 24 08:23:05 MST 2007


Author: oej
Date: Thu May 24 10:23:04 2007
New Revision: 65898

URL: http://svn.digium.com/view/asterisk?view=rev&rev=65898
Log:
Merged revisions 65892 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r65892 | oej | 2007-05-24 17:20:54 +0200 (Thu, 24 May 2007) | 2 lines

Issue 8193 - NAT issues with gtalk/STUN. Patch by phsultan. Thanks!

........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_gtalk.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/channels/chan_gtalk.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_gtalk.c?view=diff&rev=65898&r1=65897&r2=65898
==============================================================================
--- trunk/channels/chan_gtalk.c (original)
+++ trunk/channels/chan_gtalk.c Thu May 24 10:23:04 2007
@@ -1136,6 +1136,7 @@
 	struct hostent *hp;
 	struct ast_hostent ahp;
 	struct sockaddr_in sin;
+	struct sockaddr_in aux;
 
 	if (time(NULL) == p->laststun)
 		return 0;
@@ -1144,14 +1145,32 @@
 	p->laststun = time(NULL);
 	while (tmp) {
 		char username[256];
+
+		/* Find the IP address of the host */
 		hp = ast_gethostbyname(tmp->ip, &ahp);
 		sin.sin_family = AF_INET;
 		memcpy(&sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr));
 		sin.sin_port = htons(tmp->port);
 		snprintf(username, sizeof(username), "%s%s", tmp->username,
-				 p->ourcandidates->username);
-
-		ast_rtp_stun_request(p->rtp, &sin, username);
+			 p->ourcandidates->username);
+		
+		/* Find out the result of the STUN */
+		ast_rtp_get_peer(p->rtp, &aux);
+
+		/* If the STUN result is different from the IP of the hostname,
+			lock on the stun IP of the hostname advertised by the
+			remote client */
+		if (aux.sin_addr.s_addr && 
+		    aux.sin_addr.s_addr != sin.sin_addr.s_addr)
+			ast_rtp_stun_request(p->rtp, &aux, username);
+		else 
+			ast_rtp_stun_request(p->rtp, &sin, username);
+		
+		if (aux.sin_addr.s_addr && option_debug > 3) {
+			ast_log(LOG_DEBUG, "Receiving RTP traffic from IP %s, matches with remote candidate's IP %s\n", ast_inet_ntoa(aux.sin_addr), tmp->ip);
+			ast_log(LOG_DEBUG, "Sending STUN request to %s\n", tmp->ip);
+		}
+
 		tmp = tmp->next;
 	}
 	return 1;



More information about the asterisk-commits mailing list