23 #ifndef _ASTERISK_PBX_H 24 #define _ASTERISK_PBX_H 36 #if defined(__cplusplus) || defined(c_plusplus) 40 #define AST_MAX_APP 32 42 #define AST_PBX_GOTO_FAILED -3 43 #define AST_PBX_KEEP 0 44 #define AST_PBX_REPLACE 1 48 #define AST_PBX_HANGUP -1 50 #define AST_PBX_ERROR 1 51 #define AST_PBX_INCOMPLETE 12 54 #define PRIORITY_HINT -1 176 unsigned int minmask[48];
506 int priority,
const char *label,
const char *callerid,
507 const char *application,
void *data,
void (*datad)(
void *),
const char *
registrar);
518 int priority,
const char *label,
const char *callerid,
519 const char *application,
void *data,
void (*datad)(
void *),
const char *
registrar,
520 const char *registrar_file,
int registrar_line);
530 int priority,
const char *label,
const char *callerid,
531 const char *application,
void *data,
void (*datad)(
void *),
const char *
registrar,
532 const char *registrar_file,
int registrar_line);
715 int ast_get_hint(
char *hint,
int hintsize,
char *name,
int namesize,
716 struct ast_channel *
c,
const char *context,
const char *exten);
734 struct ast_channel *
c,
const char *context,
const char *exten);
753 int priority,
const char *callerid);
772 const char *exten,
const char *label,
const char *callerid);
786 const char *exten,
const char *label,
const char *callerid);
806 const char *exten,
int priority,
const char *callerid);
827 const char *exten,
int priority,
const char *callerid);
879 const char *exten,
int priority,
const char *callerid,
int *found,
int combined_find_spawn);
979 const char *data,
const char *
registrar);
982 const char *data,
const char *
registrar);
1003 int priority,
const char *
registrar,
int already_locked);
1010 int already_locked);
1193 int timeout,
const char *context,
const char *exten,
int priority,
int *reason,
1195 const char *account,
struct ast_channel **locked_channel,
int early_media,
1199 int timeout,
const char *context,
const char *exten,
int priority,
int *reason,
1201 const char *account,
struct ast_channel **locked_channel,
int early_media,
1237 int timeout,
const char *
app,
const char *appdata,
int *reason,
int synchronous,
1239 const char *account,
struct ast_channel **locked_channel,
1243 int timeout,
const char *
app,
const char *appdata,
int *reason,
int synchronous,
1245 const char *account,
struct ast_channel **locked_channel,
1320 const struct ast_sw *sw);
1508 #define ast_custom_function_register(acf) __ast_custom_function_register(acf, AST_MODULE_SELF) 1517 #define ast_custom_function_register_escalating(acf, escalation) __ast_custom_function_register_escalating(acf, escalation, AST_MODULE_SELF) 1604 #define STATUS_NO_CONTEXT 1 1605 #define STATUS_NO_EXTENSION 2 1606 #define STATUS_NO_PRIORITY 3 1607 #define STATUS_NO_LABEL 4 1608 #define STATUS_SUCCESS 5 1611 #define AST_PBX_MAX_STACK 128 1613 #define AST_PBX_MAX_STACK 512 1629 const char *foundcontext;
1634 const char *context,
const char *exten,
int priority,
1635 const char *label,
const char *callerid,
enum ext_match_t action);
1689 #if defined(__cplusplus) || defined(c_plusplus)
ast_include: include= support in extensions.conf
static const char synopsis[]
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)
Options for ast_pbx_run()
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.
void ast_pbx_h_exten_run(struct ast_channel *chan, const char *context)
Run the h exten from the given context.
const char * ast_get_switch_name(const struct ast_sw *sw)
const char * ast_get_switch_registrar(const struct ast_sw *sw)
int ast_extension_state_add_destroy_extended(const char *context, const char *exten, ast_state_cb_type change_cb, ast_state_cb_destroy_type destroy_cb, void *data)
Add watcher for extended extension states with destructor.
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...
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_extension_state_add_extended(const char *context, const char *exten, ast_state_cb_type change_cb, void *data)
Add watcher for extended extension states.
int ast_context_remove_include(const char *context, const char *include, const char *registrar)
Remove a context include.
const char * presence_message
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.
const struct ast_sw * ast_walk_context_switches(const struct ast_context *con, const struct ast_sw *sw)
void pbx_builtin_clear_globals(void)
const char * ast_get_extension_registrar(struct ast_exten *e)
const char * ast_get_context_name(struct ast_context *con)
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
const char * ast_get_ignorepat_registrar(const struct ast_ignorepat *ip)
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.
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_lockmacro(const char *macrocontext)
locks the macrolock in the given context
int ast_extension_state_del(int id, ast_state_cb_type change_cb)
Deletes a state change watcher by ID.
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
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.
void ast_pbx_hangup_handler_init(struct ast_channel *chan)
Init the hangup handler container on a channel.
int ast_context_switches_count(const struct ast_context *con)
const char * ast_get_extension_app(struct ast_exten *e)
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 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)
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)
struct ast_context * ast_walk_contexts(struct ast_context *con)
Structure to pass both assignedid values to channel drivers.
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
int ast_pbx_outgoing_exten_predial(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, int early_media, const struct ast_assigned_ids *assignedids, const char *predial_callee)
void ast_unregister_switch(struct ast_switch *sw)
Unregister an alternative switch.
void * ast_get_extension_app_data(struct ast_exten *e)
int ast_rdlock_contexts(void)
Read locks the context list.
const char * ast_get_extension_label(struct ast_exten *e)
const char * ast_get_include_registrar(const struct ast_include *i)
int ast_pbx_hangup_handler_pop(struct ast_channel *chan)
Pop the top of the channel hangup handler stack.
#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)
unsigned int write_escalates
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_hint_presence_state(struct ast_channel *c, const char *context, const char *exten, char **subtype, char **message)
Uses hint and presence state callback to get the presence state of an extension.
int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, int early_media, const struct ast_assigned_ids *assignedids)
Synchronously or asynchronously make an outbound call and send it to a particular extension...
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.
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
int ast_context_remove_switch(const char *context, const char *sw, const char *data, const char *registrar)
Remove a switch.
int ast_get_switch_eval(const struct ast_sw *sw)
const struct ast_include * ast_walk_context_includes(const struct ast_context *con, const struct ast_include *inc)
int ast_context_add_include2(struct ast_context *con, const char *include, const char *registrar)
Add a context include.
const struct ast_sw * ast_context_switches_get(const struct ast_context *con, int idx)
struct ast_channel * causing_channel
struct ast_context * ast_context_find(const char *name)
Find a context.
ast_sw: Switch statement in extensions.conf
General Asterisk PBX channel definitions.
int pbx_builtin_raise_exception(struct ast_channel *chan, const char *data)
ast_state_cb_update_reason
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.
int(* ast_acf_write_fn_t)(struct ast_channel *chan, const char *function, char *data, const char *value)
Typedef for a custom write 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.
void(* ast_state_cb_destroy_type)(int id, void *data)
Typedef for devicestate and hint callback removal indication callback.
int ast_parseable_goto(struct ast_channel *chan, const char *goto_string)
int pbx_set_extenpatternmatchnew(int newval)
unsigned int read_escalates
Scheduler Routines (derived from cheops)
#define AST_STRING_FIELD(name)
Declare a string field.
structure to hold extensions
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 * presence_subtype
enum ast_device_state device_state
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)
Add watcher for extension states 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 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_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.
ast_pbx_result
The result codes when starting the PBX on a channel with ast_pbx_start.
#define AST_PBX_MAX_STACK
int ast_extension_state_extended(struct ast_channel *c, const char *context, const char *exten, struct ao2_container **device_state_info)
Uses hint and devicestate callback to get the extended state of an extension.
const char * ast_get_ignorepat_name(const struct ast_ignorepat *ip)
struct ao2_container * device_state_info
int ast_context_includes_count(const struct ast_context *con)
Presence state management.
struct ast_custom_function * ast_custom_function_find(const char *name)
int ast_processed_calls(void)
Retrieve the total number of calls processed through the PBX since last restart.
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...
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...
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_thread_inhibit_escalations_swap(int inhibit)
Swap the current thread escalation inhibit setting.
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)
int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, const struct ast_assigned_ids *assignedids)
Synchronously or asynchronously make an outbound call and execute an application on the channel...
struct ast_exten * ast_walk_context_extensions(struct ast_context *con, struct ast_exten *priority)
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
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)
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
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.
void ast_pbx_hangup_handler_push(struct ast_channel *chan, const char *handler)
Push the given hangup handler onto the channel hangup handler stack.
int ast_extension_close(const char *pattern, const char *data, int needmore)
Asterisk XML Documentation API.
const char * ast_get_switch_data(const struct ast_sw *sw)
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)
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]
const struct ast_ignorepat * ast_walk_context_ignorepats(const struct ast_context *con, const struct ast_ignorepat *ip)
int(* ast_acf_read2_fn_t)(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **str, ssize_t len)
Typedef for a custom read2 function.
int ast_pbx_hangup_handler_run(struct ast_channel *chan)
Run all hangup handlers on the channel.
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...
int(* ast_acf_read_fn_t)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
Typedef for a custom read function.
const char * ast_get_include_name(const struct ast_include *include)
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, const char *registrar_file, int registrar_line)
Add an extension to an extension context, this time with an ast_context *.
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.
struct ast_exten * ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
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
static void handler(const char *name, int response_code, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
void ast_pbx_hangup_handler_destroy(struct ast_channel *chan)
Destroy the hangup handler container on a channel.
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_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
int ast_get_extension_registrar_line(struct ast_exten *e)
Get line number of configuration file used by registrar to register this extension.
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)
int ast_context_ignorepats_count(const struct ast_context *con)
int ast_pbx_outgoing_app_predial(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, const struct ast_assigned_ids *assignedids, const char *predial_callee)
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.
int ast_context_add_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar)
int(* ast_state_cb_type)(const char *context, const char *exten, struct ast_state_cb_info *info, void *data)
Typedef for devicestate and hint callbacks.
static char context[AST_MAX_CONTEXT]
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)
Add watcher for extension states.
void ast_context_set_autohints(struct ast_context *con, int enabled)
Enable or disable autohints support on a context.
int ast_context_add_switch(const char *context, const char *sw, const char *data, int eval, const char *registrar)
Add a switch.
struct ast_app * pbx_findapp(const char *app)
Look up an application.
int ast_get_extension_matchcid(struct ast_exten *e)
unsigned int no_hangup_chan
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)
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.
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 - must remain in sync with fake_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.
const struct ast_include * ast_context_includes_get(const struct ast_context *con, int idx)
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.
int ast_add_extension2_nolock(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, const char *registrar_file, int registrar_line)
Same as ast_add_extension2, but assumes you have already locked context.
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.
const struct ast_ignorepat * ast_context_ignorepats_get(const struct ast_context *con, int idx)
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.
const char * ast_get_extension_registrar_file(struct ast_exten *e)
Get name of configuration file used by registrar to register this extension.