[asterisk-commits] mmichelson: branch 12 r405298 - /branches/12/res/res_pjsip/security_events.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 10 13:39:26 CST 2014


Author: mmichelson
Date: Fri Jan 10 13:39:23 2014
New Revision: 405298

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=405298
Log:
Print "<unknown>" for artificial endpoint in PJSIP security events.

Previously, this printed a UUID, which was not very clear when dealing
with an artificial endpoint.

Review: https://reviewboard.asterisk.org/r/3113


Modified:
    branches/12/res/res_pjsip/security_events.c

Modified: branches/12/res/res_pjsip/security_events.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_pjsip/security_events.c?view=diff&rev=405298&r1=405297&r2=405298
==============================================================================
--- branches/12/res/res_pjsip/security_events.c (original)
+++ branches/12/res/res_pjsip/security_events.c Fri Jan 10 13:39:23 2014
@@ -67,6 +67,13 @@
 	ast_sockaddr_set_port(remote, rdata->pkt_info.src_port);
 }
 
+static const char *get_account_id(struct ast_sip_endpoint *endpoint)
+{
+	RAII_VAR(struct ast_sip_endpoint *, artificial, ast_sip_get_artificial_endpoint(), ao2_cleanup);
+
+	return endpoint == artificial ? "<unknown>" : ast_sorcery_object_get_id(endpoint);
+}
+
 void ast_sip_report_invalid_endpoint(const char *name, pjsip_rx_data *rdata)
 {
 	enum ast_transport transport = security_event_get_transport(rdata);
@@ -104,7 +111,7 @@
 			.common.event_type  = AST_SECURITY_EVENT_FAILED_ACL,
 			.common.version     = AST_SECURITY_EVENT_FAILED_ACL_VERSION,
 			.common.service     = "PJSIP",
-			.common.account_id  = ast_sorcery_object_get_id(endpoint),
+			.common.account_id  = get_account_id(endpoint),
 			.common.local_addr  = {
 					.addr       = &local,
 					.transport  = transport,
@@ -129,12 +136,13 @@
 	char call_id[pj_strlen(&rdata->msg_info.cid->id) + 1];
 	char nonce[64] = "", response[256] = "";
 	struct ast_sockaddr local, remote;
+	RAII_VAR(struct ast_sip_endpoint *, artificial, ast_sip_get_artificial_endpoint(), ao2_cleanup);
 
 	struct ast_security_event_chal_resp_failed chal_resp_failed = {
 				.common.event_type = AST_SECURITY_EVENT_CHAL_RESP_FAILED,
 				.common.version    = AST_SECURITY_EVENT_CHAL_RESP_FAILED_VERSION,
 				.common.service    = "PJSIP",
-				.common.account_id = ast_sorcery_object_get_id(endpoint),
+				.common.account_id = get_account_id(endpoint),
 				.common.local_addr = {
 						.addr      = &local,
 						.transport = transport,
@@ -148,7 +156,7 @@
 				.challenge         = nonce,
 				.response          = response,
 				.expected_response = "",
-		};
+	};
 
 	if (auth && !pj_strcmp2(&auth->scheme, "Digest")) {
 		ast_copy_pj_str(nonce, &auth->credential.digest.nonce, sizeof(nonce));
@@ -171,7 +179,7 @@
 			.common.event_type  = AST_SECURITY_EVENT_SUCCESSFUL_AUTH,
 			.common.version     = AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION,
 			.common.service     = "PJSIP",
-			.common.account_id  = ast_sorcery_object_get_id(endpoint),
+			.common.account_id  = get_account_id(endpoint),
 			.common.local_addr  = {
 					.addr       = &local,
 					.transport  = transport,
@@ -200,7 +208,7 @@
 			.common.event_type = AST_SECURITY_EVENT_CHAL_SENT,
 			.common.version    = AST_SECURITY_EVENT_CHAL_SENT_VERSION,
 			.common.service    = "PJSIP",
-			.common.account_id = ast_sorcery_object_get_id(endpoint),
+			.common.account_id = get_account_id(endpoint),
 			.common.local_addr = {
 					.addr      = &local,
 					.transport = transport,
@@ -233,7 +241,7 @@
 		.common.event_type  = AST_SECURITY_EVENT_REQ_NO_SUPPORT,
 		.common.version     = AST_SECURITY_EVENT_REQ_NO_SUPPORT_VERSION,
 		.common.service     = "PJSIP",
-		.common.account_id  = ast_sorcery_object_get_id(endpoint),
+		.common.account_id  = get_account_id(endpoint),
 		.common.local_addr  = {
 			.addr       = &local,
 			.transport  = transport,
@@ -261,7 +269,7 @@
 		.common.event_type  = AST_SECURITY_EVENT_MEM_LIMIT,
 		.common.version     = AST_SECURITY_EVENT_MEM_LIMIT_VERSION,
 		.common.service     = "PJSIP",
-		.common.account_id  = ast_sorcery_object_get_id(endpoint),
+		.common.account_id  = get_account_id(endpoint),
 		.common.local_addr  = {
 			.addr       = &local,
 			.transport  = transport,




More information about the asterisk-commits mailing list