[asterisk-commits] schmidts: branch schmidts/unleash-the-beast r346295 - /team/schmidts/unleash-...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Nov 28 09:07:02 CST 2011
Author: schmidts
Date: Mon Nov 28 09:06:58 2011
New Revision: 346295
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=346295
Log:
Fix regression that 'rtp/rtcp set debup ip' only works when also a port was specified.
(closes issue ASTERISK-18693)
Reported by: Davide Dal Fra
Review: https://reviewboard.asterisk.org/r/1600/
Reviewed by: Walter Doekes
Modified:
team/schmidts/unleash-the-beast/res/res_rtp_asterisk.c
Modified: team/schmidts/unleash-the-beast/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/schmidts/unleash-the-beast/res/res_rtp_asterisk.c?view=diff&rev=346295&r1=346294&r2=346295
==============================================================================
--- team/schmidts/unleash-the-beast/res/res_rtp_asterisk.c (original)
+++ team/schmidts/unleash-the-beast/res/res_rtp_asterisk.c Mon Nov 28 09:06:58 2011
@@ -91,6 +91,8 @@
static int rtcpinterval = RTCP_DEFAULT_INTERVALMS; /*!< Time between rtcp reports in millisecs */
static struct ast_sockaddr rtpdebugaddr; /*!< Debug packets to/from this host */
static struct ast_sockaddr rtcpdebugaddr; /*!< Debug RTCP packets to/from this host */
+static int rtpdebugport; /*< Debug only RTP packets from IP or IP+Port if port is > 0 */
+static int rtcpdebugport; /*< Debug only RTCP packets from IP or IP+Port if port is > 0 */
#ifdef SO_NO_CHECK
static int nochecksums;
#endif
@@ -315,8 +317,15 @@
if (!rtpdebug) {
return 0;
}
-
- return ast_sockaddr_isnull(&rtpdebugaddr) ? 1 : ast_sockaddr_cmp(&rtpdebugaddr, addr) == 0;
+ if (!ast_sockaddr_isnull(&rtpdebugaddr)) {
+ if (rtpdebugport) {
+ return (ast_sockaddr_cmp(&rtpdebugaddr, addr) == 0); /* look for RTP packets from IP+Port */
+ } else {
+ return (ast_sockaddr_cmp_addr(&rtpdebugaddr, addr) == 0); /* only look for RTP packets from IP */
+ }
+ }
+
+ return 1;
}
static inline int rtcp_debug_test_addr(struct ast_sockaddr *addr)
@@ -324,8 +333,15 @@
if (!rtcpdebug) {
return 0;
}
-
- return ast_sockaddr_isnull(&rtcpdebugaddr) ? 1 : ast_sockaddr_cmp(&rtcpdebugaddr, addr) == 0;
+ if (!ast_sockaddr_isnull(&rtcpdebugaddr)) {
+ if (rtcpdebugport) {
+ return (ast_sockaddr_cmp(&rtcpdebugaddr, addr) == 0); /* look for RTCP packets from IP+Port */
+ } else {
+ return (ast_sockaddr_cmp_addr(&rtcpdebugaddr, addr) == 0); /* only look for RTCP packets from IP */
+ }
+ }
+
+ return 1;
}
static int __rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t size, int flags, struct ast_sockaddr *sa, int rtcp)
@@ -2091,7 +2107,18 @@
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);
@@ -2711,11 +2738,14 @@
static char *rtp_do_debug_ip(struct ast_cli_args *a)
{
char *arg = ast_strdupa(a->argv[4]);
-
- if (!ast_sockaddr_parse(&rtpdebugaddr, arg, 0)) {
+ char *debughost = NULL;
+ char *debugport = NULL;
+
+ if (!ast_sockaddr_parse(&rtpdebugaddr, arg, 0) || !ast_sockaddr_split_hostport(arg, &debughost, &debugport, 0)) {
ast_cli(a->fd, "Lookup failed for '%s'\n", arg);
return CLI_FAILURE;
}
+ rtpdebugport = (!ast_strlen_zero(debugport) && debugport[0] != '0');
ast_cli(a->fd, "RTP Debugging Enabled for address: %s\n",
ast_sockaddr_stringify(&rtpdebugaddr));
rtpdebug = 1;
@@ -2725,11 +2755,14 @@
static char *rtcp_do_debug_ip(struct ast_cli_args *a)
{
char *arg = ast_strdupa(a->argv[4]);
-
- if (!ast_sockaddr_parse(&rtcpdebugaddr, arg, 0)) {
+ char *debughost = NULL;
+ char *debugport = NULL;
+
+ if (!ast_sockaddr_parse(&rtcpdebugaddr, arg, 0) || !ast_sockaddr_split_hostport(arg, &debughost, &debugport, 0)) {
ast_cli(a->fd, "Lookup failed for '%s'\n", arg);
return CLI_FAILURE;
}
+ rtcpdebugport = (!ast_strlen_zero(debugport) && debugport[0] != '0');
ast_cli(a->fd, "RTCP Debugging Enabled for address: %s\n",
ast_sockaddr_stringify(&rtcpdebugaddr));
rtcpdebug = 1;
More information about the asterisk-commits
mailing list