Skip to content

Commit 0d015c4

Browse files
committed
rtpengine: allow IPv6 destinations in sockets
(cherry picked from commit afec9c8)
1 parent ec38f4f commit 0d015c4

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

modules/rtpengine/rtpengine.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,12 @@ static inline int rtpengine_connect_node(struct rtpe_node *pnode)
18321832
}
18331833
pkg_free(hostname);
18341834

1835+
if (res->ai_addrlen > sizeof(pnode->ai_addr)) {
1836+
LM_ERR("RTP proxy address is too large\n");
1837+
freeaddrinfo(res);
1838+
return 0;
1839+
}
1840+
18351841
rtpe_socks[pnode->idx] = socket((pnode->rn_umode == 6)
18361842
? AF_INET6 : AF_INET, SOCK_DGRAM, 0);
18371843
if ( rtpe_socks[pnode->idx] == -1) {
@@ -1849,7 +1855,7 @@ static inline int rtpengine_connect_node(struct rtpe_node *pnode)
18491855
}
18501856

18511857
pnode->ai_addrlen = res->ai_addrlen;
1852-
memcpy(&(pnode->ai_addr), res->ai_addr, res->ai_addrlen);
1858+
memcpy(&pnode->ai_addr.s, res->ai_addr, res->ai_addrlen);
18531859

18541860
freeaddrinfo(res);
18551861
return 1;
@@ -3669,7 +3675,7 @@ static int start_async_send_rtpe_command(struct rtpe_node *node, bencode_item_t
36693675
LM_ERR("can't create socket %d \n",errno);
36703676
goto badproxy;
36713677
}
3672-
if (connect(fd, &(node->ai_addr), node->ai_addrlen) < 0) {
3678+
if (connect(fd, &node->ai_addr.s, node->ai_addrlen) < 0) {
36733679
LM_ERR("can't connect to RTP proxy %s (%d:%s)\n",node->rn_url.s,errno,strerror(errno));
36743680
close(fd);
36753681
goto badproxy;

modules/rtpengine/rtpengine.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define _RTPENGINE_H
2828

2929
#include "bencode.h"
30+
#include "../../ip_addr.h"
3031
#include "../../str.h"
3132

3233
/* flags for set, node, and socket management */
@@ -46,7 +47,7 @@ struct rtpe_node {
4647
unsigned int rn_last_ticks;
4748
int rn_flags;
4849
socklen_t ai_addrlen;
49-
struct sockaddr ai_addr;
50+
union sockaddr_union ai_addr;
5051

5152
struct rtpe_node *rn_next;
5253
};

0 commit comments

Comments
 (0)