mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 02:37:10 +00:00 
			
		
		
		
	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 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369817 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		| @@ -2820,6 +2820,33 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc | ||||
| 		return &ast_null_frame; | ||||
| 	} | ||||
|  | ||||
| 	/* Get fields and verify this is an RTP packet */ | ||||
| 	seqno = ntohl(rtpheader[0]); | ||||
|  | ||||
| 	ast_rtp_instance_get_remote_address(instance, &remote_address); | ||||
|  | ||||
| 	if (!(version = (seqno & 0xC0000000) >> 30)) { | ||||
| 		struct sockaddr_in addr_tmp; | ||||
| 		struct ast_sockaddr addr_v4; | ||||
| 		if (ast_sockaddr_is_ipv4(&addr)) { | ||||
| 			ast_sockaddr_to_sin(&addr, &addr_tmp); | ||||
| 		} else if (ast_sockaddr_ipv4_mapped(&addr, &addr_v4)) { | ||||
| 			ast_debug(1, "Using IPv6 mapped address %s for STUN\n", | ||||
| 				  ast_sockaddr_stringify(&addr)); | ||||
| 			ast_sockaddr_to_sin(&addr_v4, &addr_tmp); | ||||
| 		} else { | ||||
| 			ast_debug(1, "Cannot do STUN for non IPv4 address %s\n", | ||||
| 				  ast_sockaddr_stringify(&addr)); | ||||
| 			return &ast_null_frame; | ||||
| 		} | ||||
| 		if ((ast_stun_handle_packet(rtp->s, &addr_tmp, rtp->rawdata + AST_FRIENDLY_OFFSET, res, NULL, NULL) == AST_STUN_ACCEPT) && | ||||
| 		    ast_sockaddr_isnull(&remote_address)) { | ||||
| 			ast_sockaddr_from_sin(&addr, &addr_tmp); | ||||
| 			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)); | ||||
| @@ -2853,33 +2880,6 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/* Get fields and verify this is an RTP packet */ | ||||
| 	seqno = ntohl(rtpheader[0]); | ||||
|  | ||||
| 	ast_rtp_instance_get_remote_address(instance, &remote_address); | ||||
|  | ||||
| 	if (!(version = (seqno & 0xC0000000) >> 30)) { | ||||
| 		struct sockaddr_in addr_tmp; | ||||
| 		struct ast_sockaddr addr_v4; | ||||
| 		if (ast_sockaddr_is_ipv4(&addr)) { | ||||
| 			ast_sockaddr_to_sin(&addr, &addr_tmp); | ||||
| 		} else if (ast_sockaddr_ipv4_mapped(&addr, &addr_v4)) { | ||||
| 			ast_debug(1, "Using IPv6 mapped address %s for STUN\n", | ||||
| 				  ast_sockaddr_stringify(&addr)); | ||||
| 			ast_sockaddr_to_sin(&addr_v4, &addr_tmp); | ||||
| 		} else { | ||||
| 			ast_debug(1, "Cannot do STUN for non IPv4 address %s\n", | ||||
| 				  ast_sockaddr_stringify(&addr)); | ||||
| 			return &ast_null_frame; | ||||
| 		} | ||||
| 		if ((ast_stun_handle_packet(rtp->s, &addr_tmp, rtp->rawdata + AST_FRIENDLY_OFFSET, res, NULL, NULL) == AST_STUN_ACCEPT) && | ||||
| 		    ast_sockaddr_isnull(&remote_address)) { | ||||
| 			ast_sockaddr_from_sin(&addr, &addr_tmp); | ||||
| 			ast_rtp_instance_set_remote_address(instance, &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 */ | ||||
| 	if (ast_rtp_instance_get_prop(instance, AST_RTP_PROPERTY_NAT)) { | ||||
| 		if (ast_sockaddr_cmp(&remote_address, &addr)) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user