Thu Oct 11 06:44:30 2012

Asterisk developer's documentation


AMI functions

callback to display queues status in manager More...

Data Structures

struct  ast_manager_user
struct  eventqent
struct  fast_originate_helper
struct  mansession
struct  mansession_session
struct  permalias
struct  sessions
struct  users
struct  variable_count

Defines

#define ASTMAN_APPEND_BUF_INITSIZE   256
#define MANAGER_EVENT_BUF_INITSIZE   256
#define MAX_BLACKLIST_CMD_LEN   2

Functions

static void * accept_thread (void *ignore)
static int action_command (struct mansession *s, const struct message *m)
 action_command: Manager command "command" - execute CLI command
static int action_events (struct mansession *s, const struct message *m)
static int action_extensionstate (struct mansession *s, const struct message *m)
static int action_getconfig (struct mansession *s, const struct message *m)
static int action_getvar (struct mansession *s, const struct message *m)
static int action_hangup (struct mansession *s, const struct message *m)
static int action_listcommands (struct mansession *s, const struct message *m)
static int action_logoff (struct mansession *s, const struct message *m)
static int action_mailboxcount (struct mansession *s, const struct message *m)
static int action_mailboxstatus (struct mansession *s, const struct message *m)
static int action_originate (struct mansession *s, const struct message *m)
static int action_ping (struct mansession *s, const struct message *m)
static int action_redirect (struct mansession *s, const struct message *m)
 action_redirect: The redirect manager command
static int action_setvar (struct mansession *s, const struct message *m)
static int action_status (struct mansession *s, const struct message *m)
 Manager "status" command to show channels.
