aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-04 21:23:30 +0000
committerqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-04 21:23:30 +0000
commita2d2f6950208386d2158c1c42d83dcf35955e722 (patch)
treece9c7c504bcf84c7594c00cd1e4acdf1196d7371
parentbdd896e7bec050adc63834cce2e24e224d689a24 (diff)
Add manager action 'sipshowregistry'.
Closes issue #11464, patch by eliel. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@90991 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--CHANGES1
-rw-r--r--channels/chan_sip.c57
2 files changed, 57 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 476baf554..772df3d55 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,7 @@
AMI - The manager (TCP/TLS/HTTP)
--------------------------------
+ * Added a new action 'SIPshowregistry' to list SIP registrations.
* Added TLS support for the manager interface and HTTP server
* Added the URI redirect option for the built-in HTTP server
* The output of CallerID in Manager events is now more consistent.
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 15cd86ef6..d4532521f 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -10813,6 +10813,59 @@ static char *sip_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
#undef FORMAT
}
+/*! \brief Manager Action SIPShowRegistry description */
+static char mandescr_show_registry[] =
+"Description: Lists all registration requests and status\n"
+"Registrations will follow as separate events. followed by a final event called\n"
+"RegistrationsComplete.\n"
+"Variables: \n"
+" ActionID: <id> Action ID for this transaction. Will be returned.\n";
+
+/*! \brief Show SIP registrations in the manager API */
+static int manager_show_registry(struct mansession *s, const struct message *m)
+{
+ const char *id = astman_get_header(m, "ActionID");
+ char idtext[256] = "";
+ char tmpdat[256] = "";
+ int total = 0;
+ struct ast_tm tm;
+
+ if (!ast_strlen_zero(id))
+ snprintf(idtext, sizeof(idtext), "ActionID: %s\r\n", id);
+
+ astman_send_listack(s, m, "Registrations will follow", "start");
+
+ ASTOBJ_CONTAINER_TRAVERSE(&regl, 1, do {
+ ASTOBJ_RDLOCK(iterator);
+ if (iterator->regtime.tv_sec) {
+ ast_localtime(&iterator->regtime, &tm, NULL);
+ ast_strftime(tmpdat, sizeof(tmpdat), "%a, %d %b %Y %T", &tm);
+ } else
+ tmpdat[0] = '\0';
+ astman_append(s,
+ "Event: RegistryEntry\r\n"
+ "Host: %s\r\n"
+ "Port: %d\r\n"
+ "Username: %s\r\n"
+ "Refresh: %d\r\n"
+ "State: %s\r\n"
+ "Reg.Time: %s\r\n"
+ "\r\n", iterator->hostname, iterator->portno ? iterator->portno : STANDARD_SIP_PORT,
+ iterator->username, iterator->refresh, regstate2str(iterator->regstate), tmpdat);
+ ASTOBJ_UNLOCK(iterator);
+ total++;
+ } while(0));
+
+ astman_append(s,
+ "Event: RegistrationsComplete\r\n"
+ "EventList: Complete\r\n"
+ "ListItems: %d\r\n"
+ "%s"
+ "\r\n", total, idtext);
+
+ return 0;
+}
+
static char mandescr_show_peers[] =
"Description: Lists SIP peers in text format with details on current status.\n"
"Peerlist will follow as separate events, followed by a final event called\n"
@@ -19307,7 +19360,8 @@ static int load_module(void)
"List SIP peers (text format)", mandescr_show_peers);
ast_manager_register2("SIPshowpeer", EVENT_FLAG_SYSTEM, manager_sip_show_peer,
"Show SIP peer (text format)", mandescr_show_peer);
-
+ ast_manager_register2("SIPshowregistry", EVENT_FLAG_SYSTEM, manager_show_registry,
+ "Show SIP registrations (text format)", mandescr_show_registry);
sip_poke_all_peers();
sip_send_all_registers();
@@ -19348,6 +19402,7 @@ static int unload_module(void)
/* Unregister AMI actions */
ast_manager_unregister("SIPpeers");
ast_manager_unregister("SIPshowpeer");
+ ast_manager_unregister("SIPshowregistry");
dialoglist_lock();
/* Hangup all dialogs if they have an owner */