aboutsummaryrefslogtreecommitdiffstats
path: root/channels
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 /channels
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 'channels')
-rw-r--r--channels/chan_gtalk.c66
-rw-r--r--channels/chan_mgcp.c207
-rw-r--r--channels/chan_oss.c118
-rw-r--r--channels/chan_skinny.c390
-rw-r--r--channels/iax2-provision.c79
5 files changed, 474 insertions, 386 deletions
diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c
index a67df2c8a..be3a346c5 100644
--- a/channels/chan_gtalk.c
+++ b/channels/chan_gtalk.c
@@ -191,8 +191,8 @@ static int gtalk_indicate(struct ast_channel *ast, int condition, const void *da
static int gtalk_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
static int gtalk_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen);
static struct gtalk_pvt *gtalk_alloc(struct gtalk *client, const char *us, const char *them, const char *sid);
-static int gtalk_do_reload(int fd, int argc, char **argv);
-static int gtalk_show_channels(int fd, int argc, char **argv);
+static char *gtalk_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+static char *gtalk_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
/*----- RTP interface functions */
static int gtalk_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp,
struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active);
@@ -226,7 +226,6 @@ static struct sched_context *sched; /*!< The scheduling context */
static struct io_context *io; /*!< The IO context */
static struct in_addr __ourip;
-
/*! \brief RTP driver interface */
static struct ast_rtp_protocol gtalk_rtp = {
type: "Gtalk",
@@ -235,21 +234,10 @@ static struct ast_rtp_protocol gtalk_rtp = {
get_codec: gtalk_get_codec,
};
-static const char debug_usage[] =
-"Usage: gtalk show channels\n"
-" Shows current state of the Gtalk channels.\n";
-
-static const char reload_usage[] =
-"Usage: gtalk reload\n"
-" Reload gtalk channel driver.\n";
-
-
static struct ast_cli_entry gtalk_cli[] = {
- {{ "gtalk", "reload", NULL}, gtalk_do_reload, "Enable Jabber debugging", reload_usage },
- {{ "gtalk", "show", "channels", NULL}, gtalk_show_channels, "Show GoogleTalk Channels", debug_usage },
- };
-
-
+ NEW_CLI(gtalk_do_reload, "Enable Jabber debugging"),
+ NEW_CLI(gtalk_show_channels, "Show GoogleTalk Channels"),
+};
static char externip[16];
@@ -265,7 +253,7 @@ static struct gtalk *find_gtalk(char *name, char *connection)
struct gtalk *gtalk = NULL;
char *domain = NULL , *s = NULL;
- if(strchr(connection, '@')) {
+ if (strchr(connection, '@')) {
s = ast_strdupa(connection);
domain = strsep(&s, "@");
ast_verbose("OOOOH domain = %s\n", domain);
@@ -1581,7 +1569,7 @@ static struct ast_channel *gtalk_request(const char *type, int format, void *dat
}
/*! \brief CLI command "gtalk show channels" */
-static int gtalk_show_channels(int fd, int argc, char **argv)
+static char *gtalk_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
#define FORMAT "%-30.30s %-30.30s %-15.15s %-5.5s %-5.5s \n"
struct gtalk_pvt *p;
@@ -1591,11 +1579,22 @@ static int gtalk_show_channels(int fd, int argc, char **argv)
char *jid = NULL;
char *resource = NULL;
- if (argc != 3)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "gtalk show channels";
+ e->usage =
+ "Usage: gtalk show channels\n"
+ " Shows current state of the Gtalk channels.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 3)
+ return CLI_SHOWUSAGE;
ast_mutex_lock(&gtalklock);
- ast_cli(fd, FORMAT, "Channel", "Jabber ID", "Resource", "Read", "Write");
+ ast_cli(a->fd, FORMAT, "Channel", "Jabber ID", "Resource", "Read", "Write");
ASTOBJ_CONTAINER_TRAVERSE(&gtalk_list, 1, {
ASTOBJ_WRLOCK(iterator);
p = iterator->p;
@@ -1611,7 +1610,7 @@ static int gtalk_show_channels(int fd, int argc, char **argv)
resource ++;
}
if (chan)
- ast_cli(fd, FORMAT,
+ ast_cli(a->fd, FORMAT,
chan->name,
jid,
resource,
@@ -1628,16 +1627,27 @@ static int gtalk_show_channels(int fd, int argc, char **argv)
ast_mutex_unlock(&gtalklock);
- ast_cli(fd, "%d active gtalk channel%s\n", numchans, (numchans != 1) ? "s" : "");
- return RESULT_SUCCESS;
+ ast_cli(a->fd, "%d active gtalk channel%s\n", numchans, (numchans != 1) ? "s" : "");
+ return CLI_SUCCESS;
#undef FORMAT
}
-/*! \brief CLI command "gtalk show channels" */
-static int gtalk_do_reload(int fd, int argc, char **argv)
+/*! \brief CLI command "gtalk reload" */
+static char *gtalk_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "gtalk reload";
+ e->usage =
+ "Usage: gtalk reload\n"
+ " Reload gtalk channel driver.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
ast_verbose("IT DOES WORK!\n");
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
static int gtalk_parser(void *data, ikspak *pak)
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 7693397c7..a509dea7d 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -422,7 +422,7 @@ static void start_rtp(struct mgcp_subchannel *sub);
static void handle_response(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
int result, unsigned int ident, struct mgcp_request *resp);
static void dump_cmd_queues(struct mgcp_endpoint *p, struct mgcp_subchannel *sub);
-static int mgcp_reload(int fd, int argc, char *argv[]);
+static char *mgcp_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static int reload_config(int reload);
static struct ast_channel *mgcp_request(const char *type, int format, void *data, int *cause);
@@ -1041,71 +1041,72 @@ static int mgcp_hangup(struct ast_channel *ast)
return 0;
}
-static int mgcp_show_endpoints(int fd, int argc, char *argv[])
+static char *handle_mgcp_show_endpoints(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- struct mgcp_gateway *g;
- struct mgcp_endpoint *e;
+ struct mgcp_gateway *mg;
+ struct mgcp_endpoint *me;
int hasendpoints = 0;
- if (argc != 3)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "mgcp show endpoints";
+ e->usage =
+ "Usage: mgcp show endpoints\n"
+ " Lists all endpoints known to the MGCP (Media Gateway Control Protocol) subsystem.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 3)
+ return CLI_SHOWUSAGE;
ast_mutex_lock(&gatelock);
- g = gateways;
- while(g) {
- e = g->endpoints;
- ast_cli(fd, "Gateway '%s' at %s (%s)\n", g->name, g->addr.sin_addr.s_addr ? ast_inet_ntoa(g->addr.sin_addr) : ast_inet_ntoa(g->defaddr.sin_addr), g->dynamic ? "Dynamic" : "Static");
- while(e) {
+ mg = gateways;
+ while(mg) {
+ me = mg->endpoints;
+ ast_cli(a->fd, "Gateway '%s' at %s (%s)\n", mg->name, mg->addr.sin_addr.s_addr ? ast_inet_ntoa(mg->addr.sin_addr) : ast_inet_ntoa(mg->defaddr.sin_addr), mg->dynamic ? "Dynamic" : "Static");
+ while(me) {
/* Don't show wilcard endpoint */
- if (strcmp(e->name, g->wcardep) !=0)
- ast_cli(fd, " -- '%s@%s in '%s' is %s\n", e->name, g->name, e->context, e->sub->owner ? "active" : "idle");
+ if (strcmp(me->name, mg->wcardep) != 0)
+ ast_cli(a->fd, " -- '%s@%s in '%s' is %s\n", me->name, mg->name, me->context, me->sub->owner ? "active" : "idle");
hasendpoints = 1;
- e = e->next;
+ me = me->next;
}
if (!hasendpoints) {
- ast_cli(fd, " << No Endpoints Defined >> ");
+ ast_cli(a->fd, " << No Endpoints Defined >> ");
}
- g = g->next;
+ mg = mg->next;
}
ast_mutex_unlock(&gatelock);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
-static const char show_endpoints_usage[] =
-"Usage: mgcp show endpoints\n"
-" Lists all endpoints known to the MGCP (Media Gateway Control Protocol) subsystem.\n";
-
-static const char audit_endpoint_usage[] =
-"Usage: mgcp audit endpoint <endpointid>\n"
-" Lists the capabilities of an endpoint in the MGCP (Media Gateway Control Protocol) subsystem.\n"
-" mgcp debug MUST be on to see the results of this command.\n";
-
-static const char debug_usage[] =
-"Usage: mgcp set debug\n"
-" Enables dumping of MGCP packets for debugging purposes\n";
-
-static const char no_debug_usage[] =
-"Usage: mgcp set debug off\n"
-" Disables dumping of MGCP packets for debugging purposes\n";
-
-static const char mgcp_reload_usage[] =
-"Usage: mgcp reload\n"
-" Reloads MGCP configuration from mgcp.conf\n"
-" Deprecated: please use 'reload chan_mgcp.so' instead.\n";
-
-static int mgcp_audit_endpoint(int fd, int argc, char *argv[])
+static char *handle_mgcp_audit_endpoint(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- struct mgcp_gateway *g;
- struct mgcp_endpoint *e;
+ struct mgcp_gateway *mg;
+ struct mgcp_endpoint *me;
int found = 0;
char *ename,*gname, *c;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "mgcp audit endpoint";
+ e->usage =
+ "Usage: mgcp audit endpoint <endpointid>\n"
+ " Lists the capabilities of an endpoint in the MGCP (Media Gateway Control Protocol) subsystem.\n"
+ " mgcp debug MUST be on to see the results of this command.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
if (!mgcpdebug) {
- return RESULT_SHOWUSAGE;
+ return CLI_SHOWUSAGE;
}
- if (argc != 4)
- return RESULT_SHOWUSAGE;
+ if (a->argc != 4)
+ return CLI_SHOWUSAGE;
/* split the name into parts by null */
- ename = argv[3];
+ ename = a->argv[3];
gname = ename;
while (*gname) {
if (*gname == '@') {
@@ -1120,69 +1121,77 @@ static int mgcp_audit_endpoint(int fd, int argc, char *argv[])
if ((c = strrchr(gname, ']')))
*c = '\0';
ast_mutex_lock(&gatelock);
- g = gateways;
- while(g) {
- if (!strcasecmp(g->name, gname)) {
- e = g->endpoints;
- while(e) {
- if (!strcasecmp(e->name, ename)) {
+ mg = gateways;
+ while(mg) {
+ if (!strcasecmp(mg->name, gname)) {
+ me = mg->endpoints;
+ while(me) {
+ if (!strcasecmp(me->name, ename)) {
found = 1;
- transmit_audit_endpoint(e);
+ transmit_audit_endpoint(me);
break;
}
- e = e->next;
+ me = me->next;
}
if (found) {
break;
}
}
- g = g->next;
+ mg = mg->next;
}
if (!found) {
- ast_cli(fd, " << Could not find endpoint >> ");
+ ast_cli(a->fd, " << Could not find endpoint >> ");
}
ast_mutex_unlock(&gatelock);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
-static int mgcp_do_debug(int fd, int argc, char *argv[])
+static char *handle_mgcp_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- if (argc != 3)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "mgcp set debug";
+ e->usage =
+ "Usage: mgcp set debug\n"
+ " Enables dumping of MGCP packets for debugging purposes\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 3)
+ return CLI_SHOWUSAGE;
mgcpdebug = 1;
- ast_cli(fd, "MGCP Debugging Enabled\n");
- return RESULT_SUCCESS;
+ ast_cli(a->fd, "MGCP Debugging Enabled\n");
+ return CLI_SUCCESS;
}
-static int mgcp_no_debug(int fd, int argc, char *argv[])
+static char *handle_mgcp_set_debug_off(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- if (argc != 4)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "mgcp set debug off";
+ e->usage =
+ "Usage: mgcp set debug off\n"
+ " Disables dumping of MGCP packets for debugging purposes\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 4)
+ return CLI_SHOWUSAGE;
mgcpdebug = 0;
- ast_cli(fd, "MGCP Debugging Disabled\n");
- return RESULT_SUCCESS;
+ ast_cli(a->fd, "MGCP Debugging Disabled\n");
+ return CLI_SUCCESS;
}
static struct ast_cli_entry cli_mgcp[] = {
- { { "mgcp", "audit", "endpoint", NULL },
- mgcp_audit_endpoint, "Audit specified MGCP endpoint",
- audit_endpoint_usage },
-
- { { "mgcp", "show", "endpoints", NULL },
- mgcp_show_endpoints, "List defined MGCP endpoints",
- show_endpoints_usage },
-
- { { "mgcp", "set", "debug", NULL },
- mgcp_do_debug, "Enable MGCP debugging",
- debug_usage },
-
- { { "mgcp", "set", "debug", "off", NULL },
- mgcp_no_debug, "Disable MGCP debugging",
- no_debug_usage },
-
- { { "mgcp", "reload", NULL },
- mgcp_reload, "Reload MGCP configuration",
- mgcp_reload_usage },
+ NEW_CLI(handle_mgcp_audit_endpoint, "Audit specified MGCP endpoint"),
+ NEW_CLI(handle_mgcp_show_endpoints, "List defined MGCP endpoints"),
+ NEW_CLI(handle_mgcp_set_debug, "Enable MGCP debugging"),
+ NEW_CLI(handle_mgcp_set_debug_off, "Disable MGCP debugging"),
+ NEW_CLI(mgcp_reload, "Reload MGCP configuration"),
};
static int mgcp_answer(struct ast_channel *ast)
@@ -4242,10 +4251,24 @@ static int load_module(void)
return AST_MODULE_LOAD_SUCCESS;
}
-static int mgcp_reload(int fd, int argc, char *argv[])
+static char *mgcp_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
static int deprecated = 0;
- if (!deprecated && argc > 0) {
+
+ if (e) {
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "mgcp reload";
+ e->usage =
+ "Usage: mgcp reload\n"
+ " 'mgcp reload' is deprecated. Please use 'reload chan_mgcp.so' instead.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+ }
+
+ if (!deprecated && a && a->argc > 0) {
ast_log(LOG_WARNING, "'mgcp reload' is deprecated. Please use 'reload chan_mgcp.so' instead.\n");
deprecated = 1;
}
@@ -4257,12 +4280,12 @@ static int mgcp_reload(int fd, int argc, char *argv[])
mgcp_reloading = 1;
ast_mutex_unlock(&mgcp_reload_lock);
restart_monitor();
- return 0;
+ return CLI_SUCCESS;
}
static int reload(void)
{
- mgcp_reload(0, 0, NULL);
+ mgcp_reload(NULL, 0, NULL);
return 0;
}
@@ -4297,7 +4320,7 @@ static int unload_module(void)
/* We always want to leave this in a consistent state */
ast_channel_register(&mgcp_tech);
mgcp_reloading = 0;
- mgcp_reload(0, 0, NULL);
+ mgcp_reload(NULL, 0, NULL);
return -1;
}
@@ -4317,7 +4340,7 @@ static int unload_module(void)
/* Allow the monitor to restart */
monitor_thread = AST_PTHREADT_NULL;
mgcp_reloading = 0;
- mgcp_reload(0, 0, NULL);
+ mgcp_reload(NULL, 0, NULL);
return -1;
}
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index 42e054609..cea7984dc 100644
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -1333,69 +1333,83 @@ static char *console_mute(struct ast_cli_entry *e, int cmd, struct ast_cli_args
return CLI_SUCCESS;
}
-static int console_transfer(int fd, int argc, char *argv[])
+static char *console_transfer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct chan_oss_pvt *o = find_desc(oss_active);
struct ast_channel *b = NULL;
char *tmp, *ext, *ctx;
- if (argc != 3)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "console transfer";
+ e->usage =
+ "Usage: console transfer <extension>[@context]\n"
+ " Transfers the currently connected call to the given extension (and\n"
+ " context if specified)\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 3)
+ return CLI_SHOWUSAGE;
if (o == NULL)
- return RESULT_FAILURE;
+ return CLI_FAILURE;
if (o->owner == NULL || (b = ast_bridged_channel(o->owner)) == NULL) {
- ast_cli(fd, "There is no call to transfer\n");
- return RESULT_SUCCESS;
+ ast_cli(a->fd, "There is no call to transfer\n");
+ return CLI_SUCCESS;
}
- tmp = ast_ext_ctx(argv[2], &ext, &ctx);
+ tmp = ast_ext_ctx(a->argv[2], &ext, &ctx);
if (ctx == NULL) /* supply default context if needed */
ctx = o->owner->context;
if (!ast_exists_extension(b, ctx, ext, 1, b->cid.cid_num))
- ast_cli(fd, "No such extension exists\n");
+ ast_cli(a->fd, "No such extension exists\n");
else {
- ast_cli(fd, "Whee, transferring %s to %s@%s.\n", b->name, ext, ctx);
+ ast_cli(a->fd, "Whee, transferring %s to %s@%s.\n", b->name, ext, ctx);
if (ast_async_goto(b, ctx, ext, 1))
- ast_cli(fd, "Failed to transfer :(\n");
+ ast_cli(a->fd, "Failed to transfer :(\n");
}
if (tmp)
ast_free(tmp);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
-static const char transfer_usage[] =
- "Usage: console transfer <extension>[@context]\n"
- " Transfers the currently connected call to the given extension (and\n"
- "context if specified)\n";
-
-static int console_active(int fd, int argc, char *argv[])
+static char *console_active(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- if (argc == 2)
- ast_cli(fd, "active console is [%s]\n", oss_active);
- else if (argc != 3)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "console active";
+ e->usage =
+ "Usage: console active [device]\n"
+ " If used without a parameter, displays which device is the current\n"
+ " console. If a device is specified, the console sound device is changed to\n"
+ " the device specified.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc == 2)
+ ast_cli(a->fd, "active console is [%s]\n", oss_active);
+ else if (a->argc != 3)
+ return CLI_SHOWUSAGE;
else {
struct chan_oss_pvt *o;
- if (strcmp(argv[2], "show") == 0) {
+ if (strcmp(a->argv[2], "show") == 0) {
for (o = oss_default.next; o; o = o->next)
- ast_cli(fd, "device [%s] exists\n", o->name);
- return RESULT_SUCCESS;
+ ast_cli(a->fd, "device [%s] exists\n", o->name);
+ return CLI_SUCCESS;
}
- o = find_desc(argv[2]);
+ o = find_desc(a->argv[2]);
if (o == NULL)
- ast_cli(fd, "No device [%s] exists\n", argv[2]);
+ ast_cli(a->fd, "No device [%s] exists\n", a->argv[2]);
else
oss_active = o->name;
}
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
-static const char active_usage[] =
- "Usage: console active [device]\n"
- " If used without a parameter, displays which device is the current\n"
- "console. If a device is specified, the console sound device is changed to\n"
- "the device specified.\n";
-
/*!
* \brief store the boost factor
*/
@@ -1418,15 +1432,26 @@ static void store_boost(struct chan_oss_pvt *o, char *s)
ast_log(LOG_WARNING, "setting boost %s to %d\n", s, o->boost);
}
-static int do_boost(int fd, int argc, char *argv[])
+static char *console_boost(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct chan_oss_pvt *o = find_desc(oss_active);
- if (argc == 2)
- ast_cli(fd, "boost currently %5.1f\n", 20 * log10(((double) o->boost / (double) BOOST_SCALE)));
- else if (argc == 3)
- store_boost(o, argv[2]);
- return RESULT_SUCCESS;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "console boost";
+ e->usage =
+ "Usage: console boost [boost in dB]\n"
+ " Sets or display mic boost in dB\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc == 2)
+ ast_cli(a->fd, "boost currently %5.1f\n", 20 * log10(((double) o->boost / (double) BOOST_SCALE)));
+ else if (a->argc == 3)
+ store_boost(o, a->argv[2]);
+ return CLI_SUCCESS;
}
static struct ast_cli_entry cli_oss[] = {
@@ -1435,20 +1460,11 @@ static struct ast_cli_entry cli_oss[] = {
NEW_CLI(console_flash, "Flash a call on the console"),
NEW_CLI(console_dial, "Dial an extension on the console"),
NEW_CLI(console_mute, "Disable/Enable mic input"),
- { { "console", "transfer", NULL },
- console_transfer, "Transfer a call to a different extension",
- transfer_usage },
-
+ NEW_CLI(console_transfer, "Transfer a call to a different extension"),
NEW_CLI(console_sendtext, "Send text to the remote device"),
NEW_CLI(console_autoanswer, "Sets/displays autoanswer"),
-
- { { "console", "boost", NULL },
- do_boost, "Sets/displays mic boost in dB",
- NULL },
-
- { { "console", "active", NULL },
- console_active, "Sets/displays active console",
- active_usage },
+ NEW_CLI(console_boost, "Sets/displays mic boost in dB"),
+ NEW_CLI(console_active, "Sets/displays active console"),
};
/*!
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index b1a83abbe..0e5868982 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -2262,24 +2262,46 @@ static struct ast_rtp_protocol skinny_rtp = {
.set_rtp_peer = skinny_set_rtp_peer,
};
-static int skinny_do_debug(int fd, int argc, char *argv[])
+static char *handle_skinny_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- if (argc != 3)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "skinny set debug";
+ e->usage =
+ "Usage: skinny set debug\n"
+ " Enables dumping of Skinny packets for debugging purposes\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 3)
+ return CLI_SHOWUSAGE;
skinnydebug = 1;
- ast_cli(fd, "Skinny Debugging Enabled\n");
- return RESULT_SUCCESS;
+ ast_cli(a->fd, "Skinny Debugging Enabled\n");
+ return CLI_SUCCESS;
}
-static int skinny_no_debug(int fd, int argc, char *argv[])
+static char *handle_skinny_set_debug_off(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- if (argc != 4)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "skinny set debug off";
+ e->usage =
+ "Usage: skinny set debug off\n"
+ " Disables dumping of Skinny packets for debugging purposes\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 4)
+ return CLI_SHOWUSAGE;
skinnydebug = 0;
- ast_cli(fd, "Skinny Debugging Disabled\n");
- return RESULT_SUCCESS;
+ ast_cli(a->fd, "Skinny Debugging Disabled\n");
+ return CLI_SUCCESS;
}
static char *complete_skinny_devices(const char *word, int state)
@@ -2306,7 +2328,7 @@ static char *complete_skinny_reset(const char *line, const char *word, int pos,
return (pos == 2 ? ast_strdup(complete_skinny_devices(word, state)) : NULL);
}
-static char *complete_skinny_show_lines(const char *line, const char *word, int pos, int state)
+static char *complete_skinny_show_line(const char *line, const char *word, int pos, int state)
{
struct skinny_device *d;
struct skinny_line *l;
@@ -2326,26 +2348,37 @@ static char *complete_skinny_show_lines(const char *line, const char *word, int
return result;
}
-static int skinny_reset_device(int fd, int argc, char *argv[])
+static char *handle_skinny_reset(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct skinny_device *d;
struct skinny_req *req;
- if (argc < 3 || argc > 4)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "skinny reset";
+ e->usage =
+ "Usage: skinny reset <DeviceId|DeviceName|all> [restart]\n"
+ " Causes a Skinny device to reset itself, optionally with a full restart\n";
+ return NULL;
+ case CLI_GENERATE:
+ return complete_skinny_reset(a->line, a->word, a->pos, a->n);
+ }
+
+ if (a->argc < 3 || a->argc > 4)
+ return CLI_SHOWUSAGE;
ast_mutex_lock(&devicelock);
for (d = devices; d; d = d->next) {
int fullrestart = 0;
- if (!strcasecmp(argv[2], d->id) || !strcasecmp(argv[2], d->name) || !strcasecmp(argv[2], "all")) {
+ if (!strcasecmp(a->argv[2], d->id) || !strcasecmp(a->argv[2], d->name) || !strcasecmp(a->argv[2], "all")) {
if (!(d->session))
continue;
if (!(req = req_alloc(sizeof(struct reset_message), RESET_MESSAGE)))
continue;
- if (argc == 4 && !strcasecmp(argv[3], "restart"))
+ if (a->argc == 4 && !strcasecmp(a->argv[3], "restart"))
fullrestart = 1;
if (fullrestart)
@@ -2358,7 +2391,7 @@ static int skinny_reset_device(int fd, int argc, char *argv[])
}
}
ast_mutex_unlock(&devicelock);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
static char *device2str(int type)
@@ -2450,18 +2483,29 @@ static void print_codec_to_cli(int fd, struct ast_codec_pref *pref)
ast_cli(fd, "none");
}
-static int skinny_show_devices(int fd, int argc, char *argv[])
+static char *handle_skinny_show_devices(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct skinny_device *d;
struct skinny_line *l;
- if (argc != 3)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "skinny show devices";
+ e->usage =
+ "Usage: skinny show devices\n"
+ " Lists all devices known to the Skinny subsystem.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 3)
+ return CLI_SHOWUSAGE;
ast_mutex_lock(&devicelock);
- ast_cli(fd, "Name DeviceId IP Type R NL\n");
- ast_cli(fd, "-------------------- ---------------- --------------- --------------- - --\n");
+ ast_cli(a->fd, "Name DeviceId IP Type R NL\n");
+ ast_cli(a->fd, "-------------------- ---------------- --------------- --------------- - --\n");
for (d = devices; d; d = d->next) {
int numlines = 0;
@@ -2469,7 +2513,7 @@ static int skinny_show_devices(int fd, int argc, char *argv[])
for (l = d->lines; l; l = l->next)
numlines++;
- ast_cli(fd, "%-20s %-16s %-15s %-15s %c %2d\n",
+ ast_cli(a->fd, "%-20s %-16s %-15s %-15s %c %2d\n",
d->name,
d->id,
d->session?ast_inet_ntoa(d->session->sin.sin_addr):"",
@@ -2480,69 +2524,91 @@ static int skinny_show_devices(int fd, int argc, char *argv[])
ast_mutex_unlock(&devicelock);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
/*! \brief Show device information */
-static int skinny_show_device(int fd, int argc, char *argv[])
+static char *handle_skinny_show_device(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct skinny_device *d;
struct skinny_line *l;
struct skinny_speeddial *sd;
- struct skinny_addon *a;
+ struct skinny_addon *sa;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "skinny show device";
+ e->usage =
+ "Usage: skinny show device <DeviceId|DeviceName>\n"
+ " Lists all deviceinformation of a specific device known to the Skinny subsystem.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return complete_skinny_show_device(a->line, a->word, a->pos, a->n);
+ }
- if (argc < 4)
- return RESULT_SHOWUSAGE;
+ if (a->argc < 4)
+ return CLI_SHOWUSAGE;
ast_mutex_lock(&devicelock);
for (d = devices; d; d = d->next) {
- if (!strcasecmp(argv[3], d->id) || !strcasecmp(argv[3], d->name)) {
+ if (!strcasecmp(a->argv[3], d->id) || !strcasecmp(a->argv[3], d->name)) {
int numlines = 0, numaddons = 0, numspeeddials = 0;
for (l = d->lines; l; l = l->next)
numlines++;
- ast_cli(fd, "Name: %s\n", d->name);
- ast_cli(fd, "Id: %s\n", d->id);
- ast_cli(fd, "version: %s\n", S_OR(d->version_id, "Unknown"));
- ast_cli(fd, "Ip address: %s\n", (d->session ? ast_inet_ntoa(d->session->sin.sin_addr) : "Unknown"));
- ast_cli(fd, "Port: %d\n", (d->session ? ntohs(d->session->sin.sin_port) : 0));
- ast_cli(fd, "Device Type: %s\n", device2str(d->type));
- ast_cli(fd, "Registered: %s\n", (d->registered ? "Yes" : "No"));
- ast_cli(fd, "Lines: %d\n", numlines);
+ ast_cli(a->fd, "Name: %s\n", d->name);
+ ast_cli(a->fd, "Id: %s\n", d->id);
+ ast_cli(a->fd, "version: %s\n", S_OR(d->version_id, "Unknown"));
+ ast_cli(a->fd, "Ip address: %s\n", (d->session ? ast_inet_ntoa(d->session->sin.sin_addr) : "Unknown"));
+ ast_cli(a->fd, "Port: %d\n", (d->session ? ntohs(d->session->sin.sin_port) : 0));
+ ast_cli(a->fd, "Device Type: %s\n", device2str(d->type));
+ ast_cli(a->fd, "Registered: %s\n", (d->registered ? "Yes" : "No"));
+ ast_cli(a->fd, "Lines: %d\n", numlines);
for (l = d->lines; l; l = l->next)
- ast_cli(fd, " %s (%s)\n", l->name, l->label);
- for (a = d->addons; a; a = a->next)
+ ast_cli(a->fd, " %s (%s)\n", l->name, l->label);
+ for (sa = d->addons; sa; sa = sa->next)
numaddons++;
- ast_cli(fd, "Addons: %d\n", numaddons);
- for (a = d->addons; a; a = a->next)
- ast_cli(fd, " %s\n", a->type);
+ ast_cli(a->fd, "Addons: %d\n", numaddons);
+ for (sa = d->addons; sa; sa = sa->next)
+ ast_cli(a->fd, " %s\n", sa->type);
for (sd = d->speeddials; sd; sd = sd->next)
numspeeddials++;
- ast_cli(fd, "Speeddials: %d\n", numspeeddials);
+ ast_cli(a->fd, "Speeddials: %d\n", numspeeddials);
for (sd = d->speeddials; sd; sd = sd->next)
- ast_cli(fd, " %s (%s) ishint: %d\n", sd->exten, sd->label, sd->isHint);
+ ast_cli(a->fd, " %s (%s) ishint: %d\n", sd->exten, sd->label, sd->isHint);
}
}
ast_mutex_unlock(&devicelock);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
-static int skinny_show_lines(int fd, int argc, char *argv[])
+static char *handle_skinny_show_lines(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct skinny_device *d;
struct skinny_line *l;
- if (argc != 3)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "skinny show lines";
+ e->usage =
+ "Usage: skinny show lines\n"
+ " Lists all lines known to the Skinny subsystem.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 3)
+ return CLI_SHOWUSAGE;
ast_mutex_lock(&devicelock);
- ast_cli(fd, "Device Name Instance Name Label \n");
- ast_cli(fd, "-------------------- -------- -------------------- --------------------\n");
+ ast_cli(a->fd, "Device Name Instance Name Label \n");
+ ast_cli(a->fd, "-------------------- -------- -------------------- --------------------\n");
for (d = devices; d; d = d->next) {
for (l = d->lines; l; l = l->next) {
- ast_cli(fd, "%-20s %8d %-20s %-20s\n",
+ ast_cli(a->fd, "%-20s %8d %-20s %-20s\n",
d->name,
l->instance,
l->name,
@@ -2551,162 +2617,128 @@ static int skinny_show_lines(int fd, int argc, char *argv[])
}
ast_mutex_unlock(&devicelock);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
/*! \brief List line information. */
-static int skinny_show_line(int fd, int argc, char *argv[])
+static char *handle_skinny_show_line(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct skinny_device *d;
struct skinny_line *l;
-
char codec_buf[512];
char group_buf[256];
- if (argc < 4)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "skinny show line";
+ e->usage =
+ "Usage: skinny show line <Line> [ on <DeviceID|DeviceName> ]\n"
+ " List all lineinformation of a specific line known to the Skinny subsystem.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return complete_skinny_show_line(a->line, a->word, a->pos, a->n);
+ }
+
+ if (a->argc < 4)
+ return CLI_SHOWUSAGE;
ast_mutex_lock(&devicelock);
/* Show all lines matching the one supplied */
for (d = devices; d; d = d->next) {
- if (argc == 6 && (strcasecmp(argv[5], d->id) && strcasecmp(argv[5], d->name)))
+ if (a->argc == 6 && (strcasecmp(a->argv[5], d->id) && strcasecmp(a->argv[5], d->name)))
continue;
for (l = d->lines; l; l = l->next) {
- if (strcasecmp(argv[3], l->name))
+ if (strcasecmp(a->argv[3], l->name))
continue;
- ast_cli(fd, "Line: %s\n", l->name);
- ast_cli(fd, "On Device: %s\n", d->name);
- ast_cli(fd, "Line Label: %s\n", l->label);
- ast_cli(fd, "Extension: %s\n", S_OR(l->exten, "<not set>"));
- ast_cli(fd, "Context: %s\n", l->context);
- ast_cli(fd, "CallGroup: %s\n", ast_print_group(group_buf, sizeof(group_buf), l->callgroup));
- ast_cli(fd, "PickupGroup: %s\n", ast_print_group(group_buf, sizeof(group_buf), l->pickupgroup));
- ast_cli(fd, "Language: %s\n", S_OR(l->language, "<not set>"));
- ast_cli(fd, "Accountcode: %s\n", S_OR(l->accountcode, "<not set>"));
- ast_cli(fd, "AmaFlag: %s\n", ast_cdr_flags2str(l->amaflags));
- ast_cli(fd, "CallerId Number: %s\n", S_OR(l->cid_num, "<not set>"));
- ast_cli(fd, "CallerId Name: %s\n", S_OR(l->cid_name, "<not set>"));
- ast_cli(fd, "Hide CallerId: %s\n", (l->hidecallerid ? "Yes" : "No"));
- ast_cli(fd, "CallForward: %s\n", S_OR(l->call_forward, "<not set>"));
- ast_cli(fd, "VoicemailBox: %s\n", S_OR(l->mailbox, "<not set>"));
- ast_cli(fd, "VoicemailNumber: %s\n", S_OR(l->vmexten, "<not set>"));
- ast_cli(fd, "MWIblink: %d\n", l->mwiblink);
- ast_cli(fd, "Regextension: %s\n", S_OR(l->regexten, "<not set>"));
- ast_cli(fd, "Regcontext: %s\n", S_OR(l->regcontext, "<not set>"));
- ast_cli(fd, "MoHInterpret: %s\n", S_OR(l->mohinterpret, "<not set>"));
- ast_cli(fd, "MoHSuggest: %s\n", S_OR(l->mohsuggest, "<not set>"));
- ast_cli(fd, "Last dialed nr: %s\n", S_OR(l->lastnumberdialed, "<no calls made yet>"));
- ast_cli(fd, "Last CallerID: %s\n", S_OR(l->lastcallerid, "<not set>"));
- ast_cli(fd, "Transfer enabled: %s\n", (l->transfer ? "Yes" : "No"));
- ast_cli(fd, "Callwaiting: %s\n", (l->callwaiting ? "Yes" : "No"));
- ast_cli(fd, "3Way Calling: %s\n", (l->threewaycalling ? "Yes" : "No"));
- ast_cli(fd, "Can forward: %s\n", (l->cancallforward ? "Yes" : "No"));
- ast_cli(fd, "Do Not Disturb: %s\n", (l->dnd ? "Yes" : "No"));
- ast_cli(fd, "NAT: %s\n", (l->nat ? "Yes" : "No"));
- ast_cli(fd, "immediate: %s\n", (l->immediate ? "Yes" : "No"));
- ast_cli(fd, "Group: %d\n", l->group);
- ast_cli(fd, "Codecs: ");
- ast_getformatname_multiple(codec_buf, sizeof(codec_buf) -1, l->capability);
- ast_cli(fd, "%s\n", codec_buf);
- ast_cli(fd, "Codec Order: (");
- print_codec_to_cli(fd, &l->prefs);
- ast_cli(fd, ")\n");
- ast_cli(fd, "\n");
+ ast_cli(a->fd, "Line: %s\n", l->name);
+ ast_cli(a->fd, "On Device: %s\n", d->name);
+ ast_cli(a->fd, "Line Label: %s\n", l->label);
+ ast_cli(a->fd, "Extension: %s\n", S_OR(l->exten, "<not set>"));
+ ast_cli(a->fd, "Context: %s\n", l->context);
+ ast_cli(a->fd, "CallGroup: %s\n", ast_print_group(group_buf, sizeof(group_buf), l->callgroup));
+ ast_cli(a->fd, "PickupGroup: %s\n", ast_print_group(group_buf, sizeof(group_buf), l->pickupgroup));
+ ast_cli(a->fd, "Language: %s\n", S_OR(l->language, "<not set>"));
+ ast_cli(a->fd, "Accountcode: %s\n", S_OR(l->accountcode, "<not set>"));
+ ast_cli(a->fd, "AmaFlag: %s\n", ast_cdr_flags2str(l->amaflags));
+ ast_cli(a->fd, "CallerId Number: %s\n", S_OR(l->cid_num, "<not set>"));
+ ast_cli(a->fd, "CallerId Name: %s\n", S_OR(l->cid_name, "<not set>"));
+ ast_cli(a->fd, "Hide CallerId: %s\n", (l->hidecallerid ? "Yes" : "No"));
+ ast_cli(a->fd, "CallForward: %s\n", S_OR(l->call_forward, "<not set>"));
+ ast_cli(a->fd, "VoicemailBox: %s\n", S_OR(l->mailbox, "<not set>"));
+ ast_cli(a->fd, "VoicemailNumber: %s\n", S_OR(l->vmexten, "<not set>"));
+ ast_cli(a->fd, "MWIblink: %d\n", l->mwiblink);
+ ast_cli(a->fd, "Regextension: %s\n", S_OR(l->regexten, "<not set>"));
+ ast_cli(a->fd, "Regcontext: %s\n", S_OR(l->regcontext, "<not set>"));
+ ast_cli(a->fd, "MoHInterpret: %s\n", S_OR(l->mohinterpret, "<not set>"));
+ ast_cli(a->fd, "MoHSuggest: %s\n", S_OR(l->mohsuggest, "<not set>"));
+ ast_cli(a->fd, "Last dialed nr: %s\n", S_OR(l->lastnumberdialed, "<no calls made yet>"));
+ ast_cli(a->fd, "Last CallerID: %s\n", S_OR(l->lastcallerid, "<not set>"));
+ ast_cli(a->fd, "Transfer enabled: %s\n", (l->transfer ? "Yes" : "No"));
+ ast_cli(a->fd, "Callwaiting: %s\n", (l->callwaiting ? "Yes" : "No"));
+ ast_cli(a->fd, "3Way Calling: %s\n", (l->threewaycalling ? "Yes" : "No"));
+ ast_cli(a->fd, "Can forward: %s\n", (l->cancallforward ? "Yes" : "No"));
+ ast_cli(a->fd, "Do Not Disturb: %s\n", (l->dnd ? "Yes" : "No"));
+ ast_cli(a->fd, "NAT: %s\n", (l->nat ? "Yes" : "No"));
+ ast_cli(a->fd, "immediate: %s\n", (l->immediate ? "Yes" : "No"));
+ ast_cli(a->fd, "Group: %d\n", l->group);
+ ast_cli(a->fd, "Codecs: ");
+ ast_getformatname_multiple(codec_buf, sizeof(codec_buf) - 1, l->capability);
+ ast_cli(a->fd, "%s\n", codec_buf);
+ ast_cli(a->fd, "Codec Order: (");
+ print_codec_to_cli(a->fd, &l->prefs);
+ ast_cli(a->fd, ")\n");
+ ast_cli(a->fd, "\n");
}
}
ast_mutex_unlock(&devicelock);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
/*! \brief List global settings for the Skinny subsystem. */
-static int skinny_show_settings(int fd, int argc, char *argv[])
+static char *handle_skinny_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- if (argc != 3)
- return RESULT_SHOWUSAGE;
-
- ast_cli(fd, "\nGlobal Settings:\n");
- ast_cli(fd, " Skinny Port: %d\n", ntohs(bindaddr.sin_port));
- ast_cli(fd, " Bindaddress: %s\n", ast_inet_ntoa(bindaddr.sin_addr));
- ast_cli(fd, " KeepAlive: %d\n", keep_alive);
- ast_cli(fd, " Date Format: %s\n", date_format);
- ast_cli(fd, " Voice Mail Extension: %s\n", S_OR(vmexten, "(not set)"));
- ast_cli(fd, " Reg. context: %s\n", S_OR(regcontext, "(not set)"));
- ast_cli(fd, " Jitterbuffer enabled: %s\n", (ast_test_flag(&global_jbconf, AST_JB_ENABLED) ? "Yes" : "No"));
- ast_cli(fd, " Jitterbuffer forced: %s\n", (ast_test_flag(&global_jbconf, AST_JB_FORCED) ? "Yes" : "No"));
- ast_cli(fd, " Jitterbuffer max size: %ld\n", global_jbconf.max_size);
- ast_cli(fd, " Jitterbuffer resync: %ld\n", global_jbconf.resync_threshold);
- ast_cli(fd, " Jitterbuffer impl: %s\n", global_jbconf.impl);
- ast_cli(fd, " Jitterbuffer log: %s\n", (ast_test_flag(&global_jbconf, AST_JB_LOG) ? "Yes" : "No"));
-
- return RESULT_SUCCESS;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "skinny show settings";
+ e->usage =
+ "Usage: skinny show settings\n"
+ " Lists all global configuration settings of the Skinny subsystem.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 3)
+ return CLI_SHOWUSAGE;
+
+ ast_cli(a->fd, "\nGlobal Settings:\n");
+ ast_cli(a->fd, " Skinny Port: %d\n", ntohs(bindaddr.sin_port));
+ ast_cli(a->fd, " Bindaddress: %s\n", ast_inet_ntoa(bindaddr.sin_addr));
+ ast_cli(a->fd, " KeepAlive: %d\n", keep_alive);
+ ast_cli(a->fd, " Date Format: %s\n", date_format);
+ ast_cli(a->fd, " Voice Mail Extension: %s\n", S_OR(vmexten, "(not set)"));
+ ast_cli(a->fd, " Reg. context: %s\n", S_OR(regcontext, "(not set)"));
+ ast_cli(a->fd, " Jitterbuffer enabled: %s\n", (ast_test_flag(&global_jbconf, AST_JB_ENABLED) ? "Yes" : "No"));
+ ast_cli(a->fd, " Jitterbuffer forced: %s\n", (ast_test_flag(&global_jbconf, AST_JB_FORCED) ? "Yes" : "No"));
+ ast_cli(a->fd, " Jitterbuffer max size: %ld\n", global_jbconf.max_size);
+ ast_cli(a->fd, " Jitterbuffer resync: %ld\n", global_jbconf.resync_threshold);
+ ast_cli(a->fd, " Jitterbuffer impl: %s\n", global_jbconf.impl);
+ ast_cli(a->fd, " Jitterbuffer log: %s\n", (ast_test_flag(&global_jbconf, AST_JB_LOG) ? "Yes" : "No"));
+
+ return CLI_SUCCESS;
}
-static const char show_devices_usage[] =
-"Usage: skinny show devices\n"
-" Lists all devices known to the Skinny subsystem.\n";
-
-static const char show_device_usage[] =
-"Usage: skinny show device <DeviceId|DeviceName>\n"
-" Lists all deviceinformation of a specific device known to the Skinny subsystem.\n";
-
-static const char show_lines_usage[] =
-"Usage: skinny show lines\n"
-" Lists all lines known to the Skinny subsystem.\n";
-
-static const char show_line_usage[] =
-"Usage: skinny show line <Line> [ on <DeviceID|DeviceName> ]\n"
-" List all lineinformation of a specific line known to the Skinny subsystem.\n";
-
-static const char show_settings_usage[] =
-"Usage: skinny show settings\n"
-" Lists all global configuration settings of the Skinny subsystem.\n";
-
-static const char debug_usage[] =
-"Usage: skinny set debug\n"
-" Enables dumping of Skinny packets for debugging purposes\n";
-
-static const char no_debug_usage[] =
-"Usage: skinny set debug off\n"
-" Disables dumping of Skinny packets for debugging purposes\n";
-
-static const char reset_usage[] =
-"Usage: skinny reset <DeviceId|DeviceName|all> [restart]\n"
-" Causes a Skinny device to reset itself, optionally with a full restart\n";
-
static struct ast_cli_entry cli_skinny[] = {
- { { "skinny", "show", "devices", NULL },
- skinny_show_devices, "List defined Skinny devices",
- show_devices_usage },
-
- { { "skinny", "show", "device", NULL },
- skinny_show_device, "List Skinny device information",
- show_device_usage, complete_skinny_show_device },
-
- { { "skinny", "show", "lines", NULL },
- skinny_show_lines, "List defined Skinny lines per device",
- show_lines_usage },
-
- { { "skinny", "show", "line", NULL },
- skinny_show_line, "List Skinny line information",
- show_line_usage, complete_skinny_show_lines },
-
- { { "skinny", "show", "settings", NULL },
- skinny_show_settings, "List global Skinny settings",
- show_settings_usage },
-
- { { "skinny", "set", "debug", NULL },
- skinny_do_debug, "Enable Skinny debugging",
- debug_usage },
-
- { { "skinny", "set", "debug", "off", NULL },
- skinny_no_debug, "Disable Skinny debugging",
- no_debug_usage },
-
- { { "skinny", "reset", NULL },
- skinny_reset_device, "Reset Skinny device(s)",
- reset_usage, complete_skinny_reset },
+ NEW_CLI(handle_skinny_show_devices, "List defined Skinny devices"),
+ NEW_CLI(handle_skinny_show_device, "List Skinny device information"),
+ NEW_CLI(handle_skinny_show_lines, "List defined Skinny lines per device"),
+ NEW_CLI(handle_skinny_show_line, "List Skinny line information"),
+ NEW_CLI(handle_skinny_show_settings, "List global Skinny settings"),
+ NEW_CLI(handle_skinny_set_debug, "Enable Skinny debugging"),
+ NEW_CLI(handle_skinny_set_debug_off, "Disable Skinny debugging"),
+ NEW_CLI(handle_skinny_reset, "Reset Skinny device(s)"),
};
#if 0
diff --git a/channels/iax2-provision.c b/channels/iax2-provision.c
index 031897fc7..782a4097e 100644
--- a/channels/iax2-provision.c
+++ b/channels/iax2-provision.c
@@ -166,15 +166,16 @@ char *iax_prov_complete_template(const char *line, const char *word, int pos, in
char *ret = NULL;
int wordlen = strlen(word);
- ast_mutex_lock(&provlock);
- for (c = templates; c; c = c->next) {
- if (!strncasecmp(word, c->name, wordlen) && ++which > state) {
- ret = ast_strdup(c->name);
- break;
+ if (pos == 3) {
+ ast_mutex_lock(&provlock);
+ for (c = templates; c; c = c->next) {
+ if (!strncasecmp(word, c->name, wordlen) && ++which > state) {
+ ret = ast_strdup(c->name);
+ break;
+ }
}
+ ast_mutex_unlock(&provlock);
}
- ast_mutex_unlock(&provlock);
-
return ret;
}
@@ -398,11 +399,6 @@ static int iax_process_template(struct ast_config *cfg, char *s, char *def)
return 0;
}
-static const char show_provisioning_usage[] =
-"Usage: iax list provisioning [template]\n"
-" Lists all known IAX provisioning templates or a\n"
-" specific one if specified.\n";
-
static const char *ifthere(const char *s)
{
if (strlen(s))
@@ -424,51 +420,62 @@ static const char *iax_server(unsigned int addr)
}
-static int iax_show_provisioning(int fd, int argc, char *argv[])
+static char *iax_show_provisioning(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct iax_template *cur;
char server[INET_ADDRSTRLEN];
char alternate[INET_ADDRSTRLEN];
char flags[80]; /* Has to be big enough for 'flags' too */
int found = 0;
- if ((argc != 3) && (argc != 4))
- return RESULT_SHOWUSAGE;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "iax2 show provisioning";
+ e->usage =
+ "Usage: iax2 show provisioning [template]\n"
+ " Lists all known IAX provisioning templates or a\n"
+ " specific one if specified.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return iax_prov_complete_template(a->line, a->word, a->pos, a->n);
+ }
+
+ if ((a->argc != 3) && (a->argc != 4))
+ return CLI_SHOWUSAGE;
ast_mutex_lock(&provlock);
for (cur = templates;cur;cur = cur->next) {
- if ((argc == 3) || (!strcasecmp(argv[3], cur->name))) {
+ if ((a->argc == 3) || (!strcasecmp(a->argv[3], cur->name))) {
if (found)
- ast_cli(fd, "\n");
+ ast_cli(a->fd, "\n");
ast_copy_string(server, iax_server(cur->server), sizeof(server));
ast_copy_string(alternate, iax_server(cur->altserver), sizeof(alternate));
- ast_cli(fd, "== %s ==\n", cur->name);
- ast_cli(fd, "Base Templ: %s\n", strlen(cur->src) ? cur->src : "<none>");
- ast_cli(fd, "Username: %s\n", ifthere(cur->user));
- ast_cli(fd, "Secret: %s\n", ifthere(cur->pass));
- ast_cli(fd, "Language: %s\n", ifthere(cur->lang));
- ast_cli(fd, "Bind Port: %d\n", cur->port);
- ast_cli(fd, "Server: %s\n", server);
- ast_cli(fd, "Server Port: %d\n", cur->serverport);
- ast_cli(fd, "Alternate: %s\n", alternate);
- ast_cli(fd, "Flags: %s\n", iax_provflags2str(flags, sizeof(flags), cur->flags));
- ast_cli(fd, "Format: %s\n", ast_getformatname(cur->format));
- ast_cli(fd, "TOS: 0x%x\n", cur->tos);
+ ast_cli(a->fd, "== %s ==\n", cur->name);
+ ast_cli(a->fd, "Base Templ: %s\n", strlen(cur->src) ? cur->src : "<none>");
+ ast_cli(a->fd, "Username: %s\n", ifthere(cur->user));
+ ast_cli(a->fd, "Secret: %s\n", ifthere(cur->pass));
+ ast_cli(a->fd, "Language: %s\n", ifthere(cur->lang));
+ ast_cli(a->fd, "Bind Port: %d\n", cur->port);
+ ast_cli(a->fd, "Server: %s\n", server);
+ ast_cli(a->fd, "Server Port: %d\n", cur->serverport);
+ ast_cli(a->fd, "Alternate: %s\n", alternate);
+ ast_cli(a->fd, "Flags: %s\n", iax_provflags2str(flags, sizeof(flags), cur->flags));
+ ast_cli(a->fd, "Format: %s\n", ast_getformatname(cur->format));
+ ast_cli(a->fd, "TOS: 0x%x\n", cur->tos);
found++;
}
}
ast_mutex_unlock(&provlock);
if (!found) {
- if (argc == 3)
- ast_cli(fd, "No provisioning templates found\n");
+ if (a->argc == 3)
+ ast_cli(a->fd, "No provisioning templates found\n");
else
- ast_cli(fd, "No provisioning template matching '%s' found\n", argv[3]);
+ ast_cli(a->fd, "No provisioning template matching '%s' found\n", a->argv[3]);
}
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
static struct ast_cli_entry cli_iax2_provision[] = {
- { { "iax2", "show", "provisioning", NULL },
- iax_show_provisioning, "Display iax provisioning",
- show_provisioning_usage, iax_prov_complete_template, },
+ NEW_CLI(iax_show_provisioning, "Display iax provisioning"),
};
static int iax_provision_init(void)