[Asterisk-cvs] asterisk rtp.c,1.143,1.144
kpfleming
kpfleming
Wed Sep 7 16:33:10 CDT 2005
- Previous message: [Asterisk-cvs] asterisk/apps app_authenticate.c, 1.13,
1.14 app_chanisavail.c, 1.17, 1.18 app_dial.c, 1.164,
1.165 app_directory.c, 1.40, 1.41 app_disa.c, 1.31,
1.32 app_groupcount.c, 1.19, 1.20 app_hasnewvoicemail.c, 1.14,
1.15 app_lookupblacklist.c, 1.9, 1.10 app_md5.c, 1.6,
1.7 app_meetme.c, 1.108, 1.109 app_osplookup.c, 1.8,
1.9 app_playback.c, 1.18, 1.19 app_privacy.c, 1.15,
1.16 app_queue.c, 1.160, 1.161 app_talkdetect.c, 1.11,
1.12 app_txtcidname.c, 1.14, 1.15 app_voicemail.c, 1.244, 1.245
- Next message: [Asterisk-cvs] asterisk/apps app_macro.c,1.26,1.27
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv31151
Modified Files:
rtp.c
Log Message:
clarify transmission failure message when RTP peer is behind NAT (issue #5136 with mods to use flag bits instead of new variable)
Index: rtp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/rtp.c,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- rtp.c 30 Aug 2005 02:12:09 -0000 1.143
+++ rtp.c 7 Sep 2005 20:33:30 -0000 1.144
@@ -66,7 +66,10 @@
#define MAX_RTP_PT 256
-#define FLAG_3389_WARNING (1 << 0)
+#define FLAG_3389_WARNING (1 << 0)
+#define FLAG_NAT_ACTIVE (3 << 1)
+#define FLAG_NAT_INACTIVE (0 << 1)
+#define FLAG_NAT_INACTIVE_NOWARN (1 << 1)
struct ast_rtp {
int s;
@@ -86,7 +89,7 @@
int dtmfcount;
unsigned int dtmfduration;
int nat;
- int flags;
+ unsigned int flags;
struct sockaddr_in us;
struct sockaddr_in them;
struct timeval rxcore;
@@ -279,11 +282,15 @@
guaranteed to have it every 20ms or anything */
if (rtpdebug)
ast_log(LOG_DEBUG, "- RTP 3389 Comfort noise event: Level %d (len = %d)\n", rtp->lastrxformat, len);
- if (!(rtp->flags & FLAG_3389_WARNING)) {
+
+ if (!(ast_test_flag(rtp, FLAG_3389_WARNING))) {
char iabuf[INET_ADDRSTRLEN];
- ast_log(LOG_NOTICE, "Comfort noise support incomplete in Asterisk (RFC 3389). Please turn off on client if possible. Client IP: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
- rtp->flags |= FLAG_3389_WARNING;
+
+ ast_log(LOG_NOTICE, "Comfort noise support incomplete in Asterisk (RFC 3389). Please turn off on client if possible. Client IP: %s\n",
+ ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
+ ast_set_flag(rtp, FLAG_3389_WARNING);
}
+
/* Must have at least one byte */
if (!len)
return NULL;
@@ -354,8 +361,8 @@
if ((rtp->rtcp->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
(rtp->rtcp->them.sin_port != sin.sin_port)) {
memcpy(&rtp->rtcp->them, &sin, sizeof(rtp->rtcp->them));
- if (option_debug)
- ast_log(LOG_DEBUG, "RTP NAT: Using address %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
+ if (option_debug || rtpdebug)
+ ast_log(LOG_DEBUG, "RTCP NAT: Got RTCP from other end. Now sending to address %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
}
}
if (option_debug)
@@ -424,7 +431,9 @@
(rtp->them.sin_port != sin.sin_port)) {
memcpy(&rtp->them, &sin, sizeof(rtp->them));
rtp->rxseqno = 0;
- ast_log(LOG_DEBUG, "RTP NAT: Using address %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port));
+ ast_set_flag(rtp, FLAG_NAT_ACTIVE);
+ if (option_debug || rtpdebug)
+ ast_log(LOG_DEBUG, "RTP NAT: Got audio from other end. Now sending to address %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port));
}
}
@@ -646,6 +655,8 @@
void ast_rtp_pt_clear(struct ast_rtp* rtp)
{
int i;
+ if (!rtp)
+ return;
for (i = 0; i < MAX_RTP_PT; ++i) {
rtp->current_RTP_PT[i].isAstFormat = 0;
@@ -1212,8 +1223,17 @@
if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
res = sendto(rtp->s, (void *)rtpheader, f->datalen + hdrlen, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));
- if (res <0)
- ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
+ if (res <0) {
+ if (!rtp->nat || (rtp->nat && (ast_test_flag(rtp, FLAG_NAT_ACTIVE) == FLAG_NAT_ACTIVE))) {
+ ast_log(LOG_DEBUG, "RTP Transmission error of packet %d to %s:%d: %s\n", rtp->seqno, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
+ } else if ((ast_test_flag(rtp, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug) {
+ /* Only give this error message once if we are not RTP debugging */
+ if (option_debug || rtpdebug)
+ ast_log(LOG_DEBUG, "RTP NAT: Can't write RTP to private address %s:%d, waiting for other end to send audio...\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port));
+ ast_set_flag(rtp, FLAG_NAT_INACTIVE_NOWARN);
+ }
+ }
+
if(rtp_debug_test_addr(&rtp->them))
ast_verbose("Sent RTP packet to %s:%d (type %d, seq %d, ts %d, len %d)\n"
, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), codec, rtp->seqno, rtp->lastts,res - hdrlen);
- Previous message: [Asterisk-cvs] asterisk/apps app_authenticate.c, 1.13,
1.14 app_chanisavail.c, 1.17, 1.18 app_dial.c, 1.164,
1.165 app_directory.c, 1.40, 1.41 app_disa.c, 1.31,
1.32 app_groupcount.c, 1.19, 1.20 app_hasnewvoicemail.c, 1.14,
1.15 app_lookupblacklist.c, 1.9, 1.10 app_md5.c, 1.6,
1.7 app_meetme.c, 1.108, 1.109 app_osplookup.c, 1.8,
1.9 app_playback.c, 1.18, 1.19 app_privacy.c, 1.15,
1.16 app_queue.c, 1.160, 1.161 app_talkdetect.c, 1.11,
1.12 app_txtcidname.c, 1.14, 1.15 app_voicemail.c, 1.244, 1.245
- Next message: [Asterisk-cvs] asterisk/apps app_macro.c,1.26,1.27
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the svn-commits
mailing list