summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Nicholson <mnicholson@digium.com>2011-11-10 16:29:13 +0000
committerMatthew Nicholson <mnicholson@digium.com>2011-11-10 16:29:13 +0000
commit3d44965e70ced03d71a7bb590f3215bfbdc7e4dd (patch)
tree86485a66ca8dfb9b88ed09a75b75b6ab6cc186ed
parent6d481420ce07ea171736f891bed54828a5173789 (diff)
only attempt to do stun handling on ipv4 or ipv4 mapped to ipv6 addresses
Patch by: jkonieczny (modified) ASTERISK-18490 ........ Merged revisions 344330 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 344334 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@344335 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--res/res_rtp_asterisk.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index aaa31c319..4dc627e8f 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -2094,7 +2094,18 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
if (!(version = (seqno & 0xC0000000) >> 30)) {
struct sockaddr_in addr_tmp;
- ast_sockaddr_to_sin(&addr, &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);