[asterisk-commits] file: branch group/stasis_cache_usage r392853 - /team/group/stasis_cache_usag...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jun 25 12:20:45 CDT 2013
Author: file
Date: Tue Jun 25 12:20:43 2013
New Revision: 392853
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392853
Log:
Add an AMI action for getting bridge information.
Modified:
team/group/stasis_cache_usage/main/manager.c
Modified: team/group/stasis_cache_usage/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/group/stasis_cache_usage/main/manager.c?view=diff&rev=392853&r1=392852&r2=392853
==============================================================================
--- team/group/stasis_cache_usage/main/manager.c (original)
+++ team/group/stasis_cache_usage/main/manager.c Tue Jun 25 12:20:43 2013
@@ -219,6 +219,21 @@
<description>
<para>Will return the status information of each channel along with the
value for the specified channel variables.</para>
+ </description>
+ </manager>
+ <manager name="BridgeShow" language="en_US">
+ <synopsis>
+ List bridge information.
+ </synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+ <parameter name="Bridge" required="false">
+ <para>Optional identifier of a specific bridge.</para>
+ </parameter>
+ </syntax>
+ <description>
+ <para>Will return the bridge information of each bridge, or optionally
+ only information for a specific bridge.</para>
</description>
</manager>
<manager name="Setvar" language="en_US">
@@ -3825,6 +3840,105 @@
return 0;
}
+/*! \brief Manager "bridgeshow" command to show bridges */
+static int action_bridgeshow(struct mansession *s, const struct message *m)
+{
+ const char *name = astman_get_header(m, "Bridge");
+ RAII_VAR(struct ao2_container *, cached_bridges, NULL, ao2_cleanup);
+ struct stasis_message *msg;
+ int bridges = 0;
+ int all = ast_strlen_zero(name); /* set if we want all channels */
+ const char *id = astman_get_header(m, "ActionID");
+ char idText[256];
+ struct ast_str *str = ast_str_create(1000);
+ struct ao2_iterator it_bridges;
+
+ if (!ast_strlen_zero(id)) {
+ snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
+ } else {
+ idText[0] = '\0';
+ }
+
+ if (all) {
+ if (!(cached_bridges = stasis_cache_dump(ast_bridge_topic_all_cached(), ast_bridge_snapshot_type()))) {
+ ast_free(str);
+ astman_send_error(s, m, "Memory Allocation Failure");
+ return 1;
+ }
+ it_bridges = ao2_iterator_init(cached_bridges, 0);
+ msg = ao2_iterator_next(&it_bridges);
+ } else {
+ if (!(msg = stasis_cache_get(ast_bridge_topic_all_cached(), ast_bridge_snapshot_type(), name))) {
+ astman_send_error(s, m, "No such bridge");
+ ast_free(str);
+ return 0;
+ }
+ }
+
+ astman_send_ack(s, m, "Bridge status will follow");
+
+ /* if we look by name, we break after the first iteration */
+ for (; msg; msg = ao2_iterator_next(&it_bridges)) {
+ struct ast_bridge_snapshot *snapshot = stasis_message_data(msg);
+ struct ao2_iterator it_chans;
+ char *chan;
+
+ bridges++;
+
+ ast_str_reset(str);
+ it_chans = ao2_iterator_init(snapshot->channels, 0);
+ for (; (chan = ao2_iterator_next(&it_chans)); ao2_ref(chan, -1)) {
+ RAII_VAR(struct stasis_message *, chan_msg, NULL, ao2_cleanup);
+ struct ast_channel_snapshot *channel_snapshot;
+
+ if (!(chan_msg = stasis_cache_get(ast_channel_topic_all_cached(), ast_channel_snapshot_type(), chan))) {
+ continue;
+ }
+ channel_snapshot = stasis_message_data(chan_msg);
+
+ ast_str_append(&str, 0, "Channel: %s\r\n", channel_snapshot->name);
+ }
+ ao2_iterator_destroy(&it_chans);
+
+ astman_append(s,
+ "Event: BridgeShow\r\n"
+ "Privilege: Call\r\n"
+ "Bridge: %s\r\n"
+ "Type: %s\r\n"
+ "Technology: %s\r\n"
+ "Num-Channels: %d\r\n"
+ "%s"
+ "%s"
+ "\r\n",
+ snapshot->uniqueid,
+ snapshot->subclass,
+ snapshot->technology,
+ snapshot->num_channels,
+ ast_str_buffer(str),
+ idText);
+
+ ao2_ref(msg, -1);
+
+ if (!all) {
+ break;
+ }
+ }
+
+ if (all) {
+ ao2_iterator_destroy(&it_bridges);
+ }
+
+ astman_append(s,
+ "Event: BridgeShowComplete\r\n"
+ "%s"
+ "Items: %d\r\n"
+ "\r\n", idText, bridges);
+
+ ast_free(str);
+
+ return 0;
+}
+
static int action_sendtext(struct mansession *s, const struct message *m)
{
struct ast_channel *c = NULL;
@@ -7752,6 +7866,7 @@
ast_manager_register_xml_core("Challenge", 0, action_challenge);
ast_manager_register_xml_core("Hangup", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL, action_hangup);
ast_manager_register_xml_core("Status", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_status);
+ ast_manager_register_xml_core("BridgeShow", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_bridgeshow);
ast_manager_register_xml_core("Setvar", EVENT_FLAG_CALL, action_setvar);
ast_manager_register_xml_core("Getvar", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_getvar);
ast_manager_register_xml_core("GetConfig", EVENT_FLAG_SYSTEM | EVENT_FLAG_CONFIG, action_getconfig);
More information about the asterisk-commits
mailing list