aboutsummaryrefslogtreecommitdiffstats
path: root/main/udptl.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-11 19:03:06 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-11 19:03:06 +0000
commit13b9c5237c9f5b8b3d72634d575665b1d1147ba3 (patch)
tree44dcb2c14abed6932db4f248b17626a01a38f59b /main/udptl.c
parenta8506328befc2a11643cea88772609610ec11c33 (diff)
Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :)
(closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@85460 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/udptl.c')
-rw-r--r--main/udptl.c99
1 files changed, 59 insertions, 40 deletions
diff --git a/main/udptl.c b/main/udptl.c
index d3c6163e7..a140cc4fe 100644
--- a/main/udptl.c
+++ b/main/udptl.c
@@ -1107,7 +1107,7 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
return -1;
}
-static int udptl_do_debug_ip(int fd, int argc, char *argv[])
+static char *handle_cli_udptl_debug_ip(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct hostent *hp;
struct ast_hostent ahp;
@@ -1115,10 +1115,22 @@ static int udptl_do_debug_ip(int fd, int argc, char *argv[])
char *p;
char *arg;
+ 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";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
port = 0;
- if (argc != 4)
- return RESULT_SHOWUSAGE;
- arg = argv[3];
+
+ if (a->argc != 4)
+ return CLI_SHOWUSAGE;
+ arg = a->argv[3];
p = strstr(arg, ":");
if (p) {
*p = '\0';
@@ -1127,60 +1139,67 @@ static int udptl_do_debug_ip(int fd, int argc, char *argv[])
}
hp = ast_gethostbyname(arg, &ahp);
if (hp == NULL)
- return RESULT_SHOWUSAGE;
+ 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(fd, "UDPTL Debugging Enabled for IP: %s\n", ast_inet_ntoa(udptldebugaddr.sin_addr));
+ ast_cli(a->fd, "UDPTL Debugging Enabled for IP: %s\n", ast_inet_ntoa(udptldebugaddr.sin_addr));
else
- ast_cli(fd, "UDPTL Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(udptldebugaddr.sin_addr), port);
+ ast_cli(a->fd, "UDPTL Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(udptldebugaddr.sin_addr), port);
udptldebug = 1;
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
-static int udptl_do_debug(int fd, int argc, char *argv[])
+static char *handle_cli_udptl_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- if (argc != 2) {
- if (argc != 4)
- return RESULT_SHOWUSAGE;
- return udptl_do_debug_ip(fd, argc, argv);
+ 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)
+ return CLI_SHOWUSAGE;
+
udptldebug = 1;
- memset(&udptldebugaddr,0,sizeof(udptldebugaddr));
- ast_cli(fd, "UDPTL Debugging Enabled\n");
- return RESULT_SUCCESS;
-}
+ memset(&udptldebugaddr, 0, sizeof(udptldebugaddr));
-static int udptl_nodebug(int fd, int argc, char *argv[])
-{
- if (argc != 3)
- return RESULT_SHOWUSAGE;
- udptldebug = 0;
- ast_cli(fd,"UDPTL Debugging Disabled\n");
- return RESULT_SUCCESS;
+ ast_cli(a->fd, "UDPTL Debugging Enabled\n");
+ return CLI_SUCCESS;
}
-static const char debug_usage[] =
- "Usage: udptl debug [ip host[:port]]\n"
- " Enable dumping of all UDPTL packets to and from host.\n";
+static char *handle_cli_udptl_debug_off(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "udptl debug off";
+ e->usage =
+ "Usage: udptl debug off\n"
+ " Disable dumping of all UDPTL packets.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
-static const char nodebug_usage[] =
- "Usage: udptl debug off\n"
- " Disable all UDPTL debugging\n";
+ if (a->argc != 3)
+ return CLI_SHOWUSAGE;
-static struct ast_cli_entry cli_udptl[] = {
- { { "udptl", "debug", NULL },
- udptl_do_debug, "Enable UDPTL debugging",
- debug_usage },
+ udptldebug = 0;
- { { "udptl", "debug", "ip", NULL },
- udptl_do_debug, "Enable UDPTL debugging on IP",
- debug_usage },
+ ast_cli(a->fd, "UDPTL Debugging Disabled\n");
+ return CLI_SUCCESS;
+}
- { { "udptl", "debug", "off", NULL },
- udptl_nodebug, "Disable UDPTL debugging",
- nodebug_usage },
+static struct ast_cli_entry cli_udptl[] = {
+ NEW_CLI(handle_cli_udptl_debug, "Enable UDPTL debugging"),
+ NEW_CLI(handle_cli_udptl_debug_ip, "Enable UDPTL debugging on IP"),
+ NEW_CLI(handle_cli_udptl_debug_off, "Disable UDPTL debugging")
};
static void __ast_udptl_reload(int reload)