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 1434 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().
01435 { 01436 int as; 01437 struct sockaddr_in sin; 01438 socklen_t sinlen; 01439 struct mansession *s; 01440 struct protoent *p; 01441 int arg = 1; 01442 int flags; 01443 pthread_attr_t attr; 01444 01445 pthread_attr_init(&attr); 01446 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 01447 01448 for (;;) { 01449 sinlen = sizeof(sin); 01450 as = accept(asock, (struct sockaddr *)&sin, &sinlen); 01451 if (as < 0) { 01452 ast_log(LOG_NOTICE, "Accept returned -1: %s\n", strerror(errno)); 01453 continue; 01454 } 01455 p = getprotobyname("tcp"); 01456 if (p) { 01457 if( setsockopt(as, p->p_proto, TCP_NODELAY, (char *)&arg, sizeof(arg) ) < 0 ) { 01458 ast_log(LOG_WARNING, "Failed to set manager tcp connection to TCP_NODELAY mode: %s\n", strerror(errno)); 01459 } 01460 } 01461 s = malloc(sizeof(struct mansession)); 01462 if (!s) { 01463 ast_log(LOG_WARNING, "Failed to allocate management session: %s\n", strerror(errno)); 01464 continue; 01465 } 01466 memset(s, 0, sizeof(struct mansession)); 01467 memcpy(&s->sin, &sin, sizeof(sin)); 01468 s->writetimeout = 100; 01469 01470 if(! block_sockets) { 01471 /* For safety, make sure socket is non-blocking */ 01472 flags = fcntl(as, F_GETFL); 01473 fcntl(as, F_SETFL, flags | O_NONBLOCK); 01474 } 01475 ast_mutex_init(&s->__lock); 01476 s->fd = as; 01477 s->send_events = -1; 01478 ast_mutex_lock(&sessionlock); 01479 s->next = sessions; 01480 sessions = s; 01481 ast_mutex_unlock(&sessionlock); 01482 if (ast_pthread_create(&s->t, &attr, session_do, s)) 01483 destroy_session(s); 01484 } 01485 pthread_attr_destroy(&attr); 01486 return NULL; 01487 }
| static int action_command | ( | struct mansession * | s, | |
| struct message * | m | |||
| ) | [static] |
action_command: Manager command "command" - execute CLI command
Definition at line 926 of file manager.c.
References ast_cli(), ast_cli_command(), ast_strlen_zero(), astman_get_header(), and s.
Referenced by init_manager().
00927 { 00928 char *cmd = astman_get_header(m, "Command"); 00929 char *id = astman_get_header(m, "ActionID"); 00930 ast_cli(s->fd, "Response: Follows\r\nPrivilege: Command\r\n"); 00931 if (!ast_strlen_zero(id)) 00932 ast_cli(s->fd, "ActionID: %s\r\n", id); 00933 /* FIXME: Wedge a ActionID response in here, waiting for later changes */ 00934 ast_cli_command(s->fd, cmd); 00935 ast_cli(s->fd, "--END COMMAND--\r\n\r\n"); 00936 return 0; 00937 }
| 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 1187 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().
01188 { 01189 char *exten = astman_get_header(m, "Exten"); 01190 char *context = astman_get_header(m, "Context"); 01191 char *id = astman_get_header(m,"ActionID"); 01192 char idText[256] = ""; 01193 char hint[256] = ""; 01194 int status; 01195 if (ast_strlen_zero(exten)) { 01196 astman_send_error(s, m, "Extension not specified"); 01197 return 0; 01198 } 01199 if (ast_strlen_zero(context)) 01200 context = "default"; 01201 status = ast_extension_state(NULL, context, exten); 01202 ast_get_hint(hint, sizeof(hint) - 1, NULL, 0, NULL, context, exten); 01203 if (!ast_strlen_zero(id)) { 01204 snprintf(idText,256,"ActionID: %s\r\n",id); 01205 } 01206 ast_cli(s->fd, "Response: Success\r\n" 01207 "%s" 01208 "Message: Extension Status\r\n" 01209 "Exten: %s\r\n" 01210 "Context: %s\r\n" 01211 "Hint: %s\r\n" 01212 "Status: %d\r\n\r\n", 01213 idText,exten, context, hint, status); 01214 return 0; 01215 }
| static int action_getvar | ( | struct mansession * | s, | |
| struct message * | m | |||
| ) | [static] |
Definition at line 720 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().
00721 { 00722 struct ast_channel *c = NULL; 00723 char *name = astman_get_header(m, "Channel"); 00724 char *varname = astman_get_header(m, "Variable"); 00725 char *id = astman_get_header(m,"ActionID"); 00726 char *varval; 00727 char *varval2=NULL; 00728 00729 if (!strlen(varname)) { 00730 astman_send_error(s, m, "No variable specified"); 00731 return 0; 00732 } 00733 00734 if (strlen(name)) { 00735 c = ast_get_channel_by_name_locked(name); 00736 if (!c) { 00737 astman_send_error(s, m, "No such channel"); 00738 return 0; 00739 } 00740 } 00741 00742 varval=pbx_builtin_getvar_helper(c,varname); 00743 if (varval) 00744 varval2 = ast_strdupa(varval); 00745 if (!varval2) 00746 varval2 = ""; 00747 if (c) 00748 ast_mutex_unlock(&c->lock); 00749 ast_cli(s->fd, "Response: Success\r\n" 00750 "Variable: %s\r\nValue: %s\r\n" ,varname,varval2); 00751 if (!ast_strlen_zero(id)) 00752 ast_cli(s->fd, "ActionID: %s\r\n",id); 00753 ast_cli(s->fd, "\r\n"); 00754 00755 return 0; 00756 }
| 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 1151 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().
01152 { 01153 char *mailbox = astman_get_header(m, "Mailbox"); 01154 char *id = astman_get_header(m,"ActionID"); 01155 char idText[256] = ""; 01156 int newmsgs = 0, oldmsgs = 0; 01157 if (ast_strlen_zero(mailbox)) { 01158 astman_send_error(s, m, "Mailbox not specified"); 01159 return 0; 01160 } 01161 ast_app_messagecount(mailbox, &newmsgs, &oldmsgs); 01162 if (!ast_strlen_zero(id)) { 01163 snprintf(idText,256,"ActionID: %s\r\n",id); 01164 } 01165 ast_cli(s->fd, "Response: Success\r\n" 01166 "%s" 01167 "Message: Mailbox Message Count\r\n" 01168 "Mailbox: %s\r\n" 01169 "NewMessages: %d\r\n" 01170 "OldMessages: %d\r\n" 01171 "\r\n", 01172 idText,mailbox, newmsgs, oldmsgs); 01173 return 0; 01174 }
| static int action_mailboxstatus | ( | struct mansession * | s, | |
| struct message * | m | |||
| ) | [static] |
Definition at line 1119 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().
01120 { 01121 char *mailbox = astman_get_header(m, "Mailbox"); 01122 char *id = astman_get_header(m,"ActionID"); 01123 char idText[256] = ""; 01124 int ret; 01125 if (ast_strlen_zero(mailbox)) { 01126 astman_send_error(s, m, "Mailbox not specified"); 01127 return 0; 01128 } 01129 if (!ast_strlen_zero(id)) 01130 snprintf(idText,256,"ActionID: %s\r\n",id); 01131 ret = ast_app_has_voicemail(mailbox, NULL); 01132 ast_cli(s->fd, "Response: Success\r\n" 01133 "%s" 01134 "Message: Mailbox Status\r\n" 01135 "Mailbox: %s\r\n" 01136 "Waiting: %d\r\n\r\n", idText, mailbox, ret); 01137 return 0; 01138 }
| static int action_originate | ( | struct mansession * | s, | |
| struct message * | m | |||
| ) | [static] |
Definition at line 1001 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().
01002 { 01003 char *name = astman_get_header(m, "Channel"); 01004 char *exten = astman_get_header(m, "Exten"); 01005 char *context = astman_get_header(m, "Context"); 01006 char *priority = astman_get_header(m, "Priority"); 01007 char *timeout = astman_get_header(m, "Timeout"); 01008 char *callerid = astman_get_header(m, "CallerID"); 01009 char *account = astman_get_header(m, "Account"); 01010 char *app = astman_get_header(m, "Application"); 01011 char *appdata = astman_get_header(m, "Data"); 01012 char *async = astman_get_header(m, "Async"); 01013 char *id = astman_get_header(m, "ActionID"); 01014 struct ast_variable *vars = astman_get_variables(m); 01015 char *tech, *data; 01016 char *l=NULL, *n=NULL; 01017 int pi = 0; 01018 int res; 01019 int to = 30000; 01020 int reason = 0; 01021 char tmp[256]; 01022 char tmp2[256]; 01023 01024 pthread_t th; 01025 pthread_attr_t attr; 01026 if (!name) { 01027 astman_send_error(s, m, "Channel not specified"); 01028 return 0; 01029 } 01030 if (!ast_strlen_zero(priority) && (sscanf(priority, "%d", &pi) != 1)) { 01031 astman_send_error(s, m, "Invalid priority\n"); 01032 return 0; 01033 } 01034 if (!ast_strlen_zero(timeout) && (sscanf(timeout, "%d", &to) != 1)) { 01035 astman_send_error(s, m, "Invalid timeout\n"); 01036 return 0; 01037 } 01038 ast_copy_string(tmp, name, sizeof(tmp)); 01039 tech = tmp; 01040 data = strchr(tmp, '/'); 01041 if (!data) { 01042 astman_send_error(s, m, "Invalid channel\n"); 01043 return 0; 01044 } 01045 *data = '\0'; 01046 data++; 01047 ast_copy_string(tmp2, callerid, sizeof(tmp2)); 01048 ast_callerid_parse(tmp2, &n, &l); 01049 if (n) { 01050 if (ast_strlen_zero(n)) 01051 n = NULL; 01052 } 01053 if (l) { 01054 ast_shrink_phone_number(l); 01055 if (ast_strlen_zero(l)) 01056 l = NULL; 01057 } 01058 if (ast_true(async)) { 01059 struct fast_originate_helper *fast = malloc(sizeof(struct fast_originate_helper)); 01060 if (!fast) { 01061 res = -1; 01062 } else { 01063 memset(fast, 0, sizeof(struct fast_originate_helper)); 01064 if (!ast_strlen_zero(id)) 01065 snprintf(fast->idtext, sizeof(fast->idtext), "ActionID: %s\r\n", id); 01066 ast_copy_string(fast->tech, tech, sizeof(fast->tech)); 01067 ast_copy_string(fast->data, data, sizeof(fast->data)); 01068 ast_copy_string(fast->app, app, sizeof(fast->app)); 01069 ast_copy_string(fast->appdata, appdata, sizeof(fast->appdata)); 01070 if (l) 01071 ast_copy_string(fast->cid_num, l, sizeof(fast->cid_num)); 01072 if (n) 01073 ast_copy_string(fast->cid_name, n, sizeof(fast->cid_name)); 01074 fast->vars = vars; 01075 ast_copy_string(fast->context, context, sizeof(fast->context)); 01076 ast_copy_string(fast->exten, exten, sizeof(fast->exten)); 01077 ast_copy_string(fast->account, account, sizeof(fast->account)); 01078 fast->timeout = to; 01079 fast->priority = pi; 01080 pthread_attr_init(&attr); 01081 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 01082 if (ast_pthread_create(&th, &attr, fast_originate, fast)) { 01083 res = -1; 01084 } else { 01085 res = 0; 01086 } 01087 pthread_attr_destroy(&attr); 01088 } 01089 } else if (!ast_strlen_zero(app)) { 01090 res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL); 01091 } else { 01092 if (exten && context && pi) 01093 res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL); 01094 else { 01095 astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'"); 01096 return 0; 01097 } 01098 } 01099 if (!res) 01100 astman_send_ack(s, m, "Originate successfully queued"); 01101 else 01102 astman_send_error(s, m, "Originate failed"); 01103 return 0; 01104 }
| 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 858 of file manager.c.
References ast_async_goto(), ast_check_hangup(), 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().
00859 { 00860 char *name = astman_get_header(m, "Channel"); 00861 char *name2 = astman_get_header(m, "ExtraChannel"); 00862 char *exten = astman_get_header(m, "Exten"); 00863 char *context = astman_get_header(m, "Context"); 00864 char *priority = astman_get_header(m, "Priority"); 00865 struct ast_channel *chan, *chan2 = NULL; 00866 int pi = 0; 00867 int res; 00868 00869 if (ast_strlen_zero(name)) { 00870 astman_send_error(s, m, "Channel not specified"); 00871 return 0; 00872 } 00873 if (!ast_strlen_zero(priority) && (sscanf(priority, "%d", &pi) != 1)) { 00874 astman_send_error(s, m, "Invalid priority\n"); 00875 return 0; 00876 } 00877 chan = ast_get_channel_by_name_locked(name); 00878 if (!chan) { 00879 char buf[BUFSIZ]; 00880 snprintf(buf, sizeof(buf), "Channel does not exist: %s", name); 00881 astman_send_error(s, m, buf); 00882 return 0; 00883 } 00884 if (ast_check_hangup(chan)) { 00885 astman_send_error(s, m, "Redirect failed, channel hung up.\n"); 00886 ast_mutex_unlock(&chan->lock); 00887 return 0; 00888 } 00889 if (!ast_strlen_zero(name2)) 00890 chan2 = ast_get_channel_by_name_locked(name2); 00891 if (chan2 && ast_check_hangup(chan2)) { 00892 astman_send_error(s, m, "Redirect failed, extra channel hung up.\n"); 00893 ast_mutex_unlock(&chan->lock); 00894 ast_mutex_unlock(&chan2->lock); 00895 return 0; 00896 } 00897 res = ast_async_goto(chan, context, exten, pi); 00898 if (!res) { 00899 if (!ast_strlen_zero(name2)) { 00900 if (chan2) 00901 res = ast_async_goto(chan2, context, exten, pi); 00902 else 00903 res = -1; 00904 if (!res) 00905 astman_send_ack(s, m, "Dual Redirect successful"); 00906 else 00907 astman_send_error(s, m, "Secondary redirect failed"); 00908 } else 00909 astman_send_ack(s, m, "Redirect successful"); 00910 } else 00911 astman_send_error(s, m, "Redirect failed"); 00912 if (chan) 00913 ast_mutex_unlock(&chan->lock); 00914 if (chan2) 00915 ast_mutex_unlock(&chan2->lock); 00916 return 0; 00917 }
| 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(name)) { 00696 c = ast_get_channel_by_name_locked(name); 00697 if (!c) { 00698 astman_send_error(s, m, "No such channel"); 00699 return 0; 00700 } 00701 } 00702 00703 pbx_builtin_setvar_helper(c, varname, varval ? varval : ""); 00704 00705 if (c) 00706 ast_mutex_unlock(&c->lock); 00707 00708 astman_send_ack(s, m, "Variable Set"); 00709 00710 return 0; 00711 }
| static int action_status | ( | struct mansession * | s, | |
| struct message * | m | |||
| ) | [static] |
action_status: Manager "status" command to show channels
Definition at line 761 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().
00762 { 00763 char *id = astman_get_header(m,"ActionID"); 00764 char *name = astman_get_header(m,"Channel"); 00765 char idText[256] = ""; 00766 struct ast_channel *c; 00767 char bridge[256]; 00768 struct timeval now = ast_tvnow(); 00769 long elapsed_seconds=0; 00770 int all = ast_strlen_zero(name); /* set if we want all channels */ 00771 00772 if (!ast_strlen_zero(id)) 00773 snprintf(idText,256,"ActionID: %s\r\n",id); 00774 if (all) 00775 c = ast_channel_walk_locked(NULL); 00776 else { 00777 c = ast_get_channel_by_name_locked(name); 00778 if (!c) { 00779 astman_send_error(s, m, "No such channel"); 00780 return 0; 00781 } 00782 } 00783 astman_send_ack(s, m, "Channel status will follow"); 00784 /* if we look by name, we break after the first iteration */ 00785 while(c) { 00786 if (c->_bridge) 00787 snprintf(bridge, sizeof(bridge), "Link: %s\r\n", c->_bridge->name); 00788 else 00789 bridge[0] = '\0'; 00790 if (c->pbx) { 00791 if (c->cdr) { 00792 elapsed_seconds = now.tv_sec - c->cdr->start.tv_sec; 00793 } 00794 ast_cli(s->fd, 00795 "Event: Status\r\n" 00796 "Privilege: Call\r\n" 00797 "Channel: %s\r\n" 00798 "CallerID: %s\r\n" 00799 "CallerIDName: %s\r\n" 00800 "Account: %s\r\n" 00801 "State: %s\r\n" 00802 "Context: %s\r\n" 00803 "Extension: %s\r\n" 00804 "Priority: %d\r\n" 00805 "Seconds: %ld\r\n" 00806 "%s" 00807 "Uniqueid: %s\r\n" 00808 "%s" 00809 "\r\n", 00810 c->name, 00811 c->cid.cid_num ? c->cid.cid_num : "<unknown>", 00812 c->cid.cid_name ? c->cid.cid_name : "<unknown>", 00813 c->accountcode, 00814 ast_state2str(c->_state), c->context, 00815 c->exten, c->priority, (long)elapsed_seconds, bridge, c->uniqueid, idText); 00816 } else { 00817 ast_cli(s->fd, 00818 "Event: Status\r\n" 00819 "Privilege: Call\r\n" 00820 "Channel: %s\r\n" 00821 "CallerID: %s\r\n" 00822 "CallerIDName: %s\r\n" 00823 "Account: %s\r\n" 00824 "State: %s\r\n" 00825 "%s" 00826 "Uniqueid: %s\r\n" 00827 "%s" 00828 "\r\n", 00829 c->name, 00830 c->cid.cid_num ? c->cid.cid_num : "<unknown>", 00831 c->cid.cid_name ? c->cid.cid_name : "<unknown>", 00832 c->accountcode, 00833 ast_state2str(c->_state), bridge, c->uniqueid, idText); 00834 } 00835 ast_mutex_unlock(&c->lock); 00836 if (!all) 00837 break; 00838 c = ast_channel_walk_locked(c); 00839 } 00840 ast_cli(s->fd, 00841 "Event: StatusComplete\r\n" 00842 "%s" 00843 "\r\n",idText); 00844 return 0; 00845 }
| static int action_timeout | ( | struct mansession * | s, | |
| struct message * | m | |||
| ) | [static] |
Definition at line 1224 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().