mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
res_pjsip_session: Use Caller ID for extension matching.
Currently, there is no Caller ID available to us when checking for an extension match when handling INVITEs. As a result, extension patterns that depend on the Caller ID are not matched and calls may be incorrectly rejected. The Caller ID is not available because the supplement that adds Caller ID to the session does not execute until after this check. Supplement callbacks cannot yet be executed at this point since the session is not yet in the appropriate state. To fix this without impacting existing behavior, the Caller ID number is now retrieved before attempting to pattern match. This ensures pattern matching works correctly and there is no behavior change to the way supplements are called. ASTERISK-28767 #close Change-Id: Iec7f5a3b90e51b65ccf74342f96bf80314b7cfc7
This commit is contained in:
committed by
Friendly Automation
parent
f86d2a211c
commit
c4066871d8
@@ -3641,6 +3641,21 @@ struct ast_sip_session *ast_sip_dialog_get_session(pjsip_dialog *dlg)
|
||||
return session;
|
||||
}
|
||||
|
||||
/*! \brief Fetch just the Caller ID number in order of PAI, RPID, From */
|
||||
static int fetch_callerid_num(struct ast_sip_session *session, pjsip_rx_data *rdata, char *buf, size_t len)
|
||||
{
|
||||
int res = -1;
|
||||
struct ast_party_id id;
|
||||
|
||||
ast_party_id_init(&id);
|
||||
if (!ast_sip_set_id_from_invite(rdata, &id, &session->endpoint->id.self, session->endpoint->id.trust_inbound)) {
|
||||
ast_copy_string(buf, id.number.str, len);
|
||||
res = 0;
|
||||
}
|
||||
ast_party_id_free(&id);
|
||||
return res;
|
||||
}
|
||||
|
||||
enum sip_get_destination_result {
|
||||
/*! The extension was successfully found */
|
||||
SIP_GET_DEST_EXTEN_FOUND,
|
||||
@@ -3664,6 +3679,7 @@ enum sip_get_destination_result {
|
||||
*/
|
||||
static enum sip_get_destination_result get_destination(struct ast_sip_session *session, pjsip_rx_data *rdata)
|
||||
{
|
||||
char cid_num[AST_CHANNEL_NAME];
|
||||
pjsip_uri *ruri = rdata->msg_info.msg->line.req.uri;
|
||||
struct ast_features_pickup_config *pickup_cfg;
|
||||
const char *pickupexten;
|
||||
@@ -3695,8 +3711,10 @@ static enum sip_get_destination_result get_destination(struct ast_sip_session *s
|
||||
ao2_ref(pickup_cfg, -1);
|
||||
}
|
||||
|
||||
fetch_callerid_num(session, rdata, cid_num, sizeof(cid_num));
|
||||
|
||||
if (!strcmp(session->exten, pickupexten) ||
|
||||
ast_exists_extension(NULL, session->endpoint->context, session->exten, 1, NULL)) {
|
||||
ast_exists_extension(NULL, session->endpoint->context, session->exten, 1, S_OR(cid_num, NULL))) {
|
||||
/*
|
||||
* Save off the INVITE Request-URI in case it is
|
||||
* needed: CHANNEL(pjsip,request_uri)
|
||||
@@ -3711,7 +3729,7 @@ static enum sip_get_destination_result get_destination(struct ast_sip_session *s
|
||||
*/
|
||||
if (session->endpoint->allow_overlap && (
|
||||
!strncmp(session->exten, pickupexten, strlen(session->exten)) ||
|
||||
ast_canmatch_extension(NULL, session->endpoint->context, session->exten, 1, NULL))) {
|
||||
ast_canmatch_extension(NULL, session->endpoint->context, session->exten, 1, S_OR(cid_num, NULL)))) {
|
||||
/* Overlap partial match */
|
||||
return SIP_GET_DEST_EXTEN_PARTIAL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user