From: Russell Bryant Date: Tue, 10 Aug 2010 16:54:20 +0000 (+0000) Subject: Ensure that the proper external address is used for the RTP destination. X-Git-Tag: 1.8.0-beta3~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=83e01097b1d56f7701804e7029f5bebebd787116;p=thirdparty%2Fasterisk.git Ensure that the proper external address is used for the RTP destination. (closes issue #17044) Reported by: ebroad Tested by: ebroad Review: https://reviewboard.asterisk.org/r/566/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@281532 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index cdf598a662..d6e4ccc1d8 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -10259,6 +10259,8 @@ static void get_our_media_address(struct sip_pvt *p, int needvideo, int needtext struct ast_sockaddr *taddr, struct ast_sockaddr *dest, struct ast_sockaddr *vdest, struct ast_sockaddr *tdest) { + int use_externip = 0; + /* First, get our address */ ast_rtp_instance_get_local_address(p->rtp, addr); if (p->vrtp) { @@ -10268,6 +10270,11 @@ static void get_our_media_address(struct sip_pvt *p, int needvideo, int needtext ast_rtp_instance_get_local_address(p->trtp, taddr); } + /* If our real IP differs from the local address returned by the RTP engine, use it. */ + /* The premise is that if we are already using that IP to communicate with the client, */ + /* we should be using it for RTP too. */ + use_externip = ast_sockaddr_cmp_addr(&p->ourip, addr); + /* Now, try to figure out where we want them to send data */ /* Is this a re-invite to move the media out, then use the original offer from caller */ if (!ast_sockaddr_isnull(&p->redirip)) { /* If we have a redirection IP, use it */ @@ -10286,7 +10293,7 @@ static void get_our_media_address(struct sip_pvt *p, int needvideo, int needtext */ ast_sockaddr_copy(dest, !ast_sockaddr_isnull(&media_address) ? &media_address : - !ast_sockaddr_is_any(addr) ? addr : + !ast_sockaddr_is_any(addr) && !use_externip ? addr : &p->ourip); ast_sockaddr_set_port(dest, ast_sockaddr_port(addr)); } @@ -10309,7 +10316,7 @@ static void get_our_media_address(struct sip_pvt *p, int needvideo, int needtext */ ast_sockaddr_copy(vdest, !ast_sockaddr_isnull(&media_address) ? &media_address : - !ast_sockaddr_is_any(vaddr) ? vaddr : + !ast_sockaddr_is_any(vaddr) && !use_externip ? vaddr : &p->ourip); ast_sockaddr_set_port(vdest, ast_sockaddr_port(vaddr)); } @@ -10333,7 +10340,7 @@ static void get_our_media_address(struct sip_pvt *p, int needvideo, int needtext */ ast_sockaddr_copy(tdest, !ast_sockaddr_isnull(&media_address) ? &media_address : - !ast_sockaddr_is_any(taddr) ? taddr : + !ast_sockaddr_is_any(taddr) && !use_externip ? taddr : &p->ourip); ast_sockaddr_set_port(tdest, ast_sockaddr_port(taddr)); }