static int action_timeout (struct mansession *s, const struct message *m)
static int action_updateconfig (struct mansession *s, const struct message *m)
static int action_userevent (struct mansession *s, const struct message *m)
static int action_waitevent (struct mansession *s, const struct message *m)
static int append_event (const char *str, int category)
static struct ast_manager_userast_get_manager_by_name_locked (const char *name)
static int ast_instring (const char *bigstr, const char *smallstr, char delim)
static int ast_is_number (const char *string)
int ast_manager_register2 (const char *action, int auth, int(*func)(struct mansession *s, const 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)
void astman_append (struct mansession *s, const char *fmt,...)
static void astman_append_buf_init (void)
const char * astman_get_header (const struct message *m, char *var)
struct ast_variableastman_get_variables (const struct message *m)
void astman_send_ack (struct mansession *s, const struct message *m, char *msg)
void astman_send_error (struct mansession *s, const struct message *m, char *error)
void astman_send_response (struct mansession *s, const struct message *m, char *resp, char *msg)
static int authenticate (struct mansession *s, const struct message *m)
static char * authority_to_str (int authority, char *res, int reslen)
 Convert authority code to string with serveral options.
static int check_blacklist (const char *cmd)
static char * complete_show_mancmd (const char *line, const char *word, int pos, int state)
static int compress_char (char c)
static void destroy_session (struct mansession_session *s)
static int do_message (struct mansession *s)
static void * fast_originate (void *data)
static void free_session (struct mansession_session *s)
static int get_input (struct mansession_session *s, char *output)
static int get_perm (const char *instr)
static int handle_showmanager (int fd, int argc, char *argv[])
static int handle_showmanagers (int fd, int argc, char *argv[])
static int handle_showmancmd (int fd, int argc, char *argv[])
static int handle_showmancmds (int fd, int argc, char *argv[])
 CLI command Should change to "manager show commands".
static int handle_showmanconn (int fd, int argc, char *argv[])
 CLI command show manager connected.
static int handle_showmaneventq (int fd, int argc, char *argv[])
 CLI command show manager connected.
static void handle_updates (struct mansession *s, const struct message *m, struct ast_config *cfg)
static char * html_translate (char *in)
int manager_event (int category, const char *event, const char *fmt,...)
 manager_event: Send AMI event to client
static void manager_event_buf_init (void)
static int manager_state_cb (char *context, char *exten, int state, void *data)
static int process_events (struct mansession *s)
static int process_message (struct mansession *s, const struct message *m)
static void * session_do (void *data)
static int set_eventmask (struct mansession_session *s, const char *eventmask)
 Rather than braindead on,off this now can also accept a specific int mask value or a ',' delim list of mask strings (the same as manager.conf) -anthm.
static int strings_to_mask (const char *string)
static void unuse_eventqent (struct eventqent *e)
static int variable_count_cmp_fn (void *obj, void *vstr, int flags)
static int variable_count_hash_fn (const void *vvc, const int flags)
static void xml_copy_escape (char **dst, size_t *maxlen, const char *src, int lower)
static char * xml_translate (char *in, struct ast_variable *vars)

Variables

static ast_rwlock_t actionlock = PTHREAD_RWLOCK_INITIALIZER
static int asock = -1
static struct ast_threadstorage astman_append_buf = { .once = PTHREAD_ONCE_INIT , .key_init = astman_append_buf_init , }
static int authlimit
static int authtimeout
static int block_sockets
static int broken_events_action
static struct ast_cli_entry cli_manager []
static struct ast_cli_entry cli_show_manager_command_deprecated
static struct ast_cli_entry cli_show_manager_commands_deprecated
static struct ast_cli_entry cli_show_manager_connected_deprecated
static struct ast_cli_entry cli_show_manager_eventq_deprecated
struct {
   char *   words [AST_MAX_CMD_LEN]
command_blacklist []
static const int DEFAULT_AUTHLIMIT = 50
static const int DEFAULT_AUTHTIMEOUT = 30
static const int DEFAULT_BLOCKSOCKETS = 0
static const int DEFAULT_BROKENEVENTSACTION = 0
static const int DEFAULT_DISPLAYCONNECTS = 1
static const int DEFAULT_ENABLED = 0
static const int DEFAULT_HTTPTIMEOUT = 60
static const int DEFAULT_TIMESTAMPEVENTS = 0
static const int DEFAULT_WEBENABLED = 0
static int displayconnects
static int enabled
static struct manager_actionfirst_action
static int httptimeout
static struct ast_threadstorage manager_event_buf = { .once = PTHREAD_ONCE_INIT , .key_init = manager_event_buf_init , }
static char mandescr_command []
static char mandescr_events []
static char mandescr_extensionstate []
static char mandescr_getconfig []
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 []
 Manager PING.
static char mandescr_redirect []
static char mandescr_setvar []
static char mandescr_timeout []
static char mandescr_updateconfig []
static char mandescr_userevent []
static char mandescr_waitevent []
 Manager WAITEVENT.
struct eventqentmaster_eventq = NULL
static int num_sessions
static struct permalias perms []
static int portno = DEFAULT_MANAGER_PORT
static char showmanager_help []
static char showmanagers_help []
static char showmancmd_help []
static char showmancmds_help []
static char showmanconn_help []
static char showmaneventq_help []
static pthread_t t
static int timestampevents
static int unauth_sessions = 0

Detailed Description

callback to display queues status in manager


Define Documentation

#define ASTMAN_APPEND_BUF_INITSIZE   256

Definition at line 133 of file manager.c.

Referenced by astman_append().

#define MANAGER_EVENT_BUF_INITSIZE   256

Definition at line 130 of file manager.c.

Referenced by manager_event().

#define MAX_BLACKLIST_CMD_LEN   2

Definition at line 151 of file manager.c.

Referenced by check_blacklist().


Function Documentation

static void* accept_thread ( void *  ignore  )  [static]

Definition at line 2521 of file manager.c.

References mansession_session::__lock, ast_atomic_fetchadd_int(), ast_calloc, ast_inet_ntoa(), AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_log(), ast_mutex_init(), ast_poll, ast_pthread_create_background, AST_PTHREADT_NULL, ast_verbose(), mansession_session::authenticated, mansession_session::authstart, destroy_session(), errno, mansession_session::eventq, mansession_session::fd, ast_channel::flags, free, free_session(), mansession_session::inuse, mansession_session::list, LOG_ERROR, LOG_NOTICE, LOG_WARNING, eventqent::next, option_verbose, s, mansession_session::send_events, session_do(), mansession_session::sessiontimeout, mansession_session::sin, eventqent::usecount, mansession_session::username, VERBOSE_PREFIX_2, mansession_session::waiting_thread, and mansession_session::writetimeout.

Referenced by init_manager(), and reload_config().

02522 {
02523    int as;
02524    struct sockaddr_in sin;
02525    socklen_t sinlen;
02526    struct eventqent *eqe;
02527    struct mansession_session *s;
02528    struct protoent *p;
02529    int arg = 1;
02530    int flags;
02531    pthread_t t;
02532    pthread_attr_t attr;
02533    time_t now;
02534    struct pollfd pfds[1];
02535 
02536    pthread_attr_init(&attr);
02537    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
02538 
02539    for (;;) {
02540       time(&now);
02541       AST_LIST_LOCK(&sessions);
02542       AST_LIST_TRAVERSE_SAFE_BEGIN(&sessions, s, list) {
02543          if (s->sessiontimeout && (now > s->sessiontimeout) && !s->inuse) {
02544             AST_LIST_REMOVE_CURRENT(&sessions, list);
02545             num_sessions--;
02546             if (s->authenticated && (option_verbose > 1) && displayconnects) {
02547                ast_verbose(VERBOSE_PREFIX_2 "HTTP Manager '%s' timed out from %s\n",
02548                   s->username, ast_inet_ntoa(s->sin.sin_addr));
02549             }
02550             free_session(s);
02551             break;   
02552          }
02553       }
02554       AST_LIST_TRAVERSE_SAFE_END
02555       /* Purge master event queue of old, unused events, but make sure we
02556          always keep at least one in the queue */
02557       eqe = master_eventq;
02558       while (master_eventq->next && !master_eventq->usecount) {
02559          eqe = master_eventq;
02560          master_eventq = master_eventq->next;
02561          free(eqe);
02562       }
02563       AST_LIST_UNLOCK(&sessions);
02564 
02565       sinlen = sizeof(sin);
02566       pfds[0].fd = asock;
02567       pfds[0].events = POLLIN;
02568       /* Wait for something to happen, but timeout every few seconds so
02569          we can ditch any old manager sessions */
02570       if (ast_poll(pfds, 1, 5000) < 1)
02571          continue;
02572       as = accept(asock, (struct sockaddr *)&sin, &sinlen);
02573       if (as < 0) {
02574          ast_log(LOG_NOTICE, "Accept returned -1: %s\n", strerror(errno));
02575          continue;
02576       }
02577 
02578       if (ast_atomic_fetchadd_int(&unauth_sessions, +1) >= authlimit) {
02579          close(as);
02580          ast_atomic_fetchadd_int(&unauth_sessions, -1);
02581          ast_log(LOG_WARNING, "manager connection rejected, too many unauthenticated sessions.\n");
02582          continue;
02583       }
02584 
02585       p = getprotobyname("tcp");
02586       if (p) {
02587          if( setsockopt(as, p->p_proto, TCP_NODELAY, (char *)&arg, sizeof(arg) ) < 0 ) {
02588             ast_log(LOG_WARNING, "Failed to set manager tcp connection to TCP_NODELAY mode: %s\n", strerror(errno));
02589          }
02590       }
02591       if (!(s = ast_calloc(1, sizeof(*s)))) {
02592          close(as);
02593          ast_atomic_fetchadd_int(&unauth_sessions, -1);
02594          continue;
02595       }
02596 
02597       memcpy(&s->sin, &sin, sizeof(sin));
02598       s->writetimeout = 100;
02599       s->waiting_thread = AST_PTHREADT_NULL;
02600 
02601       if (!block_sockets) {
02602          /* For safety, make sure socket is non-blocking */
02603          flags = fcntl(as, F_GETFL);
02604          fcntl(as, F_SETFL, flags | O_NONBLOCK);
02605       } else {
02606          flags = fcntl(as, F_GETFL);
02607          fcntl(as, F_SETFL, flags & ~O_NONBLOCK);
02608       }
02609       ast_mutex_init(&s->__lock);
02610       s->fd = as;
02611       s->send_events = -1;
02612       AST_LIST_LOCK(&sessions);
02613       AST_LIST_INSERT_HEAD(&sessions, s, list);
02614       num_sessions++;
02615       /* Find the last place in the master event queue and hook ourselves
02616          in there */
02617       s->eventq = master_eventq;
02618       while(s->eventq->next)
02619          s->eventq = s->eventq->next;
02620       ast_atomic_fetchadd_int(&s->eventq->usecount, 1);
02621       AST_LIST_UNLOCK(&sessions);
02622       if(time(&s->authstart) == -1) {
02623          ast_log(LOG_ERROR, "error executing time(): %s; disconnecting client\n", strerror(errno));
02624          ast_atomic_fetchadd_int(&unauth_sessions, -1);
02625          destroy_session(s);
02626          continue;
02627       }
02628       if (ast_pthread_create_background(&t, &attr, session_do, s)) {
02629          ast_atomic_fetchadd_int(&unauth_sessions, -1);
02630          destroy_session(s);
02631       }
02632    }
02633    pthread_attr_destroy(&attr);
02634    return NULL;
02635 }

static int action_command ( struct mansession s,
const struct message m 
) [static]

action_command: Manager command "command" - execute CLI command

Definition at line 1838 of file manager.c.

References ast_calloc, ast_cli_command(), ast_free, ast_log(), ast_strlen_zero(), astman_append(), astman_get_header(), astman_send_error(), check_blacklist(), errno, mansession_session::fd, LOG_WARNING, S_OR, and term_strip().

Referenced by init_manager().

01839 {
01840    const char *cmd = astman_get_header(m, "Command");
01841    const char *id = astman_get_header(m, "ActionID");
01842    char *buf, *final_buf;
01843    char template[] = "/tmp/ast-ami-XXXXXX";  /* template for temporary file */
01844    int fd;
01845    off_t l;
01846 
01847    if (ast_strlen_zero(cmd)) {
01848       astman_send_error(s, m, "No command provided");
01849       return 0;
01850    }
01851 
01852    if (check_blacklist(cmd)) {
01853       astman_send_error(s, m, "Command blacklisted");
01854       return 0;
01855    }
01856 
01857    fd = mkstemp(template);
01858 
01859    astman_append(s, "Response: Follows\r\nPrivilege: Command\r\n");
01860    if (!ast_strlen_zero(id))
01861       astman_append(s, "ActionID: %s\r\n", id);
01862    /* FIXME: Wedge a ActionID response in here, waiting for later changes */
01863    ast_cli_command(fd, cmd);  /* XXX need to change this to use a FILE * */
01864    l = lseek(fd, 0, SEEK_END);   /* how many chars available */
01865 
01866    /* This has a potential to overflow the stack.  Hence, use the heap. */
01867    buf = ast_calloc(1, l + 1);
01868    final_buf = ast_calloc(1, l + 1);
01869    if (buf) {
01870       lseek(fd, 0, SEEK_SET);
01871       if (read(fd, buf, l) < 0) {
01872          ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
01873       }
01874       buf[l] = '\0';
01875       if (final_buf) {
01876          term_strip(final_buf, buf, l);
01877          final_buf[l] = '\0';
01878       }
01879       astman_append(s, "%s", S_OR(final_buf, buf));
01880       ast_free(buf);
01881    }
01882    close(fd);
01883    unlink(template);
01884    astman_append(s, "--END COMMAND--\r\n\r\n");
01885    if (final_buf)
01886       ast_free(final_buf);
01887    return 0;
01888 }

static int action_events ( struct mansession s,
const struct message m 
) [static]

Definition at line 1447 of file manager.c.

References ARRAY_LEN, astman_get_header(), astman_send_error(), astman_send_response(), permalias::num, perms, mansession::session, and set_eventmask().

Referenced by init_manager().

01448 {
01449    const char *mask = astman_get_header(m, "EventMask");
01450    int res, x;
01451 
01452    res = set_eventmask(s->session, mask);
01453    if (broken_events_action) {
01454       /* if this option is set we should not return a response on
01455        * error, or when all events are set */
01456 
01457       if (res > 0) {
01458          for (x = 0; x < ARRAY_LEN(perms); x++) {
01459             if (!strcasecmp(perms[x].label, "all") && res == perms[x].num) {
01460                return 0;
01461             }
01462          }
01463          astman_send_response(s, m, "Events On", NULL);
01464       } else if (res == 0)
01465          astman_send_response(s, m, "Events Off", NULL);
01466       return 0;
01467    }
01468 
01469    if (res > 0)
01470       astman_send_response(s, m, "Events On", NULL);
01471    else if (res == 0)
01472       astman_send_response(s, m, "Events Off", NULL);
01473    else
01474       astman_send_error(s, m, "Invalid event mask");
01475 
01476    return 0;
01477 }

static int action_extensionstate ( struct mansession s,
const struct message m 
) [static]

Definition at line 2156 of file manager.c.

References ast_extension_state(), ast_get_hint(), ast_strlen_zero(), astman_append(), astman_get_header(), astman_send_error(), context, and exten.

Referenced by init_manager().

02157 {
02158    const char *exten = astman_get_header(m, "Exten");
02159    const char *context = astman_get_header(m, "Context");
02160    const char *id = astman_get_header(m,"ActionID");
02161    char idText[256] = "";
02162    char hint[256] = "";
02163    int status;
02164    if (ast_strlen_zero(exten)) {
02165       astman_send_error(s, m, "Extension not specified");
02166       return 0;
02167    }
02168    if (ast_strlen_zero(context))
02169       context = "default";
02170    status = ast_extension_state(NULL, context, exten);
02171    ast_get_hint(hint, sizeof(hint) - 1, NULL, 0, NULL, context, exten);
02172         if (!ast_strlen_zero(id)) {
02173                 snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
02174         }
02175    astman_append(s, "Response: Success\r\n"
02176                     "%s"
02177                "Message: Extension Status\r\n"
02178                "Exten: %s\r\n"
02179                "Context: %s\r\n"
02180                "Hint: %s\r\n"
02181                "Status: %d\r\n\r\n",
02182                idText,exten, context, hint, status);
02183    return 0;
02184 }

static int action_getconfig ( struct mansession s,
const struct message m 
) [static]

Definition at line 1176 of file manager.c.

References ast_category_browse(), ast_config_destroy(), ast_config_load_with_comments(), ast_strlen_zero(), ast_variable_browse(), astman_append(), astman_get_header(), astman_send_error(), ast_variable::name, ast_variable::next, and ast_variable::value.

Referenced by init_manager().

01177 {
01178    struct ast_config *cfg;
01179    const char *fn = astman_get_header(m, "Filename");
01180    int catcount = 0;
01181    int lineno = 0;
01182    char *category=NULL;
01183    struct ast_variable *v;
01184    char idText[256] = "";
01185    const char *id = astman_get_header(m, "ActionID");
01186 
01187    if (!ast_strlen_zero(id))
01188       snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
01189 
01190    if (ast_strlen_zero(fn)) {
01191       astman_send_error(s, m, "Filename not specified");
01192       return 0;
01193    }
01194    if (!(cfg = ast_config_load_with_comments(fn))) {
01195       astman_send_error(s, m, "Config file not found");
01196       return 0;
01197    }
01198    astman_append(s, "Response: Success\r\n%s", idText);
01199    while ((category = ast_category_browse(cfg, category))) {
01200       lineno = 0;
01201       astman_append(s, "Category-%06d: %s\r\n", catcount, category);
01202       for (v = ast_variable_browse(cfg, category); v; v = v->next)
01203          astman_append(s, "Line-%06d-%06d: %s=%s\r\n", catcount, lineno++, v->name, v->value);
01204       catcount++;
01205    }
01206    ast_config_destroy(cfg);
01207    astman_append(s, "\r\n");
01208 
01209    return 0;
01210 }

static int action_getvar ( struct mansession s,
const struct message m 
) [static]

Definition at line 1567 of file manager.c.

References ast_channel_alloc(), ast_channel_free(), ast_channel_unlock, ast_func_read(), ast_get_channel_by_name_locked(), ast_log(), ast_strdupa, ast_strlen_zero(), astman_append(), astman_get_header(), astman_send_error(), copy(), LOG_ERROR, name, pbx_retrieve_variable(), and S_OR.

Referenced by init_manager().

01568 {
01569    struct ast_channel *c = NULL;
01570    const char *name = astman_get_header(m, "Channel");
01571    const char *varname = astman_get_header(m, "Variable");
01572    const char *id = astman_get_header(m,"ActionID");
01573    char *varval;
01574    char workspace[1024] = "";
01575 
01576    if (ast_strlen_zero(varname)) {
01577       astman_send_error(s, m, "No variable specified");
01578       return 0;
01579    }
01580 
01581    if (!ast_strlen_zero(name)) {
01582       c = ast_get_channel_by_name_locked(name);
01583       if (!c) {
01584          astman_send_error(s, m, "No such channel");
01585          return 0;
01586       }
01587    }
01588 
01589    if (varname[strlen(varname) - 1] == ')') {
01590       char *copy = ast_strdupa(varname);
01591       if (!c) {
01592          c = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Bogus/manager");
01593          if (c) {
01594             ast_func_read(c, copy, workspace, sizeof(workspace));
01595             ast_channel_free(c);
01596             c = NULL;
01597          } else
01598             ast_log(LOG_ERROR, "Unable to allocate bogus channel for variable substitution.  Function results may be blank.\n");
01599       } else
01600          ast_func_read(c, copy, workspace, sizeof(workspace));
01601       varval = workspace;
01602    } else {
01603       pbx_retrieve_variable(c, varname, &varval, workspace, sizeof(workspace), NULL);
01604    }
01605 
01606    if (c)
01607       ast_channel_unlock(c);
01608    astman_append(s, "Response: Success\r\n"
01609       "Variable: %s\r\nValue: %s\r\n", varname, S_OR(varval, ""));
01610    if (!ast_strlen_zero(id))
01611       astman_append(s, "ActionID: %s\r\n",id);
01612    astman_append(s, "\r\n");
01613 
01614    return 0;
01615 }

static int action_hangup ( struct mansession s,
const struct message m 
) [static]

Definition at line 1494 of file manager.c.

References ast_channel_unlock, ast_get_channel_by_name_locked(), ast_softhangup(), AST_SOFTHANGUP_EXPLICIT, ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), and name.

Referenced by init_manager().

01495 {
01496    struct ast_channel *c = NULL;
01497    const char *name = astman_get_header(m, "Channel");
01498    if (ast_strlen_zero(name)) {
01499       astman_send_error(s, m, "No channel specified");
01500       return 0;
01501    }
01502    c = ast_get_channel_by_name_locked(name);
01503    if (!c) {
01504       astman_send_error(s, m, "No such channel");
01505       return 0;
01506    }
01507    ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
01508    ast_channel_unlock(c);
01509    astman_send_ack(s, m, "Channel Hungup");
01510    return 0;
01511 }

static int action_listcommands ( struct mansession s,
const struct message m 
) [static]

Note:
The actionlock is read-locked by the caller of this function

Definition at line 1420 of file manager.c.

References manager_action::action, ast_strlen_zero(), astman_append(), astman_get_header(), manager_action::authority, authority_to_str(), first_action, manager_action::next, mansession::session, manager_action::synopsis, and mansession_session::writeperm.

Referenced by init_manager().

01421 {
01422    struct manager_action *cur;
01423    char idText[256] = "";
01424    char temp[BUFSIZ];
01425    const char *id = astman_get_header(m,"ActionID");
01426 
01427    if (!ast_strlen_zero(id))
01428       snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
01429    astman_append(s, "Response: Success\r\n%s", idText);
01430    for (cur = first_action; cur; cur = cur->next) {
01431       if ((s->session->writeperm & cur->authority) == cur->authority)
01432          astman_append(s, "%s: %s (Priv: %s)\r\n", cur->action, cur->synopsis, authority_to_str(cur->authority, temp, sizeof(temp)));
01433    }
01434    astman_append(s, "\r\n");
01435 
01436    return 0;
01437 }

static int action_logoff ( struct mansession s,
const struct message m 
) [static]

Definition at line 1483 of file manager.c.

References astman_send_response().

Referenced by init_manager().

01484 {
01485    astman_send_response(s, m, "Goodbye", "Thanks for all the fish.");
01486    return -1;
01487 }

static int action_mailboxcount ( struct mansession s,
const struct message m 
) [static]

Definition at line 2120 of file manager.c.

References ast_app_inboxcount(), ast_strlen_zero(), astman_append(), astman_get_header(), astman_send_error(), and mailbox.

Referenced by init_manager().

02121 {
02122    const char *mailbox = astman_get_header(m, "Mailbox");
02123    const char *id = astman_get_header(m,"ActionID");
02124    char idText[256] = "";
02125    int newmsgs = 0, oldmsgs = 0;
02126    if (ast_strlen_zero(mailbox)) {
02127       astman_send_error(s, m, "Mailbox not specified");
02128       return 0;
02129    }
02130    ast_app_inboxcount(mailbox, &newmsgs, &oldmsgs);
02131    if (!ast_strlen_zero(id)) {
02132       snprintf(idText, sizeof(idText), "ActionID: %s\r\n",id);
02133    }
02134    astman_append(s, "Response: Success\r\n"
02135                "%s"
02136                "Message: Mailbox Message Count\r\n"
02137                "Mailbox: %s\r\n"
02138                "NewMessages: %d\r\n"
02139                "OldMessages: %d\r\n" 
02140                "\r\n",
02141                 idText,mailbox, newmsgs, oldmsgs);
02142    return 0;
02143 }

static int action_mailboxstatus ( struct mansession s,
const struct message m 
) [static]

Definition at line 2088 of file manager.c.

References ast_app_has_voicemail(), ast_strlen_zero(), astman_append(), astman_get_header(), astman_send_error(), and mailbox.

Referenced by init_manager().

02089 {
02090    const char *mailbox = astman_get_header(m, "Mailbox");
02091    const char *id = astman_get_header(m,"ActionID");
02092    char idText[256] = "";
02093    int ret;
02094    if (ast_strlen_zero(mailbox)) {
02095       astman_send_error(s, m, "Mailbox not specified");
02096       return 0;
02097    }
02098         if (!ast_strlen_zero(id))
02099                 snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
02100    ret = ast_app_has_voicemail(mailbox, NULL);
02101    astman_append(s, "Response: Success\r\n"
02102                "%s"
02103                "Message: Mailbox Status\r\n"
02104                "Mailbox: %s\r\n"
02105                "Waiting: %d\r\n\r\n", idText, mailbox, ret);
02106    return 0;
02107 }

static int action_originate ( struct mansession s,
const struct message m 
) [static]

Definition at line 1956 of file manager.c.

References fast_originate_helper::account, fast_originate_helper::app, app, fast_originate_helper::appdata, ast_callerid_parse(), ast_calloc, ast_copy_string(), ast_findlabel_extension(), AST_FORMAT_SLINEAR, ast_free, ast_parse_allow_disallow(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_pthread_create, ast_shrink_phone_number(), ast_strlen_zero(), ast_true(), ast_variables_destroy(), 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, ast_channel::data, fast_originate_helper::exten, exten, fast_originate(), fast_originate_helper::format, format, fast_originate_helper::idtext, name, fast_originate_helper::priority, ast_channel::priority, fast_originate_helper::tech, ast_channel::tech, fast_originate_helper::timeout, and fast_originate_helper::vars.

Referenced by init_manager().

01957 {
01958    const char *name = astman_get_header(m, "Channel");
01959    const char *exten = astman_get_header(m, "Exten");
01960    const char *context = astman_get_header(m, "Context");
01961    const char *priority = astman_get_header(m, "Priority");
01962    const char *timeout = astman_get_header(m, "Timeout");
01963    const char *callerid = astman_get_header(m, "CallerID");
01964    const char *account = astman_get_header(m, "Account");
01965    const char *app = astman_get_header(m, "Application");
01966    const char *appdata = astman_get_header(m, "Data");
01967    const char *async = astman_get_header(m, "Async");
01968    const char *id = astman_get_header(m, "ActionID");
01969    const char *codecs = astman_get_header(m, "Codecs");
01970    struct ast_variable *vars;
01971    char *tech, *data;
01972    char *l = NULL, *n = NULL;
01973    int pi = 0;
01974    int res;
01975    int to = 30000;
01976    int reason = 0;
01977    char tmp[256];
01978    char tmp2[256];
01979    int format = AST_FORMAT_SLINEAR;
01980    
01981    pthread_t th;
01982    pthread_attr_t attr;
01983    if (ast_strlen_zero(name)) {
01984       astman_send_error(s, m, "Channel not specified");
01985       return 0;
01986    }
01987    if (!ast_strlen_zero(priority) && (sscanf(priority, "%30d", &pi) != 1)) {
01988       if ((pi = ast_findlabel_extension(NULL, context, exten, priority, NULL)) < 1) {
01989          astman_send_error(s, m, "Invalid priority");
01990          return 0;
01991       }
01992    }
01993    if (!ast_strlen_zero(timeout) && (sscanf(timeout, "%30d", &to) != 1)) {
01994       astman_send_error(s, m, "Invalid timeout");
01995       return 0;
01996    }
01997    ast_copy_string(tmp, name, sizeof(tmp));
01998    tech = tmp;
01999    data = strchr(tmp, '/');
02000    if (!data) {
02001       astman_send_error(s, m, "Invalid channel");
02002       return 0;
02003    }
02004    *data++ = '\0';
02005    ast_copy_string(tmp2, callerid, sizeof(tmp2));
02006    ast_callerid_parse(tmp2, &n, &l);
02007    if (n) {
02008       if (ast_strlen_zero(n))
02009          n = NULL;
02010    }
02011    if (l) {
02012       ast_shrink_phone_number(l);
02013       if (ast_strlen_zero(l))
02014          l = NULL;
02015    }
02016    if (!ast_strlen_zero(codecs)) {
02017       format = 0;
02018       ast_parse_allow_disallow(NULL, &format, codecs, 1);
02019    }
02020    /* Allocate requested channel variables */
02021    vars = astman_get_variables(m);
02022 
02023    if (ast_true(async)) {
02024       struct fast_originate_helper *fast = ast_calloc(1, sizeof(*fast));
02025       if (!fast) {
02026          res = -1;
02027       } else {
02028          if (!ast_strlen_zero(id))
02029             snprintf(fast->idtext, sizeof(fast->idtext), "ActionID: %s", id);
02030          ast_copy_string(fast->tech, tech, sizeof(fast->tech));
02031             ast_copy_string(fast->data, data, sizeof(fast->data));
02032          ast_copy_string(fast->app, app, sizeof(fast->app));
02033          ast_copy_string(fast->appdata, appdata, sizeof(fast->appdata));
02034          if (l)
02035             ast_copy_string(fast->cid_num, l, sizeof(fast->cid_num));
02036          if (n)
02037             ast_copy_string(fast->cid_name, n, sizeof(fast->cid_name));
02038          fast->vars = vars;   
02039          ast_copy_string(fast->context, context, sizeof(fast->context));
02040          ast_copy_string(fast->exten, exten, sizeof(fast->exten));
02041          ast_copy_string(fast->account, account, sizeof(fast->account));
02042          fast->format = format;
02043          fast->timeout = to;
02044          fast->priority = pi;
02045          pthread_attr_init(&attr);
02046          pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
02047          if (ast_pthread_create(&th, &attr, fast_originate, fast)) {
02048             ast_free(fast);
02049             res = -1;
02050          } else {
02051             res = 0;
02052          }
02053          pthread_attr_destroy(&attr);
02054       }
02055    } else if (!ast_strlen_zero(app)) {
02056          res = ast_pbx_outgoing_app(tech, format, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
02057       } else {
02058       if (exten && context && pi)
02059             res = ast_pbx_outgoing_exten(tech, format, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL);
02060       else {
02061          astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'");
02062          if (vars) {
02063             ast_variables_destroy(vars);
02064          }
02065          return 0;
02066       }
02067    }   
02068    if (!res)
02069       astman_send_ack(s, m, "Originate successfully queued");
02070    else
02071       astman_send_error(s, m, "Originate failed");
02072    return 0;
02073 }

static int action_ping ( struct mansession s,
const struct message m 
) [static]

Definition at line 1164 of file manager.c.

References astman_send_response().

Referenced by init_manager().

01165 {
01166    astman_send_response(s, m, "Pong", NULL);
01167    return 0;
01168 }

static int action_redirect ( struct mansession s,
const struct message m 
) [static]

action_redirect: The redirect manager command

Definition at line 1721 of file manager.c.

References ast_async_goto(), ast_channel_lock, ast_channel_unlock, ast_check_hangup(), ast_findlabel_extension(), AST_FLAG_BRIDGE_HANGUP_DONT, ast_get_channel_by_name_locked(), ast_set_flag, ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), context, exten, name, and ast_channel::pbx.

Referenced by init_manager().

01722 {
01723    const char *name = astman_get_header(m, "Channel");
01724    const char *name2 = astman_get_header(m, "ExtraChannel");
01725    const char *exten = astman_get_header(m, "Exten");
01726    const char *context = astman_get_header(m, "Context");
01727    const char *priority = astman_get_header(m, "Priority");
01728    struct ast_channel *chan, *chan2 = NULL;
01729    int pi = 0;
01730    int res;
01731 
01732    if (ast_strlen_zero(name)) {
01733       astman_send_error(s, m, "Channel not specified");
01734       return 0;
01735    }
01736    if (!ast_strlen_zero(priority) && (sscanf(priority, "%30d", &pi) != 1)) {
01737       if ((pi = ast_findlabel_extension(NULL, context, exten, priority, NULL)) < 1) {
01738          astman_send_error(s, m, "Invalid priority");
01739          return 0;
01740       }
01741    }
01742    /* XXX watch out, possible deadlock!!! */
01743    chan = ast_get_channel_by_name_locked(name);
01744    if (!chan) {
01745       char buf[BUFSIZ];
01746       snprintf(buf, sizeof(buf), "Channel does not exist: %s", name);
01747       astman_send_error(s, m, buf);
01748       return 0;
01749    }
01750    if (ast_check_hangup(chan)) {
01751       astman_send_error(s, m, "Redirect failed, channel not up.");
01752       ast_channel_unlock(chan);
01753       return 0;
01754    }
01755    if (!ast_strlen_zero(name2))
01756       chan2 = ast_get_channel_by_name_locked(name2);
01757    if (chan2 && ast_check_hangup(chan2)) {
01758       astman_send_error(s, m, "Redirect failed, extra channel not up.");
01759       ast_channel_unlock(chan);
01760       ast_channel_unlock(chan2);
01761       return 0;
01762    }
01763    if (chan->pbx) {
01764       ast_channel_lock(chan);
01765       ast_set_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */
01766       ast_channel_unlock(chan);
01767    }
01768    res = ast_async_goto(chan, context, exten, pi);
01769    if (!res) {
01770       if (!ast_strlen_zero(name2)) {
01771          if (chan2) {
01772             if (chan2->pbx) {
01773                ast_channel_lock(chan2);
01774                ast_set_flag(chan2, AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */
01775                ast_channel_unlock(chan2);
01776             }
01777             res = ast_async_goto(chan2, context, exten, pi);
01778          } else {
01779             res = -1;
01780          }
01781          if (!res)
01782             astman_send_ack(s, m, "Dual Redirect successful");
01783          else
01784             astman_send_error(s, m, "Secondary redirect failed");
01785       } else
01786          astman_send_ack(s, m, "Redirect successful");
01787    } else
01788       astman_send_error(s, m, "Redirect failed");
01789    if (chan)
01790       ast_channel_unlock(chan);
01791    if (chan2)
01792       ast_channel_unlock(chan2);
01793    return 0;
01794 }

static int action_setvar ( struct mansession s,
const struct message m 
) [static]

Definition at line 1520 of file manager.c.

References ast_channel_unlock, ast_func_write(), ast_get_channel_by_name_locked(), ast_strdupa, ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), name, pbx_builtin_setvar_helper(), and S_OR.

Referenced by init_manager().

01521 {
01522         struct ast_channel *c = NULL;
01523    const char *name = astman_get_header(m, "Channel");
01524    const char *varname = astman_get_header(m, "Variable");
01525    const char *varval = astman_get_header(m, "Value");
01526    int res = 0;
01527    
01528    if (ast_strlen_zero(varname)) {
01529       astman_send_error(s, m, "No variable specified");
01530       return 0;
01531    }
01532    
01533    if (!ast_strlen_zero(name)) {
01534       c = ast_get_channel_by_name_locked(name);
01535       if (!c) {
01536          astman_send_error(s, m, "No such channel");
01537          return 0;
01538       }
01539    }
01540    if (varname[strlen(varname)-1] == ')') {
01541       char *function = ast_strdupa(varname);
01542       res = ast_func_write(c, function, varval);
01543    } else {
01544       pbx_builtin_setvar_helper(c, varname, S_OR(varval, ""));
01545    }
01546      
01547    if (c) {
01548       ast_channel_unlock(c);
01549    }
01550 
01551    if (res == 0) {
01552       astman_send_ack(s, m, "Variable Set"); 
01553    } else {
01554       astman_send_error(s, m, "Variable not set");
01555    }
01556 
01557    return 0;
01558 }

static int action_status ( struct mansession s,
const struct message m 
) [static]

Manager "status" command to show channels.

Definition at line 1620 of file manager.c.

References ast_channel::_bridge, ast_channel::_state, ast_channel::accountcode, ast_channel_unlock, ast_channel_walk_locked(), ast_get_channel_by_name_locked(), ast_state2str(), ast_strlen_zero(), ast_tvnow(), astman_append(), 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::name, name, ast_channel::pbx, ast_channel::priority, S_OR, ast_cdr::start, and ast_channel::uniqueid.

Referenced by init_manager().

01621 {
01622    const char *id = astman_get_header(m,"ActionID");
01623       const char *name = astman_get_header(m,"Channel");
01624    char idText[256] = "";
01625    struct ast_channel *c;
01626    char bridge[256];
01627    struct timeval now = ast_tvnow();
01628    long elapsed_seconds = 0;
01629    int all = ast_strlen_zero(name); /* set if we want all channels */
01630 
01631    if (!ast_strlen_zero(id))
01632       snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
01633    if (all)
01634       c = ast_channel_walk_locked(NULL);
01635    else {
01636       c = ast_get_channel_by_name_locked(name);
01637       if (!c) {
01638          astman_send_error(s, m, "No such channel");
01639          return 0;
01640       }
01641    }
01642    astman_send_ack(s, m, "Channel status will follow");
01643    /* if we look by name, we break after the first iteration */
01644    while (c) {
01645       if (c->_bridge)
01646          snprintf(bridge, sizeof(bridge), "Link: %s\r\n", c->_bridge->name);
01647       else
01648          bridge[0] = '\0';
01649       if (c->pbx) {
01650          if (c->cdr) {
01651             elapsed_seconds = now.tv_sec - c->cdr->start.tv_sec;
01652          }
01653          astman_append(s,
01654          "Event: Status\r\n"
01655          "Privilege: Call\r\n"
01656          "Channel: %s\r\n"
01657          "CallerID: %s\r\n"      /* This parameter is deprecated and will be removed post-1.4 */
01658          "CallerIDNum: %s\r\n"
01659          "CallerIDName: %s\r\n"
01660          "Account: %s\r\n"
01661          "State: %s\r\n"
01662          "Context: %s\r\n"
01663          "Extension: %s\r\n"
01664          "Priority: %d\r\n"
01665          "Seconds: %ld\r\n"
01666          "%s"
01667          "Uniqueid: %s\r\n"
01668          "%s"
01669          "\r\n",
01670          c->name, 
01671          S_OR(c->cid.cid_num, "<unknown>"), 
01672          S_OR(c->cid.cid_num, "<unknown>"), 
01673          S_OR(c->cid.cid_name, "<unknown>"), 
01674          c->accountcode,
01675          ast_state2str(c->_state), c->context,
01676          c->exten, c->priority, (long)elapsed_seconds, bridge, c->uniqueid, idText);
01677       } else {
01678          astman_append(s,
01679          "Event: Status\r\n"
01680          "Privilege: Call\r\n"
01681          "Channel: %s\r\n"
01682          "CallerID: %s\r\n"      /* This parameter is deprecated and will be removed post-1.4 */
01683          "CallerIDNum: %s\r\n"
01684          "CallerIDName: %s\r\n"
01685          "Account: %s\r\n"
01686          "State: %s\r\n"
01687          "%s"
01688          "Uniqueid: %s\r\n"
01689          "%s"
01690          "\r\n",
01691          c->name, 
01692          S_OR(c->cid.cid_num, "<unknown>"), 
01693          S_OR(c->cid.cid_num, "<unknown>"), 
01694          S_OR(c->cid.cid_name, "<unknown>"), 
01695          c->accountcode,
01696          ast_state2str(c->_state), bridge, c->uniqueid, idText);
01697       }
01698       ast_channel_unlock(c);
01699       if (!all)
01700          break;
01701       c = ast_channel_walk_locked(c);
01702    }
01703    astman_append(s,
01704    "Event: StatusComplete\r\n"
01705    "%s"
01706    "\r\n",idText);
01707    return 0;
01708 }

static int action_timeout ( struct mansession s,
const struct message m 
) [static]

Definition at line 2193 of file manager.c.

References ast_channel_setwhentohangup(), ast_channel_unlock, ast_get_channel_by_name_locked(), ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), and name.

Referenced by init_manager().

02194 {
02195    struct ast_channel *c = NULL;
02196    const char *name = astman_get_header(m, "Channel");
02197    int timeout = atoi(astman_get_header(m, "Timeout"));
02198    if (ast_strlen_zero(name)) {
02199       astman_send_error(s, m, "No channel specified");
02200       return 0;
02201    }
02202    if (!timeout) {
02203       astman_send_error(s, m, "No timeout specified");
02204       return 0;
02205    }
02206    c = ast_get_channel_by_name_locked(name);
02207    if (!c) {
02208       astman_send_error(s, m, "No such channel");
02209       return 0;
02210    }
02211    ast_channel_setwhentohangup(c, timeout);
02212    ast_channel_unlock(c);
02213    astman_send_ack(s, m, "Timeout Set");
02214    return 0;
02215 }

static int action_updateconfig ( struct mansession s,
const struct message m 
) [static]

Definition at line 1287 of file manager.c.

References ast_config_destroy(), ast_config_load_with_comments(), ast_module_reload(), ast_strlen_zero(), ast_true(), astman_append(), astman_get_header(), astman_send_error(), config_text_file_save(), and handle_updates().

Referenced by init_manager().

01288 {
01289    struct ast_config *cfg;
01290    const char *sfn = astman_get_header(m, "SrcFilename");
01291    const char *dfn = astman_get_header(m, "DstFilename");
01292    int res;
01293    char idText[256] = "";
01294    const char *id = astman_get_header(m, "ActionID");
01295    const char *rld = astman_get_header(m, "Reload");
01296 
01297    if (!ast_strlen_zero(id))
01298       snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
01299 
01300    if (ast_strlen_zero(sfn) || ast_strlen_zero(dfn)) {
01301       astman_send_error(s, m, "Filename not specified");
01302       return 0;
01303    }
01304    if (!(cfg = ast_config_load_with_comments(sfn))) {
01305       astman_send_error(s, m, "Config file not found");
01306       return 0;
01307    }
01308    handle_updates(s, m, cfg);
01309    res = config_text_file_save(dfn, cfg, "Manager");
01310    ast_config_destroy(cfg);
01311    if (res) {
01312       astman_send_error(s, m, "Save of config failed");
01313       return 0;
01314    }
01315    astman_append(s, "Response: Success\r\n%s\r\n", idText);
01316    if (!ast_strlen_zero(rld)) {
01317       if (ast_true(rld))
01318          rld = NULL;
01319       ast_module_reload(rld); 
01320    }
01321    return 0;
01322 }

static int action_userevent ( struct mansession s,
const struct message m 
) [static]

Definition at line 2250 of file manager.c.

References ast_copy_string(), ast_log(), astman_get_header(), astman_send_ack(), EVENT_FLAG_USER, message::hdrcount, message::headers, LOG_WARNING, and manager_event().

Referenced by init_manager().

02251 {
02252    const char *event = astman_get_header(m, "UserEvent");
02253    char body[2048] = "";
02254    int x, bodylen = 0, xlen;
02255    for (x = 0; x < m->hdrcount; x++) {
02256       if (strncasecmp("UserEvent:", m->headers[x], strlen("UserEvent:"))) {
02257          if (sizeof(body) < bodylen + (xlen = strlen(m->headers[x])) + 3) {
02258             ast_log(LOG_WARNING, "UserEvent exceeds our buffer length.  Truncating.\n");
02259             break;
02260          }
02261          ast_copy_string(body + bodylen, m->headers[x], sizeof(body) - bodylen - 3);
02262          bodylen += xlen;
02263          ast_copy_string(body + bodylen, "\r\n", 3);
02264          bodylen += 2;
02265       }
02266    }
02267 
02268    astman_send_ack(s, m, "Event Sent");   
02269    manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", event, body);
02270    return 0;
02271 }

static int action_waitevent ( struct mansession s,
const struct message m 
) [static]

Definition at line 1332 of file manager.c.

References mansession_session::__lock, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), AST_PTHREADT_NULL, ast_strlen_zero(), ast_wait_for_input(), astman_append(), astman_get_header(), astman_send_response(), eventqent::category, eventqent::eventdata, mansession_session::eventq, mansession_session::fd, LOG_DEBUG, mansession_session::needdestroy, eventqent::next, option_debug, mansession_session::readperm, mansession_session::send_events, mansession::session, mansession_session::sessiontimeout, unuse_eventqent(), and mansession_session::waiting_thread.

