From bc81a9000f858b123378e0cb0606575b1e06c50c Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Fri, 4 Oct 2013 14:54:32 +0000 Subject: [PATCH] Replace the connection address at the SDP level if altering the SDP with the external media address. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@400510 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_pjsip_session.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c index 07ccd0ce2e..a186bf67ca 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];