summaryrefslogtreecommitdiff
path: root/res/res_pjsip_session.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2013-10-04 14:55:22 +0000
committerJoshua Colp <jcolp@digium.com>2013-10-04 14:55:22 +0000
commit47da03e737b87c7f382548c872b896587c4d7a09 (patch)
treecc723cd409f3bb32edb61b605a37d0da8568c741 /res/res_pjsip_session.c
parentd35b5c9cb083a400aca801778f40ae389c5f0986 (diff)
Replace the connection address at the SDP level if altering the SDP with the external media address.
........ Merged revisions 400510 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400511 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip_session.c')
-rw-r--r--res/res_pjsip_session.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index 07ccd0ce2..a186bf67c 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -42,6 +42,7 @@
#include "asterisk/causes.h"
#include "asterisk/sdp_srtp.h"
#include "asterisk/dsp.h"
+#include "asterisk/acl.h"
#define SDP_HANDLER_BUCKETS 11
@@ -2096,6 +2097,18 @@ static void session_outgoing_nat_hook(pjsip_tx_data *tdata, struct ast_sip_trans
sdp = tdata->msg->body->data;
+ if (sdp->conn) {
+ char host[NI_MAXHOST];
+ struct ast_sockaddr addr = { { 0, } };
+
+ ast_copy_pj_str(host, &sdp->conn->addr, sizeof(host));
+ ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID);
+
+ if (ast_apply_ha(transport->localnet, &addr) != AST_SENSE_ALLOW) {
+ pj_strdup2(tdata->pool, &sdp->conn->addr, transport->external_media_address);
+ }
+ }
+
for (stream = 0; stream < sdp->media_count; ++stream) {
/* See if there are registered handlers for this media stream type */
char media[20];