mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
add 'show channeltype' CLI command (issue #6149, with small modifications)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@8422 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
81
channel.c
81
channel.c
@@ -193,13 +193,93 @@ static int show_channeltypes(int fd, int argc, char *argv[])
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int show_channeltype(int fd, int argc, char *argv[])
|
||||||
|
{
|
||||||
|
struct chanlist *cl = NULL;
|
||||||
|
|
||||||
|
if (argc != 3)
|
||||||
|
return RESULT_SHOWUSAGE;
|
||||||
|
|
||||||
|
if (ast_mutex_lock(&chlock)) {
|
||||||
|
ast_log(LOG_WARNING, "Unable to lock channel list\n");
|
||||||
|
return RESULT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
AST_LIST_TRAVERSE(&backends, cl, list) {
|
||||||
|
if (!strncasecmp(cl->tech->type, argv[2], strlen(cl->tech->type))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!cl) {
|
||||||
|
ast_cli(fd, "\n%s is not a registered channel driver.\n", argv[2]);
|
||||||
|
ast_mutex_unlock(&chlock);
|
||||||
|
return RESULT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ast_cli(fd,
|
||||||
|
"-- Info about channel driver: %s --\n"
|
||||||
|
" Device State: %s\n"
|
||||||
|
" Indication: %s\n"
|
||||||
|
" Transfer : %s\n"
|
||||||
|
" Capabilities: %d\n"
|
||||||
|
" Send Digit: %s\n"
|
||||||
|
" Send HTML : %s\n"
|
||||||
|
" Image Support: %s\n"
|
||||||
|
" Text Support: %s\n",
|
||||||
|
cl->tech->type,
|
||||||
|
(cl->tech->devicestate) ? "yes" : "no",
|
||||||
|
(cl->tech->indicate) ? "yes" : "no",
|
||||||
|
(cl->tech->transfer) ? "yes" : "no",
|
||||||
|
(cl->tech->capabilities) ? cl->tech->capabilities : -1,
|
||||||
|
(cl->tech->send_digit) ? "yes" : "no",
|
||||||
|
(cl->tech->send_html) ? "yes" : "no",
|
||||||
|
(cl->tech->send_image) ? "yes" : "no",
|
||||||
|
(cl->tech->send_text) ? "yes" : "no"
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
ast_mutex_unlock(&chlock);
|
||||||
|
return RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *complete_channeltypes(const char *line, const char *word, int pos, int state)
|
||||||
|
{
|
||||||
|
struct chanlist *cl;
|
||||||
|
int which = 0;
|
||||||
|
int wordlen;
|
||||||
|
char *ret = NULL;
|
||||||
|
|
||||||
|
if (pos != 2)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
wordlen = strlen(word);
|
||||||
|
|
||||||
|
AST_LIST_TRAVERSE(&backends, cl, list) {
|
||||||
|
if (!strncasecmp(word, cl->tech->type, wordlen) && ++which > state) {
|
||||||
|
ret = strdup(cl->tech->type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static char show_channeltypes_usage[] =
|
static char show_channeltypes_usage[] =
|
||||||
"Usage: show channeltypes\n"
|
"Usage: show channeltypes\n"
|
||||||
" Shows available channel types registered in your Asterisk server.\n";
|
" Shows available channel types registered in your Asterisk server.\n";
|
||||||
|
|
||||||
|
static char show_channeltype_usage[] =
|
||||||
|
"Usage: show channeltype <name>\n"
|
||||||
|
" Show details about the specified channel type, <name>.\n";
|
||||||
|
|
||||||
static struct ast_cli_entry cli_show_channeltypes =
|
static struct ast_cli_entry cli_show_channeltypes =
|
||||||
{ { "show", "channeltypes", NULL }, show_channeltypes, "Show available channel types", show_channeltypes_usage };
|
{ { "show", "channeltypes", NULL }, show_channeltypes, "Show available channel types", show_channeltypes_usage };
|
||||||
|
|
||||||
|
static struct ast_cli_entry cli_show_channeltype =
|
||||||
|
{ { "show", "channeltype", NULL }, show_channeltype, "Give more details on that channel type", show_channeltype_usage, complete_channeltypes };
|
||||||
|
|
||||||
/*! \brief Checks to see if a channel is needing hang up */
|
/*! \brief Checks to see if a channel is needing hang up */
|
||||||
int ast_check_hangup(struct ast_channel *chan)
|
int ast_check_hangup(struct ast_channel *chan)
|
||||||
{
|
{
|
||||||
@@ -3779,6 +3859,7 @@ void ast_moh_cleanup(struct ast_channel *chan)
|
|||||||
void ast_channels_init(void)
|
void ast_channels_init(void)
|
||||||
{
|
{
|
||||||
ast_cli_register(&cli_show_channeltypes);
|
ast_cli_register(&cli_show_channeltypes);
|
||||||
|
ast_cli_register(&cli_show_channeltype);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Print call group and pickup group ---*/
|
/*! \brief Print call group and pickup group ---*/
|
||||||
|
Reference in New Issue
Block a user