23 #ifndef _ASTERISK_PBX_H
24 #define _ASTERISK_PBX_H
35 #if defined(__cplusplus) || defined(c_plusplus)
39 #define AST_MAX_APP 32
41 #define AST_PBX_GOTO_FAILED -3
42 #define AST_PBX_KEEP 0
43 #define AST_PBX_REPLACE 1
47 #define AST_PBX_HANGUP -1
49 #define AST_PBX_ERROR 1
50 #define AST_PBX_INCOMPLETE 12
53 #define PRIORITY_HINT -1
125 const
char *
exten,
int priority, const
char *callerid, const
char *data);
131 const
char *description;
144 unsigned int minmask[48];
343 unsigned int no_hangup_chan:1;
382 int priority,
const char *label,
const char *callerid,
383 const char *application,
void *data,
void (*datad)(
void *),
const char *
registrar);
391 int priority,
const char *label,
const char *callerid,
392 const char *application,
void *data,
void (*datad)(
void *),
const char *
registrar);
489 struct ast_channel *c,
const char *context,
const char *exten);
507 struct ast_channel *c,
const char *context,
const char *exten);
526 int priority,
const char *callerid);
545 const char *exten,
const char *label,
const char *callerid);
559 const char *exten,
const char *label,
const char *callerid);
579 const char *exten,
int priority,
const char *callerid);
600 const char *exten,
int priority,
const char *callerid);
652 const char *exten,
int priority,
const char *callerid,
int *found,
int combined_find_spawn);
752 const char *data,
const char *
registrar);
755 const char *data,
const char *
registrar);
776 int priority,
const char *
registrar,
int already_locked);
926 int ast_pbx_outgoing_exten(
const char *
type,
format_t format,
void *data,
int timeout,
const char *context,
const char *exten,
int priority,
int *reason,
int sync,
const char *
cid_num,
const char *
cid_name,
struct ast_variable *vars,
const char *account,
struct ast_channel **locked_channel);
930 int ast_pbx_outgoing_app(
const char *
type,
format_t format,
void *data,
int timeout,
const char *
app,
const char *appdata,
int *reason,
int sync,
const char *
cid_num,
const char *
cid_name,
struct ast_variable *vars,
const char *account,
struct ast_channel **locked_channel);
1164 #define ast_custom_function_register(acf) __ast_custom_function_register(acf, ast_module_info->self)
1173 #define ast_custom_function_register_escalating(acf, escalation) __ast_custom_function_register_escalating(acf, escalation, ast_module_info->self)
1260 #define STATUS_NO_CONTEXT 1
1261 #define STATUS_NO_EXTENSION 2
1262 #define STATUS_NO_PRIORITY 3
1263 #define STATUS_NO_LABEL 4
1264 #define STATUS_SUCCESS 5
1265 #define AST_PBX_MAX_STACK 128
1278 struct ast_switch *swo;
1280 const char *foundcontext;
1285 const char *context,
const char *exten,
int priority,
1286 const char *label,
const char *callerid,
enum ext_match_t action);
1328 #if defined(__cplusplus) || defined(c_plusplus)
struct ast_include * ast_walk_context_includes(struct ast_context *con, struct ast_include *inc)
ast_include: include= support in extensions.conf
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
hashtable functions for contexts
int ast_unlock_context(struct ast_context *con)
enum sip_cc_notify_state state
Options for ast_pbx_run()
int( ast_switch_f)(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
All switch functions have the same interface, so define a type for them.
int ast_get_hint(char *hint, int hintsize, char *name, int namesize, struct ast_channel *c, const char *context, const char *exten)
If an extension hint exists, return non-zero.
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) ...
int ast_func_read(struct ast_channel *chan, const char *function, char *workspace, size_t len)
executes a read operation on a function
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
int ast_check_timing2(const struct ast_timing *i, const struct timeval tv)
Evaluate a pre-constructed bitmap as to whether a particular time falls within the range specified...
int ast_context_add_include2(struct ast_context *con, const char *include, const char *registrar)
Add a context include.
ast_device_state
Device States.
int ast_get_extension_priority(struct ast_exten *exten)
ast_extension_states
Extension states.
ast_exten: An extension The dialplan is saved as a linked list with each context having it's own link...
int ast_context_remove_include(const char *context, const char *include, const char *registrar)
Remove a context include.
int ast_context_remove_ignorepat(const char *context, const char *ignorepat, const char *registrar)
int ast_active_calls(void)
Retrieve the number of active calls.
void pbx_builtin_clear_globals(void)
const char * ast_get_extension_registrar(struct ast_exten *e)
struct ast_app * pbx_findapp(const char *app)
Look up an application.
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
int __ast_custom_function_register_escalating(struct ast_custom_function *acf, enum ast_custom_function_escalation escalation, struct ast_module *mod)
Register a custom function which requires escalated privileges.
static int exists(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
int ast_context_lockmacro(const char *macrocontext)
locks the macrolock in the given given context
int ast_extension_state_del(int id, ast_state_cb_type change_cb)
Deletes a registered state change callback by ID.
const ast_string_field syntax
int ast_func_read2(struct ast_channel *chan, const char *function, struct ast_str **str, ssize_t maxlen)
executes a read operation on a function
int(* ast_state_cb_type)(char *context, char *id, enum ast_extension_states state, void *data)
Typedef for devicestate and hint callbacks.
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
int ast_extension_cmp(const char *a, const char *b)
Determine if one extension should match before another.
const char * ast_get_extension_app(struct ast_exten *e)
int ast_add_extension2(struct ast_context *con, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add an extension to an extension context, this time with an ast_context *.
ast_custom_function_escalation
Description of the ways in which a function may escalate privileges.
char * ast_complete_applications(const char *line, const char *word, int state)
Command completion for the list of installed applications.
Generic (perhaps overly so) hashtable implementation Hash Table support in Asterisk.
Structure for variables, used for configurations and for channel variables.
int pbx_checkcondition(const char *condition)
Evaluate a condition.
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
const ast_string_field desc
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
void ast_unregister_switch(struct ast_switch *sw)
Unregister an alternative switch.
const ast_string_field arguments
void * ast_get_extension_app_data(struct ast_exten *e)
int ast_rdlock_contexts(void)
Read locks the context list.
static int matchmore(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
const char * ast_get_extension_label(struct ast_exten *e)
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
int ast_wrlock_contexts(void)
Write locks the context list.
int ast_context_remove_extension_callerid2(struct ast_context *con, const char *extension, int priority, const char *callerid, int matchcid, const char *registrar, int already_locked)
int ast_context_remove_include2(struct ast_context *con, const char *include, const char *registrar)
Removes an include by an ast_context structure.
void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, without removing any previously set value...
const char * ast_get_context_registrar(struct ast_context *c)
int ast_str_get_hint(struct ast_str **hint, ssize_t hintsize, struct ast_str **name, ssize_t namesize, struct ast_channel *c, const char *context, const char *exten)
If an extension hint exists, return non-zero.
int(* ast_acf_read2_fn_t)(struct ast_channel *, const char *, char *, struct ast_str **, ssize_t)
Typedef for a custom read2 function.
int ast_context_add_switch2(struct ast_context *con, const char *sw, const char *data, int eval, const char *registrar)
Adds a switch (first param is a ast_context)
AST_LIST_ENTRY(ast_custom_function) acflist
static char cid_num[AST_MAX_EXTENSION]
ast_doc_src
From where the documentation come from, this structure is useful for use it inside application/functi...
int ast_context_add_include(const char *context, const char *include, const char *registrar)
Add a context include.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
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.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
String fields in structures.
int ast_context_remove_switch(const char *context, const char *sw, const char *data, const char *registrar)
Remove a switch.
const char * ast_get_switch_name(struct ast_sw *sw)
const char * ast_get_include_name(struct ast_include *include)
const char * ast_get_include_registrar(struct ast_include *i)
ast_sw: Switch statement in extensions.conf
General Asterisk PBX channel definitions.
struct ast_exten * ast_walk_context_extensions(struct ast_context *con, struct ast_exten *priority)
int pbx_builtin_raise_exception(struct ast_channel *chan, const char *data)
int ast_context_add_ignorepat(const char *context, const char *ignorepat, const char *registrar)
Add an ignorepat.
Data structure associated with a custom dialplan function.
enum ast_pbx_result ast_pbx_run_args(struct ast_channel *c, struct ast_pbx_args *args)
Execute the PBX in the current thread.
int ast_parseable_goto(struct ast_channel *chan, const char *goto_string)
int pbx_set_extenpatternmatchnew(int newval)
Scheduler Routines (derived from cheops)
const char * ast_get_ignorepat_registrar(struct ast_ignorepat *ip)
#define AST_STRING_FIELD(name)
Declare a string field.
ast_ext_matchcid_types
extension matchcid types
const char * ast_extension_state2str(int extension_state)
Return string representation of the state of an extension.
const char * ast_get_switch_data(struct ast_sw *sw)
int ast_extension_state_add_destroy(const char *context, const char *exten, ast_state_cb_type change_cb, ast_state_cb_destroy_type destroy_cb, void *data)
Registers a state change callback with destructor.
void ast_str_substitute_variables_full(struct ast_str **buf, ssize_t maxlen, struct ast_channel *c, struct varshead *headp, const char *templ, size_t *used)
int(* ast_acf_read_fn_t)(struct ast_channel *, const char *, char *, char *, size_t)
Typedef for a custom read function.
struct ast_ignorepat * ast_walk_context_ignorepats(struct ast_context *con, struct ast_ignorepat *ip)
int pbx_set_autofallthrough(int newval)
const char * ast_get_extension_cidmatch(struct ast_exten *e)
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
int ast_context_add_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar)
struct ast_context * ast_walk_contexts(struct ast_context *con)
const char * ast_get_context_name(struct ast_context *con)
ast_pbx_result
The result codes when starting the PBX on a channel with ast_pbx_start.
#define AST_PBX_MAX_STACK
struct ast_custom_function * ast_custom_function_find(const char *name)
int ast_get_switch_eval(struct ast_sw *sw)
int ast_processed_calls(void)
Retrieve the total number of calls processed through the PBX since last restart.
int ast_pbx_outgoing_exten(const char *type, format_t format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
static int canmatch(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
void ast_str_substitute_variables_varshead(struct ast_str **buf, ssize_t maxlen, struct varshead *headp, const char *templ)
void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp)
Retrieve the value of a builtin variable or variable from the channel variable stack.
void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar)
Merge the temporary contexts into a global contexts list and delete from the global list the ones tha...
const char * ast_get_switch_registrar(struct ast_sw *sw)
int ast_check_timing(const struct ast_timing *i)
Evaluate a pre-constructed bitmap as to whether the current time falls within the range specified...
void(* ast_state_cb_destroy_type)(int id, void *data)
Typedef for devicestate and hint callback removal indication callback.
struct ast_exten * ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
ast_ignorepat: Ignore patterns in dial plan
int ast_unlock_contexts(void)
Unlocks contexts.
int ast_findlabel_extension(struct ast_channel *c, const char *context, const char *exten, const char *label, const char *callerid)
Find the priority of an extension that has the specified label.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_extension_patmatch(const char *pattern, const char *data)
int pbx_builtin_setvar_multiple(struct ast_channel *chan, const char *data)
Parse and set multiple channel variables, where the pairs are separated by the ',' character...
int ast_context_remove_extension_callerid(const char *context, const char *extension, int priority, const char *callerid, int matchcid, const char *registrar)
const char * ast_get_extension_name(struct ast_exten *exten)
int ast_wrlock_context(struct ast_context *con)
Write locks a given context.
int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
enum ast_extension_states ast_devstate_to_extenstate(enum ast_device_state devstate)
Map devstate to an extension state.
int ast_destroy_timing(struct ast_timing *i)
Deallocates memory structures associated with a timing bitmap.
static int matchcid(const char *cidpattern, const char *callerid)
const char * ast_get_ignorepat_name(struct ast_ignorepat *ip)
unsigned int ast_hashtab_hash_contexts(const void *obj)
void pbx_live_dangerously(int new_live_dangerously)
Enable/disable the execution of 'dangerous' functions from external protocols (AMI, etc.).
int ast_register_switch(struct ast_switch *sw)
Register an alternative dialplan switch.
int ast_extension_close(const char *pattern, const char *data, int needmore)
Asterisk XML Documentation API.
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
int pbx_builtin_setvar(struct ast_channel *chan, const char *data)
Parse and set a single channel variable, where the name and value are separated with an '=' character...
int ast_async_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
const ast_string_field synopsis
int ast_build_timing(struct ast_timing *i, const char *info)
Construct a timing bitmap, for use in time-based conditionals.
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)
static char cid_name[AST_MAX_EXTENSION]
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string)
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...
struct ast_sw * ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw)
static int exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
const char * ast_str_retrieve_variable(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, struct varshead *headp, const char *var)
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
int ast_extension_state(struct ast_channel *c, const char *context, const char *exten)
Uses hint and devicestate callback to get the state of an extension.
ast_app: A registered application
int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
void pbx_set_overrideswitch(const char *newval)
int ast_thread_inhibit_escalations(void)
Inhibit (in the current thread) the execution of dialplan functions which cause privilege escalations...
enum ast_pbx_result ast_pbx_run(struct ast_channel *c)
Execute the PBX in the current thread.
int ast_context_remove_extension2(struct ast_context *con, const char *extension, int priority, const char *registrar, int already_locked)
This functionc locks given context, search for the right extension and fires out all peer in this ext...
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
void ast_context_destroy(struct ast_context *con, const char *registrar)
Destroy a context (matches the specified context (or ANY context if NULL)
void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead *headp, const char *cp1, char *cp2, int cp2_size, size_t *used)
int ast_context_verify_includes(struct ast_context *con)
Verifies includes in an ast_contect structure.
struct ast_exten * pbx_find_extension(struct ast_channel *chan, struct ast_context *bypass, struct pbx_find_info *q, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action)
static char context[AST_MAX_CONTEXT]
int ast_pbx_outgoing_app(const char *type, format_t format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
int ast_extension_state_add(const char *context, const char *exten, ast_state_cb_type change_cb, void *data)
Registers a state change callback.
int ast_context_add_switch(const char *context, const char *sw, const char *data, int eval, const char *registrar)
Add a switch.
const ast_string_field seealso
int ast_get_extension_matchcid(struct ast_exten *e)
int(* ast_acf_write_fn_t)(struct ast_channel *, const char *, char *, const char *)
Typedef for a custom write function.
struct ast_module_info * info
int ast_findlabel_extension2(struct ast_channel *c, struct ast_context *con, const char *exten, const char *label, const char *callerid)
Find the priority of an extension that has the specified label.
int ast_context_remove_switch2(struct ast_context *con, const char *sw, const char *data, const char *registrar)
This function locks given context, removes switch, unlock context and return.
static snd_pcm_format_t format
Asterisk internal frame definitions.
int ast_func_write(struct ast_channel *chan, const char *function, const char *value)
executes a write operation on a function
ast_context: An extension context
int ast_context_remove_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar)
int ast_context_unlockmacro(const char *macrocontext)
Unlocks the macrolock in the given context.
struct ast_context * ast_context_find(const char *name)
Find a context.
int ast_async_goto_by_name(const char *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count)
struct ast_context * ast_get_extension_context(struct ast_exten *exten)
int ast_rdlock_context(struct ast_context *con)
Read locks a given context.
int pbx_builtin_serialize_variables(struct ast_channel *chan, struct ast_str **buf)
Create a human-readable string, specifying all variables and their corresponding values.