Referenced by init_manager().

01333 {
01334    const char *timeouts = astman_get_header(m, "Timeout");
01335    int timeout = -1, max;
01336    int x;
01337    int needexit = 0;
01338    time_t now;
01339    struct eventqent *eqe;
01340    const char *id = astman_get_header(m,"ActionID");
01341    char idText[256] = "";
01342 
01343    if (!ast_strlen_zero(id))
01344       snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
01345 
01346    if (!ast_strlen_zero(timeouts)) {
01347       sscanf(timeouts, "%30i", &timeout);
01348    }
01349    
01350    ast_mutex_lock(&s->session->__lock);
01351    if (s->session->waiting_thread != AST_PTHREADT_NULL) {
01352       pthread_kill(s->session->waiting_thread, SIGURG);
01353    }
01354    if (s->session->sessiontimeout) {
01355       time(&now);
01356       max = s->session->sessiontimeout - now - 10;
01357       if (max < 0)
01358          max = 0;
01359       if ((timeout < 0) || (timeout > max))
01360          timeout = max;
01361       if (!s->session->send_events)
01362          s->session->send_events = -1;
01363       /* Once waitevent is called, always queue events from now on */
01364    }
01365    ast_mutex_unlock(&s->session->__lock);
01366    s->session->waiting_thread = pthread_self();
01367    if (option_debug)
01368       ast_log(LOG_DEBUG, "Starting waiting for an event!\n");
01369    for (x=0; ((x < timeout) || (timeout < 0)); x++) {
01370       ast_mutex_lock(&s->session->__lock);
01371       if (s->session->eventq && s->session->eventq->next)
01372          needexit = 1;
01373       if (s->session->waiting_thread != pthread_self())
01374          needexit = 1;
01375       if (s->session->needdestroy)
01376          needexit = 1;
01377       ast_mutex_unlock(&s->session->__lock);
01378       if (needexit)
01379          break;
01380       if (s->session->fd > 0) {
01381          if (ast_wait_for_input(s->session->fd, 1000))
01382             break;
01383       } else {
01384          sleep(1);
01385       }
01386    }
01387    if (option_debug)
01388       ast_log(LOG_DEBUG, "Finished waiting for an event!\n");
01389    ast_mutex_lock(&s->session->__lock);
01390    if (s->session->waiting_thread == pthread_self()) {
01391       astman_send_response(s, m, "Success", "Waiting for Event...");
01392       /* Only show events if we're the most recent waiter */
01393       while(s->session->eventq->next) {
01394          eqe = s->session->eventq->next;
01395          if (((s->session->readperm & eqe->category) == eqe->category) &&
01396              ((s->session->send_events & eqe->category) == eqe->category)) {
01397             astman_append(s, "%s", eqe->eventdata);
01398          }
01399          unuse_eventqent(s->session->eventq);
01400          s->session->eventq = eqe;
01401       }
01402       astman_append(s,
01403          "Event: WaitEventComplete\r\n"
01404          "%s"
01405          "\r\n", idText);
01406       s->session->waiting_thread = AST_PTHREADT_NULL;
01407    } else {
01408       ast_log(LOG_DEBUG, "Abandoning event request!\n");
01409    }
01410    ast_mutex_unlock(&s->session->__lock);
01411    return 0;
01412 }

