Wed Jan 8 2020 09:50:17

Asterisk developer's documentation


pbx_loopback.c File Reference

Loopback PBX Module. More...

#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/frame.h"
#include "asterisk/cli.h"
#include "asterisk/lock.h"
#include "asterisk/md5.h"
#include "asterisk/linkedlists.h"
#include "asterisk/chanvars.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
#include "asterisk/utils.h"
#include "asterisk/astdb.h"

Go to the source code of this file.

Macros

#define LOOPBACK_COMMON
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int load_module (void)
 
static int loopback_canmatch (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
 
static int loopback_exec (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
 
static int loopback_exists (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
 
static int loopback_matchmore (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
 
static void loopback_parse (char **newexten, char **newcontext, int *priority, char **newpattern, char *buf)
 
static char * loopback_subst (char *buf, int buflen, const char *exten, const char *context, int priority, 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 = "Loopback Switch" , .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 struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_switch loopback_switch
 

Detailed Description

Loopback PBX Module.

Definition in file pbx_loopback.c.

Macro Definition Documentation

#define LOOPBACK_COMMON

Function Documentation

static void __reg_module ( void  )
static

Definition at line 190 of file pbx_loopback.c.

static void __unreg_module ( void  )
static

Definition at line 190 of file pbx_loopback.c.

static int load_module ( void  )
static

Definition at line 183 of file pbx_loopback.c.

References AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, and ast_register_switch().

184 {
188 }
int ast_register_switch(struct ast_switch *sw)
Register an alternative dialplan switch.
Definition: pbx.c:6439
static struct ast_switch loopback_switch
Definition: pbx_loopback.c:167
static int loopback_canmatch ( struct ast_channel chan,
const char *  context,
const char *  exten,
int  priority,
const char *  callerid,
const char *  data 
)
static

Definition at line 141 of file pbx_loopback.c.

References ast_canmatch_extension(), ast_extension_match(), and LOOPBACK_COMMON.

142 {
144  res = ast_canmatch_extension(chan, newcontext, newexten, newpriority, callerid);
145  if (newpattern && !ast_extension_match(newpattern, exten))
146  res = 0;
147  return res;
148 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
Definition: pbx.c:5415
#define LOOPBACK_COMMON
Definition: pbx_loopback.c:75
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
Definition: pbx.c:2943
static int loopback_exec ( struct ast_channel chan,
const char *  context,
const char *  exten,
int  priority,
const char *  callerid,
const char *  data 
)
static

Definition at line 150 of file pbx_loopback.c.

References ast_spawn_extension(), and LOOPBACK_COMMON.

151 {
152  int found;
154  res = ast_spawn_extension(chan, newcontext, newexten, newpriority, callerid, &found, 0);
155  return res;
156 }
#define LOOPBACK_COMMON
Definition: pbx_loopback.c:75
int ast_spawn_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid, int *found, int combined_find_spawn)
Launch a new extension (i.e. new stack)
Definition: pbx.c:5425
static int loopback_exists ( struct ast_channel chan,
const char *  context,
const char *  exten,
int  priority,
const char *  callerid,
const char *  data 
)
static

Definition at line 132 of file pbx_loopback.c.

References ast_exists_extension(), ast_extension_match(), and LOOPBACK_COMMON.

133 {
135  res = ast_exists_extension(chan, newcontext, newexten, newpriority, callerid);
136  if (newpattern && !ast_extension_match(newpattern, exten))
137  res = 0;
138  return res;
139 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:5400
#define LOOPBACK_COMMON
Definition: pbx_loopback.c:75
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
Definition: pbx.c:2943
static int loopback_matchmore ( struct ast_channel chan,
const char *  context,
const char *  exten,
int  priority,
const char *  callerid,
const char *  data 
)
static

Definition at line 158 of file pbx_loopback.c.

References ast_extension_match(), ast_matchmore_extension(), and LOOPBACK_COMMON.

159 {
161  res = ast_matchmore_extension(chan, newcontext, newexten, newpriority, callerid);
162  if (newpattern && !ast_extension_match(newpattern, exten))
163  res = 0;
164  return res;
165 }
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks to see if adding anything to this extension might match something. (exists ^ canmatch) ...
Definition: pbx.c:5420
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
#define LOOPBACK_COMMON
Definition: pbx_loopback.c:75
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
Definition: pbx.c:2943
static void loopback_parse ( char **  newexten,
char **  newcontext,
int *  priority,
char **  newpattern,
char *  buf 
)
static

Definition at line 111 of file pbx_loopback.c.

References ast_strlen_zero().

112 {
113  char *con;
114  char *pri;
115  *newpattern = strchr(buf, '/');
116  if (*newpattern)
117  *(*newpattern)++ = '\0';
118  con = strchr(buf, '@');
119  if (con) {
120  *con++ = '\0';
121  pri = strchr(con, ':');
122  } else
123  pri = strchr(buf, ':');
124  if (!ast_strlen_zero(buf))
125  *newexten = buf;
126  if (!ast_strlen_zero(con))
127  *newcontext = con;
128  if (!ast_strlen_zero(pri))
129  sscanf(pri, "%30d", priority);
130 }
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static char* loopback_subst ( char *  buf,
int  buflen,
const char *  exten,
const char *  context,
int  priority,
const char *  data 
)
static

Definition at line 86 of file pbx_loopback.c.

References AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_INSERT_HEAD, AST_LIST_REMOVE_HEAD, ast_var_assign(), ast_var_delete(), and pbx_substitute_variables_varshead().

87 {
88  struct ast_var_t *newvariable;
89  struct varshead headp;
90  char tmp[80];
91 
92  snprintf(tmp, sizeof(tmp), "%d", priority);
94  if ((newvariable = ast_var_assign("EXTEN", exten))) {
95  AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
96  }
97  if ((newvariable = ast_var_assign("CONTEXT", context))) {
98  AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
99  }
100  if ((newvariable = ast_var_assign("PRIORITY", tmp))) {
101  AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
102  }
103  /* Substitute variables */
104  pbx_substitute_variables_varshead(&headp, data, buf, buflen);
105  /* free the list */
106  while ((newvariable = AST_LIST_REMOVE_HEAD(&headp, entries)))
107  ast_var_delete(newvariable);
108  return buf;
109 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
struct ast_var_t * ast_var_assign(const char *name, const char *value)
Definition: chanvars.c:41
void ast_var_delete(struct ast_var_t *var)
Definition: chanvars.c:63
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:818
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:696
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:666
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count)
Definition: pbx.c:4682
static int unload_module ( void  )
static

Definition at line 177 of file pbx_loopback.c.

References ast_unregister_switch().

178 {
180  return 0;
181 }
void ast_unregister_switch(struct ast_switch *sw)
Unregister an alternative switch.
Definition: pbx.c:6457
static struct ast_switch loopback_switch
Definition: pbx_loopback.c:167

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Loopback Switch" , .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 190 of file pbx_loopback.c.

Definition at line 190 of file pbx_loopback.c.

struct ast_switch loopback_switch
static

Definition at line 167 of file pbx_loopback.c.