[asterisk-commits] russell: branch russell/events r84694 - /team/russell/events/pbx/pbx_dundi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 4 17:07:09 CDT 2007


Author: russell
Date: Thu Oct  4 17:07:09 2007
New Revision: 84694

URL: http://svn.digium.com/view/asterisk?view=rev&rev=84694
Log:
add a CLI command for showing configured event mappings from dundi.conf

Modified:
    team/russell/events/pbx/pbx_dundi.c

Modified: team/russell/events/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/pbx/pbx_dundi.c?view=diff&rev=84694&r1=84693&r2=84694
==============================================================================
--- team/russell/events/pbx/pbx_dundi.c (original)
+++ team/russell/events/pbx/pbx_dundi.c Thu Oct  4 17:07:09 2007
@@ -290,6 +290,7 @@
 	AST_DECLARE_STRING_FIELDS(
 		/*! The DUNDi context where events are being published to */
 		AST_STRING_FIELD(context);
+		AST_STRING_FIELD(event_type_s);
 	);
 	/*! This is the Asterisk event type being published */
 	enum ast_event_type event_type;
@@ -2716,6 +2717,57 @@
 #undef FORMAT2
 }
 
+static int print_event_map(void *obj, void *arg, int flags)
+{
+	struct pub_event_map *map = obj;
+	struct ast_cli_args *a = arg;
+	struct ast_variable *v;
+
+	ast_cli(a->fd, "=== ---------------------------------------------------------\n"
+	               "=== Mapping:\n"
+	               "=== ==> DUNDi Context: %s\n"
+	               "=== ==> Event type: %s\n", map->context, map->event_type_s);
+
+	for (v = map->parameters; v; v = v->next) {
+		ast_cli(a->fd,
+		           "=== === --> %s = %s\n", v->name, v->value);
+	}
+
+	ast_cli(a->fd, "=== ---------------------------------------------------------\n"
+	               "===\n");
+
+	return 0;
+}
+
+static char *dundi_show_event_mappings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "dundi show event mappings";
+		e->usage =
+			"Usage: dundi show event mappings\n"
+			"   List all event mappings from dundi.conf\n";
+		return NULL;
+
+	case CLI_GENERATE:
+		return NULL;	/* no completion */
+	}
+
+	ast_cli(a->fd, "\n"
+	            "=============================================================\n"
+	            "=== Event Mappings ==========================================\n"
+	            "=============================================================\n"
+	            "===\n");
+
+
+	ao2_callback(pub_event_maps, OBJ_NODATA, print_event_map, a);
+
+	ast_cli(a->fd, "=============================================================\n"
+	               "\n");
+
+	return CLI_SUCCESS;
+}
+
 static const char debug_usage[] = 
 "Usage: dundi debug\n"
 "       Enables dumping of DUNDi packets for debugging purposes\n";
@@ -2846,6 +2898,8 @@
 	{ { "dundi", "query", NULL },
 	dundi_do_query, "Query a DUNDi EID",
 	query_usage },
+
+	NEW_CLI(dundi_show_event_mappings, "Show event mappings"),
 };
 
 static struct dundi_transaction *create_transaction(struct dundi_peer *p)
@@ -4819,6 +4873,7 @@
 		goto return_unref;
 
 	ast_string_field_set(pub_event_map, context, context);
+	ast_string_field_set(pub_event_map, event_type_s, event_type_s);
 
 	pub_event_map->event_type = event_type;
 
@@ -4859,6 +4914,8 @@
 			"for event mapping\n");
 		goto return_unref;
 	}
+
+	/*! XXX \todo Need to send a SUBSCRIBE out to the network */
 
 	ao2_link(pub_event_maps, pub_event_map);
 
@@ -5079,7 +5136,7 @@
 		pthread_join(previous_precachethreadid, NULL);
 	}
 
-	ast_cli_unregister_multiple(cli_dundi, sizeof(cli_dundi) / sizeof(struct ast_cli_entry));
+	ast_cli_unregister_multiple(cli_dundi, ARRAY_LEN(cli_dundi));
 	ast_unregister_switch(&dundi_switch);
 	ast_custom_function_unregister(&dundi_function);
 	ast_custom_function_unregister(&dundi_query_function);
@@ -5155,7 +5212,7 @@
 		return AST_MODULE_LOAD_FAILURE;
 	}
 	
-	ast_cli_register_multiple(cli_dundi, sizeof(cli_dundi) / sizeof(*cli_dundi));
+	ast_cli_register_multiple(cli_dundi, ARRAY_LEN(cli_dundi));
 	if (ast_register_switch(&dundi_switch))
 		ast_log(LOG_ERROR, "Unable to register DUNDi switch\n");
 	ast_custom_function_register(&dundi_function);




More information about the asterisk-commits mailing list