static int append_event ( const char *  str,
int  category 
) [static]

Definition at line 2637 of file manager.c.

References ast_malloc, eventqent::category, eventqent::eventdata, eventqent::next, and eventqent::usecount.

Referenced by init_manager(), and manager_event().

02638 {
02639    struct eventqent *tmp, *prev = NULL;
02640    tmp = ast_malloc(sizeof(*tmp) + strlen(str));
02641 
02642    if (!tmp)
02643       return -1;
02644 
02645    tmp->next = NULL;
02646    tmp->category = category;
02647    strcpy(tmp->eventdata, str);
02648    
02649    if (master_eventq) {
02650       prev = master_eventq;
02651       while (prev->next) 
02652          prev = prev->next;
02653       prev->next = tmp;
02654    } else {
02655       master_eventq = tmp;
02656    }
02657    
02658    tmp->usecount = num_sessions;
02659    
02660    return 0;
02661 }

static struct ast_manager_user* ast_get_manager_by_name_locked ( const char *  name  )  [static, read]

Definition at line 532 of file manager.c.

References AST_LIST_TRAVERSE, mansession_session::list, and ast_manager_user::username.

Referenced by handle_showmanager(), and init_manager().

00533 {
00534    struct ast_manager_user *user = NULL;
00535 
00536    AST_LIST_TRAVERSE(&users, user, list)
00537       if (!strcasecmp(user->username, name))
00538          break;
00539    return user;
00540 }

static int ast_instring ( const char *  bigstr,
const 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 920 of file manager.c.

References mansession_session::next.

Referenced by get_perm(), and strings_to_mask().

00921 {
00922    const char *val = bigstr, *next;
00923 
00924    do {
00925       if ((next = strchr(val, delim))) {
00926          if (!strncmp(val, smallstr, (next - val)))
00927             return 1;
00928          else
00929             continue;
00930       } else
00931          return !strcmp(smallstr, val);
00932 
00933    } while (*(val = (next + 1)));
00934 
00935    return 0;
00936 }

static int ast_is_number ( const char *  string  )  [static]

Definition at line 953 of file manager.c.

Referenced by strings_to_mask().

00954 {
00955    int ret = 1, x = 0;
00956 
00957    if (!string)
00958       return 0;
00959 
00960    for (x = 0; x < strlen(string); x++) {
00961       if (!(string[x] >= 48 && string[x] <= 57)) {
00962          ret = 0;
00963          break;
00964       }
00965    }
00966    
00967    return ret ? atoi(string) : 0;
00968 }

int ast_manager_register2 ( const char *  action,
int  authority,
int(*)(struct mansession *s, const 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

Register a manager command with the manager interface

Parameters:
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 2798 of file manager.c.

References manager_action::action, ast_free, ast_malloc, ast_manager_register_struct(), manager_action::authority, manager_action::description, manager_action::func, manager_action::next, and manager_action::synopsis.

Referenced by init_manager(), and load_module().

02799 {
02800    struct manager_action *cur;
02801 
02802    cur = ast_malloc(sizeof(*cur));
02803    if (!cur)
02804       return -1;
02805    
02806    cur->action = action;
02807    cur->authority = auth;
02808    cur->func = func;
02809    cur->synopsis = synopsis;
02810    cur->description = description;
02811    cur->next = NULL;
02812 
02813    if (ast_manager_register_struct(cur)) {
02814       ast_free(cur);
02815       return -1;
02816    }
02817 
02818    return 0;
02819 }

static int ast_manager_register_struct ( struct manager_action act  )  [static]

Definition at line 2750 of file manager.c.

References manager_action::action, actionlock, ast_log(), ast_rwlock_timedwrlock(), ast_rwlock_unlock(), ast_verbose(), first_action, LOG_ERROR, LOG_WARNING, manager_action::next, option_verbose, tv, and VERBOSE_PREFIX_2.

Referenced by ast_manager_register2().

02751 {
02752    struct manager_action *cur, *prev = NULL;
02753    int ret;
02754    struct timespec tv = { 5, };
02755 
02756    if (ast_rwlock_timedwrlock(&actionlock, &tv)) {
02757       ast_log(LOG_ERROR, "Could not obtain lock on manager list\n");
02758       return -1;
02759    }
02760    cur = first_action;
02761    while (cur) { /* Walk the list of actions */
02762       ret = strcasecmp(cur->action, act->action);
02763       if (ret == 0) {
02764          ast_log(LOG_WARNING, "Manager: Action '%s' already registered\n", act->action);
02765          ast_rwlock_unlock(&actionlock);
02766          return -1;
02767       } else if (ret > 0) {
02768          /* Insert these alphabetically */
02769          if (prev) {
02770             act->next = prev->next;
02771             prev->next = act;
02772          } else {
02773             act->next = first_action;
02774             first_action = act;
02775          }
02776          break;
02777       }
02778       prev = cur; 
02779       cur = cur->next;
02780    }
02781    
02782    if (!cur) {
02783       if (prev)
02784          prev->next = act;
02785       else
02786          first_action = act;
02787       act->next = NULL;
02788    }
02789 
02790    if (option_verbose > 1) 
02791       ast_verbose(VERBOSE_PREFIX_2 "Manager registered action %s\n", act->action);
02792    ast_rwlock_unlock(&actionlock);
02793    return 0;
02794 }

int ast_manager_unregister ( char *  action  ) 

Unregister a registered manager command

Parameters:
action Name of registered Action:

Definition at line 2717 of file manager.c.

References manager_action::action, actionlock, ast_log(), ast_rwlock_timedwrlock(), ast_rwlock_unlock(), ast_verbose(), first_action, free, LOG_ERROR, manager_action::next, option_verbose, tv, and VERBOSE_PREFIX_2.

Referenced by __unload_module(), and unload_module().

02718 {
02719    struct manager_action *cur, *prev;
02720    struct timespec tv = { 5, };
02721 
02722    if (ast_rwlock_timedwrlock(&actionlock, &tv)) {
02723       ast_log(LOG_ERROR, "Could not obtain lock on manager list\n");
02724       return -1;
02725    }
02726    cur = prev = first_action;
02727    while (cur) {
02728       if (!strcasecmp(action, cur->action)) {
02729          prev->next = cur->next;
02730          free(cur);
02731          if (option_verbose > 1) 
02732             ast_verbose(VERBOSE_PREFIX_2 "Manager unregistered action %s\n", action);
02733          ast_rwlock_unlock(&actionlock);
02734          return 0;
02735       }
02736       prev = cur;
02737       cur = cur->next;
02738    }
02739    ast_rwlock_unlock(&actionlock);
02740    return 0;
02741 }

void astman_append ( struct mansession s,
const char *  fmt,
  ... 
)

Definition at line 542 of file manager.c.

References mansession_session::__lock, ast_calloc, ast_carefulwrite(), ast_dynamic_str_append(), ast_dynamic_str_thread_get(), ast_dynamic_str_thread_set_va, ast_mutex_lock(), ast_mutex_unlock(), astman_append_buf, ASTMAN_APPEND_BUF_INITSIZE, mansession::fd, mansession_session::outputstr, mansession::session, ast_dynamic_str::str, and mansession_session::writetimeout.

Referenced by __action_showchannels(), __iax2_show_peers(), __queues_show(), _sip_show_peer(), _sip_show_peers(), action_agents(), action_command(), action_extensionstate(), action_getconfig(), action_getvar(), action_listcommands(), action_mailboxcount(), action_mailboxstatus(), action_status(), action_updateconfig(), action_waitevent(), ast_cli_netstats(), astman_send_error(), astman_send_response(), manager_dbget(), manager_iax2_show_netstats(), manager_iax2_show_peers(), manager_jabber_send(), manager_parking_status(), manager_queues_show(), manager_queues_status(), manager_sip_show_peer(), manager_sip_show_peers(), process_message(), and session_do().

00543 {
00544    va_list ap;
00545    struct ast_dynamic_str *buf;
00546 
00547    ast_mutex_lock(&s->session->__lock);
00548 
00549    if (!(buf = ast_dynamic_str_thread_get(&astman_append_buf, ASTMAN_APPEND_BUF_INITSIZE))) {
00550       ast_mutex_unlock(&s->session->__lock);
00551       return;
00552    }
00553 
00554    va_start(ap, fmt);
00555    ast_dynamic_str_thread_set_va(&buf, 0, &astman_append_buf, fmt, ap);
00556    va_end(ap);
00557    
00558    if (s->fd > -1)
00559       ast_carefulwrite(s->fd, buf->str, strlen(buf->str), s->session->writetimeout);
00560    else {
00561       if (!s->session->outputstr && !(s->session->outputstr = ast_calloc(1, sizeof(*s->session->outputstr)))) {
00562          ast_mutex_unlock(&s->session->__lock);
00563          return;
00564       }
00565 
00566       ast_dynamic_str_append(&s->session->outputstr, 0, "%s", buf->str);   
00567    }
00568 
00569    ast_mutex_unlock(&s->session->__lock);
00570 }

static void astman_append_buf_init ( void   )  [static]

Definition at line 132 of file manager.c.

00135 {

const char* astman_get_header ( const struct message m,
char *  var 
)

struct ast_variable* astman_get_variables ( const struct message m  )  [read]

Get a linked list of the Variable: headers

Definition at line 838 of file manager.c.

References AST_APP_ARG, AST_DECLARE_APP_ARGS, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_variable_new(), message::hdrcount, message::headers, parse(), and var.

Referenced by action_originate().

00839 {
00840    int varlen, x, y;
00841    struct ast_variable *head = NULL, *cur;
00842    char *var, *val;
00843 
00844    char *parse;    
00845    AST_DECLARE_APP_ARGS(args,
00846       AST_APP_ARG(vars)[32];
00847    );
00848 
00849    varlen = strlen("Variable: ");   
00850 
00851    for (x = 0; x < m->hdrcount; x++) {
00852       if (strncasecmp("Variable: ", m->headers[x], varlen))
00853          continue;
00854 
00855       parse = ast_strdupa(m->headers[x] + varlen);
00856 
00857       AST_STANDARD_APP_ARGS(args, parse);
00858       if (args.argc) {
00859          for (y = 0; y < args.argc; y++) {
00860             if (!args.vars[y])
00861                continue;
00862             var = val = ast_strdupa(args.vars[y]);
00863             strsep(&val, "=");
00864             if (!val || ast_strlen_zero(var))
00865                continue;
00866             cur = ast_variable_new(var, val);
00867             if (head) {
00868                cur->next = head;
00869                head = cur;
00870             } else
00871                head = cur;
00872          }
00873       }
00874    }
00875 
00876    return head;
00877 }

void astman_send_ack ( struct mansession s,
const struct message m,
char *  msg 
)

void astman_send_error ( struct mansession s,
const struct message m,
char *  error 
)

Note:
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 887 of file manager.c.

References ast_strlen_zero(), astman_append(), and astman_get_header().

Referenced by __action_dialoffhook(), __action_dnd(), __action_restart(), __action_transfer(), __action_transferhangup(), _sip_show_peer(), action_agent_callback_login(), action_agent_logoff(), action_command(), action_events(), action_extensionstate(), action_getconfig(), action_getvar(), action_hangup(), action_mailboxcount(), action_mailboxstatus(), action_originate(), action_redirect(), action_setcdruserfield(), action_setvar(), action_status(), action_timeout(), action_updateconfig(), change_monitor_action(), do_pause_or_unpause(), manager_add_queue_member(), manager_dbget(), manager_dbput(), manager_jabber_send(), manager_park(), manager_pause_queue_member(), manager_play_dtmf(), manager_remove_queue_member(), manager_sip_show_peer(), meetmemute(), process_message(), start_monitor_action(), and stop_monitor_action().

00888 {
00889    const char *id = astman_get_header(m,"ActionID");
00890 
00891    astman_append(s, "Response: Error\r\n");
00892    if (!ast_strlen_zero(id))
00893       astman_append(s, "ActionID: %s\r\n", id);
00894    astman_append(s, "Message: %s\r\n\r\n", error);
00895 }

void astman_send_response ( struct mansession s,
const struct message m,
char *  resp,
char *  msg 
)

Definition at line 897 of file manager.c.

References ast_strlen_zero(), astman_append(), and astman_get_header().

Referenced by action_events(), action_logoff(), action_ping(), action_waitevent(), and astman_send_ack().

00898 {
00899    const char *id = astman_get_header(m,"ActionID");
00900 
00901    astman_append(s, "Response: %s\r\n", resp);
00902    if (!ast_strlen_zero(id))
00903       astman_append(s, "ActionID: %s\r\n", id);
00904    if (msg)
00905       astman_append(s, "Message: %s\r\n\r\n", msg);
00906    else
00907       astman_append(s, "\r\n");
00908 }

static int authenticate ( struct mansession s,
const struct message m 
) [static]

Definition at line 1013 of file manager.c.

References ast_append_ha(), ast_apply_ha(), ast_category_browse(), ast_config_AST_SYSTEM_NAME, ast_config_destroy(), ast_config_load(), ast_copy_string(), ast_free_ha(), ast_inet_ntoa(), ast_log(), ast_strlen_zero(), ast_true(), ast_variable_browse(), ast_variable_retrieve(), astman_get_header(), mansession_session::challenge, mansession_session::displaysystemname, events, get_perm(), len(), ast_variable::lineno, LOG_DEBUG, LOG_ERROR, LOG_NOTICE, LOG_WARNING, MD5Final(), MD5Init(), MD5Update(), ast_variable::name, ast_variable::next, password, mansession_session::readperm, S_OR, mansession::session, set_eventmask(), mansession_session::sin, mansession_session::username, ast_variable::value, mansession_session::writeperm, and mansession_session::writetimeout.

Referenced by authenticate_reply(), handle_response_invite(), process_message(), and registry_rerequest().

01014 {
01015    struct ast_config *cfg;
01016    char *cat;
01017    const char *user = astman_get_header(m, "Username");
01018    const char *pass = astman_get_header(m, "Secret");
01019    const char *authtype = astman_get_header(m, "AuthType");
01020    const char *key = astman_get_header(m, "Key");
01021    const char *events = astman_get_header(m, "Events");
01022    
01023    cfg = ast_config_load("manager.conf");
01024    if (!cfg)
01025       return -1;
01026    cat = ast_category_browse(cfg, NULL);
01027    while (cat) {
01028       if (strcasecmp(cat, "general")) {
01029          /* This is a user */
01030          if (!strcasecmp(cat, user)) {
01031             struct ast_variable *v;
01032             struct ast_ha *ha = NULL;
01033             char *password = NULL;
01034 
01035             for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
01036                if (!strcasecmp(v->name, "secret")) {
01037                   password = v->value;
01038                } else if (!strcasecmp(v->name, "displaysystemname")) {
01039                   if (ast_true(v->value)) {
01040                      if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)) {
01041                         s->session->displaysystemname = 1;
01042                      } else {
01043                         ast_log(LOG_ERROR, "Can't enable displaysystemname in manager.conf - no system name configured in asterisk.conf\n");
01044                      }
01045                   }
01046                } else if (!strcasecmp(v->name, "permit") ||
01047                      !strcasecmp(v->name, "deny")) {
01048                   ha = ast_append_ha(v->name, v->value, ha);
01049                } else if (!strcasecmp(v->name, "writetimeout")) {
01050                   int val = atoi(v->value);
01051 
01052                   if (val < 100)
01053                      ast_log(LOG_WARNING, "Invalid writetimeout value '%s' at line %d\n", v->value, v->lineno);
01054                   else
01055                      s->session->writetimeout = val;
01056                }
01057                      
01058             }
01059             if (ha && !ast_apply_ha(ha, &(s->session->sin))) {
01060                ast_log(LOG_NOTICE, "%s failed to pass IP ACL as '%s'\n", ast_inet_ntoa(s->session->sin.sin_addr), user);
01061                ast_free_ha(ha);
01062                ast_config_destroy(cfg);
01063                return -1;
01064             } else if (ha)
01065                ast_free_ha(ha);
01066             if (!strcasecmp(authtype, "MD5")) {
01067                if (!ast_strlen_zero(key) && 
01068                    !ast_strlen_zero(s->session->challenge) && !ast_strlen_zero(password)) {
01069                   int x;
01070                   int len = 0;
01071                   char md5key[256] = "";
01072                   struct MD5Context md5;
01073                   unsigned char digest[16];
01074                   MD5Init(&md5);
01075                   MD5Update(&md5, (unsigned char *) s->session->challenge, strlen(s->session->challenge));
01076                   MD5Update(&md5, (unsigned char *) password, strlen(password));
01077                   MD5Final(digest, &md5);
01078                   for (x=0; x<16; x++)
01079                      len += sprintf(md5key + len, "%2.2x", digest[x]);
01080                   if (!strcmp(md5key, key))
01081                      break;
01082                   else {
01083                      ast_config_destroy(cfg);
01084                      return -1;
01085                   }
01086                } else {
01087                   ast_log(LOG_DEBUG, "MD5 authentication is not possible.  challenge: '%s'\n", 
01088                      S_OR(s->session->challenge, ""));
01089                   ast_config_destroy(cfg);
01090                   return -1;
01091                }
01092             } else if (password && !strcmp(password, pass)) {
01093                break;
01094             } else {
01095                ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", ast_inet_ntoa(s->session->sin.sin_addr), user);
01096                ast_config_destroy(cfg);
01097                return -1;
01098             }  
01099          }
01100       }
01101       cat = ast_category_browse(cfg, cat);
01102    }
01103    if (cat) {
01104       ast_copy_string(s->session->username, cat, sizeof(s->session->username));
01105       s->session->readperm = get_perm(ast_variable_retrieve(cfg, cat, "read"));
01106       s->session->writeperm = get_perm(ast_variable_retrieve(cfg, cat, "write"));
01107       ast_config_destroy(cfg);
01108       if (events)
01109          set_eventmask(s->session, events);
01110       return 0;
01111    }
01112    ast_config_destroy(cfg);
01113    cfg = ast_config_load("users.conf");
01114    if (!cfg)
01115       return -1;
01116    cat = ast_category_browse(cfg, NULL);
01117    while (cat) {
01118       struct ast_variable *v;
01119       const char *password = NULL;
01120       int hasmanager = 0;
01121       const char *readperms = NULL;
01122       const char *writeperms = NULL;
01123 
01124       if (strcasecmp(cat, user) || !strcasecmp(cat, "general")) {
01125          cat = ast_category_browse(cfg, cat);
01126          continue;
01127       }
01128       for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
01129          if (!strcasecmp(v->name, "secret"))
01130             password = v->value;
01131          else if (!strcasecmp(v->name, "hasmanager"))
01132             hasmanager = ast_true(v->value);
01133          else if (!strcasecmp(v->name, "managerread"))
01134             readperms = v->value;
01135          else if (!strcasecmp(v->name, "managerwrite"))
01136             writeperms = v->value;
01137       }
01138       if (!hasmanager)
01139          break;
01140       if (!password || strcmp(password, pass)) {
01141          ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", ast_inet_ntoa(s->session->sin.sin_addr), user);
01142          ast_config_destroy(cfg);
01143          return -1;
01144       }
01145       ast_copy_string(s->session->username, cat, sizeof(s->session->username));
01146       s->session->readperm = readperms ? get_perm(readperms) : -1;
01147       s->session->writeperm = writeperms ? get_perm(writeperms) : -1;
01148       ast_config_destroy(cfg);
01149       if (events)
01150          set_eventmask(s->session, events);
01151       return 0;
01152    }
01153    ast_log(LOG_NOTICE, "%s tried to authenticate with nonexistent user '%s'\n", ast_inet_ntoa(s->session->sin.sin_addr), user);
01154    ast_config_destroy(cfg);
01155    return -1;
01156 }

