diff options
author | Walter Doekes <walter+asterisk@wjd.nu> | 2017-09-10 13:17:27 +0200 |
---|---|---|
committer | Walter Doekes <walter+asterisk@wjd.nu> | 2017-09-10 06:19:14 -0500 |
commit | 1d2e58705ed9e5fb5de906a97dc9b9202997670d (patch) | |
tree | c8ba4c9cf80b55230c5d3e142caf96c20b466e51 /res/res_pjsip_session.c | |
parent | a8aff0be477cf85530a5b1ff184514ee9b476cf0 (diff) |
res/res_pjsip: Fix localnet checks in pjsip, part 2.
In 45744fc53, I mistakenly broke SDP media address rewriting by
misinterpreting which address was checked in the localnet comparison.
Instead of checking the remote peer address to decide whether we need
media address rewriting, we check our local media address: if it's
local, then we rewrite. This feels awkward, but works and even made
directmedia work properly if you set local_net. (For the record: for
local peers, the SDP media rewrite code is not called, so the
comparison does no harm there.)
ASTERISK-27248 #close
Change-Id: I566be1c33f4d0a689567d451ed46bab9c3861d4f
Diffstat (limited to 'res/res_pjsip_session.c')
-rw-r--r-- | res/res_pjsip_session.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c index b9970244e..64416a063 100644 --- a/res/res_pjsip_session.c +++ b/res/res_pjsip_session.c @@ -3976,12 +3976,16 @@ static void session_outgoing_nat_hook(pjsip_tx_data *tdata, struct ast_sip_trans if (sdp->conn) { char host[NI_MAXHOST]; - struct ast_sockaddr addr = { { 0, } }; + struct ast_sockaddr our_sdp_addr = { { 0, } }; ast_copy_pj_str(host, &sdp->conn->addr, sizeof(host)); - ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID); + ast_sockaddr_parse(&our_sdp_addr, host, PARSE_PORT_FORBID); - if (ast_sip_transport_is_nonlocal(transport_state, &addr)) { + /* Reversed check here. We don't check the remote + * endpoint being in our local net, but whether our + * outgoing session IP is local. If it is, we'll do + * rewriting. No localnet configured? Always rewrite. */ + if (ast_sip_transport_is_local(transport_state, &our_sdp_addr) || !transport_state->localnet) { ast_debug(5, "Setting external media address to %s\n", ast_sockaddr_stringify_host(&transport_state->external_media_address)); pj_strdup2(tdata->pool, &sdp->conn->addr, ast_sockaddr_stringify_host(&transport_state->external_media_address)); } |