]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Replace the connection address at the SDP level if altering the SDP with the external...
authorJoshua Colp <jcolp@digium.com>
Fri, 4 Oct 2013 14:54:32 +0000 (14:54 +0000)
committerJoshua Colp <jcolp@digium.com>
Fri, 4 Oct 2013 14:54:32 +0000 (14:54 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@400510 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_pjsip_session.c

index 07ccd0ce2ee2b5b06b41e7c0acf91b6ee30d8d69..a186bf67ca29a7bf8b054787a5a003cf95ac81b7 100644 (file)
@@ -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];