Data Structures | |
struct | fast_originate_helper |
struct | permalias |
Functions | |
static void * | accept_thread (void *ignore) |
static int | action_command (struct mansession *s, struct message *m) |
action_command: Manager command "command" - execute CLI command | |
static int | action_events (struct mansession *s, struct message *m) |
static int | action_extensionstate (struct mansession *s, struct message *m) |
static int | action_getvar (struct mansession *s, struct message *m) |
static int | action_hangup (struct mansession *s, struct message *m) |
static int | action_listcommands (struct mansession *s, struct message *m) |
static int | action_logoff (struct mansession *s, struct message *m) |
static int | action_mailboxcount (struct mansession *s, struct message *m) |
static int | action_mailboxstatus (struct mansession *s, struct message *m) |
static int | action_originate (struct mansession *s, struct message *m) |
static int | action_ping (struct mansession *s, struct message *m) |
static int | action_redirect (struct mansession *s, struct message *m) |
action_redirect: The redirect manager command | |
static int | action_setvar (struct mansession *s, struct message *m) |
static int | action_status (struct mansession *s, struct message *m) |
action_status: Manager "status" command to show channels | |
static int | action_timeout (struct mansession *s, struct message *m) |
static int | append_event (struct mansession *s, const char *str) |
int | ast_carefulwrite (int fd, char *s, int len, int timeoutms) |
static int | ast_instring (char *bigstr, char *smallstr, char delim) |
static int | ast_is_number (char *string) |
int | ast_manager_register2 (const char *action, int auth, int(*func)(struct mansession *s, struct message *m), 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 | |
static int | ast_manager_register_struct (struct manager_action *act) |
int | ast_manager_unregister (char *action) |
AST_MUTEX_DEFINE_STATIC (actionlock) | |
AST_MUTEX_DEFINE_STATIC (sessionlock) | |
static int | ast_strings_to_mask (char *string) |
char * | astman_get_header (struct message *m, char *var) |
ast_variable * | astman_get_variables (struct message *m) |
void | astman_send_ack (struct mansession *s, struct message *m, char *msg) |
void | astman_send_error (struct mansession *s, struct message *m, char *error) |
void | astman_send_response (struct mansession *s, struct message *m, char *resp, char *msg) |
static int | authenticate (struct mansession *s, struct message *m) |
static char * | authority_to_str (int authority, char *res, int reslen) |
static char * | complete_show_mancmd (char *line, char *word, int pos, int state) |
static void | destroy_session (struct mansession *s) |
static void * | fast_originate (void *data) |
static void | free_session (struct mansession *s) |
static int | get_input (struct mansession *s, char *output) |
static int | get_perm (char *instr) |
static int | handle_showmancmd (int fd, int argc, char *argv[]) |
static int | handle_showmancmds (int fd, int argc, char *argv[]) |
handle_showmancmds: CLI command | |
static int | handle_showmanconn (int fd, int argc, char *argv[]) |
handle_showmanconn: CLI command show manager connected | |
int | manager_event (int category, char *event, char *fmt,...) |
manager_event: Send AMI event to client | |
static int | manager_state_cb (char *context, char *exten, int state, void *data) |
static int | process_message (struct mansession *s, struct message *m) |
static void * | session_do (void *data) |
static int | set_eventmask (struct mansession *s, char *eventmask) |
Variables | |
static int | asock = -1 |
static int | block_sockets = 0 |
static int | displayconnects = 1 |
static int | enabled = 0 |
static struct manager_action * | first_action = NULL |
static char | mandescr_command [] |
static char | mandescr_events [] |
static char | mandescr_extensionstate [] |
static char | mandescr_getvar [] |
static char | mandescr_hangup [] |
static char | mandescr_listcommands [] |
static char | mandescr_logoff [] |
static char | mandescr_mailboxcount [] |
static char | mandescr_mailboxstatus [] |
Help text for manager command mailboxstatus. | |
static char | mandescr_originate [] |
static char | mandescr_ping [] |
PING: Manager PING. | |
static char | mandescr_redirect [] |
static char | mandescr_setvar [] |
static char | mandescr_timeout [] |
static struct permalias | perms [] |
static int | portno = DEFAULT_MANAGER_PORT |
static struct mansession * | sessions = NULL |
static struct ast_cli_entry | show_mancmd_cli |
static struct ast_cli_entry | show_mancmds_cli |
static struct ast_cli_entry | show_manconn_cli |
static char | showmancmd_help [] |
static char | showmancmds_help [] |
static char | showmanconn_help [] |
static pthread_t | t |
static void* accept_thread | ( | void * | ignore | ) | [static] |
Definition at line 1427 of file manager.c.
References asock, ast_log(), ast_mutex_init(), ast_mutex_lock(), ast_mutex_unlock(), ast_pthread_create, block_sockets, destroy_session(), LOG_NOTICE, LOG_WARNING, malloc, s, session_do(), and sessions.
Referenced by init_manager(), and reload_config().
01428 { 01429 int as; 01430 struct sockaddr_in sin; 01431 socklen_t sinlen; 01432 struct mansession *s; 01433 struct protoent *p; 01434 int arg = 1; 01435 int flags; 01436 pthread_attr_t attr; 01437 01438 pthread_attr_init(&attr); 01439 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 01440 01441 for (;;) { 01442 sinlen = sizeof(sin); 01443 as = accept(asock, (struct sockaddr *)&sin, &sinlen); 01444 if (as < 0) { 01445 ast_log(LOG_NOTICE, "Accept returned -1: %s\n", strerror(errno)); 01446 continue; 01447 } 01448 p = getprotobyname("tcp"); 01449 if (p) { 01450 if( setsockopt(as, p->p_proto, TCP_NODELAY, (char *)&arg, sizeof(arg) ) < 0 ) { 01451 ast_log(LOG_WARNING, "Failed to set manager tcp connection to TCP_NODELAY mode: %s\n", strerror(errno)); 01452 } 01453 } 01454 s = malloc(sizeof(struct mansession)); 01455 if (!s) { 01456 ast_log(LOG_WARNING, "Failed to allocate management session: %s\n", strerror(errno)); 01457 continue; 01458 } 01459 memset(s, 0, sizeof(struct mansession)); 01460 memcpy(&s->sin, &sin, sizeof(sin)); 01461 s->writetimeout = 100; 01462 01463 if(! block_sockets) { 01464 /* For safety, make sure socket is non-blocking */ 01465 flags = fcntl(as, F_GETFL); 01466 fcntl(as, F_SETFL, flags | O_NONBLOCK); 01467 } 01468 ast_mutex_init(&s->__lock); 01469 s->fd = as; 01470 s->send_events = -1; 01471 ast_mutex_lock(&sessionlock); 01472 s->next = sessions; 01473 sessions = s; 01474 ast_mutex_unlock(&sessionlock); 01475 if (ast_pthread_create(&s->t, &attr, session_do, s)) 01476 destroy_session(s); 01477 } 01478 pthread_attr_destroy(&attr); 01479 return NULL; 01480 }
static int action_command | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
action_command: Manager command "command" - execute CLI command
Definition at line 920 of file manager.c.
References ast_cli(), ast_cli_command(), ast_strlen_zero(), astman_get_header(), and s.
Referenced by init_manager().
00921 { 00922 char *cmd = astman_get_header(m, "Command"); 00923 char *id = astman_get_header(m, "ActionID"); 00924 ast_cli(s->fd, "Response: Follows\r\nPrivilege: Command\r\n"); 00925 if (!ast_strlen_zero(id)) 00926 ast_cli(s->fd, "ActionID: %s\r\n", id); 00927 /* FIXME: Wedge a ActionID response in here, waiting for later changes */ 00928 ast_cli_command(s->fd, cmd); 00929 ast_cli(s->fd, "--END COMMAND--\r\n\r\n"); 00930 return 0; 00931 }
static int action_events | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 628 of file manager.c.
References astman_get_header(), astman_send_response(), s, and set_eventmask().
Referenced by init_manager().
00629 { 00630 char *mask = astman_get_header(m, "EventMask"); 00631 int res; 00632 00633 res = set_eventmask(s, mask); 00634 if (res > 0) 00635 astman_send_response(s, m, "Events On", NULL); 00636 else if (res == 0) 00637 astman_send_response(s, m, "Events Off", NULL); 00638 00639 return 0; 00640 }
static int action_extensionstate | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 1180 of file manager.c.
References ast_cli(), ast_extension_state(), ast_get_hint(), ast_strlen_zero(), astman_get_header(), astman_send_error(), context, exten, and s.
Referenced by init_manager().
01181 { 01182 char *exten = astman_get_header(m, "Exten"); 01183 char *context = astman_get_header(m, "Context"); 01184 char *id = astman_get_header(m,"ActionID"); 01185 char idText[256] = ""; 01186 char hint[256] = ""; 01187 int status; 01188 if (ast_strlen_zero(exten)) { 01189 astman_send_error(s, m, "Extension not specified"); 01190 return 0; 01191 } 01192 if (ast_strlen_zero(context)) 01193 context = "default"; 01194 status = ast_extension_state(NULL, context, exten); 01195 ast_get_hint(hint, sizeof(hint) - 1, NULL, 0, NULL, context, exten); 01196 if (!ast_strlen_zero(id)) { 01197 snprintf(idText,256,"ActionID: %s\r\n",id); 01198 } 01199 ast_cli(s->fd, "Response: Success\r\n" 01200 "%s" 01201 "Message: Extension Status\r\n" 01202 "Exten: %s\r\n" 01203 "Context: %s\r\n" 01204 "Hint: %s\r\n" 01205 "Status: %d\r\n\r\n", 01206 idText,exten, context, hint, status); 01207 return 0; 01208 }
static int action_getvar | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 725 of file manager.c.
References ast_cli(), ast_get_channel_by_name_locked(), ast_mutex_unlock(), ast_strdupa, ast_strlen_zero(), astman_get_header(), astman_send_error(), ast_channel::lock, name, pbx_builtin_getvar_helper(), and s.
Referenced by init_manager().
00726 { 00727 struct ast_channel *c = NULL; 00728 char *name = astman_get_header(m, "Channel"); 00729 char *varname = astman_get_header(m, "Variable"); 00730 char *id = astman_get_header(m,"ActionID"); 00731 char *varval; 00732 char *varval2=NULL; 00733 00734 if (!strlen(varname)) { 00735 astman_send_error(s, m, "No variable specified"); 00736 return 0; 00737 } 00738 00739 if (strlen(name)) { 00740 c = ast_get_channel_by_name_locked(name); 00741 if (!c) { 00742 astman_send_error(s, m, "No such channel"); 00743 return 0; 00744 } 00745 } 00746 00747 varval=pbx_builtin_getvar_helper(c,varname); 00748 if (varval) 00749 varval2 = ast_strdupa(varval); 00750 if (!varval2) 00751 varval2 = ""; 00752 if (c) 00753 ast_mutex_unlock(&c->lock); 00754 ast_cli(s->fd, "Response: Success\r\n" 00755 "Variable: %s\r\nValue: %s\r\n" ,varname,varval2); 00756 if (!ast_strlen_zero(id)) 00757 ast_cli(s->fd, "ActionID: %s\r\n",id); 00758 ast_cli(s->fd, "\r\n"); 00759 00760 return 0; 00761 }
static int action_hangup | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 657 of file manager.c.
References ast_get_channel_by_name_locked(), ast_mutex_unlock(), ast_softhangup(), AST_SOFTHANGUP_EXPLICIT, ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), ast_channel::lock, name, and s.
Referenced by init_manager().
00658 { 00659 struct ast_channel *c = NULL; 00660 char *name = astman_get_header(m, "Channel"); 00661 if (ast_strlen_zero(name)) { 00662 astman_send_error(s, m, "No channel specified"); 00663 return 0; 00664 } 00665 c = ast_get_channel_by_name_locked(name); 00666 if (!c) { 00667 astman_send_error(s, m, "No such channel"); 00668 return 0; 00669 } 00670 ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT); 00671 ast_mutex_unlock(&c->lock); 00672 astman_send_ack(s, m, "Channel Hungup"); 00673 return 0; 00674 }
static int action_listcommands | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 598 of file manager.c.
References manager_action::action, ast_cli(), ast_mutex_lock(), ast_mutex_unlock(), ast_strlen_zero(), astman_get_header(), manager_action::authority, authority_to_str(), first_action, manager_action::next, s, and manager_action::synopsis.
Referenced by init_manager().
00599 { 00600 struct manager_action *cur = first_action; 00601 char idText[256] = ""; 00602 char temp[BUFSIZ]; 00603 char *id = astman_get_header(m,"ActionID"); 00604 00605 if (!ast_strlen_zero(id)) 00606 snprintf(idText,256,"ActionID: %s\r\n",id); 00607 ast_cli(s->fd, "Response: Success\r\n%s", idText); 00608 ast_mutex_lock(&actionlock); 00609 while (cur) { /* Walk the list of actions */ 00610 if ((s->writeperm & cur->authority) == cur->authority) 00611 ast_cli(s->fd, "%s: %s (Priv: %s)\r\n", cur->action, cur->synopsis, authority_to_str(cur->authority, temp, sizeof(temp)) ); 00612 cur = cur->next; 00613 } 00614 ast_mutex_unlock(&actionlock); 00615 ast_cli(s->fd, "\r\n"); 00616 00617 return 0; 00618 }
static int action_logoff | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 646 of file manager.c.
References astman_send_response(), and s.
Referenced by init_manager().
00647 { 00648 astman_send_response(s, m, "Goodbye", "Thanks for all the fish."); 00649 return -1; 00650 }
static int action_mailboxcount | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 1144 of file manager.c.
References ast_app_messagecount(), ast_cli(), ast_strlen_zero(), astman_get_header(), astman_send_error(), mailbox, and s.
Referenced by init_manager().
01145 { 01146 char *mailbox = astman_get_header(m, "Mailbox"); 01147 char *id = astman_get_header(m,"ActionID"); 01148 char idText[256] = ""; 01149 int newmsgs = 0, oldmsgs = 0; 01150 if (ast_strlen_zero(mailbox)) { 01151 astman_send_error(s, m, "Mailbox not specified"); 01152 return 0; 01153 } 01154 ast_app_messagecount(mailbox, &newmsgs, &oldmsgs); 01155 if (!ast_strlen_zero(id)) { 01156 snprintf(idText,256,"ActionID: %s\r\n",id); 01157 } 01158 ast_cli(s->fd, "Response: Success\r\n" 01159 "%s" 01160 "Message: Mailbox Message Count\r\n" 01161 "Mailbox: %s\r\n" 01162 "NewMessages: %d\r\n" 01163 "OldMessages: %d\r\n" 01164 "\r\n", 01165 idText,mailbox, newmsgs, oldmsgs); 01166 return 0; 01167 }
static int action_mailboxstatus | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 1112 of file manager.c.
References ast_app_has_voicemail(), ast_cli(), ast_strlen_zero(), astman_get_header(), astman_send_error(), mailbox, and s.
Referenced by init_manager().
01113 { 01114 char *mailbox = astman_get_header(m, "Mailbox"); 01115 char *id = astman_get_header(m,"ActionID"); 01116 char idText[256] = ""; 01117 int ret; 01118 if (ast_strlen_zero(mailbox)) { 01119 astman_send_error(s, m, "Mailbox not specified"); 01120 return 0; 01121 } 01122 if (!ast_strlen_zero(id)) 01123 snprintf(idText,256,"ActionID: %s\r\n",id); 01124 ret = ast_app_has_voicemail(mailbox, NULL); 01125 ast_cli(s->fd, "Response: Success\r\n" 01126 "%s" 01127 "Message: Mailbox Status\r\n" 01128 "Mailbox: %s\r\n" 01129 "Waiting: %d\r\n\r\n", idText, mailbox, ret); 01130 return 0; 01131 }
static int action_originate | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 995 of file manager.c.
References fast_originate_helper::account, fast_originate_helper::app, app, fast_originate_helper::appdata, ast_callerid_parse(), AST_FORMAT_SLINEAR, ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_pthread_create, ast_shrink_phone_number(), ast_strlen_zero(), ast_true(), astman_get_header(), astman_get_variables(), astman_send_ack(), astman_send_error(), fast_originate_helper::cid_name, fast_originate_helper::cid_num, fast_originate_helper::context, context, fast_originate_helper::data, fast_originate_helper::exten, exten, fast_originate(), fast_originate_helper::idtext, malloc, n, name, fast_originate_helper::priority, ast_channel::priority, s, fast_originate_helper::tech, fast_originate_helper::timeout, and fast_originate_helper::vars.
Referenced by init_manager().
00996 { 00997 char *name = astman_get_header(m, "Channel"); 00998 char *exten = astman_get_header(m, "Exten"); 00999 char *context = astman_get_header(m, "Context"); 01000 char *priority = astman_get_header(m, "Priority"); 01001 char *timeout = astman_get_header(m, "Timeout"); 01002 char *callerid = astman_get_header(m, "CallerID"); 01003 char *account = astman_get_header(m, "Account"); 01004 char *app = astman_get_header(m, "Application"); 01005 char *appdata = astman_get_header(m, "Data"); 01006 char *async = astman_get_header(m, "Async"); 01007 char *id = astman_get_header(m, "ActionID"); 01008 struct ast_variable *vars = astman_get_variables(m); 01009 char *tech, *data; 01010 char *l=NULL, *n=NULL; 01011 int pi = 0; 01012 int res; 01013 int to = 30000; 01014 int reason = 0; 01015 char tmp[256]; 01016 char tmp2[256]; 01017 01018 pthread_t th; 01019 pthread_attr_t attr; 01020 if (!name) { 01021 astman_send_error(s, m, "Channel not specified"); 01022 return 0; 01023 } 01024 if (!ast_strlen_zero(priority) && (sscanf(priority, "%d", &pi) != 1)) { 01025 astman_send_error(s, m, "Invalid priority\n"); 01026 return 0; 01027 } 01028 if (!ast_strlen_zero(timeout) && (sscanf(timeout, "%d", &to) != 1)) { 01029 astman_send_error(s, m, "Invalid timeout\n"); 01030 return 0; 01031 } 01032 ast_copy_string(tmp, name, sizeof(tmp)); 01033 tech = tmp; 01034 data = strchr(tmp, '/'); 01035 if (!data) { 01036 astman_send_error(s, m, "Invalid channel\n"); 01037 return 0; 01038 } 01039 *data = '\0'; 01040 data++; 01041 ast_copy_string(tmp2, callerid, sizeof(tmp2)); 01042 ast_callerid_parse(tmp2, &n, &l); 01043 if (n) { 01044 if (ast_strlen_zero(n)) 01045 n = NULL; 01046 } 01047 if (l) { 01048 ast_shrink_phone_number(l); 01049 if (ast_strlen_zero(l)) 01050 l = NULL; 01051 } 01052 if (ast_true(async)) { 01053 struct fast_originate_helper *fast = malloc(sizeof(struct fast_originate_helper)); 01054 if (!fast) { 01055 res = -1; 01056 } else { 01057 memset(fast, 0, sizeof(struct fast_originate_helper)); 01058 if (!ast_strlen_zero(id)) 01059 snprintf(fast->idtext, sizeof(fast->idtext), "ActionID: %s\r\n", id); 01060 ast_copy_string(fast->tech, tech, sizeof(fast->tech)); 01061 ast_copy_string(fast->data, data, sizeof(fast->data)); 01062 ast_copy_string(fast->app, app, sizeof(fast->app)); 01063 ast_copy_string(fast->appdata, appdata, sizeof(fast->appdata)); 01064 if (l) 01065 ast_copy_string(fast->cid_num, l, sizeof(fast->cid_num)); 01066 if (n) 01067 ast_copy_string(fast->cid_name, n, sizeof(fast->cid_name)); 01068 fast->vars = vars; 01069 ast_copy_string(fast->context, context, sizeof(fast->context)); 01070 ast_copy_string(fast->exten, exten, sizeof(fast->exten)); 01071 ast_copy_string(fast->account, account, sizeof(fast->account)); 01072 fast->timeout = to; 01073 fast->priority = pi; 01074 pthread_attr_init(&attr); 01075 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 01076 if (ast_pthread_create(&th, &attr, fast_originate, fast)) { 01077 res = -1; 01078 } else { 01079 res = 0; 01080 } 01081 } 01082 } else if (!ast_strlen_zero(app)) { 01083 res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL); 01084 } else { 01085 if (exten && context && pi) 01086 res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL); 01087 else { 01088 astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'"); 01089 return 0; 01090 } 01091 } 01092 if (!res) 01093 astman_send_ack(s, m, "Originate successfully queued"); 01094 else 01095 astman_send_error(s, m, "Originate failed"); 01096 return 0; 01097 }
static int action_ping | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 587 of file manager.c.
References astman_send_response(), and s.
Referenced by init_manager().
00588 { 00589 astman_send_response(s, m, "Pong", NULL); 00590 return 0; 00591 }
static int action_redirect | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
action_redirect: The redirect manager command
Definition at line 863 of file manager.c.
References ast_async_goto(), ast_get_channel_by_name_locked(), ast_mutex_unlock(), ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), context, exten, ast_channel::lock, name, and s.
Referenced by init_manager().
00864 { 00865 char *name = astman_get_header(m, "Channel"); 00866 char *name2 = astman_get_header(m, "ExtraChannel"); 00867 char *exten = astman_get_header(m, "Exten"); 00868 char *context = astman_get_header(m, "Context"); 00869 char *priority = astman_get_header(m, "Priority"); 00870 struct ast_channel *chan, *chan2 = NULL; 00871 int pi = 0; 00872 int res; 00873 00874 if (ast_strlen_zero(name)) { 00875 astman_send_error(s, m, "Channel not specified"); 00876 return 0; 00877 } 00878 if (!ast_strlen_zero(priority) && (sscanf(priority, "%d", &pi) != 1)) { 00879 astman_send_error(s, m, "Invalid priority\n"); 00880 return 0; 00881 } 00882 chan = ast_get_channel_by_name_locked(name); 00883 if (!chan) { 00884 char buf[BUFSIZ]; 00885 snprintf(buf, sizeof(buf), "Channel does not exist: %s", name); 00886 astman_send_error(s, m, buf); 00887 return 0; 00888 } 00889 if (!ast_strlen_zero(name2)) 00890 chan2 = ast_get_channel_by_name_locked(name2); 00891 res = ast_async_goto(chan, context, exten, pi); 00892 if (!res) { 00893 if (!ast_strlen_zero(name2)) { 00894 if (chan2) 00895 res = ast_async_goto(chan2, context, exten, pi); 00896 else 00897 res = -1; 00898 if (!res) 00899 astman_send_ack(s, m, "Dual Redirect successful"); 00900 else 00901 astman_send_error(s, m, "Secondary redirect failed"); 00902 } else 00903 astman_send_ack(s, m, "Redirect successful"); 00904 } else 00905 astman_send_error(s, m, "Redirect failed"); 00906 if (chan) 00907 ast_mutex_unlock(&chan->lock); 00908 if (chan2) 00909 ast_mutex_unlock(&chan2->lock); 00910 return 0; 00911 }
static int action_setvar | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 683 of file manager.c.
References ast_get_channel_by_name_locked(), ast_mutex_unlock(), ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), ast_channel::lock, name, pbx_builtin_setvar_helper(), and s.
Referenced by init_manager().
00684 { 00685 struct ast_channel *c = NULL; 00686 char *name = astman_get_header(m, "Channel"); 00687 char *varname = astman_get_header(m, "Variable"); 00688 char *varval = astman_get_header(m, "Value"); 00689 00690 if (ast_strlen_zero(varname)) { 00691 astman_send_error(s, m, "No variable specified"); 00692 return 0; 00693 } 00694 00695 if (ast_strlen_zero(varval)) { 00696 astman_send_error(s, m, "No value specified"); 00697 return 0; 00698 } 00699 00700 if (!ast_strlen_zero(name)) { 00701 c = ast_get_channel_by_name_locked(name); 00702 if (!c) { 00703 astman_send_error(s, m, "No such channel"); 00704 return 0; 00705 } 00706 } 00707 00708 pbx_builtin_setvar_helper(c, varname, varval); 00709 00710 if (c) 00711 ast_mutex_unlock(&c->lock); 00712 00713 astman_send_ack(s, m, "Variable Set"); 00714 00715 return 0; 00716 }
static int action_status | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
action_status: Manager "status" command to show channels
Definition at line 766 of file manager.c.
References ast_channel::_bridge, ast_channel::_state, ast_channel::accountcode, ast_channel_walk_locked(), ast_cli(), ast_get_channel_by_name_locked(), ast_mutex_unlock(), ast_state2str(), ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), ast_channel::cdr, ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ast_channel::context, ast_channel::exten, ast_channel::lock, ast_channel::name, name, ast_channel::pbx, ast_channel::priority, s, ast_cdr::start, and ast_channel::uniqueid.
Referenced by init_manager().
00767 { 00768 char *id = astman_get_header(m,"ActionID"); 00769 char *name = astman_get_header(m,"Channel"); 00770 char idText[256] = ""; 00771 struct ast_channel *c; 00772 char bridge[256]; 00773 struct timeval now = ast_tvnow(); 00774 long elapsed_seconds=0; 00775 int all = ast_strlen_zero(name); /* set if we want all channels */ 00776 00777 astman_send_ack(s, m, "Channel status will follow"); 00778 if (!ast_strlen_zero(id)) 00779 snprintf(idText,256,"ActionID: %s\r\n",id); 00780 if (all) 00781 c = ast_channel_walk_locked(NULL); 00782 else { 00783 c = ast_get_channel_by_name_locked(name); 00784 if (!c) { 00785 astman_send_error(s, m, "No such channel"); 00786 return 0; 00787 } 00788 } 00789 /* if we look by name, we break after the first iteration */ 00790 while(c) { 00791 if (c->_bridge) 00792 snprintf(bridge, sizeof(bridge), "Link: %s\r\n", c->_bridge->name); 00793 else 00794 bridge[0] = '\0'; 00795 if (c->pbx) { 00796 if (c->cdr) { 00797 elapsed_seconds = now.tv_sec - c->cdr->start.tv_sec; 00798 } 00799 ast_cli(s->fd, 00800 "Event: Status\r\n" 00801 "Privilege: Call\r\n" 00802 "Channel: %s\r\n" 00803 "CallerID: %s\r\n" 00804 "CallerIDName: %s\r\n" 00805 "Account: %s\r\n" 00806 "State: %s\r\n" 00807 "Context: %s\r\n" 00808 "Extension: %s\r\n" 00809 "Priority: %d\r\n" 00810 "Seconds: %ld\r\n" 00811 "%s" 00812 "Uniqueid: %s\r\n" 00813 "%s" 00814 "\r\n", 00815 c->name, 00816 c->cid.cid_num ? c->cid.cid_num : "<unknown>", 00817 c->cid.cid_name ? c->cid.cid_name : "<unknown>", 00818 c->accountcode, 00819 ast_state2str(c->_state), c->context, 00820 c->exten, c->priority, (long)elapsed_seconds, bridge, c->uniqueid, idText); 00821 } else { 00822 ast_cli(s->fd, 00823 "Event: Status\r\n" 00824 "Privilege: Call\r\n" 00825 "Channel: %s\r\n" 00826 "CallerID: %s\r\n" 00827 "CallerIDName: %s\r\n" 00828 "Account: %s\r\n" 00829 "State: %s\r\n" 00830 "%s" 00831 "Uniqueid: %s\r\n" 00832 "%s" 00833 "\r\n", 00834 c->name, 00835 c->cid.cid_num ? c->cid.cid_num : "<unknown>", 00836 c->cid.cid_name ? c->cid.cid_name : "<unknown>", 00837 c->accountcode, 00838 ast_state2str(c->_state), bridge, c->uniqueid, idText); 00839 } 00840 ast_mutex_unlock(&c->lock); 00841 if (!all) 00842 break; 00843 c = ast_channel_walk_locked(c); 00844 } 00845 ast_cli(s->fd, 00846 "Event: StatusComplete\r\n" 00847 "%s" 00848 "\r\n",idText); 00849 return 0; 00850 }
static int action_timeout | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 1217 of file manager.c.
References ast_channel_setwhentohangup(), ast_get_channel_by_name_locked(), ast_mutex_unlock(), ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), ast_channel::lock, name, and s.
Referenced by init_manager().
01218 { 01219 struct ast_channel *c = NULL; 01220 char *name = astman_get_header(m, "Channel"); 01221 int timeout = atoi(astman_get_header(m, "Timeout")); 01222 if (ast_strlen_zero(name)) { 01223 astman_send_error(s, m, "No channel specified"); 01224 return 0; 01225 } 01226 if (!timeout) { 01227 astman_send_error(s, m, "No timeout specified"); 01228 return 0; 01229 } 01230 c = ast_get_channel_by_name_locked(name); 01231 if (!c) { 01232 astman_send_error(s, m, "No such channel"); 01233 return 0; 01234 } 01235 ast_channel_setwhentohangup(c, timeout); 01236 ast_mutex_unlock(&c->lock); 01237 astman_send_ack(s, m, "Timeout Set"); 01238 return 0; 01239 }
static int append_event | ( | struct mansession * | s, | |
const char * | str | |||
) | [static] |
Definition at line 1482 of file manager.c.
References eventqent::eventdata, malloc, eventqent::next, and s.
Referenced by manager_event().
01483 { 01484 struct eventqent *tmp, *prev=NULL; 01485 tmp = malloc(sizeof(struct eventqent) + strlen(str)); 01486 if (tmp) { 01487 tmp->next = NULL; 01488 strcpy(tmp->eventdata, str); 01489 if (s->eventq) { 01490 prev = s->eventq; 01491 while(prev->next) 01492 prev = prev->next; 01493 prev->next = tmp; 01494 } else { 01495 s->eventq = tmp; 01496 } 01497 return 0; 01498 } 01499 return -1; 01500 }
int ast_carefulwrite | ( | int | fd, | |
char * | s, | |||
int | len, | |||
int | timeoutms | |||
) |
If you are calling ast_carefulwrite, it is assumed that you are calling it on a file descriptor that _DOES_ have NONBLOCK set. This way, there is only one system call made to do a write, unless we actually have a need to wait. This way, we get better performance.
Definition at line 114 of file manager.c.
References pollfd::events, pollfd::fd, poll(), and POLLOUT.
Referenced by agi_debug_cli(), ast_cli(), manager_event(), and process_message().
00115 { 00116 /* Try to write string, but wait no more than ms milliseconds 00117 before timing out */ 00118 int res=0; 00119 struct pollfd fds[1]; 00120 while(len) { 00121 res = write(fd, s, len); 00122 if ((res < 0) && (errno != EAGAIN)) { 00123 return -1; 00124 } 00125 if (res < 0) res = 0; 00126 len -= res; 00127 s += res; 00128 res = 0; 00129 if (len) { 00130 fds[0].fd = fd; 00131 fds[0].events = POLLOUT; 00132 /* Wait until writable again */ 00133 res = poll(fds, 1, timeoutms); 00134 if (res < 1) 00135 return -1; 00136 } 00137 } 00138 return res; 00139 }
static int ast_instring | ( | char * | bigstr, | |
char * | smallstr, | |||
char | delim | |||
) | [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 395 of file manager.c.
References ast_variable::next.
Referenced by ast_strings_to_mask(), and get_perm().
00396 { 00397 char *val = bigstr, *next; 00398 00399 do { 00400 if ((next = strchr(val, delim))) { 00401 if (!strncmp(val, smallstr, (next - val))) 00402 return 1; 00403 else 00404 continue; 00405 } else 00406 return !strcmp(smallstr, val); 00407 00408 } while (*(val = (next + 1))); 00409 00410 return 0; 00411 }
static int ast_is_number | ( | char * | string | ) | [static] |
Definition at line 427 of file manager.c.
Referenced by ast_strings_to_mask().
00428 { 00429 int ret = 1, x = 0; 00430 00431 if (!string) 00432 return 0; 00433 00434 for (x=0; x < strlen(string); x++) { 00435 if (!(string[x] >= 48 && string[x] <= 57)) { 00436 ret = 0; 00437 break; 00438 } 00439 } 00440 00441 return ret ? atoi(string) : 0; 00442 }
int ast_manager_register2 | ( | const char * | action, | |
int | authority, | |||
int(*)(struct mansession *s, struct message *m) | func, | |||
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
action | Name of the requested Action: | |
authority | Required authority for this command | |
func | Function to call for this command | |
synopsis | Help text (one line, up to 30 chars) for CLI manager show commands | |
description | Help text, several lines |
Definition at line 1619 of file manager.c.
References manager_action::action, ast_log(), ast_manager_register_struct(), manager_action::authority, manager_action::description, manager_action::func, LOG_WARNING, malloc, manager_action::next, and manager_action::synopsis.
Referenced by init_manager(), and load_module().
01620 { 01621 struct manager_action *cur; 01622 01623 cur = malloc(sizeof(struct manager_action)); 01624 if (!cur) { 01625 ast_log(LOG_WARNING, "Manager: out of memory trying to register action\n"); 01626 return -1; 01627 } 01628 cur->action = action; 01629 cur->authority = auth; 01630 cur->func = func; 01631 cur->synopsis = synopsis; 01632 cur->description = description; 01633 cur->next = NULL; 01634 01635 ast_manager_register_struct(cur); 01636 01637 return 0; 01638 }
static int ast_manager_register_struct | ( | struct manager_action * | act | ) | [static] |
Definition at line 1576 of file manager.c.
References manager_action::action, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), first_action, LOG_WARNING, manager_action::next, and option_verbose.
Referenced by ast_manager_register2().
01577 { 01578 struct manager_action *cur = first_action, *prev = NULL; 01579 int ret; 01580 01581 ast_mutex_lock(&actionlock); 01582 while(cur) { /* Walk the list of actions */ 01583 ret = strcasecmp(cur->action, act->action); 01584 if (ret == 0) { 01585 ast_log(LOG_WARNING, "Manager: Action '%s' already registered\n", act->action); 01586 ast_mutex_unlock(&actionlock); 01587 return -1; 01588 } else if (ret > 0) { 01589 /* Insert these alphabetically */ 01590 if (prev) { 01591 act->next = prev->next; 01592 prev->next = act; 01593 } else { 01594 act->next = first_action; 01595 first_action = act; 01596 } 01597 break; 01598 } 01599 prev = cur; 01600 cur = cur->next; 01601 } 01602 01603 if (!cur) { 01604 if (prev) 01605 prev->next = act; 01606 else 01607 first_action = act; 01608 act->next = NULL; 01609 } 01610 01611 if (option_verbose > 1) 01612 ast_verbose(VERBOSE_PREFIX_2 "Manager registered action %s\n", act->action); 01613 ast_mutex_unlock(&actionlock); 01614 return 0; 01615 }
int ast_manager_unregister | ( | char * | action | ) |
action | Name of registred Action: |
Definition at line 1548 of file manager.c.
References manager_action::action, ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), first_action, free, manager_action::next, and option_verbose.
Referenced by __unload_module(), and unload_module().
01549 { 01550 struct manager_action *cur = first_action, *prev = first_action; 01551 01552 ast_mutex_lock(&actionlock); 01553 while( cur ) { 01554 if (!strcasecmp(action, cur->action)) { 01555 prev->next = cur->next; 01556 free(cur); 01557 if (option_verbose > 1) 01558 ast_verbose(VERBOSE_PREFIX_2 "Manager unregistered action %s\n", action); 01559 ast_mutex_unlock(&actionlock); 01560 return 0; 01561 } 01562 prev = cur; 01563 cur = cur->next; 01564 } 01565 ast_mutex_unlock(&actionlock); 01566 return 0; 01567 }
AST_MUTEX_DEFINE_STATIC | ( | actionlock | ) |
AST_MUTEX_DEFINE_STATIC | ( | sessionlock | ) |
static int ast_strings_to_mask | ( | char * | string | ) | [static] |
Definition at line 444 of file manager.c.
References ast_false(), ast_instring(), ast_is_number(), ast_strlen_zero(), ast_true(), and perms.
Referenced by set_eventmask().
00445 { 00446 int x, ret = -1; 00447 00448 x = ast_is_number(string); 00449 00450 if (x) { 00451 ret = x; 00452 } else if (ast_strlen_zero(string)) { 00453 ret = -1; 00454 } else if (ast_false(string)) { 00455 ret = 0; 00456 } else if (ast_true(string)) { 00457 ret = 0; 00458 for (x=0; x<sizeof(perms) / sizeof(perms[0]); x++) 00459 ret |= perms[x].num; 00460 } else { 00461 ret = 0; 00462 for (x=0; x<sizeof(perms) / sizeof(perms[0]); x++) { 00463 if (ast_instring(string, perms[x].label, ',')) 00464 ret |= perms[x].num; 00465 } 00466 } 00467 00468 return ret; 00469 }
char* astman_get_header | ( | struct message * | m, | |
char * | var | |||
) |
Get header from mananger transaction
Definition at line 305 of file manager.c.
References message::hdrcount, and message::headers.
Referenced by _sip_show_peers(), action_agent_callback_login(), action_agent_logoff(), action_agents(), action_command(), action_events(), action_extensionstate(), action_getvar(), action_hangup(), action_listcommands(), action_mailboxcount(), action_mailboxstatus(), action_originate(), action_redirect(), action_setcdruserfield(), action_setvar(), action_status(), action_timeout(), action_transfer(), action_transferhangup(), action_zapdialoffhook(), action_zapdndoff(), action_zapdndon(), action_zapshowchannels(), astman_send_error(), astman_send_response(), authenticate(), change_monitor_action(), manager_add_queue_member(), manager_dbget(), manager_dbput(), manager_iax2_show_peers(), manager_parking_status(), manager_pause_queue_member(), manager_play_dtmf(), manager_queues_status(), manager_remove_queue_member(), manager_sip_show_peer(), manager_sip_show_peers(), process_message(), start_monitor_action(), and stop_monitor_action().
00306 { 00307 char cmp[80]; 00308 int x; 00309 snprintf(cmp, sizeof(cmp), "%s: ", var); 00310 for (x=0;x<m->hdrcount;x++) 00311 if (!strncasecmp(cmp, m->headers[x], strlen(cmp))) 00312 return m->headers[x] + strlen(cmp); 00313 return ""; 00314 }
struct ast_variable* astman_get_variables | ( | struct message * | m | ) |
Get a linked list of the Variable: headers
Definition at line 316 of file manager.c.
References ast_app_separate_args(), ast_strdupa, ast_strlen_zero(), ast_variable_new(), message::hdrcount, message::headers, strsep(), and var.
Referenced by action_originate().
00317 { 00318 int varlen, x, y; 00319 struct ast_variable *head = NULL, *cur; 00320 char *var, *val; 00321 unsigned int var_count; 00322 char *vars[32]; 00323 00324 varlen = strlen("Variable: "); 00325 00326 for (x = 0; x < m->hdrcount; x++) { 00327 if (strncasecmp("Variable: ", m->headers[x], varlen)) 00328 continue; 00329 00330 if (!(var = ast_strdupa(m->headers[x] + varlen))) 00331 return head; 00332 00333 if ((var_count = ast_app_separate_args(var, '|', vars, sizeof(vars) / sizeof(vars[0])))) { 00334 for (y = 0; y < var_count; y++) { 00335 if (!vars[y]) 00336 continue; 00337 var = val = ast_strdupa(vars[y]); 00338 strsep(&val, "="); 00339 if (!val || ast_strlen_zero(var)) 00340 continue; 00341 cur = ast_variable_new(var, val); 00342 if (head) { 00343 cur->next = head; 00344 head = cur; 00345 } else 00346 head = cur; 00347 } 00348 } 00349 } 00350 00351 return head; 00352 }
void astman_send_ack | ( | struct mansession * | s, | |
struct message * | m, | |||
char * | msg | |||
) |
Definition at line 385 of file manager.c.
References astman_send_response(), and s.
Referenced by action_agent_callback_login(), action_agent_logoff(), action_agents(), action_hangup(), action_originate(), action_redirect(), action_setcdruserfield(), action_setvar(), action_status(), action_timeout(), action_transfer(), action_transferhangup(), action_zapdialoffhook(), action_zapdndoff(), action_zapdndon(), action_zaprestart(), action_zapshowchannels(), change_monitor_action(), manager_add_queue_member(), manager_dbget(), manager_dbput(), manager_parking_status(), manager_pause_queue_member(), manager_play_dtmf(), manager_queues_status(), manager_remove_queue_member(), manager_sip_show_peers(), process_message(), start_monitor_action(), and stop_monitor_action().
00386 { 00387 astman_send_response(s, m, "Success", msg); 00388 }
void astman_send_error | ( | struct mansession * | s, | |
struct message * | m, | |||
char * | error | |||
) |
NOTE: Callers of astman_send_error(), astman_send_response() or astman_send_ack() must EITHER hold the session lock _or_ be running in an action callback (in which case s->busy will be non-zero). In either of these cases, there is no need to lock-protect the session's fd, since no other output will be sent (events will be queued), and no input will be read until either the current action finishes or get_input() obtains the session lock.
Definition at line 362 of file manager.c.
References ast_cli(), ast_strlen_zero(), astman_get_header(), and s.
Referenced by _sip_show_peer(), action_agent_callback_login(), action_agent_logoff(), action_extensionstate(), action_getvar(), action_hangup(), action_mailboxcount(), action_mailboxstatus(), action_originate(), action_redirect(), action_setcdruserfield(), action_setvar(), action_status(), action_timeout(), action_transfer(), action_transferhangup(), action_zapdialoffhook(), action_zapdndoff(), action_zapdndon(), action_zaprestart(), change_monitor_action(), manager_add_queue_member(), manager_dbget(), manager_dbput(), manager_pause_queue_member(), manager_play_dtmf(), manager_remove_queue_member(), manager_sip_show_peer(), process_message(), start_monitor_action(), and stop_monitor_action().
00363 { 00364 char *id = astman_get_header(m,"ActionID"); 00365 00366 ast_cli(s->fd, "Response: Error\r\n"); 00367 if (!ast_strlen_zero(id)) 00368 ast_cli(s->fd, "ActionID: %s\r\n",id); 00369 ast_cli(s->fd, "Message: %s\r\n\r\n", error); 00370 }
void astman_send_response | ( | struct mansession * | s, | |
struct message * | m, | |||
char * | resp, | |||
char * | msg | |||
) |
Definition at line 372 of file manager.c.
References ast_cli(), ast_strlen_zero(), astman_get_header(), and s.
Referenced by action_events(), action_logoff(), action_ping(), and astman_send_ack().
00373 { 00374 char *id = astman_get_header(m,"ActionID"); 00375 00376 ast_cli(s->fd, "Response: %s\r\n", resp); 00377 if (!ast_strlen_zero(id)) 00378 ast_cli(s->fd, "ActionID: %s\r\n",id); 00379 if (msg) 00380 ast_cli(s->fd, "Message: %s\r\n\r\n", msg); 00381 else 00382 ast_cli(s->fd, "\r\n"); 00383 }
static int authenticate | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 488 of file manager.c.
References ast_append_ha(), ast_apply_ha(), ast_category_browse(), ast_config_destroy(), ast_config_load(), ast_free_ha(), ast_inet_ntoa(), ast_log(), ast_strlen_zero(), ast_variable_browse(), ast_variable_retrieve(), astman_get_header(), cfg, events, get_perm(), key(), ast_variable::lineno, LOG_NOTICE, LOG_WARNING, MD5Final(), MD5Init(), MD5Update(), ast_variable::name, ast_variable::next, pass, password, s, set_eventmask(), user, and ast_variable::value.
Referenced by authenticate_reply(), handle_response_invite(), process_message(), and registry_rerequest().
00489 { 00490 struct ast_config *cfg; 00491 char iabuf[INET_ADDRSTRLEN]; 00492 char *cat; 00493 char *user = astman_get_header(m, "Username"); 00494 char *pass = astman_get_header(m, "Secret"); 00495 char *authtype = astman_get_header(m, "AuthType"); 00496 char *key = astman_get_header(m, "Key"); 00497 char *events = astman_get_header(m, "Events"); 00498 00499 cfg = ast_config_load("manager.conf"); 00500 if (!cfg) 00501 return -1; 00502 cat = ast_category_browse(cfg, NULL); 00503 while(cat) { 00504 if (strcasecmp(cat, "general")) { 00505 /* This is a user */ 00506 if (!strcasecmp(cat, user)) { 00507 struct ast_variable *v; 00508 struct ast_ha *ha = NULL; 00509 char *password = NULL; 00510 v = ast_variable_browse(cfg, cat); 00511 while (v) { 00512 if (!strcasecmp(v->name, "secret")) { 00513 password = v->value; 00514 } else if (!strcasecmp(v->name, "permit") || 00515 !strcasecmp(v->name, "deny")) { 00516 ha = ast_append_ha(v->name, v->value, ha); 00517 } else if (!strcasecmp(v->name, "writetimeout")) { 00518 int val = atoi(v->value); 00519 00520 if (val < 100) 00521 ast_log(LOG_WARNING, "Invalid writetimeout value '%s' at line %d\n", v->value, v->lineno); 00522 else 00523 s->writetimeout = val; 00524 } 00525 00526 v = v->next; 00527 } 00528 if (ha && !ast_apply_ha(ha, &(s->sin))) { 00529 ast_log(LOG_NOTICE, "%s failed to pass IP ACL as '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user); 00530 ast_free_ha(ha); 00531 ast_config_destroy(cfg); 00532 return -1; 00533 } else if (ha) 00534 ast_free_ha(ha); 00535 if (!strcasecmp(authtype, "MD5")) { 00536 if (!ast_strlen_zero(key) && 00537 !ast_strlen_zero(s->challenge) && !ast_strlen_zero(password)) { 00538 int x; 00539 int len=0; 00540 char md5key[256] = ""; 00541 struct MD5Context md5; 00542 unsigned char digest[16]; 00543 MD5Init(&md5); 00544 MD5Update(&md5, (unsigned char *) s->challenge, strlen(s->challenge)); 00545 MD5Update(&md5, (unsigned char *) password, strlen(password)); 00546 MD5Final(digest, &md5); 00547 for (x=0;x<16;x++) 00548 len += sprintf(md5key + len, "%2.2x", digest[x]); 00549 if (!strcmp(md5key, key)) 00550 break; 00551 else { 00552 ast_config_destroy(cfg); 00553 return -1; 00554 } 00555 } 00556 } else if (password && !strcasecmp(password, pass)) { 00557 break; 00558 } else { 00559 ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user); 00560 ast_config_destroy(cfg); 00561 return -1; 00562 } 00563 } 00564 } 00565 cat = ast_category_browse(cfg, cat); 00566 } 00567 if (cat) { 00568 ast_copy_string(s->username, cat, sizeof(s->username)); 00569 s->readperm = get_perm(ast_variable_retrieve(cfg, cat, "read")); 00570 s->writeperm = get_perm(ast_variable_retrieve(cfg, cat, "write")); 00571 ast_config_destroy(cfg); 00572 if (events) 00573 set_eventmask(s, events); 00574 return 0; 00575 } 00576 ast_log(LOG_NOTICE, "%s tried to authenticate with nonexistent user '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user); 00577 ast_config_destroy(cfg); 00578 return -1; 00579 }
static char* authority_to_str | ( | int | authority, | |
char * | res, | |||
int | reslen | |||
) | [static] |
authority_to_str: Convert authority code to string with serveral options
Definition at line 142 of file manager.c.
References ast_strlen_zero(), and perms.
Referenced by action_listcommands(), handle_showmancmd(), handle_showmancmds(), and manager_event().
00143 { 00144 int running_total = 0, i; 00145 memset(res, 0, reslen); 00146 for (i=0; i<sizeof(perms) / sizeof(perms[0]) - 1; i++) { 00147 if (authority & perms[i].num) { 00148 if (*res) { 00149 strncat(res, ",", (reslen > running_total) ? reslen - running_total : 0); 00150 running_total++; 00151 } 00152 strncat(res, perms[i].label, (reslen > running_total) ? reslen - running_total : 0); 00153 running_total += strlen(perms[i].label); 00154 } 00155 } 00156 if (ast_strlen_zero(res)) { 00157 ast_copy_string(res, "<none>", reslen); 00158 } 00159 return res; 00160 }
static char* complete_show_mancmd | ( | char * | line, | |
char * | word, | |||
int | pos, | |||
int | state | |||
) | [static] |
Definition at line 162 of file manager.c.
References manager_action::action, ast_mutex_lock(), ast_mutex_unlock(), first_action, manager_action::next, and strdup.
00163 { 00164 struct manager_action *cur = first_action; 00165 int which = 0; 00166 00167 ast_mutex_lock(&actionlock); 00168 while (cur) { /* Walk the list of actions */ 00169 if (!strncasecmp(word, cur->action, strlen(word))) { 00170 if (++which > state) { 00171 char *ret = strdup(cur->action); 00172 ast_mutex_unlock(&actionlock); 00173 return ret; 00174 } 00175 } 00176 cur = cur->next; 00177 } 00178 ast_mutex_unlock(&actionlock); 00179 return NULL; 00180 }
static void destroy_session | ( | struct mansession * | s | ) | [static] |
Definition at line 282 of file manager.c.
References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), free_session(), LOG_WARNING, mansession::next, s, and sessions.
Referenced by accept_thread(), and skinny_session().
00283 { 00284 struct mansession *cur, *prev = NULL; 00285 ast_mutex_lock(&sessionlock); 00286 cur = sessions; 00287 while(cur) { 00288 if (cur == s) 00289 break; 00290 prev = cur; 00291 cur = cur->next; 00292 } 00293 if (cur) { 00294 if (prev) 00295 prev->next = cur->next; 00296 else 00297 sessions = cur->next; 00298 free_session(s); 00299 } else 00300 ast_log(LOG_WARNING, "Trying to delete nonexistent session %p?\n", s); 00301 ast_mutex_unlock(&sessionlock); 00302 00303 }
static void* fast_originate | ( | void * | data | ) | [static] |
Definition at line 933 of file manager.c.
References fast_originate_helper::account, fast_originate_helper::app, fast_originate_helper::appdata, AST_FORMAT_SLINEAR, ast_mutex_unlock(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_strlen_zero(), fast_originate_helper::cid_name, fast_originate_helper::cid_num, fast_originate_helper::context, fast_originate_helper::data, EVENT_FLAG_CALL, fast_originate_helper::exten, free, fast_originate_helper::idtext, ast_channel::lock, manager_event(), fast_originate_helper::priority, fast_originate_helper::tech, fast_originate_helper::timeout, ast_channel::uniqueid, and fast_originate_helper::vars.
Referenced by action_originate().
00934 { 00935 struct fast_originate_helper *in = data; 00936 int res; 00937 int reason = 0; 00938 struct ast_channel *chan = NULL; 00939 00940 if (!ast_strlen_zero(in->app)) { 00941 res = ast_pbx_outgoing_app(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->app, in->appdata, &reason, 1, 00942 !ast_strlen_zero(in->cid_num) ? in->cid_num : NULL, 00943 !ast_strlen_zero(in->cid_name) ? in->cid_name : NULL, 00944 in->vars, in->account, &chan); 00945 } else { 00946 res = ast_pbx_outgoing_exten(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1, 00947 !ast_strlen_zero(in->cid_num) ? in->cid_num : NULL, 00948 !ast_strlen_zero(in->cid_name) ? in->cid_name : NULL, 00949 in->vars, in->account, &chan); 00950 } 00951 if (!res) 00952 manager_event(EVENT_FLAG_CALL, 00953 "OriginateSuccess", 00954 "%s" 00955 "Channel: %s/%s\r\n" 00956 "Context: %s\r\n" 00957 "Exten: %s\r\n" 00958 "Reason: %d\r\n" 00959 "Uniqueid: %s\r\n", 00960 in->idtext, in->tech, in->data, in->context, in->exten, reason, chan ? chan->uniqueid : "<null>"); 00961 else 00962 manager_event(EVENT_FLAG_CALL, 00963 "OriginateFailure", 00964 "%s" 00965 "Channel: %s/%s\r\n" 00966 "Context: %s\r\n" 00967 "Exten: %s\r\n" 00968 "Reason: %d\r\n" 00969 "Uniqueid: %s\r\n", 00970 in->idtext, in->tech, in->data, in->context, in->exten, reason, chan ? chan->uniqueid : "<null>"); 00971 00972 /* Locked by ast_pbx_outgoing_exten or ast_pbx_outgoing_app */ 00973 if (chan) 00974 ast_mutex_unlock(&chan->lock); 00975 free(in); 00976 return NULL; 00977 }
static void free_session | ( | struct mansession * | s | ) | [static] |
Definition at line 268 of file manager.c.
References ast_mutex_destroy(), free, and s.
Referenced by destroy_session().
00269 { 00270 struct eventqent *eqe; 00271 if (s->fd > -1) 00272 close(s->fd); 00273 ast_mutex_destroy(&s->__lock); 00274 while(s->eventq) { 00275 eqe = s->eventq; 00276 s->eventq = s->eventq->next; 00277 free(eqe); 00278 } 00279 free(s); 00280 }
static int get_input | ( | struct mansession * | s, | |
char * | output | |||
) | [static] |
Definition at line 1334 of file manager.c.
References s.
Referenced by session_do(), and skinny_session().
01335 { 01336 /* output must have at least sizeof(s->inbuf) space */ 01337 int res; 01338 int x; 01339 struct pollfd fds[1]; 01340 char iabuf[INET_ADDRSTRLEN]; 01341 for (x=1;x<s->inlen;x++) { 01342 if ((s->inbuf[x] == '\n') && (s->inbuf[x-1] == '\r')) { 01343 /* Copy output data up to and including \r\n */ 01344 memcpy(output, s->inbuf, x + 1); 01345 /* Add trailing \0 */ 01346 output[x+1] = '\0'; 01347 /* Move remaining data back to the front */ 01348 memmove(s->inbuf, s->inbuf + x + 1, s->inlen - x); 01349 s->inlen -= (x + 1); 01350 return 1; 01351 } 01352 } 01353 if (s->inlen >= sizeof(s->inbuf) - 1) { 01354 ast_log(LOG_WARNING, "Dumping long line with no return from %s: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), s->inbuf); 01355 s->inlen = 0; 01356 } 01357 fds[0].fd = s->fd; 01358 fds[0].events = POLLIN; 01359 do { 01360 res = poll(fds, 1, -1); 01361 if (res < 0) { 01362 if (errno == EINTR) { 01363 if (s->dead) 01364 return -1; 01365 continue; 01366 } 01367 ast_log(LOG_WARNING, "Select returned error: %s\n", strerror(errno)); 01368 return -1; 01369 } else if (res > 0) { 01370 ast_mutex_lock(&s->__lock); 01371 res = read(s->fd, s->inbuf + s->inlen, sizeof(s->inbuf) - 1 - s->inlen); 01372 ast_mutex_unlock(&s->__lock); 01373 if (res < 1) 01374 return -1; 01375 break; 01376 } 01377 } while(1); 01378 s->inlen += res; 01379 s->inbuf[s->inlen] = '\0'; 01380 return 0; 01381 }
static int get_perm | ( | char * | instr | ) | [static] |
Definition at line 413 of file manager.c.
References ast_instring(), and perms.
Referenced by authenticate().
00414 { 00415 int x = 0, ret = 0; 00416 00417 if (!instr) 00418 return 0; 00419 00420 for (x=0; x<sizeof(perms) / sizeof(perms[0]); x++) 00421 if (ast_instring(instr, perms[x].label, ',')) 00422 ret |= perms[x].num; 00423 00424 return ret; 00425 }
static int handle_showmancmd | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 182 of file manager.c.
References manager_action::action, ast_cli(), ast_mutex_lock(), manager_action::authority, authority_to_str(), manager_action::description, first_action, manager_action::next, RESULT_SHOWUSAGE, and manager_action::synopsis.
00183 { 00184 struct manager_action *cur = first_action; 00185 char authority[80]; 00186 int num; 00187 00188 if (argc != 4) 00189 return RESULT_SHOWUSAGE; 00190 ast_mutex_lock(&actionlock); 00191 while (cur) { /* Walk the list of actions */ 00192 for (num = 3; num < argc; num++) { 00193 if (!strcasecmp(cur->action, argv[num])) { 00194 ast_cli(fd, "Action: %s\nSynopsis: %s\nPrivilege: %s\n%s\n", cur->action, cur->synopsis, authority_to_str(cur->authority, authority, sizeof(authority) -1), cur->description ? cur->description : ""); 00195 } 00196 } 00197 cur = cur->next; 00198 } 00199 00200 ast_mutex_unlock(&actionlock); 00201 return RESULT_SUCCESS; 00202 }
static int handle_showmancmds | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
handle_showmancmds: CLI command
Definition at line 206 of file manager.c.
References manager_action::action, ast_cli(), ast_mutex_lock(), ast_mutex_unlock(), manager_action::authority, authority_to_str(), first_action, format, manager_action::next, RESULT_SUCCESS, and manager_action::synopsis.
00207 { 00208 struct manager_action *cur = first_action; 00209 char authority[80]; 00210 char *format = " %-15.15s %-15.15s %-55.55s\n"; 00211 00212 ast_mutex_lock(&actionlock); 00213 ast_cli(fd, format, "Action", "Privilege", "Synopsis"); 00214 ast_cli(fd, format, "------", "---------", "--------"); 00215 while (cur) { /* Walk the list of actions */ 00216 ast_cli(fd, format, cur->action, authority_to_str(cur->authority, authority, sizeof(authority) -1), cur->synopsis); 00217 cur = cur->next; 00218 } 00219 00220 ast_mutex_unlock(&actionlock); 00221 return RESULT_SUCCESS; 00222 }
static int handle_showmanconn | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
handle_showmanconn: CLI command show manager connected
Definition at line 226 of file manager.c.
References ast_cli(), ast_inet_ntoa(), ast_mutex_lock(), ast_mutex_unlock(), format, RESULT_SUCCESS, s, and sessions.
00227 { 00228 struct mansession *s; 00229 char iabuf[INET_ADDRSTRLEN]; 00230 char *format = " %-15.15s %-15.15s\n"; 00231 ast_mutex_lock(&sessionlock); 00232 s = sessions; 00233 ast_cli(fd, format, "Username", "IP Address"); 00234 while (s) { 00235 ast_cli(fd, format,s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); 00236 s = s->next; 00237 } 00238 00239 ast_mutex_unlock(&sessionlock); 00240 return RESULT_SUCCESS; 00241 }
int manager_event | ( | int | category, | |
char * | event, | |||
char * | fmt, | |||
... | ||||
) |
manager_event: Send AMI event to client
Definition at line 1503 of file manager.c.
References append_event(), ast_build_string(), ast_build_string_va(), ast_carefulwrite(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_strlen_zero(), authority_to_str(), LOG_WARNING, s, and sessions.
Referenced by __login_exec(), action_agent_callback_login(), add_to_queue(), agent_hangup(), ast_change_name(), ast_channel_bridge(), ast_do_masquerade(), ast_hangup(), ast_log(), ast_park_call(), ast_request(), ast_set_callerid(), ast_setstate(), changethread(), conf_run(), do_parking_thread(), expire_register(), fast_originate(), forward_message(), handle_init_event(), handle_response_peerpoke(), handle_response_register(), iax2_ack_registry(), iax2_poke_noanswer(), join_queue(), leave_queue(), manager_log(), manager_state_cb(), notify_new_message(), park_exec(), parse_register_contact(), pbx_extension_helper(), process_sdp(), quit_handler(), realtime_exec(), register_verify(), reload_logger(), reload_manager(), remove_from_queue(), ring_entry(), senddialevent(), set_member_paused(), sip_poke_noanswer(), sip_reg_timeout(), socket_read(), ss_thread(), try_calling(), update_registry(), update_status(), userevent_exec(), vm_execmain(), and zt_handle_event().
01504 { 01505 struct mansession *s; 01506 char auth[80]; 01507 char tmp[4096] = ""; 01508 char *tmp_next = tmp; 01509 size_t tmp_left = sizeof(tmp) - 2; 01510 va_list ap; 01511 01512 ast_mutex_lock(&sessionlock); 01513 for (s = sessions; s; s = s->next) { 01514 if ((s->readperm & category) != category) 01515 continue; 01516 01517 if ((s->send_events & category) != category) 01518 continue; 01519 01520 if (ast_strlen_zero(tmp)) { 01521 ast_build_string(&tmp_next, &tmp_left, "Event: %s\r\nPrivilege: %s\r\n", 01522 event, authority_to_str(category, auth, sizeof(auth))); 01523 va_start(ap, fmt); 01524 ast_build_string_va(&tmp_next, &tmp_left, fmt, ap); 01525 va_end(ap); 01526 *tmp_next++ = '\r'; 01527 *tmp_next++ = '\n'; 01528 *tmp_next = '\0'; 01529 } 01530 01531 ast_mutex_lock(&s->__lock); 01532 if (s->busy) { 01533 append_event(s, tmp); 01534 } else if (!s->dead) { 01535 if (ast_carefulwrite(s->fd, tmp, tmp_next - tmp, s->writetimeout) < 0) { 01536 ast_log(LOG_WARNING, "Disconnecting slow (or gone) manager session!\n"); 01537 s->dead = 1; 01538 pthread_kill(s->t, SIGURG); 01539 } 01540 } 01541 ast_mutex_unlock(&s->__lock); 01542 } 01543 ast_mutex_unlock(&sessionlock); 01544 01545 return 0; 01546 }
static int manager_state_cb | ( | char * | context, | |
char * | exten, | |||
int | state, | |||
void * | data | |||
) | [static] |
Definition at line 1569 of file manager.c.
References EVENT_FLAG_CALL, and manager_event().
Referenced by init_manager().
01570 { 01571 /* Notify managers of change */ 01572 manager_event(EVENT_FLAG_CALL, "ExtensionStatus", "Exten: %s\r\nContext: %s\r\nStatus: %d\r\n", exten, context, state); 01573 return 0; 01574 }
static int process_message | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 1241 of file manager.c.
References manager_action::action, ast_carefulwrite(), ast_cli(), ast_inet_ntoa(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_strlen_zero(), ast_verbose(), astman_get_header(), astman_send_ack(), astman_send_error(), authenticate(), manager_action::authority, displayconnects, first_action, free, manager_action::func, LOG_DEBUG, LOG_EVENT, eventqent::next, manager_action::next, option_verbose, s, and VERBOSE_PREFIX_2.
Referenced by session_do().
01242 { 01243 char action[80] = ""; 01244 struct manager_action *tmp = first_action; 01245 char *id = astman_get_header(m,"ActionID"); 01246 char idText[256] = ""; 01247 char iabuf[INET_ADDRSTRLEN]; 01248 01249 ast_copy_string(action, astman_get_header(m, "Action"), sizeof(action)); 01250 ast_log( LOG_DEBUG, "Manager received command '%s'\n", action ); 01251 01252 if (ast_strlen_zero(action)) { 01253 astman_send_error(s, m, "Missing action in request"); 01254 return 0; 01255 } 01256 if (!ast_strlen_zero(id)) { 01257 snprintf(idText,256,"ActionID: %s\r\n",id); 01258 } 01259 if (!s->authenticated) { 01260 if (!strcasecmp(action, "Challenge")) { 01261 char *authtype; 01262 authtype = astman_get_header(m, "AuthType"); 01263 if (!strcasecmp(authtype, "MD5")) { 01264 if (ast_strlen_zero(s->challenge)) 01265 snprintf(s->challenge, sizeof(s->challenge), "%d", rand()); 01266 ast_mutex_lock(&s->__lock); 01267 ast_cli(s->fd, "Response: Success\r\n" 01268 "%s" 01269 "Challenge: %s\r\n\r\n", 01270 idText,s->challenge); 01271 ast_mutex_unlock(&s->__lock); 01272 return 0; 01273 } else { 01274 astman_send_error(s, m, "Must specify AuthType"); 01275 return 0; 01276 } 01277 } else if (!strcasecmp(action, "Login")) { 01278 if (authenticate(s, m)) { 01279 sleep(1); 01280 astman_send_error(s, m, "Authentication failed"); 01281 return -1; 01282 } else { 01283 s->authenticated = 1; 01284 if (option_verbose > 1) { 01285 if ( displayconnects ) { 01286 ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged on from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); 01287 } 01288 } 01289 ast_log(LOG_EVENT, "Manager '%s' logged on from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); 01290 astman_send_ack(s, m, "Authentication accepted"); 01291 } 01292 } else if (!strcasecmp(action, "Logoff")) { 01293 astman_send_ack(s, m, "See ya"); 01294 return -1; 01295 } else 01296 astman_send_error(s, m, "Authentication Required"); 01297 } else { 01298 int ret=0; 01299 struct eventqent *eqe; 01300 ast_mutex_lock(&s->__lock); 01301 s->busy = 1; 01302 ast_mutex_unlock(&s->__lock); 01303 while( tmp ) { 01304 if (!strcasecmp(action, tmp->action)) { 01305 if ((s->writeperm & tmp->authority) == tmp->authority) { 01306 if (tmp->func(s, m)) 01307 ret = -1; 01308 } else { 01309 astman_send_error(s, m, "Permission denied"); 01310 } 01311 break; 01312 } 01313 tmp = tmp->next; 01314 } 01315 if (!tmp) 01316 astman_send_error(s, m, "Invalid/unknown command"); 01317 ast_mutex_lock(&s->__lock); 01318 s->busy = 0; 01319 while(s->eventq) { 01320 if (ast_carefulwrite(s->fd, s->eventq->eventdata, strlen(s->eventq->eventdata), s->writetimeout) < 0) { 01321 ret = -1; 01322 break; 01323 } 01324 eqe = s->eventq; 01325 s->eventq = s->eventq->next; 01326 free(eqe); 01327 } 01328 ast_mutex_unlock(&s->__lock); 01329 return ret; 01330 } 01331 return 0; 01332 }
static void* session_do | ( | void * | data | ) | [static] |
Definition at line 1383 of file manager.c.
References ast_cli(), AST_MAX_MANHEADERS, ast_mutex_lock(), ast_mutex_unlock(), ast_strlen_zero(), get_input(), process_message(), and s.
Referenced by accept_thread().
01384 { 01385 struct mansession *s = data; 01386 struct message m; 01387 char iabuf[INET_ADDRSTRLEN]; 01388 int res; 01389 01390 ast_mutex_lock(&s->__lock); 01391 ast_cli(s->fd, "Asterisk Call Manager/1.0\r\n"); 01392 ast_mutex_unlock(&s->__lock); 01393 memset(&m, 0, sizeof(m)); 01394 for (;;) { 01395 res = get_input(s, m.headers[m.hdrcount]); 01396 if (res > 0) { 01397 /* Strip trailing \r\n */ 01398 if (strlen(m.headers[m.hdrcount]) < 2) 01399 continue; 01400 m.headers[m.hdrcount][strlen(m.headers[m.hdrcount]) - 2] = '\0'; 01401 if (ast_strlen_zero(m.headers[m.hdrcount])) { 01402 if (process_message(s, &m)) 01403 break; 01404 memset(&m, 0, sizeof(m)); 01405 } else if (m.hdrcount < AST_MAX_MANHEADERS - 1) 01406 m.hdrcount++; 01407 } else if (res < 0) 01408 break; 01409 } 01410 if (s->authenticated) { 01411 if (option_verbose > 1) { 01412 if (displayconnects) 01413 ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); 01414 } 01415 ast_log(LOG_EVENT, "Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); 01416 } else { 01417 if (option_verbose > 1) { 01418 if ( displayconnects ) 01419 ast_verbose(VERBOSE_PREFIX_2 "Connect attempt from '%s' unable to authenticate\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); 01420 } 01421 ast_log(LOG_EVENT, "Failed attempt from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); 01422 } 01423 destroy_session(s); 01424 return NULL; 01425 }
static int set_eventmask | ( | struct mansession * | s, | |
char * | eventmask | |||
) | [static] |
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
Definition at line 476 of file manager.c.
References ast_mutex_lock(), ast_mutex_unlock(), ast_strings_to_mask(), and s.
Referenced by action_events(), and authenticate().
00477 { 00478 int maskint = ast_strings_to_mask(eventmask); 00479 00480 ast_mutex_lock(&s->__lock); 00481 if (maskint >= 0) 00482 s->send_events = maskint; 00483 ast_mutex_unlock(&s->__lock); 00484 00485 return maskint; 00486 }
int asock = -1 [static] |
int block_sockets = 0 [static] |
int displayconnects = 1 [static] |
struct manager_action* first_action = NULL [static] |
Definition at line 107 of file manager.c.
Referenced by action_listcommands(), ast_manager_register_struct(), ast_manager_unregister(), complete_show_mancmd(), handle_showmancmd(), handle_showmancmds(), and process_message().
char mandescr_command[] [static] |
Initial value:
"Description: Run a CLI command.\n" "Variables: (Names marked with * are required)\n" " *Command: Asterisk CLI command to run\n" " ActionID: Optional Action id for message matching.\n"
Definition at line 913 of file manager.c.
Referenced by init_manager().
char mandescr_events[] [static] |
char mandescr_extensionstate[] [static] |
char mandescr_getvar[] [static] |
char mandescr_hangup[] [static] |
Initial value:
"Description: Hangup a channel\n" "Variables: \n" " Channel: The channel name to be hungup\n"
Definition at line 652 of file manager.c.
Referenced by init_manager().
char mandescr_listcommands[] [static] |
Initial value:
"Description: Returns the action name and synopsis for every\n" " action that is available to the user\n" "Variables: NONE\n"
Definition at line 593 of file manager.c.
Referenced by init_manager().
char mandescr_logoff[] [static] |
Initial value:
"Description: Logoff this manager session\n" "Variables: NONE\n"
Definition at line 642 of file manager.c.
Referenced by init_manager().
char mandescr_mailboxcount[] [static] |
char mandescr_mailboxstatus[] [static] |
Help text for manager command mailboxstatus.
Definition at line 1101 of file manager.c.
Referenced by init_manager().
char mandescr_originate[] [static] |
char mandescr_ping[] [static] |
Initial value:
"Description: A 'Ping' action will ellicit a 'Pong' response. Used to keep the " " manager connection open.\n" "Variables: NONE\n"
Definition at line 582 of file manager.c.
Referenced by init_manager().
char mandescr_redirect[] [static] |
char mandescr_setvar[] [static] |
char mandescr_timeout[] [static] |
Referenced by ast_strings_to_mask(), authority_to_str(), and get_perm().
int portno = DEFAULT_MANAGER_PORT [static] |
Definition at line 83 of file manager.c.
Referenced by ast_netsock_bind(), create_addr(), init_manager(), process_sdp(), and set_config().
struct mansession* sessions = NULL [static] |
Definition at line 106 of file manager.c.
Referenced by accept_thread(), destroy_session(), handle_showmanconn(), and manager_event().
struct ast_cli_entry show_mancmd_cli [static] |
Initial value:
{ { "show", "manager", "command", NULL }, handle_showmancmd, "Show a manager interface command", showmancmd_help, complete_show_mancmd }
Definition at line 256 of file manager.c.
Referenced by init_manager().
struct ast_cli_entry show_mancmds_cli [static] |
Initial value:
{ { "show", "manager", "commands", NULL }, handle_showmancmds, "List manager interface commands", showmancmds_help }
Definition at line 260 of file manager.c.
Referenced by init_manager().
struct ast_cli_entry show_manconn_cli [static] |
Initial value:
{ { "show", "manager", "connected", NULL }, handle_showmanconn, "Show connected manager interface users", showmanconn_help }
Definition at line 264 of file manager.c.
Referenced by init_manager().
char showmancmd_help[] [static] |
char showmancmds_help[] [static] |
char showmanconn_help[] [static] |
pthread_t t [static] |
Definition at line 87 of file manager.c.
Referenced by acf_odbc_write(), add_sdp(), append_date(), ast_cdr_getvar(), ast_check_timing(), ast_do_masquerade(), ast_log(), ast_pbx_start(), ast_register_translator(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), ast_say_number_full_de(), ast_unregister_translator(), ast_verbose(), background_detect_exec(), build_mapping(), byteReverse(), calc_cost(), callerid_genmsg(), callerid_getcarrier(), check_user_full(), cli_prompt(), config_text_file_save(), datetime_exec(), do_monitor(), dump_cmd_queues(), enumlookup_exec(), find_channel(), gen_tone(), gen_tones(), get_date(), get_trans_id(), handle_hd_hf(), handle_message(), iax2_datetime(), iax_template_parse(), init_manager(), launch_page(), launch_service(), listener(), localsub(), lws2sws(), manager_log(), MD5Update(), network_verboser(), packdate(), play_message_datetime(), prune_gateways(), rebuild_matrix(), register_verify(), rpt(), rpt_tele_thread(), send_request(), sendmail(), sendpage(), sms_readfile(), sqlite_log(), statechange_queue(), strip_quotes(), tdd_getcarrier(), time1(), time2(), transmit_notify_request_with_callerid(), transmit_notify_with_mwi(), transmit_state_notify(), and write_metadata().