19#ifndef _ASTERISK_MANAGER_H
20#define _ASTERISK_MANAGER_H
57#define AMI_VERSION "12.0.0"
58#define DEFAULT_MANAGER_PORT 5038
59#define DEFAULT_MANAGER_TLS_PORT 5039
66#define AMI_SUCCESS (0)
67#define AMI_DESTROY (-1)
75#define EVENT_FLAG_SYSTEM (1 << 0)
76#define EVENT_FLAG_CALL (1 << 1)
77#define EVENT_FLAG_LOG (1 << 2)
78#define EVENT_FLAG_VERBOSE (1 << 3)
79#define EVENT_FLAG_COMMAND (1 << 4)
80#define EVENT_FLAG_AGENT (1 << 5)
81#define EVENT_FLAG_USER (1 << 6)
82#define EVENT_FLAG_CONFIG (1 << 7)
83#define EVENT_FLAG_DTMF (1 << 8)
84#define EVENT_FLAG_REPORTING (1 << 9)
85#define EVENT_FLAG_CDR (1 << 10)
86#define EVENT_FLAG_DIALPLAN (1 << 11)
87#define EVENT_FLAG_ORIGINATE (1 << 12)
88#define EVENT_FLAG_AGI (1 << 13)
89#define EVENT_FLAG_HOOKRESPONSE (1 << 14)
90#define EVENT_FLAG_CC (1 << 15)
91#define EVENT_FLAG_AOC (1 << 16)
92#define EVENT_FLAG_TEST (1 << 17)
93#define EVENT_FLAG_SECURITY (1 << 18)
95#define EVENT_FLAG_MESSAGE (1 << 30)
100#define AST_MAX_MANHEADERS 128
188#define ast_manager_register(action, authority, func, synopsis) ast_manager_register2(action, authority, func, AST_MODULE_SELF, synopsis, NULL)
191#define ast_manager_register_xml(action, authority, func) ast_manager_register2(action, authority, func, AST_MODULE_SELF, NULL, NULL)
202#define ast_manager_register_xml_core(action, authority, func) ast_manager_register2(action, authority, func, NULL, NULL, NULL)
219 const char *description);
253#define manager_event(category, event, contents , ...) \
254 __ast_manager_event_multichan(category, event, 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__)
255#define ast_manager_event(chan, category, event, contents , ...) \
257 struct ast_channel *_chans[] = { chan, }; \
258 __ast_manager_event_multichan(category, event, 1, _chans, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__); \
260#define ast_manager_event_multichan(category, event, nchans, chans, contents , ...) \
261 __ast_manager_event_multichan(category, event, nchans, chans, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__);
275 const char *
contents, ...) __attribute__((format(printf, 8, 9)));
525__attribute__((format(printf, 3, 4)))
529 const
char *extra_fields_fmt,
533#define NO_EXTRA_FIELDS "%s", ""
Asterisk datastore objects.
int __ast_manager_event_multichan(int category, const char *event, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *contents,...)
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
int ast_manager_check_enabled(void)
Check if AMI is enabled.
int ast_webmanager_check_enabled(void)
Check if AMI/HTTP is enabled.
void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg)
Send response in manager transaction.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
void astman_send_error_va(struct mansession *s, const struct message *m, const char *fmt,...)
Send error in manager transaction (with va_args support)
void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj)
Publish an event to AMI.
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
struct stasis_message_router * ast_manager_get_message_router(void)
Get the stasis_message_router for AMI.
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
struct ast_variable * astman_get_variables(const struct message *m)
Get a linked list of the Variable: headers.
struct ast_str * ast_manager_str_from_json_object(struct ast_json *blob, key_exclusion_cb exclusion_cb)
Convert a JSON object into an AMI compatible string.
void ast_manager_unregister_hook(struct manager_custom_hook *hook)
Delete a custom hook to be called when an event is fired.
struct ast_variable * astman_get_variables_order(const struct message *m, enum variable_orders order)
Get a linked list of the Variable: headers with order specified.
void ast_manager_register_hook(struct manager_custom_hook *hook)
Add a custom hook to be called when an event is fired.
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
int ast_manager_register2(const char *action, int authority, int(*func)(struct mansession *s, const struct message *m), struct ast_module *module, const char *synopsis, const char *description)
Register a manager command with the manager interface.
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
void astman_append(struct mansession *s, const char *fmt,...)
void astman_live_dangerously(int new_live_dangerously)
Enable/disable the inclusion of 'dangerous' configurations outside of the ast_config_AST_CONFIG_DIR.
int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg)
Registered hooks can call this function to invoke actions and they will receive responses through reg...
int ast_manager_hangup_helper(struct mansession *s, const struct message *m, manager_hangup_handler_t handler, manager_hangup_cause_validator_t cause_validator)
A manager helper function that hangs up a channel using a supplied channel type specific hangup funct...
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
static char prefix[MAX_PREFIX]
Asterisk locking-related definitions:
int(* manager_hook_t)(int category, const char *event, char *body)
Manager Helper Function.
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
struct ast_str * ast_manager_build_channel_state_string(const struct ast_channel_snapshot *snapshot)
Generate the AMI message body from a channel snapshot.
int manager_mwi_init(void)
Initialize support for AMI MWI events.
int astman_verify_session_writepermissions(uint32_t ident, int perm)
Verify a session's write permissions against a permission mask.
int manager_bridging_init(void)
Initialize support for AMI channel events.
struct ast_datastore * astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a session.
int ast_str_append_event_header(struct ast_str **fields_string, const char *header, const char *value)
append an event header to an ast string
int astman_datastore_add(struct mansession *s, struct ast_datastore *datastore)
Add a datastore to a session.
struct ast_str * ast_manager_build_bridge_state_string_prefix(const struct ast_bridge_snapshot *snapshot, const char *prefix)
Generate the AMI message body from a bridge snapshot.
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
int astman_verify_session_readpermissions(uint32_t ident, int perm)
Verify a session's read permissions against a permission mask.
int manager_endpoints_init(void)
Initialize support for AMI endpoint events.
void(* manager_hangup_handler_t)(struct ast_channel *chan, int causecode)
Callback used by ast_manager_hangup_helper that will actually hangup a channel.
int(* key_exclusion_cb)(const char *key)
Callback used to determine whether a key should be skipped when converting a JSON object to a manager...
struct stasis_message_type * ast_manager_get_generic_type(void)
Get the stasis_message_type for generic messages.
#define AST_MAX_MANHEADERS
Export manager structures.
int manager_system_init(void)
Initialize support for AMI system events.
int manager_channels_init(void)
Initialize support for AMI channel events.
struct ast_str * ast_manager_build_bridge_state_string(const struct ast_bridge_snapshot *snapshot)
Generate the AMI message body from a bridge snapshot.
int astman_is_authed(uint32_t ident)
Determine if a manager session ident is authenticated.
struct ast_str * ast_manager_build_channel_state_string_prefix(const struct ast_channel_snapshot *snapshot, const char *prefix)
Generate the AMI message body from a channel snapshot.
int(* manager_hangup_cause_validator_t)(const char *channel_name, const char *cause)
Callback used by ast_manager_hangup_helper that will validate the cause code.
int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastore)
Remove a datastore from a session.
Wrapper for network related headers, masking differences between various operating systems....
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define AST_STRING_FIELD(name)
Declare a string field.
Structure that contains a snapshot of information about a bridge.
Structure representing a snapshot of channel state.
Main Channel structure associated with a channel.
Structure for a data store type.
Structure for a data store object.
Abstract JSON element (object, array, string, int, ...).
Struct containing info for an AMI event to send out.
const char * manager_event
Support for dynamic strings.
Structure for variables, used for configurations and for channel variables.
Struct that contains the XML documentation for a particular item. Note that this is an ao2 ref counte...
const ast_string_field description
struct ast_module * module
struct ast_xml_doc_item * final_response
const ast_string_field synopsis
int(* func)(struct mansession *s, const struct message *m)
const ast_string_field seealso
const ast_string_field syntax
unsigned int registered
TRUE if the AMI action is registered and the callback can be called.
const ast_string_field arguments
struct ast_xml_doc_item * list_responses
In case you didn't read that giant block of text above the mansession_session struct,...
const char * headers[AST_MAX_MANHEADERS]
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)
int error(const char *format,...)
Asterisk XML Documentation API.
ast_doc_src
From where the documentation come from, this structure is useful for use it inside application/functi...