[asterisk-commits] kmoore: branch 10 r373703 - in /branches/10: ./ res/res_rtp_asterisk.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 25 14:34:05 CDT 2012


Author: kmoore
Date: Tue Sep 25 14:34:01 2012
New Revision: 373703

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=373703
Log:
Fix an issue where media would not flow for situations where the legacy STUN code is in use.

The STUN packets should *not* be blocked by strict RTP.

(closes issue ASTERISK-20415)
Reported-by: Michele Cicciotti
Patch-by: Josh Colp (trunk r369817)
........

Merged revisions 373702 from http://svn.asterisk.org/svn/asterisk/branches/1.8

Modified:
    branches/10/   (props changed)
    branches/10/res/res_rtp_asterisk.c

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/res/res_rtp_asterisk.c?view=diff&rev=373703&r1=373702&r2=373703
==============================================================================
--- branches/10/res/res_rtp_asterisk.c (original)
+++ branches/10/res/res_rtp_asterisk.c Tue Sep 25 14:34:01 2012
@@ -2160,39 +2160,6 @@
 		return &ast_null_frame;
 	}
 
-	/* If strict RTP protection is enabled see if we need to learn the remote address or if we need to drop the packet */
-	if (rtp->strict_rtp_state == STRICT_RTP_LEARN) {
-		ast_debug(1, "%p -- start learning mode pass with addr = %s\n", rtp, ast_sockaddr_stringify(&addr));
-		/* For now, we always copy the address. */
-		ast_sockaddr_copy(&rtp->strict_rtp_address, &addr);
-
-		/* Send the rtp and the seqno from header to rtp_learning_rtp_seq_update to see whether we can exit or not*/
-		if (rtp_learning_rtp_seq_update(rtp, ntohl(rtpheader[0]))) {
-			ast_debug(1, "%p -- Condition for learning hasn't exited, so reject the frame.\n", rtp);
-			return &ast_null_frame;
-		}
-
-		ast_debug(1, "%p -- Probation Ended. Set strict_rtp_state to STRICT_RTP_CLOSED with address %s\n", rtp, ast_sockaddr_stringify(&addr));
-		rtp->strict_rtp_state = STRICT_RTP_CLOSED;
-	} else if (rtp->strict_rtp_state == STRICT_RTP_CLOSED) {
-		if (ast_sockaddr_cmp(&rtp->strict_rtp_address, &addr)) {
-			/* Hmm, not the strict addres. Perhaps we're getting audio from the alternate? */
-			if (!ast_sockaddr_cmp(&rtp->alt_rtp_address, &addr)) {
-				/* ooh, we did! You're now the new expected address, son! */
-				ast_sockaddr_copy(&rtp->strict_rtp_address,
-						  &addr);
-			} else  {
-				const char *real_addr = ast_strdupa(ast_sockaddr_stringify(&addr));
-				const char *expected_addr = ast_strdupa(ast_sockaddr_stringify(&rtp->strict_rtp_address));
-
-				ast_debug(1, "Received RTP packet from %s, dropping due to strict RTP protection. Expected it to be from %s\n",
-						real_addr, expected_addr);
-
-				return &ast_null_frame;
-			}
-		}
-	}
-
 	/* Get fields and verify this is an RTP packet */
 	seqno = ntohl(rtpheader[0]);
 
@@ -2218,6 +2185,39 @@
 			ast_rtp_instance_set_remote_address(instance, &addr);
 		}
 		return &ast_null_frame;
+	}
+
+	/* If strict RTP protection is enabled see if we need to learn the remote address or if we need to drop the packet */
+	if (rtp->strict_rtp_state == STRICT_RTP_LEARN) {
+		ast_debug(1, "%p -- start learning mode pass with addr = %s\n", rtp, ast_sockaddr_stringify(&addr));
+		/* For now, we always copy the address. */
+		ast_sockaddr_copy(&rtp->strict_rtp_address, &addr);
+
+		/* Send the rtp and the seqno from header to rtp_learning_rtp_seq_update to see whether we can exit or not*/
+		if (rtp_learning_rtp_seq_update(rtp, ntohl(rtpheader[0]))) {
+			ast_debug(1, "%p -- Condition for learning hasn't exited, so reject the frame.\n", rtp);
+			return &ast_null_frame;
+		}
+
+		ast_debug(1, "%p -- Probation Ended. Set strict_rtp_state to STRICT_RTP_CLOSED with address %s\n", rtp, ast_sockaddr_stringify(&addr));
+		rtp->strict_rtp_state = STRICT_RTP_CLOSED;
+	} else if (rtp->strict_rtp_state == STRICT_RTP_CLOSED) {
+		if (ast_sockaddr_cmp(&rtp->strict_rtp_address, &addr)) {
+			/* Hmm, not the strict addres. Perhaps we're getting audio from the alternate? */
+			if (!ast_sockaddr_cmp(&rtp->alt_rtp_address, &addr)) {
+				/* ooh, we did! You're now the new expected address, son! */
+				ast_sockaddr_copy(&rtp->strict_rtp_address,
+						  &addr);
+			} else  {
+				const char *real_addr = ast_strdupa(ast_sockaddr_stringify(&addr));
+				const char *expected_addr = ast_strdupa(ast_sockaddr_stringify(&rtp->strict_rtp_address));
+
+				ast_debug(1, "Received RTP packet from %s, dropping due to strict RTP protection. Expected it to be from %s\n",
+						real_addr, expected_addr);
+
+				return &ast_null_frame;
+			}
+		}
 	}
 
 	/* If symmetric RTP is enabled see if the remote side is not what we expected and change where we are sending audio */




More information about the asterisk-commits mailing list