[asterisk-commits] gtjoseph: branch 13 r423284 - in /branches/13: ./ include/asterisk/ res/ res/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 18 10:13:32 CDT 2014


Author: gtjoseph
Date: Thu Sep 18 10:13:29 2014
New Revision: 423284

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=423284
Log:
res_pjsip: ami: Fix error in AMI output when an endpoint has no transport

When no transport is associated to an endpoint, the AMI output for
PJSIPShowEndpoint indicates an error instead of silently ignoring the
missing transport.

This patch causes the error to appear only if a transport was specified
on the endpoint and the transport doesn't exist.  It also fixes an issue
with counting the objects that were actually found.

ASTERISK-24161 #close
ASTERISK-24331 #close
Tested by: George Joseph
Review: https://reviewboard.asterisk.org/r/3998/
........

Merged revisions 423282 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    branches/13/   (props changed)
    branches/13/include/asterisk/res_pjsip.h
    branches/13/res/res_pjsip/config_auth.c
    branches/13/res/res_pjsip/config_transport.c
    branches/13/res/res_pjsip/location.c
    branches/13/res/res_pjsip/pjsip_configuration.c
    branches/13/res/res_pjsip/pjsip_options.c
    branches/13/res/res_pjsip_endpoint_identifier_ip.c

Propchange: branches/13/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: branches/13/include/asterisk/res_pjsip.h
URL: http://svnview.digium.com/svn/asterisk/branches/13/include/asterisk/res_pjsip.h?view=diff&rev=423284&r1=423283&r2=423284
==============================================================================
--- branches/13/include/asterisk/res_pjsip.h (original)
+++ branches/13/include/asterisk/res_pjsip.h Thu Sep 18 10:13:29 2014
@@ -1727,6 +1727,8 @@
 	const char *action_id;
 	/*! user specified argument data */
 	void *arg;
+	/*! count of objects */
+	int count;
 };
 
 /*!

Modified: branches/13/res/res_pjsip/config_auth.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/res_pjsip/config_auth.c?view=diff&rev=423284&r1=423283&r2=423284
==============================================================================
--- branches/13/res/res_pjsip/config_auth.c (original)
+++ branches/13/res/res_pjsip/config_auth.c Thu Sep 18 10:13:29 2014
@@ -175,6 +175,8 @@
 	}
 
 	astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
+	ami->count++;
+
 	return 0;
 }
 

Modified: branches/13/res/res_pjsip/config_transport.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/res_pjsip/config_transport.c?view=diff&rev=423284&r1=423283&r2=423284
==============================================================================
--- branches/13/res/res_pjsip/config_transport.c (original)
+++ branches/13/res/res_pjsip/config_transport.c Thu Sep 18 10:13:29 2014
@@ -39,16 +39,20 @@
 static int format_ami_endpoint_transport(const struct ast_sip_endpoint *endpoint,
 					 struct ast_sip_ami *ami)
 {
-	RAII_VAR(struct ast_str *, buf,
-		 ast_sip_create_ami_event("TransportDetail", ami), ast_free);
-	RAII_VAR(struct ast_sip_transport *,
-		 transport, ast_sorcery_retrieve_by_id(
-			 ast_sip_get_sorcery(), "transport",
-			 endpoint->transport), ao2_cleanup);
+	RAII_VAR(struct ast_str *, buf, NULL, ast_free);
+	RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup);
+
+	if (ast_strlen_zero(endpoint->transport)) {
+		return 0;
+	}
+
+	buf = ast_sip_create_ami_event("TransportDetail", ami);
 	if (!buf) {
 		return -1;
 	}
 
+	transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport",
+		endpoint->transport);
 	if (!transport) {
 		astman_send_error_va(ami->s, ami->m, "Unable to retrieve "
 				     "transport %s\n", endpoint->transport);
@@ -61,6 +65,8 @@
 		       ast_sorcery_object_get_id(endpoint));
 
 	astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
+	ami->count++;
+
 	return 0;
 }
 

Modified: branches/13/res/res_pjsip/location.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/res_pjsip/location.c?view=diff&rev=423284&r1=423283&r2=423284
==============================================================================
--- branches/13/res/res_pjsip/location.c (original)
+++ branches/13/res/res_pjsip/location.c Thu Sep 18 10:13:29 2014
@@ -506,6 +506,8 @@
 		       ast_sorcery_object_get_id(endpoint));
 
 	astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
+	ami->count++;
+
 	return 0;
 }
 

Modified: branches/13/res/res_pjsip/pjsip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/res_pjsip/pjsip_configuration.c?view=diff&rev=423284&r1=423283&r2=423284
==============================================================================
--- branches/13/res/res_pjsip/pjsip_configuration.c (original)
+++ branches/13/res/res_pjsip/pjsip_configuration.c Thu Sep 18 10:13:29 2014
@@ -1107,7 +1107,8 @@
 
 static int ami_show_endpoint(struct mansession *s, const struct message *m)
 {
-	struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"), };
+	struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"),
+		.count = 0, };
 	RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
 	const char *endpoint_name = astman_get_header(m, "Endpoint");
 	int count = 0;
@@ -1144,7 +1145,8 @@
 		astman_append(s, "ActionID: %s\r\n", ami.action_id);
 	}
 	astman_append(s, "EventList: Complete\r\n"
-		      "ListItems: %d\r\n\r\n", count + 1);
+		      "ListItems: %d\r\n\r\n", ami.count + 1);
+
 	return 0;
 }
 

Modified: branches/13/res/res_pjsip/pjsip_options.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/res_pjsip/pjsip_options.c?view=diff&rev=423284&r1=423283&r2=423284
==============================================================================
--- branches/13/res/res_pjsip/pjsip_options.c (original)
+++ branches/13/res/res_pjsip/pjsip_options.c Thu Sep 18 10:13:29 2014
@@ -995,7 +995,8 @@
 	ast_str_append(&buf, 0, "EndpointName: %s\r\n",
 			ast_sorcery_object_get_id(endpoint));
 	astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
-
+	ami->count++;
+	
 	ast_free(buf);
 	ao2_cleanup(status);
 	return 0;

Modified: branches/13/res/res_pjsip_endpoint_identifier_ip.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/res_pjsip_endpoint_identifier_ip.c?view=diff&rev=423284&r1=423283&r2=423284
==============================================================================
--- branches/13/res/res_pjsip_endpoint_identifier_ip.c (original)
+++ branches/13/res/res_pjsip_endpoint_identifier_ip.c Thu Sep 18 10:13:29 2014
@@ -263,6 +263,8 @@
 		ast_sorcery_object_get_id(endpoint));
 
 	astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
+	ami->count++;
+
 	return 0;
 }
 




More information about the asterisk-commits mailing list