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
106 enum ast_presence_state presence_state;
107 const char *presence_subtype;
108 const char *presence_message;
157 const
char *exten,
int priority, const
char *callerid, const
char *data);
176 unsigned int minmask[48];
373 AST_PBX_CALL_LIMIT = -2,
414 unsigned int no_hangup_chan:1;
514 int priority,
const char *label,
const char *callerid,
515 const char *application,
void *data,
void (*datad)(
void *),
const char *registrar);
541 int priority,
const char *label,
const char *callerid,
542 const char *application,
void *data,
void (*datad)(
void *),
const char *registrar,
543 const char *registrar_file,
int registrar_line);
553 int priority,
const char *label,
const char *callerid,
554 const char *application,
void *data,
void (*datad)(
void *),
const char *registrar,
555 const char *registrar_file,
int registrar_line);
738 int ast_get_hint(
char *hint,
int hintsize,
char *name,
int namesize,
739 struct ast_channel *c,
const char *context,
const char *exten);
757 struct ast_channel *c,
const char *context,
const char *exten);
776 int priority,
const char *callerid);
795 const char *exten,
const char *label,
const char *callerid);
809 const char *exten,
const char *label,
const char *callerid);
829 const char *exten,
int priority,
const char *callerid);
850 const char *exten,
int priority,
const char *callerid);
865 int ast_extension_close(
const char *pattern,
const char *data,
int needmore);
902 const char *exten,
int priority,
const char *callerid,
int *found,
int combined_find_spawn);
917 const char *registrar);
927 const char *registrar);
935 const char *registrar);
943 const char *registrar);
970 int eval,
const char *registrar);
980 int eval,
const char *registrar);
991 const char *data,
const char *registrar);
994 const char *data,
const char *registrar);
1012 const char *registrar);
1015 int priority,
const char *registrar,
int already_locked);
1017 int ast_context_remove_extension_callerid(
const char *context,
const char *extension,
1018 int priority,
const char *callerid,
int matchcid,
const char *registrar);
1020 int ast_context_remove_extension_callerid2(
struct ast_context *con,
const char *extension,
1021 int priority,
const char *callerid,
int matchcid,
const char *registrar,
1022 int already_locked);
1039 int ast_context_add_ignorepat2(
struct ast_context *con,
const char *ignorepat,
const char *registrar);
1055 int ast_context_remove_ignorepat2(
struct ast_context *con,
const char *ignorepat,
const char *registrar);
1181 int timeout,
const char *context,
const char *exten,
int priority,
int *reason,
1182 int synchronous,
const char *cid_num,
const char *cid_name,
struct ast_variable *vars,
1183 const char *account,
struct ast_channel **locked_channel,
int early_media,
1187 int timeout,
const char *context,
const char *exten,
int priority,
int *reason,
1188 int synchronous,
const char *cid_num,
const char *cid_name,
struct ast_variable *vars,
1189 const char *account,
struct ast_channel **locked_channel,
int early_media,
1225 int timeout,
const char *app,
const char *appdata,
int *reason,
int synchronous,
1226 const char *cid_num,
const char *cid_name,
struct ast_variable *vars,
1227 const char *account,
struct ast_channel **locked_channel,
1230 int ast_pbx_outgoing_app_predial(
const char *type,
struct ast_format_cap *cap,
const char *addr,
1231 int timeout,
const char *app,
const char *appdata,
int *reason,
int synchronous,
1232 const char *cid_num,
const char *cid_name,
struct ast_variable *vars,
1233 const char *account,
struct ast_channel **locked_channel,
1249 const char *ast_get_context_name(
struct ast_context *con);
1250 const char *ast_get_extension_name(
struct ast_exten *exten);
1252 const char *ast_get_include_name(
const struct ast_include *include);
1253 const char *ast_get_ignorepat_name(
const struct ast_ignorepat *ip);
1254 const char *ast_get_switch_name(
const struct ast_sw *sw);
1255 const char *ast_get_switch_data(
const struct ast_sw *sw);
1256 int ast_get_switch_eval(
const struct ast_sw *sw);
1262 int ast_get_extension_priority(
struct ast_exten *exten);
1263 int ast_get_extension_matchcid(
struct ast_exten *e);
1264 const char *ast_get_extension_cidmatch(
struct ast_exten *e);
1265 const char *ast_get_extension_app(
struct ast_exten *e);
1266 const char *ast_get_extension_label(
struct ast_exten *e);
1267 void *ast_get_extension_app_data(
struct ast_exten *e);
1283 const char *context,
const char *exten,
int priority);
1288 const char *ast_get_context_registrar(
struct ast_context *c);
1289 const char *ast_get_extension_registrar(
struct ast_exten *e);
1290 const char *ast_get_include_registrar(
const struct ast_include *i);
1291 const char *ast_get_ignorepat_registrar(
const struct ast_ignorepat *ip);
1292 const char *ast_get_switch_registrar(
const struct ast_sw *sw);
1324 const struct ast_sw *sw);
1329 int ast_context_includes_count(
const struct ast_context *con);
1331 int ast_context_ignorepats_count(
const struct ast_context *con);
1333 int ast_context_switches_count(
const struct ast_context *con);
1334 const struct ast_sw *ast_context_switches_get(
const struct ast_context *con,
int idx);
1386 void pbx_builtin_clear_globals(
void);
1400 int pbx_builtin_raise_exception(
struct ast_channel *chan,
const char *data);
1404 void pbx_substitute_variables_helper(
struct ast_channel *c,
const char *cp1,
char *cp2,
int count);
1405 void pbx_substitute_variables_varshead(
struct varshead *headp,
const char *cp1,
char *cp2,
int count);
1406 void pbx_substitute_variables_helper_full(
struct ast_channel *c,
struct varshead *headp,
const char *cp1,
char *cp2,
int cp2_size,
size_t *used);
1471 size_t *used,
int use_both);
1475 int ast_extension_patmatch(
const char *pattern,
const char *data);
1558 #define ast_custom_function_register(acf) __ast_custom_function_register(acf, AST_MODULE_SELF)
1567 #define ast_custom_function_register_escalating(acf, escalation) __ast_custom_function_register_escalating(acf, escalation, AST_MODULE_SELF)
1649 E_MATCH_MASK = 0x03,
1654 #define STATUS_NO_CONTEXT 1
1655 #define STATUS_NO_EXTENSION 2
1656 #define STATUS_NO_PRIORITY 3
1657 #define STATUS_NO_LABEL 4
1658 #define STATUS_SUCCESS 5
1661 #define AST_PBX_MAX_STACK 128
1663 #define AST_PBX_MAX_STACK 512
1669 const char *context;
1674 char *incstack[AST_PBX_MAX_STACK];
1679 const char *foundcontext;
1684 const char *context,
const char *exten,
int priority,
1685 const char *label,
const char *callerid,
enum ext_match_t action);
1690 unsigned int ast_hashtab_hash_contexts(
const void *obj);
1739 #if defined(__cplusplus) || defined(c_plusplus)
ast_include: include= support in extensions.conf
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.
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
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.
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_build_timing(struct ast_timing *i, const char *info_in)
Construct a timing bitmap, for use in time-based conditionals.
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.
int pbx_parse_location(struct ast_channel *chan, char **context, char **exten, char **pri, int *ipri, int *mode, char *rest)
Parses a dialplan location into context, extension, priority.
int ast_context_remove_ignorepat(const char *context, const char *ignorepat, const char *registrar)
Remove an ignorepat.
int ast_active_calls(void)
Retrieve the number of active calls.
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.
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_extension_state_del(int id, ast_state_cb_type change_cb)
Deletes a state change watcher 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
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.
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_get_extension_data(char *buf, int bufsize, struct ast_channel *c, const char *context, const char *exten, int priority)
Fill a string buffer with the data at a dialplan extension.
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)
const ast_string_field desc
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.
const ast_string_field arguments
int ast_rdlock_contexts(void)
Read locks the context list.
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_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...
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...
ast_doc_src
From where the documentation come from, this structure is useful for use it inside application/functi...
void pbx_substitute_variables_helper_full_location(struct ast_channel *c, struct varshead *headp, const char *cp1, char *cp2, int cp2_size, size_t *used, const char *context, const char *exten, int pri)
Substitutes variables, similar to pbx_substitute_variables_helper_full, but allows passing the contex...
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.
struct ast_context * ast_context_find(const char *name)
Find a context.
ast_sw: Switch statement in extensions.conf
General Asterisk PBX channel definitions.
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.
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)
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
ast_pbx_result
The result codes when starting the PBX on a channel with ast_pbx_start.
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.
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.
Presence state management.
int ast_pbx_exec_application(struct ast_channel *chan, const char *app_name, const char *app_args)
Execute an application.
int ast_processed_calls(void)
Retrieve the total number of calls processed through the PBX since last restart.
Support for dynamic strings.
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.
int ast_thread_inhibit_escalations_swap(int inhibit)
Swap the current thread escalation inhibit setting.
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...
const char * app_name(struct ast_app *app)
int ast_context_add_include2(struct ast_context *con, const char *value, const char *registrar)
Add a context include.
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...
#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.
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
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.
Asterisk XML Documentation API.
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_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)
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.
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.
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.
static int enabled
Whether or not we are storing history.
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
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.
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_verify_includes(struct ast_context *con)
Verifies includes in an ast_contect structure.
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.
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.
const ast_string_field seealso
struct ast_app * pbx_findapp(const char *app)
Look up an application.
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
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 ast_str_substitute_variables_full2(struct ast_str **buf, ssize_t maxlen, struct ast_channel *c, struct varshead *headp, const char *templ, size_t *used, int use_both)
Perform variable/function/expression substitution on an ast_str.
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.
const char * ast_get_extension_registrar_file(struct ast_exten *e)
Get name of configuration file used by registrar to register this extension.