[asterisk-commits] tilghman: trunk r82200 - in /trunk: UPGRADE.txt channels/chan_iax2.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 10 15:03:52 CDT 2007
Author: tilghman
Date: Mon Sep 10 15:03:51 2007
New Revision: 82200
URL: http://svn.digium.com/view/asterisk?view=rev&rev=82200
Log:
Change the IAXPeers command to have manager-style output, instead of CLI-style output (closes issue #8254)
Modified:
trunk/UPGRADE.txt
trunk/channels/chan_iax2.c
Modified: trunk/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/trunk/UPGRADE.txt?view=diff&rev=82200&r1=82199&r2=82200
==============================================================================
--- trunk/UPGRADE.txt (original)
+++ trunk/UPGRADE.txt Mon Sep 10 15:03:51 2007
@@ -113,3 +113,8 @@
semicolon, in order to make the Local channel driver compatible with the comma
delimiter change in applications.
+Manager:
+
+* The IAXpeers command output has been changed to more closely resemble the
+ output of the SIPpeers command.
+
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=82200&r1=82199&r2=82200
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Mon Sep 10 15:03:51 2007
@@ -4505,7 +4505,7 @@
char name[256];
int registeredonly=0;
char *term = manager ? "\r\n" : "\n";
-
+ char idtext[256] = "";
switch (argc) {
case 6:
if (!strcasecmp(argv[3], "registered"))
@@ -4540,9 +4540,7 @@
}
- if (s)
- astman_append(s, FORMAT2, "Name/Username", "Host", " ", "Mask", "Port", " ", "Status", term);
- else
+ if (!s)
ast_cli(fd, FORMAT2, "Name/Username", "Host", " ", "Mask", "Port", " ", "Status", term);
i = ao2_iterator_init(peers, 0);
@@ -4581,12 +4579,21 @@
peer->encmethods ? "(E)" : " ", status, term);
if (s)
- astman_append(s, FORMAT, name,
- peer->addr.sin_addr.s_addr ? ast_inet_ntoa( peer->addr.sin_addr) : "(Unspecified)",
- ast_test_flag(peer, IAX_DYNAMIC) ? "(D)" : "(S)",
- nm,
- ntohs(peer->addr.sin_port), ast_test_flag(peer, IAX_TRUNK) ? "(T)" : " ",
- peer->encmethods ? "(E)" : " ", status, term);
+ astman_append(s,
+ "Event: PeerEntry\r\n%s"
+ "Channeltype: IAX2\r\n"
+ "ObjectName: %s\r\n"
+ "IPaddress: %s\r\n"
+ "IPport: %d\r\n"
+ "Dynamic: %s\r\n"
+ "Status: %s\r\n\r\n",
+ idtext,
+ name,
+ peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "-none-",
+ ntohs(peer->addr.sin_port),
+ ast_test_flag(peer, IAX_DYNAMIC) ? "yes" : "no",
+ status);
+
else
ast_cli(fd, FORMAT, name,
peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)",
@@ -4597,9 +4604,7 @@
total_peers++;
}
- if (s)
- astman_append(s,"%d iax2 peers [%d online, %d offline, %d unmonitored]%s", total_peers, online_peers, offline_peers, unmonitored_peers, term);
- else
+ if (!s)
ast_cli(fd,"%d iax2 peers [%d online, %d offline, %d unmonitored]%s", total_peers, online_peers, offline_peers, unmonitored_peers, term);
if (havepattern)
@@ -4748,14 +4753,13 @@
static int manager_iax2_show_peers(struct mansession *s, const struct message *m)
{
char *a[] = { "iax2", "show", "users" };
- int ret;
const char *id = astman_get_header(m,"ActionID");
+ char idtext[256] = "";
if (!ast_strlen_zero(id))
- astman_append(s, "ActionID: %s\r\n",id);
- ret = __iax2_show_peers(1, -1, s, 3, a );
- astman_append(s, "\r\n\r\n" );
- return ret;
+ snprintf(idtext, sizeof(idtext), "ActionID: %s\r\n", id);
+ astman_send_ack(s, m, "Peer status list will follow");
+ return __iax2_show_peers(1, -1, s, 3, a );
} /* /JDG */
static char *regstate2str(int regstate)
More information about the asterisk-commits
mailing list