Asterisk - The Open Source Telephony Project GIT-master-1f1c5bb
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 = AST_BUILDOPT_SUM, .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

Definition at line 73 of file pbx_loopback.c.

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.

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

References AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_register_switch(), and loopback_switch.

◆ 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.

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}
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:4190
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:4295
#define LOOPBACK_COMMON
Definition: pbx_loopback.c:73

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

◆ 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.

151{
152 int found;
154 res = ast_spawn_extension(chan, newcontext, newexten, newpriority, callerid, &found, 0);
155 return res;
156}
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:4200

References ast_spawn_extension(), and LOOPBACK_COMMON.

◆ 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.

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}
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:4175

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

◆ 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.

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:4195

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

◆ 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.

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}
static int priority
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65

References ast_strlen_zero(), buf, and priority.

◆ 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.

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 int tmp()
Definition: bt_open.c:389
#define ast_var_assign(name, value)
Definition: chanvars.h:40
void ast_var_delete(struct ast_var_t *var)
Definition: extconf.c:2471
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:681
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:711
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:833
void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count)

References AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_INSERT_HEAD, AST_LIST_REMOVE_HEAD, ast_var_assign, ast_var_delete(), buf, voicemailpwcheck::context, pbx_substitute_variables_varshead(), priority, and tmp().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 178 of file pbx_loopback.c.

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

References ast_unregister_switch(), and loopback_switch.

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 = AST_BUILDOPT_SUM, .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.

Referenced by load_module(), and unload_module().