mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 04:11:08 +00:00
allow users of RTP to know when the peer endpoint is (apparently) behind a NAT
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6558 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -3928,7 +3928,7 @@ static struct ast_rtp *mgcp_get_rtp_peer(struct ast_channel *chan)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs)
|
||||
static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active)
|
||||
{
|
||||
/* XXX Is there such thing as video support with MGCP? XXX */
|
||||
struct mgcp_subchannel *sub;
|
||||
|
@@ -11920,7 +11920,7 @@ static struct ast_rtp *sip_get_vrtp_peer(struct ast_channel *chan)
|
||||
}
|
||||
|
||||
/*--- sip_set_rtp_peer: Set the RTP peer for this call ---*/
|
||||
static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs)
|
||||
static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active)
|
||||
{
|
||||
struct sip_pvt *p;
|
||||
|
||||
|
@@ -1327,7 +1327,7 @@ static struct ast_rtp *skinny_get_rtp_peer(struct ast_channel *chan)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int skinny_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs)
|
||||
static int skinny_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active)
|
||||
{
|
||||
struct skinny_subchannel *sub;
|
||||
sub = chan->tech_pvt;
|
||||
|
@@ -50,7 +50,7 @@ struct ast_rtp_protocol {
|
||||
/* Get RTP struct, or NULL if unwilling to transfer */
|
||||
struct ast_rtp *(* const get_vrtp_info)(struct ast_channel *chan);
|
||||
/* Set RTP peer */
|
||||
int (* const set_rtp_peer)(struct ast_channel *chan, struct ast_rtp *peer, struct ast_rtp *vpeer, int codecs);
|
||||
int (* const set_rtp_peer)(struct ast_channel *chan, struct ast_rtp *peer, struct ast_rtp *vpeer, int codecs, int nat_active);
|
||||
int (* const get_codec)(struct ast_channel *chan);
|
||||
const char * const type;
|
||||
struct ast_rtp_protocol *next;
|
||||
|
18
rtp.c
18
rtp.c
@@ -1538,7 +1538,7 @@ enum ast_bridge_result ast_rtp_bridge(struct ast_channel *c0, struct ast_channel
|
||||
}
|
||||
|
||||
/* Ok, we should be able to redirect the media. Start with one channel */
|
||||
if (pr0->set_rtp_peer(c0, p1, vp1, codec1))
|
||||
if (pr0->set_rtp_peer(c0, p1, vp1, codec1, ast_test_flag(p1, FLAG_NAT_ACTIVE)))
|
||||
ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", c0->name, c1->name);
|
||||
else {
|
||||
/* Store RTP peer */
|
||||
@@ -1547,7 +1547,7 @@ enum ast_bridge_result ast_rtp_bridge(struct ast_channel *c0, struct ast_channel
|
||||
ast_rtp_get_peer(vp1, &vac1);
|
||||
}
|
||||
/* Then test the other channel */
|
||||
if (pr1->set_rtp_peer(c1, p0, vp0, codec0))
|
||||
if (pr1->set_rtp_peer(c1, p0, vp0, codec0, ast_test_flag(p0, FLAG_NAT_ACTIVE)))
|
||||
ast_log(LOG_WARNING, "Channel '%s' failed to talk back to '%s'\n", c1->name, c0->name);
|
||||
else {
|
||||
/* Store RTP peer */
|
||||
@@ -1571,11 +1571,11 @@ enum ast_bridge_result ast_rtp_bridge(struct ast_channel *c0, struct ast_channel
|
||||
(c0->masq || c0->masqr || c1->masq || c1->masqr)) {
|
||||
ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n");
|
||||
if (c0->tech_pvt == pvt0) {
|
||||
if (pr0->set_rtp_peer(c0, NULL, NULL, 0))
|
||||
if (pr0->set_rtp_peer(c0, NULL, NULL, 0, 0))
|
||||
ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c0->name);
|
||||
}
|
||||
if (c1->tech_pvt == pvt1) {
|
||||
if (pr1->set_rtp_peer(c1, NULL, NULL, 0))
|
||||
if (pr1->set_rtp_peer(c1, NULL, NULL, 0, 0))
|
||||
ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c1->name);
|
||||
}
|
||||
return AST_BRIDGE_RETRY;
|
||||
@@ -1600,10 +1600,10 @@ enum ast_bridge_result ast_rtp_bridge(struct ast_channel *c0, struct ast_channel
|
||||
c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), vt1.sin_addr), ntohs(vt1.sin_port), codec1);
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n",
|
||||
c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), ac1.sin_addr), ntohs(ac1.sin_port), oldcodec1);
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' wasv %s:%d/(format %d)\n",
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n",
|
||||
c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), vac1.sin_addr), ntohs(vac1.sin_port), oldcodec1);
|
||||
}
|
||||
if (pr0->set_rtp_peer(c0, t1.sin_addr.s_addr ? p1 : NULL, vt1.sin_addr.s_addr ? vp1 : NULL, codec1))
|
||||
if (pr0->set_rtp_peer(c0, t1.sin_addr.s_addr ? p1 : NULL, vt1.sin_addr.s_addr ? vp1 : NULL, codec1, ast_test_flag(p1, FLAG_NAT_ACTIVE)))
|
||||
ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c0->name, c1->name);
|
||||
memcpy(&ac1, &t1, sizeof(ac1));
|
||||
memcpy(&vac1, &vt1, sizeof(vac1));
|
||||
@@ -1616,7 +1616,7 @@ enum ast_bridge_result ast_rtp_bridge(struct ast_channel *c0, struct ast_channel
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n",
|
||||
c0->name, ast_inet_ntoa(iabuf, sizeof(iabuf), ac0.sin_addr), ntohs(ac0.sin_port), oldcodec0);
|
||||
}
|
||||
if (pr1->set_rtp_peer(c1, t0.sin_addr.s_addr ? p0 : NULL, vt0.sin_addr.s_addr ? vp0 : NULL, codec0))
|
||||
if (pr1->set_rtp_peer(c1, t0.sin_addr.s_addr ? p0 : NULL, vt0.sin_addr.s_addr ? vp0 : NULL, codec0, ast_test_flag(p0, FLAG_NAT_ACTIVE)))
|
||||
ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c1->name, c0->name);
|
||||
memcpy(&ac0, &t0, sizeof(ac0));
|
||||
memcpy(&vac0, &vt0, sizeof(vac0));
|
||||
@@ -1640,11 +1640,11 @@ enum ast_bridge_result ast_rtp_bridge(struct ast_channel *c0, struct ast_channel
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG, "Oooh, got a %s\n", f ? "digit" : "hangup");
|
||||
if ((c0->tech_pvt == pvt0) && (!c0->_softhangup)) {
|
||||
if (pr0->set_rtp_peer(c0, NULL, NULL, 0))
|
||||
if (pr0->set_rtp_peer(c0, NULL, NULL, 0, 0))
|
||||
ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c0->name);
|
||||
}
|
||||
if ((c1->tech_pvt == pvt1) && (!c1->_softhangup)) {
|
||||
if (pr1->set_rtp_peer(c1, NULL, NULL, 0))
|
||||
if (pr1->set_rtp_peer(c1, NULL, NULL, 0, 0))
|
||||
ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c1->name);
|
||||
}
|
||||
return AST_BRIDGE_COMPLETE;
|
||||
|
Reference in New Issue
Block a user