From ec6d3b535a513044aba1b2dce5951377af5a466a Mon Sep 17 00:00:00 2001
From: Mark Spencer <markster@digium.com>
Date: Thu, 15 Apr 2004 20:12:46 +0000
Subject: [PATCH] Don't set the address with NAT mode if we haven't programmed
 an address

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2697 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 rtp.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/rtp.c b/rtp.c
index 9e6395bb6c..a6c6300545 100755
--- a/rtp.c
+++ b/rtp.c
@@ -413,6 +413,12 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
 		ast_log(LOG_WARNING, "RTP Read too short\n");
 		return &null_frame;
 	}
+
+	/* Ignore if the other side hasn't been given an address
+	   yet.  */
+	if (!rtp->them.sin_addr.s_addr || !rtp->them.sin_port)
+		return &null_frame;
+
 	if (rtp->nat) {
 		/* Send to whoever sent to us */
 		if ((rtp->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
@@ -421,10 +427,6 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
 			ast_log(LOG_DEBUG, "RTP NAT: Using address %s:%d\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port));
 		}
 	}
-	/* Ignore if the other side hasn't been given an address
-	   yet.  */
-	if (!rtp->them.sin_addr.s_addr || !rtp->them.sin_port)
-		return &null_frame;
 
 	/* Get fields */
 	seqno = ntohl(rtpheader[0]);
-- 
GitLab