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:55:22 +0000 (14:55 +0000)
committerJoshua Colp <jcolp@digium.com>
Fri, 4 Oct 2013 14:55:22 +0000 (14:55 +0000)
........

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

res/res_pjsip_session.c

index 07ccd0c..a186bf6 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];