163#define DEFAULT_REALM "asterisk"
191#define MGR_SHOW_TERMINAL_WIDTH 80
196#define EVENT_FLAG_SHUTDOWN -1
208#define MAX_BLACKLIST_CMD_LEN 2
212 {{
"module",
"load",
NULL }},
213 {{
"module",
"unload",
NULL }},
214 {{
"restart",
"gracefully",
NULL }},
405 const char *filter_pattern,
struct ao2_container *includefilters,
432 ao2_t_ref(act, +1,
"found action object");
477 size_t index,
struct ast_str **res,
487 const char *parent_key,
struct ast_str **res,
492 ast_str_set(&key_str, 0,
"%s/%s", parent_key, key);
515 if (exclusion_cb && key && exclusion_cb(key)) {
529 key, j, res, exclusion_cb);
538 key, res, exclusion_cb);
553#define manager_event_sessions(sessions, category, event, contents , ...) \
554 __manager_event_sessions(sessions, category, event, 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__)
556#define any_manager_listeners(sessions) \
557 ((sessions && ao2_container_count(sessions)) || !AST_RWLIST_EMPTY(&manager_hooks))
650 "class_type", class_type,
725#define MAX_AUTH_PERM_STRING 150
732 strstr(evaluating,
"SHELL") ||
733 strstr(evaluating,
"EVAL")
774 if (authority &
perms[i].num) {
794static int ast_instring(
const char *bigstr,
const char *smallstr,
const char delim)
796 const char *
val = bigstr, *next;
799 if ((next = strchr(
val, delim))) {
800 if (!strncmp(
val, smallstr, (next -
val))) {
806 return !strcmp(smallstr,
val);
808 }
while (*(
val = (next + 1)));
842 for (p =
string; *p; p++) {
843 if (*p <
'0' || *p >
'9') {
869 ast_debug(1,
"Mansession: %p refcount now %d\n", s, refcount - 1);
895 pthread_kill(
session->http_thread, SIGURG);
917 ao2_t_ref(
session->includefilters, -1,
"decrement ref for include container, should be last one");
921 ao2_t_ref(
session->excludefilters, -1,
"decrement ref for exclude container, should be last one");
1024 if (!strcasecmp(
user->username,
name)) {
1043 ret =
user->displayconnects;
1060 const char *auth_str;
1064 e->
command =
"manager show command";
1066 "Usage: manager show command <actionname> [<actionname> [<actionname> [...]]]\n"
1067 " Shows the detailed description for a specific Asterisk manager interface command.\n";
1070 l = strlen(
a->word);
1073 if (!strncasecmp(
a->word, cur->
action, l)) {
1090 for (num = 3; num <
a->argc; num++) {
1091 if (!strcasecmp(cur->
action,
a->argv[num])) {
1106 if (!
synopsis || !provided_by || !since || !description || !syntax || !arguments
1107 || !privilege || !seealso || !responses) {
1117 ast_cli(
a->fd,
"Allocation failure.\n");
1124 "%s -= Info about Manager Command '%s' =- %s\n\n"
1155 ast_cli(
a->fd,
"%s\n\n", responses);
1173 ast_cli(
a->fd,
"%s\n\n", responses);
1195 ast_cli(
a->fd,
"Action: %s\nSynopsis: %s\nPrivilege: %s\n%s\n",
1212 e->
command =
"manager set debug [on|off]";
1213 e->
usage =
"Usage: manager set debug [on|off]\n Show, enable, disable debugging of the manager code.\n";
1221 }
else if (
a->argc == 4) {
1222 if (!strcasecmp(
a->argv[3],
"on")) {
1224 }
else if (!strcasecmp(
a->argv[3],
"off")) {
1243 e->
command =
"manager show user";
1245 " Usage: manager show user <user>\n"
1246 " Display all information related to the manager user specified.\n";
1249 l = strlen(
a->word);
1255 if (!strncasecmp(
a->word,
user->username, l)) {
1272 ast_cli(
a->fd,
"There is no manager called %s\n",
a->argv[3]);
1284 " displayconnects: %s\n"
1285 "allowmultiplelogin: %s\n",
1287 (
user->secret ?
"<Set>" :
"(N/A)"),
1291 (
user->displayconnects ?
"yes" :
"no"),
1292 (
user->allowmultiplelogin ?
"yes" :
"no"));
1294 for (v =
user->chanvars ; v ; v = v->
next) {
1312 e->
command =
"manager show users";
1314 "Usage: manager show users\n"
1315 " Prints a listing of all managers that are currently configured on that\n"
1329 ast_cli(
a->fd,
"There are no manager users.\n");
1334 ast_cli(
a->fd,
"\nusername\n--------\n");
1343 ast_cli(
a->fd,
"-------------------\n"
1344 "%d manager users configured.\n", count_amu);
1353 int space_remaining;
1354#define HSMC_FORMAT " %-*.*s %-.*s\n"
1357 e->
command =
"manager show commands";
1359 "Usage: manager show commands\n"
1360 " Prints a listing of all the available Asterisk manager interface commands.\n";
1368 int incoming_len = strlen(cur->
action);
1369 if (incoming_len > name_len) {
1370 name_len = incoming_len;
1375 if (space_remaining < 0) {
1376 space_remaining = 0;
1401 e->
command =
"manager kick session";
1403 "Usage: manager kick session <file descriptor>\n"
1404 " Kick an active Asterisk Manager Interface session\n";
1414 fd = atoi(
a->argv[3]);
1416 ast_cli(
a->fd,
"Invalid AMI file descriptor: %s\n",
a->argv[3]);
1429 ast_cli(
a->fd,
"Manager session using file descriptor %d has already been kicked\n", fd);
1436 ast_cli(
a->fd,
"Kicking manager session connected using file descriptor %d\n", fd);
1451 ast_cli(
a->fd,
"No manager session found using file descriptor %d\n", fd);
1461 time_t now = time(
NULL);
1462#define HSMCONN_FORMAT1 " %-15.15s %-55.55s %-10.10s %-10.10s %-8.8s %-8.8s %-10.10s %-10.10s\n"
1463#define HSMCONN_FORMAT2 " %-15.15s %-55.55s %-10d %-10d %-8d %-8d %-10.10d %-10.10d\n"
1469 e->
command =
"manager show connected";
1471 "Usage: manager show connected\n"
1472 " Prints a listing of the users that are currently connected to the\n"
1473 "Asterisk manager interface.\n";
1479 ast_cli(
a->fd,
HSMCONN_FORMAT1,
"Username",
"IP Address",
"Start",
"Elapsed",
"FileDes",
"HttpCnt",
"ReadPerms",
"WritePerms");
1489 (
int) (
session->sessionstart),
1490 (
int) (now -
session->sessionstart),
1501 ast_cli(
a->fd,
"%d users connected.\n", count);
1513 e->
command =
"manager reload";
1515 "Usage: manager reload\n"
1516 " Reloads the manager configuration.\n";
1528#define GET_HEADER_FIRST_MATCH 0
1529#define GET_HEADER_LAST_MATCH 1
1530#define GET_HEADER_SKIP_EMPTY 2
1547 int x, l = strlen(
var);
1554 for (x = 0; x < m->
hdrcount; x++) {
1555 const char *h = m->
headers[x];
1556 if (!strncasecmp(
var, h, l) && h[l] ==
':') {
1557 const char *
value = h + l + 1;
1640 for (y = 0; y <
args.argc; y++) {
1645 if (!
args.vars[y]) {
1680 static const char var_hdr[] =
"Variable:";
1683 varlen = strlen(var_hdr);
1684 for (x = 0; x < m->
hdrcount; x++) {
1685 if (strncasecmp(var_hdr, m->
headers[x], varlen)) {
1722 curlen = strlen(src);
1723 for (x = 0; x < curlen; x++) {
1725 if (src[x] ==
'\r' && x+1 < curlen && src[x+1] ==
'\n')
1727 else if (src[x] ==
'\n')
1746 if (!strcasecmp(action,
"login")) {
1769 if (!act_found->module || mod_ref) {
1770 ret = act_found->
func(&s, &m);
1776 ao2_t_ref(act_found, -1,
"done with found action object");
1828#define ASTMAN_APPEND_BUF_INITSIZE 256
1835 ast_verbose(
"No connection stream in astman_append, should not happen\n");
1862 ast_verbose(
"No connection stream in astman_append, should not happen\n");
1876#define MSG_MOREDATA ((char *)astman_send_response)
1983 "EventList: Complete\r\n"
1984 "ListItems: %d\r\n",
2050 char session_id[32];
2054 .common.service =
"AMI",
2055 .common.account_id = username,
2057 .common.local_addr = {
2061 .common.remote_addr = {
2065 .common.session_id = session_id,
2068 snprintf(session_id,
sizeof(session_id),
"%p", s);
2075 char session_id[32];
2079 .common.service =
"AMI",
2080 .common.account_id = username,
2082 .common.local_addr = {
2086 .common.remote_addr = {
2090 .common.session_id = session_id,
2093 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2100 char session_id[32];
2104 .common.service =
"AMI",
2105 .common.account_id = username,
2107 .common.local_addr = {
2111 .common.remote_addr = {
2115 .common.session_id = session_id,
2118 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2125 char session_id[32];
2129 .common.service =
"AMI",
2132 .common.local_addr = {
2136 .common.remote_addr = {
2140 .common.session_id = session_id,
2143 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2150 char session_id[32];
2151 char request_type[64];
2155 .common.service =
"AMI",
2158 .common.local_addr = {
2162 .common.remote_addr = {
2166 .common.session_id = session_id,
2171 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2179 char session_id[32];
2184 .common.service =
"AMI",
2187 .common.local_addr = {
2191 .common.remote_addr = {
2195 .common.session_id = session_id,
2200 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2207 const char *response,
const char *expected_response)
2209 char session_id[32];
2213 .common.service =
"AMI",
2216 .common.local_addr = {
2220 .common.remote_addr = {
2224 .common.session_id = session_id,
2231 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2238 char session_id[32];
2242 .common.service =
"AMI",
2245 .common.local_addr = {
2249 .common.remote_addr = {
2253 .common.session_id = session_id,
2256 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2274 regex_t *regex_filter;
2296 char md5key[256] =
"";
2298 unsigned char digest[16];
2304 for (x = 0; x < 16; x++)
2305 len += sprintf(md5key +
len,
"%02hhx", digest[x]);
2306 if (!strcmp(md5key, key)) {
2312 ast_debug(1,
"MD5 authentication is not possible. challenge: '%s'\n",
2315 }
else if (
user->secret) {
2316 if (!strcmp(password,
user->secret)) {
2338 if (
user->chanvars) {
2345 ao2_t_ref(regex_filter, -1,
"remove iterator ref");
2352 ao2_t_ref(regex_filter, -1,
"remove iterator ref");
2388 "Timestamp: %ld.%06lu\r\n"
2390 (
long) now.tv_sec, (
unsigned long) now.tv_usec);
2417 char *stripped_filename;
2428 if (stripped_filename[0] ==
'/') {
2429 real_path = realpath(stripped_filename,
NULL);
2434 real_path = realpath(path,
NULL);
2454 const char *category_name;
2471 }
else if (ret == -1) {
2491 astman_append(s,
"Category-%06d: %s\r\n", catcount, category_name);
2539 }
else if (ret == -1) {
2558 if (catcount == 0) {
2572 if (*
in ==
'\\' || *
in ==
'\"') {
2603 const char *category_name;
2679 for (x = 0; x < 100000; x++) {
2680 unsigned int object = 0;
2684 int ignoreerror = 0;
2692 snprintf(hdr,
sizeof(hdr),
"Action-%06d", x);
2697 snprintf(hdr,
sizeof(hdr),
"Cat-%06d", x);
2704 snprintf(hdr,
sizeof(hdr),
"Var-%06d", x);
2707 snprintf(hdr,
sizeof(hdr),
"Value-%06d", x);
2715 snprintf(hdr,
sizeof(hdr),
"Match-%06d", x);
2718 snprintf(hdr,
sizeof(hdr),
"Line-%06d", x);
2721 snprintf(hdr,
sizeof(hdr),
"Options-%06d", x);
2728 if (!strcasecmp(
"allowdups", token)) {
2732 if (!strcasecmp(
"template", token)) {
2736 if (!strcasecmp(
"ignoreerror", token)) {
2759 if (!strcasecmp(action,
"newcat")) {
2761 char *tmpl_name =
NULL;
2801 if (category !=
NULL) {
2812 }
else if (!strcasecmp(action,
"renamecat")) {
2828 }
else if (!strcasecmp(action,
"delcat")) {
2835 if (!foundcat && !ignoreerror) {
2839 }
else if (!strcasecmp(action,
"emptycat")) {
2850 }
else if (!strcasecmp(action,
"update")) {
2874 }
else if (!strcasecmp(action,
"delete")) {
2894 if (!foundvar && !ignoreerror) {
2898 }
else if (!strcasecmp(action,
"append")) {
2910 if (
object || (
match && !strcasecmp(
match,
"object"))) {
2921 }
else if (!strcasecmp(action,
"insert")) {
2961 const char *preserve_effective_context_string =
astman_get_header(m,
"PreserveEffectiveContext");
3048 char *stripped_filename;
3062 if (stripped_filename[0] !=
'/') {
3081 filename = strrchr(filepath,
'/');
3090 real_dir = realpath(filepath,
NULL);
3103 if (
ast_asprintf(&real_path,
"%s/%s", real_dir, filename) == -1) {
3108 if ((fd = open(real_path, O_CREAT | O_EXCL,
AST_FILE_MODE)) != -1) {
3120 struct pollfd pfds[2];
3122 size_t events_count;
3126 memset(pfds, 0,
sizeof(pfds));
3128 pfds[0].events = POLLIN | POLLPRI;
3130 pfds[1].events = POLLIN | POLLPRI;
3132 ast_debug(1,
"Starting waiting for an event!\n");
3134 for (x = 0; x < timeout || timeout < 0; x++) {
3150 if (pfds[1].revents) {
3153 ast_debug(1,
"Manager session has been kicked\n");
3162 if (pfds[0].revents) {
3167 ast_debug(1,
"Finished waiting for an event!\n");
3178 for (x = 0; x < events_count; x++) {
3190 "Event: WaitEventComplete\r\n"
3203 int max, needexit = 0, x;
3224 if (timeout < 0 || timeout >
max) {
3235 ast_debug(1,
"Starting waiting for an event!\n");
3237 for (x = 0; x < timeout || timeout < 0; x++) {
3264 ast_debug(1,
"Finished waiting for an event!\n");
3268 size_t events_count;
3282 for (x = 0; x < events_count; x++) {
3293 "Event: WaitEventComplete\r\n"
3300 ast_debug(1,
"Abandoning event request!\n");
3314 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n",
id);
3320 sscanf(timeouts,
"%30i", &timeout);
3361 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n",
id);
3373 if (!strcasecmp(
perms[x].label,
"all") && res ==
perms[x].
num) {
3378 "Events: On\r\n\r\n", id_text);
3379 }
else if (res == 0)
3381 "Events: Off\r\n\r\n", id_text);
3387 "Events: On\r\n\r\n", id_text);
3390 "Events: Off\r\n\r\n", id_text);
3428 long lastreloaded = 0;
3434 uptime = tmp.tv_sec;
3439 lastreloaded = tmp.tv_sec;
3445 "LastReload: %ld\r\n"
3446 "Status: Fully Booted\r\n\r\n", cat_str, uptime, lastreloaded);
3455 if (!strcasecmp(authtype,
"MD5")) {
3482 int channels_matched = 0;
3490 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n",
id);
3495 if (cause_validator) {
3496 causecode = cause_validator(name_or_regex, cause);
3499 causecode = strtol(cause, &endptr, 10);
3500 if (causecode < 0 || causecode > 127 || *endptr !=
'\0') {
3510 if (name_or_regex[0] !=
'/') {
3518 ast_verb(3,
"%sManager '%s' from %s, hanging up channel: %s\n",
3524 hangup_handler(
c, causecode);
3536 if (!regex_string) {
3543 astman_send_error(s, m,
"Regex format invalid, Channel param should be /regex/");
3549 if (regcomp(®exbuf,
ast_str_buffer(regex_string), REG_EXTENDED | REG_NOSUB)) {
3564 ast_verb(3,
"%sManager '%s' from %s, hanging up channel: %s\n",
3570 hangup_handler(
c, causecode);
3574 "Event: ChannelHungup\r\n"
3635 char workspace[1024];
3655 workspace[0] =
'\0';
3656 if (varname[strlen(varname) - 1] ==
')') {
3660 ast_func_read(
c, (
char *) varname, workspace,
sizeof(workspace));
3662 ast_log(
LOG_ERROR,
"Unable to allocate bogus channel for variable substitution. Function results may be blank.\n");
3664 ast_func_read(
c, (
char *) varname, workspace,
sizeof(workspace));
3676 astman_append(s,
"Variable: %s\r\nValue: %s\r\n\r\n", varname,
S_OR(varval,
""));
3684 long elapsed_seconds;
3702 if (!snapshot_str) {
3706 if (all_variables) {
3711 if (!variable_str) {
3720 for (i = 0; i < varc; i++) {
3721 char valbuf[512], *ret =
NULL;
3723 if (vars[i][strlen(vars[i]) - 1] ==
')') {
3724 if (
ast_func_read(chan, vars[i], valbuf,
sizeof(valbuf)) < 0) {
3732 ast_str_append(&variable_str, 0,
"Variable: %s=%s\r\n", vars[i], ret);
3736 if (all_variables) {
3750 "Privilege: Call\r\n"
3754 "EffectiveConnectedLineNum: %s\r\n"
3755 "EffectiveConnectedLineName: %s\r\n"
3756 "TimeToHangup: %ld\r\n"
3758 "Application: %s\r\n"
3760 "Nativeformats: %s\r\n"
3761 "Readformat: %s\r\n"
3763 "Writeformat: %s\r\n"
3764 "Writetrans: %s\r\n"
3765 "Callgroup: %llu\r\n"
3766 "Pickupgroup: %llu\r\n"
3787 (long)elapsed_seconds,
3801 int all_variables = 0;
3814 all_variables =
ast_true(all_chan_variables);
3839 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n",
id);
3891 obj_size = payload_size +
sizeof(*obj);
3900 memcpy(obj->
payload, payload, payload_size);
3934 const char *content_type)
4037 if (sscanf(
priority,
"%30d", &pi) != 1) {
4055 if (sscanf(priority2,
"%30d", &pi2) != 1) {
4066 snprintf(
buf,
sizeof(
buf),
"Channel does not exist: %s",
name);
4090 snprintf(
buf,
sizeof(
buf),
"ExtraChannel does not exist: %s", name2);
4267 if (!feature_code) {
4289 char *cmd_copy, *cur_cmd;
4301 cmd_words[i] = cur_cmd;
4326 char *
buf =
NULL, *final_buf =
NULL, *delim, *output;
4327 char template[] =
"/tmp/ast-ami-XXXXXX";
4341 if ((fd = mkstemp(
template)) < 0) {
4350 if ((
len = lseek(fd, 0, SEEK_END)) < 0) {
4351 astman_append(s,
"Message: Failed to determine number of characters: %s\r\n", strerror(
errno));
4352 goto action_command_cleanup;
4359 if (!
buf || !final_buf) {
4361 goto action_command_cleanup;
4364 if (lseek(fd, 0, SEEK_SET) < 0) {
4365 astman_append(s,
"Message: Failed to set position on temporary file: %s\r\n", strerror(
errno));
4366 goto action_command_cleanup;
4369 if (read(fd,
buf,
len) < 0) {
4370 astman_append(s,
"Message: Failed to read from temporary file: %s\r\n", strerror(
errno));
4371 goto action_command_cleanup;
4376 final_buf[
len] =
'\0';
4379 if (
len && final_buf[
len - 1] ==
'\n') {
4380 final_buf[
len - 1] =
'\0';
4386 while ((output =
strsep(&delim,
"\n"))) {
4390action_command_cleanup:
4448 .uniqueid2 =
in->otherchannelid
4453 in->timeout,
in->app,
in->appdata, &reason,
4457 in->vars,
in->account, &chan, &assignedids);
4460 in->timeout,
in->context,
in->exten,
in->priority, &reason,
4464 in->vars,
in->account, &chan,
in->early_media, &assignedids);
4477 "Application: %s\r\n"
4481 "CallerIDNum: %s\r\n"
4482 "CallerIDName: %s\r\n",
4483 in->idtext, res ?
"Failure" :
"Success",
4485 in->app,
in->appdata, reason,
4487 S_OR(
in->cid_num,
"<unknown>"),
4488 S_OR(
in->cid_name,
"<unknown>")
4499 "CallerIDNum: %s\r\n"
4500 "CallerIDName: %s\r\n",
4501 in->idtext, res ?
"Failure" :
"Success",
4503 in->context,
in->exten, reason,
4505 S_OR(
in->cid_num,
"<unknown>"),
4506 S_OR(
in->cid_name,
"<unknown>")
4521 const char *unitamount;
4522 const char *unittype;
4525 memset(entry, 0,
sizeof(*entry));
4554 const char *association_num =
astman_get_header(m,
"ChargingAssociationNumber");
4562 unsigned int _currencyamount = 0;
4563 int _association_id = 0;
4564 unsigned int _association_plan = 0;
4570 goto aocmessage_cleanup;
4575 if (!strcasecmp(chargetype,
"NA")) {
4577 }
else if (!strcasecmp(chargetype,
"Free")) {
4579 }
else if (!strcasecmp(chargetype,
"Currency")) {
4581 }
else if (!strcasecmp(chargetype,
"Unit")) {
4585 goto aocmessage_cleanup;
4590 if (
ast_strlen_zero(currencyamount) || (sscanf(currencyamount,
"%30u", &_currencyamount) != 1)) {
4591 astman_send_error(s, m,
"Invalid CurrencyAmount, CurrencyAmount is a required when ChargeType is Currency");
4592 goto aocmessage_cleanup;
4596 astman_send_error(s, m,
"ChargeMultiplier unspecified, ChargeMultiplier is required when ChargeType is Currency.");
4597 goto aocmessage_cleanup;
4598 }
else if (!strcasecmp(mult,
"onethousandth")) {
4600 }
else if (!strcasecmp(mult,
"onehundredth")) {
4602 }
else if (!strcasecmp(mult,
"onetenth")) {
4604 }
else if (!strcasecmp(mult,
"one")) {
4606 }
else if (!strcasecmp(mult,
"ten")) {
4608 }
else if (!strcasecmp(mult,
"hundred")) {
4610 }
else if (!strcasecmp(mult,
"thousand")) {
4614 goto aocmessage_cleanup;
4621 goto aocmessage_cleanup;
4625 if (!
ast_strlen_zero(totaltype) && !strcasecmp(totaltype,
"subtotal")) {
4631 }
else if (!strcasecmp(aocbillingid,
"Normal")) {
4633 }
else if (!strcasecmp(aocbillingid,
"ReverseCharge")) {
4635 }
else if (!strcasecmp(aocbillingid,
"CreditCard")) {
4639 goto aocmessage_cleanup;
4644 }
else if (!strcasecmp(aocbillingid,
"Normal")) {
4646 }
else if (!strcasecmp(aocbillingid,
"ReverseCharge")) {
4648 }
else if (!strcasecmp(aocbillingid,
"CreditCard")) {
4650 }
else if (!strcasecmp(aocbillingid,
"CallFwdUnconditional")) {
4652 }
else if (!strcasecmp(aocbillingid,
"CallFwdBusy")) {
4654 }
else if (!strcasecmp(aocbillingid,
"CallFwdNoReply")) {
4656 }
else if (!strcasecmp(aocbillingid,
"CallDeflection")) {
4658 }
else if (!strcasecmp(aocbillingid,
"CallTransfer")) {
4662 goto aocmessage_cleanup;
4665 if (!
ast_strlen_zero(association_id) && (sscanf(association_id,
"%30d", &_association_id) != 1)) {
4667 goto aocmessage_cleanup;
4669 if (!
ast_strlen_zero(association_plan) && (sscanf(association_plan,
"%30u", &_association_plan) != 1)) {
4671 goto aocmessage_cleanup;
4674 if (_association_id) {
4688 for (i = 0; i < 32; i++) {
4698 astman_send_error(s, m,
"Invalid UnitAmount(0), At least one valid unit entry is required when ChargeType is set to Unit");
4699 goto aocmessage_cleanup;
4734 unsigned int _currencyamount = 0;
4736 unsigned int _time = 0;
4738 unsigned int _granularity = 0;
4745 goto aocmessage_cleanup;
4750 goto aocmessage_cleanup;
4753 if (!strcasecmp(chargeditem,
"NA")) {
4755 }
else if (!strcasecmp(chargeditem,
"SpecialArrangement")) {
4757 }
else if (!strcasecmp(chargeditem,
"BasicCommunication")) {
4759 }
else if (!strcasecmp(chargeditem,
"CallAttempt")) {
4761 }
else if (!strcasecmp(chargeditem,
"CallSetup")) {
4763 }
else if (!strcasecmp(chargeditem,
"UserUserInfo")) {
4765 }
else if (!strcasecmp(chargeditem,
"SupplementaryService")) {
4769 goto aocmessage_cleanup;
4772 if (!strcasecmp(ratetype,
"NA")) {
4774 }
else if (!strcasecmp(ratetype,
"Free")) {
4776 }
else if (!strcasecmp(ratetype,
"FreeFromBeginning")) {
4778 }
else if (!strcasecmp(ratetype,
"Duration")) {
4780 }
else if (!strcasecmp(ratetype,
"Flat")) {
4782 }
else if (!strcasecmp(ratetype,
"Volume")) {
4784 }
else if (!strcasecmp(ratetype,
"SpecialCode")) {
4788 goto aocmessage_cleanup;
4792 if (
ast_strlen_zero(currencyamount) || (sscanf(currencyamount,
"%30u",
4793 &_currencyamount) != 1)) {
4794 astman_send_error(s, m,
"Invalid CurrencyAmount, CurrencyAmount is a required when RateType is non-free");
4795 goto aocmessage_cleanup;
4799 astman_send_error(s, m,
"ChargeMultiplier unspecified, ChargeMultiplier is required when ChargeType is Currency.");
4800 goto aocmessage_cleanup;
4801 }
else if (!strcasecmp(mult,
"onethousandth")) {
4803 }
else if (!strcasecmp(mult,
"onehundredth")) {
4805 }
else if (!strcasecmp(mult,
"onetenth")) {
4807 }
else if (!strcasecmp(mult,
"one")) {
4809 }
else if (!strcasecmp(mult,
"ten")) {
4811 }
else if (!strcasecmp(mult,
"hundred")) {
4813 }
else if (!strcasecmp(mult,
"thousand")) {
4817 goto aocmessage_cleanup;
4823 astman_send_error(s, m,
"TimeScale unspecified, TimeScale is required when RateType is Duration.");
4824 goto aocmessage_cleanup;
4825 }
else if (!strcasecmp(timescale,
"onehundredthsecond")) {
4827 }
else if (!strcasecmp(timescale,
"onetenthsecond")) {
4829 }
else if (!strcasecmp(timescale,
"second")) {
4831 }
else if (!strcasecmp(timescale,
"tenseconds")) {
4833 }
else if (!strcasecmp(timescale,
"minute")) {
4835 }
else if (!strcasecmp(timescale,
"hour")) {
4837 }
else if (!strcasecmp(timescale,
"day")) {
4841 goto aocmessage_cleanup;
4845 astman_send_error(s, m,
"Invalid Time, Time is a required when RateType is Duration");
4846 goto aocmessage_cleanup;
4850 if ((sscanf(time,
"%30u", &_granularity) != 1)) {
4852 goto aocmessage_cleanup;
4856 astman_send_error(s, m,
"Invalid GranularityTimeScale, GranularityTimeScale is a required when Granularity is specified");
4857 }
else if (!strcasecmp(granularitytimescale,
"onehundredthsecond")) {
4859 }
else if (!strcasecmp(granularitytimescale,
"onetenthsecond")) {
4861 }
else if (!strcasecmp(granularitytimescale,
"second")) {
4863 }
else if (!strcasecmp(granularitytimescale,
"tenseconds")) {
4865 }
else if (!strcasecmp(granularitytimescale,
"minute")) {
4867 }
else if (!strcasecmp(granularitytimescale,
"hour")) {
4869 }
else if (!strcasecmp(granularitytimescale,
"day")) {
4873 goto aocmessage_cleanup;
4877 if (
ast_strlen_zero(chargingtype) || strcasecmp(chargingtype,
"continuouscharging") == 0) {
4879 }
else if (strcasecmp(chargingtype,
"stepfunction") == 0 ) {
4883 goto aocmessage_cleanup;
4889 astman_send_error(s, m,
"VolumeUnit unspecified, VolumeUnit is required when RateType is Volume.");
4890 goto aocmessage_cleanup;
4891 }
else if (!strcasecmp(timescale,
"octet")) {
4893 }
else if (!strcasecmp(timescale,
"segment")) {
4895 }
else if (!strcasecmp(timescale,
"message")) {
4899 goto aocmessage_cleanup;
4906 astman_send_error(s, m,
"Invalid Code, Code is a required when ChargedItem is SpecialArrangement and when RateType is SpecialCode");
4907 goto aocmessage_cleanup;
4915 currencyname, _time, _scale, _granularity, _granularity_time_scale, _step);
4921 _mult, currencyname);
4945 static const char hdr[] =
"ChargedItem:";
4951 goto aocmessage_cleanup;
4954 hdrlen = strlen(hdr);
4955 for (x = 0; x < m->
hdrcount; x++) {
4956 if (strncasecmp(hdr, m->
headers[x], hdrlen) == 0) {
4959 goto aocmessage_cleanup;
4970 goto aocmessage_cleanup;
4992 size_t encoded_size = 0;
4995 astman_send_error(s, m,
"Channel and PartialChannel are not specified. Specify at least one of these.");
4996 goto aocmessage_cleanup;
5005 goto aocmessage_cleanup;
5008 if (strcasecmp(msgtype,
"d") == 0 || strcasecmp(msgtype,
"e") == 0) {
5011 else if (strcasecmp(msgtype,
"s") == 0) {
5016 goto aocmessage_cleanup;
5020 goto aocmessage_cleanup;
5027 astman_send_error(s, m,
"Error encoding AOC message, could not queue onto channel");
5044 int (*searchfn)(
const char *
app,
const char *data,
const char *search);
5081 return !!(strstr(data, search));
5183#ifdef TEST_FRAMEWORK
5184#define ALL_PERMISSIONS (INT_MAX)
5185#define NO_PERMISSIONS (0)
5192 info->name =
"originate_permissions_test";
5193 info->category =
"/main/manager/";
5194 info->summary =
"Test permissions for originate action";
5196 "Make sure that dialplan apps/functions that need special "
5197 "permissions are prohibited if the user doesn't have the permission.";
5213 NULL, ALL_PERMISSIONS),
"exec check permission failed");
5219 NULL, NO_PERMISSIONS),
"exec permission check failed");
5230 NULL, NO_PERMISSIONS),
"Queue permission check failed");
5232 "somequeue,CcdHh,someURL,tt-monkeys,100,,gosub,rule,666",
5237 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5240 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5243 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5244 ALL_PERMISSIONS),
"Queue permission check failed");
5248 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5249 NO_PERMISSIONS),
"Queue permission check failed");
5251 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5260 "aaa DB bbb", ALL_PERMISSIONS),
"exec permission check failed");
5262 "aaaDBbbb", NO_PERMISSIONS),
"exec permission check failed");
5264 "aaa DB bbb", NO_PERMISSIONS),
"exec permission check failed");
5267 "aaa db bbb", NO_PERMISSIONS),
"exec permission check failed");
5271#undef ALL_PERMISSIONS
5272#undef NO_PERMISSIONS
5307 int bridge_early = 0;
5320 goto fast_orig_cleanup;
5326 goto fast_orig_cleanup;
5332 goto fast_orig_cleanup;
5335 if (!
ast_strlen_zero(timeout) && (sscanf(timeout,
"%30d", &to) != 1)) {
5338 goto fast_orig_cleanup;
5342 data = strchr(tmp,
'/');
5346 goto fast_orig_cleanup;
5371 goto fast_orig_cleanup;
5376 if (exten && context && pi) {
5381 goto fast_orig_cleanup;
5396 for (v = vars; v->
next; v = v->
next );
5402 bridge_early =
ast_true(early_media);
5446 if (exten && context && pi) {
5449 l, n, vars, account,
NULL, bridge_early,
5453 astman_send_error(s, m,
"Originate with 'Exten' requires 'Context' and 'Priority'");
5456 goto fast_orig_cleanup;
5483 "Waiting: %d\r\n\r\n", mailbox, ret);
5490 int newmsgs = 0, oldmsgs = 0, urgentmsgs = 0;;
5500 "UrgMessages: %d\r\n"
5501 "NewMessages: %d\r\n"
5502 "OldMessages: %d\r\n"
5504 mailbox, urgentmsgs, newmsgs, oldmsgs);
5520 context =
"default";
5531 "StatusText: %s\r\n"
5533 exten, context, hint,
status,
5570 "PresenceMessage: %s\r\n",
5586 struct timeval when = { timeout, 0 };
5593 if (!timeout || timeout < 0) {
5603 when.tv_usec = (timeout - when.tv_sec) * 1000000.0;
5647 char *line_buffer_start =
NULL;
5648 char *line_buffer =
NULL;
5667 line_buffer = line_buffer_start;
5668 if (!line_buffer_start) {
5682 line_buffer_start =
NULL;
5740 if (!strcasecmp(operation,
"Add")) {
5748 S_COR(have_match,
"(",
""),
S_OR(match_criteria,
""),
5749 S_COR(have_match,
")",
""));
5751 astman_send_error(s, m,
"Internal Error. Failed to allocate storage for filter type");
5763 "Filter did not compile. Check the syntax of the filter given.");
5767 "Filter was formatted incorrectly. Check the syntax of the filter given.");
5801 const char *criteria,
const char *filter_pattern,
5807 const char *options_start =
NULL;
5808 SCOPE_ENTER(3,
"manager_add_filter(%s, %s, %p, %p)", criteria, filter_pattern, includefilters, excludefilters);
5810 if (!filter_entry) {
5825 if (!filter_pattern) {
5835 if (filter_pattern[0] ==
'!') {
5836 filter_entry->is_excludefilter = 1;
5848 options_start = strstr(criteria,
"(");
5855 "'%s = %s': Legacy filter with no filter pattern specified\n",
5856 criteria, filter_pattern);
5859 if (options_start) {
5864 char *saveptr =
NULL;
5865 char *option =
NULL;
5866 enum found_options {
5867 action_found = (1 << 0),
5868 name_found = (1 << 1),
5869 header_found = (1 << 2),
5870 method_found = (1 << 3),
5872 enum found_options options_found = 0;
5879 "'%s = %s': Filter options not formatted correctly\n",
5880 criteria, filter_pattern);
5888 while ((option = strtok_r(temp,
" ,)", &saveptr))) {
5889 if (!strncmp(option,
"action", 6)) {
5890 char *
method = strstr(option,
"(");
5893 criteria, filter_pattern);
5897 if (!strcmp(
method,
"include")) {
5898 filter_entry->is_excludefilter = 0;
5899 }
else if (!strcmp(
method,
"exclude")) {
5900 filter_entry->is_excludefilter = 1;
5903 criteria, filter_pattern,
method);
5905 options_found |= action_found;
5906 }
else if (!strncmp(option,
"name", 4)) {
5907 char *event_name = strstr(option,
"(");
5912 criteria, filter_pattern);
5914 filter_entry->event_name =
ast_strdup(event_name);
5915 filter_entry->event_name_hash =
ast_str_hash(event_name);
5916 options_found |= name_found;
5917 }
else if (!strncmp(option,
"header", 6)) {
5918 char *header_name = strstr(option,
"(");
5923 criteria, filter_pattern);
5926 filter_entry->header_name =
ast_malloc(strlen(header_name) + 2);
5927 if (!filter_entry->header_name) {
5930 sprintf(filter_entry->header_name,
"%s:", header_name);
5932 filter_entry->header_name =
ast_strdup(header_name);
5934 options_found |= header_found;
5935 }
else if (!strncmp(option,
"method", 6)) {
5936 char *
method = strstr(option,
"(");
5941 criteria, filter_pattern);
5943 if (!strcmp(
method,
"regex")) {
5945 }
else if (!strcmp(
method,
"exact")) {
5947 }
else if (!strcmp(
method,
"starts_with")) {
5949 }
else if (!strcmp(
method,
"ends_with")) {
5951 }
else if (!strcmp(
method,
"contains")) {
5953 }
else if (!strcmp(
method,
"none")) {
5957 criteria, filter_pattern,
method);
5959 options_found |= method_found;
5962 criteria, filter_pattern, option);
5966 if (!options_found) {
5968 "'%s = %s': No action, name, header, or method option found\n",
5969 criteria, filter_pattern);
5973 "'%s = %s': method can't be '%s' with no filter pattern\n",
5978 "'%s = %s': method can't be 'none' with a filter pattern\n",
5979 criteria, filter_pattern);
5981 if (!(options_found & name_found) && !(options_found & header_found) &&
5984 "'%s = %s': No name or header option found and no filter pattern\n",
5985 criteria, filter_pattern);
5991 filter_entry->regex_filter =
ast_calloc(1,
sizeof(regex_t));
5992 if (!filter_entry->regex_filter) {
5995 if (regcomp(filter_entry->regex_filter, filter_pattern, REG_EXTENDED | REG_NOSUB)) {
5999 filter_entry->string_filter =
ast_strdup(filter_pattern);
6004 "conf entry: %s = %s\n"
6005 "event_name: %s (hash: %d)\n"
6008 "regex_filter: %p\n"
6009 "string filter: %s\n"
6010 "is excludefilter: %d\n",
6011 criteria, filter_pattern,
6012 S_OR(filter_entry->event_name,
"<not used>"),
6013 filter_entry->event_name_hash,
6014 S_OR(filter_entry->header_name,
"<not used>"),
6016 filter_entry->regex_filter,
6017 filter_entry->string_filter,
6018 filter_entry->is_excludefilter);
6020 if (filter_entry->is_excludefilter) {
6021 ao2_t_link(excludefilters, filter_entry,
"link new filter into exclude user container");
6023 ao2_t_link(includefilters, filter_entry,
"link new filter into include user container");
6029#ifdef TEST_FRAMEWORK
6031struct test_filter_data {
6032 const char *criteria;
6036 const char *test_event_name;
6037 const char *test_event_payload;
6038 int expected_should_send_event;
6041static char *add_filter_result_enums[] = {
6048#define TEST_EVENT_NEWCHANNEL "Newchannel", "Event: Newchannel\r\nChannel: XXX\r\nSomeheader: YYY\r\n"
6049#define TEST_EVENT_VARSET "VarSet", "Event: VarSet\r\nChannel: ABC\r\nSomeheader: XXX\r\n"
6050#define TEST_EVENT_NONE "", ""
6052static struct test_filter_data parsing_filter_tests[] = {
6060 {
"eventfilter(name(Newchannel),method(regex))",
"X[XYZ]X",
FILTER_SUCCESS,
6062 {
"eventfilter(name(Newchannel),method(regex))",
"X[abc]X",
FILTER_SUCCESS,
6064 {
"eventfilter(action(exclude),name(Newchannel),method(regex))",
"X[XYZ]X",
FILTER_SUCCESS,
6066 {
"eventfilter(action(exclude),name(Newchannel),method(regex))",
"X[abc]X",
FILTER_SUCCESS,
6068 {
"eventfilter(action(include),name(VarSet),header(Channel),method(starts_with))",
"AB",
FILTER_SUCCESS,
6070 {
"eventfilter(action(include),name(VarSet),header(Channel),method(ends_with))",
"BC",
FILTER_SUCCESS,
6072 {
"eventfilter(action(include),name(VarSet),header(Channel),method(exact))",
"ABC",
FILTER_SUCCESS,
6074 {
"eventfilter(action(include),name(VarSet),header(Channel),method(exact))",
"XXX",
FILTER_SUCCESS,
6076 {
"eventfilter(name(VarSet),header(Channel),method(exact))",
"!ZZZ",
FILTER_SUCCESS,
6078 {
"eventfilter(action(exclude),name(VarSet),header(Channel),method(exact))",
"ZZZ",
FILTER_SUCCESS,
6080 {
"eventfilter(action(include),name(VarSet),header(Someheader),method(exact))",
"!XXX",
FILTER_SUCCESS,
6089 {
"eventfilter(nnnn(yyy),header(VarSet),method(contains)",
"XXX",
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
6090 {
"eventfilter(name(yyy),heder(VarSet),method(contains)",
"XXX",
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
6091 {
"eventfilter(name(yyy),header(VarSet),mehod(contains)",
"XXX",
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
6092 {
"eventfilter(name(yyy),header(VarSet),method(coains)",
"XXX",
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
6105static int strings_equal(
const char *str1,
const char *str2)
6107 if ((!str1 && str2) || (str1 && !str2)) {
6111 return str1 == str2 || !strcmp(str1, str2);
6123 info->name =
"eventfilter_test_creation";
6124 info->category =
"/main/manager/";
6125 info->summary =
"Test eventfilter creation";
6127 "This creates various eventfilters and tests to make sure they were created successfully.";
6135 if (!includefilters || !excludefilters) {
6140 for (i = 0; i <
ARRAY_LEN(parsing_filter_tests); i++) {
6145 int include_container_count = 0;
6146 int exclude_container_count = 0;
6153 includefilters, excludefilters);
6158 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6159 add_filter_result_enums[parsing_filter_tests[i].expected_add_filter_result],
6160 add_filter_result_enums[add_filter_res],
6161 add_filter_res != parsing_filter_tests[i].expected_add_filter_result ?
"FAIL" :
"PASS");
6164 if (add_filter_res != parsing_filter_tests[i].expected_add_filter_result) {
6166 "Unexpected add filter result '%s = %s'. Expected result: %s Actual result: %s\n",
6167 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6168 add_filter_result_enums[parsing_filter_tests[i].expected_add_filter_result],
6169 add_filter_result_enums[add_filter_res]);
6174 if (parsing_filter_tests[i].expected_add_filter_result !=
FILTER_SUCCESS) {
6183 if (parsing_filter_tests[i].expected_filter_entry.event_name) {
6184 parsing_filter_tests[i].expected_filter_entry.event_name_hash =
6185 ast_str_hash(parsing_filter_tests[i].expected_filter_entry.event_name);
6191 if (parsing_filter_tests[i].expected_filter_entry.is_excludefilter) {
6192 if (exclude_container_count != 1 || include_container_count != 0) {
6194 "Invalid container counts for exclude filter '%s = %s'. Exclude: %d Include: %d. Should be 1 and 0\n",
6195 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6196 exclude_container_count, include_container_count);
6203 if (include_container_count != 1 || exclude_container_count != 0) {
6205 "Invalid container counts for include filter '%s = %s'. Include: %d Exclude: %d. Should be 1 and 0\n",
6206 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6207 include_container_count, exclude_container_count);
6215 if (!filter_entry) {
6217 "Failed to find filter entry for '%s = %s' in %s filter container\n",
6218 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6219 parsing_filter_tests[i].expected_filter_entry.is_excludefilter ?
"exclude" :
"include");
6224 if (filter_entry->
match_type != parsing_filter_tests[i].expected_filter_entry.match_type) {
6226 "Failed to match filter type for '%s = %s'. Expected: %s Actual: %s\n",
6227 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6228 match_type_names[parsing_filter_tests[i].expected_filter_entry.match_type],
6234 if (!strings_equal(filter_entry->
event_name, parsing_filter_tests[i].expected_filter_entry.event_name)) {
6236 "Failed to match event name for '%s = %s'. Expected: '%s' Actual: '%s'\n",
6237 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6238 parsing_filter_tests[i].expected_filter_entry.event_name, filter_entry->
event_name);
6243 if (filter_entry->
event_name_hash != parsing_filter_tests[i].expected_filter_entry.event_name_hash) {
6245 "Event name hashes failed to match for '%s = %s'. Expected: %u Actual: %u\n",
6246 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6247 parsing_filter_tests[i].expected_filter_entry.event_name_hash, filter_entry->
event_name_hash);
6252 if (!strings_equal(filter_entry->
header_name, parsing_filter_tests[i].expected_filter_entry.header_name)) {
6254 "Failed to match header name for '%s = %s'. Expected: '%s' Actual: '%s'\n",
6255 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6256 parsing_filter_tests[i].expected_filter_entry.header_name, filter_entry->
header_name);
6261 switch (parsing_filter_tests[i].expected_filter_entry.match_type) {
6265 "Failed to compile regex filter for '%s = %s'\n",
6266 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter);
6274 "Unexpected regex filter or string for '%s = %s' with match_type 'none'\n",
6275 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter);
6286 "Unexpected regex filter or empty string for '%s = %s' with match_type '%s'\n",
6287 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6288 match_type_names[parsing_filter_tests[i].expected_filter_entry.match_type]);
6310 if (
send_event != parsing_filter_tests[i].expected_should_send_event) {
6313 "Should send event failed to match for '%s = %s' payload '%s'. Expected: %s Actual: %s\n",
6314 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter, escaped,
6329struct test_filter_matching {
6330 const char *criteria;
6331 const char *pattern;
6347static struct test_filter_matching filters_for_matching[] = {
6348 {
"eventfilter(name(VarSet),method(none))",
""},
6349 {
"eventfilter(name(Newchannel),method(regex))",
"X[XYZ]X"},
6350 {
"eventfilter(name(Newchannel),method(regex))",
"X[abc]X"},
6351 {
"eventfilter(name(Newchannel),header(Someheader),method(regex))",
"ZZZ"},
6352 {
"eventfilter(action(exclude),name(Newchannel),method(regex))",
"X[a]X"},
6353 {
"eventfilter(action(exclude),name(Newchannel),method(regex))",
"X[Z]X"},
6354 {
"eventfilter(action(exclude),name(VarSet),header(Channel),method(regex))",
"YYY"},
6357struct test_event_matching{
6358 const char *event_name;
6359 const char *payload;
6360 int expected_should_send_event;
6363static struct test_event_matching events_for_matching[] = {
6364 {
"Newchannel",
"Event: Newchannel\r\nChannel: XXX\r\nSomeheader: YYY\r\n", 1 },
6365 {
"Newchannel",
"Event: Newchannel\r\nChannel: XZX\r\nSomeheader: YYY\r\n", 0 },
6366 {
"Newchannel",
"Event: Newchannel\r\nChannel: XaX\r\nSomeheader: YYY\r\n", 0 },
6367 {
"Newchannel",
"Event: Newchannel\r\nChannel: XbX\r\nSomeheader: YYY\r\n", 1 },
6368 {
"Newchannel",
"Event: Newchannel\r\nChannel: XcX\r\nSomeheader: YYY\r\n", 1 },
6369 {
"Newchannel",
"Event: Newchannel\r\nChannel: YYY\r\nSomeheader: YYY\r\n", 0 },
6370 {
"Newchannel",
"Event: Newchannel\r\nChannel: YYY\r\nSomeheader: ZZZ\r\n", 1 },
6371 {
"VarSet",
"Event: VarSet\r\nChannel: XXX\r\nSomeheader: YYY\r\n", 1 },
6372 {
"VarSet",
"Event: VarSet\r\nChannel: YYY\r\nSomeheader: YYY\r\n", 0 },
6384 info->name =
"eventfilter_test_matching";
6385 info->category =
"/main/manager/";
6386 info->summary =
"Test eventfilter matching";
6388 "This creates various eventfilters and tests to make sure they were matched successfully.";
6396 if (!includefilters || !excludefilters) {
6402 for (i = 0; i <
ARRAY_LEN(filters_for_matching); i++) {
6406 filters_for_matching[i].pattern, includefilters, excludefilters);
6410 "Unexpected add filter result '%s = %s'. Expected result: %s Actual result: %s\n",
6411 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6413 add_filter_result_enums[add_filter_res]);
6425 for (i = 0; i <
ARRAY_LEN(events_for_matching); i++) {
6437 if (
send_event != events_for_matching[i].expected_should_send_event) {
6440 "Should send event failed to match for '%s'. Expected: %s Actual: %s\n",
6462 size_t events_count;
6479 for (i = 0; i < events_count; i++) {
6483 ast_debug(3,
"Received CloseSession event\n");
6512 for (x = 0; x < m->
hdrcount; x++) {
6513 if (strncasecmp(
"UserEvent:", m->
headers[x], strlen(
"UserEvent:")) &&
6514 strncasecmp(
"Action:", m->
headers[x], strlen(
"Action:"))) {
6531 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
6538 "AMIversion: %s\r\n"
6539 "AsteriskVersion: %s\r\n"
6540 "SystemName: %s\r\n"
6541 "CoreMaxCalls: %d\r\n"
6542 "CoreMaxLoadAvg: %f\r\n"
6543 "CoreRunUser: %s\r\n"
6544 "CoreRunGroup: %s\r\n"
6545 "CoreMaxFilehandles: %d\r\n"
6546 "CoreRealTimeEnabled: %s\r\n"
6547 "CoreCDRenabled: %s\r\n"
6548 "CoreHTTPenabled: %s\r\n"
6549 "SoundsSearchCustomDir: %s\r\n"
6573 char startuptime[150], startupdate[150];
6574 char reloadtime[150], reloaddate[150];
6578 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
6584 ast_strftime(startuptime,
sizeof(startuptime),
"%H:%M:%S", &tm);
6585 ast_strftime(startupdate,
sizeof(startupdate),
"%Y-%m-%d", &tm);
6587 ast_strftime(reloadtime,
sizeof(reloadtime),
"%H:%M:%S", &tm);
6588 ast_strftime(reloaddate,
sizeof(reloaddate),
"%Y-%m-%d", &tm);
6592 "CoreStartupDate: %s\r\n"
6593 "CoreStartupTime: %s\r\n"
6594 "CoreReloadDate: %s\r\n"
6595 "CoreReloadTime: %s\r\n"
6596 "CoreCurrentCalls: %d\r\n"
6597 "CoreProcessedCalls: %d\r\n"
6613 const char *
module = astman_get_header(m, "Module");
6653 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
6665 char durbuf[16] =
"";
6672 int duration, durh, durm, durs;
6675 durh = duration / 3600;
6676 durm = (duration % 3600) / 60;
6677 durs = duration % 60;
6678 snprintf(durbuf,
sizeof(durbuf),
"%02d:%02d:%02d", durh, durm, durs);
6682 "Event: CoreShowChannel\r\n"
6685 "Application: %s\r\n"
6686 "ApplicationData: %s\r\n"
6732 char *current_channel_uid;
6737 int add_channel_res;
6741 if (!strcmp(current_channel_uid, channel_snapshot->
base->
uniqueid)) {
6742 ao2_ref(current_channel_uid, -1);
6747 if (!current_channel_snapshot) {
6748 ast_debug(5,
"Unable to get channel snapshot\n");
6749 ao2_ref(current_channel_uid, -1);
6754 if (add_channel_res) {
6756 ao2_ref(current_channel_snapshot, -1);
6757 ao2_ref(current_channel_uid, -1);
6765 int size = strlen(current_channel_snapshot->
base->
name);
6766 char other_local[size + 1];
6771 other_local[size] =
'\0';
6774 if (!other_local_snapshot) {
6775 ast_debug(5,
"Unable to get other local channel snapshot\n");
6776 ao2_ref(current_channel_snapshot, -1);
6777 ao2_ref(current_channel_uid, -1);
6783 ao2_ref(current_channel_snapshot, -1);
6784 ao2_ref(current_channel_uid, -1);
6785 ao2_ref(other_local_snapshot, -1);
6790 if (other_bridge_snapshot) {
6794 ao2_ref(current_channel_snapshot, -1);
6795 ao2_ref(current_channel_uid, -1);
6796 ao2_ref(other_local_snapshot, -1);
6797 ao2_ref(other_bridge_snapshot, -1);
6815 char *current_channel_name;
6824 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n", actionid);
6835 if (!channel_snapshot) {
6848 if (!bridge_snapshot) {
6872 "Event: CoreShowChannelMap\r\n"
6875 "ConnectedChannel: %s\r\n\r\n",
6878 current_channel_name);
6906 const char *
module = astman_get_header(m, "Module");
6909 ast_debug(1,
"**** ModuleCheck .so file %s\n", module);
6921#if !defined(LOW_MEMORY)
6945 char *stripped_filename;
6961 real_path = realpath(path,
NULL);
6972 const char *
module = astman_get_header(m, "Module");
6976 if (!loadtype || strlen(loadtype) == 0) {
6979 if ((!module || strlen(module) == 0) && strcasecmp(loadtype,
"reload") != 0) {
6987 }
else if (res == -1) {
6992 if (!strcasecmp(loadtype,
"load")) {
6999 }
else if (!strcasecmp(loadtype,
"unload")) {
7006 }
else if (!strcasecmp(loadtype,
"refresh")) {
7013 }
else if (!strcasecmp(loadtype,
"reload")) {
7018 switch (reload_res) {
7064 for (x = 0; x < m->
hdrcount; ++x) {
7065 if (!strncasecmp(m->
headers[x],
"Secret", 6)) {
7094 const char *username;
7109 ast_log(
LOG_ERROR,
"Unable to process manager action '%s'. Asterisk is shutting down.\n", action);
7117 && strcasecmp(action,
"Login")
7118 && strcasecmp(action,
"Logoff")
7119 && strcasecmp(action,
"Challenge")) {
7130 && (!strcasecmp(action,
"Login")
7131 || !strcasecmp(action,
"Challenge"))) {
7137 if (
user && !
user->allowmultiplelogin) {
7164 if (mod_ref || !act_found->module) {
7166 ret = act_found->
func(s, m);
7185 ao2_t_ref(act_found, -1,
"done with found action object");
7190 snprintf(
buf,
sizeof(
buf),
"Invalid/unknown command: %s. Use Action: ListCommands to show available commands.", action);
7231 if (src[x] ==
'\r' && x+1 < s->
session->
inlen && src[x + 1] ==
'\n') {
7233 }
else if (src[x] ==
'\n') {
7238 memmove(output, src, x);
7257 if(time(&now) == -1) {
7285 if (pfds[1].revents) {
7288 ast_debug(1,
"Manager session has been kicked\n");
7298 if (pfds[0].revents) {
7349 struct pollfd pfds[2];
7352 memset(pfds, 0,
sizeof(pfds));
7354 pfds[0].events = POLLIN | POLLPRI;
7356 pfds[1].events = POLLIN | POLLPRI;
7364 if (time(&now) == -1) {
7379 }
else if (res > 0) {
7469 if(time(&
session->authstart) == -1) {
7522 time_t now = time(
NULL);
7540 ast_verb(2,
"HTTP Manager '%s' timed out from %s\n",
7569#define MANAGER_EVENT_BUF_INITSIZE 256
7588 event->category = category;
7596 if (!
event->message) {
7623 const
char *event_name,
7634 const char *cat_str;
7639 ast_debug(3,
"AMI Event '%s' is globally disabled, skipping\n", event_name);
7653 "Privilege: %s\r\n",
7654 event_name, cat_str);
7661 "Timestamp: %ld.%06lu\r\n",
7662 (
long)now.tv_sec, (
unsigned long) now.tv_usec);
7668 "SequenceNumber: %d\r\n",
7678 "SystemName: %s\r\n",
7703 (
session->send_events & category) == category) {
7759 const char *fmt, ...)
7773 file, line, func, fmt, ap);
7788 if (!strcasecmp(action, cur->
action)) {
7805 ao2_t_ref(cur, -1,
"action object removed from list");
7806 ast_verb(5,
"Manager unregistered action %s\n", action);
7820 switch(info->reason) {
7827 "StatusText: %s\r\n",
7846 info->presence_subtype,
7847 info->presence_message);
7873 ao2_t_ref(act, +1,
"action object added to list");
7917 ao2_t_ref(cur, -1,
"action object creation failed");
7922 ao2_t_ref(cur, -1,
"action object creation failed");
7927 ao2_t_ref(cur, -1,
"action object creation failed");
7934 cur->module =
module;
7981 ao2_t_ref(cur, -1,
"action object registration failed");
7985 ao2_t_ref(cur, -1,
"action object registration successful");
8065 if (nonce == 0 || username ==
NULL || stale ==
NULL) {
8077 if (!strcasecmp(
session->username, username) &&
session->managerid == nonce) {
8080 }
else if (!strcasecmp(
session->username, username) &&
session->oldnonce == nonce) {
8100 authed = (
session->authenticated != 0);
8127 if ((
session->managerid == ident) && (
session->readperm & perm)) {
8160 if ((
session->managerid == ident) && (
session->writeperm & perm)) {
8184 const char *save = src;
8185 int space =
sizeof(
buf);
8187 for ( ; *src || dst !=
buf ; src++) {
8188 if (*src ==
'\0' || space < 10) {
8192 space =
sizeof(
buf);
8199 if (save == src && isdigit(*src)) {
8205 }
else if (!isalnum(*src)) {
8214 strcpy(dst,
"<");
8219 strcpy(dst,
">");
8224 strcpy(dst,
""");
8229 strcpy(dst,
"'");
8234 strcpy(dst,
"&");
8240 *dst++ = mode ? tolower(*src) : *src;
8300 const char *dest =
NULL;
8302 const char *objtype =
NULL;
8311 for (v = get_vars; v; v = v->
next) {
8312 if (!strcasecmp(v->
name,
"ajaxdest")) {
8314 }
else if (!strcasecmp(v->
name,
"ajaxobjtype")) {
8322 objtype =
"generic";
8329 if (
in && *
in ==
'\n') {
8333 ast_debug(5,
"inobj %d in_data %d line <%s>\n", inobj, in_data,
val);
8345 "<tr><td colspan=\"2\"><hr></td></tr>\r\n");
8380 var =
"Opaque-data";
8397 if (vc->
count > 1) {
8403 if (!in_data || !*
in) {
8410 "<tr><td colspan=\"2\"><hr></td></tr>\r\n");
8421 ast_log(
LOG_ERROR,
"Attempted to close file/file descriptor on mansession without a valid file or file descriptor.\n");
8439 l = lseek(fd, 0, SEEK_CUR);
8441 if (MAP_FAILED == (
buf = mmap(
NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0))) {
8461 const struct ast_sockaddr *remote_address,
const char *uri,
8471 char template[] =
"/tmp/ast-http-XXXXXX";
8476 ast_http_error(ser, 501,
"Not Implemented",
"Attempt to use unimplemented / unsupported method");
8490 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8513 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (ast_str_create() out of memory)");
8514 goto generic_callback_out;
8518 fd = mkstemp(
template);
8521 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (mkstemp failed)");
8522 goto generic_callback_out;
8527 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (fdopen failed)");
8529 goto generic_callback_out;
8537 ast_http_error(ser, 413,
"Request Entity Too Large",
"Body too large");
8539 goto generic_callback_out;
8544 goto generic_callback_out;
8546 ast_http_error(ser, 400,
"Bad Request",
"Error parsing request body");
8548 goto generic_callback_out;
8571 "Content-type: text/%s\r\n"
8572 "Set-Cookie: mansession_id=\"%08x\"; Version=1; Max-Age=%d\r\n"
8573 "Pragma: SuppressEvents\r\n",
8586#define ROW_FMT "<tr><td colspan=\"2\" bgcolor=\"#f1f1ff\">%s</td></tr>\r\n"
8587#define TEST_STRING \
8588 "<form action=\"manager\" method=\"post\">\n\
8589 Action: <select name=\"action\">\n\
8590 <option value=\"\">-----></option>\n\
8591 <option value=\"login\">login</option>\n\
8592 <option value=\"command\">Command</option>\n\
8593 <option value=\"waitevent\">waitevent</option>\n\
8594 <option value=\"listcommands\">listcommands</option>\n\
8596 or <input name=\"action\"><br/>\n\
8597 CLI Command <input name=\"command\"><br>\n\
8598 user <input name=\"username\"> pass <input type=\"password\" name=\"secret\"><br>\n\
8599 <input type=\"submit\">\n</form>\n"
8602 ast_str_append(&
out, 0,
"<body bgcolor=\"#ffffff\"><table align=center bgcolor=\"#f1f1f1\" width=\"500\">\r\n");
8621 ast_debug(1,
"Need destroy, doing it now!\n");
8624 ast_debug(1,
"Need destroy, but can't do it yet!\n");
8627 pthread_kill(
session->http_thread, SIGURG);
8641generic_callback_out:
8670 const struct ast_sockaddr *remote_address,
const char *uri,
8677 char template[] =
"/tmp/ast-http-XXXXXX";
8683 time_t time_now = time(
NULL);
8684 unsigned long nonce = 0, nc;
8688 char resp_hash[256]=
"";
8690 char u_username[80];
8694 int u_displayconnects;
8697 ast_http_error(ser, 501,
"Not Implemented",
"Attempt to use unimplemented / unsupported method");
8702 for (v = headers; v; v = v->
next) {
8703 if (!strcasecmp(v->
name,
"Authorization")) {
8715 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8724 if (sscanf(
d.nonce,
"%30lx", &nonce) != 1) {
8744 ast_http_error(ser, 403,
"Permission denied",
"Permission denied");
8761 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8770 snprintf(resp,
sizeof(resp),
"%s:%08lx:%s:%s:auth:%s",
user->a1_hash, nonce,
d.nc,
d.cnonce, a2_hash);
8773 snprintf(resp,
sizeof(resp),
"%s:%08lx:%s",
user->a1_hash, nonce, a2_hash);
8778 if (strncasecmp(
d.response, resp_hash, strlen(resp_hash))) {
8790 u_readperm =
user->readperm;
8791 u_writeperm =
user->writeperm;
8792 u_displayconnects =
user->displayconnects;
8793 u_writetimeout =
user->writetimeout;
8803 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8811 session->readperm = u_readperm;
8812 session->writeperm = u_writeperm;
8813 session->writetimeout = u_writetimeout;
8815 if (u_displayconnects) {
8838 sscanf(
d.nc,
"%30lx", &nc);
8839 if (
session->nc >= nc || ((time_now -
session->noncetime) > 62) ) {
8850 session->noncetime = time_now;
8866 fd = mkstemp(
template);
8869 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (mkstemp failed)");
8870 goto auth_callback_out;
8875 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (fdopen failed)");
8877 goto auth_callback_out;
8885 ast_http_error(ser, 413,
"Request Entity Too Large",
"Body too large");
8887 goto auth_callback_out;
8892 goto auth_callback_out;
8894 ast_http_error(ser, 400,
"Bad Request",
"Error parsing request body");
8896 goto auth_callback_out;
8904 if (u_displayconnects) {
8919 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (ast_str_create() out of memory)");
8921 goto auth_callback_out;
8930 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
8932 "<title>Asterisk™ Manager Interface</title>\r\n"
8933 "</head><body style=\"background-color: #ffffff;\">\r\n"
8934 "<form method=\"POST\">\r\n"
8935 "<table align=\"center\" style=\"background-color: #f1f1f1;\" width=\"500\">\r\n"
8936 "<tr><th colspan=\"2\" style=\"background-color: #f1f1ff;\"><h1>Manager Tester</h1></th></tr>\r\n"
8937 "<tr><th colspan=\"2\" style=\"background-color: #f1f1ff;\">Action: <input name=\"action\" /> Cmd: <input name=\"command\" /><br>"
8938 "<input type=\"submit\" value=\"Send request\" /></th></tr>\r\n");
8972 ast_debug(1,
"Need destroy, doing it now!\n");
9022 .
description =
"Raw HTTP Manager Event Interface",
9081 .
description =
"Raw HTTP Manager Event Interface w/Digest authentication",
9090 .
description =
"HTML Manager Event Interface w/Digest authentication",
9099 .
description =
"XML Manager Event Interface w/Digest authentication",
9111 const char *login = (
char *)arg;
9112 int *no_sessions = data;
9114 if (strcasecmp(
session->username, login) == 0) {
9134 ast_log(
LOG_WARNING,
"AMI_CLIENT() requires two arguments: AMI_CLIENT(<name>[,<arg>])\n");
9149 if (!strcasecmp(
args.param,
"sessions")) {
9150 int no_sessions = 0;
9158 snprintf(
buf,
len,
"%d", no_sessions);
9171 .
name =
"AMI_CLIENT",
9201 .poll_timeout = 5000,
9203 .name =
"AMI server",
9213 .name =
"AMI TLS server",
9223 e->
command =
"manager show settings";
9225 "Usage: manager show settings\n"
9226 " Provides detailed list of the configuration of the Manager.\n";
9231#define FORMAT " %-25.25s %-15.55s\n"
9232#define FORMAT2 " %-25.25s %-15d\n"
9233#define FORMAT3 " %-25.25s %s\n"
9237 ast_cli(
a->fd,
"\nGlobal Settings:\n");
9238 ast_cli(
a->fd,
"----------------\n");
9269 int *max_len = data;
9272 if (
len > *max_len) {
9288 const char *dashes =
"--------------------------------------------------------------------------------";
9292 e->
command =
"manager show events";
9294 "Usage: manager show events\n"
9295 " Prints a listing of the available Asterisk manager interface events.\n";
9311 ast_cli(
a->fd,
"No manager event documentation loaded\n");
9319 ast_xml_doc_item_sort_fn,
NULL);
9320 if (!sorted_events) {
9335 ast_cli(
a->fd,
" %.*s %.*s %.*s \n", maxlen, dashes, maxlen, dashes, maxlen, dashes);
9339 if (++col % 3 == 0) {
9350 ast_cli(
a->fd,
"\n%d events registered.\n", col);
9360 char *since, *syntax, *provided_by, *description, *
synopsis, *seealso, *arguments;
9370 if (!
synopsis || !provided_by || !since || !description || !syntax || !arguments || !seealso) {
9371 ast_cli(
a->fd,
"Error: Memory allocation failed\n");
9376 "%s -= Info about Manager Event '%s' =- %s\n\n"
9418 e->
command =
"manager show event";
9420 "Usage: manager show event <eventname>\n"
9421 " Provides a detailed description a Manager interface event.\n";
9427 ast_cli(
a->fd,
"No manager event documentation loaded\n");
9436 length = strlen(
a->word);
9439 if (!strncasecmp(
a->word,
item->
name, length)) {
9457 ast_cli(
a->fd,
"Could not find event '%s'\n",
a->argv[3]);
9461 ast_cli(
a->fd,
"Event: %s\n",
a->argv[3]);
9531 if (
user->includefilters) {
9532 ao2_t_ref(
user->includefilters, -1,
"decrement ref for include container, should be last one");
9534 if (
user->excludefilters) {
9535 ao2_t_ref(
user->excludefilters, -1,
"decrement ref for exclude container, should be last one");
9550#ifdef TEST_FRAMEWORK
9605#ifdef TEST_FRAMEWORK
9607 test_suite_forwarder =
NULL;
9763 int newhttptimeout = 60;
9771 int tls_was_enabled = 0;
9772 int acl_subscription_flag = 0;
9831#ifdef TEST_FRAMEWORK
9841 if (temp_event_docs) {
9843 ao2_t_ref(temp_event_docs, -1,
"Remove creation ref - container holds only ref now");
9863 ast_log(
LOG_NOTICE,
"Unable to open AMI configuration manager.conf, or configuration is invalid.\n");
9868 if (!by_external_config) {
9885 if (strcasecmp(
var->name,
"tlscafile")
9886 && strcasecmp(
var->name,
"tlscapath")
9887 && strcasecmp(
var->name,
"tlscadir")
9888 && strcasecmp(
var->name,
"tlsverifyclient")
9889 && strcasecmp(
var->name,
"tlsdontverifyserver")
9890 && strcasecmp(
var->name,
"tlsclientmethod")
9891 && strcasecmp(
var->name,
"sslclientmethod")
9896 if (!strcasecmp(
var->name,
"enabled")) {
9898 }
else if (!strcasecmp(
var->name,
"webenabled")) {
9900 }
else if (!strcasecmp(
var->name,
"port")) {
9906 }
else if (!strcasecmp(
var->name,
"bindaddr")) {
9921 }
else if (!strcasecmp(
var->name,
"brokeneventsaction")) {
9923 }
else if (!strcasecmp(
var->name,
"allowmultiplelogin")) {
9925 }
else if (!strcasecmp(
var->name,
"displayconnects")) {
9927 }
else if (!strcasecmp(
var->name,
"timestampevents")) {
9929 }
else if (!strcasecmp(
var->name,
"debug")) {
9931 }
else if (!strcasecmp(
var->name,
"httptimeout")) {
9932 newhttptimeout = atoi(
val);
9933 }
else if (!strcasecmp(
var->name,
"authtimeout")) {
9934 int timeout = atoi(
var->value);
9941 }
else if (!strcasecmp(
var->name,
"authlimit")) {
9942 int limit = atoi(
var->value);
9949 }
else if (!strcasecmp(
var->name,
"channelvars")) {
9951 }
else if (!strcasecmp(
var->name,
"disabledevents")) {
9992 if (!strcasecmp(cat,
"general")) {
10005 user->readperm = 0;
10006 user->writeperm = 0;
10011 user->writetimeout = 100;
10014 if (!
user->includefilters || !
user->excludefilters) {
10028 oldacl =
user->acl;
10034 if (!strcasecmp(
var->name,
"secret")) {
10037 }
else if (!strcasecmp(
var->name,
"deny") ||
10038 !strcasecmp(
var->name,
"permit") ||
10039 !strcasecmp(
var->name,
"acl")) {
10044 ast_log(
LOG_ERROR,
"Invalid ACL '%s' for manager user '%s' on line %d. Deleting user\n",
10048 }
else if (!strcasecmp(
var->name,
"read") ) {
10050 }
else if (!strcasecmp(
var->name,
"write") ) {
10052 }
else if (!strcasecmp(
var->name,
"displayconnects") ) {
10054 }
else if (!strcasecmp(
var->name,
"allowmultiplelogin") ) {
10056 }
else if (!strcasecmp(
var->name,
"writetimeout")) {
10063 }
else if (!strcasecmp(
var->name,
"setvar")) {
10072 if ((varval = strchr(varname,
'='))) {
10076 user->chanvars = tmpvar;
10083 ast_debug(1,
"%s is an unknown option.\n",
var->name);
10092 if (acl_subscription_flag && !by_external_config) {
10141 if (newhttptimeout > 0) {
10177#ifdef TEST_FRAMEWORK
10219 if ((datastore->
uid !=
NULL) && !strcasecmp(
uid, datastore->
uid)) {
10232 if (!*fields_string) {
10234 if (!*fields_string) {
10250__attribute__((format(printf, 3, 4)))
10254 const
char *extra_fields_fmt,
10276 va_start(argp, extra_fields_fmt);
10289 .
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)
void ast_alertpipe_close(int alert_pipe[2])
Close an alert pipe.
ssize_t ast_alertpipe_write(int alert_pipe[2])
Write an event to an alert pipe.
void ast_alertpipe_clear(int alert_pipe[2])
Sets the alert pipe file descriptors to default values.
int ast_alertpipe_init(int alert_pipe[2])
Initialize an alert pipe.
int attribute_pure ast_alertpipe_readfd(int alert_pipe[2])
Get the alert pipe's read file descriptor.
ast_alert_status_t ast_alertpipe_read(int alert_pipe[2])
Read an event from an alert pipe.
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()
int ao2_container_dup(struct ao2_container *dest, struct ao2_container *src, enum search_flags flags)
Copy all object references in the src container into the dest container.
#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)
@ AO2_ITERATOR_DONTLOCK
Assume that the ao2_container is already locked.
#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_STRING_FIELD_SORT_FN(stype, field)
Creates a sort function for a structure string field.
#define ao2_container_alloc_rbtree(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a red-black tree 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.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
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.
#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.
@ AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE
Replace objects with duplicate keys 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
#define send_event(_instance, _event,...)
Use this macro to create and send events passing in any event-specific parameters.
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)
@ AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT
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.
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 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 void log_action(const struct message *m, const char *action)
static int __manager_event_sessions_va(struct ao2_container *sessions, int category, const char *event_name, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *fmt, va_list ap)
static void report_invalid_user(const struct mansession *s, const char *username)
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 void session_notify(struct mansession_session *session)
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 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)
static int action_waitevent_http(struct mansession *s, const struct message *m, const char *id, int timeout)
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 const struct @400 command_blacklist[]
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 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 void manager_subscription_change_msg_cb(void *userdata, struct stasis_subscription *sub, struct stasis_message *message)
Callback for subscription change messages.
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 get_input(struct mansession *s, struct pollfd *pfds, char *output)
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)
Send any pending events to the client listening on this socket.
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 void eventqent_destructor(void *obj)
Destructor for manager event message.
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 struct mansession_session * build_mansession(const struct ast_sockaddr *addr, unsigned int needs_alert_pipe)
Allocate manager session structure and add it to the list of sessions.
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.
static int action_waitevent_tcp(struct mansession *s, const struct message *m, const char *id, int timeout)
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
Initial size of the manager event message buffer.
static const struct permalias perms[]
#define manager_event_sessions(sessions, category, event, contents,...)
static struct eventqent * eventqent_alloc(const char *event_name, int category)
Allocate a manager event.
static char * manager_disabledevents
int ast_manager_unregister(const char *action)
support functions to register/unregister AMI action handlers,
@ 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 stasis_message_type * stasis_subscription_change_type(void)
Gets the message type for subscription change notices.
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.
@ CONFIG_FLAG_WITHCOMMENTS
@ CONFIG_FLAG_FILEUNCHANGED
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.
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_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 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
static int event_max_name_len_cb(void *obj, void *arg, void *data, int flags)
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.
#define ast_poll(a, b, c)
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.
int stasis_subscription_final_message(struct stasis_subscription *sub, struct stasis_message *msg)
Determine whether a message is the final message to be received on a subscription.
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)
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"....
#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.
@ AST_DYNSTR_BUILD_FAILED
#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::@224 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 ast_manager_user::@403 list
struct ao2_container * includefilters
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_str * provided_by
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
int category
Category this event belongs to.
int event_name_hash
Hash of the name of the event.
struct ast_str * message
The contents of the AMI event message.
helper function for originate
struct ast_variable * vars
struct ast_format_cap * cap
struct ast_module *enum ast_doc_src docsrc
struct manager_action::@251 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 mansession_session::@402 list
struct ast_iostream * stream
struct mansession_session::@401 pending_events
struct timeval sessionstart_tv
ast_mutex_t pending_events_lock
ast_mutex_t http_thread_lock
struct mansession_session::mansession_datastores datastores
struct ao2_container * includefilters
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_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.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_STEAL_ELEMENTS(vec)
Steal the elements from a vector and reinitialize.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
#define AST_VECTOR(name, type)
Define a vector structure.
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_build_provided_by(const char *type, const char *name, const char *module)
Generate provided-by documentation from XML.
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...