Common subdirectories: asterisk-16.8.0-orig/res/ael and asterisk-16.8.0-patched/res/ael Common subdirectories: asterisk-16.8.0-orig/res/ari and asterisk-16.8.0-patched/res/ari Common subdirectories: asterisk-16.8.0-orig/res/parking and asterisk-16.8.0-patched/res/parking Common subdirectories: asterisk-16.8.0-orig/res/res_pjsip and asterisk-16.8.0-patched/res/res_pjsip diff -u asterisk-16.8.0-orig/res/res_pjsip_sdp_rtp.c asterisk-16.8.0-patched/res/res_pjsip_sdp_rtp.c --- asterisk-16.8.0-orig/res/res_pjsip_sdp_rtp.c 2020-02-04 16:03:05.000000000 +0100 +++ asterisk-16.8.0-patched/res/res_pjsip_sdp_rtp.c 2020-03-04 13:39:56.039030051 +0100 @@ -2044,7 +2044,7 @@ { RAII_VAR(struct ast_sip_transport_state *, transport_state, ast_sip_get_transport_state(ast_sorcery_object_get_id(transport)), ao2_cleanup); char host[NI_MAXHOST]; - struct ast_sockaddr our_sdp_addr = { { 0, } }; + struct ast_sockaddr addr = { { 0, } }; /* If the stream has been rejected there will be no connection line */ if (!stream->conn || !transport_state) { @@ -2052,13 +2052,10 @@ } ast_copy_pj_str(host, &stream->conn->addr, sizeof(host)); - ast_sockaddr_parse(&our_sdp_addr, host, PARSE_PORT_FORBID); + ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID); - /* 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 not, we won't do rewriting. No localnet - * configured? Always rewrite. */ - if (ast_sip_transport_is_nonlocal(transport_state, &our_sdp_addr) && transport_state->localnet) { + /* Is the address within the SDP inside the same network? */ + if (ast_sip_transport_is_local(transport_state, &addr)) { return; } ast_debug(5, "Setting media address to %s\n", ast_sockaddr_stringify_host(&transport_state->external_media_address)); diff -u asterisk-16.8.0-orig/res/res_pjsip_session.c asterisk-16.8.0-patched/res/res_pjsip_session.c --- asterisk-16.8.0-orig/res/res_pjsip_session.c 2020-02-04 16:03:05.000000000 +0100 +++ asterisk-16.8.0-patched/res/res_pjsip_session.c 2020-03-04 14:05:19.173937415 +0100 @@ -4329,16 +4329,12 @@ if (sdp->conn) { char host[NI_MAXHOST]; - struct ast_sockaddr our_sdp_addr = { { 0, } }; + struct ast_sockaddr addr = { { 0, } }; ast_copy_pj_str(host, &sdp->conn->addr, sizeof(host)); - ast_sockaddr_parse(&our_sdp_addr, host, PARSE_PORT_FORBID); + ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID); - /* 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) { + if (ast_sip_transport_is_nonlocal(transport_state, &addr)) { 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)); pj_strassign(&sdp->origin.addr, &sdp->conn->addr); diff -u asterisk-16.8.0-orig/res/res_pjsip_t38.c asterisk-16.8.0-patched/res/res_pjsip_t38.c --- asterisk-16.8.0-orig/res/res_pjsip_t38.c 2020-02-04 16:03:05.000000000 +0100 +++ asterisk-16.8.0-patched/res/res_pjsip_t38.c 2020-03-04 14:06:25.956144620 +0100 @@ -1030,7 +1030,7 @@ { RAII_VAR(struct ast_sip_transport_state *, transport_state, ast_sip_get_transport_state(ast_sorcery_object_get_id(transport)), ao2_cleanup); char host[NI_MAXHOST]; - struct ast_sockaddr our_sdp_addr = { { 0, } }; + struct ast_sockaddr addr = { { 0, } }; /* If the stream has been rejected there will be no connection line */ if (!stream->conn || !transport_state) { @@ -1038,13 +1038,10 @@ } ast_copy_pj_str(host, &stream->conn->addr, sizeof(host)); - ast_sockaddr_parse(&our_sdp_addr, host, PARSE_PORT_FORBID); + ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID); - /* 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 not, we won't do rewriting. No localnet - * configured? Always rewrite. */ - if (ast_sip_transport_is_nonlocal(transport_state, &our_sdp_addr) && transport_state->localnet) { + /* Is the address within the SDP inside the same network? */ + if (ast_sip_transport_is_local(transport_state, &addr)) { return; } ast_debug(5, "Setting media address to %s\n", ast_sockaddr_stringify_host(&transport_state->external_media_address)); Common subdirectories: asterisk-16.8.0-orig/res/snmp and asterisk-16.8.0-patched/res/snmp Common subdirectories: asterisk-16.8.0-orig/res/srtp and asterisk-16.8.0-patched/res/srtp Common subdirectories: asterisk-16.8.0-orig/res/stasis and asterisk-16.8.0-patched/res/stasis Common subdirectories: asterisk-16.8.0-orig/res/stasis_recording and asterisk-16.8.0-patched/res/stasis_recording