175#define DEFAULT_REALM       "asterisk" 
  203#define MGR_SHOW_TERMINAL_WIDTH 80 
  208#define EVENT_FLAG_SHUTDOWN -1 
  220#define MAX_BLACKLIST_CMD_LEN 2 
  224    {{ 
"module", 
"load", 
NULL }},
 
  225    {{ 
"module", 
"unload", 
NULL }},
 
  226    {{ 
"restart", 
"gracefully", 
NULL }},
 
  414    const char *filter_pattern, 
struct ao2_container *includefilters,
 
  441            ao2_t_ref(act, +1, 
"found action object");
 
 
  486                    size_t index, 
struct ast_str **res,
 
 
  496                      const char *parent_key, 
struct ast_str **res,
 
  501        ast_str_set(&key_str, 0, 
"%s/%s", parent_key, key);
 
 
  524    if (exclusion_cb && key && exclusion_cb(key)) {
 
  538                            key, j, res, exclusion_cb);
 
  547                      key, res, exclusion_cb);
 
 
  562#define manager_event_sessions(sessions, category, event, contents , ...)   \ 
  563    __manager_event_sessions(sessions, category, event, 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__) 
 
  565#define any_manager_listeners(sessions) \ 
  566    ((sessions && ao2_container_count(sessions)) || !AST_RWLIST_EMPTY(&manager_hooks)) 
 
  647            "class_type", class_type,
 
 
  774#define MAX_AUTH_PERM_STRING    150 
  781            strstr(evaluating, 
"SHELL") ||       
 
  782            strstr(evaluating, 
"EVAL")           
 
 
  823            if (authority & 
perms[i].num) {
 
 
  843static int ast_instring(
const char *bigstr, 
const char *smallstr, 
const char delim)
 
  845    const char *
val = bigstr, *next;
 
  848        if ((next = strchr(
val, delim))) {
 
  849            if (!strncmp(
val, smallstr, (next - 
val))) {
 
  855            return !strcmp(smallstr, 
val);
 
  857    } 
while (*(
val = (next + 1)));
 
 
  891    for (p = 
string; *p; p++) {
 
  892        if (*p < 
'0' || *p > 
'9') {
 
 
  918        ast_debug(1, 
"Mansession: %p refcount now %d\n", s, refcount - 1);
 
 
  955        ao2_t_ref(
session->includefilters, -1, 
"decrement ref for include container, should be last one");
 
  959        ao2_t_ref(
session->excludefilters, -1, 
"decrement ref for exclude container, should be last one");
 
 
 1047        if (!strcasecmp(
user->username, 
name)) {
 
 
 1066        ret = 
user->displayconnects;
 
 
 1083    const char *auth_str;
 
 1087        e->
command = 
"manager show command";
 
 1089            "Usage: manager show command <actionname> [<actionname> [<actionname> [...]]]\n" 
 1090            "   Shows the detailed description for a specific Asterisk manager interface command.\n";
 
 1093        l = strlen(
a->word);
 
 1096            if (!strncasecmp(
a->word, cur->
action, l)) {
 
 1113        for (num = 3; num < 
a->argc; num++) {
 
 1114            if (!strcasecmp(cur->
action, 
a->argv[num])) {
 
 1128                    if (!
synopsis || !since || !description || !syntax || !arguments
 
 1129                            || !privilege || !seealso || !responses) {
 
 1138                        ast_cli(
a->fd, 
"Allocation failure.\n");
 
 1145                        "%s  -= Info about Manager Command '%s' =- %s\n\n" 
 1173                        ast_cli(
a->fd, 
"%s\n\n", responses);
 
 1191                        ast_cli(
a->fd, 
"%s\n\n", responses);
 
 1212                    ast_cli(
a->fd, 
"Action: %s\nSynopsis: %s\nPrivilege: %s\n%s\n",
 
 
 1229        e->
command = 
"manager set debug [on|off]";
 
 1230        e->
usage = 
"Usage: manager set debug [on|off]\n Show, enable, disable debugging of the manager code.\n";
 
 1238    } 
else if (
a->argc == 4) {
 
 1239        if (!strcasecmp(
a->argv[3], 
"on")) {
 
 1241        } 
else if (!strcasecmp(
a->argv[3], 
"off")) {
 
 
 1260        e->
command = 
"manager show user";
 
 1262            " Usage: manager show user <user>\n" 
 1263            "        Display all information related to the manager user specified.\n";
 
 1266        l = strlen(
a->word);
 
 1272            if (!strncasecmp(
a->word, 
user->username, l)) {
 
 1289        ast_cli(
a->fd, 
"There is no manager called %s\n", 
a->argv[3]);
 
 1301        "   displayconnects: %s\n" 
 1302        "allowmultiplelogin: %s\n",
 
 1304        (
user->secret ? 
"<Set>" : 
"(N/A)"),
 
 1308        (
user->displayconnects ? 
"yes" : 
"no"),
 
 1309        (
user->allowmultiplelogin ? 
"yes" : 
"no"));
 
 1311        for (v = 
user->chanvars ; v ; v = v->
next) {
 
 
 1329        e->
command = 
"manager show users";
 
 1331            "Usage: manager show users\n" 
 1332            "       Prints a listing of all managers that are currently configured on that\n" 
 1346        ast_cli(
a->fd, 
"There are no manager users.\n");
 
 1351    ast_cli(
a->fd, 
"\nusername\n--------\n");
 
 1360    ast_cli(
a->fd,
"-------------------\n" 
 1361              "%d manager users configured.\n", count_amu);
 
 
 1370    int space_remaining;
 
 1371#define HSMC_FORMAT "  %-*.*s  %-.*s\n" 
 1374        e->
command = 
"manager show commands";
 
 1376            "Usage: manager show commands\n" 
 1377            "   Prints a listing of all the available Asterisk manager interface commands.\n";
 
 1385        int incoming_len = strlen(cur->
action);
 
 1386        if (incoming_len > name_len) {
 
 1387            name_len = incoming_len;
 
 1392    if (space_remaining < 0) {
 
 1393        space_remaining = 0;
 
 
 1418        e->
command = 
"manager kick session";
 
 1420            "Usage: manager kick session <file descriptor>\n" 
 1421            "   Kick an active Asterisk Manager Interface session\n";
 
 1431    fd = atoi(
a->argv[3]);
 
 1433        ast_cli(
a->fd, 
"Invalid AMI file descriptor: %s\n", 
a->argv[3]);
 
 1446                        ast_cli(
a->fd, 
"Manager session using file descriptor %d has already been kicked\n", fd);
 
 1453                    ast_cli(
a->fd, 
"Kicking manager session connected using file descriptor %d\n", fd);
 
 1457                        pthread_kill(
session->waiting_thread, SIGURG);
 
 1472        ast_cli(
a->fd, 
"No manager session found using file descriptor %d\n", fd);
 
 
 1482    time_t now = time(
NULL);
 
 1483#define HSMCONN_FORMAT1 "  %-15.15s  %-55.55s  %-10.10s  %-10.10s  %-8.8s  %-8.8s  %-10.10s  %-10.10s\n" 
 1484#define HSMCONN_FORMAT2 "  %-15.15s  %-55.55s  %-10d  %-10d  %-8d  %-8d  %-10.10d  %-10.10d\n" 
 1490        e->
command = 
"manager show connected";
 
 1492            "Usage: manager show connected\n" 
 1493            "   Prints a listing of the users that are currently connected to the\n" 
 1494            "Asterisk manager interface.\n";
 
 1500    ast_cli(
a->fd, 
HSMCONN_FORMAT1, 
"Username", 
"IP Address", 
"Start", 
"Elapsed", 
"FileDes", 
"HttpCnt", 
"ReadPerms", 
"WritePerms");
 
 1510                (
int) (
session->sessionstart),
 
 1511                (
int) (now - 
session->sessionstart),
 
 1522    ast_cli(
a->fd, 
"%d users connected.\n", count);
 
 
 1534        e->
command = 
"manager show eventq";
 
 1536            "Usage: manager show eventq\n" 
 1537            "   Prints a listing of all events pending in the Asterisk manger\n" 
 
 1561        e->
command = 
"manager reload";
 
 1563            "Usage: manager reload\n" 
 1564            "       Reloads the manager configuration.\n";
 
 
 1589#define GET_HEADER_FIRST_MATCH  0 
 1590#define GET_HEADER_LAST_MATCH   1 
 1591#define GET_HEADER_SKIP_EMPTY   2 
 1608    int x, l = strlen(
var);
 
 1615    for (x = 0; x < m->
hdrcount; x++) {
 
 1616        const char *h = m->
headers[x];
 
 1617        if (!strncasecmp(
var, h, l) && h[l] == 
':') {
 
 1618            const char *
value = h + l + 1;
 
 
 1701        for (y = 0; y < 
args.argc; y++) {
 
 1706            if (!
args.vars[y]) {
 
 
 1741    static const char var_hdr[] = 
"Variable:";
 
 1744    varlen = strlen(var_hdr);
 
 1745    for (x = 0; x < m->
hdrcount; x++) {
 
 1746        if (strncasecmp(var_hdr, m->
headers[x], varlen)) {
 
 
 1783    curlen = strlen(src);
 
 1784    for (x = 0; x < curlen; x++) {
 
 1786        if (src[x] == 
'\r' && x+1 < curlen && src[x+1] == 
'\n')
 
 1788        else if (src[x] == 
'\n')
 
 1807        if (!strcasecmp(action, 
"login")) {
 
 1830            if (!act_found->module || mod_ref) {
 
 1831                ret = act_found->
func(&s, &m);
 
 1837        ao2_t_ref(act_found, -1, 
"done with found action object");
 
 
 1889#define ASTMAN_APPEND_BUF_INITSIZE   256 
 1896        ast_verbose(
"No connection stream in astman_append, should not happen\n");
 
 
 1923        ast_verbose(
"No connection stream in astman_append, should not happen\n");
 
 
 1937#define MSG_MOREDATA    ((char *)astman_send_response) 
 2044        "EventList: Complete\r\n" 
 2045        "ListItems: %d\r\n",
 
 
 2110    char session_id[32];
 
 2114        .common.service    = 
"AMI",
 
 2115        .common.account_id = username,
 
 2117        .common.local_addr = {
 
 2121        .common.remote_addr = {
 
 2125        .common.session_id = session_id,
 
 2128    snprintf(session_id, 
sizeof(session_id), 
"%p", s);
 
 
 2135    char session_id[32];
 
 2139        .common.service    = 
"AMI",
 
 2140        .common.account_id = username,
 
 2142        .common.local_addr = {
 
 2146        .common.remote_addr = {
 
 2150        .common.session_id = session_id,
 
 2153    snprintf(session_id, 
sizeof(session_id), 
"%p", s->
session);
 
 
 2160    char session_id[32];
 
 2164        .common.service    = 
"AMI",
 
 2165        .common.account_id = username,
 
 2167        .common.local_addr = {
 
 2171        .common.remote_addr = {
 
 2175        .common.session_id = session_id,
 
 2178    snprintf(session_id, 
sizeof(session_id), 
"%p", s->
session);
 
 
 2185    char session_id[32];
 
 2189        .common.service    = 
"AMI",
 
 2192        .common.local_addr = {
 
 2196        .common.remote_addr = {
 
 2200        .common.session_id = session_id,
 
 2203    snprintf(session_id, 
sizeof(session_id), 
"%p", s->
session);
 
 
 2210    char session_id[32];
 
 2211    char request_type[64];
 
 2215        .common.service    = 
"AMI",
 
 2218        .common.local_addr = {
 
 2222        .common.remote_addr = {
 
 2226        .common.session_id = session_id,
 
 2231    snprintf(session_id, 
sizeof(session_id), 
"%p", s->
session);
 
 
 2239    char session_id[32];
 
 2244        .common.service    = 
"AMI",
 
 2247        .common.local_addr = {
 
 2251        .common.remote_addr = {
 
 2255        .common.session_id = session_id,
 
 2260    snprintf(session_id, 
sizeof(session_id), 
"%p", s->
session);
 
 
 2267        const char *response, 
const char *expected_response)
 
 2269    char session_id[32];
 
 2273        .common.service    = 
"AMI",
 
 2276        .common.local_addr = {
 
 2280        .common.remote_addr = {
 
 2284        .common.session_id = session_id,
 
 2291    snprintf(session_id, 
sizeof(session_id), 
"%p", s->
session);
 
 
 2298    char session_id[32];
 
 2302        .common.service    = 
"AMI",
 
 2305        .common.local_addr = {
 
 2309        .common.remote_addr = {
 
 2313        .common.session_id = session_id,
 
 2316    snprintf(session_id, 
sizeof(session_id), 
"%p", s->
session);
 
 
 2334    regex_t *regex_filter;
 
 2355            char md5key[256] = 
"";
 
 2357            unsigned char digest[16];
 
 2363            for (x = 0; x < 16; x++)
 
 2364                len += sprintf(md5key + 
len, 
"%02hhx", digest[x]);
 
 2365            if (!strcmp(md5key, key)) {
 
 2371            ast_debug(1, 
"MD5 authentication is not possible.  challenge: '%s'\n",
 
 2374    } 
else if (
user->secret) {
 
 2375        if (!strcmp(password, 
user->secret)) {
 
 2397    if (
user->chanvars) {
 
 2404        ao2_t_ref(regex_filter, -1, 
"remove iterator ref");
 
 2411        ao2_t_ref(regex_filter, -1, 
"remove iterator ref");
 
 
 2437        "Timestamp: %ld.%06lu\r\n" 
 2439        (
long) now.tv_sec, (
unsigned long) now.tv_usec);
 
 
 2466    char *stripped_filename;
 
 2477    if (stripped_filename[0] == 
'/') {
 
 2478        real_path = realpath(stripped_filename, 
NULL);
 
 2483        real_path = realpath(path, 
NULL);
 
 
 2503    const char *category_name;
 
 2520    } 
else if (ret == -1) {
 
 2540        astman_append(s, 
"Category-%06d: %s\r\n", catcount, category_name);
 
 
 2588    } 
else if (ret == -1) {
 
 2607    if (catcount == 0) { 
 
 
 2621        if (*
in == 
'\\' || *
in == 
'\"') {
 
 
 2652    const char *category_name;
 
 
 2728    for (x = 0; x < 100000; x++) {  
 
 2729        unsigned int object = 0;
 
 2733        int ignoreerror = 0;
 
 2741        snprintf(hdr, 
sizeof(hdr), 
"Action-%06d", x);
 
 2746        snprintf(hdr, 
sizeof(hdr), 
"Cat-%06d", x);
 
 2753        snprintf(hdr, 
sizeof(hdr), 
"Var-%06d", x);
 
 2756        snprintf(hdr, 
sizeof(hdr), 
"Value-%06d", x);
 
 2764        snprintf(hdr, 
sizeof(hdr), 
"Match-%06d", x);
 
 2767        snprintf(hdr, 
sizeof(hdr), 
"Line-%06d", x);
 
 2770        snprintf(hdr, 
sizeof(hdr), 
"Options-%06d", x);
 
 2777                if (!strcasecmp(
"allowdups", token)) {
 
 2781                if (!strcasecmp(
"template", token)) {
 
 2785                if (!strcasecmp(
"ignoreerror", token)) {
 
 2808        if (!strcasecmp(action, 
"newcat")) {
 
 2810            char *tmpl_name = 
NULL;
 
 2850            if (category != 
NULL) {
 
 2861        } 
else if (!strcasecmp(action, 
"renamecat")) {
 
 2877        } 
else if (!strcasecmp(action, 
"delcat")) {
 
 2884            if (!foundcat && !ignoreerror) {
 
 2888        } 
else if (!strcasecmp(action, 
"emptycat")) {
 
 2899        } 
else if (!strcasecmp(action, 
"update")) {
 
 2923        } 
else if (!strcasecmp(action, 
"delete")) {
 
 2943            if (!foundvar && !ignoreerror) {
 
 2947        } 
else if (!strcasecmp(action, 
"append")) {
 
 2959                if (
object || (
match && !strcasecmp(
match, 
"object"))) {
 
 2970        } 
else if (!strcasecmp(action, 
"insert")) {
 
 
 3010    const char *preserve_effective_context_string = 
astman_get_header(m, 
"PreserveEffectiveContext");
 
 
 3097    char *stripped_filename;
 
 3111    if (stripped_filename[0] != 
'/') {
 
 3130    filename = strrchr(filepath, 
'/');
 
 3139    real_dir = realpath(filepath, 
NULL);
 
 3152    if (
ast_asprintf(&real_path, 
"%s/%s", real_dir, filename) == -1) {
 
 3157    if ((fd = open(real_path, O_CREAT | O_EXCL, 
AST_FILE_MODE)) != -1) {
 
 
 3177        snprintf(idText, 
sizeof(idText), 
"ActionID: %s\r\n", 
id);
 
 3183        sscanf(timeouts, 
"%30i", &timeout);
 
 3204        time_t now = time(
NULL);
 
 3210        if (timeout < 0 || timeout > 
max) {
 
 3222    ast_debug(1, 
"Starting waiting for an event!\n");
 
 3224    for (x = 0; x < timeout || timeout < 0; x++) {
 
 3253    ast_debug(1, 
"Finished waiting for an event!\n");
 
 3273            "Event: WaitEventComplete\r\n" 
 3279        ast_debug(1, 
"Abandoning event request!\n");
 
 
 3312        snprintf(id_text, 
sizeof(id_text), 
"ActionID: %s\r\n", 
id);
 
 3324                if (!strcasecmp(
perms[x].label, 
"all") && res == 
perms[x].
num) {
 
 3329                     "Events: On\r\n\r\n", id_text);
 
 3330        } 
else if (res == 0)
 
 3332                     "Events: Off\r\n\r\n", id_text);
 
 3338                 "Events: On\r\n\r\n", id_text);
 
 3341                 "Events: Off\r\n\r\n", id_text);
 
 
 3380        long lastreloaded = 0;
 
 3386            uptime = tmp.tv_sec;
 
 3391            lastreloaded = tmp.tv_sec;
 
 3397            "LastReload: %ld\r\n" 
 3398            "Status: Fully Booted\r\n\r\n", cat_str, uptime, lastreloaded);
 
 
 3407    if (!strcasecmp(authtype, 
"MD5")) {
 
 
 3434    int channels_matched = 0;
 
 3442        snprintf(idText, 
sizeof(idText), 
"ActionID: %s\r\n", 
id);
 
 3447    if (cause_validator) {
 
 3448        causecode = cause_validator(name_or_regex, cause);
 
 3451        causecode = strtol(cause, &endptr, 10);
 
 3452        if (causecode < 0 || causecode > 127 || *endptr != 
'\0') {
 
 3462    if (name_or_regex[0] != 
'/') {
 
 3470        ast_verb(3, 
"%sManager '%s' from %s, hanging up channel: %s\n",
 
 3476        hangup_handler(
c, causecode);
 
 3488    if (!regex_string) {
 
 3495        astman_send_error(s, m, 
"Regex format invalid, Channel param should be /regex/");
 
 3501    if (regcomp(®exbuf, 
ast_str_buffer(regex_string), REG_EXTENDED | REG_NOSUB)) {
 
 3516            ast_verb(3, 
"%sManager '%s' from %s, hanging up channel: %s\n",
 
 3522            hangup_handler(
c, causecode);
 
 3526                "Event: ChannelHungup\r\n" 
 
 3587    char workspace[1024];
 
 3607    workspace[0] = 
'\0';
 
 3608    if (varname[strlen(varname) - 1] == 
')') {
 
 3612                ast_func_read(
c, (
char *) varname, workspace, 
sizeof(workspace));
 
 3614                ast_log(
LOG_ERROR, 
"Unable to allocate bogus channel for variable substitution.  Function results may be blank.\n");
 
 3616            ast_func_read(
c, (
char *) varname, workspace, 
sizeof(workspace));
 
 3628    astman_append(s, 
"Variable: %s\r\nValue: %s\r\n\r\n", varname, 
S_OR(varval, 
""));
 
 
 3636    long elapsed_seconds;
 
 3654    if (!snapshot_str) {
 
 3658    if (all_variables) {
 
 3663    if (!variable_str) {
 
 3672    for (i = 0; i < varc; i++) {
 
 3673        char valbuf[512], *ret = 
NULL;
 
 3675        if (vars[i][strlen(vars[i]) - 1] == 
')') {
 
 3676            if (
ast_func_read(chan, vars[i], valbuf, 
sizeof(valbuf)) < 0) {
 
 3684        ast_str_append(&variable_str, 0, 
"Variable: %s=%s\r\n", vars[i], ret);
 
 3688    if (all_variables) {
 
 3702        "Privilege: Call\r\n" 
 3706        "EffectiveConnectedLineNum: %s\r\n" 
 3707        "EffectiveConnectedLineName: %s\r\n" 
 3708        "TimeToHangup: %ld\r\n" 
 3710        "Application: %s\r\n" 
 3712        "Nativeformats: %s\r\n" 
 3713        "Readformat: %s\r\n" 
 3715        "Writeformat: %s\r\n" 
 3716        "Writetrans: %s\r\n" 
 3717        "Callgroup: %llu\r\n" 
 3718        "Pickupgroup: %llu\r\n" 
 3739        (long)elapsed_seconds,
 
 
 3753    int all_variables = 0;
 
 3766        all_variables = 
ast_true(all_chan_variables);
 
 3791        snprintf(id_text, 
sizeof(id_text), 
"ActionID: %s\r\n", 
id);
 
 
 3843    obj_size = payload_size + 
sizeof(*obj);
 
 3852    memcpy(obj->
payload, payload, payload_size);
 
 
 3886    const char *content_type)
 
 
 3989    if (sscanf(
priority, 
"%30d", &pi) != 1) {
 
 4007        if (sscanf(priority2, 
"%30d", &pi2) != 1) {
 
 4018        snprintf(
buf, 
sizeof(
buf), 
"Channel does not exist: %s", 
name);
 
 4042        snprintf(
buf, 
sizeof(
buf), 
"ExtraChannel does not exist: %s", name2);
 
 
 4219    if (!feature_code) {
 
 
 4241    char *cmd_copy, *cur_cmd;
 
 4253        cmd_words[i] = cur_cmd;
 
 
 4278    char *
buf = 
NULL, *final_buf = 
NULL, *delim, *output;
 
 4279    char template[] = 
"/tmp/ast-ami-XXXXXX";    
 
 4293    if ((fd = mkstemp(
template)) < 0) {
 
 4302    if ((
len = lseek(fd, 0, SEEK_END)) < 0) {
 
 4303        astman_append(s, 
"Message: Failed to determine number of characters: %s\r\n", strerror(
errno));
 
 4304        goto action_command_cleanup;
 
 4311    if (!
buf || !final_buf) {
 
 4313        goto action_command_cleanup;
 
 4316    if (lseek(fd, 0, SEEK_SET) < 0) {
 
 4317        astman_append(s, 
"Message: Failed to set position on temporary file: %s\r\n", strerror(
errno));
 
 4318        goto action_command_cleanup;
 
 4321    if (read(fd, 
buf, 
len) < 0) {
 
 4322        astman_append(s, 
"Message: Failed to read from temporary file: %s\r\n", strerror(
errno));
 
 4323        goto action_command_cleanup;
 
 4328    final_buf[
len] = 
'\0';
 
 4331    if (
len && final_buf[
len - 1] == 
'\n') {
 
 4332        final_buf[
len - 1] = 
'\0';
 
 4338    while ((output = 
strsep(&delim, 
"\n"))) {
 
 4342action_command_cleanup:
 
 
 4400        .uniqueid2 = 
in->otherchannelid
 
 4405            in->timeout, 
in->app, 
in->appdata, &reason,
 
 4409            in->vars, 
in->account, &chan, &assignedids);
 
 4412            in->timeout, 
in->context, 
in->exten, 
in->priority, &reason,
 
 4416            in->vars, 
in->account, &chan, 
in->early_media, &assignedids);
 
 4429            "Application: %s\r\n" 
 4433            "CallerIDNum: %s\r\n" 
 4434            "CallerIDName: %s\r\n",
 
 4435            in->idtext, res ? 
"Failure" : 
"Success",
 
 4437            in->app, 
in->appdata, reason,
 
 4439            S_OR(
in->cid_num, 
"<unknown>"),
 
 4440            S_OR(
in->cid_name, 
"<unknown>")
 
 4451            "CallerIDNum: %s\r\n" 
 4452            "CallerIDName: %s\r\n",
 
 4453            in->idtext, res ? 
"Failure" : 
"Success",
 
 4455            in->context, 
in->exten, reason,
 
 4457            S_OR(
in->cid_num, 
"<unknown>"),
 
 4458            S_OR(
in->cid_name, 
"<unknown>")
 
 
 4473    const char *unitamount;
 
 4474    const char *unittype;
 
 4477    memset(entry, 0, 
sizeof(*entry));
 
 
 4506    const char *association_num = 
astman_get_header(m, 
"ChargingAssociationNumber");
 
 4514    unsigned int _currencyamount = 0;
 
 4515    int _association_id = 0;
 
 4516    unsigned int _association_plan = 0;
 
 4522        goto aocmessage_cleanup;
 
 4527    if (!strcasecmp(chargetype, 
"NA")) {
 
 4529    } 
else if (!strcasecmp(chargetype, 
"Free")) {
 
 4531    } 
else if (!strcasecmp(chargetype, 
"Currency")) {
 
 4533    } 
else if (!strcasecmp(chargetype, 
"Unit")) {
 
 4537        goto aocmessage_cleanup;
 
 4542        if (
ast_strlen_zero(currencyamount) || (sscanf(currencyamount, 
"%30u", &_currencyamount) != 1)) {
 
 4543            astman_send_error(s, m, 
"Invalid CurrencyAmount, CurrencyAmount is a required when ChargeType is Currency");
 
 4544            goto aocmessage_cleanup;
 
 4548            astman_send_error(s, m, 
"ChargeMultiplier unspecified, ChargeMultiplier is required when ChargeType is Currency.");
 
 4549            goto aocmessage_cleanup;
 
 4550        } 
else if (!strcasecmp(mult, 
"onethousandth")) {
 
 4552        } 
else if (!strcasecmp(mult, 
"onehundredth")) {
 
 4554        } 
else if (!strcasecmp(mult, 
"onetenth")) {
 
 4556        } 
else if (!strcasecmp(mult, 
"one")) {
 
 4558        } 
else if (!strcasecmp(mult, 
"ten")) {
 
 4560        } 
else if (!strcasecmp(mult, 
"hundred")) {
 
 4562        } 
else if (!strcasecmp(mult, 
"thousand")) {
 
 4566            goto aocmessage_cleanup;
 
 4573            goto aocmessage_cleanup;
 
 4577        if (!
ast_strlen_zero(totaltype) && !strcasecmp(totaltype, 
"subtotal")) {
 
 4583        } 
else if (!strcasecmp(aocbillingid, 
"Normal")) {
 
 4585        } 
else if (!strcasecmp(aocbillingid, 
"ReverseCharge")) {
 
 4587        } 
else if (!strcasecmp(aocbillingid, 
"CreditCard")) {
 
 4591            goto aocmessage_cleanup;
 
 4596        } 
else if (!strcasecmp(aocbillingid, 
"Normal")) {
 
 4598        } 
else if (!strcasecmp(aocbillingid, 
"ReverseCharge")) {
 
 4600        } 
else if (!strcasecmp(aocbillingid, 
"CreditCard")) {
 
 4602        } 
else if (!strcasecmp(aocbillingid, 
"CallFwdUnconditional")) {
 
 4604        } 
else if (!strcasecmp(aocbillingid, 
"CallFwdBusy")) {
 
 4606        } 
else if (!strcasecmp(aocbillingid, 
"CallFwdNoReply")) {
 
 4608        } 
else if (!strcasecmp(aocbillingid, 
"CallDeflection")) {
 
 4610        } 
else if (!strcasecmp(aocbillingid, 
"CallTransfer")) {
 
 4614            goto aocmessage_cleanup;
 
 4617        if (!
ast_strlen_zero(association_id) && (sscanf(association_id, 
"%30d", &_association_id) != 1)) {
 
 4619            goto aocmessage_cleanup;
 
 4621        if (!
ast_strlen_zero(association_plan) && (sscanf(association_plan, 
"%30u", &_association_plan) != 1)) {
 
 4623            goto aocmessage_cleanup;
 
 4626        if (_association_id) {
 
 4640        for (i = 0; i < 32; i++) {
 
 4650            astman_send_error(s, m, 
"Invalid UnitAmount(0), At least one valid unit entry is required when ChargeType is set to Unit");
 
 4651            goto aocmessage_cleanup;
 
 
 4686    unsigned int _currencyamount = 0;
 
 4688    unsigned int _time = 0;
 
 4690    unsigned int _granularity = 0;
 
 4697        goto aocmessage_cleanup;
 
 4702        goto aocmessage_cleanup;
 
 4705    if (!strcasecmp(chargeditem, 
"NA")) {
 
 4707    } 
else if (!strcasecmp(chargeditem, 
"SpecialArrangement")) {
 
 4709    } 
else if (!strcasecmp(chargeditem, 
"BasicCommunication")) {
 
 4711    } 
else if (!strcasecmp(chargeditem, 
"CallAttempt")) {
 
 4713    } 
else if (!strcasecmp(chargeditem, 
"CallSetup")) {
 
 4715    } 
else if (!strcasecmp(chargeditem, 
"UserUserInfo")) {
 
 4717    } 
else if (!strcasecmp(chargeditem, 
"SupplementaryService")) {
 
 4721        goto aocmessage_cleanup;
 
 4724    if (!strcasecmp(ratetype, 
"NA")) {
 
 4726    } 
else if (!strcasecmp(ratetype, 
"Free")) {
 
 4728    } 
else if (!strcasecmp(ratetype, 
"FreeFromBeginning")) {
 
 4730    } 
else if (!strcasecmp(ratetype, 
"Duration")) {
 
 4732    } 
else if (!strcasecmp(ratetype, 
"Flat")) {
 
 4734    } 
else if (!strcasecmp(ratetype, 
"Volume")) {
 
 4736    } 
else if (!strcasecmp(ratetype, 
"SpecialCode")) {
 
 4740        goto aocmessage_cleanup;
 
 4744        if (
ast_strlen_zero(currencyamount) || (sscanf(currencyamount, 
"%30u",
 
 4745                &_currencyamount) != 1)) {
 
 4746            astman_send_error(s, m, 
"Invalid CurrencyAmount, CurrencyAmount is a required when RateType is non-free");
 
 4747            goto aocmessage_cleanup;
 
 4751            astman_send_error(s, m, 
"ChargeMultiplier unspecified, ChargeMultiplier is required when ChargeType is Currency.");
 
 4752            goto aocmessage_cleanup;
 
 4753        } 
else if (!strcasecmp(mult, 
"onethousandth")) {
 
 4755        } 
else if (!strcasecmp(mult, 
"onehundredth")) {
 
 4757        } 
else if (!strcasecmp(mult, 
"onetenth")) {
 
 4759        } 
else if (!strcasecmp(mult, 
"one")) {
 
 4761        } 
else if (!strcasecmp(mult, 
"ten")) {
 
 4763        } 
else if (!strcasecmp(mult, 
"hundred")) {
 
 4765        } 
else if (!strcasecmp(mult, 
"thousand")) {
 
 4769            goto aocmessage_cleanup;
 
 4775            astman_send_error(s, m, 
"TimeScale unspecified, TimeScale is required when RateType is Duration.");
 
 4776            goto aocmessage_cleanup;
 
 4777        } 
else if (!strcasecmp(timescale, 
"onehundredthsecond")) {
 
 4779        } 
else if (!strcasecmp(timescale, 
"onetenthsecond")) {
 
 4781        } 
else if (!strcasecmp(timescale, 
"second")) {
 
 4783        } 
else if (!strcasecmp(timescale, 
"tenseconds")) {
 
 4785        } 
else if (!strcasecmp(timescale, 
"minute")) {
 
 4787        } 
else if (!strcasecmp(timescale, 
"hour")) {
 
 4789        } 
else if (!strcasecmp(timescale, 
"day")) {
 
 4793            goto aocmessage_cleanup;
 
 4797            astman_send_error(s, m, 
"Invalid Time, Time is a required when RateType is Duration");
 
 4798            goto aocmessage_cleanup;
 
 4802            if ((sscanf(time, 
"%30u", &_granularity) != 1)) {
 
 4804                goto aocmessage_cleanup;
 
 4808                astman_send_error(s, m, 
"Invalid GranularityTimeScale, GranularityTimeScale is a required when Granularity is specified");
 
 4809            } 
else if (!strcasecmp(granularitytimescale, 
"onehundredthsecond")) {
 
 4811            } 
else if (!strcasecmp(granularitytimescale, 
"onetenthsecond")) {
 
 4813            } 
else if (!strcasecmp(granularitytimescale, 
"second")) {
 
 4815            } 
else if (!strcasecmp(granularitytimescale, 
"tenseconds")) {
 
 4817            } 
else if (!strcasecmp(granularitytimescale, 
"minute")) {
 
 4819            } 
else if (!strcasecmp(granularitytimescale, 
"hour")) {
 
 4821            } 
else if (!strcasecmp(granularitytimescale, 
"day")) {
 
 4825                goto aocmessage_cleanup;
 
 4829        if (
ast_strlen_zero(chargingtype) || strcasecmp(chargingtype, 
"continuouscharging") == 0) {
 
 4831        } 
else if (strcasecmp(chargingtype, 
"stepfunction") == 0 ) {
 
 4835            goto aocmessage_cleanup;
 
 4841            astman_send_error(s, m, 
"VolumeUnit unspecified, VolumeUnit is required when RateType is Volume.");
 
 4842            goto aocmessage_cleanup;
 
 4843        } 
else if (!strcasecmp(timescale, 
"octet")) {
 
 4845        } 
else if (!strcasecmp(timescale, 
"segment")) {
 
 4847        } 
else if (!strcasecmp(timescale, 
"message")) {
 
 4851            goto aocmessage_cleanup;
 
 4858            astman_send_error(s, m, 
"Invalid Code, Code is a required when ChargedItem is SpecialArrangement and when RateType is SpecialCode");
 
 4859            goto aocmessage_cleanup;
 
 4867            currencyname, _time, _scale, _granularity, _granularity_time_scale, _step);
 
 4873            _mult, currencyname);
 
 
 4897    static const char hdr[] = 
"ChargedItem:";
 
 4903        goto aocmessage_cleanup;
 
 4906    hdrlen = strlen(hdr);
 
 4907    for (x = 0; x < m->
hdrcount; x++) {
 
 4908        if (strncasecmp(hdr, m->
headers[x], hdrlen) == 0) {
 
 4911                    goto aocmessage_cleanup;
 
 4922            goto aocmessage_cleanup;
 
 
 4944    size_t encoded_size = 0;
 
 4947        astman_send_error(s, m, 
"Channel and PartialChannel are not specified. Specify at least one of these.");
 
 4948        goto aocmessage_cleanup;
 
 4957        goto aocmessage_cleanup;
 
 4960    if (strcasecmp(msgtype, 
"d") == 0 || strcasecmp(msgtype, 
"e") == 0) {
 
 4963    else if (strcasecmp(msgtype, 
"s") == 0) {
 
 4968        goto aocmessage_cleanup;
 
 4972        goto aocmessage_cleanup;
 
 4979        astman_send_error(s, m, 
"Error encoding AOC message, could not queue onto channel");
 
 
 4996    int (*searchfn)(
const char *
app, 
const char *data, 
const char *search);
 
 
 5033    return !!(strstr(data, search));
 
 
 5135#ifdef TEST_FRAMEWORK 
 5136#define ALL_PERMISSIONS (INT_MAX) 
 5137#define NO_PERMISSIONS (0) 
 5144        info->name = 
"originate_permissions_test";
 
 5145        info->category = 
"/main/manager/";
 
 5146        info->summary = 
"Test permissions for originate action";
 
 5148            "Make sure that dialplan apps/functions that need special " 
 5149            "permissions are prohibited if the user doesn't have the permission.";
 
 5165        NULL, ALL_PERMISSIONS), 
"exec check permission failed");
 
 5171        NULL, NO_PERMISSIONS), 
"exec permission check failed");
 
 5182        NULL, NO_PERMISSIONS), 
"Queue permission check failed");
 
 5184        "somequeue,CcdHh,someURL,tt-monkeys,100,,gosub,rule,666",
 
 5189        "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
 
 5192        "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
 
 5195        "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
 
 5196        ALL_PERMISSIONS), 
"Queue permission check failed");
 
 5200        "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
 
 5201        NO_PERMISSIONS), 
"Queue permission check failed");
 
 5203        "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
 
 5212        "aaa DB bbb", ALL_PERMISSIONS), 
"exec permission check failed");
 
 5214        "aaaDBbbb", NO_PERMISSIONS), 
"exec permission check failed");
 
 5216        "aaa DB bbb", NO_PERMISSIONS), 
"exec permission check failed");
 
 5219        "aaa db bbb", NO_PERMISSIONS), 
"exec permission check failed");
 
 5223#undef ALL_PERMISSIONS 
 5224#undef NO_PERMISSIONS 
 5259    int bridge_early = 0;
 
 5272        goto fast_orig_cleanup;
 
 5278        goto fast_orig_cleanup;
 
 5284            goto fast_orig_cleanup;
 
 5287    if (!
ast_strlen_zero(timeout) && (sscanf(timeout, 
"%30d", &to) != 1)) {
 
 5290        goto fast_orig_cleanup;
 
 5294    data = strchr(tmp, 
'/');
 
 5298        goto fast_orig_cleanup;
 
 5323            goto fast_orig_cleanup;
 
 5328    if (exten && context && pi) {
 
 5333            goto fast_orig_cleanup;
 
 5348            for (v = vars; v->
next; v = v->
next );
 
 5354    bridge_early = 
ast_true(early_media);
 
 5398        if (exten && context && pi) {
 
 5401                    l, n, vars, account, 
NULL, bridge_early,
 
 5405            astman_send_error(s, m, 
"Originate with 'Exten' requires 'Context' and 'Priority'");
 
 5408            goto fast_orig_cleanup;
 
 
 5435             "Waiting: %d\r\n\r\n", mailbox, ret);
 
 
 5442    int newmsgs = 0, oldmsgs = 0, urgentmsgs = 0;;
 
 5452               "UrgMessages: %d\r\n" 
 5453               "NewMessages: %d\r\n" 
 5454               "OldMessages: %d\r\n" 
 5456               mailbox, urgentmsgs, newmsgs, oldmsgs);
 
 
 5472        context = 
"default";
 
 5483        "StatusText: %s\r\n" 
 5485        exten, context, hint, 
status,
 
 
 5522                         "PresenceMessage: %s\r\n",
 
 
 5538    struct timeval when = { timeout, 0 };
 
 5545    if (!timeout || timeout < 0) {
 
 5555    when.tv_usec = (timeout - when.tv_sec) * 1000000.0;
 
 
 5599    char *line_buffer_start = 
NULL;
 
 5600    char *line_buffer = 
NULL;
 
 5619    line_buffer = line_buffer_start;
 
 5620    if (!line_buffer_start) {
 
 5634                line_buffer_start = 
NULL;
 
 
 5692    if (!strcasecmp(operation, 
"Add")) {
 
 5700            S_COR(have_match, 
"(", 
""), 
S_OR(match_criteria, 
""),
 
 5701            S_COR(have_match, 
")", 
""));
 
 5703            astman_send_error(s, m, 
"Internal Error. Failed to allocate storage for filter type");
 
 5715                    "Filter did not compile.  Check the syntax of the filter given.");
 
 5719                    "Filter was formatted incorrectly.  Check the syntax of the filter given.");
 
 
 5753    const char *criteria, 
const char *filter_pattern,
 
 5759    char *options_start = 
NULL;
 
 5760    SCOPE_ENTER(3, 
"manager_add_filter(%s, %s, %p, %p)", criteria, filter_pattern, includefilters, excludefilters);
 
 5762    if (!filter_entry) {
 
 5777    if (!filter_pattern) {
 
 5787    if (filter_pattern[0] == 
'!') {
 
 5788        filter_entry->is_excludefilter = 1;
 
 5800    options_start = strstr(criteria, 
"(");
 
 5807            "'%s = %s': Legacy filter with no filter pattern specified\n",
 
 5808            criteria, filter_pattern);
 
 5811    if (options_start) {
 
 5816        char *saveptr = 
NULL;
 
 5817        char *option = 
NULL;
 
 5818        enum found_options {
 
 5819            action_found = (1 << 0),
 
 5820            name_found = (1 << 1),
 
 5821            header_found = (1 << 2),
 
 5822            method_found = (1 << 3),
 
 5824        enum found_options options_found = 0;
 
 5831                "'%s = %s': Filter options not formatted correctly\n",
 
 5832                criteria, filter_pattern);
 
 5840        while ((option = strtok_r(temp, 
" ,)", &saveptr))) {
 
 5841            if (!strncmp(option, 
"action", 6)) {
 
 5842                char *
method = strstr(option, 
"(");
 
 5845                        criteria, filter_pattern);
 
 5849                if (!strcmp(
method, 
"include")) {
 
 5850                    filter_entry->is_excludefilter = 0;
 
 5851                } 
else if (!strcmp(
method, 
"exclude")) {
 
 5852                    filter_entry->is_excludefilter = 1;
 
 5855                        criteria, filter_pattern, 
method);
 
 5857                options_found |= action_found;
 
 5858            } 
else if (!strncmp(option, 
"name", 4)) {
 
 5859                char *event_name = strstr(option, 
"(");
 
 5864                        criteria, filter_pattern);
 
 5866                filter_entry->event_name = 
ast_strdup(event_name);
 
 5867                filter_entry->event_name_hash = 
ast_str_hash(event_name);
 
 5868                options_found |= name_found;
 
 5869            } 
else if (!strncmp(option, 
"header", 6)) {
 
 5870                char *header_name = strstr(option, 
"(");
 
 5875                        criteria, filter_pattern);
 
 5878                    filter_entry->header_name = 
ast_malloc(strlen(header_name) + 2);
 
 5879                    if (!filter_entry->header_name) {
 
 5882                    sprintf(filter_entry->header_name, 
"%s:", header_name); 
 
 5884                    filter_entry->header_name = 
ast_strdup(header_name);
 
 5886                options_found |= header_found;
 
 5887            } 
else if (!strncmp(option, 
"method", 6)) {
 
 5888                char *
method = strstr(option, 
"(");
 
 5893                        criteria, filter_pattern);
 
 5895                if (!strcmp(
method, 
"regex")) {
 
 5897                } 
else if (!strcmp(
method, 
"exact")) {
 
 5899                } 
else if (!strcmp(
method, 
"starts_with")) {
 
 5901                } 
else if (!strcmp(
method, 
"ends_with")) {
 
 5903                } 
else if (!strcmp(
method, 
"contains")) {
 
 5905                } 
else if (!strcmp(
method, 
"none")) {
 
 5909                        criteria, filter_pattern, 
method);
 
 5911                options_found |= method_found;
 
 5914                    criteria, filter_pattern, option);
 
 5918        if (!options_found) {
 
 5920                "'%s = %s': No action, name, header, or method option found\n",
 
 5921                criteria, filter_pattern);
 
 5925                "'%s = %s': method can't be '%s' with no filter pattern\n",
 
 5930                "'%s = %s': method can't be 'none' with a filter pattern\n",
 
 5931                criteria, filter_pattern);
 
 5933        if (!(options_found & name_found) && !(options_found & header_found) &&
 
 5936                "'%s = %s': No name or header option found and no filter pattern\n",
 
 5937                criteria, filter_pattern);
 
 5943            filter_entry->regex_filter = 
ast_calloc(1, 
sizeof(regex_t));
 
 5944            if (!filter_entry->regex_filter) {
 
 5947            if (regcomp(filter_entry->regex_filter, filter_pattern, REG_EXTENDED | REG_NOSUB)) {
 
 5951            filter_entry->string_filter = 
ast_strdup(filter_pattern);
 
 5956        "conf entry: %s = %s\n" 
 5957        "event_name: %s (hash: %d)\n" 
 5960        "regex_filter: %p\n" 
 5961        "string filter: %s\n" 
 5962        "is excludefilter: %d\n",
 
 5963        criteria, filter_pattern,
 
 5964        S_OR(filter_entry->event_name, 
"<not used>"),
 
 5965        filter_entry->event_name_hash,
 
 5966        S_OR(filter_entry->header_name, 
"<not used>"),
 
 5968        filter_entry->regex_filter,
 
 5969        filter_entry->string_filter,
 
 5970        filter_entry->is_excludefilter);
 
 5972    if (filter_entry->is_excludefilter) {
 
 5973        ao2_t_link(excludefilters, filter_entry, 
"link new filter into exclude user container");
 
 5975        ao2_t_link(includefilters, filter_entry, 
"link new filter into include user container");
 
 
 5981#ifdef TEST_FRAMEWORK 
 5983struct test_filter_data {
 
 5984    const char *criteria;
 
 5988    const char *test_event_name;
 
 5989    const char *test_event_payload;
 
 5990    int expected_should_send_event;
 
 5993static char *add_filter_result_enums[] = {
 
 6000#define TEST_EVENT_NEWCHANNEL "Newchannel", "Event: Newchannel\r\nChannel: XXX\r\nSomeheader: YYY\r\n" 
 6001#define TEST_EVENT_VARSET "VarSet", "Event: VarSet\r\nChannel: ABC\r\nSomeheader: XXX\r\n" 
 6002#define TEST_EVENT_NONE "", "" 
 6004static struct test_filter_data parsing_filter_tests[] = {
 
 6012    { 
"eventfilter(name(Newchannel),method(regex))", 
"X[XYZ]X", 
FILTER_SUCCESS,
 
 6014    { 
"eventfilter(name(Newchannel),method(regex))", 
"X[abc]X", 
FILTER_SUCCESS,
 
 6016    { 
"eventfilter(action(exclude),name(Newchannel),method(regex))", 
"X[XYZ]X", 
FILTER_SUCCESS,
 
 6018    { 
"eventfilter(action(exclude),name(Newchannel),method(regex))", 
"X[abc]X", 
FILTER_SUCCESS,
 
 6020    { 
"eventfilter(action(include),name(VarSet),header(Channel),method(starts_with))", 
"AB", 
FILTER_SUCCESS,
 
 6022    { 
"eventfilter(action(include),name(VarSet),header(Channel),method(ends_with))", 
"BC", 
FILTER_SUCCESS,
 
 6024    { 
"eventfilter(action(include),name(VarSet),header(Channel),method(exact))", 
"ABC", 
FILTER_SUCCESS,
 
 6026    { 
"eventfilter(action(include),name(VarSet),header(Channel),method(exact))", 
"XXX", 
FILTER_SUCCESS,
 
 6028    { 
"eventfilter(name(VarSet),header(Channel),method(exact))", 
"!ZZZ", 
FILTER_SUCCESS,
 
 6030    { 
"eventfilter(action(exclude),name(VarSet),header(Channel),method(exact))", 
"ZZZ", 
FILTER_SUCCESS,
 
 6032    { 
"eventfilter(action(include),name(VarSet),header(Someheader),method(exact))", 
"!XXX", 
FILTER_SUCCESS,
 
 6041    { 
"eventfilter(nnnn(yyy),header(VarSet),method(contains)", 
"XXX", 
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
 
 6042    { 
"eventfilter(name(yyy),heder(VarSet),method(contains)", 
"XXX", 
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
 
 6043    { 
"eventfilter(name(yyy),header(VarSet),mehod(contains)", 
"XXX", 
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
 
 6044    { 
"eventfilter(name(yyy),header(VarSet),method(coains)", 
"XXX", 
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
 
 6057static int strings_equal(
const char *str1, 
const char *str2)
 
 6059    if ((!str1 && str2) || (str1 && !str2)) {
 
 6063    return str1 == str2 || !strcmp(str1, str2);
 
 6075        info->name = 
"eventfilter_test_creation";
 
 6076        info->category = 
"/main/manager/";
 
 6077        info->summary = 
"Test eventfilter creation";
 
 6079            "This creates various eventfilters and tests to make sure they were created successfully.";
 
 6087    if (!includefilters || !excludefilters) {
 
 6092    for (i = 0; i < 
ARRAY_LEN(parsing_filter_tests); i++) {
 
 6097        int include_container_count = 0;
 
 6098        int exclude_container_count = 0;
 
 6105            includefilters, excludefilters);
 
 6110            parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
 
 6111            add_filter_result_enums[parsing_filter_tests[i].expected_add_filter_result],
 
 6112            add_filter_result_enums[add_filter_res],
 
 6113            add_filter_res != parsing_filter_tests[i].expected_add_filter_result ? 
"FAIL" : 
"PASS");
 
 6116        if (add_filter_res != parsing_filter_tests[i].expected_add_filter_result) {
 
 6118                "Unexpected add filter result '%s = %s'. Expected result: %s Actual result: %s\n",
 
 6119                parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
 
 6120                add_filter_result_enums[parsing_filter_tests[i].expected_add_filter_result],
 
 6121                add_filter_result_enums[add_filter_res]);
 
 6126        if (parsing_filter_tests[i].expected_add_filter_result != 
FILTER_SUCCESS) {
 
 6135        if (parsing_filter_tests[i].expected_filter_entry.event_name) {
 
 6136            parsing_filter_tests[i].expected_filter_entry.event_name_hash =
 
 6137                ast_str_hash(parsing_filter_tests[i].expected_filter_entry.event_name);
 
 6143        if (parsing_filter_tests[i].expected_filter_entry.is_excludefilter) {
 
 6144            if (exclude_container_count != 1 || include_container_count != 0) {
 
 6146                    "Invalid container counts for exclude filter '%s = %s'. Exclude: %d Include: %d.  Should be 1 and 0\n",
 
 6147                    parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
 
 6148                    exclude_container_count, include_container_count);
 
 6155            if (include_container_count != 1 || exclude_container_count != 0) {
 
 6157                    "Invalid container counts for include filter '%s = %s'. Include: %d Exclude: %d.  Should be 1 and 0\n",
 
 6158                    parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
 
 6159                    include_container_count, exclude_container_count);
 
 6167        if (!filter_entry) {
 
 6169                "Failed to find filter entry for '%s = %s' in %s filter container\n",
 
 6170                parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
 
 6171                parsing_filter_tests[i].expected_filter_entry.is_excludefilter ? 
"exclude" : 
"include");
 
 6176        if (filter_entry->
match_type != parsing_filter_tests[i].expected_filter_entry.match_type) {
 
 6178                "Failed to match filter type for '%s = %s'. Expected: %s Actual: %s\n",
 
 6179                parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
 
 6180                match_type_names[parsing_filter_tests[i].expected_filter_entry.match_type],
 
 6186        if (!strings_equal(filter_entry->
event_name, parsing_filter_tests[i].expected_filter_entry.event_name)) {
 
 6188                "Failed to match event name for '%s = %s'. Expected: '%s' Actual: '%s'\n",
 
 6189                parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
 
 6190                parsing_filter_tests[i].expected_filter_entry.event_name, filter_entry->
event_name);
 
 6195        if (filter_entry->
event_name_hash != parsing_filter_tests[i].expected_filter_entry.event_name_hash) {
 
 6197                "Event name hashes failed to match for '%s = %s'. Expected: %u Actual: %u\n",
 
 6198                parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
 
 6199                parsing_filter_tests[i].expected_filter_entry.event_name_hash, filter_entry->
event_name_hash);
 
 6204        if (!strings_equal(filter_entry->
header_name, parsing_filter_tests[i].expected_filter_entry.header_name)) {
 
 6206                "Failed to match header name for '%s = %s'. Expected: '%s' Actual: '%s'\n",
 
 6207                parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
 
 6208                parsing_filter_tests[i].expected_filter_entry.header_name, filter_entry->
header_name);
 
 6213        switch (parsing_filter_tests[i].expected_filter_entry.match_type) {
 
 6217                    "Failed to compile regex filter for '%s = %s'\n",
 
 6218                    parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter);
 
 6226                    "Unexpected regex filter or string for '%s = %s' with match_type 'none'\n",
 
 6227                    parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter);
 
 6238                    "Unexpected regex filter or empty string for '%s = %s' with match_type '%s'\n",
 
 6239                    parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
 
 6240                    match_type_names[parsing_filter_tests[i].expected_filter_entry.match_type]);
 
 6253        eqe = 
ast_calloc(1, 
sizeof(*eqe) + strlen(parsing_filter_tests[i].test_event_payload) + 1);
 
 6260        strcpy(eqe->
eventdata, parsing_filter_tests[i].test_event_payload); 
 
 6263        if (send_event != parsing_filter_tests[i].expected_should_send_event) {
 
 6266                "Should send event failed to match for '%s = %s' payload '%s'. Expected: %s Actual: %s\n",
 
 6267                parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter, escaped,
 
 6268                AST_YESNO(parsing_filter_tests[i].expected_should_send_event), 
AST_YESNO(send_event));
 
 6282struct test_filter_matching {
 
 6283    const char *criteria;
 
 6284    const char *pattern;
 
 6300static struct test_filter_matching filters_for_matching[] = {
 
 6301    { 
"eventfilter(name(VarSet),method(none))", 
""},
 
 6302    { 
"eventfilter(name(Newchannel),method(regex))", 
"X[XYZ]X"},
 
 6303    { 
"eventfilter(name(Newchannel),method(regex))", 
"X[abc]X"},
 
 6304    { 
"eventfilter(name(Newchannel),header(Someheader),method(regex))", 
"ZZZ"},
 
 6305    { 
"eventfilter(action(exclude),name(Newchannel),method(regex))", 
"X[a]X"},
 
 6306    { 
"eventfilter(action(exclude),name(Newchannel),method(regex))", 
"X[Z]X"},
 
 6307    { 
"eventfilter(action(exclude),name(VarSet),header(Channel),method(regex))", 
"YYY"},
 
 6310struct test_event_matching{
 
 6311    const char *event_name;
 
 6312    const char *payload;
 
 6313    int expected_should_send_event;
 
 6316static struct test_event_matching events_for_matching[] = {
 
 6317    { 
"Newchannel", 
"Event: Newchannel\r\nChannel: XXX\r\nSomeheader: YYY\r\n", 1 },
 
 6318    { 
"Newchannel", 
"Event: Newchannel\r\nChannel: XZX\r\nSomeheader: YYY\r\n", 0 },
 
 6319    { 
"Newchannel", 
"Event: Newchannel\r\nChannel: XaX\r\nSomeheader: YYY\r\n", 0 },
 
 6320    { 
"Newchannel", 
"Event: Newchannel\r\nChannel: XbX\r\nSomeheader: YYY\r\n", 1 },
 
 6321    { 
"Newchannel", 
"Event: Newchannel\r\nChannel: XcX\r\nSomeheader: YYY\r\n", 1 },
 
 6322    { 
"Newchannel", 
"Event: Newchannel\r\nChannel: YYY\r\nSomeheader: YYY\r\n", 0 },
 
 6323    { 
"Newchannel", 
"Event: Newchannel\r\nChannel: YYY\r\nSomeheader: ZZZ\r\n", 1 },
 
 6324    { 
"VarSet", 
"Event: VarSet\r\nChannel: XXX\r\nSomeheader: YYY\r\n", 1 },
 
 6325    { 
"VarSet", 
"Event: VarSet\r\nChannel: YYY\r\nSomeheader: YYY\r\n", 0 },
 
 6337        info->name = 
"eventfilter_test_matching";
 
 6338        info->category = 
"/main/manager/";
 
 6339        info->summary = 
"Test eventfilter matching";
 
 6341            "This creates various eventfilters and tests to make sure they were matched successfully.";
 
 6349    if (!includefilters || !excludefilters) {
 
 6355    for (i = 0; i < 
ARRAY_LEN(filters_for_matching); i++) {
 
 6359            filters_for_matching[i].pattern, includefilters, excludefilters);
 
 6363                "Unexpected add filter result '%s = %s'. Expected result: %s Actual result: %s\n",
 
 6364                parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
 
 6366                add_filter_result_enums[add_filter_res]);
 
 6378    for (i = 0; i < 
ARRAY_LEN(events_for_matching); i++) {
 
 6382        eqe = 
ast_calloc(1, 
sizeof(*eqe) + strlen(events_for_matching[i].payload) + 1);
 
 6388        strcpy(eqe->
eventdata, events_for_matching[i].payload); 
 
 6391        if (send_event != events_for_matching[i].expected_should_send_event) {
 
 6394                "Should send event failed to match for '%s'. Expected: %s Actual: %s\n",
 
 6396                AST_YESNO(events_for_matching[i].expected_should_send_event), 
AST_YESNO(send_event));
 
 6423                ast_debug(3, 
"Received CloseSession event\n");
 
 
 6449    for (x = 0; x < m->
hdrcount; x++) {
 
 6450        if (strncasecmp(
"UserEvent:", m->
headers[x], strlen(
"UserEvent:")) &&
 
 6451                strncasecmp(
"Action:", m->
headers[x], strlen(
"Action:"))) {
 
 
 6468        snprintf(idText, 
sizeof(idText), 
"ActionID: %s\r\n", actionid);
 
 6475            "AMIversion: %s\r\n" 
 6476            "AsteriskVersion: %s\r\n" 
 6477            "SystemName: %s\r\n" 
 6478            "CoreMaxCalls: %d\r\n" 
 6479            "CoreMaxLoadAvg: %f\r\n" 
 6480            "CoreRunUser: %s\r\n" 
 6481            "CoreRunGroup: %s\r\n" 
 6482            "CoreMaxFilehandles: %d\r\n" 
 6483            "CoreRealTimeEnabled: %s\r\n" 
 6484            "CoreCDRenabled: %s\r\n" 
 6485            "CoreHTTPenabled: %s\r\n" 
 6486            "SoundsSearchCustomDir: %s\r\n" 
 
 6510    char startuptime[150], startupdate[150];
 
 6511    char reloadtime[150], reloaddate[150];
 
 6515        snprintf(idText, 
sizeof(idText), 
"ActionID: %s\r\n", actionid);
 
 6521    ast_strftime(startuptime, 
sizeof(startuptime), 
"%H:%M:%S", &tm);
 
 6522    ast_strftime(startupdate, 
sizeof(startupdate), 
"%Y-%m-%d", &tm);
 
 6524    ast_strftime(reloadtime, 
sizeof(reloadtime), 
"%H:%M:%S", &tm);
 
 6525    ast_strftime(reloaddate, 
sizeof(reloaddate), 
"%Y-%m-%d", &tm);
 
 6529            "CoreStartupDate: %s\r\n" 
 6530            "CoreStartupTime: %s\r\n" 
 6531            "CoreReloadDate: %s\r\n" 
 6532            "CoreReloadTime: %s\r\n" 
 6533            "CoreCurrentCalls: %d\r\n" 
 6534            "CoreProcessedCalls: %d\r\n" 
 
 6550    const char *
module = astman_get_header(m, "Module");
 
 
 6590        snprintf(idText, 
sizeof(idText), 
"ActionID: %s\r\n", actionid);
 
 6602        char durbuf[16] = 
"";
 
 6609            int duration, durh, durm, durs;
 
 6612            durh = duration / 3600;
 
 6613            durm = (duration % 3600) / 60;
 
 6614            durs = duration % 60;
 
 6615            snprintf(durbuf, 
sizeof(durbuf), 
"%02d:%02d:%02d", durh, durm, durs);
 
 6619            "Event: CoreShowChannel\r\n" 
 6622            "Application: %s\r\n" 
 6623            "ApplicationData: %s\r\n" 
 
 6669    char *current_channel_uid;
 
 6674        int add_channel_res;
 
 6678        if (!strcmp(current_channel_uid, channel_snapshot->
base->
uniqueid)) {
 
 6679            ao2_ref(current_channel_uid, -1);
 
 6684        if (!current_channel_snapshot) {
 
 6685            ast_debug(5, 
"Unable to get channel snapshot\n");
 
 6686            ao2_ref(current_channel_uid, -1);
 
 6691        if (add_channel_res) {
 
 6693            ao2_ref(current_channel_snapshot, -1);
 
 6694            ao2_ref(current_channel_uid, -1);
 
 6702            int size = strlen(current_channel_snapshot->
base->
name);
 
 6703            char other_local[size + 1];
 
 6708            other_local[size] = 
'\0';
 
 6711            if (!other_local_snapshot) {
 
 6712                ast_debug(5, 
"Unable to get other local channel snapshot\n");
 
 6713                ao2_ref(current_channel_snapshot, -1);
 
 6714                ao2_ref(current_channel_uid, -1);
 
 6720                ao2_ref(current_channel_snapshot, -1);
 
 6721                ao2_ref(current_channel_uid, -1);
 
 6722                ao2_ref(other_local_snapshot, -1);
 
 6727            if (other_bridge_snapshot) {
 
 6731            ao2_ref(current_channel_snapshot, -1);
 
 6732            ao2_ref(current_channel_uid, -1);
 
 6733            ao2_ref(other_local_snapshot, -1);
 
 6734            ao2_ref(other_bridge_snapshot, -1);
 
 
 6752    char *current_channel_name;
 
 6761        snprintf(id_text, 
sizeof(id_text), 
"ActionID: %s\r\n", actionid);
 
 6772    if (!channel_snapshot) {
 
 6785    if (!bridge_snapshot) {
 
 6809            "Event: CoreShowChannelMap\r\n" 
 6812            "ConnectedChannel: %s\r\n\r\n",
 
 6815            current_channel_name);
 
 
 6843    const char *
module = astman_get_header(m, "Module");
 
 6846    ast_debug(1, 
"**** ModuleCheck .so file %s\n", module);
 
 6858#if !defined(LOW_MEMORY) 
 
 6882    char *stripped_filename;
 
 6898    real_path = realpath(path, 
NULL);
 
 
 6909    const char *
module = astman_get_header(m, "Module");
 
 6913    if (!loadtype || strlen(loadtype) == 0) {
 
 6916    if ((!module || strlen(module) == 0) && strcasecmp(loadtype, 
"reload") != 0) {
 
 6924    } 
else if (res == -1) {
 
 6929    if (!strcasecmp(loadtype, 
"load")) {
 
 6936    } 
else if (!strcasecmp(loadtype, 
"unload")) {
 
 6943    } 
else if (!strcasecmp(loadtype, 
"refresh")) {
 
 6950    } 
else if (!strcasecmp(loadtype, 
"reload")) {
 
 6955            switch (reload_res) {
 
 
 7001    for (x = 0; x < m->
hdrcount; ++x) {
 
 7002        if (!strncasecmp(m->
headers[x], 
"Secret", 6)) {
 
 
 7031    const char *username;
 
 7046        ast_log(
LOG_ERROR, 
"Unable to process manager action '%s'. Asterisk is shutting down.\n", action);
 
 7054        && strcasecmp(action, 
"Login")
 
 7055        && strcasecmp(action, 
"Logoff")
 
 7056        && strcasecmp(action, 
"Challenge")) {
 
 7067        && (!strcasecmp(action, 
"Login")
 
 7068            || !strcasecmp(action, 
"Challenge"))) {
 
 7074            if (
user && !
user->allowmultiplelogin) {
 
 7101                if (mod_ref || !act_found->module) {
 
 7103                    ret = act_found->
func(s, m);
 
 7122        ao2_t_ref(act_found, -1, 
"done with found action object");
 
 7127        snprintf(
buf, 
sizeof(
buf), 
"Invalid/unknown command: %s. Use Action: ListCommands to show available commands.", action);
 
 
 7168        if (src[x] == 
'\r' && x+1 < s->
session->
inlen && src[x + 1] == 
'\n') {
 
 7170        } 
else if (src[x] == 
'\n') {
 
 7175        memmove(output, src, x);    
 
 7194            if(time(&now) == -1) {
 
 7223            ast_debug(1, 
"Manager session has been kicked\n");
 
 
 7294                if (time(&now) == -1) {
 
 7309        } 
else if (res > 0) {
 
 
 7405    if(time(&
session->authstart) == -1) {
 
 
 7458    time_t now = time(
NULL);
 
 7476                ast_verb(2, 
"HTTP Manager '%s' timed out from %s\n",
 
 
 7539#define MANAGER_EVENT_BUF_INITSIZE   256 
 7554    const char *cat_str;
 
 7558    int event_name_hash;
 
 7562            ast_debug(3, 
"AMI Event '%s' is globally disabled, skipping\n", 
event);
 
 7576        "Privilege: %s\r\n",
 
 7582            "Timestamp: %ld.%06lu\r\n",
 
 7583            (
long)now.tv_sec, (
unsigned long) now.tv_usec);
 
 7589            "SequenceNumber: %d\r\n",
 
 7599            "SystemName: %s\r\n",
 
 7623                pthread_kill(
session->waiting_thread, SIGURG);
 
 
 7675    const char *fmt, ...)
 
 7689        file, line, func, fmt, ap);
 
 
 7704        if (!strcasecmp(action, cur->
action)) {
 
 7721        ao2_t_ref(cur, -1, 
"action object removed from list");
 
 7722        ast_verb(5, 
"Manager unregistered action %s\n", action);
 
 
 7736    switch(info->reason) {
 
 7743            "StatusText: %s\r\n",
 
 7762            info->presence_subtype,
 
 7763            info->presence_message);
 
 
 7789    ao2_t_ref(act, +1, 
"action object added to list");
 
 
 7833        ao2_t_ref(cur, -1, 
"action object creation failed");
 
 7838        ao2_t_ref(cur, -1, 
"action object creation failed");
 
 7845    cur->module = 
module;
 
 7888        ao2_t_ref(cur, -1, 
"action object registration failed");
 
 7892    ao2_t_ref(cur, -1, 
"action object registration successful");
 
 
 7972    if (nonce == 0 || username == 
NULL || stale == 
NULL) {
 
 7984        if (!strcasecmp(
session->username, username) && 
session->managerid == nonce) {
 
 7987        } 
else if (!strcasecmp(
session->username, username) && 
session->oldnonce == nonce) {
 
 
 8007    authed = (
session->authenticated != 0);
 
 
 8034        if ((
session->managerid == ident) && (
session->readperm & perm)) {
 
 
 8067        if ((
session->managerid == ident) && (
session->writeperm & perm)) {
 
 
 8091    const char *save = src;
 
 8092    int space = 
sizeof(
buf);
 
 8094    for ( ; *src || dst != 
buf ; src++) {
 
 8095        if (*src == 
'\0' || space < 10) {   
 
 8099            space = 
sizeof(
buf);
 
 8106            if (save == src && isdigit(*src)) {
 
 8112            } 
else if (!isalnum(*src)) {
 
 8121            strcpy(dst, 
"<");
 
 8126            strcpy(dst, 
">");
 
 8131            strcpy(dst, 
""");
 
 8136            strcpy(dst, 
"'");
 
 8141            strcpy(dst, 
"&");
 
 8147            *dst++ = mode ? tolower(*src) : *src;
 
 
 8207    const char *dest = 
NULL;
 
 8209    const char *objtype = 
NULL;
 
 8218        for (v = get_vars; v; v = v->
next) {
 
 8219            if (!strcasecmp(v->
name, 
"ajaxdest")) {
 
 8221            } 
else if (!strcasecmp(v->
name, 
"ajaxobjtype")) {
 
 8229            objtype = 
"generic";
 
 8236        if (
in && *
in == 
'\n') {    
 
 8240        ast_debug(5, 
"inobj %d in_data %d line <%s>\n", inobj, in_data, 
val);
 
 8252                    "<tr><td colspan=\"2\"><hr></td></tr>\r\n");
 
 8287            var = 
"Opaque-data";
 
 8304        if (vc->
count > 1) {
 
 8310        if (!in_data || !*
in) {
 
 8317            "<tr><td colspan=\"2\"><hr></td></tr>\r\n");
 
 
 8328        ast_log(
LOG_ERROR, 
"Attempted to close file/file descriptor on mansession without a valid file or file descriptor.\n");
 
 
 8346    l = lseek(fd, 0, SEEK_CUR);
 
 8348        if (MAP_FAILED == (
buf = mmap(
NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0))) {
 
 
 8368                         const struct ast_sockaddr *remote_address, 
const char *uri,
 
 8378    char template[] = 
"/tmp/ast-http-XXXXXX";   
 
 8383        ast_http_error(ser, 501, 
"Not Implemented", 
"Attempt to use unimplemented / unsupported method");
 
 8397            ast_http_error(ser, 500, 
"Server Error", 
"Internal Server Error (out of memory)");
 
 8423        ast_http_error(ser, 500, 
"Server Error", 
"Internal Server Error (ast_str_create() out of memory)");
 
 8424        goto generic_callback_out;
 
 8428    fd = mkstemp(
template); 
 
 8431        ast_http_error(ser, 500, 
"Server Error", 
"Internal Server Error (mkstemp failed)");
 
 8432        goto generic_callback_out;
 
 8437        ast_http_error(ser, 500, 
"Server Error", 
"Internal Server Error (fdopen failed)");
 
 8439        goto generic_callback_out;
 
 8447                ast_http_error(ser, 413, 
"Request Entity Too Large", 
"Body too large");
 
 8449                goto generic_callback_out;
 
 8454                goto generic_callback_out;
 
 8456                ast_http_error(ser, 400, 
"Bad Request", 
"Error parsing request body");
 
 8458                goto generic_callback_out;
 
 8481        "Content-type: text/%s\r\n" 
 8482        "Set-Cookie: mansession_id=\"%08x\"; Version=1; Max-Age=%d\r\n" 
 8483        "Pragma: SuppressEvents\r\n",
 
 8496#define ROW_FMT "<tr><td colspan=\"2\" bgcolor=\"#f1f1ff\">%s</td></tr>\r\n" 
 8497#define TEST_STRING \ 
 8498    "<form action=\"manager\" method=\"post\">\n\ 
 8499    Action: <select name=\"action\">\n\ 
 8500        <option value=\"\">-----></option>\n\ 
 8501        <option value=\"login\">login</option>\n\ 
 8502        <option value=\"command\">Command</option>\n\ 
 8503        <option value=\"waitevent\">waitevent</option>\n\ 
 8504        <option value=\"listcommands\">listcommands</option>\n\ 
 8506    or <input name=\"action\"><br/>\n\ 
 8507    CLI Command <input name=\"command\"><br>\n\ 
 8508    user <input name=\"username\"> pass <input type=\"password\" name=\"secret\"><br>\n\ 
 8509    <input type=\"submit\">\n</form>\n" 
 8512        ast_str_append(&
out, 0, 
"<body bgcolor=\"#ffffff\"><table align=center bgcolor=\"#f1f1f1\" width=\"500\">\r\n");
 
 8531            ast_debug(1, 
"Need destroy, doing it now!\n");
 
 8534            ast_debug(1, 
"Need destroy, but can't do it yet!\n");
 
 8537                pthread_kill(
session->waiting_thread, SIGURG);
 
 8551generic_callback_out:
 
 
 8580                         const struct ast_sockaddr *remote_address, 
const char *uri,
 
 8587    char template[] = 
"/tmp/ast-http-XXXXXX";   
 
 8593    time_t time_now = time(
NULL);
 
 8594    unsigned long nonce = 0, nc;
 
 8598    char resp_hash[256]=
"";
 
 8600    char u_username[80];
 
 8604    int u_displayconnects;
 
 8607        ast_http_error(ser, 501, 
"Not Implemented", 
"Attempt to use unimplemented / unsupported method");
 
 8612    for (v = headers; v; v = v->
next) {
 
 8613        if (!strcasecmp(v->
name, 
"Authorization")) {
 
 8625        ast_http_error(ser, 500, 
"Server Error", 
"Internal Server Error (out of memory)");
 
 8634    if (sscanf(
d.nonce, 
"%30lx", &nonce) != 1) {
 
 8654        ast_http_error(ser, 403, 
"Permission denied", 
"Permission denied");
 
 8671            ast_http_error(ser, 500, 
"Server Error", 
"Internal Server Error (out of memory)");
 
 8680            snprintf(resp, 
sizeof(resp), 
"%s:%08lx:%s:%s:auth:%s", 
user->a1_hash, nonce, 
d.nc, 
d.cnonce, a2_hash);
 
 8683            snprintf(resp, 
sizeof(resp), 
"%s:%08lx:%s", 
user->a1_hash, nonce, a2_hash);
 
 8688    if (strncasecmp(
d.response, resp_hash, strlen(resp_hash))) {
 
 8700    u_readperm = 
user->readperm;
 
 8701    u_writeperm = 
user->writeperm;
 
 8702    u_displayconnects = 
user->displayconnects;
 
 8703    u_writetimeout = 
user->writetimeout;
 
 8713            ast_http_error(ser, 500, 
"Server Error", 
"Internal Server Error (out of memory)");
 
 8723        session->readperm = u_readperm;
 
 8724        session->writeperm = u_writeperm;
 
 8725        session->writetimeout = u_writetimeout;
 
 8727        if (u_displayconnects) {
 
 8750        sscanf(
d.nc, 
"%30lx", &nc);
 
 8751        if (
session->nc >= nc || ((time_now - 
session->noncetime) > 62) ) {
 
 8762            session->noncetime = time_now;
 
 8778    fd = mkstemp(
template); 
 
 8781        ast_http_error(ser, 500, 
"Server Error", 
"Internal Server Error (mkstemp failed)");
 
 8782        goto auth_callback_out;
 
 8787        ast_http_error(ser, 500, 
"Server Error", 
"Internal Server Error (fdopen failed)");
 
 8789        goto auth_callback_out;
 
 8797                ast_http_error(ser, 413, 
"Request Entity Too Large", 
"Body too large");
 
 8799                goto auth_callback_out;
 
 8804                goto auth_callback_out;
 
 8806                ast_http_error(ser, 400, 
"Bad Request", 
"Error parsing request body");
 
 8808                goto auth_callback_out;
 
 8816        if (u_displayconnects) {
 
 8831        ast_http_error(ser, 500, 
"Server Error", 
"Internal Server Error (ast_str_create() out of memory)");
 
 8833        goto auth_callback_out;
 
 8842        "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n" 
 8844        "<title>Asterisk™ Manager Interface</title>\r\n" 
 8845        "</head><body style=\"background-color: #ffffff;\">\r\n" 
 8846        "<form method=\"POST\">\r\n" 
 8847        "<table align=\"center\" style=\"background-color: #f1f1f1;\" width=\"500\">\r\n" 
 8848        "<tr><th colspan=\"2\" style=\"background-color: #f1f1ff;\"><h1>Manager Tester</h1></th></tr>\r\n" 
 8849        "<tr><th colspan=\"2\" style=\"background-color: #f1f1ff;\">Action: <input name=\"action\" /> Cmd: <input name=\"command\" /><br>" 
 8850        "<input type=\"submit\" value=\"Send request\" /></th></tr>\r\n");
 
 8884        ast_debug(1, 
"Need destroy, doing it now!\n");
 
 
 8934    .
description = 
"Raw HTTP Manager Event Interface",
 
 
 8993    .
description = 
"Raw HTTP Manager Event Interface w/Digest authentication",
 
 
 9002    .
description = 
"HTML Manager Event Interface w/Digest authentication",
 
 
 9011    .
description = 
"XML Manager Event Interface w/Digest authentication",
 
 
 9023    const char *login = (
char *)arg;
 
 9024    int *no_sessions = data;
 
 9026    if (strcasecmp(
session->username, login) == 0) {
 
 
 9046        ast_log(
LOG_WARNING, 
"AMI_CLIENT() requires two arguments: AMI_CLIENT(<name>[,<arg>])\n");
 
 9061    if (!strcasecmp(
args.param, 
"sessions")) {
 
 9062        int no_sessions = 0;
 
 9070        snprintf(
buf, 
len, 
"%d", no_sessions);
 
 
 9083    .
name = 
"AMI_CLIENT",
 
 
 9114    .poll_timeout = 5000,   
 
 9116    .name = 
"AMI server",
 
 
 9126    .name = 
"AMI TLS server",
 
 
 9136        e->
command = 
"manager show settings";
 
 9138            "Usage: manager show settings\n" 
 9139            "       Provides detailed list of the configuration of the Manager.\n";
 
 9144#define FORMAT "  %-25.25s  %-15.55s\n" 
 9145#define FORMAT2 "  %-25.25s  %-15d\n" 
 9146#define FORMAT3 "  %-25.25s  %s\n" 
 9150    ast_cli(
a->fd, 
"\nGlobal Settings:\n");
 
 9151    ast_cli(
a->fd, 
"----------------\n");
 
 
 9180    return strcmp((*item_a)->name, (*item_b)->name);
 
 
 9190    int i = 0, totalitems = 0;
 
 9194        e->
command = 
"manager show events";
 
 9196            "Usage: manager show events\n" 
 9197                "   Prints a listing of the available Asterisk manager interface events.\n";
 
 9213        ast_cli(
a->fd, 
"No manager event documentation loaded\n");
 
 9237        items[totalitems++] = 
item;
 
 9244    ast_cli(
a->fd, 
"  --------------------  --------------------  --------------------  \n");
 
 9245    for (i = 0; i < totalitems; i++) {
 
 9247        if ((i + 1) % 3 == 0) {
 
 9252    if ((i + 1) % 3 != 0) {
 
 
 9266    char *since, *syntax, *description, *
synopsis, *seealso, *arguments;
 
 9275    if (!
synopsis || !since || !description || !syntax || !arguments || !seealso) {
 
 9276        ast_cli(
a->fd, 
"Error: Memory allocation failed\n");
 
 9281        "%s  -= Info about Manager Event '%s' =- %s\n\n" 
 
 9320        e->
command = 
"manager show event";
 
 9322            "Usage: manager show event <eventname>\n" 
 9323            "       Provides a detailed description a Manager interface event.\n";
 
 9329        ast_cli(
a->fd, 
"No manager event documentation loaded\n");
 
 9338        length = strlen(
a->word);
 
 9341            if (!strncasecmp(
a->word, 
item->
name, length)) {
 
 9359        ast_cli(
a->fd, 
"Could not find event '%s'\n", 
a->argv[3]);
 
 9363    ast_cli(
a->fd, 
"Event: %s\n", 
a->argv[3]);
 
 
 9434    if (
user->includefilters) {
 
 9435        ao2_t_ref(
user->includefilters, -1, 
"decrement ref for include container, should be last one");
 
 9437    if (
user->excludefilters) {
 
 9438        ao2_t_ref(
user->excludefilters, -1, 
"decrement ref for exclude container, should be last one");
 
 
 9453#ifdef TEST_FRAMEWORK 
 9508#ifdef TEST_FRAMEWORK 
 9510    test_suite_forwarder = 
NULL;
 
 
 9650    int newhttptimeout = 60;
 
 9658    int tls_was_enabled = 0;
 
 9659    int acl_subscription_flag = 0;
 
 9718#ifdef TEST_FRAMEWORK 
 9734        if (temp_event_docs) {
 
 9736            ao2_t_ref(temp_event_docs, -1, 
"Remove creation ref - container holds only ref now");
 
 9756        ast_log(
LOG_NOTICE, 
"Unable to open AMI configuration manager.conf, or configuration is invalid.\n");
 
 9761    if (!by_external_config) {
 
 9778        if (strcasecmp(
var->name, 
"tlscafile")
 
 9779            && strcasecmp(
var->name, 
"tlscapath")
 
 9780            && strcasecmp(
var->name, 
"tlscadir")
 
 9781            && strcasecmp(
var->name, 
"tlsverifyclient")
 
 9782            && strcasecmp(
var->name, 
"tlsdontverifyserver")
 
 9783            && strcasecmp(
var->name, 
"tlsclientmethod")
 
 9784            && strcasecmp(
var->name, 
"sslclientmethod")
 
 9789        if (!strcasecmp(
var->name, 
"enabled")) {
 
 9791        } 
else if (!strcasecmp(
var->name, 
"webenabled")) {
 
 9793        } 
else if (!strcasecmp(
var->name, 
"port")) {
 
 9799        } 
else if (!strcasecmp(
var->name, 
"bindaddr")) {
 
 9814        } 
else if (!strcasecmp(
var->name, 
"brokeneventsaction")) {
 
 9816        } 
else if (!strcasecmp(
var->name, 
"allowmultiplelogin")) {
 
 9818        } 
else if (!strcasecmp(
var->name, 
"displayconnects")) {
 
 9820        } 
else if (!strcasecmp(
var->name, 
"timestampevents")) {
 
 9822        } 
else if (!strcasecmp(
var->name, 
"debug")) {
 
 9824        } 
else if (!strcasecmp(
var->name, 
"httptimeout")) {
 
 9825            newhttptimeout = atoi(
val);
 
 9826        } 
else if (!strcasecmp(
var->name, 
"authtimeout")) {
 
 9827            int timeout = atoi(
var->value);
 
 9834        } 
else if (!strcasecmp(
var->name, 
"authlimit")) {
 
 9835            int limit = atoi(
var->value);
 
 9842        } 
else if (!strcasecmp(
var->name, 
"channelvars")) {
 
 9844        } 
else if (!strcasecmp(
var->name, 
"disabledevents")) {
 
 9885        if (!strcasecmp(cat, 
"general")) {
 
 9899            user->writeperm = 0;
 
 9904            user->writetimeout = 100;
 
 9907            if (!
user->includefilters || !
user->excludefilters) {
 
 9927            if (!strcasecmp(
var->name, 
"secret")) {
 
 9930            } 
else if (!strcasecmp(
var->name, 
"deny") ||
 
 9931                       !strcasecmp(
var->name, 
"permit") ||
 
 9932                       !strcasecmp(
var->name, 
"acl")) {
 
 9937                    ast_log(
LOG_ERROR, 
"Invalid ACL '%s' for manager user '%s' on line %d. Deleting user\n",
 
 9941            }  
else if (!strcasecmp(
var->name, 
"read") ) {
 
 9943            }  
else if (!strcasecmp(
var->name, 
"write") ) {
 
 9945            }  
else if (!strcasecmp(
var->name, 
"displayconnects") ) {
 
 9947            }  
else if (!strcasecmp(
var->name, 
"allowmultiplelogin") ) {
 
 9949            } 
else if (!strcasecmp(
var->name, 
"writetimeout")) {
 
 9956            } 
else if (!strcasecmp(
var->name, 
"setvar")) {
 
 9965                if ((varval = strchr(varname,
'='))) {
 
 9969                        user->chanvars = tmpvar;
 
 9985    if (acl_subscription_flag && !by_external_config) {
 
10034    if (newhttptimeout > 0) {
 
 
10070#ifdef TEST_FRAMEWORK 
 
10112        if ((datastore->
uid != 
NULL) && !strcasecmp(
uid, datastore->
uid)) {
 
 
10125    if (!*fields_string) {
 
10127        if (!*fields_string) {
 
 
10143__attribute__((format(printf, 3, 4)))
 
10147    const 
char *extra_fields_fmt,
 
10169    va_start(argp, extra_fields_fmt);
 
 
10182    .
requires = 
"extconfig,acl,http",
 
Access Control of various sorts.
enum ast_acl_sense ast_apply_acl(struct ast_acl_list *acl_list, const struct ast_sockaddr *addr, const char *purpose)
Apply a set of rules to a given IP address.
struct stasis_message_type * ast_named_acl_change_type(void)
a stasis_message_type for changes against a named ACL or the set of all named ACLs
void ast_acl_output(int fd, struct ast_acl_list *acl, const char *prefix)
output an ACL to the provided fd
void ast_append_acl(const char *sense, const char *stuff, struct ast_acl_list **path, int *error, int *named_acl_flag)
Add a rule to an ACL struct.
int ast_acl_list_is_empty(struct ast_acl_list *acl_list)
Determines if an ACL is empty or if it contains entries.
struct ast_acl_list * ast_free_acl_list(struct ast_acl_list *acl)
Free a list of ACLs.
void ast_cli_unregister_multiple(void)
Generic Advice of Charge encode and decode routines.
void * ast_aoc_destroy_encoded(struct ast_aoc_encoded *encoded)
free an ast_aoc_encoded object
int ast_aoc_s_add_rate_duration(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name, unsigned long time, enum ast_aoc_time_scale time_scale, unsigned long granularity_time, enum ast_aoc_time_scale granularity_time_scale, int step_function)
Add AOC-S duration rate entry.
@ AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION
@ AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT
@ AST_AOC_CHARGED_ITEM_NA
@ AST_AOC_CHARGED_ITEM_USER_USER_INFO
@ AST_AOC_CHARGED_ITEM_CALL_SETUP
@ AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE
@ AST_AOC_CHARGED_ITEM_CALL_ATTEMPT
@ AST_AOC_CHARGE_CURRENCY
@ AST_AOC_TIME_SCALE_TEN_SECOND
@ AST_AOC_TIME_SCALE_TENTH_SECOND
@ AST_AOC_TIME_SCALE_MINUTE
@ AST_AOC_TIME_SCALE_SECOND
@ AST_AOC_TIME_SCALE_HOUR
@ AST_AOC_TIME_SCALE_HUNDREDTH_SECOND
@ AST_AOC_VOLUME_UNIT_OCTET
@ AST_AOC_VOLUME_UNIT_SEGMENT
@ AST_AOC_VOLUME_UNIT_MESSAGE
int ast_aoc_s_add_rate_special_charge_code(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, unsigned int code)
Add AOC-S special rate entry.
ast_aoc_currency_multiplier
Defines the currency multiplier for an aoc message.
@ AST_AOC_MULT_ONEHUNDREDTH
@ AST_AOC_MULT_ONETHOUSANDTH
struct ast_aoc_decoded * ast_aoc_create(const enum ast_aoc_type msg_type, const enum ast_aoc_charge_type charge_type, const enum ast_aoc_request requests)
creates a ast_aoc_decode object of a specific message type
void * ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded)
free an ast_aoc_decoded object
int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num, uint8_t plan)
set the charging association number for an AOC-E message
int ast_aoc_add_unit_entry(struct ast_aoc_decoded *decoded, const unsigned int amount_is_present, const unsigned int amount, const unsigned int type_is_present, const unsigned int type)
Adds a unit entry into the list of units.
ast_aoc_billing_id
Defines the billing id options for an aoc message.
@ AST_AOC_BILLING_CALL_FWD_BUSY
@ AST_AOC_BILLING_CALL_FWD_NO_REPLY
@ AST_AOC_BILLING_CALL_DEFLECTION
@ AST_AOC_BILLING_CREDIT_CARD
@ AST_AOC_BILLING_CALL_TRANSFER
@ AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL
@ AST_AOC_BILLING_REVERSE_CHARGE
int ast_aoc_s_add_rate_free(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, int from_beginning)
Add AOC-S indicating charge item is free.
int ast_aoc_set_billing_id(struct ast_aoc_decoded *decoded, const enum ast_aoc_billing_id id)
set the billing id for a AOC-D or AST_AOC_E message
int ast_aoc_s_add_special_arrangement(struct ast_aoc_decoded *decoded, unsigned int code)
Add AOC-S special arrangement entry.
int ast_aoc_set_currency_info(struct ast_aoc_decoded *decoded, const unsigned int amount, const enum ast_aoc_currency_multiplier multiplier, const char *name)
Sets the currency values for a AOC-D or AOC-E message.
int ast_aoc_set_association_id(struct ast_aoc_decoded *decoded, const int id)
set the charging association id for an AST_AOC_E message
int ast_aoc_s_add_rate_flat(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name)
Add AOC-S flat rate entry.
struct ast_aoc_encoded * ast_aoc_encode(struct ast_aoc_decoded *decoded, size_t *out_size, struct ast_channel *chan)
encodes a decoded aoc structure so it can be passed on the wire
int ast_aoc_set_total_type(struct ast_aoc_decoded *decoded, const enum ast_aoc_total_type type)
Sets the type of total for a AOC-D message.
int ast_aoc_s_add_rate_volume(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, enum ast_aoc_volume_unit volume_unit, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name)
Add AOC-S volume rate entry.
unsigned int ast_aoc_s_get_count(struct ast_aoc_decoded *decoded)
get the number rates associated with an AOC-S message
int ast_aoc_s_add_rate_na(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item)
Add AOC-S entry indicating charge item is not available.
@ AST_AOC_RATE_TYPE_VOLUME
@ AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING
@ AST_AOC_RATE_TYPE_SPECIAL_CODE
@ AST_AOC_RATE_TYPE_DURATION
static const struct adsi_event events[]
static volatile unsigned int seq
static int copy(char *infile, char *outfile)
Utility function to copy a file.
Asterisk version information.
const char * ast_get_version(void)
Retrieve the Asterisk version string.
char * strsep(char **str, const char *delims)
char * strcasestr(const char *, const char *)
Asterisk main include file. File version handling, generic pbx functions.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
int ast_shutting_down(void)
static struct ast_mansession session
void ast_std_free(void *ptr)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
#define ao2_t_ref(o, delta, tag)
#define ao2_iterator_next(iter)
#define AO2_GLOBAL_OBJ_STATIC(name)
Define a global object holder to be used to hold an ao2 object, statically initialized.
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_NOLOCK
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define ao2_global_obj_replace_unref(holder, obj)
Replace an ao2 object in the global holder, throwing away any old object.
#define ao2_t_global_obj_replace_unref(holder, obj, tag)
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_callback_data(container, flags, cb_fn, arg, data)
#define ao2_unlink(container, obj)
Remove an object from a container.
#define ao2_t_link(container, obj, tag)
#define ao2_global_obj_ref(holder)
Get a reference to the object stored in the global holder.
#define ao2_find(container, arg, flags)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc_options(data_size, destructor_fn, options)
#define ao2_t_callback_data(container, flags, cb_fn, arg, data, tag)
ao2_callback_data() is a generic function that applies cb_fn() to all objects in a container....
#define ao2_global_obj_release(holder)
Release the ao2 object held in the global holder.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ao2_t_alloc(data_size, destructor_fn, debug_msg)
@ OBJ_SEARCH_OBJECT
The arg parameter is an object of the same type.
@ OBJ_NOLOCK
Assume that the ao2_container is already locked.
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a list container.
#define ao2_alloc(data_size, destructor_fn)
#define ao2_t_global_obj_release(holder, tag)
#define ao2_t_callback(c, flags, cb_fn, arg, tag)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
@ AO2_CONTAINER_ALLOC_OPT_DUPS_OBJ_REJECT
Reject duplicate objects in container.
enum ast_transfer_result ast_bridge_transfer_blind(int is_external, struct ast_channel *transferer, const char *exten, const char *context, transfer_channel_cb new_channel_cb, void *user_data)
Blind transfer target to the extension and context provided.
@ AST_BRIDGE_TRANSFER_NOT_PERMITTED
@ AST_BRIDGE_TRANSFER_SUCCESS
@ AST_BRIDGE_TRANSFER_INVALID
@ AST_BRIDGE_TRANSFER_FAIL
After Bridge Execution API.
void ast_bridge_discard_after_goto(struct ast_channel *chan)
Discard channel after bridge goto location.
static struct prometheus_metrics_provider provider
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s,...
int ast_cdr_is_enabled(void)
Return TRUE if CDR subsystem is enabled.
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
static struct unistimsession * sessions
General Asterisk PBX channel definitions.
struct varshead * ast_channel_get_manager_vars(struct ast_channel *chan)
Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
const char * ast_channel_name(const struct ast_channel *chan)
#define AST_MAX_PUBLIC_UNIQUEID
const char * ast_channel_data(const struct ast_channel *chan)
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Clear a flag on a channel.
struct varshead * ast_channel_varshead(struct ast_channel *chan)
struct ast_channel_iterator * ast_channel_iterator_destroy(struct ast_channel_iterator *i)
Destroy a channel iterator.
void ast_channel_set_manager_vars(size_t varc, char **vars)
Sets the variables to be stored in the manager_vars field of all snapshots.
#define ast_channel_lock(chan)
struct ast_trans_pvt * ast_channel_readtrans(const struct ast_channel *chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
struct ast_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan)
ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan)
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
int ast_check_hangup_locked(struct ast_channel *chan)
struct ast_channel * ast_channel_get_by_name_prefix(const char *name, size_t name_len)
Find a channel by a name prefix.
void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode)
Lock the given channel, then request softhangup on the channel with the given causecode.
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
const char * ast_channel_appl(const struct ast_channel *chan)
struct timeval ast_channel_creationtime(struct ast_channel *chan)
struct ast_channel * ast_channel_get_by_name(const char *search)
Find a channel by name or uniqueid.
int ast_active_channels(void)
returns number of active/allocated channels
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
#define ast_channel_unref(c)
Decrease channel reference count.
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
ast_group_t ast_channel_callgroup(const struct ast_channel *chan)
struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan)
void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Set when to hang a channel up.
#define ast_dummy_channel_alloc()
Create a fake channel structure.
@ AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT
struct ast_channel_iterator * ast_channel_iterator_all_new(void)
Create a new channel iterator.
#define ast_channel_unlock(chan)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
const char * ast_var_name(const struct ast_var_t *var)
const char * ast_var_value(const struct ast_var_t *var)
Standard Command Line Interface.
#define AST_CLI_YESNO(x)
Return Yes or No depending on the argument.
#define AST_CLI_DEFINE(fn, txt,...)
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_command(fd, s)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static struct ao2_container * codecs
Registered codecs.
static struct channel_usage channels
Local proxy channel special access.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Call Parking and Pickup API Includes code and algorithms from the Zapata library.
Generic File Format Support. Should be included by clients of the file handling routines....
static int md5(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int filter(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static int action_setvar(struct mansession *s, const struct message *m)
static int action_createconfig(struct mansession *s, const struct message *m)
static void purge_events(void)
static char * handle_showmancmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * match_type_names[]
static int manager_state_cb(const char *context, const char *exten, struct ast_state_cb_info *info, void *data)
static void mansession_unlock(struct mansession *s)
Unlock the 'mansession' structure.
static int action_loggerrotate(struct mansession *s, const struct message *m)
Manager command "LoggerRotate" - reloads and rotates the logger in the same manner as the CLI command...
int __ast_manager_event_multichan(int category, const char *event, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *fmt,...)
static int match_eventdata(struct event_filter_entry *entry, const char *eventdata)
Test eventdata against a filter entry.
#define GET_HEADER_LAST_MATCH
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
static int purge_sessions(int n_max)
remove at most n_max stale session from the list.
static int process_message(struct mansession *s, const struct message *m)
Process an AMI message, performing desired action. Return 0 on success, -1 on error that require the ...
static int strings_to_mask(const char *string)
static void print_event_instance(struct ast_cli_args *a, struct ast_xml_doc_item *instance)
static int __manager_event_sessions(struct ao2_container *sessions, int category, const char *event, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *fmt,...)
static struct ast_manager_user * get_manager_by_name_locked(const char *name)
static void acl_change_stasis_subscribe(void)
static char * handle_showmaneventq(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager list eventq.
static void log_action(const struct message *m, const char *action)
static struct mansession_session * build_mansession(const struct ast_sockaddr *addr)
Allocate manager session structure and add it to the list of sessions.
static void report_invalid_user(const struct mansession *s, const char *username)
static int append_event(const char *str, int event_name_hash, int category)
events are appended to a queue from where they can be dispatched to clients.
static int manager_enabled
int ast_manager_check_enabled(void)
Check if AMI is enabled.
static void astman_free_headers(struct message *m)
Free headers inside message structure, but not the message structure itself.
static int action_sendtext(struct mansession *s, const struct message *m)
static int action_mailboxcount(struct mansession *s, const struct message *m)
static void manager_json_to_ast_str(struct ast_json *obj, const char *key, struct ast_str **res, key_exclusion_cb exclusion_cb)
static int ast_manager_register_struct(struct manager_action *act)
static int queue_read_action_payload(struct ast_channel *chan, const unsigned char *payload, size_t payload_size, enum ast_frame_read_action action)
Queue a given read action containing a payload onto a channel.
static struct manager_action * action_find(const char *name)
static int action_getconfigjson(struct mansession *s, const struct message *m)
int ast_webmanager_check_enabled(void)
Check if AMI/HTTP is enabled.
void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg)
Send response in manager transaction.
static void report_failed_acl(const struct mansession *s, const char *username)
static int is_originate_app_permitted(const char *app, const char *data, int permission)
static int action_listcategories(struct mansession *s, const struct message *m)
static int action_hangup(struct mansession *s, const struct message *m)
static void mansession_lock(struct mansession *s)
Lock the 'mansession' structure.
static int action_listcommands(struct mansession *s, const struct message *m)
static void destroy_fast_originate_helper(struct fast_originate_helper *doomed)
static int action_atxfer(struct mansession *s, const struct message *m)
static int action_timeout(struct mansession *s, const struct message *m)
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
static struct stasis_subscription * acl_change_sub
static void generate_status(struct mansession *s, struct ast_channel *chan, char **vars, int varc, int all_variables, char *id_text, int *count)
static int do_message(struct mansession *s)
static struct originate_permissions_entry originate_app_permissions[]
void astman_send_error_va(struct mansession *s, const struct message *m, const char *fmt,...)
Send error in manager transaction (with va_args support)
static void manager_default_msg_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static int action_coresettings(struct mansession *s, const struct message *m)
Show PBX core settings information.
static int mansession_cmp_fn(void *obj, void *arg, int flags)
static int displayconnects
static int action_filter(struct mansession *s, const struct message *m)
Manager command to add an event filter to a manager session.
static int action_mailboxstatus(struct mansession *s, const struct message *m)
static void append_channel_vars(struct ast_str **pbuf, struct ast_channel *chan)
static int action_login(struct mansession *s, const struct message *m)
static int action_getvar(struct mansession *s, const struct message *m)
static int get_input(struct mansession *s, char *output)
static int action_blind_transfer(struct mansession *s, const struct message *m)
static const char * user_authority_to_str(int authority, struct ast_str **res)
Convert authority code to a list of options for a user. This will only display those authority codes ...
static int app_match(const char *app, const char *data, const char *search)
static struct mansession_session * unref_mansession(struct mansession_session *s)
Unreference manager session object. If no more references, then go ahead and delete it.
static int queue_match(const char *app, const char *data, const char *search)
#define ASTMAN_APPEND_BUF_INITSIZE
initial allocated size for the astman_append_buf and astman_send_*_va
void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj)
Publish an event to AMI.
static void session_destroy(struct mansession_session *s)
static int filter_cmp_fn(void *obj, void *arg, void *data, int flags)
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
static int appdata_match(const char *app, const char *data, const char *search)
struct stasis_message_router * ast_manager_get_message_router(void)
Get the stasis_message_router for AMI.
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
static void astman_send_response_full(struct mansession *s, const struct message *m, char *resp, char *msg, char *listflag)
send a response with an optional message, and terminate it with an empty line. m is used only to grab...
static void astman_append_json(struct mansession *s, const char *str)
#define MGR_SHOW_TERMINAL_WIDTH
static enum error_type handle_updates(struct mansession *s, const struct message *m, struct ast_config *cfg, const char *dfn)
helper function for action_updateconfig
static int action_extensionstate(struct mansession *s, const struct message *m)
static char * handle_showmanconn(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager list connected.
static int action_getconfig(struct mansession *s, const struct message *m)
static void event_filter_destructor(void *obj)
static void * session_do(void *data)
The body of the individual manager session. Call get_input() to read one line at a time (or be woken ...
static struct eventqent * advance_event(struct eventqent *e)
static int coreshowchannelmap_add_connected_channels(struct ao2_container *channel_map, struct ast_channel_snapshot *channel_snapshot, struct ast_bridge_snapshot *bridge_snapshot)
Recursive function to get all channels in a bridge. Follow local channels as well.
static enum add_filter_result manager_add_filter(const char *criteria, const char *filter_pattern, struct ao2_container *includefilters, struct ao2_container *excludefilters)
Add an event filter to a manager session.
static void session_destructor(void *obj)
static struct stasis_message_router * stasis_router
The stasis_message_router for all Stasis Message Bus API messages.
static void json_escape(char *out, const char *in)
static int manager_displayconnects(struct mansession_session *session)
Get displayconnects config option.
static int action_logoff(struct mansession *s, const struct message *m)
static char * handle_kickmanconn(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager kick session.
static int action_updateconfig(struct mansession *s, const struct message *m)
static void astman_start_ack(struct mansession *s, const struct message *m)
static const char * __astman_get_header(const struct message *m, char *var, int mode)
Return a matching header value.
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
static int file_in_modules_dir(const char *filename)
Check if the given file path is in the modules dir or not.
static void handle_parse_error(struct mansession *s, struct message *m, char *error)
static int manager_moduleload(struct mansession *s, const struct message *m)
static void acl_change_stasis_unsubscribe(void)
static int reload_module(void)
static void manager_json_array_with_key(struct ast_json *obj, const char *key, size_t index, struct ast_str **res, key_exclusion_cb exclusion_cb)
static void astman_append_headers(struct message *m, const struct ast_variable *params)
Append additional headers into the message structure from params.
static void report_failed_challenge_response(const struct mansession *s, const char *response, const char *expected_response)
#define any_manager_listeners(sessions)
static int action_reload(struct mansession *s, const struct message *m)
Send a reload event.
struct ast_variable * astman_get_variables(const struct message *m)
Get a linked list of the Variable: headers.
static int live_dangerously
Set to true (non-zero) to globally allow all dangerous AMI actions to run.
static int is_restricted_file(const char *filename)
Check if a file is restricted or not.
struct ast_str * ast_manager_str_from_json_object(struct ast_json *blob, key_exclusion_cb exclusion_cb)
Convert a JSON object into an AMI compatible string.
static struct eventqent * grab_last(void)
static int should_send_event(struct ao2_container *includefilters, struct ao2_container *excludefilters, struct eventqent *eqe)
static struct stasis_forward * rtp_topic_forwarder
The stasis_subscription for forwarding the RTP topic to the AMI topic.
static int action_aocmessage(struct mansession *s, const struct message *m)
static char * handle_showmanagers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int check_manager_session_inuse(const char *name)
static int check_blacklist(const char *cmd)
static int action_events(struct mansession *s, const struct message *m)
void ast_manager_unregister_hook(struct manager_custom_hook *hook)
Delete a custom hook to be called when an event is fired.
static void astman_flush(struct mansession *s, struct ast_str *buf)
static const char * authority_to_str(int authority, struct ast_str **res)
Convert authority code to a list of options. Note that the EVENT_FLAG_ALL authority will always be re...
static int action_redirect(struct mansession *s, const struct message *m)
action_redirect: The redirect manager command
static struct stasis_forward * security_topic_forwarder
The stasis_subscription for forwarding the Security topic to the AMI topic.
static int action_presencestate(struct mansession *s, const struct message *m)
struct ast_variable * astman_get_variables_order(const struct message *m, enum variable_orders order)
Get a linked list of the Variable: headers with order specified.
static char * manager_channelvars
void ast_manager_register_hook(struct manager_custom_hook *hook)
Add a custom hook to be called when an event is fired.
static int allowmultiplelogin
static void manager_json_value_str_append(struct ast_json *value, const char *key, struct ast_str **res)
static int queue_sendtext_data(struct ast_channel *chan, const char *body, const char *content_type)
Queue a read action to send a text data message.
const char * astman_get_header(const struct message *m, char *var)
Return the first matching variable from an array.
#define GET_HEADER_SKIP_EMPTY
static enum ast_transport mansession_get_transport(const struct mansession *s)
static int function_capable_string_allowed_with_auths(const char *evaluating, int writepermlist)
Checks to see if a string which can be used to evaluate functions should be rejected.
static char * handle_showmanager(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int action_cancel_atxfer(struct mansession *s, const struct message *m)
static void report_req_not_allowed(const struct mansession *s, const char *action)
static char global_realm[MAXHOSTNAMELEN]
static int action_originate(struct mansession *s, const struct message *m)
static int send_string(struct mansession *s, char *string)
#define MAX_AUTH_PERM_STRING
static int action_userevent(struct mansession *s, const struct message *m)
static int action_command(struct mansession *s, const struct message *m)
Manager command "command" - execute CLI command.
static void report_inval_password(const struct mansession *s, const char *username)
static int ast_instring(const char *bigstr, const char *smallstr, const char delim)
#define MAX_BLACKLIST_CMD_LEN
Descriptor for a manager session, either on the AMI socket or over HTTP.
int ast_manager_register2(const char *action, int auth, int(*func)(struct mansession *s, const struct message *m), struct ast_module *module, const char *synopsis, const char *description)
register a new command with manager, including online help. This is the preferred way to register a m...
static int process_events(struct mansession *s)
static int broken_events_action
static void report_session_limit(const struct mansession *s)
static int unauth_sessions
static int set_eventmask(struct mansession *s, const char *eventmask)
Rather than braindead on,off this now can also accept a specific int mask value or a ',...
static int timestampevents
static void manager_generic_msg_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static struct ast_aoc_decoded * action_aoc_s_message(struct mansession *s, const struct message *m)
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
static char * handle_manager_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager reload.
static struct ast_aoc_decoded * action_aoc_de_message(struct mansession *s, const struct message *m)
static int authenticate(struct mansession *s, const struct message *m)
void astman_append(struct mansession *s, const char *fmt,...)
static void manager_json_obj_with_key(struct ast_json *obj, const char *key, const char *parent_key, struct ast_str **res, key_exclusion_cb exclusion_cb)
static char * handle_showmancmds(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager list commands.
#define EVENT_FLAG_SHUTDOWN
Fake event class used to end sessions at shutdown.
static int manager_modulecheck(struct mansession *s, const struct message *m)
Manager function to check if module is loaded.
static void astman_send_list_complete(struct mansession *s, const struct message *m, const char *event_name, int count)
static int async_goto_with_discard_bridge_after(struct ast_channel *chan, const char *context, const char *exten, int priority)
void astman_live_dangerously(int new_live_dangerously)
Enable/disable the inclusion of 'dangerous' configurations outside of the ast_config_AST_CONFIG_DIR.
int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg)
access for hooks to send action messages to ami
static int action_aoc_s_submessage(struct mansession *s, const struct message *m, struct ast_aoc_decoded *decoded)
static int webmanager_enabled
static struct ast_str * astman_send_list_complete_start_common(struct mansession *s, const struct message *m, const char *event_name, int count)
static int action_status(struct mansession *s, const struct message *m)
Manager "status" command to show channels.
static int get_perm(const char *instr)
static int action_coreshowchannels(struct mansession *s, const struct message *m)
Manager command "CoreShowChannels" - List currently defined channels and some information about them.
static struct ast_variable * man_do_variable_value(struct ast_variable *head, const char *hdr_val)
static int action_corestatus(struct mansession *s, const struct message *m)
Show PBX core status information.
static int queue_sendtext(struct ast_channel *chan, const char *body)
Queue a read action to send a text message.
static void action_destroy(void *obj)
static int action_challenge(struct mansession *s, const struct message *m)
static struct stasis_topic * manager_topic
A stasis_topic that all topics AMI cares about will be forwarded to.
static int action_waitevent(struct mansession *s, const struct message *m)
static void report_req_bad_format(const struct mansession *s, const char *action)
static int action_coreshowchannelmap(struct mansession *s, const struct message *m)
Manager command "CoreShowChannelMap" - Lists all channels connected to the specified channel.
mansession_message_parsing
static char * handle_mandebug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int action_ping(struct mansession *s, const struct message *m)
#define GET_HEADER_FIRST_MATCH
static int aocmessage_get_unit_entry(const struct message *m, struct ast_aoc_unit_entry *entry, unsigned int entry_num)
static int coreshowchannelmap_add_to_map(struct ao2_container *c, const char *s)
Helper function to add a channel name to the vector.
int ast_manager_hangup_helper(struct mansession *s, const struct message *m, manager_hangup_handler_t hangup_handler, manager_hangup_cause_validator_t cause_validator)
A manager helper function that hangs up a channel using a supplied channel type specific hangup funct...
static void report_auth_success(const struct mansession *s)
static void * fast_originate(void *data)
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
#define MANAGER_EVENT_BUF_INITSIZE
static const struct permalias perms[]
#define manager_event_sessions(sessions, category, event, contents,...)
static char * manager_disabledevents
static int __manager_event_sessions_va(struct ao2_container *sessions, int category, const char *event, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *fmt, va_list ap)
int ast_manager_unregister(const char *action)
support functions to register/unregister AMI action handlers,
static const struct @399 command_blacklist[]
@ FILTER_MATCH_STARTS_WITH
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
#define SCOPE_EXIT_LOG_RTN_VALUE(__value, __log_level,...)
#define SCOPE_ENTER(level,...)
struct ast_channel_snapshot * ast_channel_snapshot_get_latest(const char *uniqueid)
Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object,...
struct ast_channel_snapshot * ast_channel_snapshot_get_latest_by_name(const char *name)
Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object,...
struct ao2_container * ast_channel_cache_by_name(void)
Secondary channel cache, indexed by name.
struct ast_msg_data * ast_msg_data_alloc2(enum ast_msg_data_source_type source_type, const char *to, const char *from, const char *content_type, const char *body)
Allocates an ast_msg_data structure.
size_t ast_msg_data_get_length(struct ast_msg_data *msg)
Get length of the structure.
@ AST_MSG_DATA_SOURCE_TYPE_UNKNOWN
double ast_option_maxload
Support for Private Asterisk HTTP Servers.
void ast_http_send(struct ast_tcptls_session_instance *ser, enum ast_http_method method, int status_code, const char *status_title, struct ast_str *http_header, struct ast_str *out, int fd, unsigned int static_content)
Generic function for sending HTTP/1.1 response.
struct ast_variable * ast_http_get_post_vars(struct ast_tcptls_session_instance *ser, struct ast_variable *headers)
Get post variables from client Request Entity-Body, if content type is application/x-www-form-urlenco...
ast_http_method
HTTP Request methods known by Asterisk.
void ast_http_uri_unlink(struct ast_http_uri *urihandler)
Unregister a URI handler.
uint32_t ast_http_manid_from_vars(struct ast_variable *headers) attribute_pure
Return manager id, if exist, from request headers.
const char * ast_get_http_method(enum ast_http_method method) attribute_pure
Return http method name string.
void ast_http_request_close_on_completion(struct ast_tcptls_session_instance *ser)
Request the HTTP connection be closed after this HTTP request.
void ast_http_error(struct ast_tcptls_session_instance *ser, int status, const char *title, const char *text)
Send HTTP error message and close socket.
int ast_http_uri_link(struct ast_http_uri *urihandler)
Register a URI handler.
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
int ast_app_has_voicemail(const char *mailboxes, const char *folder)
Determine if a given mailbox has any voicemail If folder is NULL, defaults to "INBOX"....
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
int ast_app_inboxcount2(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Determine number of urgent/new/old messages in a mailbox.
Configuration File Parser.
void ast_include_rename(struct ast_config *conf, const char *from_file, const char *to_file)
int ast_category_inherit(struct ast_category *existing, const struct ast_category *base)
Applies base (template) to category.
const char * ast_category_get_name(const struct ast_category *category)
Return the name of the category.
struct ast_category * ast_category_new_template(const char *name, const char *in_file, int lineno)
Create a category making it a template.
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
struct ast_category * ast_category_delete(struct ast_config *cfg, struct ast_category *cat)
Delete a category.
int ast_config_text_file_save2(const char *filename, const struct ast_config *cfg, const char *generator, uint32_t flags)
Save a config text file.
void ast_category_rename(struct ast_category *cat, const char *name)
int ast_variable_delete(struct ast_category *category, const char *variable, const char *match, const char *line)
#define CONFIG_STATUS_FILEMISSING
int ast_category_insert(struct ast_config *config, struct ast_category *cat, const char *match)
Inserts new category.
void ast_category_append(struct ast_config *config, struct ast_category *category)
Appends a category to a config.
void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
int ast_variable_update(struct ast_category *category, const char *variable, const char *value, const char *match, unsigned int object)
Update variable value within a config.
struct ast_variable * ast_variables_reverse(struct ast_variable *var)
Reverse a variable list.
int ast_realtime_enabled(void)
Check if there's any realtime engines loaded.
struct ast_category * ast_category_new(const char *name, const char *in_file, int lineno)
Create a category.
#define ast_variable_new(name, value, filename)
struct ast_str * ast_category_get_templates(const struct ast_category *category)
Return the template names this category inherits from.
#define CONFIG_STATUS_FILEUNCHANGED
@ CONFIG_SAVE_FLAG_PRESERVE_EFFECTIVE_CONTEXT
#define CONFIG_STATUS_FILEINVALID
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *p_result,...)
The argument parsing routine.
struct ast_variable * ast_variables_dup(struct ast_variable *var)
Duplicate variable list.
void ast_category_destroy(struct ast_category *cat)
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
int ast_category_empty(struct ast_category *category)
Removes and destroys all variables in a category.
int ast_category_is_template(const struct ast_category *category)
Check if category is a template.
@ CONFIG_FLAG_WITHCOMMENTS
@ CONFIG_FLAG_FILEUNCHANGED
struct ast_variable * ast_category_first(struct ast_category *cat)
given a pointer to a category, return the root variable.
void ast_variable_insert(struct ast_category *category, struct ast_variable *variable, const char *line)
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name, const char *filter)
Retrieve a category if it exists.
struct ast_category * ast_category_browse_filtered(struct ast_config *config, const char *category_name, struct ast_category *prev, const char *filter)
Browse categories with filters.
#define AST_FEATURE_MAX_LEN
int ast_get_builtin_feature(struct ast_channel *chan, const char *feature, char *buf, size_t len)
Get the DTMF code for a builtin feature.
char * ast_get_chan_features_atxferabort(struct ast_channel *chan)
Get the transfer configuration option atxferabort.
ast_frame_read_action
Actions to indicate to, and be handled on channel read.
@ AST_FRAME_READ_ACTION_SEND_TEXT
@ AST_FRAME_READ_ACTION_SEND_TEXT_DATA
@ AST_CONTROL_READ_ACTION
int ast_logger_rotate(void)
Reload logger while rotating log files.
#define ast_debug(level,...)
Log a DEBUG message.
#define VERBOSITY_ATLEAST(level)
#define ast_verb(level,...)
void ast_iostream_set_timeout_inactivity(struct ast_iostream *stream, int timeout)
Set the iostream inactivity timeout timer.
struct ast_iostream * ast_iostream_from_fd(int *fd)
Create an iostream from a file descriptor.
ssize_t ast_iostream_write(struct ast_iostream *stream, const void *buffer, size_t count)
Write data to an iostream.
int ast_iostream_get_fd(struct ast_iostream *stream)
Get an iostream's file descriptor.
void ast_iostream_set_exclusive_input(struct ast_iostream *stream, int exclusive_input)
Set the iostream if it can exclusively depend upon the set timeouts.
ssize_t ast_iostream_read(struct ast_iostream *stream, void *buffer, size_t count)
Read data from an iostream.
void ast_iostream_set_timeout_sequence(struct ast_iostream *stream, struct timeval start, int timeout)
Set the iostream I/O sequence timeout timer.
void ast_iostream_nonblock(struct ast_iostream *stream)
Make an iostream non-blocking.
int ast_iostream_close(struct ast_iostream *stream)
Close an iostream.
void ast_iostream_set_timeout_disable(struct ast_iostream *stream)
Disable the iostream timeout timer.
Asterisk JSON abstraction layer.
struct ast_json * ast_json_object_iter_value(struct ast_json_iter *iter)
Get the value from an iterator.
enum ast_json_type ast_json_typeof(const struct ast_json *value)
Get the type of value.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_json_iter * ast_json_object_iter_next(struct ast_json *object, struct ast_json_iter *iter)
Get the next iterator.
struct ast_json * ast_json_array_get(const struct ast_json *array, size_t index)
Get an element from an array.
struct ast_json_payload * ast_json_payload_create(struct ast_json *json)
Create an ao2 object to pass json blobs as data payloads for stasis.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
struct ast_json_iter * ast_json_object_iter(struct ast_json *object)
Get an iterator pointing to the first field in a JSON object.
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
const char * ast_json_object_iter_key(struct ast_json_iter *iter)
Get the key from an iterator.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
size_t ast_json_array_size(const struct ast_json *array)
Get the size of a JSON array.
int ast_json_is_null(const struct ast_json *value)
Check if value is JSON null.
A set of macros to manage forward-linked lists.
#define AST_RWLIST_REMOVE_CURRENT
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized.
#define AST_RWLIST_REMOVE_HEAD
#define AST_RWLIST_INSERT_AFTER
#define AST_RWLIST_REMOVE
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_RWLIST_TRAVERSE_SAFE_END
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_RWLIST_TRAVERSE
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_RWLIST_INSERT_HEAD
#define AST_RWLIST_INSERT_TAIL
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
Asterisk locking-related definitions:
#define AST_PTHREADT_NULL
#define ast_mutex_init(pmutex)
#define ast_mutex_unlock(a)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
#define ast_mutex_destroy(a)
#define ast_mutex_lock(a)
static int auth_mxml_http_callback(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
static int manager_subscriptions_init(void)
Initialize all Stasis Message Bus API topics and routers used by the various sub-components of AMI.
static struct ast_tls_config ami_tls_cfg
static void close_mansession_file(struct mansession *s)
static int ast_xml_doc_item_cmp_fn(const void *a, const void *b)
static struct ast_tcptls_session_args ami_desc
static struct ast_http_uri managerxmluri
const char * words[AST_MAX_CMD_LEN]
static char * handle_manager_show_events(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int manager_http_callback(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
int astman_verify_session_writepermissions(uint32_t ident, int perm)
Verify a session's write permissions against a permission mask.
static int __init_manager(int reload, int by_external_config)
static struct ast_tcptls_session_args amis_desc
static void xml_copy_escape(struct ast_str **out, const char *src, int mode)
static struct ast_custom_function managerclient_function
description of AMI_CLIENT dialplan function
static void purge_old_stuff(void *data)
cleanup code called at each iteration of server_root, guaranteed to happen every 5 seconds at most
struct ast_datastore * astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a session.
static struct mansession_session * find_session(uint32_t ident, int incinuse)
static int mxml_http_callback(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
int ast_str_append_event_header(struct ast_str **fields_string, const char *header, const char *value)
append an event header to an ast string
int astman_datastore_add(struct mansession *s, struct ast_datastore *datastore)
Add a datastore to a session.
static int variable_count_cmp_fn(void *obj, void *vstr, int flags)
static char * handle_manager_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager show settings.
static void manager_event_blob_dtor(void *obj)
static void load_channelvars(struct ast_variable *var)
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
static struct mansession_session * find_session_by_nonce(const char *username, unsigned long nonce, int *stale)
int astman_verify_session_readpermissions(uint32_t ident, int perm)
Verify a session's read permissions against a permission mask.
static struct ast_http_uri manageruri
static void manager_set_defaults(void)
static void manager_shutdown(void)
static void process_output(struct mansession *s, struct ast_str **out, struct ast_variable *params, enum output_format format)
static int rawman_http_callback(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
static char * handle_manager_show_event(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int function_amiclient(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
${AMI_CLIENT()} Dialplan function - reads manager client data
static int auth_rawman_http_callback(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
static int load_module(void)
static struct ast_http_uri arawmanuri
static void xml_translate(struct ast_str **out, char *in, struct ast_variable *get_vars, enum output_format format)
Convert the input into XML or HTML. The input is supposed to be a sequence of lines of the form Name:...
static int variable_count_hash_fn(const void *vvc, const int flags)
int astman_is_authed(uint32_t ident)
Determine if a manager session ident is authenticated.
static struct ast_http_uri rawmanuri
static struct ast_cli_entry cli_manager[]
static int unload_module(void)
static void manager_free_user(struct ast_manager_user *user)
static int auth_manager_http_callback(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
static int auth_http_callback(struct ast_tcptls_session_instance *ser, enum ast_http_method method, enum output_format format, const struct ast_sockaddr *remote_address, const char *uri, struct ast_variable *get_params, struct ast_variable *headers)
static struct ast_http_uri amanageruri
static int get_manager_sessions_cb(void *obj, void *arg, void *data, int flags)
Get number of logged in sessions for a login name.
static int subscribe_all(void)
static const char *const contenttype[]
static struct ast_http_uri amanagerxmluri
static int generic_http_callback(struct ast_tcptls_session_instance *ser, enum ast_http_method method, enum output_format format, const struct ast_sockaddr *remote_address, const char *uri, struct ast_variable *get_params, struct ast_variable *headers)
int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastore)
Remove a datastore from a session.
static void load_disabledevents(struct ast_variable *var)
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define EVENT_FLAG_VERBOSE
#define EVENT_FLAG_REPORTING
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
struct ast_str * ast_manager_build_channel_state_string(const struct ast_channel_snapshot *snapshot)
Generate the AMI message body from a channel snapshot.
int manager_mwi_init(void)
Initialize support for AMI MWI events.
#define EVENT_FLAG_CONFIG
int manager_bridging_init(void)
Initialize support for AMI channel events.
#define EVENT_FLAG_SYSTEM
#define EVENT_FLAG_SECURITY
int manager_endpoints_init(void)
Initialize support for AMI endpoint events.
void(* manager_hangup_handler_t)(struct ast_channel *chan, int causecode)
Callback used by ast_manager_hangup_helper that will actually hangup a channel.
int(* key_exclusion_cb)(const char *key)
Callback used to determine whether a key should be skipped when converting a JSON object to a manager...
struct stasis_message_type * ast_manager_get_generic_type(void)
Get the stasis_message_type for generic messages.
#define DEFAULT_MANAGER_PORT
int manager_system_init(void)
Initialize support for AMI system events.
#define EVENT_FLAG_HOOKRESPONSE
#define ast_manager_event_multichan(category, event, nchans, chans, contents,...)
#define DEFAULT_MANAGER_TLS_PORT
#define EVENT_FLAG_MESSAGE
#define EVENT_FLAG_COMMAND
int manager_channels_init(void)
Initialize support for AMI channel events.
#define EVENT_FLAG_DIALPLAN
#define EVENT_FLAG_ORIGINATE
struct ast_str * ast_manager_build_channel_state_string_prefix(const struct ast_channel_snapshot *snapshot, const char *prefix)
Generate the AMI message body from a channel snapshot.
int(* manager_hangup_cause_validator_t)(const char *channel_name, const char *cause)
Callback used by ast_manager_hangup_helper that will validate the cause code.
void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len)
void MD5Init(struct MD5Context *context)
void MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], struct MD5Context *context)
Out-of-call text message support.
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define ast_module_unref(mod)
Release a reference to the module.
int ast_module_check(const char *name)
Check if module with the name given is loaded.
int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode)
Unload a module.
enum ast_module_load_result ast_load_resource(const char *resource_name)
Load a module.
int ast_refresh_resource(const char *resource_name, enum ast_module_unload_mode force, int recursive)
Unload and load a module again.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
ast_module_reload_result
Possible return types for ast_module_reload.
@ AST_MODULE_RELOAD_IN_PROGRESS
@ AST_MODULE_RELOAD_QUEUED
@ AST_MODULE_RELOAD_SUCCESS
@ AST_MODULE_RELOAD_ERROR
@ AST_MODULE_RELOAD_NOT_IMPLEMENTED
@ AST_MODULE_RELOAD_NOT_FOUND
@ AST_MODULE_RELOAD_UNINITIALIZED
#define ast_module_running_ref(mod)
Hold a reference to the module if it is running.
@ AST_MODULE_LOAD_FAILURE
Module could not be loaded properly.
@ AST_MODULE_LOAD_SUCCESS
enum ast_module_reload_result ast_module_reload(const char *name)
Reload asterisk modules.
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized,...
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
static void ast_sockaddr_setnull(struct ast_sockaddr *addr)
Sets address addr to null.
struct timeval ast_lastreloadtime
struct timeval ast_startuptime
#define ast_opt_sounds_search_custom
Asterisk file paths, configured in asterisk.conf.
const char * ast_config_AST_RUN_GROUP
const char * ast_config_AST_RUN_USER
const char * ast_config_AST_MODULE_DIR
const char * ast_config_AST_CONFIG_DIR
const char * ast_config_AST_SYSTEM_NAME
Core PBX routines and definitions.
int ast_findlabel_extension(struct ast_channel *c, const char *context, const char *exten, const char *label, const char *callerid)
Find the priority of an extension that has the specified label.
int ast_pbx_outgoing_exten_predial(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, int early_media, const struct ast_assigned_ids *assignedids, const char *predial_callee)
const char * ast_extension_state2str(int extension_state)
Return string representation of the state of an extension.
int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, const struct ast_assigned_ids *assignedids)
Synchronously or asynchronously make an outbound call and execute an application on the channel.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, int early_media, const struct ast_assigned_ids *assignedids)
Synchronously or asynchronously make an outbound call and send it to a particular extension.
int ast_processed_calls(void)
Retrieve the total number of calls processed through the PBX since last restart.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_func_read(struct ast_channel *chan, const char *function, char *workspace, size_t len)
executes a read operation on a function
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp)
Retrieve the value of a builtin variable or variable from the channel variable stack.
@ AST_HINT_UPDATE_PRESENCE
int ast_extension_state_add(const char *context, const char *exten, ast_state_cb_type change_cb, void *data)
Add watcher for extension states.
int ast_get_hint(char *hint, int hintsize, char *name, int namesize, struct ast_channel *c, const char *context, const char *exten)
If an extension hint exists, return non-zero.
int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
int ast_extension_state(struct ast_channel *c, const char *context, const char *exten)
Uses hint and devicestate callback to get the state of an extension.
Presence state management.
const char * ast_presence_state2str(enum ast_presence_state state)
Convert presence state to text string for output.
static struct stasis_subscription * sub
Statsd channel stats. Exmaple of how to subscribe to Stasis events.
Pluggable RTP Architecture.
struct stasis_topic * ast_rtp_topic(void)
Stasis Message Bus API topic for RTP and RTCP related messages
Security Event Reporting API.
int ast_security_event_report(const struct ast_security_event_common *sec)
Report a security event.
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
#define AST_SECURITY_EVENT_CHAL_RESP_FAILED_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_SESSION_LIMIT_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_REQ_NOT_ALLOWED_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_REQ_BAD_FORMAT_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_FAILED_ACL_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_INVAL_PASSWORD_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_INVAL_ACCT_ID_VERSION
Event descriptor version.
@ AST_SECURITY_EVENT_INVAL_PASSWORD
An attempt at basic password authentication failed.
@ AST_SECURITY_EVENT_SESSION_LIMIT
Session limit reached.
@ AST_SECURITY_EVENT_FAILED_ACL
Failed ACL.
@ AST_SECURITY_EVENT_REQ_NOT_ALLOWED
A request was made that is not allowed.
@ AST_SECURITY_EVENT_CHAL_RESP_FAILED
An attempt at challenge/response authentication failed.
@ AST_SECURITY_EVENT_REQ_BAD_FORMAT
Request received with bad formatting.
@ AST_SECURITY_EVENT_SUCCESSFUL_AUTH
FYI FWIW, Successful authentication has occurred.
@ AST_SECURITY_EVENT_INVAL_ACCT_ID
Invalid Account ID.
#define AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION
Event descriptor version.
struct ast_manager_event_blob * stasis_message_to_ami(struct stasis_message *msg)
Build the AMI representation of the message.
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
@ STASIS_SUBSCRIPTION_FILTER_SELECTIVE
struct stasis_forward * stasis_forward_cancel(struct stasis_forward *forward)
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
@ STASIS_SUBSCRIPTION_FORMATTER_AMI
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
#define STASIS_MESSAGE_TYPE_DEFN(name,...)
Boiler-plate messaging macro for defining public message types.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
struct stasis_forward * stasis_forward_all(struct stasis_topic *from_topic, struct stasis_topic *to_topic)
Create a subscription which forwards all messages from one topic to another.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
#define stasis_subscribe(topic, callback, data)
int stasis_message_can_be_ami(struct stasis_message *msg)
Determine if the given message can be converted to AMI.
struct ast_bridge_snapshot * ast_bridge_get_snapshot_by_uniqueid(const char *bridge_id)
Returns the current snapshot for the bridge.
int stasis_message_router_set_congestion_limits(struct stasis_message_router *router, long low_water, long high_water)
Set the high and low alert water marks of the stasis message router.
#define stasis_message_router_create(topic)
Create a new message router object.
int stasis_message_router_add(struct stasis_message_router *router, struct stasis_message_type *message_type, stasis_subscription_cb callback, void *data)
Add a route to a message router.
void stasis_message_router_unsubscribe_and_join(struct stasis_message_router *router)
Unsubscribe the router from the upstream topic, blocking until the final message has been processed.
void stasis_message_router_set_formatters_default(struct stasis_message_router *router, stasis_subscription_cb callback, void *data, enum stasis_subscription_message_formatters formatters)
Sets the default route of a router with formatters.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define ast_string_field_ptr_build_va(x, ptr, fmt, args)
Set a field to a complex (built) value with prebuilt va_lists.
#define AST_STRING_FIELD(name)
Declare a string field.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
#define ast_string_field_init_extended(x, field)
Initialize an extended string field.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
String manipulation functions.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
int ast_str_set_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap)
Set a dynamic string from a va_list.
size_t attribute_pure ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
static int force_inline attribute_pure ast_ends_with(const char *str, const char *suffix)
Checks whether a string ends with another.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"....
@ AST_DYNSTR_BUILD_FAILED
#define ast_str_alloca(init_len)
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
int ast_in_delimited_string(const char *needle, const char *haystack, char delim)
Check if there is an exact match for 'needle' between delimiters in 'haystack'.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
int ast_str_append_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap)
Append to a dynamic string using a va_list.
char * ast_read_line_from_buffer(char **buffer)
Read lines from a string buffer.
#define AST_YESNO(x)
return Yes or No depending on the argument.
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
char * ast_escape_c_alloc(const char *s)
Escape standard 'C' sequences in the given string.
struct ao2_container * ast_str_container_alloc_options(enum ao2_alloc_opts opts, int buckets)
Allocates a hash container for bare strings.
int ast_str_container_add(struct ao2_container *str_container, const char *add)
Adds a string to a string container allocated by ast_str_container_alloc.
char * ast_strsep(char **s, const char sep, uint32_t flags)
Act like strsep but ignore separators inside quotes.
char *attribute_pure ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
int ast_regex_string_to_regex_pattern(const char *regex_string, struct ast_str **regex_pattern)
Given a string regex_string in the form of "/regex/", convert it into the form of "regex".
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
list of actions registered
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Wrapper for an ast_acl linked list.
Structure to pass both assignedid values to channel drivers.
Structure that contains a snapshot of information about a bridge.
struct ao2_container * channels
Structure that contains information about a bridge.
const ast_string_field uniqueid
struct ast_category * prev
char * file
The file name from whence this declaration was read.
struct timeval creationtime
const ast_string_field uniqueid
const ast_string_field name
const ast_string_field data
const ast_string_field appl
Structure representing a snapshot of channel state.
struct ast_channel_snapshot_dialplan * dialplan
struct ast_channel_snapshot_bridge * bridge
struct ast_channel_snapshot_base * base
Structure to describe a channel "technology", ie a channel driver See for examples:
Main Channel structure associated with a channel.
descriptor for a cli entry.
enum ast_frame_read_action action
Data structure associated with a custom dialplan function.
Structure for a data store type.
Structure for a data store object.
const struct ast_datastore_info * info
struct ast_datastore::@227 entry
Structure used to handle boolean flags.
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
HTTP authentication information.
Definition of a URI handler.
Iterator for JSON object key/values.
Abstract JSON element (object, array, string, int, ...).
Struct containing info for an AMI event to send out.
const ast_string_field extra_fields
const char * manager_event
user descriptor, as read from the config file.
struct ast_variable * chanvars
struct ao2_container * excludefilters
struct ast_acl_list * acl
struct ao2_container * includefilters
struct ast_manager_user::@402 list
Structure used to transport a message through the frame core.
Structure for mutex and tracking information.
Information needed to identify an endpoint in a call.
struct ast_party_name name
Subscriber name.
struct ast_party_number number
Subscriber phone number.
unsigned char valid
TRUE if the name information is valid/present.
char * str
Subscriber name (Malloced)
unsigned char valid
TRUE if the number information is valid/present.
char * str
Subscriber phone number (Malloced)
An attempt at challenge/response auth failed.
const char * response
Response received.
struct ast_security_event_common common
Common security event descriptor elements.
const char * expected_response
Response expected to be received.
enum ast_security_event_type event_type
The security event sub-type.
Checking against an IP access control list failed.
struct ast_security_event_common common
Common security event descriptor elements.
Invalid account ID specified (invalid username, for example)
struct ast_security_event_common common
Common security event descriptor elements.
An attempt at basic password auth failed.
struct ast_security_event_common common
Common security event descriptor elements.
Request denied because it's not allowed.
struct ast_security_event_common common
Common security event descriptor elements.
const char * request_type
Request type that was made.
Request denied because of a session limit.
struct ast_security_event_common common
Common security event descriptor elements.
Successful authentication.
struct ast_security_event_common common
Common security event descriptor elements.
Socket address structure.
Support for dynamic strings.
arguments for the accepting thread
struct ast_sockaddr local_address
struct ast_tls_config * tls_cfg
describes a server instance
struct ast_iostream * stream
struct ast_sockaddr remote_address
struct ast_tcptls_session_args * parent
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
Struct that contains the XML documentation for a particular item. Note that this is an ao2 ref counte...
struct ast_xml_doc_item * next
struct ast_str * arguments
struct ast_str * description
const ast_string_field name
struct ast_str * synopsis
unsigned int event_name_hash
enum event_filter_match_type match_type
struct eventqent::@400 eq_next
helper function for originate
struct ast_variable * vars
struct ast_format_cap * cap
struct ast_module *enum ast_doc_src docsrc
struct manager_action::@253 list
const ast_string_field description
struct ast_xml_doc_item * final_response
const ast_string_field synopsis
int(* func)(struct mansession *s, const struct message *m)
const ast_string_field seealso
const ast_string_field syntax
unsigned int registered
TRUE if the AMI action is registered and the callback can be called.
const ast_string_field arguments
struct ast_xml_doc_item * list_responses
struct ast_variable * chanvars
struct ao2_container * excludefilters
struct ast_iostream * stream
struct timeval sessionstart_tv
struct eventqent * last_ev
struct mansession_session::mansession_datastores datastores
struct ao2_container * includefilters
struct mansession_session::@401 list
In case you didn't read that giant block of text above the mansession_session struct,...
struct ast_iostream * stream
struct manager_custom_hook * hook
struct mansession_session * session
enum mansession_message_parsing parsing
struct ast_tcptls_session_instance * tcptls_session
const char * headers[AST_MAX_MANHEADERS]
structure to hold users read from phoneprov_users.conf
list of users found in the config file
An API for managing task processing threads that can be shared across modules.
#define AST_TASKPROCESSOR_HIGH_WATER_LEVEL
Generic support for tcp/tls servers in Asterisk.
void * ast_tcptls_server_root(void *)
void ast_tcptls_server_stop(struct ast_tcptls_session_args *desc)
Shutdown a running server if there is one.
int ast_ssl_setup(struct ast_tls_config *cfg)
Set up an SSL server.
void ast_tcptls_server_start(struct ast_tcptls_session_args *desc)
This is a generic (re)start routine for a TCP server, which does the socket/bind/listen and starts a ...
int ast_tls_read_conf(struct ast_tls_config *tls_cfg, struct ast_tcptls_session_args *tls_desc, const char *varname, const char *value)
Used to parse conf files containing tls/ssl options.
Handy terminal functions for vt* terms.
const char * ast_term_reset(void)
Returns the terminal reset code.
const char * ast_term_color(int fgcolor, int bgcolor)
Return a color sequence string.
char * term_strip(char *outbuf, const char *inbuf, int maxout)
Remove colorings from a specified string.
#define COLORIZE(fg, bg, str)
#define COLORIZE_FMT
Shortcut macros for coloring a set of text.
#define ast_test_debug(test, fmt,...)
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
#define AST_TEST_DEFINE(hdr)
static struct aco_type item
Definitions to aid in the use of thread local storage.
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
int64_t ast_tvdiff_sec(struct timeval end, struct timeval start)
Computes the difference (in seconds) between two struct timeval instances.
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Support for translation of data formats. translate.c.
const char * ast_translate_path_to_str(struct ast_trans_pvt *t, struct ast_str **str)
Puts a string representation of the translation path into outbuf.
int error(const char *format,...)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
int ast_wait_for_input(int fd, int ms)
int ast_parse_digest(const char *digest, struct ast_http_digest *d, int request, int pedantic)
Parse digest authorization header.
long int ast_random(void)
#define ast_pthread_create_detached(a, b, c, d)
#define ast_set_flag(p, flag)
void ast_md5_hash(char *output, const char *input)
Produces MD5 hash based on input string.
struct ast_xml_doc_item * ast_xmldoc_build_list_responses(const char *type, const char *name, const char *module)
Generate the [list responses] tag based on type of node ('application', 'function' or 'agi') and name...
char * ast_xmldoc_build_description(const char *type, const char *name, const char *module)
Generate description documentation from XML.
char * ast_xmldoc_build_syntax(const char *type, const char *name, const char *module)
Get the syntax for a specified application or function.
char * ast_xmldoc_build_arguments(const char *type, const char *name, const char *module)
Generate the [arguments] tag based on type of node ('application', 'function' or 'agi') and name.
char * ast_xmldoc_build_synopsis(const char *type, const char *name, const char *module)
Generate synopsis documentation from XML.
char * ast_xmldoc_build_since(const char *type, const char *name, const char *module)
Parse the <since> node content.
struct ao2_container * ast_xmldoc_build_documentation(const char *type)
Build the documentation for a particular source type.
char * ast_xmldoc_build_seealso(const char *type, const char *name, const char *module)
Parse the <see-also> node content.
char * ast_xmldoc_printable(const char *bwinput, int withcolors)
Colorize and put delimiters (instead of tags) to the xmldoc output.
struct ast_xml_doc_item * ast_xmldoc_build_final_response(const char *type, const char *name, const char *module)
Generate the [final response] tag based on type of node ('application', 'function' or 'agi') and name...