#include "asterisk/network.h"
#include "asterisk/lock.h"
#include "asterisk/datastore.h"
#include "asterisk/xmldoc.h"
Go to the source code of this file.
Data Structures | |
struct | manager_action |
struct | manager_custom_hook |
struct | message |
Constant return values | |
| |
#define | AMI_DESTROY (-1) |
#define | AMI_SUCCESS (0) |
Manager event classes | |
#define | EVENT_FLAG_AGENT (1 << 5) |
#define | EVENT_FLAG_AGI (1 << 13) |
#define | EVENT_FLAG_AOC (1 << 16) |
#define | EVENT_FLAG_CALL (1 << 1) |
#define | EVENT_FLAG_CC (1 << 15) |
#define | EVENT_FLAG_CDR (1 << 10) |
#define | EVENT_FLAG_COMMAND (1 << 4) |
#define | EVENT_FLAG_CONFIG (1 << 7) |
#define | EVENT_FLAG_DIALPLAN (1 << 11) |
#define | EVENT_FLAG_DTMF (1 << 8) |
#define | EVENT_FLAG_HOOKRESPONSE (1 << 14) |
#define | EVENT_FLAG_LOG (1 << 2) |
#define | EVENT_FLAG_ORIGINATE (1 << 12) |
#define | EVENT_FLAG_REPORTING (1 << 9) |
#define | EVENT_FLAG_SYSTEM (1 << 0) |
#define | EVENT_FLAG_USER (1 << 6) |
#define | EVENT_FLAG_VERBOSE (1 << 3) |
Defines | |
#define | AMI_VERSION "1.1" |
#define | ast_manager_event(chan, category, event, contents,) |
#define | ast_manager_event_multichan(category, event, nchans, chans, contents,) __ast_manager_event_multichan(category, event, nchans, chans, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__); |
#define | ast_manager_register(a, b, c, d) ast_manager_register2(a, b, c, d, NULL) |
External routines may register/unregister manager callbacks this way. | |
#define | ast_manager_register_xml(a, b, c) ast_manager_register2(a, b, c, NULL, NULL) |
Register a manager callback using XML documentation to describe the manager. | |
#define | AST_MAX_MANHEADERS 128 |
Export manager structures. | |
#define | DEFAULT_MANAGER_PORT 5038 |
#define | manager_event(category, event, contents,) __ast_manager_event_multichan(category, event, 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__) |
External routines may send asterisk manager events this way. | |
Typedefs | |
typedef int(*) | manager_hook_t (int, const char *, char *) |
Manager Helper Function. | |
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 *contents,...) |
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 registered callback. | |
int | ast_manager_register2 (const char *action, int authority, int(*func)(struct mansession *s, const struct message *m), const char *synopsis, const char *description) |
Register a manager command with the manager interface. | |
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_unregister (char *action) |
Unregister a registered manager command. | |
void | ast_manager_unregister_hook (struct manager_custom_hook *hook) |
Delete a custom hook to be called when an event is fired. | |
void | astman_append (struct mansession *s, const char *fmt,...) |
int | astman_datastore_add (struct mansession *s, struct ast_datastore *datastore) |
Add a datastore to a session. | |
ast_datastore * | astman_datastore_find (struct mansession *s, const struct ast_datastore_info *info, const char *uid) |
Find a datastore on a session. | |
int | astman_datastore_remove (struct mansession *s, struct ast_datastore *datastore) |
Remove a datastore from a session. | |
const char * | astman_get_header (const struct message *m, char *var) |
Get header from mananger transaction. | |
ast_variable * | astman_get_variables (const struct message *m) |
Get a linked list of the Variable: headers. | |
int | astman_is_authed (uint32_t ident) |
Determinie if a manager session ident is authenticated. | |
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_listack (struct mansession *s, const struct message *m, char *msg, char *listflag) |
Send ack in manager list transaction. | |
void | astman_send_response (struct mansession *s, const struct message *m, char *resp, char *msg) |
Send response in manager transaction. | |
int | astman_verify_session_readpermissions (uint32_t ident, int perm) |
Verify a session's read permissions against a permission mask. | |
int | astman_verify_session_writepermissions (uint32_t ident, int perm) |
Verify a session's write permissions against a permission mask. | |
int | check_manager_enabled (void) |
Check if AMI is enabled. | |
int | check_webmanager_enabled (void) |
Check if AMI/HTTP is enabled. | |
int | init_manager (void) |
Called by Asterisk initialization. | |
int | reload_manager (void) |
Called by Asterisk module functions and the CLI command. |
Manager protocol packages are text fields of the form a: b. There is always exactly one space after the colon.
For Actions replies, the first line of the reply is a "Response:" header with values "success", "error" or "follows". "Follows" implies that the response is coming as separate events with the same ActionID. If the Action request has no ActionID, it will be hard matching events to the Action request in the manager client. The first header type is the "Event" header. Other headers vary from event to event. Headers end with standard \\r\\n termination. The last line of the manager response or event is an empty line. (\\r\\n)
Definition in file manager.h.
#define AMI_SUCCESS (0) |
#define AMI_VERSION "1.1" |
#define ast_manager_event | ( | chan, | |||
category, | |||||
event, | |||||
contents | ) |
Value:
do { \ struct ast_channel *_chans[] = { chan, }; \ __ast_manager_event_multichan(category, event, 1, _chans, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__); \ } while (0)
Definition at line 210 of file manager.h.
Referenced by __ast_change_name_nolink(), __ast_channel_alloc_ap(), ast_aoc_manager_event(), ast_cdr_setaccount(), ast_cdr_setpeeraccount(), ast_do_masquerade(), ast_hangup(), ast_monitor_start(), ast_monitor_stop(), ast_setstate(), bridge_exec(), channel_spy(), conf_run(), join_queue(), leave_queue(), local_ast_moh_stop(), notify_new_message(), park_call_full(), park_exec_full(), phase_e_handler(), report_new_callerid(), send_dtmf_event(), send_talking_event(), senddialendevent(), socket_process(), and vm_execmain().
#define ast_manager_event_multichan | ( | category, | |||
event, | |||||
nchans, | |||||
chans, | |||||
contents | ) | __ast_manager_event_multichan(category, event, nchans, chans, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__); |
Definition at line 215 of file manager.h.
Referenced by action_bridge(), ast_aoc_manager_event(), ast_channel_bridge(), ast_do_masquerade(), ast_pickup_call(), bridge_exec(), channel_spy(), fast_originate(), handle_request_refer(), local_attended_transfer(), manager_bridge_event(), pickup_do(), and senddialevent().
#define ast_manager_register | ( | a, | |||
b, | |||||
c, | |||||
d | ) | ast_manager_register2(a, b, c, d, NULL) |
External routines may register/unregister manager callbacks this way.
Definition at line 158 of file manager.h.
Referenced by load_module().
#define ast_manager_register_xml | ( | a, | |||
b, | |||||
c | ) | ast_manager_register2(a, b, c, NULL, NULL) |
Register a manager callback using XML documentation to describe the manager.
Definition at line 161 of file manager.h.
Referenced by __init_manager(), ast_data_init(), ast_features_init(), astdb_init(), load_module(), and load_pbx().
#define AST_MAX_MANHEADERS 128 |
#define DEFAULT_MANAGER_PORT 5038 |
#define EVENT_FLAG_AGENT (1 << 5) |
Definition at line 75 of file manager.h.
Referenced by add_to_queue(), load_module(), login_exec(), record_abandoned(), remove_from_queue(), ring_entry(), rna(), send_agent_complete(), set_member_paused(), set_member_penalty(), and update_status().
#define EVENT_FLAG_AGI (1 << 13) |
Definition at line 83 of file manager.h.
Referenced by agi_handle_command(), launch_asyncagi(), and load_module().
#define EVENT_FLAG_AOC (1 << 16) |
Definition at line 86 of file manager.h.
Referenced by __init_manager(), and ast_aoc_manager_event().
#define EVENT_FLAG_CALL (1 << 1) |
Definition at line 71 of file manager.h.
Referenced by __ast_change_name_nolink(), __ast_channel_alloc_ap(), __init_manager(), action_bridge(), ast_cdr_setaccount(), ast_cdr_setpeeraccount(), ast_channel_bridge(), ast_do_masquerade(), ast_features_init(), ast_hangup(), ast_monitor_start(), ast_monitor_stop(), ast_pickup_call(), ast_setstate(), bridge_exec(), change_hold_state(), channel_spy(), conf_free(), conf_run(), fast_originate(), handle_request_refer(), join_queue(), leave_queue(), load_module(), local_ast_moh_stop(), local_attended_transfer(), manager_bridge_event(), manager_state_cb(), notify_new_message(), park_call_full(), park_exec_full(), phase_e_handler(), pickup_do(), post_manager_event(), receivefax_exec(), report_fax_status(), report_new_callerid(), send_talking_event(), senddialendevent(), senddialevent(), sendfax_exec(), socket_process(), and vm_execmain().
#define EVENT_FLAG_CC (1 << 15) |
Definition at line 85 of file manager.h.
Referenced by ast_handle_cc_control_frame(), cc_active(), cc_caller_busy(), cc_caller_offered(), cc_complete(), cc_failed(), cc_monitor_failed(), cc_recalling(), and request_cc().
#define EVENT_FLAG_CDR (1 << 10) |
#define EVENT_FLAG_COMMAND (1 << 4) |
#define EVENT_FLAG_CONFIG (1 << 7) |
#define EVENT_FLAG_DIALPLAN (1 << 11) |
Definition at line 81 of file manager.h.
Referenced by frame_set_var(), pbx_builtin_setvar_helper(), pbx_extension_helper(), and shared_write().
#define EVENT_FLAG_DTMF (1 << 8) |
#define EVENT_FLAG_HOOKRESPONSE (1 << 14) |
#define EVENT_FLAG_ORIGINATE (1 << 12) |
#define EVENT_FLAG_REPORTING (1 << 9) |
Definition at line 79 of file manager.h.
Referenced by __init_manager(), ast_rtcp_read(), ast_rtcp_write_sr(), astdb_init(), load_module(), load_pbx(), and log_jitterstats().
#define EVENT_FLAG_SYSTEM (1 << 0) |
Definition at line 70 of file manager.h.
Referenced by __analog_handle_event(), __expire_registry(), __iax2_poke_noanswer(), __init_manager(), action_login(), action_originate(), analog_dnd(), analog_handle_init_event(), astdb_init(), dahdi_dnd(), do_reload(), expire_register(), gtalk_answer(), gtalk_new(), handle_alarms(), handle_clear_alarms(), handle_response_invite(), handle_response_peerpoke(), handle_response_register(), iax2_ack_registry(), iax2_ami_channelupdate(), load_module(), logger_print_normal(), main(), parse_register_contact(), private_enum_init(), quit_handler(), register_verify(), reload_logger(), sip_new(), sip_poke_noanswer(), sip_reg_timeout(), sip_request_call(), skinny_register(), skinny_unregister(), socket_process(), unload_module(), and update_registry().
#define EVENT_FLAG_USER (1 << 6) |
Definition at line 76 of file manager.h.
Referenced by __init_manager(), action_userevent(), aji_handle_presence(), aji_log_hook(), and userevent_exec().
#define manager_event | ( | category, | |||
event, | |||||
contents | ) | __ast_manager_event_multichan(category, event, 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__) |
External routines may send asterisk manager events this way.
category | Event category, matches manager authorization | |
event | Event name | |
contents | Contents of event |
Definition at line 208 of file manager.h.
Referenced by __analog_handle_event(), __expire_registry(), __iax2_poke_noanswer(), action_login(), action_userevent(), add_to_queue(), agi_handle_command(), aji_handle_presence(), aji_log_hook(), analog_dnd(), analog_handle_init_event(), ast_handle_cc_control_frame(), ast_rtcp_read(), ast_rtcp_write_sr(), cc_active(), cc_caller_busy(), cc_caller_offered(), cc_complete(), cc_failed(), cc_monitor_failed(), cc_recalling(), change_hold_state(), conf_free(), dahdi_dnd(), do_reload(), expire_register(), frame_set_var(), gtalk_answer(), gtalk_new(), handle_alarms(), handle_clear_alarms(), handle_response_invite(), handle_response_peerpoke(), handle_response_register(), iax2_ack_registry(), iax2_ami_channelupdate(), launch_asyncagi(), log_jitterstats(), logger_print_normal(), login_exec(), main(), manager_log(), manager_state_cb(), parse_register_contact(), pbx_builtin_setvar_helper(), pbx_extension_helper(), post_manager_event(), private_enum_init(), quit_handler(), receivefax_exec(), record_abandoned(), register_verify(), reload_logger(), remove_from_queue(), report_fax_status(), request_cc(), ring_entry(), rna(), send_agent_complete(), sendfax_exec(), set_member_paused(), set_member_penalty(), shared_write(), sip_new(), sip_poke_noanswer(), sip_reg_timeout(), sip_request_call(), skinny_register(), skinny_unregister(), socket_process(), unload_module(), update_registry(), update_status(), and userevent_exec().
typedef int(*) manager_hook_t(int, const char *, char *) |
int astman_datastore_add | ( | struct mansession * | s, | |
struct ast_datastore * | datastore | |||
) |
Add a datastore to a session.
0 | success | |
non-zero | failure |
Definition at line 6644 of file manager.c.
References AST_LIST_INSERT_HEAD, mansession_session::datastores, manager_channel_variable::entry, and mansession::session.
06645 { 06646 AST_LIST_INSERT_HEAD(&s->session->datastores, datastore, entry); 06647 06648 return 0; 06649 }
struct ast_datastore* astman_datastore_find | ( | struct mansession * | s, | |
const struct ast_datastore_info * | info, | |||
const char * | uid | |||
) |
Find a datastore on a session.
pointer | to the datastore if found | |
NULL | if not found |
Definition at line 6656 of file manager.c.
References AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, mansession_session::datastores, ast_datastore::entry, ast_datastore::info, mansession::session, and ast_datastore::uid.
06657 { 06658 struct ast_datastore *datastore = NULL; 06659 06660 if (info == NULL) 06661 return NULL; 06662 06663 AST_LIST_TRAVERSE_SAFE_BEGIN(&s->session->datastores, datastore, entry) { 06664 if (datastore->info != info) { 06665 continue; 06666 } 06667 06668 if (uid == NULL) { 06669 /* matched by type only */ 06670 break; 06671 } 06672 06673 if ((datastore->uid != NULL) && !strcasecmp(uid, datastore->uid)) { 06674 /* Matched by type AND uid */ 06675 break; 06676 } 06677 } 06678 AST_LIST_TRAVERSE_SAFE_END; 06679 06680 return datastore; 06681 }
int astman_datastore_remove | ( | struct mansession * | s, | |
struct ast_datastore * | datastore | |||
) |
Remove a datastore from a session.
0 | success | |
non-zero | failure |
Definition at line 6651 of file manager.c.
References AST_LIST_REMOVE, mansession_session::datastores, manager_channel_variable::entry, and mansession::session.
06652 { 06653 return AST_LIST_REMOVE(&s->session->datastores, datastore, entry) ? 0 : -1; 06654 }
int astman_is_authed | ( | uint32_t | ident | ) |
Determinie if a manager session ident is authenticated.
Definition at line 5134 of file manager.c.
References ao2_unlock, mansession_session::authenticated, find_session(), and unref_mansession().
Referenced by http_post_callback(), and static_callback().
05135 { 05136 int authed; 05137 struct mansession_session *session; 05138 05139 if (!(session = find_session(ident, 0))) 05140 return 0; 05141 05142 authed = (session->authenticated != 0); 05143 05144 ao2_unlock(session); 05145 unref_mansession(session); 05146 05147 return authed; 05148 }
int astman_verify_session_readpermissions | ( | uint32_t | ident, | |
int | perm | |||
) |
Verify a session's read permissions against a permission mask.
ident | session identity | |
perm | permission mask to verify |
1 | if the session has the permission mask capabilities | |
0 | otherwise |
Definition at line 5150 of file manager.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock, ao2_unlock, and unref_mansession().
05151 { 05152 int result = 0; 05153 struct mansession_session *session; 05154 struct ao2_iterator i; 05155 05156 if (ident == 0) { 05157 return 0; 05158 } 05159 05160 i = ao2_iterator_init(sessions, 0); 05161 while ((session = ao2_iterator_next(&i))) { 05162 ao2_lock(session); 05163 if ((session->managerid == ident) && (session->readperm & perm)) { 05164 result = 1; 05165 ao2_unlock(session); 05166 unref_mansession(session); 05167 break; 05168 } 05169 ao2_unlock(session); 05170 unref_mansession(session); 05171 } 05172 ao2_iterator_destroy(&i); 05173 return result; 05174 }
int astman_verify_session_writepermissions | ( | uint32_t | ident, | |
int | perm | |||
) |
Verify a session's write permissions against a permission mask.
ident | session identity | |
perm | permission mask to verify |
1 | if the session has the permission mask capabilities, otherwise 0 | |
0 | otherwise |
Definition at line 5176 of file manager.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock, ao2_unlock, and unref_mansession().
05177 { 05178 int result = 0; 05179 struct mansession_session *session; 05180 struct ao2_iterator i; 05181 05182 if (ident == 0) { 05183 return 0; 05184 } 05185 05186 i = ao2_iterator_init(sessions, 0); 05187 while ((session = ao2_iterator_next(&i))) { 05188 ao2_lock(session); 05189 if ((session->managerid == ident) && (session->writeperm & perm)) { 05190 result = 1; 05191 ao2_unlock(session); 05192 unref_mansession(session); 05193 break; 05194 } 05195 ao2_unlock(session); 05196 unref_mansession(session); 05197 } 05198 ao2_iterator_destroy(&i); 05199 return result; 05200 }
int init_manager | ( | void | ) |
Called by Asterisk initialization.
Definition at line 6634 of file manager.c.
References __init_manager().
Referenced by main().
06635 { 06636 return __init_manager(0); 06637 }
int reload_manager | ( | void | ) |
Called by Asterisk module functions and the CLI command.
Definition at line 6639 of file manager.c.
References __init_manager().
Referenced by handle_manager_reload().
06640 { 06641 return __init_manager(1); 06642 }