static char* authority_to_str ( int  authority,
char *  res,
int  reslen 
) [static]

Convert authority code to string with serveral options.

Definition at line 266 of file manager.c.

References ast_copy_string(), ast_strlen_zero(), and perms.

Referenced by action_listcommands(), handle_showmancmd(), handle_showmancmds(), manager_event(), and process_message().

00267 {
00268    int running_total = 0, i;
00269 
00270    memset(res, 0, reslen);
00271    for (i = 0; i < (sizeof(perms) / sizeof(perms[0])) - 1; i++) {
00272       if (authority & perms[i].num) {
00273          if (*res) {
00274             strncat(res, ",", (reslen > running_total) ? reslen - running_total - 1 : 0);
00275             running_total++;
00276          }
00277          strncat(res, perms[i].label, (reslen > running_total) ? reslen - running_total - 1 : 0);
00278          running_total += strlen(perms[i].label);
00279       }
00280    }
00281 
00282    if (ast_strlen_zero(res))
00283       ast_copy_string(res, "<none>", reslen);
00284    
00285    return res;
00286 }

static int check_blacklist ( const char *  cmd  )  [static]

Definition at line 1796 of file manager.c.

References ARRAY_LEN, ast_strdupa, ast_strip(), ast_strlen_zero(), command_blacklist, match(), MAX_BLACKLIST_CMD_LEN, and words.

Referenced by action_command().

01797 {
01798    char *cmd_copy, *cur_cmd;
01799    char *cmd_words[MAX_BLACKLIST_CMD_LEN] = { NULL, };
01800    int i;
01801 
01802    cmd_copy = ast_strdupa(cmd);
01803    for (i = 0; i < MAX_BLACKLIST_CMD_LEN && (cur_cmd = strsep(&cmd_copy, " ")); i++) {
01804       cur_cmd = ast_strip(cur_cmd);
01805       if (ast_strlen_zero(cur_cmd)) {
01806          i--;
01807          continue;
01808       }
01809 
01810       cmd_words[i] = cur_cmd;
01811    }
01812 
01813    for (i = 0; i < ARRAY_LEN(command_blacklist); i++) {
01814       int j, match = 1;
01815 
01816       for (j = 0; command_blacklist[i].words[j]; j++) {
01817          if (ast_strlen_zero(cmd_words[j]) || strcasecmp(cmd_words[j], command_blacklist[i].words[j])) {
01818             match = 0;
01819             break;
01820          }
01821       }
01822 
01823       if (match) {
01824          return 1;
01825       }
01826    }
01827 
01828    return 0;
01829 }

static char* complete_show_mancmd ( const char *  line,
const char *  word,
int  pos,
int  state 
) [static]

Definition at line 288 of file manager.c.

References manager_action::action, actionlock, ast_rwlock_rdlock(), ast_rwlock_unlock(), ast_strdup, first_action, and manager_action::next.

00289 {
00290    struct manager_action *cur;
00291    int which = 0;
00292    char *ret = NULL;
00293 
00294    ast_rwlock_rdlock(&actionlock);
00295    for (cur = first_action; cur; cur = cur->next) { /* Walk the list of actions */
00296       if (!strncasecmp(word, cur->action, strlen(word)) && ++which > state) {
00297          ret = ast_strdup(cur->action);
00298          break;   /* make sure we exit even if ast_strdup() returns NULL */
00299       }
00300    }
00301    ast_rwlock_unlock(&actionlock);
00302 
00303    return ret;
00304 }

static int compress_char ( char  c  )  [static]

Definition at line 348 of file manager.c.

Referenced by member_hash_fn(), and variable_count_hash_fn().

00349 {
00350    c &= 0x7f;
00351    if (c < 32)
00352       return 0;
00353    else if (c >= 'a' && c <= 'z')
00354       return c - 64;
00355    else if (c > 'z')
00356       return '_';
00357    else
00358       return c - 32;
00359 }

static void destroy_session ( struct mansession_session s  )  [static]

static int do_message ( struct mansession s  )  [static]

Definition at line 2443 of file manager.c.

References ast_inet_ntoa(), ast_log(), AST_MAX_MANHEADERS, ast_strdupa, ast_strlen_zero(), mansession_session::authenticated, mansession_session::authstart, errno, mansession_session::eventq, get_input(), message::hdrcount, message::headers, mansession_session::inbuf, LOG_ERROR, LOG_EVENT, eventqent::next, process_events(), process_message(), mansession::session, and mansession_session::sin.

Referenced by session_do().

02444 {
02445    struct message m = { 0 };
02446    char header_buf[sizeof(s->session->inbuf)] = { '\0' };
02447    int res;
02448    time_t now;
02449 
02450    for (;;) {
02451       /* Check if any events are pending and do them if needed */
02452       if (s->session->eventq->next) {
02453          if (process_events(s))
02454             return -1;
02455       }
02456       res = get_input(s->session, header_buf);
02457       if (res == 0) {
02458          if (!s->session->authenticated) {
02459             if(time(&now) == -1) {
02460                ast_log(LOG_ERROR, "error executing time(): %s\n", strerror(errno));
02461                return -1;
02462             }
02463 
02464             if (now - s->session->authstart > authtimeout) {
02465                ast_log(LOG_EVENT, "Client from %s, failed to authenticate in %d seconds\n", ast_inet_ntoa(s->session->sin.sin_addr), authtimeout);
02466                return -1;
02467             }
02468          }
02469          continue;
02470       } else if (res > 0) {
02471          /* Strip trailing \r\n */
02472          if (strlen(header_buf) < 2)
02473             continue;
02474          header_buf[strlen(header_buf) - 2] = '\0';
02475          if (ast_strlen_zero(header_buf))
02476             return process_message(s, &m) ? -1 : 0;
02477          else if (m.hdrcount < (AST_MAX_MANHEADERS - 1))
02478             m.headers[m.hdrcount++] = ast_strdupa(header_buf);
02479       } else {
02480          return res;
02481       }
02482    }
02483 }

static void* fast_originate ( void *  data  )  [static]

Definition at line 1890 of file manager.c.

References fast_originate_helper::account, fast_originate_helper::app, fast_originate_helper::appdata, AST_CHANNEL_NAME, ast_channel_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, fast_originate_helper::format, free, fast_originate_helper::idtext, manager_event(), ast_channel::name, fast_originate_helper::priority, S_OR, fast_originate_helper::tech, fast_originate_helper::timeout, ast_channel::uniqueid, and fast_originate_helper::vars.

Referenced by action_originate().

01891 {
01892    struct fast_originate_helper *in = data;
01893    int res;
01894    int reason = 0;
01895    struct ast_channel *chan = NULL;
01896    char requested_channel[AST_CHANNEL_NAME];
01897 
01898    if (!ast_strlen_zero(in->app)) {
01899       res = ast_pbx_outgoing_app(in->tech, in->format, in->data, in->timeout, in->app, in->appdata, &reason, 1, 
01900          S_OR(in->cid_num, NULL), 
01901          S_OR(in->cid_name, NULL),
01902          in->vars, in->account, &chan);
01903    } else {
01904       res = ast_pbx_outgoing_exten(in->tech, in->format, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1, 
01905          S_OR(in->cid_num, NULL), 
01906          S_OR(in->cid_name, NULL),
01907          in->vars, in->account, &chan);
01908    }
01909 
01910    if (!chan)
01911       snprintf(requested_channel, AST_CHANNEL_NAME, "%s/%s", in->tech, in->data);   
01912    /* Tell the manager what happened with the channel */
01913    manager_event(EVENT_FLAG_CALL, "OriginateResponse",
01914       "%s%s"
01915       "Response: %s\r\n"
01916       "Channel: %s\r\n"
01917       "Context: %s\r\n"
01918       "Exten: %s\r\n"
01919       "Reason: %d\r\n"
01920       "Uniqueid: %s\r\n"
01921       "CallerID: %s\r\n"      /* This parameter is deprecated and will be removed post-1.4 */
01922       "CallerIDNum: %s\r\n"
01923       "CallerIDName: %s\r\n",
01924       in->idtext, ast_strlen_zero(in->idtext) ? "" : "\r\n", res ? "Failure" : "Success", 
01925       chan ? chan->name : requested_channel, in->context, in->exten, reason, 
01926       chan ? chan->uniqueid : "<null>",
01927       S_OR(in->cid_num, "<unknown>"),
01928       S_OR(in->cid_num, "<unknown>"),
01929       S_OR(in->cid_name, "<unknown>")
01930       );
01931 
01932    /* Locked by ast_pbx_outgoing_exten or ast_pbx_outgoing_app */
01933    if (chan)
01934       ast_channel_unlock(chan);
01935    free(in);
01936    return NULL;
01937 }

static void free_session ( struct mansession_session s  )  [static]

Definition at line 798 of file manager.c.

