[svn-commits] file: trunk r369817 - /trunk/res/res_rtp_asterisk.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jul 9 11:44:27 CDT 2012


Author: file
Date: Mon Jul  9 11:44:24 2012
New Revision: 369817

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=369817
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-20102)
Reported by: Malcolm Davenport

Modified:
    trunk/res/res_rtp_asterisk.c

Modified: trunk/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_rtp_asterisk.c?view=diff&rev=369817&r1=369816&r2=369817
==============================================================================
--- trunk/res/res_rtp_asterisk.c (original)
+++ trunk/res/res_rtp_asterisk.c Mon Jul  9 11:44:24 2012
@@ -2820,39 +2820,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]);
 
@@ -2878,6 +2845,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 svn-commits mailing list