Wed Jan 8 2020 09:49:55

Asterisk developer's documentation


app_transfer.c File Reference

Transfer a caller. More...

#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/channel.h"

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int load_module (void)
 
static int transfer_exec (struct ast_channel *chan, const char *data)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Transfers a caller to another extension" , .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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
 
static const char *const app = "Transfer"
 
static struct ast_module_infoast_module_info = &__mod_info
 

Detailed Description

Transfer a caller.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

Requires transfer support from channel driver

Definition in file app_transfer.c.

Function Documentation

static void __reg_module ( void  )
static

Definition at line 146 of file app_transfer.c.

static void __unreg_module ( void  )
static

Definition at line 146 of file app_transfer.c.

static int load_module ( void  )
static

Definition at line 141 of file app_transfer.c.

References ast_register_application_xml, and transfer_exec().

142 {
144 }
static const char *const app
Definition: app_transfer.c:79
static int transfer_exec(struct ast_channel *chan, const char *data)
Definition: app_transfer.c:81
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
static int transfer_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 81 of file app_transfer.c.

References args, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_transfer(), len(), LOG_WARNING, parse(), pbx_builtin_setvar_helper(), status, ast_channel::tech, ast_channel_tech::transfer, and ast_channel_tech::type.

Referenced by load_module().

82 {
83  int res;
84  int len;
85  char *slash;
86  char *tech = NULL;
87  char *dest = NULL;
88  char *status;
89  char *parse;
91  AST_APP_ARG(dest);
92  );
93 
94  if (ast_strlen_zero((char *)data)) {
95  ast_log(LOG_WARNING, "Transfer requires an argument ([Tech/]destination)\n");
96  pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
97  return 0;
98  } else
99  parse = ast_strdupa(data);
100 
101  AST_STANDARD_APP_ARGS(args, parse);
102 
103  dest = args.dest;
104 
105  if ((slash = strchr(dest, '/')) && (len = (slash - dest))) {
106  tech = dest;
107  dest = slash + 1;
108  /* Allow execution only if the Tech/destination agrees with the type of the channel */
109  if (strncasecmp(chan->tech->type, tech, len)) {
110  pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
111  return 0;
112  }
113  }
114 
115  /* Check if the channel supports transfer before we try it */
116  if (!chan->tech->transfer) {
117  pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "UNSUPPORTED");
118  return 0;
119  }
120 
121  res = ast_transfer(chan, dest);
122 
123  if (res < 0) {
124  status = "FAILURE";
125  res = 0;
126  } else {
127  status = "SUCCESS";
128  res = 0;
129  }
130 
131  pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", status);
132 
133  return res;
134 }
const char *const type
Definition: channel.h:508
#define LOG_WARNING
Definition: logger.h:144
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static struct @350 args
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int(*const transfer)(struct ast_channel *chan, const char *newdest)
Blind transfer other side (see app_transfer.c and ast_transfer()
Definition: channel.h:588
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
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...
Definition: pbx.c:10546
int ast_transfer(struct ast_channel *chan, char *dest)
Transfer a channel (if supported).
Definition: channel.c:5788
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
union ast_frame::@172 data
struct ast_channel_tech * tech
Definition: channel.h:743
jack_status_t status
Definition: app_jack.c:143
static int unload_module ( void  )
static

Definition at line 136 of file app_transfer.c.

References ast_unregister_application().

137 {
139 }
static const char *const app
Definition: app_transfer.c:79
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Transfers a caller to another extension" , .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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static

Definition at line 146 of file app_transfer.c.

const char* const app = "Transfer"
static

Definition at line 79 of file app_transfer.c.

Definition at line 146 of file app_transfer.c.