res_pjsip_caller_id: Also parse URI parameters for ANI2.

If the isup-oli was sent as a URI parameter, rather than a header
parameter, it was not being parsed. Make sure we parse both if
needed so the ANI2 is set regardless of which type of parameter
the isup-oli is sent as.

Resolves: #1220
(cherry picked from commit 5d82f69b9b)
This commit is contained in:
Naveen Albert
2025-04-26 08:33:20 -04:00
committed by Asterisk Development Team
parent aa55410b58
commit 5ebd110830

View File

@@ -35,6 +35,22 @@
#include "asterisk/callerid.h" #include "asterisk/callerid.h"
#include "asterisk/conversions.h" #include "asterisk/conversions.h"
static int extract_oli(const pjsip_param *param_list, char *buf, size_t len)
{
static const pj_str_t oli_str1 = { "isup-oli", 8 };
static const pj_str_t oli_str2 = { "ss7-oli", 7 };
static const pj_str_t oli_str3 = { "oli", 3 };
pjsip_param *oli;
if ((oli = pjsip_param_find(param_list, &oli_str1))
|| (oli = pjsip_param_find(param_list, &oli_str2))
|| (oli = pjsip_param_find(param_list, &oli_str3))) {
ast_copy_pj_str(buf, &oli->value, len);
return 0;
}
return -1;
}
/*! /*!
* \internal * \internal
* \brief Set an ANI2 integer based on OLI data in a From header * \brief Set an ANI2 integer based on OLI data in a From header
@@ -50,12 +66,6 @@ static int set_id_from_oli(pjsip_rx_data *rdata, int *ani2)
{ {
char oli[AST_CHANNEL_NAME]; char oli[AST_CHANNEL_NAME];
pjsip_param *oli1, *oli2, *oli3;
static const pj_str_t oli_str1 = { "isup-oli", 8 };
static const pj_str_t oli_str2 = { "ss7-oli", 7 };
static const pj_str_t oli_str3 = { "oli", 3 };
pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg, pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg,
PJSIP_H_FROM, rdata->msg_info.msg->hdr.next); PJSIP_H_FROM, rdata->msg_info.msg->hdr.next);
@@ -63,14 +73,18 @@ static int set_id_from_oli(pjsip_rx_data *rdata, int *ani2)
return -1; /* This had better not happen */ return -1; /* This had better not happen */
} }
if ((oli1 = pjsip_param_find(&from->other_param, &oli_str1))) { /* First, check if it was provided as a header paramter */
ast_copy_pj_str(oli, &oli1->value, sizeof(oli)); if (extract_oli(&from->other_param, oli, sizeof(oli))) {
} else if ((oli2 = pjsip_param_find(&from->other_param, &oli_str2))) { /* If not found, check if it was provided as a URI parameter */
ast_copy_pj_str(oli, &oli2->value, sizeof(oli)); pjsip_sip_uri *uri;
} else if ((oli3 = pjsip_param_find(&from->other_param, &oli_str3))) { pjsip_name_addr *name_addr = (pjsip_name_addr *) from->uri;
ast_copy_pj_str(oli, &oli3->value, sizeof(oli)); if (!ast_sip_is_uri_sip_sips(name_addr->uri)) {
} else { return -1;
return -1; }
uri = pjsip_uri_get_uri(name_addr->uri);
if (extract_oli(&uri->other_param, oli, sizeof(oli))) {
return -1; /* Not found as either type of parameter */
}
} }
return ast_str_to_int(oli, ani2); return ast_str_to_int(oli, ani2);