[Asterisk-code-review] res pjsip rfc3326.c: Account for more than one 'Reason' header (asterisk[master])
Jenkins2
asteriskteam at digium.com
Thu Mar 15 06:51:40 CDT 2018
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/8524 )
Change subject: res_pjsip_rfc3326.c: Account for more than one 'Reason' header
......................................................................
res_pjsip_rfc3326.c: Account for more than one 'Reason' header
ASTERISK-27741
Change-Id: I0aa59a54735c6d20b95c54db1bd095dbf93e7adf
---
M res/res_pjsip_rfc3326.c
1 file changed, 26 insertions(+), 23 deletions(-)
Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved
Jenkins2: Approved for Submit
diff --git a/res/res_pjsip_rfc3326.c b/res/res_pjsip_rfc3326.c
index 5ac16f0..76b0d08 100644
--- a/res/res_pjsip_rfc3326.c
+++ b/res/res_pjsip_rfc3326.c
@@ -35,32 +35,35 @@
static void rfc3326_use_reason_header(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
{
- const pj_str_t str_reason = { "Reason", 6 };
- pjsip_generic_string_hdr *header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, NULL);
- char buf[20], *cause, *text;
+ static const pj_str_t str_reason = { "Reason", 6 };
+ pjsip_generic_string_hdr *header;
+ char buf[20];
+ char *cause;
+ char *text;
int code;
- if (!header) {
- return;
+ header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, NULL);
+ for (; header;
+ header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, header->next)) {
+ ast_copy_pj_str(buf, &header->hvalue, sizeof(buf));
+ cause = ast_skip_blanks(buf);
+
+ if (strncasecmp(cause, "Q.850", 5) || !(cause = strstr(cause, "cause="))) {
+ continue;
+ }
+
+ /* If text is present get rid of it */
+ if ((text = strstr(cause, ";"))) {
+ *text = '\0';
+ }
+
+ if (sscanf(cause, "cause=%30d", &code) != 1) {
+ continue;
+ }
+
+ ast_channel_hangupcause_set(session->channel, code & 0x7f);
+ break;
}
-
- ast_copy_pj_str(buf, &header->hvalue, sizeof(buf));
- cause = ast_skip_blanks(buf);
-
- if (strncasecmp(cause, "Q.850", 5) || !(cause = strstr(cause, "cause="))) {
- return;
- }
-
- /* If text is present get rid of it */
- if ((text = strstr(cause, ";"))) {
- *text = '\0';
- }
-
- if (sscanf(cause, "cause=%30d", &code) != 1) {
- return;
- }
-
- ast_channel_hangupcause_set(session->channel, code & 0x7f);
}
static int rfc3326_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
--
To view, visit https://gerrit.asterisk.org/8524
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I0aa59a54735c6d20b95c54db1bd095dbf93e7adf
Gerrit-Change-Number: 8524
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Ross Beer <ross.beer at voicehost.co.uk>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180315/149dd1ae/attachment-0001.html>
More information about the asterisk-code-review
mailing list