diff options
Diffstat (limited to 'net/asterisk10/files/dtmf_debug.diff')
-rw-r--r-- | net/asterisk10/files/dtmf_debug.diff | 226 |
1 files changed, 226 insertions, 0 deletions
diff --git a/net/asterisk10/files/dtmf_debug.diff b/net/asterisk10/files/dtmf_debug.diff new file mode 100644 index 000000000000..2a5b6bc9ea33 --- /dev/null +++ b/net/asterisk10/files/dtmf_debug.diff @@ -0,0 +1,226 @@ +--- channels/chan_sip.c.orig 2009-05-12 21:18:44.000000000 +0300 ++++ channels/chan_sip.c 2009-05-26 12:50:22.000000000 +0300 +@@ -3891,6 +3891,7 @@ + ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, p->owner); + else { + p->owner = newchan; ++ ast_rtp_set_chan_name(p->rtp, newchan->name); + /* Re-invite RTP back to Asterisk. Needed if channel is masqueraded out of a native + RTP bridge (i.e., RTP not going through Asterisk): RTP bridge code might not be + able to do this if the masquerade happens before the bridge breaks (e.g., AMI +@@ -4168,6 +4169,7 @@ + if (i->rtp) { + tmp->fds[0] = ast_rtp_fd(i->rtp); + tmp->fds[1] = ast_rtcp_fd(i->rtp); ++ ast_rtp_set_chan_id(i->rtp, i->callid); + } + if (needvideo && i->vrtp) { + tmp->fds[2] = ast_rtp_fd(i->vrtp); +@@ -4195,6 +4197,8 @@ + if (!ast_strlen_zero(i->language)) + ast_string_field_set(tmp, language, i->language); + i->owner = tmp; ++ ast_rtp_set_chan_name(i->rtp, tmp->name); ++ + ast_module_ref(ast_module_info->self); + ast_copy_string(tmp->context, i->context, sizeof(tmp->context)); + /*Since it is valid to have extensions in the dialplan that have unescaped characters in them +@@ -4621,8 +4625,10 @@ + build_via(p); + if (!callid) + build_callid_pvt(p); +- else ++ else { + ast_string_field_set(p, callid, callid); ++ ast_rtp_set_chan_id(p->rtp, p->callid); ++ } + /* Assign default music on hold class */ + ast_string_field_set(p, mohinterpret, default_mohinterpret); + ast_string_field_set(p, mohsuggest, default_mohsuggest); +--- include/asterisk/rtp.h.orig 2008-03-04 20:05:28.000000000 +0200 ++++ include/asterisk/rtp.h 2009-05-26 12:50:22.000000000 +0300 +@@ -243,6 +243,9 @@ + + int ast_rtp_codec_getformat(int pt); + ++void ast_rtp_set_chan_name(struct ast_rtp *, const char *); ++void ast_rtp_set_chan_id(struct ast_rtp *, const char *); ++ + /*! \brief Set rtp timeout */ + void ast_rtp_set_rtptimeout(struct ast_rtp *rtp, int timeout); + /*! \brief Set rtp hold timeout */ +--- main/rtp.c.orig 2009-11-20 17:51:49.000000000 +0200 ++++ main/rtp.c 2009-11-20 17:53:11.000000000 +0200 +@@ -81,6 +81,7 @@ + static int rtpstart; /*!< First port for RTP sessions (set in rtp.conf) */ + static int rtpend; /*!< Last port for RTP sessions (set in rtp.conf) */ + static int rtpdebug; /*!< Are we debugging? */ ++static int rtpdebugdtmf; /*!< Are we debugging DTMFs? */ + static int rtcpdebug; /*!< Are we debugging RTCP? */ + static int rtcpstats; /*!< Are we debugging RTCP? */ + static int rtcpinterval = RTCP_DEFAULT_INTERVALMS; /*!< Time between rtcp reports in millisecs */ +@@ -170,6 +171,8 @@ + struct ast_rtp *bridged; /*!< Who we are Packet bridged to */ + int set_marker_bit:1; /*!< Whether to set the marker bit or not */ + unsigned int constantssrc:1; ++ char chan_name[100]; ++ char chan_id[100]; + }; + + /* Forward declarations */ +@@ -676,8 +679,8 @@ + struct ast_frame *f = NULL; + event = ntohl(*((unsigned int *)(data))); + event &= 0x001F; +- if (option_debug > 2 || rtpdebug) +- ast_log(LOG_DEBUG, "Cisco DTMF Digit: %08x (len = %d)\n", event, len); ++ if (option_debug > 2 || rtpdebug || rtpdebugdtmf) ++ ast_log(LOG_DEBUG, "Channel: %s %s Cisco DTMF packet: %08x (len = %d)\n", rtp->chan_name, rtp->chan_id, event, len); + if (event < 10) { + resp = '0' + event; + } else if (event < 11) { +@@ -691,12 +694,25 @@ + } + if (rtp->resp && (rtp->resp != resp)) { + f = send_dtmf(rtp, AST_FRAME_DTMF_END); ++ ast_log(LOG_DEBUG, "Channel: %s %s Cisco DTMF event: %c\n", rtp->chan_name, rtp->chan_id, rtp->resp); + } + rtp->resp = resp; + rtp->dtmf_timeout = 0; + return f; + } + ++void ast_rtp_set_chan_id(struct ast_rtp *rtp, const char *chan_id) { ++ if (rtp == NULL || chan_id == NULL) ++ return; ++ snprintf(rtp->chan_id, sizeof(rtp->chan_id), "%s", chan_id); ++} ++ ++void ast_rtp_set_chan_name(struct ast_rtp *rtp, const char *chan_name) { ++ if (rtp == NULL || chan_name == NULL) ++ return; ++ snprintf(rtp->chan_name, sizeof(rtp->chan_name), "%s", chan_name); ++} ++ + /*! + * \brief Process RTP DTMF and events according to RFC 2833. + * +@@ -1101,6 +1117,10 @@ + struct rtpPayloadType rtpPT; + int reconstruct = ntohl(rtpheader[0]); + ++ /* If we are listening for DTMF - then feed all packets into the core to keep the RTP stream consistent when relaying DTMFs */ ++ if (ast_test_flag(rtp, FLAG_P2P_NEED_DTMF)) ++ return -1; ++ + /* Get fields from packet */ + payload = (reconstruct & 0x7f0000) >> 16; + mark = (((reconstruct & 0x800000) >> 23) != 0); +@@ -1108,10 +1128,6 @@ + /* Check what the payload value should be */ + rtpPT = ast_rtp_lookup_pt(rtp, payload); + +- /* If the payload is DTMF, and we are listening for DTMF - then feed it into the core */ +- if (ast_test_flag(rtp, FLAG_P2P_NEED_DTMF) && !rtpPT.isAstFormat && rtpPT.code == AST_RTP_DTMF) +- return -1; +- + /* Otherwise adjust bridged payload to match */ + bridged_payload = ast_rtp_lookup_code(bridged, rtpPT.isAstFormat, rtpPT.code); + +@@ -1306,11 +1322,12 @@ + /* This is special in-band data that's not one of our codecs */ + if (rtpPT.code == AST_RTP_DTMF) { + /* It's special -- rfc2833 process it */ +- if (rtp_debug_test_addr(&sin)) { ++ if (rtp_debug_test_addr(&sin) || rtpdebugdtmf) { + unsigned char *data; + unsigned int event; + unsigned int event_end; + unsigned int duration; ++ + data = rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen; + event = ntohl(*((unsigned int *)(data))); + event >>= 24; +@@ -1319,9 +1336,12 @@ + event_end >>= 24; + duration = ntohl(*((unsigned int *)(data))); + duration &= 0xFFFF; +- ast_verbose("Got RTP RFC2833 from %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u, mark %d, event %08x, end %d, duration %-5.5d) \n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), payloadtype, seqno, timestamp, res - hdrlen, (mark?1:0), event, ((event_end & 0x80)?1:0), duration); ++ ++ ast_verbose("Channel: %s %s Got RTP RFC2833 from %s:%u to %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u, mark %d, event %08x, end %d, duration %-5.5d)\n", rtp->chan_name, rtp->chan_id, ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), ast_inet_ntoa(rtp->us.sin_addr), ntohs(rtp->us.sin_port), payloadtype, seqno, timestamp, res - hdrlen, (mark?1:0), event, ((event_end & 0x80)?1:0), duration); + } + f = process_rfc2833(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen, seqno, timestamp); ++ if (rtpdebugdtmf && f) ++ ast_verbose("Channel: %s %s Got RFC2833 DTMF event %c of type %s\n", rtp->chan_name, rtp->chan_id, f->subclass, (f->frametype == AST_FRAME_DTMF_BEGIN ? "DTMF BEGIN" : (f->frametype == AST_FRAME_DTMF_END ? "DTMF_END" : "UNKNOWN"))); + } else if (rtpPT.code == AST_RTP_CISCO_DTMF) { + /* It's really special -- process it the Cisco way */ + if (rtp->lastevent <= seqno || (rtp->lastevent >= 65530 && seqno <= 6)) { +@@ -2287,8 +2307,9 @@ + ast_log(LOG_ERROR, "RTP Transmission error to %s:%u: %s\n", + ast_inet_ntoa(rtp->them.sin_addr), + ntohs(rtp->them.sin_port), strerror(errno)); +- if (rtp_debug_test_addr(&rtp->them)) +- ast_verbose("Sent RTP DTMF packet to %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n", ++ if (rtp_debug_test_addr(&rtp->them) || rtpdebugdtmf) ++ ast_verbose("Channel: %s %s Sent RTP DTMF packet to %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n", ++ rtp->chan_name, rtp->chan_id, + ast_inet_ntoa(rtp->them.sin_addr), + ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastdigitts, res - hdrlen); + /* Increment sequence number */ +@@ -2331,8 +2352,9 @@ + ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n", + ast_inet_ntoa(rtp->them.sin_addr), + ntohs(rtp->them.sin_port), strerror(errno)); +- if (rtp_debug_test_addr(&rtp->them)) +- ast_verbose("Sent RTP DTMF packet to %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n", ++ if (rtp_debug_test_addr(&rtp->them) || rtpdebugdtmf) ++ ast_verbose("Channel: %s %s Sent RTP DTMF packet to %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n", ++ rtp->chan_name, rtp->chan_id, + ast_inet_ntoa(rtp->them.sin_addr), + ntohs(rtp->them.sin_port), rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen); + +@@ -3621,6 +3643,16 @@ + return RESULT_SUCCESS; + } + ++static int rtp_do_debug_dtmf(int fd, int argc, char *argv[]) ++{ ++ if (argc != 3) ++ return RESULT_SHOWUSAGE; ++ ++ rtpdebugdtmf = 1; ++ ast_cli(fd, "RTP DTMF debugging enabled\n"); ++ return RESULT_SUCCESS; ++} ++ + static int rtp_do_debug(int fd, int argc, char *argv[]) + { + if (argc != 2) { +@@ -3681,6 +3713,7 @@ + if (argc != 3) + return RESULT_SHOWUSAGE; + rtpdebug = 0; ++ rtpdebugdtmf = 0; + ast_cli(fd,"RTP Debugging Disabled\n"); + return RESULT_SUCCESS; + } +@@ -3741,7 +3774,7 @@ + } + + static char debug_usage[] = +- "Usage: rtp debug [ip host[:port]]\n" ++ "Usage: rtp debug [ip host[:port] | dtmf]\n" + " Enable dumping of all RTP packets to and from host.\n"; + + static char no_debug_usage[] = +@@ -3816,6 +3849,10 @@ + rtp_do_debug, "Enable RTP debugging", + debug_usage }, + ++ { { "rtp", "debug", "dtmf", NULL }, ++ rtp_do_debug_dtmf, "Enable RTP debugging on DTMFs", ++ debug_usage }, ++ + { { "rtp", "debug", "off", NULL }, + rtp_no_debug, "Disable RTP debugging", + no_debug_usage, NULL, &cli_rtp_no_debug_deprecated }, |