diff options
author | oej <oej@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-05-24 15:20:54 +0000 |
---|---|---|
committer | oej <oej@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-05-24 15:20:54 +0000 |
commit | 27cf4bcba0f46e6d9296bbaa80ca1d7ae6196e4f (patch) | |
tree | e70b90b484628cbb53f684b3981c4f9e8b45236d /channels | |
parent | 08540b68d7c48604c86e299e2df35d88c6d93487 (diff) |
Issue 8193 - NAT issues with gtalk/STUN. Patch by phsultan. Thanks!
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@65892 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_gtalk.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c index 37f865b7c..1da9e8bfa 100644 --- a/channels/chan_gtalk.c +++ b/channels/chan_gtalk.c @@ -1126,6 +1126,7 @@ static int gtalk_update_stun(struct gtalk *client, struct gtalk_pvt *p) struct hostent *hp; struct ast_hostent ahp; struct sockaddr_in sin; + struct sockaddr_in aux; if (time(NULL) == p->laststun) return 0; @@ -1134,14 +1135,32 @@ static int gtalk_update_stun(struct gtalk *client, struct gtalk_pvt *p) 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); + 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); + } - ast_rtp_stun_request(p->rtp, &sin, username); tmp = tmp->next; } return 1; |