53 static char *
orig_app(
int fd,
const char *chan,
const char *app,
const char *appdata)
60 if (ast_strlen_zero(app))
65 chantech = strsep(&chandata,
"/");
67 ast_cli(fd,
"*** No data provided after channel type! ***\n");
91 static char *
orig_exten(
int fd,
const char *chan,
const char *data)
102 chantech = strsep(&chandata,
"/");
104 ast_cli(fd,
"*** No data provided after channel type! ***\n");
105 return CLI_SHOWUSAGE;
108 if (!ast_strlen_zero(data)) {
110 exten = strsep(&context,
"@");
113 if (ast_strlen_zero(exten))
115 if (ast_strlen_zero(context))
123 NULL, NULL, NULL, 0, NULL);
138 static const char *
const choices[] = {
"application",
"extension", NULL };
142 e->
command =
"channel originate";
144 " There are two ways to use this command. A call can be originated between a\n"
145 "channel and a specific application, or between a channel and an extension in\n"
146 "the dialplan. This is similar to call files or the manager originate action.\n"
147 "Calls originated with this command are given a timeout of 30 seconds.\n\n"
149 "Usage1: channel originate <tech/data> application <appname> [appdata]\n"
150 " This will originate a call between the specified channel tech/data and the\n"
151 "given application. Arguments to the application are optional. If the given\n"
152 "arguments to the application include spaces, all of the arguments to the\n"
153 "application need to be placed in quotation marks.\n\n"
155 "Usage2: channel originate <tech/data> extension [exten@][context]\n"
156 " This will originate a call between the specified channel tech/data and the\n"
157 "given extension. If no context is specified, the 'default' context will be\n"
158 "used. If no extension is given, the 's' extension will be used.\n";
163 }
else if (a->pos == 4) {
164 if (!strcasecmp(
"application", a->argv[3])) {
171 if (ast_strlen_zero(a->argv[2]) || ast_strlen_zero(a->argv[3]))
172 return CLI_SHOWUSAGE;
174 if (!strcasecmp(
"application", a->argv[3])) {
175 res =
orig_app(a->fd, a->argv[2], a->argv[4], a->argv[5]);
176 }
else if (!strcasecmp(
"extension", a->argv[3])) {
177 res =
orig_exten(a->fd, a->argv[2], a->argv[4]);
187 const char *name, *dest;
193 e->
command =
"channel redirect";
195 "Usage: channel redirect <channel> <[[context,]exten,]priority>\n"
196 " Redirect an active channel to a specified extension.\n";
207 if (a->argc != e->
args + 2) {
208 return CLI_SHOWUSAGE;
215 ast_cli(a->fd,
"Channel '%s' not found\n", name);
224 ast_cli(a->fd,
"Channel '%s' successfully redirected to %s\n", name, dest);
226 ast_cli(a->fd,
"Channel '%s' failed to be redirected to %s\n", name, dest);
229 return res ? CLI_FAILURE : CLI_SUCCESS;
237 static int unload_module(
void)
242 static int load_module(
void)
249 AST_MODULE_INFO_STANDARD(
ASTERISK_GPL_KEY,
"Call origination and redirection from the CLI");
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define ast_channel_unref(c)
Decrease channel reference count.
descriptor for a cli entry.
char * ast_complete_applications(const char *line, const char *word, int state)
Command completion for the list of installed applications.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static char * orig_app(int fd, const char *chan, const char *app, const char *appdata)
orginate a call from the CLI
int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, int early_media, const struct ast_assigned_ids *assignedids)
Synchronously or asynchronously make an outbound call and send it to a particular extension...
int args
This gets set in ast_cli_register()
char * ast_cli_complete(const char *word, const char *const choices[], int pos)
General Asterisk PBX channel definitions.
static char * handle_orig(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
handle for orgination app or exten.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Asterisk internal frame definitions.
static char * orig_exten(int fd, const char *chan, const char *data)
orginate from extension
Core PBX routines and definitions.
int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, const struct ast_assigned_ids *assignedids)
Synchronously or asynchronously make an outbound call and execute an application on the channel...
Module has failed to load, may be in an inconsistent state.
int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string)
Standard Command Line Interface.
static char * handle_redirect(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
char * ast_complete_channels(const char *line, const char *word, int pos, int state, int rpos)
Command completion for the list of active channels.
#define ASTERISK_GPL_KEY
The text the key() function should return.
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
Asterisk module definitions.