mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Merge "res/res_pjsip_session: Only check localnet if it is defined"
This commit is contained in:
@@ -262,18 +262,18 @@ static pj_status_t nat_on_tx_message(pjsip_tx_data *tdata)
|
|||||||
return PJ_SUCCESS;
|
return PJ_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !transport_state->localnet || ast_sockaddr_isnull(&transport_state->external_address)) {
|
if (transport_state->localnet) {
|
||||||
return PJ_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ast_sockaddr_parse(&addr, tdata->tp_info.dst_name, PARSE_PORT_FORBID);
|
ast_sockaddr_parse(&addr, tdata->tp_info.dst_name, PARSE_PORT_FORBID);
|
||||||
ast_sockaddr_set_port(&addr, tdata->tp_info.dst_port);
|
ast_sockaddr_set_port(&addr, tdata->tp_info.dst_port);
|
||||||
|
|
||||||
/* See if where we are sending this request is local or not, and if not that we can get a Contact URI to modify */
|
/* See if where we are sending this request is local or not, and if not that we can get a Contact URI to modify */
|
||||||
if (ast_apply_ha(transport_state->localnet, &addr) != AST_SENSE_ALLOW) {
|
if (ast_apply_ha(transport_state->localnet, &addr) != AST_SENSE_ALLOW) {
|
||||||
|
ast_debug(5, "Request is being sent to local address, skipping NAT manipulation\n");
|
||||||
return PJ_SUCCESS;
|
return PJ_SUCCESS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ast_sockaddr_isnull(&transport_state->external_address)) {
|
||||||
/* Update the contact header with the external address */
|
/* Update the contact header with the external address */
|
||||||
if (uri || (uri = nat_get_contact_sip_uri(tdata))) {
|
if (uri || (uri = nat_get_contact_sip_uri(tdata))) {
|
||||||
pj_strdup2(tdata->pool, &uri->host, ast_sockaddr_stringify_host(&transport_state->external_address));
|
pj_strdup2(tdata->pool, &uri->host, ast_sockaddr_stringify_host(&transport_state->external_address));
|
||||||
@@ -290,6 +290,7 @@ static pj_status_t nat_on_tx_message(pjsip_tx_data *tdata)
|
|||||||
via->sent_by.port = transport->external_signaling_port;
|
via->sent_by.port = transport->external_signaling_port;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Invoke any additional hooks that may be registered */
|
/* Invoke any additional hooks that may be registered */
|
||||||
if ((hooks = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), "nat_hook", AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL))) {
|
if ((hooks = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), "nat_hook", AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL))) {
|
||||||
|
@@ -1487,10 +1487,11 @@ static void change_outgoing_sdp_stream_media_address(pjsip_tx_data *tdata, struc
|
|||||||
ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID);
|
ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID);
|
||||||
|
|
||||||
/* Is the address within the SDP inside the same network? */
|
/* Is the address within the SDP inside the same network? */
|
||||||
if (ast_apply_ha(transport_state->localnet, &addr) == AST_SENSE_ALLOW) {
|
if (transport_state->localnet
|
||||||
|
&& ast_apply_ha(transport_state->localnet, &addr) == AST_SENSE_ALLOW) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ast_debug(5, "Setting media address to %s\n", transport->external_media_address);
|
||||||
pj_strdup2(tdata->pool, &stream->conn->addr, transport->external_media_address);
|
pj_strdup2(tdata->pool, &stream->conn->addr, transport->external_media_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3126,7 +3126,10 @@ static void session_outgoing_nat_hook(pjsip_tx_data *tdata, struct ast_sip_trans
|
|||||||
ast_copy_pj_str(host, &sdp->conn->addr, sizeof(host));
|
ast_copy_pj_str(host, &sdp->conn->addr, sizeof(host));
|
||||||
ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID);
|
ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID);
|
||||||
|
|
||||||
if (ast_apply_ha(transport_state->localnet, &addr) != AST_SENSE_ALLOW) {
|
if (!transport_state->localnet
|
||||||
|
|| (transport_state->localnet
|
||||||
|
&& ast_apply_ha(transport_state->localnet, &addr) == AST_SENSE_ALLOW)) {
|
||||||
|
ast_debug(5, "Setting external media address to %s\n", transport->external_media_address);
|
||||||
pj_strdup2(tdata->pool, &sdp->conn->addr, transport->external_media_address);
|
pj_strdup2(tdata->pool, &sdp->conn->addr, transport->external_media_address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -867,10 +867,11 @@ static void change_outgoing_sdp_stream_media_address(pjsip_tx_data *tdata, struc
|
|||||||
ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID);
|
ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID);
|
||||||
|
|
||||||
/* Is the address within the SDP inside the same network? */
|
/* Is the address within the SDP inside the same network? */
|
||||||
if (ast_apply_ha(transport_state->localnet, &addr) == AST_SENSE_ALLOW) {
|
if (transport_state->localnet
|
||||||
|
&& ast_apply_ha(transport_state->localnet, &addr) == AST_SENSE_ALLOW) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ast_debug(5, "Setting media address to %s\n", transport->external_media_address);
|
||||||
pj_strdup2(tdata->pool, &stream->conn->addr, transport->external_media_address);
|
pj_strdup2(tdata->pool, &stream->conn->addr, transport->external_media_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user