[asterisk-commits] mvanbaak: branch mvanbaak/cli-command-audit r102138 - in /team/mvanbaak/cli-c...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Feb 3 06:54:02 CST 2008


Author: mvanbaak
Date: Sun Feb  3 06:54:01 2008
New Revision: 102138

URL: http://svn.digium.com/view/asterisk?view=rev&rev=102138
Log:
ael, rtcp, stun, udptl cli cleanup

Modified:
    team/mvanbaak/cli-command-audit/main/rtp.c
    team/mvanbaak/cli-command-audit/main/udptl.c
    team/mvanbaak/cli-command-audit/pbx/pbx_ael.c

Modified: team/mvanbaak/cli-command-audit/main/rtp.c
URL: http://svn.digium.com/view/asterisk/team/mvanbaak/cli-command-audit/main/rtp.c?view=diff&rev=102138&r1=102137&r2=102138
==============================================================================
--- team/mvanbaak/cli-command-audit/main/rtp.c (original)
+++ team/mvanbaak/cli-command-audit/main/rtp.c Sun Feb  3 06:54:01 2008
@@ -4005,7 +4005,7 @@
 {
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "rtcp set debug {on|off|ip host[:port]}";
+		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"
@@ -4112,9 +4112,9 @@
 {
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "stun debug [off]";
+		e->command = "stun set debug {on|off}";
 		e->usage =
-			"Usage: stun debug [off]\n"
+			"Usage: stun set debug {on|off}\n"
 			"       Enable/Disable STUN (Simple Traversal of UDP through NATs)\n"
 			"       debugging\n";
 		return NULL;

Modified: team/mvanbaak/cli-command-audit/main/udptl.c
URL: http://svn.digium.com/view/asterisk/team/mvanbaak/cli-command-audit/main/udptl.c?view=diff&rev=102138&r1=102137&r2=102138
==============================================================================
--- team/mvanbaak/cli-command-audit/main/udptl.c (original)
+++ team/mvanbaak/cli-command-audit/main/udptl.c Sun Feb  3 06:54:01 2008
@@ -1087,7 +1087,7 @@
 	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 @@
 
 	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)
+	if (a->argc < 2 || 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)
-		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) { 
+		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;
+	}
+
 	return CLI_SUCCESS;
 }
 
-static char *handle_cli_udptl_debug(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";
-		e->usage =
-			"Usage: udptl debug\n"
-			"       Enable 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 != 2)
+	if (a->argc < 4 || a->argc > 5)
 		return CLI_SHOWUSAGE;
 
-	udptldebug = 1;
-	memset(&udptldebugaddr, 0, sizeof(udptldebugaddr));
-
-	ast_cli(a->fd, "UDPTL Debugging Enabled\n");
+	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;
+	}
+
 	return CLI_SUCCESS;
 }
 
-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;
-	}
-
-	if (a->argc != 3)
-		return CLI_SHOWUSAGE;
-
-	udptldebug = 0;
-
-	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)

Modified: team/mvanbaak/cli-command-audit/pbx/pbx_ael.c
URL: http://svn.digium.com/view/asterisk/team/mvanbaak/cli-command-audit/pbx/pbx_ael.c?view=diff&rev=102138&r1=102137&r2=102138
==============================================================================
--- team/mvanbaak/cli-command-audit/pbx/pbx_ael.c (original)
+++ team/mvanbaak/cli-command-audit/pbx/pbx_ael.c Sun Feb  3 06:54:01 2008
@@ -146,7 +146,7 @@
 }
 
 /* CLI interface */
-static char *handle_cli_ael_debug_multiple(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *handle_cli_ael_debug_multiple_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	switch (cmd) {
 	case CLI_INIT:
@@ -180,6 +180,40 @@
 	return CLI_SUCCESS;
 }
 
+static char *handle_cli_ael_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "ael set debug {read|tokens|macros|contexts|off}";
+		e->usage =
+			"Usage: ael debug {read|tokens|macros|contexts|off}\n"
+			"       Enable AEL read, token, macro, or context debugging,\n"
+			"       or disable all AEL debugging messages.  Note: this\n"
+			"       currently does nothing.\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+
+	if (a->argc != e->args)
+		return CLI_SHOWUSAGE;
+
+	if (!strcasecmp(a->argv[3], "read"))
+		aeldebug |= DEBUG_READ;
+	else if (!strcasecmp(a->argv[3], "tokens"))
+		aeldebug |= DEBUG_TOKENS;
+	else if (!strcasecmp(a->argv[3], "macros"))
+		aeldebug |= DEBUG_MACROS;
+	else if (!strcasecmp(a->argv[3], "contexts"))
+		aeldebug |= DEBUG_CONTEXTS;
+	else if (!strcasecmp(a->argv[3], "off"))
+		aeldebug = 0;
+	else
+		return CLI_SHOWUSAGE;
+
+	return CLI_SUCCESS;
+}
+
 static char *handle_cli_ael_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	switch (cmd) {
@@ -199,9 +233,10 @@
 	return (pbx_load_module() ? CLI_FAILURE : CLI_SUCCESS);
 }
 
+static struct ast_cli_entry cli_ael_debug_multiple_deprecated = AST_CLI_DEFINE(handle_cli_ael_debug_multiple_deprecated, "Enable AEL debugging flags");
 static struct ast_cli_entry cli_ael[] = {
-	AST_CLI_DEFINE(handle_cli_ael_reload,         "Reload AEL configuration"),
-	AST_CLI_DEFINE(handle_cli_ael_debug_multiple, "Enable AEL debugging flags")
+	AST_CLI_DEFINE(handle_cli_ael_reload,    "Reload AEL configuration"),
+	AST_CLI_DEFINE(handle_cli_ael_set_debug, "Enable AEL debugging flags", .deprecate_cmd = &cli_ael_debug_multiple_deprecated)
 };
 
 static int unload_module(void)




More information about the asterisk-commits mailing list