Skip to content

Commit 126de28

Browse files
InterLinked1Friendly Automation
authored andcommitted
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
1 parent b4966c4 commit 126de28

File tree

1 file changed

+16
-27
lines changed

1 file changed

+16
-27
lines changed

res/res_pjsip_caller_id.c

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -133,43 +133,32 @@ static pjsip_fromto_hdr *get_id_header(pjsip_rx_data *rdata, const pj_str_t *hea
133133
*/
134134
static int set_id_from_oli(pjsip_rx_data *rdata, int *ani2)
135135
{
136-
char fromhdr[AST_CHANNEL_NAME];
137-
const char *s = NULL;
138-
pjsip_sip_uri *uri;
139-
pjsip_name_addr *id_name_addr;
136+
char oli[AST_CHANNEL_NAME];
137+
138+
pjsip_param *oli1, *oli2, *oli3;
139+
140+
static const pj_str_t oli_str1 = { "isup-oli", 8 };
141+
static const pj_str_t oli_str2 = { "ss7-oli", 7 };
142+
static const pj_str_t oli_str3 = { "oli", 3 };
140143

141144
pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg,
142145
PJSIP_H_FROM, rdata->msg_info.msg->hdr.next);
143-
id_name_addr = (pjsip_name_addr *) from->uri;
144146

145147
if (!from) {
146-
/* This had better not happen */
147-
return -1;
148+
return -1; /* This had better not happen */
148149
}
149150

150-
uri = pjsip_uri_get_uri(id_name_addr);
151-
ast_copy_pj_str(fromhdr, &uri->user, sizeof(fromhdr));
152-
153-
/* Look for the possible OLI tags. */
154-
if ((s = strcasestr(fromhdr, ";isup-oli="))) {
155-
s += 10;
156-
} else if ((s = strcasestr(fromhdr, ";ss7-oli="))) {
157-
s += 9;
158-
} else if ((s = strcasestr(fromhdr, ";oli="))) {
159-
s += 5;
160-
}
161-
162-
if (ast_strlen_zero(s)) {
163-
/* OLI tag is missing, or present with nothing following the '=' sign */
151+
if ((oli1 = pjsip_param_find(&from->other_param, &oli_str1))) {
152+
ast_copy_pj_str(oli, &oli1->value, sizeof(oli));
153+
} else if ((oli2 = pjsip_param_find(&from->other_param, &oli_str2))) {
154+
ast_copy_pj_str(oli, &oli2->value, sizeof(oli));
155+
} else if ((oli3 = pjsip_param_find(&from->other_param, &oli_str3))) {
156+
ast_copy_pj_str(oli, &oli3->value, sizeof(oli));
157+
} else {
164158
return -1;
165159
}
166160

167-
/* just in case OLI is quoted */
168-
if (*s == '\"') {
169-
s++;
170-
}
171-
172-
return ast_str_to_int(s, ani2);
161+
return ast_str_to_int(oli, ani2);
173162
}
174163

175164
/*!

0 commit comments

Comments
 (0)