19 #ifndef _ASTERISK_MANAGER_H 20 #define _ASTERISK_MANAGER_H 57 #define AMI_VERSION "7.0.1" 58 #define DEFAULT_MANAGER_PORT 5038 59 #define DEFAULT_MANAGER_TLS_PORT 5039 65 #define AMI_SUCCESS (0) 66 #define AMI_DESTROY (-1) 71 #define EVENT_FLAG_SYSTEM (1 << 0) 72 #define EVENT_FLAG_CALL (1 << 1) 73 #define EVENT_FLAG_LOG (1 << 2) 74 #define EVENT_FLAG_VERBOSE (1 << 3) 75 #define EVENT_FLAG_COMMAND (1 << 4) 76 #define EVENT_FLAG_AGENT (1 << 5) 77 #define EVENT_FLAG_USER (1 << 6) 78 #define EVENT_FLAG_CONFIG (1 << 7) 79 #define EVENT_FLAG_DTMF (1 << 8) 80 #define EVENT_FLAG_REPORTING (1 << 9) 81 #define EVENT_FLAG_CDR (1 << 10) 82 #define EVENT_FLAG_DIALPLAN (1 << 11) 83 #define EVENT_FLAG_ORIGINATE (1 << 12) 84 #define EVENT_FLAG_AGI (1 << 13) 85 #define EVENT_FLAG_HOOKRESPONSE (1 << 14) 86 #define EVENT_FLAG_CC (1 << 15) 87 #define EVENT_FLAG_AOC (1 << 16) 88 #define EVENT_FLAG_TEST (1 << 17) 89 #define EVENT_FLAG_SECURITY (1 << 18) 91 #define EVENT_FLAG_MESSAGE (1 << 30) 95 #define AST_MAX_MANHEADERS 128 183 #define ast_manager_register(action, authority, func, synopsis) ast_manager_register2(action, authority, func, AST_MODULE_SELF, synopsis, NULL) 186 #define ast_manager_register_xml(action, authority, func) ast_manager_register2(action, authority, func, AST_MODULE_SELF, NULL, NULL) 197 #define ast_manager_register_xml_core(action, authority, func) ast_manager_register2(action, authority, func, NULL, NULL, NULL) 214 const char *description);
248 #define manager_event(category, event, contents , ...) \ 249 __ast_manager_event_multichan(category, event, 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__) 250 #define ast_manager_event(chan, category, event, contents , ...) \ 252 struct ast_channel *_chans[] = { chan, }; \ 253 __ast_manager_event_multichan(category, event, 1, _chans, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__); \ 255 #define ast_manager_event_multichan(category, event, nchans, chans, contents , ...) \ 256 __ast_manager_event_multichan(category, event, nchans, chans, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__); 417 const struct ast_channel_snapshot *snapshot,
431 const struct ast_channel_snapshot *snapshot);
474 const struct ast_bridge_snapshot *snapshot,
488 const struct ast_bridge_snapshot *snapshot);
513 struct ast_manager_event_blob *
514 __attribute__((
format(printf, 3, 4)))
517 const
char *manager_event,
518 const
char *extra_fields_fmt,
522 #define NO_EXTRA_FIELDS "%s", "" static const char synopsis[]
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.
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...
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 mananger 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)
Determinie if a manager session ident is authenticated.
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
unsigned int registered
TRUE if the AMI action is registered and the callback can be called.
#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 struct 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.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
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, ...).
int error(const char *format,...)
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
static snd_pcm_format_t format
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.
static char prefix[MAX_PREFIX]
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.