summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwayne M. Hubbard <dwayne.hubbard@gmail.com>2007-06-06 22:35:35 +0000
committerDwayne M. Hubbard <dwayne.hubbard@gmail.com>2007-06-06 22:35:35 +0000
commit611c9ed353676da4c836874755d34aa103b2f2d6 (patch)
tree390b27bda25397334ab38a4b6782e3ab7f18a4db
parent6aec360466517a159d720b4ccc0d5505992089ea (diff)
added CLI 'iax2 unregister <peername>' for issue 9812, thanks eliel
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@67901 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--channels/chan_iax2.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 94ebdcf8b..086f4b03d 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -4436,6 +4436,49 @@ static int iax2_show_threads(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int iax2_unregister(int fd, int argc, char *argv[]) {
+ struct iax2_peer *p;
+
+ if (argc != 3)
+ return RESULT_SHOWUSAGE;
+
+ p = find_peer(argv[2], 1);
+ if (p) {
+ if (p->expire > 0) {
+ expire_registry(argv[2]);
+ ast_cli(fd, "Peer %s unregistered\n", argv[2]);
+ } else {
+ ast_cli(fd, "Peer %s not registered\n", argv[2]);
+ }
+ } else {
+ ast_cli(fd, "Peer unknown: %s. Not unregistered\n", argv[2]);
+ }
+ return RESULT_SUCCESS;
+}
+
+static char *complete_iax2_unregister(const char *line, const char *word, int pos, int state)
+{
+ int which = 0;
+ struct iax2_peer *p = NULL;
+ char *res = NULL;
+ int wordlen = strlen(word);
+
+ /* 0 - iax2; 1 - unregister; 2 - <peername> */
+ if (pos == 2) {
+ AST_LIST_LOCK(&peers);
+ AST_LIST_TRAVERSE(&peers, p, entry) {
+ if (!strncasecmp(p->name, word, wordlen) &&
+ ++which > state && p->expire > 0) {
+ res = ast_strdup(p->name);
+ break;
+ }
+ }
+ AST_LIST_UNLOCK(&peers);
+ }
+
+ return res;
+}
+
static int iax2_show_peers(int fd, int argc, char *argv[])
{
return __iax2_show_peers(0, fd, NULL, argc, argv);
@@ -10270,6 +10313,10 @@ static const char show_threads_usage[] =
"Usage: iax2 show threads\n"
" Lists status of IAX helper threads\n";
+static const char unregister_usage[] =
+"Usage: iax2 unregister <peername>\n"
+" Unregister (force expiration) an IAX2 peer from the registry.\n";
+
static const char show_peers_usage[] =
"Usage: iax2 show peers [registered] [like <pattern>]\n"
" Lists all known IAX2 peers.\n"
@@ -10359,6 +10406,10 @@ static struct ast_cli_entry cli_iax2[] = {
iax2_show_threads, "Display IAX helper thread info",
show_threads_usage },
+ { { "iax2", "unregister", NULL },
+ iax2_unregister, "Unregister (force expiration) an IAX2 peer from the registry",
+ unregister_usage, complete_iax2_unregister },
+
{ { "iax2", "set", "mtu", NULL },
iax2_set_mtu, "Set the IAX systemwide trunking MTU",
set_mtu_usage, NULL, NULL },