Asterisk - The Open Source Telephony Project
21.4.1
|
Data Structures | |
struct | actions |
list of actions registered More... | |
struct | all_events |
struct | ast_manager_user |
user descriptor, as read from the config file. More... | |
struct | eventqent |
struct | fast_originate_helper |
helper function for originate More... | |
struct | manager_hooks |
list of hooks registered More... | |
struct | mansession |
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. More... | |
struct | mansession_session::mansession_datastores |
struct | mansession_session |
struct | permalias |
struct | users |
list of users found in the config file More... | |
Macros | |
#define | any_manager_listeners(sessions) ((sessions && ao2_container_count(sessions)) || !AST_RWLIST_EMPTY(&manager_hooks)) |
#define | ASTMAN_APPEND_BUF_INITSIZE 256 |
initial allocated size for the astman_append_buf and astman_send_*_va | |
#define | DEFAULT_REALM "asterisk" |
#define | EVENT_FLAG_SHUTDOWN -1 |
Fake event class used to end sessions at shutdown. | |
#define | GET_HEADER_FIRST_MATCH 0 |
#define | GET_HEADER_LAST_MATCH 1 |
#define | GET_HEADER_SKIP_EMPTY 2 |
#define | MANAGER_EVENT_BUF_INITSIZE 256 |
#define | manager_event_sessions(sessions, category, event, contents, ...) __manager_event_sessions(sessions, category, event, 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__) |
#define | MAX_AUTH_PERM_STRING 150 |
#define | MAX_BLACKLIST_CMD_LEN 2 |
Descriptor for a manager session, either on the AMI socket or over HTTP. More... | |
#define | MAX_VARS 128 |
#define | MGR_SHOW_TERMINAL_WIDTH 80 |
#define | MSG_MOREDATA ((char *)astman_send_response) |
Enumerations | |
enum | add_filter_result { FILTER_SUCCESS, FILTER_ALLOC_FAILED, FILTER_COMPILE_FAIL } |
enum | error_type { UNKNOWN_ACTION = 1, UNKNOWN_CATEGORY, UNSPECIFIED_CATEGORY, UNSPECIFIED_ARGUMENT, FAILURE_ALLOCATION, FAILURE_NEWCAT, FAILURE_DELCAT, FAILURE_EMPTYCAT, FAILURE_UPDATE, FAILURE_DELETE, FAILURE_APPEND, FAILURE_TEMPLATE } |
enum | mansession_message_parsing { MESSAGE_OKAY, MESSAGE_LINE_TOO_LONG } |
Functions | |
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 *fmt,...) |
static const char * | __astman_get_header (const struct message *m, char *var, int mode) |
Return a matching header value. More... | |
static void | __init_astman_append_buf (void) |
thread local buffer for astman_append More... | |
static void | __init_manager_event_buf (void) |
static void | __init_userevent_buf (void) |
static int | __manager_event_sessions (struct ao2_container *sessions, int category, const char *event, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *fmt,...) |
static int | __manager_event_sessions_va (struct ao2_container *sessions, int category, const char *event, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *fmt, va_list ap) |
static void | acl_change_stasis_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static void | acl_change_stasis_subscribe (void) |
static void | acl_change_stasis_unsubscribe (void) |
static struct ast_aoc_decoded * | action_aoc_de_message (struct mansession *s, const struct message *m) |
static struct ast_aoc_decoded * | action_aoc_s_message (struct mansession *s, const struct message *m) |
static int | action_aoc_s_submessage (struct mansession *s, const struct message *m, struct ast_aoc_decoded *decoded) |
static int | action_aocmessage (struct mansession *s, const struct message *m) |
static int | action_atxfer (struct mansession *s, const struct message *m) |
static int | action_blind_transfer (struct mansession *s, const struct message *m) |
static int | action_cancel_atxfer (struct mansession *s, const struct message *m) |
static int | action_challenge (struct mansession *s, const struct message *m) |
static int | action_command (struct mansession *s, const struct message *m) |
Manager command "command" - execute CLI command. | |
static int | action_coresettings (struct mansession *s, const struct message *m) |
Show PBX core settings information. | |
static int | action_coreshowchannelmap (struct mansession *s, const struct message *m) |
Manager command "CoreShowChannelMap" - Lists all channels connected to the specified channel. | |
static int | action_coreshowchannels (struct mansession *s, const struct message *m) |
Manager command "CoreShowChannels" - List currently defined channels and some information about them. | |
static int | action_corestatus (struct mansession *s, const struct message *m) |
Show PBX core status information. | |
static int | action_createconfig (struct mansession *s, const struct message *m) |
static void | action_destroy (void *obj) |
static int | action_events (struct mansession *s, const struct message *m) |
static int | action_extensionstate (struct mansession *s, const struct message *m) |
static int | action_filter (struct mansession *s, const struct message *m) |
Manager command to add an event filter to a manager session. More... | |
static struct manager_action * | action_find (const char *name) |
static int | action_getconfig (struct mansession *s, const struct message *m) |
static int | action_getconfigjson (struct mansession *s, const struct message *m) |
static int | action_getvar (struct mansession *s, const struct message *m) |
static int | action_hangup (struct mansession *s, const struct message *m) |
static int | action_listcategories (struct mansession *s, const struct message *m) |
static int | action_listcommands (struct mansession *s, const struct message *m) |
static int | action_loggerrotate (struct mansession *s, const struct message *m) |
Manager command "LoggerRotate" - reloads and rotates the logger in the same manner as the CLI command 'logger rotate'. | |
static int | action_login (struct mansession *s, const struct message *m) |
static int | action_logoff (struct mansession *s, const struct message *m) |
static int | action_mailboxcount (struct mansession *s, const struct message *m) |
static int | action_mailboxstatus (struct mansession *s, const struct message *m) |
static int | action_originate (struct mansession *s, const struct message *m) |
static int | action_ping (struct mansession *s, const struct message *m) |
static int | action_presencestate (struct mansession *s, const struct message *m) |
static int | action_redirect (struct mansession *s, const struct message *m) |
action_redirect: The redirect manager command | |
static int | action_reload (struct mansession *s, const struct message *m) |
Send a reload event. | |
static int | action_sendtext (struct mansession *s, const struct message *m) |
static int | action_setvar (struct mansession *s, const struct message *m) |
static int | action_status (struct mansession *s, const struct message *m) |
Manager "status" command to show channels. | |
static int | action_timeout (struct mansession *s, const struct message *m) |
static int | action_updateconfig (struct mansession *s, const struct message *m) |
static int | action_userevent (struct mansession *s, const struct message *m) |
static int | action_waitevent (struct mansession *s, const struct message *m) |
static struct eventqent * | advance_event (struct eventqent *e) |
static | AO2_GLOBAL_OBJ_STATIC (mgr_sessions) |
static | AO2_GLOBAL_OBJ_STATIC (event_docs) |
A container of event documentation nodes. | |
static int | aocmessage_get_unit_entry (const struct message *m, struct ast_aoc_unit_entry *entry, unsigned int entry_num) |
static void | append_channel_vars (struct ast_str **pbuf, struct ast_channel *chan) |
static int | append_event (const char *str, int category) |
events are appended to a queue from where they can be dispatched to clients. | |
int | ast_hook_send_action (struct manager_custom_hook *hook, const char *msg) |
access for hooks to send action messages to ami More... | |
static int | ast_instring (const char *bigstr, const char *smallstr, const char delim) |
int | ast_manager_check_enabled (void) |
Check if AMI is enabled. | |
struct stasis_message_router * | ast_manager_get_message_router (void) |
Get the stasis_message_router for AMI. More... | |
struct stasis_topic * | ast_manager_get_topic (void) |
Get the Stasis Message Bus API topic for AMI. More... | |
int | ast_manager_hangup_helper (struct mansession *s, const struct message *m, manager_hangup_handler_t hangup_handler, manager_hangup_cause_validator_t cause_validator) |
A manager helper function that hangs up a channel using a supplied channel type specific hangup function and cause code validator. More... | |
void | ast_manager_publish_event (const char *type, int class_type, struct ast_json *obj) |
Publish an event to AMI. More... | |
int | ast_manager_register2 (const char *action, int auth, int(*func)(struct mansession *s, const struct message *m), struct ast_module *module, const char *synopsis, const char *description) |
register a new command with manager, including online help. This is the preferred way to register a manager command More... | |
void | ast_manager_register_hook (struct manager_custom_hook *hook) |
Add a custom hook to be called when an event is fired. More... | |
static int | ast_manager_register_struct (struct manager_action *act) |
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. More... | |
int | ast_manager_unregister (const char *action) |
support functions to register/unregister AMI action handlers, More... | |
void | ast_manager_unregister_hook (struct manager_custom_hook *hook) |
Delete a custom hook to be called when an event is fired. More... | |
int | ast_webmanager_check_enabled (void) |
Check if AMI/HTTP is enabled. | |
void | astman_append (struct mansession *s, const char *fmt,...) |
static void | astman_append_headers (struct message *m, const struct ast_variable *params) |
Append additional headers into the message structure from params. More... | |
static void | astman_append_json (struct mansession *s, const char *str) |
static void | astman_flush (struct mansession *s, struct ast_str *buf) |
static void | astman_free_headers (struct message *m) |
Free headers inside message structure, but not the message structure itself. | |
const char * | astman_get_header (const struct message *m, char *var) |
Return the first matching variable from an array. More... | |
struct ast_variable * | astman_get_variables (const struct message *m) |
Get a linked list of the Variable: headers. More... | |
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 | astman_live_dangerously (int new_live_dangerously) |
Enable/disable the inclusion of 'dangerous' configurations outside of the ast_config_AST_CONFIG_DIR. More... | |
void | astman_send_ack (struct mansession *s, const struct message *m, char *msg) |
Send ack 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) | |
static void | astman_send_list_complete (struct mansession *s, const struct message *m, const char *event_name, int count) |
void | astman_send_list_complete_end (struct mansession *s) |
End the list complete event. More... | |
void | astman_send_list_complete_start (struct mansession *s, const struct message *m, const char *event_name, int count) |
Start the list complete event. More... | |
static struct ast_str * | astman_send_list_complete_start_common (struct mansession *s, const struct message *m, const char *event_name, int count) |
void | astman_send_listack (struct mansession *s, const struct message *m, char *msg, char *listflag) |
Send ack in manager transaction to begin a list. More... | |
void | astman_send_response (struct mansession *s, const struct message *m, char *resp, char *msg) |
Send response in manager transaction. | |
static void | astman_send_response_full (struct mansession *s, const struct message *m, char *resp, char *msg, char *listflag) |
send a response with an optional message, and terminate it with an empty line. m is used only to grab the 'ActionID' field. More... | |
static void | astman_start_ack (struct mansession *s, const struct message *m) |
static int | authenticate (struct mansession *s, const struct message *m) |
static const char * | authority_to_str (int authority, struct ast_str **res) |
Convert authority code to a list of options. Note that the EVENT_FLAG_ALL authority will always be returned. | |
static int | blackfilter_cmp_fn (void *obj, void *arg, void *data, int flags) |
static struct mansession_session * | build_mansession (const struct ast_sockaddr *addr) |
Allocate manager session structure and add it to the list of sessions. | |
static int | check_blacklist (const char *cmd) |
static int | check_manager_session_inuse (const char *name) |
static int | coreshowchannelmap_add_connected_channels (struct ao2_container *channel_map, struct ast_channel_snapshot *channel_snapshot, struct ast_bridge_snapshot *bridge_snapshot) |
Recursive function to get all channels in a bridge. Follow local channels as well. | |
static int | coreshowchannelmap_add_to_map (struct ao2_container *c, const char *s) |
Helper function to add a channel name to the vector. | |
static void | destroy_fast_originate_helper (struct fast_originate_helper *doomed) |
static int | do_message (struct mansession *s) |
static void | event_filter_destructor (void *obj) |
static void * | fast_originate (void *data) |
static int | function_capable_string_allowed_with_auths (const char *evaluating, int writepermlist) |
Checks to see if a string which can be used to evaluate functions should be rejected. | |
static void | generate_status (struct mansession *s, struct ast_channel *chan, char **vars, int varc, int all_variables, char *id_text, int *count) |
static int | get_input (struct mansession *s, char *output) |
static struct ast_manager_user * | get_manager_by_name_locked (const char *name) |
static int | get_perm (const char *instr) |
static struct eventqent * | grab_last (void) |
static char * | handle_kickmanconn (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
CLI command manager kick session. | |
static char * | handle_manager_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
CLI command manager reload. | |
static char * | handle_mandebug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static void | handle_parse_error (struct mansession *s, struct message *m, char *error) |
static char * | handle_showmanager (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_showmanagers (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_showmancmd (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_showmancmds (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
CLI command manager list commands. | |
static char * | handle_showmanconn (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
CLI command manager list connected. | |
static char * | handle_showmaneventq (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
CLI command manager list eventq. | |
static enum error_type | handle_updates (struct mansession *s, const struct message *m, struct ast_config *cfg, const char *dfn) |
helper function for action_updateconfig | |
static void | json_escape (char *out, const char *in) |
static void | log_action (const struct message *m, const char *action) |
static struct ast_variable * | man_do_variable_value (struct ast_variable *head, const char *hdr_val) |
static enum add_filter_result | manager_add_filter (const char *filter_pattern, struct ao2_container *whitefilters, struct ao2_container *blackfilters) |
Add an event filter to a manager session. More... | |
static void | manager_default_msg_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static int | manager_displayconnects (struct mansession_session *session) |
Get displayconnects config option. More... | |
static void | manager_generic_msg_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
static void | manager_json_array_with_key (struct ast_json *obj, const char *key, size_t index, struct ast_str **res, key_exclusion_cb exclusion_cb) |
static void | manager_json_obj_with_key (struct ast_json *obj, const char *key, const char *parent_key, struct ast_str **res, key_exclusion_cb exclusion_cb) |
static void | manager_json_to_ast_str (struct ast_json *obj, const char *key, struct ast_str **res, key_exclusion_cb exclusion_cb) |
static void | manager_json_value_str_append (struct ast_json *value, const char *key, struct ast_str **res) |
static int | manager_modulecheck (struct mansession *s, const struct message *m) |
Manager function to check if module is loaded. | |
static int | manager_moduleload (struct mansession *s, const struct message *m) |
static int | manager_state_cb (const char *context, const char *exten, struct ast_state_cb_info *info, void *data) |
static int | mansession_cmp_fn (void *obj, void *arg, int flags) |
static enum ast_transport | mansession_get_transport (const struct mansession *s) |
static void | mansession_lock (struct mansession *s) |
Lock the 'mansession' structure. | |
static void | mansession_unlock (struct mansession *s) |
Unlock the 'mansession' structure. | |
static int | match_filter (struct mansession *s, char *eventdata) |
static void | print_event_instance (struct ast_cli_args *a, struct ast_xml_doc_item *instance) |
static int | process_events (struct mansession *s) |
static int | process_message (struct mansession *s, const struct message *m) |
Process an AMI message, performing desired action. Return 0 on success, -1 on error that require the session to be destroyed. | |
static void | purge_events (void) |
static int | purge_sessions (int n_max) |
remove at most n_max stale session from the list. | |
static int | queue_read_action_payload (struct ast_channel *chan, const unsigned char *payload, size_t payload_size, enum ast_frame_read_action action) |
Queue a given read action containing a payload onto a channel. More... | |
static int | queue_sendtext (struct ast_channel *chan, const char *body) |
Queue a read action to send a text message. More... | |
static int | queue_sendtext_data (struct ast_channel *chan, const char *body, const char *content_type) |
Queue a read action to send a text data message. More... | |
static int | reload_module (void) |
static void | report_auth_success (const struct mansession *s) |
static void | report_failed_acl (const struct mansession *s, const char *username) |
static void | report_failed_challenge_response (const struct mansession *s, const char *response, const char *expected_response) |
static void | report_inval_password (const struct mansession *s, const char *username) |
static void | report_invalid_user (const struct mansession *s, const char *username) |
static void | report_req_bad_format (const struct mansession *s, const char *action) |
static void | report_req_not_allowed (const struct mansession *s, const char *action) |
static void | report_session_limit (const struct mansession *s) |
static int | restrictedFile (const char *filename) |
Check if a file is restricted or not. More... | |
static int | send_string (struct mansession *s, char *string) |
static void | session_destroy (struct mansession_session *s) |
static void | session_destructor (void *obj) |
static void * | session_do (void *data) |
The body of the individual manager session. Call get_input() to read one line at a time (or be woken up on new events), collect the lines in a message until found an empty line, and execute the request. In any case, deliver events asynchronously through process_events() (called from here if no line is available, or at the end of process_message(). ) | |
static int | set_eventmask (struct mansession *s, const char *eventmask) |
Rather than braindead on,off this now can also accept a specific int mask value or a ',' delim list of mask strings (the same as manager.conf) -anthm. | |
static int | strings_to_mask (const char *string) |
static struct mansession_session * | unref_mansession (struct mansession_session *s) |
Unreference manager session object. If no more references, then go ahead and delete it. | |
static const char * | user_authority_to_str (int authority, struct ast_str **res) |
Convert authority code to a list of options for a user. This will only display those authority codes that have an explicit match on authority. | |
static int | whitefilter_cmp_fn (void *obj, void *arg, void *data, int flags) |
Variables | |
static struct stasis_subscription * | acl_change_sub |
static struct actions | actions = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
static struct all_events | all_events = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
static int | allowmultiplelogin = 1 |
static struct ast_threadstorage | astman_append_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_astman_append_buf , .custom_init = NULL , } |
static int | authlimit |
static int | authtimeout |
static int | broken_events_action = 0 |
struct { | |
const char * words [AST_MAX_CMD_LEN] | |
} | command_blacklist [] |
static int | displayconnects = 1 |
static char | global_realm [MAXHOSTNAMELEN] |
static int | httptimeout = 60 |
static int | live_dangerously |
Set to true (non-zero) to globally allow all dangerous AMI actions to run. | |
static char * | manager_channelvars |
static int | manager_debug = 0 |
static char * | manager_disabledevents |
static int | manager_enabled = 0 |
static struct ast_threadstorage | manager_event_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_manager_event_buf , .custom_init = NULL , } |
static struct manager_hooks | manager_hooks = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
static struct stasis_topic * | manager_topic |
A stasis_topic that all topics AMI cares about will be forwarded to. | |
static const struct permalias | perms [] |
static struct stasis_forward * | rtp_topic_forwarder |
The stasis_subscription for forwarding the RTP topic to the AMI topic. | |
static struct stasis_forward * | security_topic_forwarder |
The stasis_subscription for forwarding the Security topic to the AMI topic. | |
static struct stasis_message_router * | stasis_router |
The stasis_message_router for all Stasis Message Bus API messages. | |
static int | subscribed = 0 |
static int | timestampevents |
static int | unauth_sessions = 0 |
static struct ast_threadstorage | userevent_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_userevent_buf , .custom_init = NULL , } |
static struct users | users = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
static int | webmanager_enabled = 0 |
STASIS_MESSAGE_TYPE_DEFN (ast_manager_get_generic_type) | |
Define AMI message types. | |
#define MAX_AUTH_PERM_STRING 150 |
#define MAX_BLACKLIST_CMD_LEN 2 |
Descriptor for a manager session, either on the AMI socket or over HTTP.
#define MSG_MOREDATA ((char *)astman_send_response) |
Definition at line 3344 of file manager.c.
Referenced by action_command(), and astman_send_response_full().
enum error_type |
Doxygen group
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, | ||
... | |||
) |
External routines may send asterisk manager events this way
category | Event category, matches manager authorization |
event | Event name |
chancount | Number of channels in chans parameter |
chans | A pointer to an array of channels involved in the event |
file,line,func | |
contents | Format string describing event |
... |
Definition at line 8032 of file manager.c.
References ao2_global_obj_ref.
|
static |
Return a matching header value.
Generic function to return either the first or the last matching header from a list of variables, possibly skipping empty strings.
Definition at line 3013 of file manager.c.
References ast_skip_blanks().
Referenced by astman_get_header(), and process_message().
|
static |
thread local buffer for astman_append
|
static |
Manager command to add an event filter to a manager session.
Definition at line 6716 of file manager.c.
References astman_get_header(), astman_send_ack(), astman_send_error(), mansession_session::blackfilters, manager_add_filter(), and mansession_session::whitefilters.
|
static |
Active manager connection sessions container.
int ast_hook_send_action | ( | struct manager_custom_hook * | hook, |
const char * | msg | ||
) |
access for hooks to send action messages to ami
Registered hooks can call this function to invoke actions and they will receive responses through registered callback.
Definition at line 3167 of file manager.c.
References ast_module_running_ref, ast_module_unref, ast_strdup, astman_get_header(), manager_action::func, manager_action::module, and manager_action::registered.
|
static |
Tells you if smallstr exists inside bigstr which is delim by delim and uses no buf or stringsep ast_instring("this|that|more","this",'|') == 1;
feel free to move this to app.c -anthm
Definition at line 2272 of file manager.c.
struct stasis_message_router* ast_manager_get_message_router | ( | void | ) |
Get the stasis_message_router for AMI.
NULL | on error |
Definition at line 1885 of file manager.c.
References stasis_router.
Referenced by manager_bridging_init(), manager_channels_init(), manager_mwi_init(), and manager_system_init().
struct stasis_topic* ast_manager_get_topic | ( | void | ) |
Get the Stasis Message Bus API topic for AMI.
NULL | on error |
Definition at line 1880 of file manager.c.
References manager_topic.
Referenced by ast_manager_publish_event(), load_module(), manager_bridging_init(), manager_channels_init(), manager_mwi_init(), manager_system_init(), pbx_load_users(), publish_load_message_type(), and stasis_app_user_event().
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 function and cause code validator.
This function handles the lookup of channel(s) and the AMI interaction but uses the supplied callbacks to actually perform the hangup. It can be used to implement a custom AMI 'Hangup' action without having to duplicate all the code in the standard Hangup action.
s | Session |
m | Message |
handler | Function that actually performs the hangup |
cause_validator | Function that validates the cause code |
0 | on success. |
non-zero | on error. |
Definition at line 4762 of file manager.c.
References mansession_session::addr, ast_channel_get_by_name(), ast_channel_iterator_all_new(), ast_channel_iterator_destroy(), ast_channel_iterator_next(), ast_channel_unref, ast_regex_string_to_regex_pattern(), ast_sockaddr_stringify_addr(), ast_str_buffer(), ast_str_create, astman_append(), astman_get_header(), astman_send_ack(), astman_send_error(), astman_send_error_va(), astman_send_listack(), mansession_session::managerid, and mansession_session::username.
Referenced by pjsip_action_hangup().
void ast_manager_publish_event | ( | const char * | type, |
int | class_type, | ||
struct ast_json * | obj | ||
) |
Publish an event to AMI.
type | The type of AMI event to publish |
class_type | The class on which to publish the event |
obj | The event data to be published. |
Publishes a message to the Stasis Message Bus API message bus solely for the consumption of AMI. The message will be of the type provided by ast_manager_get_generic_type, and will be published to the topic provided by ast_manager_get_topic. As such, the JSON must be constructed as defined by the ast_manager_get_generic_type message.
Definition at line 2063 of file manager.c.
References ast_json_pack(), ast_json_payload_create(), ast_json_ref(), ast_json_unref(), ast_manager_get_generic_type(), ast_manager_get_topic(), RAII_VAR, stasis_message_create(), and stasis_publish().
Referenced by really_quit(), and reset_user_pw().
int ast_manager_register2 | ( | const char * | action, |
int | auth, | ||
int(*)(struct mansession *s, const struct message *m) | func, | ||
struct ast_module * | module, | ||
const char * | synopsis, | ||
const char * | description | ||
) |
register a new command with manager, including online help. This is the preferred way to register a manager command
Register a manager command with the manager interface.
Definition at line 8183 of file manager.c.
References manager_action::action, AST_STATIC_DOC, ast_string_field_init, ast_string_field_set, AST_XML_DOC, ast_xmldoc_build_arguments(), ast_xmldoc_build_description(), ast_xmldoc_build_final_response(), ast_xmldoc_build_list_responses(), ast_xmldoc_build_seealso(), ast_xmldoc_build_synopsis(), ast_xmldoc_build_syntax(), manager_action::authority, manager_action::docsrc, manager_action::final_response, manager_action::func, manager_action::list_responses, and manager_action::module.
void ast_manager_register_hook | ( | struct manager_custom_hook * | hook | ) |
Add a custom hook to be called when an event is fired.
Add a custom hook to be called when an event is fired
hook | struct manager_custom_hook object to add |
Definition at line 2094 of file manager.c.
References AST_RWLIST_UNLOCK, and AST_RWLIST_WRLOCK.
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.
blob | The JSON blob containing key/value pairs to convert |
exclusion_cb | A key_exclusion_cb pointer to a function that will exclude keys from the final AMI string |
NULL | on error |
Definition at line 1981 of file manager.c.
References ast_json_is_null(), and ast_str_create.
Referenced by mwi_app_event_cb().
int ast_manager_unregister | ( | const char * | action | ) |
support functions to register/unregister AMI action handlers,
Unregister a registered manager command.
Definition at line 8057 of file manager.c.
References manager_action::action, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and manager_action::registered.
Referenced by load_module(), unload_module(), and unload_parking_manager().
void ast_manager_unregister_hook | ( | struct manager_custom_hook * | hook | ) |
Delete a custom hook to be called when an event is fired.
Delete a custom hook to be called when an event is fired
hook | struct manager_custom_hook object to delete |
Definition at line 2102 of file manager.c.
References AST_RWLIST_UNLOCK, and AST_RWLIST_WRLOCK.
void astman_append | ( | struct mansession * | s, |
const char * | fmt, | ||
... | |||
) |
utility functions for creating AMI replies
Definition at line 3310 of file manager.c.
References AST_DYNSTR_BUILD_FAILED, ast_str_buffer(), ast_str_set_va(), ast_str_thread_get(), ASTMAN_APPEND_BUF_INITSIZE, send_string(), and ast_tcptls_session_instance::stream.
Referenced by action_command(), action_coresettings(), action_coreshowchannelmap(), action_coreshowchannels(), action_corestatus(), action_status(), append_vmbox_info_astman(), append_vmu_info_astman(), ast_manager_hangup_helper(), astman_send_list_complete_end(), do_print(), manager_modulecheck(), manager_mute_mixmonitor(), manager_queues_status(), manager_queues_summary(), manager_show_dialplan(), manager_show_dialplan_helper(), session_do(), and sig_pri_ami_show_spans().
|
static |
Append additional headers into the message structure from params.
Definition at line 3060 of file manager.c.
References ast_asprintf, ast_variable::name, ast_variable::next, and ast_variable::value.
Referenced by generic_http_callback().
const char* astman_get_header | ( | const struct message * | m, |
char * | var | ||
) |
Return the first matching variable from an array.
Get header from manager transaction.
Definition at line 3050 of file manager.c.
References __astman_get_header().
Referenced by action_add_agi_cmd(), action_bridge(), action_command(), action_coresettings(), action_coreshowchannelmap(), action_coreshowchannels(), action_corestatus(), action_filter(), action_redirect(), action_reload(), action_status(), ast_hook_send_action(), ast_manager_hangup_helper(), astman_send_response_full(), handle_updates(), manager_iax2_show_peer_list(), manager_iax2_show_peers(), manager_list_voicemail_users(), manager_modulecheck(), manager_mute_mixmonitor(), manager_queues_status(), manager_queues_summary(), manager_show_dialplan(), and process_message().
struct ast_variable* astman_get_variables | ( | const struct message * | m | ) |
Get a linked list of the Variable: headers.
Definition at line 3136 of file manager.c.
References astman_get_variables_order().
void astman_live_dangerously | ( | int | new_live_dangerously | ) |
Enable/disable the inclusion of 'dangerous' configurations outside of the ast_config_AST_CONFIG_DIR.
This function can globally enable/disable the loading of configuration files outside of ast_config_AST_CONFIG_DIR.
new_live_dangerously | If true, enable the access of files outside ast_config_AST_CONFIG_DIR from astman. |
Definition at line 3850 of file manager.c.
void astman_send_list_complete_end | ( | struct mansession * | s | ) |
End the list complete event.
s | - AMI session control struct. |
Definition at line 3475 of file manager.c.
References astman_append().
Referenced by action_coreshowchannelmap(), action_status(), append_vmbox_info_astman(), manager_iax2_show_peer_list(), manager_iax2_show_peers(), manager_list_voicemail_users(), manager_queues_status(), manager_queues_summary(), and manager_show_dialplan().
void astman_send_list_complete_start | ( | struct mansession * | s, |
const struct message * | m, | ||
const char * | event_name, | ||
int | count | ||
) |
Start the list complete event.
s | - AMI session control struct. |
m | - AMI action request that started the list. |
event_name | - AMI list complete event name. |
count | - Number of items in the list. |
Definition at line 3467 of file manager.c.
Referenced by action_coreshowchannelmap(), action_status(), append_vmbox_info_astman(), manager_iax2_show_peer_list(), manager_iax2_show_peers(), manager_list_voicemail_users(), manager_queues_status(), manager_queues_summary(), and manager_show_dialplan().
void astman_send_listack | ( | struct mansession * | s, |
const struct message * | m, | ||
char * | msg, | ||
char * | listflag | ||
) |
Send ack in manager transaction to begin a list.
s | - AMI session control struct. |
m | - AMI action request that started the list. |
msg | - Message contents describing the list to follow. |
listflag | - Should always be set to "start". |
Definition at line 3431 of file manager.c.
References astman_send_response_full().
Referenced by action_coreshowchannelmap(), action_coreshowchannels(), action_status(), append_vmbox_info_astman(), ast_manager_hangup_helper(), manager_dpsendack(), manager_iax2_show_peer_list(), manager_iax2_show_peers(), manager_list_voicemail_users(), manager_queues_status(), and manager_queues_summary().
|
static |
send a response with an optional message, and terminate it with an empty line. m is used only to grab the 'ActionID' field.
Use the explicit constant MSG_MOREDATA to remove the empty line. XXX MSG_MOREDATA should go to a header file.
Definition at line 3353 of file manager.c.
References ast_str_append(), ast_str_set(), ast_str_thread_get(), ASTMAN_APPEND_BUF_INITSIZE, astman_get_header(), and MSG_MOREDATA.
Referenced by action_command(), astman_send_ack(), astman_send_error(), astman_send_error_va(), astman_send_listack(), and astman_send_response().
|
static |
Read one full line (including crlf) from the manager socket.
* \r\n is the only valid terminator for the line. * (Note that, later, '\0' will be considered as the end-of-line marker, * so everything between the '\0' and the '\r\n' will not be used). * Also note that we assume output to have at least "maxlen" space. *
Definition at line 7519 of file manager.c.
References mansession_session::addr, ast_debug, ast_iostream_get_fd(), ast_iostream_read(), ast_sockaddr_stringify_addr(), mansession_session::authenticated, mansession_session::inbuf, mansession_session::inlen, mansession_session::kicked, mansession_session::notify_lock, mansession_session::pending_event, mansession_session::stream, and mansession_session::waiting_thread.
|
static |
lookup an entry in the list of registered users. must be called with the list lock held.
Definition at line 2465 of file manager.c.
Referenced by function_amiclient(), manager_displayconnects(), and process_message().
|
static |
Grab a reference to the last event, update usecount as needed. Can handle a NULL pointer.
Definition at line 2123 of file manager.c.
References ast_atomic_fetchadd_int(), AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and eventqent::usecount.
Referenced by generic_http_callback(), and session_do().
|
static |
|
static |
Add an event filter to a manager session.
filter_pattern | Filter syntax to add, see below for syntax |
whitefilters,blackfilters |
Filter will be used to match against each line of a manager event Filter can be any valid regular expression Filter can be a valid regular expression prefixed with !, which will add the filter as a black filter
Examples:
Definition at line 6768 of file manager.c.
References ao2_ref.
Referenced by action_filter().
|
static |
Get displayconnects config option.
session | manager session to get parameter from. |
Definition at line 2482 of file manager.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_manager_user::displayconnects, get_manager_by_name_locked(), and mansession_session::username.
Referenced by generic_http_callback(), purge_sessions(), and session_do().
|
static |
Send any applicable events to the client listening on this socket. Wait only for a finite time on each event, and drop all events whether they are successfully sent or not.
Definition at line 6833 of file manager.c.
References ast_debug, mansession_session::authenticated, EVENT_FLAG_SHUTDOWN, mansession_session::last_ev, mansession_session::readperm, mansession_session::send_events, send_string(), and mansession_session::stream.
Referenced by process_message().
|
static |
Purge unused events. Remove elements from the head as long as their usecount is 0 and there is a next element.
Definition at line 2143 of file manager.c.
References AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_tvdiff_sec(), ast_tvnow(), eventqent::tv, and eventqent::usecount.
Referenced by purge_old_stuff().
|
static |
Queue a given read action containing a payload onto a channel.
This queues a READ_ACTION control frame that contains a given "payload", or data to be triggered and handled on the channel's read side. This ensures the "action" is handled by the channel's media reading thread.
chan | The channel to queue the action on |
payload | The read action's payload |
payload_size | The size of the given payload |
action | The type of read action to queue |
-1 | on error |
0 | on success |
Definition at line 5177 of file manager.c.
References AST_CONTROL_READ_ACTION, ast_malloc, and ast_queue_control_data().
Referenced by queue_sendtext(), and queue_sendtext_data().
|
static |
Queue a read action to send a text message.
chan | The channel to queue the action on |
body | The body of the message |
-1 | on error |
0 | on success |
Definition at line 5210 of file manager.c.
References queue_read_action_payload().
|
static |
Queue a read action to send a text data message.
chan | The channel to queue the action on |
body | The body of the message |
content_type | The message's content type |
-1 | on error |
0 | on success |
Definition at line 5226 of file manager.c.
References ast_msg_data_alloc2(), ast_msg_data_get_length(), and queue_read_action_payload().
|
static |
Check if a file is restricted or not.
Definition at line 3871 of file manager.c.
References ast_asprintf, ast_begins_with(), ast_strdupa, ast_strip(), and RAII_VAR.
|
static |
helper function to send a string to the socket. Return -1 on error (e.g. buffer full).
Definition at line 3255 of file manager.c.
References ast_iostream_set_timeout_disable(), ast_iostream_set_timeout_inactivity(), ast_iostream_write(), manager_custom_hook::helper, mansession_session::stream, and mansession_session::writetimeout.
Referenced by astman_append(), and process_events().
|
static |
A number returns itself, false returns 0, true returns all flags, other strings return the flags that are set.
Definition at line 2312 of file manager.c.
References ast_false(), and ast_true().
Referenced by set_eventmask().
const { ... } command_blacklist[] |