mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
res_pjsip: Fix path usage in case dialing with '@'
Fix aor lookup on sip path addition. Issue happens in case of dialing with @ and overriding user part of RURI. ASTERISK-30100 #close Reported-by: Yury Kirsanov Change-Id: I3f2c42a583578c94397b113e32ca3ebf2d600e13
This commit is contained in:
committed by
Friendly Automation
parent
af7af641d6
commit
9fd14d60e0
@@ -36,71 +36,16 @@
|
|||||||
static const pj_str_t PATH_NAME = { "Path", 4 };
|
static const pj_str_t PATH_NAME = { "Path", 4 };
|
||||||
static pj_str_t PATH_SUPPORTED_NAME = { "path", 4 };
|
static pj_str_t PATH_SUPPORTED_NAME = { "path", 4 };
|
||||||
|
|
||||||
static struct ast_sip_aor *find_aor(struct ast_sip_endpoint *endpoint, pjsip_uri *uri)
|
static struct ast_sip_aor *find_aor(struct ast_sip_contact *contact)
|
||||||
{
|
{
|
||||||
char *configured_aors, *aor_name;
|
if (!contact) {
|
||||||
const pj_str_t *uri_username;
|
return NULL;
|
||||||
const pj_str_t *uri_hostname;
|
}
|
||||||
char *domain_name;
|
if (ast_strlen_zero(contact->aor)) {
|
||||||
char *username;
|
|
||||||
struct ast_str *id = NULL;
|
|
||||||
|
|
||||||
if (ast_strlen_zero(endpoint->aors)) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uri_hostname = ast_sip_pjsip_uri_get_hostname(uri);
|
return ast_sip_location_retrieve_aor(contact->aor);
|
||||||
domain_name = ast_alloca(uri_hostname->slen + 1);
|
|
||||||
ast_copy_pj_str(domain_name, uri_hostname, uri_hostname->slen + 1);
|
|
||||||
|
|
||||||
uri_username = ast_sip_pjsip_uri_get_username(uri);
|
|
||||||
username = ast_alloca(uri_username->slen + 1);
|
|
||||||
ast_copy_pj_str(username, uri_username, uri_username->slen + 1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We may want to match without any user options getting
|
|
||||||
* in the way.
|
|
||||||
*/
|
|
||||||
AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(username);
|
|
||||||
|
|
||||||
configured_aors = ast_strdupa(endpoint->aors);
|
|
||||||
|
|
||||||
/* Iterate the configured AORs to see if the user or the user+domain match */
|
|
||||||
while ((aor_name = ast_strip(strsep(&configured_aors, ",")))) {
|
|
||||||
struct ast_sip_domain_alias *alias = NULL;
|
|
||||||
|
|
||||||
if (ast_strlen_zero(aor_name)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(username, aor_name)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!id && !(id = ast_str_create(strlen(username) + uri_hostname->slen + 2))) {
|
|
||||||
aor_name = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ast_str_set(&id, 0, "%s@", username);
|
|
||||||
if ((alias = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "domain_alias", domain_name))) {
|
|
||||||
ast_str_append(&id, 0, "%s", alias->domain);
|
|
||||||
ao2_cleanup(alias);
|
|
||||||
} else {
|
|
||||||
ast_str_append(&id, 0, "%s", domain_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(aor_name, ast_str_buffer(id))) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ast_free(id);
|
|
||||||
|
|
||||||
if (ast_strlen_zero(aor_name)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ast_sip_location_retrieve_aor(aor_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -173,7 +118,7 @@ static void path_outgoing_request(struct ast_sip_endpoint *endpoint, struct ast_
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
aor = find_aor(endpoint, tdata->msg->line.req.uri);
|
aor = find_aor(contact);
|
||||||
if (!aor || !aor->support_path) {
|
if (!aor || !aor->support_path) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -205,7 +150,6 @@ static void path_outgoing_response(struct ast_sip_endpoint *endpoint, struct ast
|
|||||||
struct pjsip_status_line status = tdata->msg->line.status;
|
struct pjsip_status_line status = tdata->msg->line.status;
|
||||||
pj_str_t path_dup;
|
pj_str_t path_dup;
|
||||||
pjsip_generic_string_hdr *path_hdr;
|
pjsip_generic_string_hdr *path_hdr;
|
||||||
pjsip_contact_hdr *contact_hdr;
|
|
||||||
RAII_VAR(struct ast_sip_aor *, aor, NULL, ao2_cleanup);
|
RAII_VAR(struct ast_sip_aor *, aor, NULL, ao2_cleanup);
|
||||||
pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL);
|
pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL);
|
||||||
const pj_str_t REGISTER_METHOD = {"REGISTER", 8};
|
const pj_str_t REGISTER_METHOD = {"REGISTER", 8};
|
||||||
@@ -216,12 +160,7 @@ static void path_outgoing_response(struct ast_sip_endpoint *endpoint, struct ast
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_hdr = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CONTACT, NULL);
|
aor = find_aor(contact);
|
||||||
if (!contact_hdr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
aor = find_aor(endpoint, contact_hdr->uri);
|
|
||||||
if (!aor || !aor->support_path || add_supported(tdata)
|
if (!aor || !aor->support_path || add_supported(tdata)
|
||||||
|| path_get_string(tdata->pool, contact, &path_dup)) {
|
|| path_get_string(tdata->pool, contact, &path_dup)) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user