aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-02-08 21:26:32 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-02-08 21:26:32 +0000
commite9d6c2ff9b22167c463b055b65e8351dc0a4cc0c (patch)
tree425b3dafd75451669e2311d091127fe03d3c9693 /main
parent381f0dce1439f8c5344300a846760ea930987ed3 (diff)
Merge changes from team/mvanbaak/cli-command-audit
(closes issue #8925) About a year ago, as Leif Madsen and Jim van Meggelen were going over the CLI commands in Asterisk 1.4 for the next version of their book, they documented a lot of inconsistencies. This set of changes addresses all of these issues and has been reviewed by Leif. While this does introduce even more changes to the CLI command structure, it makes everything consistent, which is the most important thing. Thanks to all that helped with this one! git-svn-id: http://svn.digium.com/svn/asterisk/trunk@103171 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/asterisk.c122
-rw-r--r--main/cdr.c17
-rw-r--r--main/pbx.c2
-rw-r--r--main/rtp.c142
-rw-r--r--main/udptl.c147
5 files changed, 332 insertions, 98 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index 4b899cdd9..187623e71 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -1535,28 +1535,36 @@ static char *handle_stop_now(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
{
switch (cmd) {
case CLI_INIT:
- e->command = "stop now";
+ e->command = "core stop now";
e->usage =
- "Usage: stop now\n"
+ "Usage: core stop now\n"
" Shuts down a running Asterisk immediately, hanging up all active calls .\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
- if (a->argc != 2)
+ if (a->argc != e->args)
return CLI_SHOWUSAGE;
quit_handler(0, 0 /* Not nice */, 1 /* safely */, 0 /* not restart */);
return CLI_SUCCESS;
}
+static char *handle_stop_now_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ char *res = handle_stop_now(e, cmd, a);
+ if (cmd == CLI_INIT)
+ e->command = "stop now";
+ return res;
+}
+
static char *handle_stop_gracefully(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
- e->command = "stop gracefully";
+ e->command = "core stop gracefully";
e->usage =
- "Usage: stop gracefully\n"
+ "Usage: core stop gracefully\n"
" Causes Asterisk to not accept new calls, and exit when all\n"
" active calls have terminated normally.\n";
return NULL;
@@ -1564,39 +1572,55 @@ static char *handle_stop_gracefully(struct ast_cli_entry *e, int cmd, struct ast
return NULL;
}
- if (a->argc != 2)
+ if (a->argc != e->args)
return CLI_SHOWUSAGE;
quit_handler(0, 1 /* nicely */, 1 /* safely */, 0 /* no restart */);
return CLI_SUCCESS;
}
+static char *handle_stop_gracefully_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ char *res = handle_stop_gracefully(e, cmd, a);
+ if (cmd == CLI_INIT)
+ e->command = "stop gracefully";
+ return res;
+}
+
static char *handle_stop_when_convenient(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
- e->command = "stop when convenient";
+ e->command = "core stop when convenient";
e->usage =
- "Usage: stop when convenient\n"
+ "Usage: core stop when convenient\n"
" Causes Asterisk to perform a shutdown when all active calls have ended.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
- if (a->argc != 3)
+ if (a->argc != e->args)
return CLI_SHOWUSAGE;
ast_cli(a->fd, "Waiting for inactivity to perform halt\n");
quit_handler(0, 2 /* really nicely */, 1 /* safely */, 0 /* don't restart */);
return CLI_SUCCESS;
}
+static char *handle_stop_when_convenient_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ char *res = handle_stop_when_convenient(e, cmd, a);
+ if (cmd == CLI_INIT)
+ e->command = "stop when convenient";
+ return res;
+}
+
static char *handle_restart_now(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
- e->command = "restart now";
+ e->command = "core restart now";
e->usage =
- "Usage: restart now\n"
+ "Usage: core restart now\n"
" Causes Asterisk to hangup all calls and exec() itself performing a cold\n"
" restart.\n";
return NULL;
@@ -1604,19 +1628,27 @@ static char *handle_restart_now(struct ast_cli_entry *e, int cmd, struct ast_cli
return NULL;
}
- if (a->argc != 2)
+ if (a->argc != e->args)
return CLI_SHOWUSAGE;
quit_handler(0, 0 /* not nicely */, 1 /* safely */, 1 /* restart */);
return CLI_SUCCESS;
}
+static char *handle_restart_now_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ char *res = handle_restart_now(e, cmd, a);
+ if (cmd == CLI_INIT)
+ e->command = "restart now";
+ return res;
+}
+
static char *handle_restart_gracefully(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
- e->command = "restart gracefully";
+ e->command = "core restart gracefully";
e->usage =
- "Usage: restart gracefully\n"
+ "Usage: core restart gracefully\n"
" Causes Asterisk to stop accepting new calls and exec() itself performing a cold\n"
" restart when all active calls have ended.\n";
return NULL;
@@ -1624,39 +1656,55 @@ static char *handle_restart_gracefully(struct ast_cli_entry *e, int cmd, struct
return NULL;
}
- if (a->argc != 2)
+ if (a->argc != e->args)
return CLI_SHOWUSAGE;
quit_handler(0, 1 /* nicely */, 1 /* safely */, 1 /* restart */);
return CLI_SUCCESS;
}
+static char *handle_restart_gracefully_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ char *res = handle_restart_gracefully(e, cmd, a);
+ if (cmd == CLI_INIT)
+ e->command = "restart gracefully";
+ return res;
+}
+
static char *handle_restart_when_convenient(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
- e->command = "restart when convenient";
+ e->command = "core restart when convenient";
e->usage =
- "Usage: restart when convenient\n"
+ "Usage: core restart when convenient\n"
" Causes Asterisk to perform a cold restart when all active calls have ended.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
- if (a->argc != 3)
+ if (a->argc != e->args)
return CLI_SHOWUSAGE;
ast_cli(a->fd, "Waiting for inactivity to perform restart\n");
quit_handler(0, 2 /* really nicely */, 1 /* safely */, 1 /* restart */);
return CLI_SUCCESS;
}
+static char *handle_restart_when_convenient_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ char *res = handle_restart_when_convenient(e, cmd, a);
+ if (cmd == CLI_INIT)
+ e->command = "restart when convenient";
+ return res;
+}
+
static char *handle_abort_shutdown(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
- e->command = "abort shutdown";
+ e->command = "core abort shutdown";
e->usage =
- "Usage: abort shutdown\n"
+ "Usage: core abort shutdown\n"
" Causes Asterisk to abort an executing shutdown or restart, and resume normal\n"
" call operations.\n";
return NULL;
@@ -1664,13 +1712,21 @@ static char *handle_abort_shutdown(struct ast_cli_entry *e, int cmd, struct ast_
return NULL;
}
- if (a->argc != 2)
+ if (a->argc != e->args)
return CLI_SHOWUSAGE;
ast_cancel_shutdown();
shuttingdown = 0;
return CLI_SUCCESS;
}
+static char *handle_abort_shutdown_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ char *res = handle_abort_shutdown(e, cmd, a);
+ if (cmd == CLI_INIT)
+ e->command = "abort shutdown";
+ return res;
+}
+
static char *handle_bang(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
@@ -1770,14 +1826,24 @@ static char *show_license(struct ast_cli_entry *e, int cmd, struct ast_cli_args
#define ASTERISK_PROMPT2 "%s*CLI> "
+/* deprecated cli entries */
+static struct ast_cli_entry cli_abort_shutdown_deprecated = AST_CLI_DEFINE(handle_abort_shutdown_deprecated, "Cancel a running shutdown.");
+static struct ast_cli_entry cli_stop_now_deprecated = AST_CLI_DEFINE(handle_stop_now_deprecated, "Shut down Asterisk immediately.");
+static struct ast_cli_entry cli_stop_gracefully_deprecated = AST_CLI_DEFINE(handle_stop_gracefully_deprecated, "Gracefully shut down Asterisk.");
+static struct ast_cli_entry cli_stop_when_convenient_deprecated = AST_CLI_DEFINE(handle_stop_when_convenient_deprecated, "Shut down Asterisk at empty call volume.");
+static struct ast_cli_entry cli_restart_now_deprecated = AST_CLI_DEFINE(handle_restart_now_deprecated, "Restart Asterisk immediately.");
+static struct ast_cli_entry cli_restart_gracefully_deprecated = AST_CLI_DEFINE(handle_restart_gracefully_deprecated, "Restart Asterisk gracefully.");
+static struct ast_cli_entry cli_restart_when_convenient_deprecated = AST_CLI_DEFINE(handle_restart_when_convenient_deprecated, "Restart Asterisk at empty call volume.");
+/* end deprecated cli entries */
+
static struct ast_cli_entry cli_asterisk[] = {
- AST_CLI_DEFINE(handle_abort_shutdown, "Cancel a running shutdown"),
- AST_CLI_DEFINE(handle_stop_now, "Shut down Asterisk immediately"),
- AST_CLI_DEFINE(handle_stop_gracefully, "Gracefully shut down Asterisk"),
- AST_CLI_DEFINE(handle_stop_when_convenient, "Shut down Asterisk at empty call volume"),
- AST_CLI_DEFINE(handle_restart_now, "Restart Asterisk immediately"),
- AST_CLI_DEFINE(handle_restart_gracefully, "Restart Asterisk gracefully"),
- AST_CLI_DEFINE(handle_restart_when_convenient, "Restart Asterisk at empty call volume"),
+ AST_CLI_DEFINE(handle_abort_shutdown, "Cancel a running shutdown", .deprecate_cmd = &cli_abort_shutdown_deprecated),
+ AST_CLI_DEFINE(handle_stop_now, "Shut down Asterisk immediately", .deprecate_cmd = &cli_stop_now_deprecated),
+ AST_CLI_DEFINE(handle_stop_gracefully, "Gracefully shut down Asterisk", .deprecate_cmd = &cli_stop_gracefully_deprecated),
+ AST_CLI_DEFINE(handle_stop_when_convenient, "Shut down Asterisk at empty call volume", .deprecate_cmd = &cli_stop_when_convenient_deprecated),
+ AST_CLI_DEFINE(handle_restart_now, "Restart Asterisk immediately", .deprecate_cmd = &cli_restart_now_deprecated),
+ AST_CLI_DEFINE(handle_restart_gracefully, "Restart Asterisk gracefully", .deprecate_cmd = &cli_restart_gracefully_deprecated),
+ AST_CLI_DEFINE(handle_restart_when_convenient, "Restart Asterisk at empty call volume", .deprecate_cmd = &cli_restart_when_convenient_deprecated),
AST_CLI_DEFINE(show_warranty, "Show the warranty (if any) for this copy of Asterisk"),
AST_CLI_DEFINE(show_license, "Show the license(s) for this copy of Asterisk"),
AST_CLI_DEFINE(handle_version, "Display version info"),
diff --git a/main/cdr.c b/main/cdr.c
index 85545be62..488eeee1c 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -1236,16 +1236,16 @@ static char *handle_cli_status(struct ast_cli_entry *e, int cmd, struct ast_cli_
switch (cmd) {
case CLI_INIT:
- e->command = "cdr status";
+ e->command = "cdr show status";
e->usage =
- "Usage: cdr status\n"
+ "Usage: cdr show status\n"
" Displays the Call Detail Record engine system status.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
- if (a->argc > 2)
+ if (a->argc > 3)
return CLI_SHOWUSAGE;
ast_cli(a->fd, "CDR logging: %s\n", enabled ? "enabled" : "disabled");
@@ -1274,6 +1274,14 @@ static char *handle_cli_status(struct ast_cli_entry *e, int cmd, struct ast_cli_
return CLI_SUCCESS;
}
+static char *handle_cli_status_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ char *res = handle_cli_status(e, cmd, a);
+ if (cmd == CLI_INIT)
+ e->command = "cdr status";
+ return res;
+}
+
static char *handle_cli_submit(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
@@ -1296,7 +1304,8 @@ static char *handle_cli_submit(struct ast_cli_entry *e, int cmd, struct ast_cli_
}
static struct ast_cli_entry cli_submit = AST_CLI_DEFINE(handle_cli_submit, "Posts all pending batched CDR data");
-static struct ast_cli_entry cli_status = AST_CLI_DEFINE(handle_cli_status, "Display the CDR status");
+static struct ast_cli_entry cli_status_deprecated = AST_CLI_DEFINE(handle_cli_status_deprecated, "Display the CDR status");
+static struct ast_cli_entry cli_status = AST_CLI_DEFINE(handle_cli_status, "Display the CDR status", .deprecate_cmd = &cli_status_deprecated);
static int do_reload(int reload)
{
diff --git a/main/pbx.c b/main/pbx.c
index 468aa5425..693c4b8b4 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -4645,7 +4645,7 @@ static char *handle_show_dialplan(struct ast_cli_entry *e, int cmd, struct ast_c
case CLI_INIT:
e->command = "dialplan show";
e->usage =
- "Usage: dialplan show [exten@][context]\n"
+ "Usage: dialplan show [[exten@]context]\n"
" Show dialplan\n";
return NULL;
case CLI_GENERATE:
diff --git a/main/rtp.c b/main/rtp.c
index b514d33eb..932c6f62e 100644
--- a/main/rtp.c
+++ b/main/rtp.c
@@ -3898,7 +3898,7 @@ static char *rtcp_do_debug_ip(struct ast_cli_args *a)
return CLI_SUCCESS;
}
-static char *handle_cli_rtp_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *handle_cli_rtp_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
@@ -3933,7 +3933,40 @@ static char *handle_cli_rtp_debug(struct ast_cli_entry *e, int cmd, struct ast_c
return CLI_SUCCESS;
}
-static char *handle_cli_rtcp_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *handle_cli_rtp_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "rtp set debug {on|off|ip}";
+ e->usage =
+ "Usage: rtp set debug {on|off|ip host[:port]}\n"
+ " Enable/Disable dumping of all RTP packets. If 'ip' is\n"
+ " specified, limit the dumped packets to those to and from\n"
+ " the specified 'host' with optional port.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc == e->args) { /* set on or off */
+ if (!strncasecmp(a->argv[e->args-1], "on", 2)) {
+ rtpdebug = 1;
+ memset(&rtpdebugaddr, 0, sizeof(rtpdebugaddr));
+ ast_cli(a->fd, "RTP Debugging Enabled\n");
+ return CLI_SUCCESS;
+ } else if (!strncasecmp(a->argv[e->args-1], "off", 3)) {
+ rtpdebug = 0;
+ ast_cli(a->fd, "RTP Debugging Disabled\n");
+ return CLI_SUCCESS;
+ }
+ } else if (a->argc == e->args +1) { /* ip */
+ return rtp_do_debug_ip(a);
+ }
+
+ return CLI_SHOWUSAGE; /* default, failure */
+}
+
+static char *handle_cli_rtcp_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
@@ -3968,7 +4001,40 @@ static char *handle_cli_rtcp_debug(struct ast_cli_entry *e, int cmd, struct ast_
return CLI_SUCCESS;
}
-static char *handle_cli_rtcp_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *handle_cli_rtcp_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "rtcp set debug {on|off|ip}";
+ e->usage =
+ "Usage: rtcp set debug {on|off|ip host[:port]}\n"
+ " Enable/Disable dumping of all RTCP packets. If 'ip' is\n"
+ " specified, limit the dumped packets to those to and from\n"
+ " the specified 'host' with optional port.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc == e->args) { /* set on or off */
+ if (!strncasecmp(a->argv[e->args-1], "on", 2)) {
+ rtcpdebug = 1;
+ memset(&rtcpdebugaddr, 0, sizeof(rtcpdebugaddr));
+ ast_cli(a->fd, "RTCP Debugging Enabled\n");
+ return CLI_SUCCESS;
+ } else if (!strncasecmp(a->argv[e->args-1], "off", 3)) {
+ rtcpdebug = 0;
+ ast_cli(a->fd, "RTCP Debugging Disabled\n");
+ return CLI_SUCCESS;
+ }
+ } else if (a->argc == e->args +1) { /* ip */
+ return rtcp_do_debug_ip(a);
+ }
+
+ return CLI_SHOWUSAGE; /* default, failure */
+}
+
+static char *handle_cli_rtcp_stats_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
@@ -3991,7 +4057,34 @@ static char *handle_cli_rtcp_stats(struct ast_cli_entry *e, int cmd, struct ast_
return CLI_SUCCESS;
}
-static char *handle_cli_stun_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *handle_cli_rtcp_set_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "rtcp set stats {on|off}";
+ e->usage =
+ "Usage: rtcp set stats {on|off}\n"
+ " Enable/Disable dumping of RTCP stats.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != e->args)
+ return CLI_SHOWUSAGE;
+
+ if (!strncasecmp(a->argv[e->args-1], "on", 2))
+ rtcpstats = 1;
+ else if (!strncasecmp(a->argv[e->args-1], "off", 3))
+ rtcpstats = 0;
+ else
+ return CLI_SHOWUSAGE;
+
+ ast_cli(a->fd, "RTCP Stats %s\n", rtcpstats ? "Enabled" : "Disabled");
+ return CLI_SUCCESS;
+}
+
+static char *handle_cli_stun_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
@@ -4015,11 +4108,44 @@ static char *handle_cli_stun_debug(struct ast_cli_entry *e, int cmd, struct ast_
return CLI_SUCCESS;
}
+static char *handle_cli_stun_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "stun set debug {on|off}";
+ e->usage =
+ "Usage: stun set debug {on|off}\n"
+ " Enable/Disable STUN (Simple Traversal of UDP through NATs)\n"
+ " debugging\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != e->args)
+ return CLI_SHOWUSAGE;
+
+ if (!strncasecmp(a->argv[e->args-1], "on", 2))
+ stundebug = 1;
+ else if (!strncasecmp(a->argv[e->args-1], "off", 3))
+ stundebug = 0;
+ else
+ return CLI_SHOWUSAGE;
+
+ ast_cli(a->fd, "STUN Debugging %s\n", stundebug ? "Enabled" : "Disabled");
+ return CLI_SUCCESS;
+}
+
+static struct ast_cli_entry cli_rtp_debug_deprecated = AST_CLI_DEFINE(handle_cli_rtp_debug_deprecated, "Enable/Disable RTP debugging");
+static struct ast_cli_entry cli_rtcp_debug_deprecated = AST_CLI_DEFINE(handle_cli_rtcp_debug_deprecated, "Enable/Disable RTCP debugging");
+static struct ast_cli_entry cli_rtcp_stats_deprecated = AST_CLI_DEFINE(handle_cli_rtcp_stats_deprecated, "Enable/Disable RTCP stats");
+static struct ast_cli_entry cli_stun_debug_deprecated = AST_CLI_DEFINE(handle_cli_stun_debug_deprecated, "Enable/Disable STUN debugging");
+
static struct ast_cli_entry cli_rtp[] = {
- AST_CLI_DEFINE(handle_cli_rtp_debug, "Enable/Disable RTP debugging"),
- AST_CLI_DEFINE(handle_cli_rtcp_debug, "Enable/Disable RTCP debugging"),
- AST_CLI_DEFINE(handle_cli_rtcp_stats, "Enable/Disable RTCP stats"),
- AST_CLI_DEFINE(handle_cli_stun_debug, "Enable/Disable STUN debugging"),
+ AST_CLI_DEFINE(handle_cli_rtp_set_debug, "Enable/Disable RTP debugging", .deprecate_cmd = &cli_rtp_debug_deprecated),
+ AST_CLI_DEFINE(handle_cli_rtcp_set_debug, "Enable/Disable RTCP debugging", .deprecate_cmd = &cli_rtcp_debug_deprecated),
+ AST_CLI_DEFINE(handle_cli_rtcp_set_stats, "Enable/Disable RTCP stats", .deprecate_cmd = &cli_rtcp_stats_deprecated),
+ AST_CLI_DEFINE(handle_cli_stun_set_debug, "Enable/Disable STUN debugging", .deprecate_cmd = &cli_stun_debug_deprecated),
};
static int __ast_rtp_reload(int reload)
diff --git a/main/udptl.c b/main/udptl.c
index 12de3fd53..6ce344328 100644
--- a/main/udptl.c
+++ b/main/udptl.c
@@ -1087,7 +1087,7 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
return -1;
}
-static char *handle_cli_udptl_debug_ip(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *handle_cli_udptl_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct hostent *hp;
struct ast_hostent ahp;
@@ -1097,89 +1097,122 @@ static char *handle_cli_udptl_debug_ip(struct ast_cli_entry *e, int cmd, struct
switch (cmd) {
case CLI_INIT:
- e->command = "udptl debug ip";
- e->usage =
- "Usage: udptl debug [ip host[:port]]\n"
- " Enable dumping of all UDPTL packets to and from host.\n";
+ e->command = "udptl debug [off|ip]";
+ e->usage =
+ "Usage: udptl debug [off]|[ip host[:port]]\n"
+ " Enable or disable dumping of UDPTL packets.\n"
+ " If ip is specified, limit the dumped packets to those to and from\n"
+ " the specified 'host' with optional port.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
- port = 0;
-
- if (a->argc != 4)
- return CLI_SHOWUSAGE;
- arg = a->argv[3];
- p = strstr(arg, ":");
- if (p) {
- *p = '\0';
- p++;
- port = atoi(p);
- }
- hp = ast_gethostbyname(arg, &ahp);
- if (hp == NULL)
+ if (a->argc < 2 || a->argc > 4)
return CLI_SHOWUSAGE;
- udptldebugaddr.sin_family = AF_INET;
- memcpy(&udptldebugaddr.sin_addr, hp->h_addr, sizeof(udptldebugaddr.sin_addr));
- udptldebugaddr.sin_port = htons(port);
- if (port == 0)
- ast_cli(a->fd, "UDPTL Debugging Enabled for IP: %s\n", ast_inet_ntoa(udptldebugaddr.sin_addr));
- else
- ast_cli(a->fd, "UDPTL Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(udptldebugaddr.sin_addr), port);
- udptldebug = 1;
- return CLI_SUCCESS;
-}
-static char *handle_cli_udptl_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
- switch (cmd) {
- case CLI_INIT:
- e->command = "udptl debug";
- e->usage =
- "Usage: udptl debug\n"
- " Enable dumping of all UDPTL packets.\n";
- return NULL;
- case CLI_GENERATE:
- return NULL;
+ if (a->argc == 2) {
+ udptldebug = 1;
+ memset(&udptldebugaddr, 0, sizeof(udptldebugaddr));
+ ast_cli(a->fd, "UDPTL Debugging Enabled\n");
+ } else if (a->argc == 3) {
+ if (strncasecmp(a->argv[2], "off", 3))
+ return CLI_SHOWUSAGE;
+ udptldebug = 0;
+ ast_cli(a->fd, "UDPTL Debugging Disabled\n");
+ } else {
+ if (strncasecmp(a->argv[2], "ip", 2))
+ return CLI_SHOWUSAGE;
+ port = 0;
+ arg = a->argv[3];
+ p = strstr(arg, ":");
+ if (p) {
+ *p = '\0';
+ p++;
+ port = atoi(p);
+ }
+ hp = ast_gethostbyname(arg, &ahp);
+ if (hp == NULL)
+ return CLI_SHOWUSAGE;
+ udptldebugaddr.sin_family = AF_INET;
+ memcpy(&udptldebugaddr.sin_addr, hp->h_addr, sizeof(udptldebugaddr.sin_addr));
+ udptldebugaddr.sin_port = htons(port);
+ if (port == 0)
+ ast_cli(a->fd, "UDPTL Debugging Enabled for IP: %s\n", ast_inet_ntoa(udptldebugaddr.sin_addr));
+ else
+ ast_cli(a->fd, "UDPTL Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(udptldebugaddr.sin_addr), port);
+ udptldebug = 1;
}
- if (a->argc != 2)
- return CLI_SHOWUSAGE;
-
- udptldebug = 1;
- memset(&udptldebugaddr, 0, sizeof(udptldebugaddr));
-
- ast_cli(a->fd, "UDPTL Debugging Enabled\n");
return CLI_SUCCESS;
}
-static char *handle_cli_udptl_debug_off(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *handle_cli_udptl_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
+ struct hostent *hp;
+ struct ast_hostent ahp;
+ int port;
+ char *p;
+ char *arg;
+
switch (cmd) {
case CLI_INIT:
- e->command = "udptl debug off";
- e->usage =
- "Usage: udptl debug off\n"
- " Disable dumping of all UDPTL packets.\n";
+ e->command = "udptl set debug {on|off|ip}";
+ e->usage =
+ "Usage: udptl set debug {on|off|ip host[:port]}\n"
+ " Enable or disable dumping of UDPTL packets.\n"
+ " If ip is specified, limit the dumped packets to those to and from\n"
+ " the specified 'host' with optional port.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
- if (a->argc != 3)
+ if (a->argc < 4 || a->argc > 5)
return CLI_SHOWUSAGE;
- udptldebug = 0;
+ if (a->argc == 4) {
+ if (!strncasecmp(a->argv[3], "on", 2)) {
+ udptldebug = 1;
+ memset(&udptldebugaddr, 0, sizeof(udptldebugaddr));
+ ast_cli(a->fd, "UDPTL Debugging Enabled\n");
+ } else if (!strncasecmp(a->argv[3], "off", 3)) {
+ udptldebug = 0;
+ ast_cli(a->fd, "UDPTL Debugging Disabled\n");
+ } else {
+ return CLI_SHOWUSAGE;
+ }
+ } else {
+ if (strncasecmp(a->argv[3], "ip", 2))
+ return CLI_SHOWUSAGE;
+ port = 0;
+ arg = a->argv[4];
+ p = strstr(arg, ":");
+ if (p) {
+ *p = '\0';
+ p++;
+ port = atoi(p);
+ }
+ hp = ast_gethostbyname(arg, &ahp);
+ if (hp == NULL)
+ return CLI_SHOWUSAGE;
+ udptldebugaddr.sin_family = AF_INET;
+ memcpy(&udptldebugaddr.sin_addr, hp->h_addr, sizeof(udptldebugaddr.sin_addr));
+ udptldebugaddr.sin_port = htons(port);
+ if (port == 0)
+ ast_cli(a->fd, "UDPTL Debugging Enabled for IP: %s\n", ast_inet_ntoa(udptldebugaddr.sin_addr));
+ else
+ ast_cli(a->fd, "UDPTL Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(udptldebugaddr.sin_addr), port);
+ udptldebug = 1;
+ }
- ast_cli(a->fd, "UDPTL Debugging Disabled\n");
return CLI_SUCCESS;
}
+static struct ast_cli_entry cli_handle_udptl_debug_deprecated = AST_CLI_DEFINE(handle_cli_udptl_debug_deprecated, "Enable/Disable UDPTL debugging");
+
static struct ast_cli_entry cli_udptl[] = {
- AST_CLI_DEFINE(handle_cli_udptl_debug, "Enable UDPTL debugging"),
- AST_CLI_DEFINE(handle_cli_udptl_debug_ip, "Enable UDPTL debugging on IP"),
- AST_CLI_DEFINE(handle_cli_udptl_debug_off, "Disable UDPTL debugging")
+ AST_CLI_DEFINE(handle_cli_udptl_set_debug, "Enable/Disable UDPTL debugging", .deprecate_cmd = &cli_handle_udptl_debug_deprecated)
};
static void __ast_udptl_reload(int reload)