[Asterisk-code-review] res_pjsip_callerid: Fix OLI parsing (asterisk[19])
N A
asteriskteam at digium.com
Tue Nov 16 06:15:32 CST 2021
N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/17483 )
Change subject: res_pjsip_callerid: Fix OLI parsing
......................................................................
res_pjsip_callerid: Fix OLI parsing
Fix parsing of ANI2/OLI information, since it was previously
parsing the user, when it should have been parsing other_param.
Also improves the parsing by using pjproject native functions
rather than trying to parse the parameters ourselves like
chan_sip did. A previous attempt at this caused a crash, but
this works correctly now.
ASTERISK-29703 #close
Change-Id: I8f3c79032d9ea1a21d16f8e11f22bd8d887738a1
---
M res/res_pjsip_caller_id.c
1 file changed, 18 insertions(+), 29 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/83/17483/1
diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c
index 3b871cd..f1c89ee 100644
--- a/res/res_pjsip_caller_id.c
+++ b/res/res_pjsip_caller_id.c
@@ -133,43 +133,32 @@
*/
static int set_id_from_oli(pjsip_rx_data *rdata, int *ani2)
{
- char fromhdr[AST_CHANNEL_NAME];
- const char *s = NULL;
- pjsip_sip_uri *uri;
- pjsip_name_addr *id_name_addr;
+ 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_H_FROM, rdata->msg_info.msg->hdr.next);
- id_name_addr = (pjsip_name_addr *) from->uri;
if (!from) {
- /* This had better not happen */
+ return -1; /* This had better not happen */
+ }
+
+ if ((oli1 = pjsip_param_find(&from->other_param, &oli_str1))) {
+ ast_copy_pj_str(oli, &oli1->value, sizeof(oli));
+ } else if ((oli2 = pjsip_param_find(&from->other_param, &oli_str2))) {
+ ast_copy_pj_str(oli, &oli2->value, sizeof(oli));
+ } else if ((oli3 = pjsip_param_find(&from->other_param, &oli_str3))) {
+ ast_copy_pj_str(oli, &oli3->value, sizeof(oli));
+ } else {
return -1;
}
- uri = pjsip_uri_get_uri(id_name_addr);
- ast_copy_pj_str(fromhdr, &uri->user, sizeof(fromhdr));
-
- /* Look for the possible OLI tags. */
- if ((s = strcasestr(fromhdr, ";isup-oli="))) {
- s += 10;
- } else if ((s = strcasestr(fromhdr, ";ss7-oli="))) {
- s += 9;
- } else if ((s = strcasestr(fromhdr, ";oli="))) {
- s += 5;
- }
-
- if (ast_strlen_zero(s)) {
- /* OLI tag is missing, or present with nothing following the '=' sign */
- return -1;
- }
-
- /* just in case OLI is quoted */
- if (*s == '\"') {
- s++;
- }
-
- return ast_str_to_int(s, ani2);
+ return ast_str_to_int(oli, ani2);
}
/*!
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/17483
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 19
Gerrit-Change-Id: I8f3c79032d9ea1a21d16f8e11f22bd8d887738a1
Gerrit-Change-Number: 17483
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211116/ebc0e982/attachment-0001.html>
More information about the asterisk-code-review
mailing list