[asterisk-commits] mmichelson: branch mmichelson/rls-config r416661 - /team/mmichelson/rls-confi...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 18 18:04:43 CDT 2014
Author: mmichelson
Date: Wed Jun 18 18:04:39 2014
New Revision: 416661
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416661
Log:
Add an AMI command to list resource lists.
This will be helpful for testing, but it could also be
generally useful as well.
Modified:
team/mmichelson/rls-config/res/res_pjsip_pubsub.c
Modified: team/mmichelson/rls-config/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/rls-config/res/res_pjsip_pubsub.c?view=diff&rev=416661&r1=416660&r2=416661
==============================================================================
--- team/mmichelson/rls-config/res/res_pjsip_pubsub.c (original)
+++ team/mmichelson/rls-config/res/res_pjsip_pubsub.c Wed Jun 18 18:04:39 2014
@@ -72,6 +72,20 @@
</para>
</description>
</manager>
+ <manager name="PJSIPShowResourceLists" language="en_US">
+ <synopsis>
+ Lists resource lists.
+ </synopsis>
+ <syntax />
+ <description>
+ <para>
+ Provides a listing of all resource lists. An event <literal>ResourceListList</literal>
+ is issued for each resource list object. Once all detail events are completed a
+ <literal>ResourceListListComplete</literal> event is issued.
+ </para>
+ </description>
+ </manager>
+
<configInfo name="res_pjsip_pubsub" language="en_US">
<synopsis>Module that implements publish and subscribe support.</synopsis>
<configFile name="pjsip.conf">
@@ -1881,6 +1895,50 @@
return 0;
}
+static int format_ami_resource_lists(void *obj, void *arg, int flags)
+{
+ struct resource_list *list = obj;
+ struct ast_sip_ami *ami = arg;
+ struct ast_str *buf;
+
+ buf = ast_sip_create_ami_event("ResourceListList", ami);
+ if (!buf) {
+ return CMP_STOP;
+ }
+
+ if (ast_sip_sorcery_object_to_ami(list, &buf)) {
+ return CMP_STOP;
+ }
+
+ return 0;
+}
+
+static int ami_show_resource_lists(struct mansession *s, const struct message *m)
+{
+ struct ast_sip_ami ami = { .s = s, .m = m };
+ int num;
+ struct ao2_container *lists;
+
+ lists = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), "resource_list",
+ AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL);
+
+ if (!lists || !(num = ao2_container_count(lists))) {
+ astman_send_error(s, m, "No resource lists found\n");
+ return 0;
+ }
+
+ astman_send_listack(s, m, "A listing of resource lists follows, "
+ "presented as ResourceListList events", "start");
+
+ ao2_callback(lists, OBJ_NODATA, format_ami_resource_lists, &ami);
+
+ astman_append(s,
+ "Event: ResourceListListComplete\r\n"
+ "EventList: Complete\r\n"
+ "ListItems: %d\r\n\r\n", num);
+ return 0;
+}
+
#define AMI_SHOW_SUBSCRIPTIONS_INBOUND "PJSIPShowSubscriptionsInbound"
#define AMI_SHOW_SUBSCRIPTIONS_OUTBOUND "PJSIPShowSubscriptionsOutbound"
@@ -2080,6 +2138,8 @@
ami_show_subscriptions_inbound);
ast_manager_register_xml(AMI_SHOW_SUBSCRIPTIONS_OUTBOUND, EVENT_FLAG_SYSTEM,
ami_show_subscriptions_outbound);
+ ast_manager_register_xml("PJSIPShowResourceLists", EVENT_FLAG_SYSTEM,
+ ami_show_resource_lists);
return AST_MODULE_LOAD_SUCCESS;
}
@@ -2088,6 +2148,7 @@
{
ast_manager_unregister(AMI_SHOW_SUBSCRIPTIONS_OUTBOUND);
ast_manager_unregister(AMI_SHOW_SUBSCRIPTIONS_INBOUND);
+ ast_manager_unregister("PJSIPShowResourceLists");
if (sched) {
ast_sched_context_destroy(sched);
More information about the asterisk-commits
mailing list