References mansession_session::__lock, ast_mutex_destroy(), mansession_session::eventq, mansession_session::fd, free, eventqent::next, mansession_session::outputstr, and unuse_eventqent().

Referenced by accept_thread(), and destroy_session().

00799 {
00800    struct eventqent *eqe;
00801    if (s->fd > -1)
00802       close(s->fd);
00803    if (s->outputstr)
00804       free(s->outputstr);
00805    ast_mutex_destroy(&s->__lock);
00806    while (s->eventq) {
00807       eqe = s->eventq;
00808       s->eventq = s->eventq->next;
00809       unuse_eventqent(eqe);
00810    }
00811    free(s);
00812 }

static int get_input ( struct mansession_session s,
char *  output 
) [static]

Definition at line 2364 of file manager.c.

References mansession_session::__lock, ast_inet_ntoa(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_poll, AST_PTHREADT_NULL, mansession_session::authenticated, mansession_session::authstart, errno, mansession_session::fd, ast_channel::fds, mansession_session::inbuf, mansession_session::inlen, LOG_ERROR, LOG_WARNING, mansession_session::pending_event, mansession_session::sin, and mansession_session::waiting_thread.

Referenced by do_message(), and skinny_session().

02365 {
02366    /* output must have at least sizeof(s->inbuf) space */
02367    int res;
02368    int x;
02369    struct pollfd fds[1];
02370    int timeout = -1;
02371    time_t now;
02372    for (x = 1; x < s->inlen; x++) {
02373       if ((s->inbuf[x] == '\n') && (s->inbuf[x-1] == '\r')) {
02374          /* Copy output data up to and including \r\n */
02375          memcpy(output, s->inbuf, x + 1);
02376          /* Add trailing \0 */
02377          output[x+1] = '\0';
02378          /* Move remaining data back to the front */
02379          memmove(s->inbuf, s->inbuf + x + 1, s->inlen - x);
02380          s->inlen -= (x + 1);
02381          return 1;
02382       }
02383    } 
02384    if (s->inlen >= sizeof(s->inbuf) - 1) {
02385       ast_log(LOG_WARNING, "Dumping long line with no return from %s: %s\n", ast_inet_ntoa(s->sin.sin_addr), s->inbuf);
02386       s->inlen = 0;
02387    }
02388    fds[0].fd = s->fd;
02389    fds[0].events = POLLIN;
02390 
02391    do {
02392       /* calculate a timeout if we are not authenticated */
02393       if (!s->authenticated) {
02394          if(time(&now) == -1) {
02395             ast_log(LOG_ERROR, "error executing time(): %s\n", strerror(errno));
02396             return -1;
02397          }
02398 
02399          timeout = (authtimeout - (now - s->authstart)) * 1000;
02400          if (timeout < 0) {
02401             /* we have timed out */
02402             return 0;
02403          }
02404       }
02405 
02406       ast_mutex_lock(&s->__lock);
02407       if (s->pending_event) {
02408          s->pending_event = 0;
02409          ast_mutex_unlock(&s->__lock);
02410          return 0;
02411       }
02412       s->waiting_thread = pthread_self();
02413       ast_mutex_unlock(&s->__lock);
02414 
02415       res = ast_poll(fds, 1, timeout);
02416 
02417       ast_mutex_lock(&s->__lock);
02418       s->waiting_thread = AST_PTHREADT_NULL;
02419       ast_mutex_unlock(&s->__lock);
02420       if (res < 0) {
02421          if (errno == EINTR || errno == EAGAIN) {
02422             return 0;
02423          }
02424          ast_log(LOG_WARNING, "Select returned error: %s\n", strerror(errno));
02425          return -1;
02426       } else if (res > 0) {
02427          ast_mutex_lock(&s->__lock);
02428          res = read(s->fd, s->inbuf + s->inlen, sizeof(s->inbuf) - 1 - s->inlen);
02429          ast_mutex_unlock(&s->__lock);
02430          if (res < 1)
02431             return -1;
02432          break;
02433       } else {
02434          /* timeout */
02435          return 0;
02436       }
02437    } while(1);
02438    s->inlen += res;
02439    s->inbuf[s->inlen] = '\0';
02440    return 0;
02441 }

static int get_perm ( const char *  instr  )  [static]

Definition at line 938 of file manager.c.

References ast_instring(), and perms.

Referenced by authenticate().

00939 {
00940    int x = 0, ret = 0;
00941 
00942    if (!instr)
00943       return 0;
00944 
00945    for (x = 0; x < (sizeof(perms) / sizeof(perms[0])); x++) {
00946       if (ast_instring(instr, perms[x].label, ','))
00947          ret |= perms[x].num;
00948    }
00949    
00950    return ret;
00951 }

static int handle_showmanager ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 594 of file manager.c.

References ast_cli(), ast_get_manager_by_name_locked(), AST_LIST_LOCK, AST_LIST_UNLOCK, ast_manager_user::deny, ast_manager_user::displayconnects, ast_manager_user::permit, ast_manager_user::read, RESULT_SHOWUSAGE, RESULT_SUCCESS, ast_manager_user::secret, ast_manager_user::username, and ast_manager_user::write.

00595 {
00596    struct ast_manager_user *user = NULL;
00597 
00598    if (argc != 4)
00599       return RESULT_SHOWUSAGE;
00600 
00601    AST_LIST_LOCK(&users);
00602 
00603    if (!(user = ast_get_manager_by_name_locked(argv[3]))) {
00604       ast_cli(fd, "There is no manager called %s\n", argv[3]);
00605       AST_LIST_UNLOCK(&users);
00606       return -1;
00607    }
00608 
00609    ast_cli(fd,"\n");
00610    ast_cli(fd,
00611       "       username: %s\n"
00612       "         secret: %s\n"
00613       "           deny: %s\n"
00614       "         permit: %s\n"
00615       "           read: %s\n"
00616       "          write: %s\n"
00617       "displayconnects: %s\n",
00618       (user->username ? user->username : "(N/A)"),
00619       (user->secret ? "<Set>" : "(N/A)"),
00620       (user->deny ? user->deny : "(N/A)"),
00621       (user->permit ? user->permit : "(N/A)"),
00622       (user->read ? user->read : "(N/A)"),
00623       (user->write ? user->write : "(N/A)"),
00624       (user->displayconnects ? "yes" : "no"));
00625 
00626    AST_LIST_UNLOCK(&users);
00627 
00628    return RESULT_SUCCESS;
00629 }

static int handle_showmanagers ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 632 of file manager.c.

References ast_cli(), AST_LIST_EMPTY, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, mansession_session::list, RESULT_SHOWUSAGE, RESULT_SUCCESS, and ast_manager_user::username.

00633 {
00634    struct ast_manager_user *user = NULL;
00635    int count_amu = 0;
00636 
00637    if (argc != 3)
00638       return RESULT_SHOWUSAGE;
00639 
00640    AST_LIST_LOCK(&users);
00641 
00642    /* If there are no users, print out something along those lines */
00643    if (AST_LIST_EMPTY(&users)) {
00644       ast_cli(fd, "There are no manager users.\n");
00645       AST_LIST_UNLOCK(&users);
00646       return RESULT_SUCCESS;
00647    }
00648 
00649    ast_cli(fd, "\nusername\n--------\n");
00650 
00651    AST_LIST_TRAVERSE(&users, user, list) {
00652       ast_cli(fd, "%s\n", user->username);
00653       count_amu++;
00654    }
00655 
00656    AST_LIST_UNLOCK(&users);
00657 
00658    ast_cli(fd,"-------------------\n");
00659    ast_cli(fd,"%d manager users configured.\n", count_amu);
00660 
00661    return RESULT_SUCCESS;
00662 }

static int handle_showmancmd ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 572 of file manager.c.

References manager_action::action, actionlock, ast_cli(), ast_rwlock_rdlock(), ast_rwlock_unlock(), manager_action::authority, authority_to_str(), manager_action::description, first_action, manager_action::next, RESULT_SHOWUSAGE, RESULT_SUCCESS, and manager_action::synopsis.

00573 {
00574    struct manager_action *cur;
00575    char authority[80];
00576    int num;
00577 
00578    if (argc != 4)
00579       return RESULT_SHOWUSAGE;
00580 
00581    ast_rwlock_rdlock(&actionlock);
00582    for (cur = first_action; cur; cur = cur->next) { /* Walk the list of actions */
00583       for (num = 3; num < argc; num++) {
00584          if (!strcasecmp(cur->action, argv[num])) {
00585             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 : "");
00586          }
00587       }
00588    }
00589    ast_rwlock_unlock(&actionlock);
00590 
00591    return RESULT_SUCCESS;
00592 }

static int handle_showmancmds ( int  fd,
int  argc,
char *  argv[] 
) [static]

CLI command Should change to "manager show commands".

Definition at line 667 of file manager.c.

References manager_action::action, actionlock, ast_cli(), ast_rwlock_rdlock(), ast_rwlock_unlock(), manager_action::authority, authority_to_str(), first_action, format, manager_action::next, RESULT_SUCCESS, and manager_action::synopsis.

00668 {
00669    struct manager_action *cur;
00670    char authority[80];
00671    char *format = "  %-15.15s  %-15.15s  %-55.55s\n";
00672 
00673    ast_cli(fd, format, "Action", "Privilege", "Synopsis");
00674    ast_cli(fd, format, "------", "---------", "--------");
00675    
00676    ast_rwlock_rdlock(&actionlock);
00677    for (cur = first_action; cur; cur = cur->next) /* Walk the list of actions */
00678       ast_cli(fd, format, cur->action, authority_to_str(cur->authority, authority, sizeof(authority) -1), cur->synopsis);
00679    ast_rwlock_unlock(&actionlock);
00680    
00681    return RESULT_SUCCESS;
00682 }

static int handle_showmanconn ( int  fd,
int  argc,
char *  argv[] 
) [static]

CLI command show manager connected.

Definition at line 686 of file manager.c.

