diff --git a/apps/app_minivm.c b/apps/app_minivm.c index 148ebf49493f2177fe62d395a5dc6a3287076a12..ae76f9e8973774d582326a790d399f67197ba6cf 100644 --- a/apps/app_minivm.c +++ b/apps/app_minivm.c @@ -2602,7 +2602,7 @@ static char *handle_minivm_show_zones(struct ast_cli_entry *e, int cmd, struct a return NULL; } - if (a->argc != 3) + if (a->argc != e->args) return CLI_SHOWUSAGE; AST_LIST_LOCK(&minivm_zones); diff --git a/apps/app_playback.c b/apps/app_playback.c index 21b3ab3eba197a97b288efe2ad697a546c3c5470..b7409957acb45e8075f23ee89cc1ba4c9d5f781f 100644 --- a/apps/app_playback.c +++ b/apps/app_playback.c @@ -374,7 +374,7 @@ static char *__say_cli_init(struct ast_cli_entry *e, int cmd, struct ast_cli_arg if (a->argc == 2) { ast_cli(a->fd, "say mode is [%s]\n", old_mode); return CLI_SUCCESS; - } else if (a->argc != 3) + } else if (a->argc != e->args) return CLI_SHOWUSAGE; mode = a->argv[2]; if (!strcmp(mode, old_mode)) diff --git a/apps/app_rpt.c b/apps/app_rpt.c index 6eb0bfca86aa14fb1920e0906b53029f10c6e2d4..f703aaec0a5bfbe4ae318700424337d7dc491ef3 100644 --- a/apps/app_rpt.c +++ b/apps/app_rpt.c @@ -1090,7 +1090,7 @@ static char *handle_cli_rpt_debug_level(struct ast_cli_entry *e, int cmd, struct case CLI_GENERATE: return NULL; } - if (a->argc != 4) + if (a->argc != e->args) return CLI_SHOWUSAGE; newlevel = myatoi(a->argv[3]); if ((newlevel < 0) || (newlevel > 7)) diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 8d169061b3556b0dfb9af7c31ec14526285d9edc..7a679a04e136d342db022e2ea919df3588dd42cc 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -7859,7 +7859,7 @@ static char *handle_voicemail_show_zones(struct ast_cli_entry *e, int cmd, struc return NULL; } - if (a->argc != 3) + if (a->argc != e->args) return CLI_SHOWUSAGE; AST_LIST_LOCK(&zones); @@ -7891,7 +7891,7 @@ static char *handle_voicemail_reload(struct ast_cli_entry *e, int cmd, struct as return NULL; } - if (a->argc != 2) + if (a->argc != e->args) return CLI_SHOWUSAGE; ast_cli(a->fd, "Reloading voicemail configuration...\n"); diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index c393711b981072f69e370f4ad77df8427f292bdb..990ab41fddfca8a4777418a2173fddf47d1e4116 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -5262,117 +5262,158 @@ static char *handle_cli_iax2_show_netstats(struct ast_cli_entry *e, int cmd, str return CLI_SUCCESS; } -static char *handle_cli_iax2_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *handle_cli_iax2_set_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "iax2 set debug"; + e->command = "iax2 set debug [off]"; e->usage = - "Usage: iax2 set debug\n" - " Enables dumping of IAX packets for debugging purposes.\n"; + "Usage: iax2 set debug [off]\n" + " Enables/Disables dumping of IAX packets for debugging purposes.\n"; return NULL; case CLI_GENERATE: return NULL; } - if (a->argc < 2 || a->argc > 3) + if (a->argc < 3 || a->argc > 4) return CLI_SHOWUSAGE; - iaxdebug = 1; - ast_cli(a->fd, "IAX2 Debugging Enabled\n"); + if (a->argc == 3) { + iaxdebug = 1; + ast_cli(a->fd, "IAX2 Debugging Enabled\n"); + } else { + iaxdebug = 0; + ast_cli(a->fd, "IAX2 Debugging Disabled\n"); + } return CLI_SUCCESS; } -static char *handle_cli_iax2_set_debug_off(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *handle_cli_iax2_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "iax2 set debug off"; + e->command = "iax2 set debug {on|off}"; e->usage = - "Usage: iax2 set debug off\n" - " Disables dumping of IAX packets for debugging purposes.\n"; + "Usage: iax2 set debug {on|off}\n" + " Enables/Disables dumping of IAX packets for debugging purposes.\n"; return NULL; case CLI_GENERATE: return NULL; } - if (a->argc < 3 || a->argc > 4) + + if (a->argc != e->args) return CLI_SHOWUSAGE; - iaxdebug = 0; - ast_cli(a->fd, "IAX2 Debugging Disabled\n"); + + if (!strncasecmp(a->argv[e->args -1], "on", 2)) { + iaxdebug = 1; + ast_cli(a->fd, "IAX2 Debugging Enabled\n"); + } else { + iaxdebug = 0; + ast_cli(a->fd, "IAX2 Debugging Disabled\n"); + } return CLI_SUCCESS; } -static char *handle_cli_iax2_set_debug_trunk(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) + +static char *handle_cli_iax2_set_debug_trunk_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "iax2 set debug trunk"; + e->command = "iax2 set debug trunk [off]"; e->usage = - "Usage: iax2 set debug trunk\n" - " Requests current status of IAX trunking\n"; + "Usage: iax2 set debug trunk [off]\n" + " Enables/Disables debugging of IAX trunking\n"; return NULL; case CLI_GENERATE: return NULL; } - if (a->argc < 3 || a->argc > 4) + + if (a->argc < 4 || a->argc > 5) return CLI_SHOWUSAGE; - iaxtrunkdebug = 1; - ast_cli(a->fd, "IAX2 Trunk Debugging Requested\n"); + + if (a->argc == 4) { + iaxtrunkdebug = 1; + ast_cli(a->fd, "IAX2 Trunk Debugging Enabled\n"); + } else { + iaxtrunkdebug = 0; + ast_cli(a->fd, "IAX2 Trunk Debugging Disabled\n"); + } return CLI_SUCCESS; } -static char *handle_cli_iax2_set_debug_trunk_off(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *handle_cli_iax2_set_debug_trunk(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "iax2 set debug trunk off"; + e->command = "iax2 set debug trunk {on|off}"; e->usage = - "Usage: iax2 set debug trunk off\n" - " Disables debugging of IAX trunking\n"; + "Usage: iax2 set debug trunk {on|off}\n" + " Enables/Disables debugging of IAX trunking\n"; return NULL; case CLI_GENERATE: return NULL; } - if (a->argc < 4 || a->argc > 5) + + if (a->argc != e->args) return CLI_SHOWUSAGE; - iaxtrunkdebug = 0; - ast_cli(a->fd, "IAX2 Trunk Debugging Disabled\n"); + + if (!strncasecmp(a->argv[e->args - 1], "on", 2)) { + iaxtrunkdebug = 1; + ast_cli(a->fd, "IAX2 Trunk Debugging Enabled\n"); + } else { + iaxtrunkdebug = 0; + ast_cli(a->fd, "IAX2 Trunk Debugging Disabled\n"); + } return CLI_SUCCESS; } -static char *handle_cli_iax2_set_debug_jb(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *handle_cli_iax2_set_debug_jb_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "iax2 set debug jb"; + e->command = "iax2 set debug jb [off]"; e->usage = - "Usage: iax2 set debug jb\n" - " Enables jitterbuffer debugging information\n"; + "Usage: iax2 set debug jb [off]\n" + " Enables/Disables jitterbuffer debugging information\n"; return NULL; case CLI_GENERATE: return NULL; } - if (a->argc < 3 || a->argc > 4) + + if (a->argc < 4 || a->argc > 5) return CLI_SHOWUSAGE; - jb_setoutput(jb_error_output, jb_warning_output, jb_debug_output); - ast_cli(a->fd, "IAX2 Jitterbuffer Debugging Enabled\n"); + + if (a->argc == 4) { + jb_setoutput(jb_error_output, jb_warning_output, jb_debug_output); + ast_cli(a->fd, "IAX2 Jitterbuffer Debugging Enabled\n"); + } else { + jb_setoutput(jb_error_output, jb_warning_output, NULL); + ast_cli(a->fd, "IAX2 Jitterbuffer Debugging Disabled\n"); + } return CLI_SUCCESS; } -static char *handle_cli_iax2_set_debug_jb_off(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *handle_cli_iax2_set_debug_jb(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "iax2 set debug jb off"; + e->command = "iax2 set debug jb {on|off}"; e->usage = - "Usage: iax2 set debug jb off\n" - " Disables jitterbuffer debugging information\n"; + "Usage: iax2 set debug jb {on|off}\n" + " Enables/Disables jitterbuffer debugging information\n"; return NULL; case CLI_GENERATE: return NULL; } - if (a->argc < 4 || a->argc > 5) + + if (a->argc != e->args) return CLI_SHOWUSAGE; - jb_setoutput(jb_error_output, jb_warning_output, NULL); - ast_cli(a->fd, "IAX2 Jitterbuffer Debugging Disabled\n"); + + if (!strncasecmp(a->argv[e->args -1], "on", 2)) { + jb_setoutput(jb_error_output, jb_warning_output, jb_debug_output); + ast_cli(a->fd, "IAX2 Jitterbuffer Debugging Enabled\n"); + } else { + jb_setoutput(jb_error_output, jb_warning_output, NULL); + ast_cli(a->fd, "IAX2 Jitterbuffer Debugging Disabled\n"); + } return CLI_SUCCESS; } @@ -11474,17 +11515,18 @@ static struct ast_switch iax2_switch = #endif */ +static struct ast_cli_entry cli_iax2_set_debug_deprecated = AST_CLI_DEFINE(handle_cli_iax2_set_debug_deprecated, "Enable/Disable IAX debugging"); +static struct ast_cli_entry cli_iax2_set_debug_trunk_deprecated = AST_CLI_DEFINE(handle_cli_iax2_set_debug_trunk_deprecated, "Enable/Disable IAX debugging"); +static struct ast_cli_entry cli_iax2_set_debug_jb_deprecated = AST_CLI_DEFINE(handle_cli_iax2_set_debug_jb_deprecated, "Enable/Disable IAX debugging"); + static struct ast_cli_entry cli_iax2[] = { AST_CLI_DEFINE(handle_cli_iax2_provision, "Provision an IAX device"), AST_CLI_DEFINE(handle_cli_iax2_prune_realtime, "Prune a cached realtime lookup"), AST_CLI_DEFINE(handle_cli_iax2_reload, "Reload IAX configuration"), AST_CLI_DEFINE(handle_cli_iax2_set_mtu, "Set the IAX systemwide trunking MTU"), - AST_CLI_DEFINE(handle_cli_iax2_set_debug, "Enable IAX debugging"), - AST_CLI_DEFINE(handle_cli_iax2_set_debug_trunk, "Enable IAX trunk debugging"), - AST_CLI_DEFINE(handle_cli_iax2_set_debug_jb, "Enable IAX jitterbuffer debugging"), - AST_CLI_DEFINE(handle_cli_iax2_set_debug_off, "Disable IAX debugging"), - AST_CLI_DEFINE(handle_cli_iax2_set_debug_trunk_off, "Disable IAX trunk debugging"), - AST_CLI_DEFINE(handle_cli_iax2_set_debug_jb_off, "Disable IAX jitterbuffer debugging"), + AST_CLI_DEFINE(handle_cli_iax2_set_debug, "Enable/Disable IAX debugging", .deprecate_cmd = &cli_iax2_set_debug_deprecated), + AST_CLI_DEFINE(handle_cli_iax2_set_debug_trunk, "Enable/Disable IAX trunk debugging", .deprecate_cmd = &cli_iax2_set_debug_trunk_deprecated), + AST_CLI_DEFINE(handle_cli_iax2_set_debug_jb, "Enable/Disable IAX jitterbuffer debugging", .deprecate_cmd = &cli_iax2_set_debug_jb_deprecated), AST_CLI_DEFINE(handle_cli_iax2_show_cache, "Display IAX cached dialplan"), AST_CLI_DEFINE(handle_cli_iax2_show_channels, "List active IAX channels"), AST_CLI_DEFINE(handle_cli_iax2_show_firmware, "List available IAX firmware"), diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index de7c624be0106e318803300b36f7053b86bb42ed..f4ce2ce6a2e161021136b73bd7e535cb123138ec 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -1139,51 +1139,64 @@ static char *handle_mgcp_audit_endpoint(struct ast_cli_entry *e, int cmd, struct return CLI_SUCCESS; } -static char *handle_mgcp_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *handle_mgcp_set_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "mgcp set debug"; + e->command = "mgcp set debug [off]"; e->usage = - "Usage: mgcp set debug\n" - " Enables dumping of MGCP packets for debugging purposes\n"; + "Usage: mgcp set debug [off]\n" + " Enables/Disables dumping of MGCP packets for debugging purposes\n"; return NULL; case CLI_GENERATE: return NULL; } - if (a->argc != 3) + if (a->argc < 3 || a->argc > 4) return CLI_SHOWUSAGE; - mgcpdebug = 1; - ast_cli(a->fd, "MGCP Debugging Enabled\n"); + if (a->argc == 3) { + mgcpdebug = 1; + ast_cli(a->fd, "MGCP Debugging Enabled\n"); + } else if (!strncasecmp(a->argv[3], "off", 3)) { + mgcpdebug = 0; + ast_cli(a->fd, "MGCP Debugging Disabled\n"); + } return CLI_SUCCESS; } -static char *handle_mgcp_set_debug_off(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *handle_mgcp_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "mgcp set debug off"; + e->command = "mgcp set debug {on|off}"; e->usage = - "Usage: mgcp set debug off\n" - " Disables dumping of MGCP packets for debugging purposes\n"; + "Usage: mgcp set debug {on|off}\n" + " Enables/Disables dumping of MGCP packets for debugging purposes\n"; return NULL; case CLI_GENERATE: return NULL; } - if (a->argc != 4) + if (a->argc != e->args) return CLI_SHOWUSAGE; - mgcpdebug = 0; - ast_cli(a->fd, "MGCP Debugging Disabled\n"); + + if (!strncasecmp(a->argv[e->args - 1], "on", 2)) { + mgcpdebug = 1; + ast_cli(a->fd, "MGCP Debugging Enabled\n"); + } else if (!strncasecmp(a->argv[3], "off", 3)) { + mgcpdebug = 0; + ast_cli(a->fd, "MGCP Debugging Disabled\n"); + } else { + return CLI_SHOWUSAGE; + } return CLI_SUCCESS; } +static struct ast_cli_entry cli_mgcp_set_debug_deprecated = AST_CLI_DEFINE(handle_mgcp_set_debug_deprecated, "Enable/Disable MGCP debugging"); static struct ast_cli_entry cli_mgcp[] = { AST_CLI_DEFINE(handle_mgcp_audit_endpoint, "Audit specified MGCP endpoint"), AST_CLI_DEFINE(handle_mgcp_show_endpoints, "List defined MGCP endpoints"), - AST_CLI_DEFINE(handle_mgcp_set_debug, "Enable MGCP debugging"), - AST_CLI_DEFINE(handle_mgcp_set_debug_off, "Disable MGCP debugging"), + AST_CLI_DEFINE(handle_mgcp_set_debug, "Enable/Disable MGCP debugging", .deprecate_cmd = &cli_mgcp_set_debug_deprecated), AST_CLI_DEFINE(mgcp_reload, "Reload MGCP configuration"), }; diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 6408f52aad424e469646f52e478f61555068d9fd..40320b1bdc0f85d5bba1efa63d428d13c77a3d20 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1853,8 +1853,8 @@ static char *sip_do_debug_ip(int fd, char *arg); static char *sip_do_debug_peer(int fd, char *arg); static char *sip_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *sip_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); -static char *sip_do_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); -static char *sip_no_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); +static char *sip_do_history_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); +static char *sip_set_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static int sip_dtmfmode(struct ast_channel *chan, void *data); static int sip_addheader(struct ast_channel *chan, void *data); static int sip_do_reload(enum channelreloadreason reason); @@ -13243,7 +13243,7 @@ static char *sip_show_history(struct ast_cli_entry *e, int cmd, struct ast_cli_a if (a->argc != 4) return CLI_SHOWUSAGE; if (!recordhistory) - ast_cli(a->fd, "\n***Note: History recording is currently DISABLED. Use 'sip history' to ENABLE.\n"); + ast_cli(a->fd, "\n***Note: History recording is currently DISABLED. Use 'sip set history on' to ENABLE.\n"); len = strlen(a->argv[3]); dialoglist_lock(); for (cur = dialoglist; cur; cur = cur->next) { @@ -13652,49 +13652,63 @@ static char *sip_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a return CLI_SUCCESS; } -/*! \brief Enable SIP History logging (CLI) */ -static char *sip_do_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +/*! \brief Enable/Disable SIP History logging (CLI) - deprecated. use sip_set_history instead */ +static char *sip_do_history_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "sip history"; + e->command = "sip history [off]"; e->usage = - "Usage: sip history\n" - " Enables recording of SIP dialog history for debugging purposes.\n" + "Usage: sip history [off]\n" + " Enables/Disables recording of SIP dialog history for debugging purposes.\n" " Use 'sip show history' to view the history of a call number.\n"; return NULL; case CLI_GENERATE: return NULL; } - if (a->argc != 2) { + if (a->argc < 2 || a->argc > 3) { return CLI_SHOWUSAGE; } - recordhistory = TRUE; - ast_cli(a->fd, "SIP History Recording Enabled (use 'sip show history')\n"); + if (a->argc == 2) { + recordhistory = TRUE; + ast_cli(a->fd, "SIP History Recording Enabled (use 'sip show history')\n"); + } else { + if (strncasecmp(a->argv[2], "off", 3)) + return CLI_SHOWUSAGE; + recordhistory = FALSE; + ast_cli(a->fd, "SIP History Recording Disabled\n"); + } return CLI_SUCCESS; } -/*! \brief Disable SIP History logging (CLI) */ -static char *sip_no_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +/*! \brief Enable/Disable SIP History logging (CLI) */ +static char *sip_set_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { - switch (cmd) { case CLI_INIT: - e->command = "sip history off"; + e->command = "sip set history {on|off}"; e->usage = - "Usage: sip history off\n" - " Disables recording of SIP dialog history for debugging purposes\n"; + "Usage: sip history {on|off}\n" + " Enables/Disables recording of SIP dialog history for debugging purposes.\n" + " Use 'sip show history' to view the history of a call number.\n"; return NULL; case CLI_GENERATE: return NULL; } - if (a->argc != 3) { + if (a->argc != e->args) + return CLI_SHOWUSAGE; + + if (!strncasecmp(a->argv[e->args - 1], "on", 2)) { + recordhistory = TRUE; + ast_cli(a->fd, "SIP History Recording Enabled (use 'sip show history')\n"); + } else if (!strncasecmp(a->argv[e->args - 1], "off", 3)) { + recordhistory = FALSE; + ast_cli(a->fd, "SIP History Recording Disabled\n"); + } else { return CLI_SHOWUSAGE; } - recordhistory = FALSE; - ast_cli(a->fd, "SIP History Recording Disabled\n"); return CLI_SUCCESS; } @@ -21102,6 +21116,7 @@ static int reload(void) return 1; } +static struct ast_cli_entry cli_sip_do_history_deprecated = AST_CLI_DEFINE(sip_do_history_deprecated, "Enable/Disable SIP history"); /*! \brief SIP Cli commands definition */ static struct ast_cli_entry cli_sip[] = { AST_CLI_DEFINE(sip_show_channels, "List active SIP channels/subscriptions"), @@ -21120,8 +21135,7 @@ static struct ast_cli_entry cli_sip[] = { AST_CLI_DEFINE(sip_show_user, "Show details on specific SIP user"), AST_CLI_DEFINE(sip_prune_realtime, "Prune cached Realtime users/peers"), AST_CLI_DEFINE(sip_do_debug, "Enable/Disable SIP debugging"), - AST_CLI_DEFINE(sip_do_history, "Enable SIP history"), - AST_CLI_DEFINE(sip_no_history, "Disable SIP history"), + AST_CLI_DEFINE(sip_set_history, "Enable/Disable SIP history", .deprecate_cmd = &cli_sip_do_history_deprecated), AST_CLI_DEFINE(sip_reload, "Reload SIP configuration"), AST_CLI_DEFINE(sip_show_tcp, "List TCP Connections") }; diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 7192581784cc7903b4e9e4566065b7f5ebee53b5..b9fe618d23038cbb4b7d4b9427bc38a8163d81d0 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -2371,46 +2371,62 @@ static struct ast_rtp_protocol skinny_rtp = { .set_rtp_peer = skinny_set_rtp_peer, }; -static char *handle_skinny_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *handle_skinny_set_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "skinny set debug"; + e->command = "skinny set debug [off]"; e->usage = - "Usage: skinny set debug\n" - " Enables dumping of Skinny packets for debugging purposes\n"; + "Usage: skinny set debug [off]\n" + " Enables/Disables dumping of Skinny packets for debugging purposes\n"; return NULL; case CLI_GENERATE: return NULL; } - if (a->argc != 3) + if (a->argc < 3 || a->argc > 4) return CLI_SHOWUSAGE; - skinnydebug = 1; - ast_cli(a->fd, "Skinny Debugging Enabled\n"); - return CLI_SUCCESS; + if (a->argc == 3) { + skinnydebug = 1; + ast_cli(a->fd, "Skinny Debugging Enabled\n"); + return CLI_SUCCESS; + } else if (!strncasecmp(a->argv[3], "off", 3)) { + skinnydebug = 0; + ast_cli(a->fd, "Skinny Debugging Disabled\n"); + return CLI_SUCCESS; + } else { + return CLI_SHOWUSAGE; + } } -static char *handle_skinny_set_debug_off(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *handle_skinny_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "skinny set debug off"; + e->command = "skinny set debug {on|off}"; e->usage = - "Usage: skinny set debug off\n" - " Disables dumping of Skinny packets for debugging purposes\n"; + "Usage: skinny set debug {on|off}\n" + " Enables/Disables dumping of Skinny packets for debugging purposes\n"; return NULL; case CLI_GENERATE: return NULL; } - - if (a->argc != 4) + + if (a->argc != e->args) return CLI_SHOWUSAGE; - skinnydebug = 0; - ast_cli(a->fd, "Skinny Debugging Disabled\n"); - return CLI_SUCCESS; + if (!strncasecmp(a->argv[e->args - 1], "on", 2)) { + skinnydebug = 1; + ast_cli(a->fd, "Skinny Debugging Enabled\n"); + return CLI_SUCCESS; + } else if (!strncasecmp(a->argv[e->args - 1], "off", 3)) { + skinnydebug = 0; + ast_cli(a->fd, "Skinny Debugging Disabled\n"); + return CLI_SUCCESS; + } else { + return CLI_SHOWUSAGE; + } } static char *complete_skinny_devices(const char *word, int state) @@ -2841,14 +2857,14 @@ static char *handle_skinny_show_settings(struct ast_cli_entry *e, int cmd, struc return CLI_SUCCESS; } +static struct ast_cli_entry cli_skinny_set_debug_deprecated = AST_CLI_DEFINE(handle_skinny_set_debug_deprecated, "Enable/Disable Skinny debugging"); static struct ast_cli_entry cli_skinny[] = { AST_CLI_DEFINE(handle_skinny_show_devices, "List defined Skinny devices"), AST_CLI_DEFINE(handle_skinny_show_device, "List Skinny device information"), AST_CLI_DEFINE(handle_skinny_show_lines, "List defined Skinny lines per device"), AST_CLI_DEFINE(handle_skinny_show_line, "List Skinny line information"), AST_CLI_DEFINE(handle_skinny_show_settings, "List global Skinny settings"), - AST_CLI_DEFINE(handle_skinny_set_debug, "Enable Skinny debugging"), - AST_CLI_DEFINE(handle_skinny_set_debug_off, "Disable Skinny debugging"), + AST_CLI_DEFINE(handle_skinny_set_debug, "Enable/Disable Skinny debugging", .deprecate_cmd = &cli_skinny_set_debug_deprecated), AST_CLI_DEFINE(handle_skinny_reset, "Reset Skinny device(s)"), }; diff --git a/channels/chan_usbradio.c b/channels/chan_usbradio.c index 6b2154c82793dceb1d260b3d2c70cab49a7bc8e9..06f97939d5acfd8f6505f80556e5d2d9421a405f 100644 --- a/channels/chan_usbradio.c +++ b/channels/chan_usbradio.c @@ -1622,7 +1622,7 @@ static int set_txctcss_level(struct chan_usbradio_pvt *o) /* CLI debugging on and off */ -static char *handle_cli_radio_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *handle_cli_radio_set_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct chan_usbradio_pvt *o = NULL; @@ -1652,11 +1652,43 @@ static char *handle_cli_radio_set_debug(struct ast_cli_entry *e, int cmd, struct return CLI_SUCCESS; } +static char *handle_cli_radio_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + struct chan_usbradio_pvt *o = NULL; + + switch (cmd) { + case CLI_INIT: + e->command = "radio set debug {on|off}"; + e->usage = + "Usage: radio set debug {on|off}\n" + " Enable/Disable radio debugging.\n"; + case CLI_GENERATE: + return NULL; + } + + if (a->argc != e->args) + return CLI_SHOWUSAGE; + + o = find_desc(usbradio_active); + + if (!strncasecmp(a->argv[e->args - 1], "on", 2)) + o->debuglevel = 1; + else if (!strncasecmp(a->argv[e->args - 1], "off", 3)) + o->debuglevel = 0; + else + return CLI_SHOWUSAGE; + + ast_cli(a->fd, "USB Radio debugging %s.\n", o->debuglevel ? "enabled" : "disabled"); + + return CLI_SUCCESS; +} + +static struct ast_cli_entry cli_radio_set_debug_deprecated = AST_CLI_DEFINE(handle_cli_radio_set_debug_deprecated, "Enable/Disable Radio Debugging"); static struct ast_cli_entry cli_usbradio[] = { AST_CLI_DEFINE(handle_cli_radio_key, "Simulate Rx Signal Present"), AST_CLI_DEFINE(handle_cli_radio_unkey, "Simulate Rx Signal Lusb"), AST_CLI_DEFINE(handle_cli_radio_tune, "Radio Tune"), - AST_CLI_DEFINE(handle_cli_radio_set_debug, "Enable/Disable Radio Debugging"), + AST_CLI_DEFINE(handle_cli_radio_set_debug, "Enable/Disable Radio Debugging", .deprecate_cmd = &cli_radio_set_debug_deprecated), }; /* diff --git a/funcs/func_devstate.c b/funcs/func_devstate.c index 950208be5e37b6c45ec65b490f4737143aa6f22a..220fd50c3c798c9b4fd6c1d7fbfcad04a1e286bd 100644 --- a/funcs/func_devstate.c +++ b/funcs/func_devstate.c @@ -127,7 +127,7 @@ static enum ast_device_state custom_devstate_callback(const char *data) return ast_devstate_val(buf); } -static char *cli_funcdevstate_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *handle_cli_funcdevstate_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct ast_db_entry *db_entry, *db_tree; @@ -171,8 +171,53 @@ static char *cli_funcdevstate_list(struct ast_cli_entry *e, int cmd, struct ast_ return CLI_SUCCESS; } +static char *handle_cli_devstate_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + struct ast_db_entry *db_entry, *db_tree; + + switch (cmd) { + case CLI_INIT: + e->command = "devstate list"; + e->usage = + "Usage: devstate list\n" + " List all custom device states that have been set by using\n" + " the DEVICE_STATE dialplan function.\n"; + return NULL; + case CLI_GENERATE: + return NULL; + } + + if (a->argc != e->args) + return CLI_SHOWUSAGE; + + ast_cli(a->fd, "\n" + "---------------------------------------------------------------------\n" + "--- Custom Device States --------------------------------------------\n" + "---------------------------------------------------------------------\n" + "---\n"); + + db_entry = db_tree = ast_db_gettree(astdb_family, NULL); + for (; db_entry; db_entry = db_entry->next) { + const char *dev_name = strrchr(db_entry->key, '/') + 1; + if (dev_name <= (const char *) 1) + continue; + ast_cli(a->fd, "--- Name: 'Custom:%s' State: '%s'\n" + "---\n", dev_name, db_entry->data); + } + ast_db_freetree(db_tree); + db_tree = NULL; + + ast_cli(a->fd, + "---------------------------------------------------------------------\n" + "---------------------------------------------------------------------\n" + "\n"); + + return CLI_SUCCESS; +} + +static struct ast_cli_entry cli_funcdevstate_list_deprecated = AST_CLI_DEFINE(handle_cli_funcdevstate_list, "List currently known custom device states"); static struct ast_cli_entry cli_funcdevstate[] = { - AST_CLI_DEFINE(cli_funcdevstate_list, "List currently known custom device states"), + AST_CLI_DEFINE(handle_cli_devstate_list, "List currently known custom device states", .deprecate_cmd = &cli_funcdevstate_list_deprecated), }; static struct ast_custom_function devstate_function = { diff --git a/main/asterisk.c b/main/asterisk.c index 4b899cdd97b3a807dc1c36daf6ff1a78761efab5..187623e71f515c881561c68fc90ee28515999fce 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 85545be62b1c53331242db6272a83a04472a8907..488eeee1c0674f79a3f59438704f938bde019010 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 468aa5425accec988c1733c559bb5d2ce45ce682..693c4b8b454d62dafe6e242e721ed2f025d75702 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 b514d33eb57ba964e89699267cb0d18fb9be4ac2..932c6f62e851d7a771e8f2b1f760bdea914a3f79 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 12de3fd531ffd9ac93623c1ffa6c575ed36cc7eb..6ce34432821c719c3b7b8d185ce53c7978a8243f 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) diff --git a/pbx/pbx_ael.c b/pbx/pbx_ael.c index cffa65f40361333d0e625933bc25a230caaa7071..fa4b7d5167a9dc0abcf6f73be9bd195ffe87c341 100644 --- a/pbx/pbx_ael.c +++ b/pbx/pbx_ael.c @@ -146,7 +146,7 @@ static int pbx_load_module(void) } /* 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 @@ static char *handle_cli_ael_debug_multiple(struct ast_cli_entry *e, int cmd, str 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 @@ static char *handle_cli_ael_reload(struct ast_cli_entry *e, int cmd, struct ast_ 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) diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index 9d30fe24fa04b9db20bc94cbf5c8c25c1e17dc96..b5bd58de30e697b6ef751f0440b1890616231517 100644 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -2179,42 +2179,106 @@ static int start_network_thread(void) return 0; } -static char *dundi_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *dundi_do_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "dundi debug"; + e->command = "dundi [no] debug"; e->usage = - "Usage: dundi debug\n" - " Enables dumping of DUNDi packets for debugging purposes\n"; + "Usage: dundi [no] debug\n" + " Enables/Disables dumping of DUNDi packets for debugging purposes\n"; return NULL; case CLI_GENERATE: return NULL; } - if (a->argc != 2) + if (a->argc < 2 || a->argc > 3) return CLI_SHOWUSAGE; - dundidebug = 1; - ast_cli(a->fd, "DUNDi Debugging Enabled\n"); + if (a->argc == 2) { + dundidebug = 1; + ast_cli(a->fd, "DUNDi Debugging Enabled\n"); + } else { + dundidebug = 0; + ast_cli(a->fd, "DUNDi Debugging Disabled\n"); + } + return CLI_SUCCESS; +} + +static char *dundi_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + switch (cmd) { + case CLI_INIT: + e->command = "dundi set debug {on|off}"; + e->usage = + "Usage: dundi set debug {on|off}\n" + " Enables/Disables dumping of DUNDi packets for debugging purposes\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)) { + dundidebug = 1; + ast_cli(a->fd, "DUNDi Debugging Enabled\n"); + } else { + dundidebug = 0; + ast_cli(a->fd, "DUNDi Debugging Disabled\n"); + } return CLI_SUCCESS; } -static char *dundi_do_store_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *dundi_do_store_history_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "dundi store history"; + e->command = "dundi [no] store history"; e->usage = - "Usage: dundi store history\n" - " Enables storing of DUNDi requests and times for debugging\n" + "Usage: dundi [no] store history\n" + " Enables/Disables storing of DUNDi requests and times for debugging\n" "purposes\n"; return NULL; case CLI_GENERATE: return NULL; } - if (a->argc != 3) + if (a->argc < 3 || a->argc > 4) return CLI_SHOWUSAGE; - global_storehistory = 1; - ast_cli(a->fd, "DUNDi History Storage Enabled\n"); + + if (a->argc == 3) { + global_storehistory = 1; + ast_cli(a->fd, "DUNDi History Storage Enabled\n"); + } else { + global_storehistory = 0; + ast_cli(a->fd, "DUNDi History Storage Disabled\n"); + } + return CLI_SUCCESS; +} + +static char *dundi_store_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + switch (cmd) { + case CLI_INIT: + e->command = "dundi store history {on|off}"; + e->usage = + "Usage: dundi store history {on|off}\n" + " Enables/Disables storing of DUNDi requests and times for debugging\n" + "purposes\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)) { + global_storehistory = 1; + ast_cli(a->fd, "DUNDi History Storage Enabled\n"); + } else { + global_storehistory = 0; + ast_cli(a->fd, "DUNDi History Storage Disabled\n"); + } return CLI_SUCCESS; } @@ -2263,45 +2327,6 @@ static char *dundi_flush(struct ast_cli_entry *e, int cmd, struct ast_cli_args * return CLI_SUCCESS; } -static char *dundi_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - switch (cmd) { - case CLI_INIT: - e->command = "dundi no debug"; - e->usage = - "Usage: dundi no debug\n" - " Disables dumping of DUNDi packets for debugging purposes\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - if (a->argc != 3) - return CLI_SHOWUSAGE; - dundidebug = 0; - ast_cli(a->fd, "DUNDi Debugging Disabled\n"); - return CLI_SUCCESS; -} - -static char *dundi_no_store_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - switch (cmd) { - case CLI_INIT: - e->command = "dundi no store history"; - e->usage = - "Usage: dundi no store history\n" - " Disables storing of DUNDi requests and times for debugging\n" - "purposes\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - if (a->argc != 4) - return CLI_SHOWUSAGE; - global_storehistory = 0; - ast_cli(a->fd, "DUNDi History Storage Disabled\n"); - return CLI_SUCCESS; -} - static char *model2str(int model) { switch(model) { @@ -2817,11 +2842,11 @@ static char *dundi_show_precache(struct ast_cli_entry *e, int cmd, struct ast_cl #undef FORMAT2 } +static struct ast_cli_entry cli_dundi_do_debug_deprecated = AST_CLI_DEFINE(dundi_do_debug_deprecated, "Enable/Disable DUNDi debugging"); +static struct ast_cli_entry cli_dundi_do_store_history_deprecated = AST_CLI_DEFINE(dundi_do_store_history_deprecated, "Enable/Disable DUNDi historic records"); static struct ast_cli_entry cli_dundi[] = { - AST_CLI_DEFINE(dundi_do_debug, "Enable DUNDi debugging"), - AST_CLI_DEFINE(dundi_no_debug, "Disable DUNDi debugging"), - AST_CLI_DEFINE(dundi_do_store_history, "Enable DUNDi historic records"), - AST_CLI_DEFINE(dundi_no_store_history, "Disable DUNDi historic records"), + AST_CLI_DEFINE(dundi_set_debug, "Enable/Disable DUNDi debugging", .deprecate_cmd = &cli_dundi_do_debug_deprecated), + AST_CLI_DEFINE(dundi_store_history, "Enable/Disable DUNDi historic records", .deprecate_cmd = &cli_dundi_do_store_history_deprecated), AST_CLI_DEFINE(dundi_flush, "Flush DUNDi cache"), AST_CLI_DEFINE(dundi_show_peers, "Show defined DUNDi peers"), AST_CLI_DEFINE(dundi_show_trans, "Show active DUNDi transactions"), diff --git a/res/res_agi.c b/res/res_agi.c index 0fea962fce601de5d7395697dad7565b9a96d2e7..70df02c62af1354a4e9328234d8cd549efed700e 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -1655,9 +1655,9 @@ static char *handle_cli_agi_debug(struct ast_cli_entry *e, int cmd, struct ast_c { switch (cmd) { case CLI_INIT: - e->command = "agi debug [off]"; + e->command = "agi set debug [on|off]"; e->usage = - "Usage: agi debug [off]\n" + "Usage: agi set debug [on|off]\n" " Enables/disables dumping of AGI transactions for\n" " debugging purposes.\n"; return NULL; @@ -1665,16 +1665,16 @@ static char *handle_cli_agi_debug(struct ast_cli_entry *e, int cmd, struct ast_c case CLI_GENERATE: return NULL; } - if (a->argc < e->args - 1 || a->argc > e->args ) + + if (a->argc != e->args) return CLI_SHOWUSAGE; - if (a->argc == e->args - 1) { + + if (strncasecmp(a->argv[3], "off", 3) == 0) { + agidebug = 0; + } else if (strncasecmp(a->argv[3], "on", 2) == 0) { agidebug = 1; } else { - if (strncasecmp(a->argv[e->args - 1], "off", 3) == 0) { - agidebug = 0; - } else { - return CLI_SHOWUSAGE; - } + return CLI_SHOWUSAGE; } ast_cli(a->fd, "AGI Debugging %sabled\n", agidebug ? "En" : "Dis"); return CLI_SUCCESS; @@ -2767,30 +2767,14 @@ static void write_html_escaped(FILE *htmlfile, char *str) return; } -static char *handle_cli_agi_dumphtml(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static int write_htmldump(char *filename) { struct agi_command *command; char fullcmd[80]; FILE *htmlfile; - switch (cmd) { - case CLI_INIT: - e->command = "agi dumphtml"; - e->usage = - "Usage: agi dumphtml <filename>\n" - " Dumps the AGI command list in HTML format to the given\n" - " file.\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - if (a->argc < e->args + 1) - return CLI_SHOWUSAGE; - - if (!(htmlfile = fopen(a->argv[2], "wt"))) { - ast_cli(a->fd, "Could not create file '%s'\n", a->argv[2]); - return CLI_SHOWUSAGE; - } + if (!(htmlfile = fopen(filename, "wt"))) + return -1; fprintf(htmlfile, "<HTML>\n<HEAD>\n<TITLE>AGI Commands</TITLE>\n</HEAD>\n"); fprintf(htmlfile, "<BODY>\n<CENTER><B><H1>AGI Commands</H1></B></CENTER>\n\n"); @@ -2828,10 +2812,57 @@ static char *handle_cli_agi_dumphtml(struct ast_cli_entry *e, int cmd, struct as AST_RWLIST_UNLOCK(&agi_commands); fprintf(htmlfile, "</TABLE>\n</BODY>\n</HTML>\n"); fclose(htmlfile); + return 0; +} + +static char *handle_cli_agi_dumphtml_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + switch (cmd) { + case CLI_INIT: + e->command = "agi dumphtml"; + e->usage = + "Usage: agi dumphtml <filename>\n" + " Dumps the AGI command list in HTML format to the given\n" + " file.\n"; + return NULL; + case CLI_GENERATE: + return NULL; + } + if (a->argc < e->args + 1) + return CLI_SHOWUSAGE; + + if (write_htmldump(a->argv[2]) < 0) { + ast_cli(a->fd, "Could not create file '%s'\n", a->argv[2]); + return CLI_SHOWUSAGE; + } ast_cli(a->fd, "AGI HTML commands dumped to: %s\n", a->argv[2]); return CLI_SUCCESS; } +static char *handle_cli_agi_dump_html(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + switch (cmd) { + case CLI_INIT: + e->command = "agi dump html"; + e->usage = + "Usage: agi dump html <filename>\n" + " Dumps the AGI command list in HTML format to the given\n" + " file.\n"; + return NULL; + case CLI_GENERATE: + return NULL; + } + if (a->argc != e->args + 1) + return CLI_SHOWUSAGE; + + if (write_htmldump(a->argv[e->args]) < 0) { + ast_cli(a->fd, "Could not create file '%s'\n", a->argv[e->args]); + return CLI_SHOWUSAGE; + } + ast_cli(a->fd, "AGI HTML commands dumped to: %s\n", a->argv[e->args]); + return CLI_SUCCESS; +} + static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int dead) { enum agi_result res; @@ -2941,11 +2972,13 @@ static int deadagi_exec(struct ast_channel *chan, void *data) return agi_exec(chan, data); } +static struct ast_cli_entry cli_agi_dumphtml_deprecated = AST_CLI_DEFINE(handle_cli_agi_dumphtml_deprecated, "Dumps a list of AGI commands in HTML format"); + static struct ast_cli_entry cli_agi[] = { AST_CLI_DEFINE(handle_cli_agi_add_cmd, "Add AGI command to a channel in Async AGI"), - AST_CLI_DEFINE(handle_cli_agi_debug, "Enable/Disable AGI debugging"), - AST_CLI_DEFINE(handle_cli_agi_show, "List AGI commands or specific help"), - AST_CLI_DEFINE(handle_cli_agi_dumphtml, "Dumps a list of AGI commands in HTML format") + AST_CLI_DEFINE(handle_cli_agi_debug, "Enable/Disable AGI debugging"), + AST_CLI_DEFINE(handle_cli_agi_show, "List AGI commands or specific help"), + AST_CLI_DEFINE(handle_cli_agi_dump_html, "Dumps a list of AGI commands in HTML format", .deprecate_cmd = &cli_agi_dumphtml_deprecated) }; static int unload_module(void) diff --git a/res/res_jabber.c b/res/res_jabber.c index 8e7a3d2af59aef6d1b0a85ec09a82011963e5022..4b7dcdd4a84f3aac5a36cea9f92c4b850c4fb134 100644 --- a/res/res_jabber.c +++ b/res/res_jabber.c @@ -87,9 +87,9 @@ static void *aji_recv_loop(void *data); static int aji_initialize(struct aji_client *client); static int aji_client_connect(void *data, ikspak *pak); static void aji_set_presence(struct aji_client *client, char *to, char *from, int level, char *desc); -static char *aji_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); +static char *aji_do_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); +static char *aji_do_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *aji_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); -static char *aji_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *aji_show_clients(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *aji_show_buddies(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *aji_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); @@ -114,9 +114,9 @@ static int aji_register_transport(void *data, ikspak *pak); static int aji_register_transport2(void *data, ikspak *pak); */ +static struct ast_cli_entry cli_aji_do_debug_deprecated = AST_CLI_DEFINE(aji_do_debug_deprecated, "Enable/disable jabber debugging"); static struct ast_cli_entry aji_cli[] = { - AST_CLI_DEFINE(aji_do_debug, "Enable jabber debugging"), - AST_CLI_DEFINE(aji_no_debug, "Disable Jabber debug"), + AST_CLI_DEFINE(aji_do_set_debug, "Enable/Disable Jabber debug", .deprecate_cmd = &cli_aji_do_debug_deprecated), AST_CLI_DEFINE(aji_do_reload, "Reload Jabber configuration"), AST_CLI_DEFINE(aji_show_clients, "Show state of clients and components"), AST_CLI_DEFINE(aji_show_buddies, "Show buddy lists of our clients"), @@ -2330,77 +2330,104 @@ static void aji_set_presence(struct aji_client *client, char *to, char *from, in } /*! - * \brief Turn on console debugging. + * \brief Turn on/off console debugging. * \return CLI_SUCCESS. */ -static char *aji_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *aji_do_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { - switch (cmd) { case CLI_INIT: - e->command = "jabber debug"; + e->command = "jabber set debug {on|off}"; e->usage = - "Usage: jabber debug\n" - " Enables dumping of Jabber packets for debugging purposes.\n"; + "Usage: jabber set debug {on|off}\n" + " Enables/disables dumping of Jabber packets for debugging purposes.\n"; return NULL; case CLI_GENERATE: return NULL; } - ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { - ASTOBJ_RDLOCK(iterator); - iterator->debug = 1; - ASTOBJ_UNLOCK(iterator); - }); - ast_cli(a->fd, "Jabber Debugging Enabled.\n"); - return CLI_SUCCESS; + if (a->argc != e->args) + return CLI_SHOWUSAGE; + + if (!strncasecmp(a->argv[e->args - 1], "on", 2)) { + ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { + ASTOBJ_RDLOCK(iterator); + iterator->debug = 1; + ASTOBJ_UNLOCK(iterator); + }); + ast_cli(a->fd, "Jabber Debugging Enabled.\n"); + return CLI_SUCCESS; + } else if (!strncasecmp(a->argv[e->args - 1], "off", 3)) { + ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { + ASTOBJ_RDLOCK(iterator); + iterator->debug = 0; + ASTOBJ_UNLOCK(iterator); + }); + ast_cli(a->fd, "Jabber Debugging Disabled.\n"); + return CLI_SUCCESS; + } + return CLI_SHOWUSAGE; /* defaults to invalid */ } /*! - * \brief Reload jabber module. + * \brief Turn on/off console debugging (deprecated, use aji_do_set_debug). * \return CLI_SUCCESS. */ -static char *aji_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *aji_do_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { + switch (cmd) { case CLI_INIT: - e->command = "jabber reload"; + e->command = "jabber debug [off]"; e->usage = - "Usage: jabber reload\n" - " Reloads the Jabber module.\n"; + "Usage: jabber debug [off]\n" + " Enables/disables dumping of Jabber packets for debugging purposes.\n"; return NULL; case CLI_GENERATE: return NULL; } - aji_reload(1); - ast_cli(a->fd, "Jabber Reloaded.\n"); - return CLI_SUCCESS; + if (a->argc == 2) { + ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { + ASTOBJ_RDLOCK(iterator); + iterator->debug = 1; + ASTOBJ_UNLOCK(iterator); + }); + ast_cli(a->fd, "Jabber Debugging Enabled.\n"); + return CLI_SUCCESS; + } else if (a->argc == 3) { + if (!strncasecmp(a->argv[2], "off", 3)) { + ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { + ASTOBJ_RDLOCK(iterator); + iterator->debug = 0; + ASTOBJ_UNLOCK(iterator); + }); + ast_cli(a->fd, "Jabber Debugging Disabled.\n"); + return CLI_SUCCESS; + } + } + return CLI_SHOWUSAGE; /* defaults to invalid */ } /*! - * \brief Turn off console debugging. + * \brief Reload jabber module. * \return CLI_SUCCESS. */ -static char *aji_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *aji_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: - e->command = "jabber debug off"; + e->command = "jabber reload"; e->usage = - "Usage: jabber debug off\n" - " Disables dumping of Jabber packets for debugging purposes.\n"; + "Usage: jabber reload\n" + " Reloads the Jabber module.\n"; return NULL; case CLI_GENERATE: return NULL; } - ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { - ASTOBJ_RDLOCK(iterator); - iterator->debug = 0; - ASTOBJ_UNLOCK(iterator); - }); - ast_cli(a->fd, "Jabber Debugging Disabled.\n"); + aji_reload(1); + ast_cli(a->fd, "Jabber Reloaded.\n"); return CLI_SUCCESS; }