[Asterisk-code-review] res pjsip outbound registration: Adding Cause field value to... (asterisk[15])

Dmitriy Serov asteriskteam at digium.com
Fri Oct 5 15:54:46 CDT 2018


Dmitriy Serov has uploaded this change for review. ( https://gerrit.asterisk.org/10445


Change subject: res_pjsip_outbound_registration: Adding Cause field value to AMI event Registry
......................................................................

res_pjsip_outbound_registration: Adding Cause field value to AMI event Registry

Often there are problems with outbound registration.
By tracking the AMI Registry event, I want to know the textual cause of
registration problems that the server often reports.
Cause field of AMI event is the most appropriate way to get this information.

ASTERISK-28092 #close
Reported-by: Dmitriy Serov

Change-Id: I52d5176d9449d657ad3d33c1437f800c6318dc7b
---
M res/res_pjsip_outbound_registration.c
1 file changed, 14 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/45/10445/1

diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index b5c42f1..5c22fd7 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -892,6 +892,7 @@
 	pjsip_regc_info info;
 	char server_uri[PJSIP_MAX_URL_SIZE];
 	char client_uri[PJSIP_MAX_URL_SIZE];
+	const char *reason = NULL;
 
 	if (response->client_state->status == SIP_REGISTRATION_STOPPED) {
 		ao2_ref(response, -1);
@@ -1011,8 +1012,20 @@
 		}
 	}
 
+        if (response->rdata) {
+                static const pj_str_t str_reason = { "Reason", 6 };
+                pjsip_generic_string_hdr *reason_hdr;
+                pj_str_t reason_value;
+
+                reason_hdr = pjsip_msg_find_hdr_by_name(response->rdata->msg_info.msg, &str_reason, NULL);
+                if (reason_hdr) {
+			pj_strdup_with_null(response->rdata->tp_info.pool, &reason_value, &reason_hdr->hvalue);
+			reason = pj_strbuf(&reason_value);
+                }
+        }
+
 	ast_system_publish_registry("PJSIP", client_uri, server_uri,
-		sip_outbound_registration_status_str(response->client_state->status), NULL);
+		sip_outbound_registration_status_str(response->client_state->status), reason);
 
 	if (response->client_state->destroy) {
 		/* We have a pending deferred destruction to complete now. */

-- 
To view, visit https://gerrit.asterisk.org/10445
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: I52d5176d9449d657ad3d33c1437f800c6318dc7b
Gerrit-Change-Number: 10445
Gerrit-PatchSet: 1
Gerrit-Owner: Dmitriy Serov <serov.d.p at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181005/8a22e0fe/attachment-0001.html>


More information about the asterisk-code-review mailing list