Asterisk - The Open Source Telephony Project  18.5.0
Macros | Functions | Variables
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"
Include dependency graph for pbx_loopback.c:

Go to the source code of this file.

Macros

#define LOOPBACK_COMMON
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static const 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

◆ LOOPBACK_COMMON

#define LOOPBACK_COMMON

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 191 of file pbx_loopback.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 191 of file pbx_loopback.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 191 of file pbx_loopback.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 184 of file pbx_loopback.c.

References AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, and ast_register_switch().

185 {
189 }
int ast_register_switch(struct ast_switch *sw)
Register an alternative dialplan switch.
Definition: pbx_switch.c:58
Module could not be loaded properly.
Definition: module.h:102
static struct ast_switch loopback_switch
Definition: pbx_loopback.c:168

◆ loopback_canmatch()

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 140 of file pbx_loopback.c.

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

141 {
143  if (newpattern && !ast_extension_match(newpattern, exten))
144  res = 0;
145  else
146  res = ast_canmatch_extension(chan, newcontext, newexten, newpriority, callerid);
147  return res;
148 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
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:4194
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
Definition: extconf.c:4297
#define LOOPBACK_COMMON
Definition: pbx_loopback.c:73

◆ loopback_exec()

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:73
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:4204

◆ loopback_exists()

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 130 of file pbx_loopback.c.

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

131 {
133  if (newpattern && !ast_extension_match(newpattern, exten))
134  res = 0;
135  else
136  res = ast_exists_extension(chan, newcontext, newexten, newpriority, callerid);
137  return res;
138 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
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:4179
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
Definition: extconf.c:4297
#define LOOPBACK_COMMON
Definition: pbx_loopback.c:73

◆ loopback_matchmore()

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  if (newpattern && !ast_extension_match(newpattern, exten))
162  res = 0;
163  else
164  res = ast_matchmore_extension(chan, newcontext, newexten, newpriority, callerid);
165  return res;
166 }
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:4199
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
Definition: extconf.c:4297
#define LOOPBACK_COMMON
Definition: pbx_loopback.c:73

◆ loopback_parse()

static void loopback_parse ( char **  newexten,
char **  newcontext,
int *  priority,
char **  newpattern,
char *  buf 
)
static

Definition at line 109 of file pbx_loopback.c.

References ast_strlen_zero, and buf.

110 {
111  char *con;
112  char *pri;
113  *newpattern = strchr(buf, '/');
114  if (*newpattern)
115  *(*newpattern)++ = '\0';
116  con = strchr(buf, '@');
117  if (con) {
118  *con++ = '\0';
119  pri = strchr(con, ':');
120  } else
121  pri = strchr(buf, ':');
122  if (!ast_strlen_zero(buf))
123  *newexten = buf;
124  if (!ast_strlen_zero(con))
125  *newcontext = con;
126  if (!ast_strlen_zero(pri))
127  sscanf(pri, "%30d", priority);
128 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int priority
#define ast_strlen_zero(foo)
Definition: strings.h:52

◆ loopback_subst()

static char* loopback_subst ( char *  buf,
int  buflen,
const char *  exten,
const char *  context,
int  priority,
const char *  data 
)
static

Definition at line 84 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(), buf, pbx_substitute_variables_varshead(), and tmp().

85 {
86  struct ast_var_t *newvariable;
87  struct varshead headp;
88  char tmp[80];
89 
90  snprintf(tmp, sizeof(tmp), "%d", priority);
92  if ((newvariable = ast_var_assign("EXTEN", exten))) {
93  AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
94  }
95  if ((newvariable = ast_var_assign("CONTEXT", context))) {
96  AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
97  }
98  if ((newvariable = ast_var_assign("PRIORITY", tmp))) {
99  AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
100  }
101  /* Substitute variables */
102  pbx_substitute_variables_varshead(&headp, data, buf, buflen);
103  /* free the list */
104  while ((newvariable = AST_LIST_REMOVE_HEAD(&headp, entries)))
105  ast_var_delete(newvariable);
106  return buf;
107 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int tmp()
Definition: bt_open.c:389
static int priority
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:832
void ast_var_delete(struct ast_var_t *var)
Definition: extconf.c:2473
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:710
#define ast_var_assign(name, value)
Definition: chanvars.h:40
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:680
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count)

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 178 of file pbx_loopback.c.

References ast_unregister_switch().

179 {
181  return 0;
182 }
void ast_unregister_switch(struct ast_switch *sw)
Unregister an alternative switch.
Definition: pbx_switch.c:76
static struct ast_switch loopback_switch
Definition: pbx_loopback.c:168

Variable Documentation

◆ __mod_info

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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 191 of file pbx_loopback.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 191 of file pbx_loopback.c.

◆ loopback_switch

struct ast_switch loopback_switch
static

Definition at line 168 of file pbx_loopback.c.