References ast_cli(), ast_inet_ntoa(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, format, mansession_session::list, RESULT_SUCCESS, s, mansession_session::sin, and mansession_session::username.

00687 {
00688    struct mansession_session *s;
00689    char *format = "  %-15.15s  %-15.15s\n";
00690 
00691    ast_cli(fd, format, "Username", "IP Address");
00692    
00693    AST_LIST_LOCK(&sessions);
00694    AST_LIST_TRAVERSE(&sessions, s, list)
00695       ast_cli(fd, format,s->username, ast_inet_ntoa(s->sin.sin_addr));
00696    AST_LIST_UNLOCK(&sessions);
00697 
00698    return RESULT_SUCCESS;
00699 }

static int handle_showmaneventq ( int  fd,
int  argc,
char *  argv[] 
) [static]

CLI command show manager connected.

Definition at line 703 of file manager.c.

References ast_cli(), AST_LIST_LOCK, AST_LIST_UNLOCK, eventqent::category, eventqent::eventdata, eventqent::next, RESULT_SUCCESS, s, and eventqent::usecount.

00704 {
00705    struct eventqent *s;
00706 
00707    AST_LIST_LOCK(&sessions);
00708    for (s = master_eventq; s; s = s->next) {
00709       ast_cli(fd, "Usecount: %d\n",s->usecount);
00710       ast_cli(fd, "Category: %d\n", s->category);
00711       ast_cli(fd, "Event:\n%s", s->eventdata);
00712    }
00713    AST_LIST_UNLOCK(&sessions);
00714 
00715    return RESULT_SUCCESS;
00716 }

static void handle_updates ( struct mansession s,
const struct message m,
struct ast_config cfg 
) [static]

Definition at line 1213 of file manager.c.

References ast_category_append(), ast_category_delete(), ast_category_get(), ast_category_new(), ast_category_rename(), ast_strlen_zero(), ast_variable_append(), ast_variable_delete(), ast_variable_new(), ast_variable_update(), astman_get_header(), match(), ast_variable::object, ast_variable::value, and var.

Referenced by action_updateconfig().

01214 {
01215    int x;
01216    char hdr[40];
01217    const char *action, *cat, *var, *value, *match;
01218    struct ast_category *category;
01219    struct ast_variable *v;
01220    
01221    for (x=0;x<100000;x++) {
01222       unsigned int object = 0;
01223 
01224       snprintf(hdr, sizeof(hdr), "Action-%06d", x);
01225       action = astman_get_header(m, hdr);
01226       if (ast_strlen_zero(action))
01227          break;
01228       snprintf(hdr, sizeof(hdr), "Cat-%06d", x);
01229       cat = astman_get_header(m, hdr);
01230       snprintf(hdr, sizeof(hdr), "Var-%06d", x);
01231       var = astman_get_header(m, hdr);
01232       snprintf(hdr, sizeof(hdr), "Value-%06d", x);
01233       value = astman_get_header(m, hdr);
01234       if (!ast_strlen_zero(value) && *value == '>') {
01235          object = 1;
01236          value++;
01237       }
01238       snprintf(hdr, sizeof(hdr), "Match-%06d", x);
01239       match = astman_get_header(m, hdr);
01240       if (!strcasecmp(action, "newcat")) {
01241          if (!ast_strlen_zero(cat)) {
01242             category = ast_category_new(cat);
01243             if (category) {
01244                ast_category_append(cfg, category);
01245             }
01246          }
01247       } else if (!strcasecmp(action, "renamecat")) {
01248          if (!ast_strlen_zero(cat) && !ast_strlen_zero(value)) {
01249             category = ast_category_get(cfg, cat);
01250             if (category) 
01251                ast_category_rename(category, value);
01252          }
01253       } else if (!strcasecmp(action, "delcat")) {
01254          if (!ast_strlen_zero(cat))
01255             ast_category_delete(cfg, (char *) cat);
01256       } else if (!strcasecmp(action, "update")) {
01257          if (!ast_strlen_zero(cat) && !ast_strlen_zero(var) && (category = ast_category_get(cfg, cat)))
01258             ast_variable_update(category, var, value, match, object);
01259       } else if (!strcasecmp(action, "delete")) {
01260          if (!ast_strlen_zero(cat) && !ast_strlen_zero(var) && (category = ast_category_get(cfg, cat)))
01261             ast_variable_delete(category, (char *) var, (char *) match);
01262       } else if (!strcasecmp(action, "append")) {
01263          if (!ast_strlen_zero(cat) && !ast_strlen_zero(var) && 
01264             (category = ast_category_get(cfg, cat)) && 
01265             (v = ast_variable_new(var, value))){
01266             if (object || (match && !strcasecmp(match, "object")))
01267                v->object = 1;
01268             ast_variable_append(category, v);
01269          }
01270       }
01271    }
01272 }

static char* html_translate ( char *  in  )  [static]

Definition at line 483 of file manager.c.

References ast_build_string(), ast_malloc, len(), and var.

Referenced by generic_http_callback().

00484 {
00485    int x;
00486    int colons = 0;
00487    int breaks = 0;
00488    size_t len;
00489    int count = 1;
00490    char *tmp, *var, *val, *out;
00491 
00492    for (x=0; in[x]; x++) {
00493       if (in[x] == ':')
00494          colons++;
00495       if (in[x] == '\n')
00496          breaks++;
00497    }
00498    len = strlen(in) + colons * 40 + breaks * 40; /* <tr><td></td><td></td></tr>, "<tr><td colspan=\"2\"><hr></td></tr> */
00499    out = ast_malloc(len);
00500    if (!out)
00501       return 0;
00502    tmp = out;
00503    while (*in) {
00504       var = in;
00505       while (*in && (*in >= 32))
00506          in++;
00507       if (*in) {
00508          if ((count % 4) == 0){
00509             ast_build_string(&tmp, &len, "<tr><td colspan=\"2\"><hr></td></tr>\r\n");
00510          }
00511          count = 0;
00512          while (*in && (*in < 32)) {
00513             *in = '\0';
00514             in++;
00515             count++;
00516          }
00517          val = strchr(var, ':');
00518          if (val) {
00519             *val = '\0';
00520             val++;
00521             if (*val == ' ')
00522                val++;
00523             ast_build_string(&tmp, &len, "<tr><td>%s</td><td>%s</td></tr>\r\n", var, val);
00524          }
00525       }
00526    }
00527    return out;
00528 }

int manager_event ( int  category,
const char *  event,
const char *  contents,
  ... 
)

manager_event: Send AMI event to client

External routines may send asterisk manager events this way

Parameters:
category Event category, matches manager authorization
event Event name
contents Contents of event

Definition at line 2664 of file manager.c.

References mansession_session::__lock, append_event(), ast_dynamic_str_thread_append(), ast_dynamic_str_thread_append_va, ast_dynamic_str_thread_get(), ast_dynamic_str_thread_set(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_mutex_lock(), ast_mutex_unlock(), AST_PTHREADT_NULL, ast_tvnow(), authority_to_str(), mansession_session::list, manager_event_buf, MANAGER_EVENT_BUF_INITSIZE, mansession_session::pending_event, s, ast_dynamic_str::str, and mansession_session::waiting_thread.

Referenced by __expire_registry(), __iax2_poke_noanswer(), __login_exec(), action_agent_callback_login(), action_userevent(), add_to_queue(), agent_logoff_maintenance(), aji_log_hook(), ast_change_name(), ast_channel_alloc(), ast_channel_bridge(), ast_do_masquerade(), ast_hangup(), ast_log(), ast_setstate(), change_hold_state(), conf_run(), dahdi_handle_event(), expire_register(), fast_originate(), handle_alarms(), handle_init_event(), handle_response_peerpoke(), handle_response_register(), iax2_ack_registry(), join_queue(), leave_queue(), main(), manager_log(), manager_state_cb(), notify_new_message(), park_call_full(), park_exec(), parse_register_contact(), pbx_extension_helper(), post_manager_event(), quit_handler(), realtime_exec(), record_abandoned(), register_verify(), reload_config(), reload_logger(), reload_manager(), remove_from_queue(), report_new_callerid(), ring_entry(), send_talking_event(), senddialevent(), set_member_paused(), sip_poke_noanswer(), sip_reg_timeout(), socket_process(), ss_thread(), try_calling(), update_registry(), update_status(), userevent_exec(), and vm_execmain().

02665 {
02666    struct mansession_session *s;
02667    char auth[80];
02668    va_list ap;
02669    struct timeval now;
02670    struct ast_dynamic_str *buf;
02671 
02672    /* Abort if there aren't any manager sessions */
02673    if (!num_sessions)
02674       return 0;
02675 
02676    if (!(buf = ast_dynamic_str_thread_get(&manager_event_buf, MANAGER_EVENT_BUF_INITSIZE)))
02677       return -1;
02678 
02679    ast_dynamic_str_thread_set(&buf, 0, &manager_event_buf,
02680          "Event: %s\r\nPrivilege: %s\r\n",
02681           event, authority_to_str(category, auth, sizeof(auth)));
02682 
02683    if (timestampevents) {
02684       now = ast_tvnow();
02685       ast_dynamic_str_thread_append(&buf, 0, &manager_event_buf,
02686             "Timestamp: %ld.%06lu\r\n",
02687              (long) now.tv_sec, (unsigned long) now.tv_usec);
02688    }
02689 
02690    va_start(ap, fmt);
02691    ast_dynamic_str_thread_append_va(&buf, 0, &manager_event_buf, fmt, ap);
02692    va_end(ap);
02693    
02694    ast_dynamic_str_thread_append(&buf, 0, &manager_event_buf, "\r\n");  
02695    
02696    /* Append event to master list and wake up any sleeping sessions */
02697    AST_LIST_LOCK(&sessions);
02698    append_event(buf->str, category);
02699    AST_LIST_TRAVERSE(&sessions, s, list) {
02700       ast_mutex_lock(&s->__lock);
02701       if (s->waiting_thread != AST_PTHREADT_NULL)
02702          pthread_kill(s->waiting_thread, SIGURG);
02703       else
02704          /* We have an event to process, but the mansession is
02705           * not waiting for it. We still need to indicate that there
02706           * is an event waiting so that get_input processes the pending
02707           * event instead of polling.
02708           */
02709          s->pending_event = 1;
02710       ast_mutex_unlock(&s->__lock);
02711    }
02712    AST_LIST_UNLOCK(&sessions);
02713 
02714    return 0;
02715 }

static void manager_event_buf_init ( void   )  [static]

Definition at line 129 of file manager.c.

00135 {

static int manager_state_cb ( char *  context,
char *  exten,
int  state,
void *  data 
) [static]

Definition at line 2743 of file manager.c.

References EVENT_FLAG_CALL, and manager_event().

Referenced by init_manager().

02744 {
02745    /* Notify managers of change */
02746    manager_event(EVENT_FLAG_CALL, "ExtensionStatus", "Exten: %s\r\nContext: %s\r\nStatus: %d\r\n", exten, context, state);
02747    return 0;
02748 }

static int process_events ( struct mansession s  )  [static]

Definition at line 2217 of file manager.c.

References mansession_session::__lock, ast_calloc, ast_carefulwrite(), ast_dynamic_str_append(), ast_mutex_lock(), ast_mutex_unlock(), mansession_session::authenticated, eventqent::category, eventqent::eventdata, mansession_session::eventq, mansession::fd, eventqent::next, mansession_session::outputstr, mansession_session::readperm, mansession_session::send_events, mansession::session, unuse_eventqent(), and mansession_session::writetimeout.

Referenced by do_message(), and process_message().

02218 {
02219    struct eventqent *eqe;
02220    int ret = 0;
02221    ast_mutex_lock(&s->session->__lock);
02222    if (!s->session->eventq)
02223       s->session->eventq = master_eventq;
02224    while(s->session->eventq->next) {
02225       eqe = s->session->eventq->next;
02226       if ((s->session->authenticated && (s->session->readperm & eqe->category) == eqe->category) &&
02227                ((s->session->send_events & eqe->category) == eqe->category)) {
02228          if (s->fd > -1) {
02229             if (!ret && ast_carefulwrite(s->fd, eqe->eventdata, strlen(eqe->eventdata), s->session->writetimeout) < 0)
02230                ret = -1;
02231          } else if (!s->session->outputstr && !(s->session->outputstr = ast_calloc(1, sizeof(*s->session->outputstr)))) 
02232             ret = -1;
02233          else 
02234             ast_dynamic_str_append(&s->session->outputstr, 0, "%s", eqe->eventdata);
02235       }
02236       unuse_eventqent(s->session->eventq);
02237       s->session->eventq = eqe;
02238    }
02239    ast_mutex_unlock(&s->session->__lock);
02240    return ret;
02241 }

static int process_message ( struct mansession s,
const struct message m 
) [static]

Definition at line 2273 of file manager.c.

References manager_action::action, actionlock, ast_atomic_fetchadd_int(), ast_copy_string(), ast_inet_ntoa(), ast_log(), AST_OPT_FLAG_FULLY_BOOTED, ast_opt_send_fullybooted, ast_options, ast_random(), ast_rwlock_rdlock(), ast_rwlock_unlock(), ast_strlen_zero(), ast_test_flag, ast_verbose(), astman_append(), astman_get_header(), astman_send_ack(), astman_send_error(), authenticate(), mansession_session::authenticated, manager_action::authority, authority_to_str(), mansession_session::challenge, EVENT_FLAG_SYSTEM, first_action, manager_action::func, LOG_DEBUG, LOG_EVENT, manager_action::next, option_debug, option_verbose, process_events(), mansession::session, mansession_session::sessiontimeout, mansession_session::sin, mansession_session::username, VERBOSE_PREFIX_2, and mansession_session::writeperm.

Referenced by do_message(), and generic_http_callback().

02274 {
02275    char action[80] = "";
02276    struct manager_action *tmp;
02277    const char *id = astman_get_header(m,"ActionID");
02278    char idText[256] = "";
02279    int ret = 0;
02280 
02281    ast_copy_string(action, astman_get_header(m, "Action"), sizeof(action));
02282    if (option_debug)
02283       ast_log( LOG_DEBUG, "Manager received command '%s'\n", action );
02284 
02285    if (ast_strlen_zero(action)) {
02286       astman_send_error(s, m, "Missing action in request");
02287       return 0;
02288    }
02289    if (!ast_strlen_zero(id)) {
02290       snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
02291    }
02292    if (!s->session->authenticated) {
02293       if (!strcasecmp(action, "Challenge")) {
02294          const char *authtype = astman_get_header(m, "AuthType");
02295 
02296          if (!strcasecmp(authtype, "MD5")) {
02297             if (ast_strlen_zero(s->session->challenge))
02298                snprintf(s->session->challenge, sizeof(s->session->challenge), "%ld", ast_random());
02299             astman_append(s, "Response: Success\r\n"
02300                   "%s"
02301                   "Challenge: %s\r\n\r\n",
02302                   idText, s->session->challenge);
02303             return 0;
02304          } else {
02305             astman_send_error(s, m, "Must specify AuthType");
02306             return 0;
02307          }
02308       } else if (!strcasecmp(action, "Login")) {
02309          if (authenticate(s, m)) {
02310             sleep(1);
02311             astman_send_error(s, m, "Authentication failed");
02312             return -1;
02313          } else {
02314             s->session->authenticated = 1;
02315             ast_atomic_fetchadd_int(&unauth_sessions, -1);
02316             if (option_verbose > 1) {
02317                if (displayconnects) {
02318                   ast_verbose(VERBOSE_PREFIX_2 "%sManager '%s' logged on from %s\n", 
02319                      (s->session->sessiontimeout ? "HTTP " : ""), s->session->username, ast_inet_ntoa(s->session->sin.sin_addr));
02320                }
02321             }
02322             ast_log(LOG_EVENT, "%sManager '%s' logged on from %s\n", 
02323                (s->session->sessiontimeout ? "HTTP " : ""), s->session->username, ast_inet_ntoa(s->session->sin.sin_addr));
02324             astman_send_ack(s, m, "Authentication accepted");
02325             if (ast_opt_send_fullybooted && ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
02326                char auth[80];
02327                   authority_to_str(EVENT_FLAG_SYSTEM, auth, sizeof(auth));
02328                astman_append(s, "Event: FullyBooted\r\n"
02329                   "Privilege: %s\r\n"
02330                   "Status: Fully Booted\r\n\r\n",
02331                   auth);
02332             }
02333          }
02334       } else if (!strcasecmp(action, "Logoff")) {
02335          astman_send_ack(s, m, "See ya");
02336          return -1;
02337       } else
02338          astman_send_error(s, m, "Authentication Required");
02339    } else {
02340       if (!strcasecmp(action, "Login"))
02341          astman_send_ack(s, m, "Already logged in");
02342       else {
02343          ast_rwlock_rdlock(&actionlock);
02344          for (tmp = first_action; tmp; tmp = tmp->next) {      
02345             if (strcasecmp(action, tmp->action))
02346                continue;
02347             if ((s->session->writeperm & tmp->authority) == tmp->authority) {
02348                if (tmp->func(s, m))
02349                   ret = -1;
02350             } else
02351                astman_send_error(s, m, "Permission denied");
02352             break;
02353          }
02354          ast_rwlock_unlock(&actionlock);
02355          if (!tmp)
02356             astman_send_error(s, m, "Invalid/unknown command");
02357       }
02358    }
02359    if (ret)
02360       return ret;
02361    return process_events(s);
02362 }

static void* session_do ( void *  data  )  [static]

Definition at line 2485 of file manager.c.

References ast_atomic_fetchadd_int(), ast_inet_ntoa(), ast_log(), ast_verbose(), astman_append(), mansession_session::authenticated, destroy_session(), do_message(), mansession_session::fd, LOG_EVENT, option_verbose, s, mansession_session::sin, mansession_session::username, and VERBOSE_PREFIX_2.

Referenced by accept_thread().

02486 {
02487    struct mansession_session *session = data;
02488    int res;
02489    struct mansession s = { .session = session, .fd = session->fd };
02490 
02491    astman_append(&s, "Asterisk Call Manager/1.0\r\n");
02492    for (;;) {
02493       if ((res = do_message(&s)) < 0)
02494          break;
02495    }
02496    if (session->authenticated) {
02497       if (option_verbose > 1) {
02498          if (displayconnects) 
02499             ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged off from %s\n", session->username, ast_inet_ntoa(session->sin.sin_addr));
02500       }
02501       ast_log(LOG_EVENT, "Manager '%s' logged off from %s\n", session->username, ast_inet_ntoa(session->sin.sin_addr));
02502    } else {
02503       ast_atomic_fetchadd_int(&unauth_sessions, -1);
02504       if (option_verbose > 1) {
02505          if (displayconnects)
02506             ast_verbose(VERBOSE_PREFIX_2 "Connect attempt from '%s' unable to authenticate\n", ast_inet_ntoa(session->sin.sin_addr));
02507       }
02508       ast_log(LOG_EVENT, "Failed attempt from %s\n", ast_inet_ntoa(session->sin.sin_addr));
02509    }
02510 
02511    /* At one point there was a usleep(1) here intended to allow the call
02512     * to ast_pthread_create_background() to complete before this thread
02513     * exited. This should no longer be necessary as the thread id is no
02514     * longer stored in the mansessions_session.
02515     */
02516 
02517    destroy_session(session);
02518    return NULL;
02519 }

static int set_eventmask ( struct mansession_session s,
const 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 1001 of file manager.c.

References mansession_session::__lock, ast_mutex_lock(), ast_mutex_unlock(), mansession_session::send_events, and strings_to_mask().

Referenced by action_events(), and authenticate().

01002 {
01003    int maskint = strings_to_mask(eventmask);
01004 
01005    ast_mutex_lock(&s->__lock);
01006    if (maskint >= 0) 
01007       s->send_events = maskint;
01008    ast_mutex_unlock(&s->__lock);
01009    
01010    return maskint;
01011 }

static int strings_to_mask ( const char *  string  )  [static]

Definition at line 970 of file manager.c.

References ast_false(), ast_instring(), ast_is_number(), ast_strlen_zero(), ast_true(), and perms.

Referenced by set_eventmask().

00971 {
00972    int x, ret = -1;
00973    
00974    x = ast_is_number(string);
00975 
00976    if (x)
00977       ret = x;
00978    else if (ast_strlen_zero(string))
00979       ret = -1;
00980    else if (ast_false(string))
00981       ret = 0;
00982    else if (ast_true(string)) {
00983       ret = 0;
00984       for (x=0; x<sizeof(perms) / sizeof(perms[0]); x++)
00985          ret |= perms[x].num;    
00986    } else {
00987       ret = 0;
00988       for (x=0; x<sizeof(perms) / sizeof(perms[0]); x++) {
00989          if (ast_instring(string, perms[x].label, ',')) 
00990             ret |= perms[x].num;    
00991       }
00992    }
00993 
00994    return ret;
00995 }

static void unuse_eventqent ( struct eventqent e  )  [static]

Definition at line 791 of file manager.c.

References ast_atomic_dec_and_test(), eventqent::next, mansession_session::next, and eventqent::usecount.

Referenced by action_waitevent(), free_session(), and process_events().

00792 {
00793    struct eventqent *next = e->next;
00794    if (ast_atomic_dec_and_test(&e->usecount) && next)
00795       pthread_kill(t, SIGURG);
00796 }

static int variable_count_cmp_fn ( void *  obj,
void *  vstr,
int  flags 
) [static]

Definition at line 373 of file manager.c.

References variable_count::varname.

Referenced by xml_translate().

00374 {
00375    /* Due to the simplicity of struct variable_count, it makes no difference
00376     * if you pass in objects or strings, the same operation applies. This is
00377     * due to the fact that the hash occurs on the first element, which means
00378     * the address of both the struct and the string are exactly the same. */
00379    struct variable_count *vc = obj;
00380    char *str = vstr;
00381    return !strcmp(vc->varname, str) ? CMP_MATCH | CMP_STOP : 0;
00382 }

static int variable_count_hash_fn ( const void *  vvc,
const int  flags 
) [static]

Definition at line 361 of file manager.c.

References compress_char(), and variable_count::varname.

Referenced by xml_translate().

00362 {
00363    const struct variable_count *vc = vvc;
00364    int res = 0, i;
00365    for (i = 0; i < 5; i++) {
00366       if (vc->varname[i] == '\0')
00367          break;
00368       res += compress_char(vc->varname[i]) << (i * 6);
00369    }
00370    return res;
00371 }

static void xml_copy_escape ( char **  dst,
size_t *  maxlen,
const char *  src,
int  lower 
) [static]

Definition at line 306 of file manager.c.

Referenced by xml_translate().

00307 {
00308    while (*src && (*maxlen > 6)) {
00309       switch (*src) {
00310       case '<':
00311          strcpy(*dst, "&lt;");
00312          (*dst) += 4;
00313          *maxlen -= 4;
00314          break;
00315       case '>':
00316          strcpy(*dst, "&gt;");
00317          (*dst) += 4;
00318          *maxlen -= 4;
00319          break;
00320       case '\"':
00321          strcpy(*dst, "&quot;");
00322          (*dst) += 6;
00323          *maxlen -= 6;
00324          break;
00325       case '\'':
00326          strcpy(*dst, "&apos;");
00327          (*dst) += 6;
00328          *maxlen -= 6;
00329          break;
00330       case '&':
00331          strcpy(*dst, "&amp;");
00332          (*dst) += 5;
00333          *maxlen -= 5;
00334          break;      
00335       default:
00336          *(*dst)++ = lower ? tolower(*src) : *src;
00337          (*maxlen)--;
00338       }
00339       src++;
00340    }
00341 }

static char* xml_translate ( char *  in,
struct ast_variable vars 
) [static]

Definition at line 384 of file manager.c.

References ao2_alloc(), ao2_container_alloc(), ao2_find(), ao2_ref(), ast_build_string(), ast_malloc, variable_count::count, len(), ast_variable::name, ast_variable::next, ast_variable::value, var, variable_count_cmp_fn(), variable_count_hash_fn(), variable_count::varname, and xml_copy_escape().

Referenced by generic_http_callback().

00385 {
00386    struct ast_variable *v;
00387    char *dest = NULL;
00388    char *out, *tmp, *var, *val;
00389    char *objtype = NULL;
00390    int colons = 0;
00391    int breaks = 0;
00392    size_t len;
00393    int count = 1;
00394    int escaped = 0;
00395    int inobj = 0;
00396    int x;
00397    struct variable_count *vc = NULL;
00398    struct ao2_container *vco = NULL;
00399 
00400    for (v = vars; v; v = v->next) {
00401       if (!dest && !strcasecmp(v->name, "ajaxdest"))
00402          dest = v->value;
00403       else if (!objtype && !strcasecmp(v->name, "ajaxobjtype")) 
00404          objtype = v->value;
00405    }
00406    if (!dest)
00407       dest = "unknown";
00408    if (!objtype)
00409       objtype = "generic";
00410    for (x = 0; in[x]; x++) {
00411       if (in[x] == ':')
00412          colons++;
00413       else if (in[x] == '\n')
00414          breaks++;
00415       else if (strchr("&\"<>\'", in[x]))
00416          escaped++;
00417    }
00418    len = (size_t) (strlen(in) + colons * 5 + breaks * (40 + strlen(dest) + strlen(objtype)) + escaped * 10); /* foo="bar", "<response type=\"object\" id=\"dest\"", "&amp;" */
00419    out = ast_malloc(len);
00420    if (!out)
00421       return 0;
00422    tmp = out;
00423    while (*in) {
00424       var = in;
00425       while (*in && (*in >= 32))
00426          in++;
00427       if (*in) {
00428          if ((count > 3) && inobj) {
00429             ast_build_string(&tmp, &len, " /></response>\n");
00430             inobj = 0;
00431 
00432             /* Entity is closed, so close out the name cache */
00433             ao2_ref(vco, -1);
00434             vco = NULL;
00435          }
00436          count = 0;
00437          while (*in && (*in < 32)) {
00438             *in = '\0';
00439             in++;
00440             count++;
00441          }
00442          val = strchr(var, ':');
00443          if (val) {
00444             *val = '\0';
00445             val++;
00446             if (*val == ' ')
00447                val++;
00448             if (!inobj) {
00449                vco = ao2_container_alloc(37, variable_count_hash_fn, variable_count_cmp_fn);
00450                ast_build_string(&tmp, &len, "<response type='object' id='%s'><%s", dest, objtype);
00451                inobj = 1;
00452             }
00453 
00454             /* Check if the var has been used already */
00455             if ((vc = ao2_find(vco, var, 0)))
00456                vc->count++;
00457             else {
00458                /* Create a new entry for this one */
00459                vc = ao2_alloc(sizeof(*vc), NULL);
00460                vc->varname = var;
00461                vc->count = 1;
00462                ao2_link(vco, vc);
00463             }
00464 
00465             ast_build_string(&tmp, &len, " ");
00466             xml_copy_escape(&tmp, &len, var, 1);
00467             if (vc->count > 1)
00468                ast_build_string(&tmp, &len, "-%d", vc->count);
00469             ast_build_string(&tmp, &len, "='");
00470             xml_copy_escape(&tmp, &len, val, 0);
00471             ast_build_string(&tmp, &len, "'");
00472             ao2_ref(vc, -1);
00473          }
00474       }
00475    }
00476    if (inobj)
00477       ast_build_string(&tmp, &len, " /></response>\n");
00478    if (vco)
00479       ao2_ref(vco, -1);
00480    return out;
00481 }


Variable Documentation

ast_rwlock_t actionlock = PTHREAD_RWLOCK_INITIALIZER [static]

int asock = -1 [static]

Definition at line 113 of file manager.c.

struct ast_threadstorage astman_append_buf = { .once = PTHREAD_ONCE_INIT , .key_init = astman_append_buf_init , } [static]

Definition at line 132 of file manager.c.

Referenced by astman_append().

int authlimit [static]

Definition at line 119 of file manager.c.

int authtimeout [static]

Definition at line 118 of file manager.c.

int block_sockets [static]

Definition at line 122 of file manager.c.

int broken_events_action [static]

Definition at line 117 of file manager.c.

struct ast_cli_entry cli_manager[] [static]

Definition at line 765 of file manager.c.

Referenced by init_manager().

Initial value:

 {
   { "show", "manager", "command", NULL },
   handle_showmancmd, NULL,
   NULL, complete_show_mancmd }

Definition at line 745 of file manager.c.

Initial value:

 {
   { "show", "manager", "commands", NULL },
   handle_showmancmds, NULL,
   NULL }

Definition at line 750 of file manager.c.

Initial value:

 {
   { "show", "manager", "connected", NULL },
   handle_showmanconn, NULL,
   NULL }

Definition at line 755 of file manager.c.

Initial value:

 {
   { "show", "manager", "eventq", NULL },
   handle_showmaneventq, NULL,
   NULL }

Definition at line 760 of file manager.c.

struct { ... } command_blacklist[] [static]

Referenced by check_blacklist().

const int DEFAULT_AUTHLIMIT = 50 [static]

Default setting for authlimit

Definition at line 108 of file manager.c.

const int DEFAULT_AUTHTIMEOUT = 30 [static]

Default setting for authtimeout

Definition at line 107 of file manager.c.

const int DEFAULT_BLOCKSOCKETS = 0 [static]

Default setting for block-sockets

Definition at line 102 of file manager.c.

const int DEFAULT_BROKENEVENTSACTION = 0 [static]

Default setting for brokeneventsaction

Definition at line 106 of file manager.c.

const int DEFAULT_DISPLAYCONNECTS = 1 [static]

Default setting for displaying manager connections

Definition at line 103 of file manager.c.

const int DEFAULT_ENABLED = 0 [static]

Default setting for manager to be enabled

Definition at line 100 of file manager.c.

const int DEFAULT_HTTPTIMEOUT = 60 [static]

Default manager http timeout

Definition at line 105 of file manager.c.

const int DEFAULT_TIMESTAMPEVENTS = 0 [static]

Default setting for timestampevents

Definition at line 104 of file manager.c.

const int DEFAULT_WEBENABLED = 0 [static]

Default setting for the web interface to be enabled

Definition at line 101 of file manager.c.

int displayconnects [static]

Definition at line 114 of file manager.c.

int enabled [static]

Definition at line 111 of file manager.c.

struct manager_action* first_action [static]

int httptimeout [static]

Definition at line 116 of file manager.c.

struct ast_threadstorage manager_event_buf = { .once = PTHREAD_ONCE_INIT , .key_init = manager_event_buf_init , } [static]

Definition at line 129 of file manager.c.

Referenced by manager_event().

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 1831 of file manager.c.

Referenced by init_manager().

char mandescr_events[] [static]

Definition at line 1439 of file manager.c.

Referenced by init_manager().

char mandescr_extensionstate[] [static]

Definition at line 2145 of file manager.c.

Referenced by init_manager().

char mandescr_getconfig[] [static]

Initial value:

"Description: A 'GetConfig' action will dump the contents of a configuration\n"
"file by category and contents.\n"
"Variables:\n"
"   Filename: Configuration filename (e.g. foo.conf)\n"

Definition at line 1170 of file manager.c.

Referenced by init_manager().

char mandescr_getvar[] [static]

Definition at line 1560 of file manager.c.

Referenced by init_manager().

char mandescr_hangup[] [static]

Initial value:

 
"Description: Hangup a channel\n"
"Variables: \n"
"  Channel: The channel name to be hungup\n"

Definition at line 1489 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 1414 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 1479 of file manager.c.

Referenced by init_manager().

char mandescr_mailboxcount[] [static]

Definition at line 2109 of file manager.c.

Referenced by init_manager().

char mandescr_mailboxstatus[] [static]

Help text for manager command mailboxstatus.

Definition at line 2077 of file manager.c.

Referenced by init_manager().

char mandescr_originate[] [static]

Definition at line 1939 of file manager.c.

Referenced by init_manager().

char mandescr_ping[] [static]

Initial value:

 
"Description: A 'Ping' action will ellicit a 'Pong' response.  Used to keep the\n"
"  manager connection open.\n"
"Variables: NONE\n"
Manager PING.

Definition at line 1159 of file manager.c.

Referenced by init_manager().

char mandescr_redirect[] [static]

Definition at line 1710 of file manager.c.

Referenced by init_manager().

char mandescr_setvar[] [static]

Definition at line 1513 of file manager.c.

Referenced by init_manager().

char mandescr_timeout[] [static]

Definition at line 2186 of file manager.c.

Referenced by init_manager().

char mandescr_updateconfig[] [static]

Definition at line 1274 of file manager.c.

Referenced by init_manager().

char mandescr_userevent[] [static]

Definition at line 2243 of file manager.c.

Referenced by init_manager().

char mandescr_waitevent[] [static]

Manager WAITEVENT.

Definition at line 1325 of file manager.c.

Referenced by init_manager().

struct eventqent* master_eventq = NULL

Definition at line 127 of file manager.c.

int num_sessions [static]

Definition at line 123 of file manager.c.

struct permalias perms[] [static]

int portno = DEFAULT_MANAGER_PORT [static]

Definition at line 112 of file manager.c.

Referenced by ast_netsock_bind(), create_addr(), process_sdp(), and set_config().

char showmanager_help[] [static]

Initial value:

" Usage: manager show user <user>\n"
"        Display all information related to the manager user specified.\n"

Definition at line 741 of file manager.c.

char showmanagers_help[] [static]

Initial value:

"Usage: manager show users\n"
"       Prints a listing of all managers that are currently configured on that\n"
" system.\n"

Definition at line 736 of file manager.c.

char showmancmd_help[] [static]

Initial value:

 
"Usage: manager show command <actionname>\n"
"  Shows the detailed description for a specific Asterisk manager interface command.\n"

Definition at line 718 of file manager.c.

char showmancmds_help[] [static]

Initial value:

 
"Usage: manager show commands\n"
"  Prints a listing of all the available Asterisk manager interface commands.\n"

Definition at line 722 of file manager.c.

char showmanconn_help[] [static]

Initial value:

 
"Usage: manager show connected\n"
"  Prints a listing of the users that are currently connected to the\n"
"Asterisk manager interface.\n"

Definition at line 726 of file manager.c.

char showmaneventq_help[] [static]

Initial value:

 
"Usage: manager show eventq\n"
"  Prints a listing of all events pending in the Asterisk manger\n"
"event queue.\n"

Definition at line 731 of file manager.c.

pthread_t t [static]

Definition at line 121 of file manager.c.

Referenced by __schedule_action(), acf_odbc_write(), add_sdp(), append_date(), ast_channel_bridge(), ast_check_timing(), ast_do_masquerade(), ast_get_time_t(), ast_httpd_helper_thread(), ast_log(), ast_pbx_start(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), ast_say_number_full_de(), ast_translator_build_path(), ast_tvdiff_ms(), ast_verbose(), background_detect_exec(), build_mapping(), byteReverse(), callerid_genmsg(), callerid_getcarrier(), cb_events(), cdr_get_tv(), check_switch_expr(), check_user_full(), cli_prompt(), config_text_file_save(), destroy(), do_monitor(), does_peer_need_mwi(), dump_cmd_queues(), expr2_token_subst(), gen_match_to_pattern(), gen_tone(), gen_tones(), get_date(), get_trans_id(), gtalk_action(), gtalk_create_candidates(), gtalk_digit(), gtalk_invite(), gtalk_invite_response(), handle_bchan(), handle_call_token(), handle_enbloc_call_message(), handle_hd_hf(), handle_offhook_message(), handle_save_dialplan(), handle_soft_key_event_message(), handle_stimulus_message(), iax2_datetime(), iax2_process_thread(), iax2_show_threads(), iax_template_parse(), launch_service(), listener(), local_new(), localsub(), lws2sws(), manager_log(), MD5Update(), misdn_read(), osp_create_provider(), osp_load(), packdate(), parse_moved_contact(), pgsql_log(), prune_gateways(), rebuild_matrix(), register_verify(), send_request(), SHA1ProcessMessageBlock(), socket_read(), sqlite_log(), strip_quotes(), tdd_getcarrier(), time1(), time2(), time2sub(), transmit_notify_request_with_callerid(), transmit_notify_with_mwi(), transmit_state_notify(), and write_metadata().

int timestampevents [static]

Definition at line 115 of file manager.c.

int unauth_sessions = 0 [static]

Definition at line 124 of file manager.c.

char* words[AST_MAX_CMD_LEN] [inherited]

Definition at line 153 of file manager.c.


Generated on Thu Oct 11 06:44:30 2012 for Asterisk - the Open Source PBX by  doxygen 1.5.6