Asterisk - The Open Source Telephony Project GIT-master-c753fe4
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
Macros | Functions | Variables
app_stasis.c File Reference

Stasis dialplan application. More...

#include "asterisk.h"
#include "asterisk/app.h"
#include "asterisk/ari.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_app_impl.h"
Include dependency graph for app_stasis.c:

Go to the source code of this file.

Macros

#define MAX_ARGS   128
 Maximum number of arguments for the Stasis dialplan application. More...
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int app_exec (struct ast_channel *chan, const char *data)
 Stasis dialplan application callback. More...
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int load_module (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Stasis dialplan application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_stasis,res_ari", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static const char * stasis = "Stasis"
 Dialplan application name. More...
 

Detailed Description

Stasis dialplan application.

Author
David M. Lee, II dlee@.nosp@m.digi.nosp@m.um.co.nosp@m.m

Definition in file app_stasis.c.

Macro Definition Documentation

◆ MAX_ARGS

#define MAX_ARGS   128

Maximum number of arguments for the Stasis dialplan application.

Definition at line 82 of file app_stasis.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 169 of file app_stasis.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 169 of file app_stasis.c.

◆ app_exec()

static int app_exec ( struct ast_channel chan,
const char *  data 
)
static

Stasis dialplan application callback.

Definition at line 88 of file app_stasis.c.

89{
90 char *parse = NULL;
91 char *connection_id;
92 int ret = -1;
93
96 AST_APP_ARG(app_argv)[MAX_ARGS];
97 );
98
99 ast_assert(chan != NULL);
100 ast_assert(data != NULL);
101
102 pbx_builtin_setvar_helper(chan, "STASISSTATUS", "");
103
104 /* parse the arguments */
105 parse = ast_strdupa(data);
107
108 if (args.argc < 1) {
109 ast_log(LOG_WARNING, "Stasis app_name argument missing\n");
110 goto done;
111 }
112
113 if (stasis_app_is_registered(args.app_name)) {
114 ast_debug(3, "%s: App '%s' is already registered\n",
115 ast_channel_name(chan), args.app_name);
116 ret = stasis_app_exec(chan, args.app_name, args.argc - 1, args.app_argv);
117 goto done;
118 }
119 ast_debug(3, "%s: App '%s' is NOT already registered\n",
120 ast_channel_name(chan), args.app_name);
121
122 /*
123 * The app isn't registered so we need to see if we have a
124 * per-call outbound websocket config we can use.
125 * connection_id will be freed by ast_ari_close_per_call_websocket().
126 */
127 connection_id = ast_ari_create_per_call_websocket(args.app_name, chan);
128 if (ast_strlen_zero(connection_id)) {
130 "%s: Stasis app '%s' doesn't exist\n",
131 ast_channel_name(chan), args.app_name);
132 goto done;
133 }
134
135 ret = stasis_app_exec(chan, connection_id, args.argc - 1, args.app_argv);
137
138done:
139 if (ret) {
140 /* set ret to 0 so pbx_core doesnt hangup the channel */
141 if (!ast_check_hangup(chan)) {
142 ret = 0;
143 } else {
144 ret = -1;
145 }
146 pbx_builtin_setvar_helper(chan, "STASISSTATUS", "FAILED");
147 } else {
148 pbx_builtin_setvar_helper(chan, "STASISSTATUS", "SUCCESS");
149 }
150
151 return ret;
152}
#define MAX_ARGS
Maximum number of arguments for the Stasis dialplan application.
Definition: app_stasis.c:82
char * ast_ari_create_per_call_websocket(const char *app_name, struct ast_channel *channel)
Create a per-call outbound websocket connection.
void ast_ari_close_per_call_websocket(char *app_id)
Close a per-call outbound websocket connection.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_log
Definition: astobj2.c:42
const char * ast_channel_name(const struct ast_channel *chan)
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:444
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_WARNING
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
const char * app_name(struct ast_app *app)
Definition: pbx_app.c:463
#define NULL
Definition: resample.c:96
int stasis_app_is_registered(const char *name)
Check if a Stasis application is registered.
Definition: res_stasis.c:1747
int stasis_app_exec(struct ast_channel *chan, const char *app_name, int argc, char *argv[])
Control a channel using stasis_app.
Definition: res_stasis.c:1369
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
int done
Definition: test_amihooks.c:48
const char * args
#define ast_assert(a)
Definition: utils.h:739

References app_name(), args, AST_APP_ARG, ast_ari_close_per_call_websocket(), ast_ari_create_per_call_websocket(), ast_assert, ast_channel_name(), ast_check_hangup(), ast_debug, AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), done, LOG_WARNING, MAX_ARGS, NULL, pbx_builtin_setvar_helper(), stasis_app_exec(), and stasis_app_is_registered().

Referenced by load_module().

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 169 of file app_stasis.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 154 of file app_stasis.c.

155{
157}
static const char * stasis
Dialplan application name.
Definition: app_stasis.c:85
static int app_exec(struct ast_channel *chan, const char *data)
Stasis dialplan application callback.
Definition: app_stasis.c:88
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:640

References app_exec(), ast_register_application_xml, and stasis.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 159 of file app_stasis.c.

160{
162}
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

References ast_unregister_application(), and stasis.

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Stasis dialplan application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_stasis,res_ari", }
static

Definition at line 169 of file app_stasis.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 169 of file app_stasis.c.

◆ stasis

const char* stasis = "Stasis"
static

Dialplan application name.

Definition at line 85 of file app_stasis.c.

Referenced by ast_bridge_publish_blind_transfer(), load_module(), and unload_module().