19 #ifndef _ASTERISK_MANAGER_H
20 #define _ASTERISK_MANAGER_H
57 #define AMI_VERSION "10.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
150 unsigned int hdrcount;
183 unsigned int registered:1;
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)
218 const char *synopsis,
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)));
287 enum variable_orders {
428 const struct ast_channel_snapshot *snapshot,
442 const struct ast_channel_snapshot *snapshot);
485 const struct ast_bridge_snapshot *snapshot,
499 const struct ast_bridge_snapshot *snapshot);
524 struct ast_manager_event_blob *
525 __attribute__((format(printf, 3, 4)))
528 const
char *manager_event,
529 const
char *extra_fields_fmt,
533 #define NO_EXTRA_FIELDS "%s", ""
struct ast_datastore * astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a session.
Struct containing info for an AMI event to send out.
Main Channel structure associated with a channel.
void astman_live_dangerously(int new_live_dangerously)
Enable/disable the inclusion of 'dangerous' configurations outside of the ast_config_AST_CONFIG_DIR.
Asterisk locking-related definitions:
#define AST_MAX_MANHEADERS
Export manager structures.
void astman_append(struct mansession *s, const char *fmt,...)
int(* manager_hook_t)(int category, const char *event, char *body)
Manager Helper Function.
void ast_manager_unregister_hook(struct manager_custom_hook *hook)
Delete a custom hook to be called when an event is fired.
int astman_verify_session_readpermissions(uint32_t ident, int perm)
Verify a session's read permissions against a permission mask.
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...
void ast_manager_register_hook(struct manager_custom_hook *hook)
Add a custom hook to be called when an event is fired.
int ast_manager_check_enabled(void)
Check if AMI is enabled.
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
Structure that contains a snapshot of information about a bridge.
Structure for variables, used for configurations and for channel variables.
Structure representing a snapshot of channel state.
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.
Structure for a data store type.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
Structure for a data store object.
struct ast_xml_doc_item * list_responses
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,...)
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.
int manager_bridging_init(void)
Initialize support for AMI channel events.
void astman_send_error_va(struct mansession *s, const struct message *m, const char *fmt,...)
Send error in manager transaction (with va_args support)
ast_doc_src
From where the documentation come from, this structure is useful for use it inside application/functi...
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...
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.
struct ast_module * module
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.
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
int ast_webmanager_check_enabled(void)
Check if AMI/HTTP is enabled.
const char * manager_event
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.
Asterisk datastore objects.
struct stasis_message_type * ast_manager_get_generic_type(void)
Get the stasis_message_type for generic messages.
int astman_is_authed(uint32_t ident)
Determine if a manager session ident is authenticated.
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
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.
#define AST_STRING_FIELD(name)
Declare a string field.
In case you didn't read that giant block of text above the mansession_session struct, the mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
struct ast_str * ast_manager_build_bridge_state_string(const struct ast_bridge_snapshot *snapshot)
Generate the AMI message body from a bridge snapshot.
struct ast_str * ast_manager_build_channel_state_string(const struct ast_channel_snapshot *snapshot)
Generate the AMI message body from a channel snapshot.
void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg)
Send response in manager transaction.
Wrapper for network related headers, masking differences between various operating systems...
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Support for dynamic strings.
void(* manager_hangup_handler_t)(struct ast_channel *chan, int causecode)
Callback used by ast_manager_hangup_helper that will actually hangup a channel.
struct ast_variable * astman_get_variables(const struct message *m)
Get a linked list of the Variable: headers.
struct stasis_message_router * ast_manager_get_message_router(void)
Get the stasis_message_router for AMI.
int astman_verify_session_writepermissions(uint32_t ident, int perm)
Verify a session's write permissions against a permission mask.
int manager_endpoints_init(void)
Initialize support for AMI endpoint events.
Asterisk XML Documentation API.
int astman_datastore_add(struct mansession *s, struct ast_datastore *datastore)
Add a datastore to a session.
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastore)
Remove a datastore from a session.
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.
int manager_system_init(void)
Initialize support for AMI system events.
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...
Abstract JSON element (object, array, string, int, ...).
Struct that contains the XML documentation for a particular item. Note that this is an ao2 ref counte...
int manager_channels_init(void)
Initialize support for AMI channel events.
struct ast_xml_doc_item * final_response
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
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 manager_mwi_init(void)
Initialize support for AMI MWI events.
void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj)
Publish an event to AMI.
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.