175#define DEFAULT_REALM "asterisk"
203#define MGR_SHOW_TERMINAL_WIDTH 80
208#define EVENT_FLAG_SHUTDOWN -1
220#define MAX_BLACKLIST_CMD_LEN 2
224 {{
"module",
"load",
NULL }},
225 {{
"module",
"unload",
NULL }},
226 {{
"restart",
"gracefully",
NULL }},
414 const char *filter_pattern,
struct ao2_container *includefilters,
441 ao2_t_ref(act, +1,
"found action object");
486 size_t index,
struct ast_str **res,
496 const char *parent_key,
struct ast_str **res,
501 ast_str_set(&key_str, 0,
"%s/%s", parent_key, key);
524 if (exclusion_cb && key && exclusion_cb(key)) {
538 key, j, res, exclusion_cb);
547 key, res, exclusion_cb);
562#define manager_event_sessions(sessions, category, event, contents , ...) \
563 __manager_event_sessions(sessions, category, event, 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__)
565#define any_manager_listeners(sessions) \
566 ((sessions && ao2_container_count(sessions)) || !AST_RWLIST_EMPTY(&manager_hooks))
659 "class_type", class_type,
786#define MAX_AUTH_PERM_STRING 150
793 strstr(evaluating,
"SHELL") ||
794 strstr(evaluating,
"EVAL")
835 if (authority &
perms[i].num) {
855static int ast_instring(
const char *bigstr,
const char *smallstr,
const char delim)
857 const char *
val = bigstr, *next;
860 if ((next = strchr(
val, delim))) {
861 if (!strncmp(
val, smallstr, (next -
val))) {
867 return !strcmp(smallstr,
val);
869 }
while (*(
val = (next + 1)));
903 for (p =
string; *p; p++) {
904 if (*p <
'0' || *p >
'9') {
930 ast_debug(1,
"Mansession: %p refcount now %d\n", s, refcount - 1);
967 ao2_t_ref(
session->includefilters, -1,
"decrement ref for include container, should be last one");
971 ao2_t_ref(
session->excludefilters, -1,
"decrement ref for exclude container, should be last one");
1059 if (!strcasecmp(
user->username,
name)) {
1078 ret =
user->displayconnects;
1095 const char *auth_str;
1099 e->
command =
"manager show command";
1101 "Usage: manager show command <actionname> [<actionname> [<actionname> [...]]]\n"
1102 " Shows the detailed description for a specific Asterisk manager interface command.\n";
1105 l = strlen(
a->word);
1108 if (!strncasecmp(
a->word, cur->
action, l)) {
1125 for (num = 3; num <
a->argc; num++) {
1126 if (!strcasecmp(cur->
action,
a->argv[num])) {
1141 if (!
synopsis || !provided_by || !since || !description || !syntax || !arguments
1142 || !privilege || !seealso || !responses) {
1152 ast_cli(
a->fd,
"Allocation failure.\n");
1159 "%s -= Info about Manager Command '%s' =- %s\n\n"
1190 ast_cli(
a->fd,
"%s\n\n", responses);
1208 ast_cli(
a->fd,
"%s\n\n", responses);
1230 ast_cli(
a->fd,
"Action: %s\nSynopsis: %s\nPrivilege: %s\n%s\n",
1247 e->
command =
"manager set debug [on|off]";
1248 e->
usage =
"Usage: manager set debug [on|off]\n Show, enable, disable debugging of the manager code.\n";
1256 }
else if (
a->argc == 4) {
1257 if (!strcasecmp(
a->argv[3],
"on")) {
1259 }
else if (!strcasecmp(
a->argv[3],
"off")) {
1278 e->
command =
"manager show user";
1280 " Usage: manager show user <user>\n"
1281 " Display all information related to the manager user specified.\n";
1284 l = strlen(
a->word);
1290 if (!strncasecmp(
a->word,
user->username, l)) {
1307 ast_cli(
a->fd,
"There is no manager called %s\n",
a->argv[3]);
1319 " displayconnects: %s\n"
1320 "allowmultiplelogin: %s\n",
1322 (
user->secret ?
"<Set>" :
"(N/A)"),
1326 (
user->displayconnects ?
"yes" :
"no"),
1327 (
user->allowmultiplelogin ?
"yes" :
"no"));
1329 for (v =
user->chanvars ; v ; v = v->
next) {
1347 e->
command =
"manager show users";
1349 "Usage: manager show users\n"
1350 " Prints a listing of all managers that are currently configured on that\n"
1364 ast_cli(
a->fd,
"There are no manager users.\n");
1369 ast_cli(
a->fd,
"\nusername\n--------\n");
1378 ast_cli(
a->fd,
"-------------------\n"
1379 "%d manager users configured.\n", count_amu);
1388 int space_remaining;
1389#define HSMC_FORMAT " %-*.*s %-.*s\n"
1392 e->
command =
"manager show commands";
1394 "Usage: manager show commands\n"
1395 " Prints a listing of all the available Asterisk manager interface commands.\n";
1403 int incoming_len = strlen(cur->
action);
1404 if (incoming_len > name_len) {
1405 name_len = incoming_len;
1410 if (space_remaining < 0) {
1411 space_remaining = 0;
1436 e->
command =
"manager kick session";
1438 "Usage: manager kick session <file descriptor>\n"
1439 " Kick an active Asterisk Manager Interface session\n";
1449 fd = atoi(
a->argv[3]);
1451 ast_cli(
a->fd,
"Invalid AMI file descriptor: %s\n",
a->argv[3]);
1464 ast_cli(
a->fd,
"Manager session using file descriptor %d has already been kicked\n", fd);
1471 ast_cli(
a->fd,
"Kicking manager session connected using file descriptor %d\n", fd);
1475 pthread_kill(
session->waiting_thread, SIGURG);
1490 ast_cli(
a->fd,
"No manager session found using file descriptor %d\n", fd);
1500 time_t now = time(
NULL);
1501#define HSMCONN_FORMAT1 " %-15.15s %-55.55s %-10.10s %-10.10s %-8.8s %-8.8s %-10.10s %-10.10s\n"
1502#define HSMCONN_FORMAT2 " %-15.15s %-55.55s %-10d %-10d %-8d %-8d %-10.10d %-10.10d\n"
1508 e->
command =
"manager show connected";
1510 "Usage: manager show connected\n"
1511 " Prints a listing of the users that are currently connected to the\n"
1512 "Asterisk manager interface.\n";
1518 ast_cli(
a->fd,
HSMCONN_FORMAT1,
"Username",
"IP Address",
"Start",
"Elapsed",
"FileDes",
"HttpCnt",
"ReadPerms",
"WritePerms");
1528 (
int) (
session->sessionstart),
1529 (
int) (now -
session->sessionstart),
1540 ast_cli(
a->fd,
"%d users connected.\n", count);
1552 e->
command =
"manager show eventq";
1554 "Usage: manager show eventq\n"
1555 " Prints a listing of all events pending in the Asterisk manger\n"
1579 e->
command =
"manager reload";
1581 "Usage: manager reload\n"
1582 " Reloads the manager configuration.\n";
1607#define GET_HEADER_FIRST_MATCH 0
1608#define GET_HEADER_LAST_MATCH 1
1609#define GET_HEADER_SKIP_EMPTY 2
1626 int x, l = strlen(
var);
1633 for (x = 0; x < m->
hdrcount; x++) {
1634 const char *h = m->
headers[x];
1635 if (!strncasecmp(
var, h, l) && h[l] ==
':') {
1636 const char *
value = h + l + 1;
1719 for (y = 0; y <
args.argc; y++) {
1724 if (!
args.vars[y]) {
1759 static const char var_hdr[] =
"Variable:";
1762 varlen = strlen(var_hdr);
1763 for (x = 0; x < m->
hdrcount; x++) {
1764 if (strncasecmp(var_hdr, m->
headers[x], varlen)) {
1801 curlen = strlen(src);
1802 for (x = 0; x < curlen; x++) {
1804 if (src[x] ==
'\r' && x+1 < curlen && src[x+1] ==
'\n')
1806 else if (src[x] ==
'\n')
1825 if (!strcasecmp(action,
"login")) {
1848 if (!act_found->module || mod_ref) {
1849 ret = act_found->
func(&s, &m);
1855 ao2_t_ref(act_found, -1,
"done with found action object");
1907#define ASTMAN_APPEND_BUF_INITSIZE 256
1914 ast_verbose(
"No connection stream in astman_append, should not happen\n");
1941 ast_verbose(
"No connection stream in astman_append, should not happen\n");
1955#define MSG_MOREDATA ((char *)astman_send_response)
2062 "EventList: Complete\r\n"
2063 "ListItems: %d\r\n",
2128 char session_id[32];
2132 .common.service =
"AMI",
2133 .common.account_id = username,
2135 .common.local_addr = {
2139 .common.remote_addr = {
2143 .common.session_id = session_id,
2146 snprintf(session_id,
sizeof(session_id),
"%p", s);
2153 char session_id[32];
2157 .common.service =
"AMI",
2158 .common.account_id = username,
2160 .common.local_addr = {
2164 .common.remote_addr = {
2168 .common.session_id = session_id,
2171 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2178 char session_id[32];
2182 .common.service =
"AMI",
2183 .common.account_id = username,
2185 .common.local_addr = {
2189 .common.remote_addr = {
2193 .common.session_id = session_id,
2196 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2203 char session_id[32];
2207 .common.service =
"AMI",
2210 .common.local_addr = {
2214 .common.remote_addr = {
2218 .common.session_id = session_id,
2221 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2228 char session_id[32];
2229 char request_type[64];
2233 .common.service =
"AMI",
2236 .common.local_addr = {
2240 .common.remote_addr = {
2244 .common.session_id = session_id,
2249 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2257 char session_id[32];
2262 .common.service =
"AMI",
2265 .common.local_addr = {
2269 .common.remote_addr = {
2273 .common.session_id = session_id,
2278 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2285 const char *response,
const char *expected_response)
2287 char session_id[32];
2291 .common.service =
"AMI",
2294 .common.local_addr = {
2298 .common.remote_addr = {
2302 .common.session_id = session_id,
2309 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2316 char session_id[32];
2320 .common.service =
"AMI",
2323 .common.local_addr = {
2327 .common.remote_addr = {
2331 .common.session_id = session_id,
2334 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2352 regex_t *regex_filter;
2373 char md5key[256] =
"";
2375 unsigned char digest[16];
2381 for (x = 0; x < 16; x++)
2382 len += sprintf(md5key +
len,
"%02hhx", digest[x]);
2383 if (!strcmp(md5key, key)) {
2389 ast_debug(1,
"MD5 authentication is not possible. challenge: '%s'\n",
2392 }
else if (
user->secret) {
2393 if (!strcmp(password,
user->secret)) {
2415 if (
user->chanvars) {
2422 ao2_t_ref(regex_filter, -1,
"remove iterator ref");
2429 ao2_t_ref(regex_filter, -1,
"remove iterator ref");
2455 "Timestamp: %ld.%06lu\r\n"
2457 (
long) now.tv_sec, (
unsigned long) now.tv_usec);
2484 char *stripped_filename;
2495 if (stripped_filename[0] ==
'/') {
2496 real_path = realpath(stripped_filename,
NULL);
2501 real_path = realpath(path,
NULL);
2521 const char *category_name;
2538 }
else if (ret == -1) {
2558 astman_append(s,
"Category-%06d: %s\r\n", catcount, category_name);
2606 }
else if (ret == -1) {
2625 if (catcount == 0) {
2639 if (*
in ==
'\\' || *
in ==
'\"') {
2670 const char *category_name;
2746 for (x = 0; x < 100000; x++) {
2747 unsigned int object = 0;
2751 int ignoreerror = 0;
2759 snprintf(hdr,
sizeof(hdr),
"Action-%06d", x);
2764 snprintf(hdr,
sizeof(hdr),
"Cat-%06d", x);
2771 snprintf(hdr,
sizeof(hdr),
"Var-%06d", x);
2774 snprintf(hdr,
sizeof(hdr),
"Value-%06d", x);
2782 snprintf(hdr,
sizeof(hdr),
"Match-%06d", x);
2785 snprintf(hdr,
sizeof(hdr),
"Line-%06d", x);
2788 snprintf(hdr,
sizeof(hdr),
"Options-%06d", x);
2795 if (!strcasecmp(
"allowdups", token)) {
2799 if (!strcasecmp(
"template", token)) {
2803 if (!strcasecmp(
"ignoreerror", token)) {
2826 if (!strcasecmp(action,
"newcat")) {
2828 char *tmpl_name =
NULL;
2868 if (category !=
NULL) {
2879 }
else if (!strcasecmp(action,
"renamecat")) {
2895 }
else if (!strcasecmp(action,
"delcat")) {
2902 if (!foundcat && !ignoreerror) {
2906 }
else if (!strcasecmp(action,
"emptycat")) {
2917 }
else if (!strcasecmp(action,
"update")) {
2941 }
else if (!strcasecmp(action,
"delete")) {
2961 if (!foundvar && !ignoreerror) {
2965 }
else if (!strcasecmp(action,
"append")) {
2977 if (
object || (
match && !strcasecmp(
match,
"object"))) {
2988 }
else if (!strcasecmp(action,
"insert")) {
3028 const char *preserve_effective_context_string =
astman_get_header(m,
"PreserveEffectiveContext");
3115 char *stripped_filename;
3129 if (stripped_filename[0] !=
'/') {
3148 filename = strrchr(filepath,
'/');
3157 real_dir = realpath(filepath,
NULL);
3170 if (
ast_asprintf(&real_path,
"%s/%s", real_dir, filename) == -1) {
3175 if ((fd = open(real_path, O_CREAT | O_EXCL,
AST_FILE_MODE)) != -1) {
3195 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n",
id);
3201 sscanf(timeouts,
"%30i", &timeout);
3222 time_t now = time(
NULL);
3228 if (timeout < 0 || timeout >
max) {
3240 ast_debug(1,
"Starting waiting for an event!\n");
3242 for (x = 0; x < timeout || timeout < 0; x++) {
3271 ast_debug(1,
"Finished waiting for an event!\n");
3291 "Event: WaitEventComplete\r\n"
3297 ast_debug(1,
"Abandoning event request!\n");
3330 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n",
id);
3342 if (!strcasecmp(
perms[x].label,
"all") && res ==
perms[x].
num) {
3347 "Events: On\r\n\r\n", id_text);
3348 }
else if (res == 0)
3350 "Events: Off\r\n\r\n", id_text);
3356 "Events: On\r\n\r\n", id_text);
3359 "Events: Off\r\n\r\n", id_text);
3398 long lastreloaded = 0;
3404 uptime = tmp.tv_sec;
3409 lastreloaded = tmp.tv_sec;
3415 "LastReload: %ld\r\n"
3416 "Status: Fully Booted\r\n\r\n", cat_str, uptime, lastreloaded);
3425 if (!strcasecmp(authtype,
"MD5")) {
3452 int channels_matched = 0;
3460 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n",
id);
3465 if (cause_validator) {
3466 causecode = cause_validator(name_or_regex, cause);
3469 causecode = strtol(cause, &endptr, 10);
3470 if (causecode < 0 || causecode > 127 || *endptr !=
'\0') {
3480 if (name_or_regex[0] !=
'/') {
3488 ast_verb(3,
"%sManager '%s' from %s, hanging up channel: %s\n",
3494 hangup_handler(
c, causecode);
3506 if (!regex_string) {
3513 astman_send_error(s, m,
"Regex format invalid, Channel param should be /regex/");
3519 if (regcomp(®exbuf,
ast_str_buffer(regex_string), REG_EXTENDED | REG_NOSUB)) {
3534 ast_verb(3,
"%sManager '%s' from %s, hanging up channel: %s\n",
3540 hangup_handler(
c, causecode);
3544 "Event: ChannelHungup\r\n"
3605 char workspace[1024];
3625 workspace[0] =
'\0';
3626 if (varname[strlen(varname) - 1] ==
')') {
3630 ast_func_read(
c, (
char *) varname, workspace,
sizeof(workspace));
3632 ast_log(
LOG_ERROR,
"Unable to allocate bogus channel for variable substitution. Function results may be blank.\n");
3634 ast_func_read(
c, (
char *) varname, workspace,
sizeof(workspace));
3646 astman_append(s,
"Variable: %s\r\nValue: %s\r\n\r\n", varname,
S_OR(varval,
""));
3654 long elapsed_seconds;
3672 if (!snapshot_str) {
3676 if (all_variables) {
3681 if (!variable_str) {
3690 for (i = 0; i < varc; i++) {
3691 char valbuf[512], *ret =
NULL;
3693 if (vars[i][strlen(vars[i]) - 1] ==
')') {
3694 if (
ast_func_read(chan, vars[i], valbuf,
sizeof(valbuf)) < 0) {
3702 ast_str_append(&variable_str, 0,
"Variable: %s=%s\r\n", vars[i], ret);
3706 if (all_variables) {
3720 "Privilege: Call\r\n"
3724 "EffectiveConnectedLineNum: %s\r\n"
3725 "EffectiveConnectedLineName: %s\r\n"
3726 "TimeToHangup: %ld\r\n"
3728 "Application: %s\r\n"
3730 "Nativeformats: %s\r\n"
3731 "Readformat: %s\r\n"
3733 "Writeformat: %s\r\n"
3734 "Writetrans: %s\r\n"
3735 "Callgroup: %llu\r\n"
3736 "Pickupgroup: %llu\r\n"
3757 (long)elapsed_seconds,
3771 int all_variables = 0;
3784 all_variables =
ast_true(all_chan_variables);
3809 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n",
id);
3861 obj_size = payload_size +
sizeof(*obj);
3870 memcpy(obj->
payload, payload, payload_size);
3904 const char *content_type)
4007 if (sscanf(
priority,
"%30d", &pi) != 1) {
4025 if (sscanf(priority2,
"%30d", &pi2) != 1) {
4036 snprintf(
buf,
sizeof(
buf),
"Channel does not exist: %s",
name);
4060 snprintf(
buf,
sizeof(
buf),
"ExtraChannel does not exist: %s", name2);
4237 if (!feature_code) {
4259 char *cmd_copy, *cur_cmd;
4271 cmd_words[i] = cur_cmd;
4296 char *
buf =
NULL, *final_buf =
NULL, *delim, *output;
4297 char template[] =
"/tmp/ast-ami-XXXXXX";
4311 if ((fd = mkstemp(
template)) < 0) {
4320 if ((
len = lseek(fd, 0, SEEK_END)) < 0) {
4321 astman_append(s,
"Message: Failed to determine number of characters: %s\r\n", strerror(
errno));
4322 goto action_command_cleanup;
4329 if (!
buf || !final_buf) {
4331 goto action_command_cleanup;
4334 if (lseek(fd, 0, SEEK_SET) < 0) {
4335 astman_append(s,
"Message: Failed to set position on temporary file: %s\r\n", strerror(
errno));
4336 goto action_command_cleanup;
4339 if (read(fd,
buf,
len) < 0) {
4340 astman_append(s,
"Message: Failed to read from temporary file: %s\r\n", strerror(
errno));
4341 goto action_command_cleanup;
4346 final_buf[
len] =
'\0';
4349 if (
len && final_buf[
len - 1] ==
'\n') {
4350 final_buf[
len - 1] =
'\0';
4356 while ((output =
strsep(&delim,
"\n"))) {
4360action_command_cleanup:
4418 .uniqueid2 =
in->otherchannelid
4423 in->timeout,
in->app,
in->appdata, &reason,
4427 in->vars,
in->account, &chan, &assignedids);
4430 in->timeout,
in->context,
in->exten,
in->priority, &reason,
4434 in->vars,
in->account, &chan,
in->early_media, &assignedids);
4447 "Application: %s\r\n"
4451 "CallerIDNum: %s\r\n"
4452 "CallerIDName: %s\r\n",
4453 in->idtext, res ?
"Failure" :
"Success",
4455 in->app,
in->appdata, reason,
4457 S_OR(
in->cid_num,
"<unknown>"),
4458 S_OR(
in->cid_name,
"<unknown>")
4469 "CallerIDNum: %s\r\n"
4470 "CallerIDName: %s\r\n",
4471 in->idtext, res ?
"Failure" :
"Success",
4473 in->context,
in->exten, reason,
4475 S_OR(
in->cid_num,
"<unknown>"),
4476 S_OR(
in->cid_name,
"<unknown>")
4491 const char *unitamount;
4492 const char *unittype;
4495 memset(entry, 0,
sizeof(*entry));
4524 const char *association_num =
astman_get_header(m,
"ChargingAssociationNumber");
4532 unsigned int _currencyamount = 0;
4533 int _association_id = 0;
4534 unsigned int _association_plan = 0;
4540 goto aocmessage_cleanup;
4545 if (!strcasecmp(chargetype,
"NA")) {
4547 }
else if (!strcasecmp(chargetype,
"Free")) {
4549 }
else if (!strcasecmp(chargetype,
"Currency")) {
4551 }
else if (!strcasecmp(chargetype,
"Unit")) {
4555 goto aocmessage_cleanup;
4560 if (
ast_strlen_zero(currencyamount) || (sscanf(currencyamount,
"%30u", &_currencyamount) != 1)) {
4561 astman_send_error(s, m,
"Invalid CurrencyAmount, CurrencyAmount is a required when ChargeType is Currency");
4562 goto aocmessage_cleanup;
4566 astman_send_error(s, m,
"ChargeMultiplier unspecified, ChargeMultiplier is required when ChargeType is Currency.");
4567 goto aocmessage_cleanup;
4568 }
else if (!strcasecmp(mult,
"onethousandth")) {
4570 }
else if (!strcasecmp(mult,
"onehundredth")) {
4572 }
else if (!strcasecmp(mult,
"onetenth")) {
4574 }
else if (!strcasecmp(mult,
"one")) {
4576 }
else if (!strcasecmp(mult,
"ten")) {
4578 }
else if (!strcasecmp(mult,
"hundred")) {
4580 }
else if (!strcasecmp(mult,
"thousand")) {
4584 goto aocmessage_cleanup;
4591 goto aocmessage_cleanup;
4595 if (!
ast_strlen_zero(totaltype) && !strcasecmp(totaltype,
"subtotal")) {
4601 }
else if (!strcasecmp(aocbillingid,
"Normal")) {
4603 }
else if (!strcasecmp(aocbillingid,
"ReverseCharge")) {
4605 }
else if (!strcasecmp(aocbillingid,
"CreditCard")) {
4609 goto aocmessage_cleanup;
4614 }
else if (!strcasecmp(aocbillingid,
"Normal")) {
4616 }
else if (!strcasecmp(aocbillingid,
"ReverseCharge")) {
4618 }
else if (!strcasecmp(aocbillingid,
"CreditCard")) {
4620 }
else if (!strcasecmp(aocbillingid,
"CallFwdUnconditional")) {
4622 }
else if (!strcasecmp(aocbillingid,
"CallFwdBusy")) {
4624 }
else if (!strcasecmp(aocbillingid,
"CallFwdNoReply")) {
4626 }
else if (!strcasecmp(aocbillingid,
"CallDeflection")) {
4628 }
else if (!strcasecmp(aocbillingid,
"CallTransfer")) {
4632 goto aocmessage_cleanup;
4635 if (!
ast_strlen_zero(association_id) && (sscanf(association_id,
"%30d", &_association_id) != 1)) {
4637 goto aocmessage_cleanup;
4639 if (!
ast_strlen_zero(association_plan) && (sscanf(association_plan,
"%30u", &_association_plan) != 1)) {
4641 goto aocmessage_cleanup;
4644 if (_association_id) {
4658 for (i = 0; i < 32; i++) {
4668 astman_send_error(s, m,
"Invalid UnitAmount(0), At least one valid unit entry is required when ChargeType is set to Unit");
4669 goto aocmessage_cleanup;
4704 unsigned int _currencyamount = 0;
4706 unsigned int _time = 0;
4708 unsigned int _granularity = 0;
4715 goto aocmessage_cleanup;
4720 goto aocmessage_cleanup;
4723 if (!strcasecmp(chargeditem,
"NA")) {
4725 }
else if (!strcasecmp(chargeditem,
"SpecialArrangement")) {
4727 }
else if (!strcasecmp(chargeditem,
"BasicCommunication")) {
4729 }
else if (!strcasecmp(chargeditem,
"CallAttempt")) {
4731 }
else if (!strcasecmp(chargeditem,
"CallSetup")) {
4733 }
else if (!strcasecmp(chargeditem,
"UserUserInfo")) {
4735 }
else if (!strcasecmp(chargeditem,
"SupplementaryService")) {
4739 goto aocmessage_cleanup;
4742 if (!strcasecmp(ratetype,
"NA")) {
4744 }
else if (!strcasecmp(ratetype,
"Free")) {
4746 }
else if (!strcasecmp(ratetype,
"FreeFromBeginning")) {
4748 }
else if (!strcasecmp(ratetype,
"Duration")) {
4750 }
else if (!strcasecmp(ratetype,
"Flat")) {
4752 }
else if (!strcasecmp(ratetype,
"Volume")) {
4754 }
else if (!strcasecmp(ratetype,
"SpecialCode")) {
4758 goto aocmessage_cleanup;
4762 if (
ast_strlen_zero(currencyamount) || (sscanf(currencyamount,
"%30u",
4763 &_currencyamount) != 1)) {
4764 astman_send_error(s, m,
"Invalid CurrencyAmount, CurrencyAmount is a required when RateType is non-free");
4765 goto aocmessage_cleanup;
4769 astman_send_error(s, m,
"ChargeMultiplier unspecified, ChargeMultiplier is required when ChargeType is Currency.");
4770 goto aocmessage_cleanup;
4771 }
else if (!strcasecmp(mult,
"onethousandth")) {
4773 }
else if (!strcasecmp(mult,
"onehundredth")) {
4775 }
else if (!strcasecmp(mult,
"onetenth")) {
4777 }
else if (!strcasecmp(mult,
"one")) {
4779 }
else if (!strcasecmp(mult,
"ten")) {
4781 }
else if (!strcasecmp(mult,
"hundred")) {
4783 }
else if (!strcasecmp(mult,
"thousand")) {
4787 goto aocmessage_cleanup;
4793 astman_send_error(s, m,
"TimeScale unspecified, TimeScale is required when RateType is Duration.");
4794 goto aocmessage_cleanup;
4795 }
else if (!strcasecmp(timescale,
"onehundredthsecond")) {
4797 }
else if (!strcasecmp(timescale,
"onetenthsecond")) {
4799 }
else if (!strcasecmp(timescale,
"second")) {
4801 }
else if (!strcasecmp(timescale,
"tenseconds")) {
4803 }
else if (!strcasecmp(timescale,
"minute")) {
4805 }
else if (!strcasecmp(timescale,
"hour")) {
4807 }
else if (!strcasecmp(timescale,
"day")) {
4811 goto aocmessage_cleanup;
4815 astman_send_error(s, m,
"Invalid Time, Time is a required when RateType is Duration");
4816 goto aocmessage_cleanup;
4820 if ((sscanf(time,
"%30u", &_granularity) != 1)) {
4822 goto aocmessage_cleanup;
4826 astman_send_error(s, m,
"Invalid GranularityTimeScale, GranularityTimeScale is a required when Granularity is specified");
4827 }
else if (!strcasecmp(granularitytimescale,
"onehundredthsecond")) {
4829 }
else if (!strcasecmp(granularitytimescale,
"onetenthsecond")) {
4831 }
else if (!strcasecmp(granularitytimescale,
"second")) {
4833 }
else if (!strcasecmp(granularitytimescale,
"tenseconds")) {
4835 }
else if (!strcasecmp(granularitytimescale,
"minute")) {
4837 }
else if (!strcasecmp(granularitytimescale,
"hour")) {
4839 }
else if (!strcasecmp(granularitytimescale,
"day")) {
4843 goto aocmessage_cleanup;
4847 if (
ast_strlen_zero(chargingtype) || strcasecmp(chargingtype,
"continuouscharging") == 0) {
4849 }
else if (strcasecmp(chargingtype,
"stepfunction") == 0 ) {
4853 goto aocmessage_cleanup;
4859 astman_send_error(s, m,
"VolumeUnit unspecified, VolumeUnit is required when RateType is Volume.");
4860 goto aocmessage_cleanup;
4861 }
else if (!strcasecmp(timescale,
"octet")) {
4863 }
else if (!strcasecmp(timescale,
"segment")) {
4865 }
else if (!strcasecmp(timescale,
"message")) {
4869 goto aocmessage_cleanup;
4876 astman_send_error(s, m,
"Invalid Code, Code is a required when ChargedItem is SpecialArrangement and when RateType is SpecialCode");
4877 goto aocmessage_cleanup;
4885 currencyname, _time, _scale, _granularity, _granularity_time_scale, _step);
4891 _mult, currencyname);
4915 static const char hdr[] =
"ChargedItem:";
4921 goto aocmessage_cleanup;
4924 hdrlen = strlen(hdr);
4925 for (x = 0; x < m->
hdrcount; x++) {
4926 if (strncasecmp(hdr, m->
headers[x], hdrlen) == 0) {
4929 goto aocmessage_cleanup;
4940 goto aocmessage_cleanup;
4962 size_t encoded_size = 0;
4965 astman_send_error(s, m,
"Channel and PartialChannel are not specified. Specify at least one of these.");
4966 goto aocmessage_cleanup;
4975 goto aocmessage_cleanup;
4978 if (strcasecmp(msgtype,
"d") == 0 || strcasecmp(msgtype,
"e") == 0) {
4981 else if (strcasecmp(msgtype,
"s") == 0) {
4986 goto aocmessage_cleanup;
4990 goto aocmessage_cleanup;
4997 astman_send_error(s, m,
"Error encoding AOC message, could not queue onto channel");
5014 int (*searchfn)(
const char *
app,
const char *data,
const char *search);
5051 return !!(strstr(data, search));
5153#ifdef TEST_FRAMEWORK
5154#define ALL_PERMISSIONS (INT_MAX)
5155#define NO_PERMISSIONS (0)
5162 info->name =
"originate_permissions_test";
5163 info->category =
"/main/manager/";
5164 info->summary =
"Test permissions for originate action";
5166 "Make sure that dialplan apps/functions that need special "
5167 "permissions are prohibited if the user doesn't have the permission.";
5183 NULL, ALL_PERMISSIONS),
"exec check permission failed");
5189 NULL, NO_PERMISSIONS),
"exec permission check failed");
5200 NULL, NO_PERMISSIONS),
"Queue permission check failed");
5202 "somequeue,CcdHh,someURL,tt-monkeys,100,,gosub,rule,666",
5207 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5210 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5213 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5214 ALL_PERMISSIONS),
"Queue permission check failed");
5218 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5219 NO_PERMISSIONS),
"Queue permission check failed");
5221 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5230 "aaa DB bbb", ALL_PERMISSIONS),
"exec permission check failed");
5232 "aaaDBbbb", NO_PERMISSIONS),
"exec permission check failed");
5234 "aaa DB bbb", NO_PERMISSIONS),
"exec permission check failed");
5237 "aaa db bbb", NO_PERMISSIONS),
"exec permission check failed");
5241#undef ALL_PERMISSIONS
5242#undef NO_PERMISSIONS
5277 int bridge_early = 0;
5290 goto fast_orig_cleanup;
5296 goto fast_orig_cleanup;
5302 goto fast_orig_cleanup;
5305 if (!
ast_strlen_zero(timeout) && (sscanf(timeout,
"%30d", &to) != 1)) {
5308 goto fast_orig_cleanup;
5312 data = strchr(tmp,
'/');
5316 goto fast_orig_cleanup;
5341 goto fast_orig_cleanup;
5346 if (exten && context && pi) {
5351 goto fast_orig_cleanup;
5366 for (v = vars; v->
next; v = v->
next );
5372 bridge_early =
ast_true(early_media);
5416 if (exten && context && pi) {
5419 l, n, vars, account,
NULL, bridge_early,
5423 astman_send_error(s, m,
"Originate with 'Exten' requires 'Context' and 'Priority'");
5426 goto fast_orig_cleanup;
5453 "Waiting: %d\r\n\r\n", mailbox, ret);
5460 int newmsgs = 0, oldmsgs = 0, urgentmsgs = 0;;
5470 "UrgMessages: %d\r\n"
5471 "NewMessages: %d\r\n"
5472 "OldMessages: %d\r\n"
5474 mailbox, urgentmsgs, newmsgs, oldmsgs);
5490 context =
"default";
5501 "StatusText: %s\r\n"
5503 exten, context, hint,
status,
5540 "PresenceMessage: %s\r\n",
5556 struct timeval when = { timeout, 0 };
5563 if (!timeout || timeout < 0) {
5573 when.tv_usec = (timeout - when.tv_sec) * 1000000.0;
5617 char *line_buffer_start =
NULL;
5618 char *line_buffer =
NULL;
5637 line_buffer = line_buffer_start;
5638 if (!line_buffer_start) {
5652 line_buffer_start =
NULL;
5710 if (!strcasecmp(operation,
"Add")) {
5718 S_COR(have_match,
"(",
""),
S_OR(match_criteria,
""),
5719 S_COR(have_match,
")",
""));
5721 astman_send_error(s, m,
"Internal Error. Failed to allocate storage for filter type");
5733 "Filter did not compile. Check the syntax of the filter given.");
5737 "Filter was formatted incorrectly. Check the syntax of the filter given.");
5771 const char *criteria,
const char *filter_pattern,
5777 const char *options_start =
NULL;
5778 SCOPE_ENTER(3,
"manager_add_filter(%s, %s, %p, %p)", criteria, filter_pattern, includefilters, excludefilters);
5780 if (!filter_entry) {
5795 if (!filter_pattern) {
5805 if (filter_pattern[0] ==
'!') {
5806 filter_entry->is_excludefilter = 1;
5818 options_start = strstr(criteria,
"(");
5825 "'%s = %s': Legacy filter with no filter pattern specified\n",
5826 criteria, filter_pattern);
5829 if (options_start) {
5834 char *saveptr =
NULL;
5835 char *option =
NULL;
5836 enum found_options {
5837 action_found = (1 << 0),
5838 name_found = (1 << 1),
5839 header_found = (1 << 2),
5840 method_found = (1 << 3),
5842 enum found_options options_found = 0;
5849 "'%s = %s': Filter options not formatted correctly\n",
5850 criteria, filter_pattern);
5858 while ((option = strtok_r(temp,
" ,)", &saveptr))) {
5859 if (!strncmp(option,
"action", 6)) {
5860 char *
method = strstr(option,
"(");
5863 criteria, filter_pattern);
5867 if (!strcmp(
method,
"include")) {
5868 filter_entry->is_excludefilter = 0;
5869 }
else if (!strcmp(
method,
"exclude")) {
5870 filter_entry->is_excludefilter = 1;
5873 criteria, filter_pattern,
method);
5875 options_found |= action_found;
5876 }
else if (!strncmp(option,
"name", 4)) {
5877 char *event_name = strstr(option,
"(");
5882 criteria, filter_pattern);
5884 filter_entry->event_name =
ast_strdup(event_name);
5885 filter_entry->event_name_hash =
ast_str_hash(event_name);
5886 options_found |= name_found;
5887 }
else if (!strncmp(option,
"header", 6)) {
5888 char *header_name = strstr(option,
"(");
5893 criteria, filter_pattern);
5896 filter_entry->header_name =
ast_malloc(strlen(header_name) + 2);
5897 if (!filter_entry->header_name) {
5900 sprintf(filter_entry->header_name,
"%s:", header_name);
5902 filter_entry->header_name =
ast_strdup(header_name);
5904 options_found |= header_found;
5905 }
else if (!strncmp(option,
"method", 6)) {
5906 char *
method = strstr(option,
"(");
5911 criteria, filter_pattern);
5913 if (!strcmp(
method,
"regex")) {
5915 }
else if (!strcmp(
method,
"exact")) {
5917 }
else if (!strcmp(
method,
"starts_with")) {
5919 }
else if (!strcmp(
method,
"ends_with")) {
5921 }
else if (!strcmp(
method,
"contains")) {
5923 }
else if (!strcmp(
method,
"none")) {
5927 criteria, filter_pattern,
method);
5929 options_found |= method_found;
5932 criteria, filter_pattern, option);
5936 if (!options_found) {
5938 "'%s = %s': No action, name, header, or method option found\n",
5939 criteria, filter_pattern);
5943 "'%s = %s': method can't be '%s' with no filter pattern\n",
5948 "'%s = %s': method can't be 'none' with a filter pattern\n",
5949 criteria, filter_pattern);
5951 if (!(options_found & name_found) && !(options_found & header_found) &&
5954 "'%s = %s': No name or header option found and no filter pattern\n",
5955 criteria, filter_pattern);
5961 filter_entry->regex_filter =
ast_calloc(1,
sizeof(regex_t));
5962 if (!filter_entry->regex_filter) {
5965 if (regcomp(filter_entry->regex_filter, filter_pattern, REG_EXTENDED | REG_NOSUB)) {
5969 filter_entry->string_filter =
ast_strdup(filter_pattern);
5974 "conf entry: %s = %s\n"
5975 "event_name: %s (hash: %d)\n"
5978 "regex_filter: %p\n"
5979 "string filter: %s\n"
5980 "is excludefilter: %d\n",
5981 criteria, filter_pattern,
5982 S_OR(filter_entry->event_name,
"<not used>"),
5983 filter_entry->event_name_hash,
5984 S_OR(filter_entry->header_name,
"<not used>"),
5986 filter_entry->regex_filter,
5987 filter_entry->string_filter,
5988 filter_entry->is_excludefilter);
5990 if (filter_entry->is_excludefilter) {
5991 ao2_t_link(excludefilters, filter_entry,
"link new filter into exclude user container");
5993 ao2_t_link(includefilters, filter_entry,
"link new filter into include user container");
5999#ifdef TEST_FRAMEWORK
6001struct test_filter_data {
6002 const char *criteria;
6006 const char *test_event_name;
6007 const char *test_event_payload;
6008 int expected_should_send_event;
6011static char *add_filter_result_enums[] = {
6018#define TEST_EVENT_NEWCHANNEL "Newchannel", "Event: Newchannel\r\nChannel: XXX\r\nSomeheader: YYY\r\n"
6019#define TEST_EVENT_VARSET "VarSet", "Event: VarSet\r\nChannel: ABC\r\nSomeheader: XXX\r\n"
6020#define TEST_EVENT_NONE "", ""
6022static struct test_filter_data parsing_filter_tests[] = {
6030 {
"eventfilter(name(Newchannel),method(regex))",
"X[XYZ]X",
FILTER_SUCCESS,
6032 {
"eventfilter(name(Newchannel),method(regex))",
"X[abc]X",
FILTER_SUCCESS,
6034 {
"eventfilter(action(exclude),name(Newchannel),method(regex))",
"X[XYZ]X",
FILTER_SUCCESS,
6036 {
"eventfilter(action(exclude),name(Newchannel),method(regex))",
"X[abc]X",
FILTER_SUCCESS,
6038 {
"eventfilter(action(include),name(VarSet),header(Channel),method(starts_with))",
"AB",
FILTER_SUCCESS,
6040 {
"eventfilter(action(include),name(VarSet),header(Channel),method(ends_with))",
"BC",
FILTER_SUCCESS,
6042 {
"eventfilter(action(include),name(VarSet),header(Channel),method(exact))",
"ABC",
FILTER_SUCCESS,
6044 {
"eventfilter(action(include),name(VarSet),header(Channel),method(exact))",
"XXX",
FILTER_SUCCESS,
6046 {
"eventfilter(name(VarSet),header(Channel),method(exact))",
"!ZZZ",
FILTER_SUCCESS,
6048 {
"eventfilter(action(exclude),name(VarSet),header(Channel),method(exact))",
"ZZZ",
FILTER_SUCCESS,
6050 {
"eventfilter(action(include),name(VarSet),header(Someheader),method(exact))",
"!XXX",
FILTER_SUCCESS,
6059 {
"eventfilter(nnnn(yyy),header(VarSet),method(contains)",
"XXX",
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
6060 {
"eventfilter(name(yyy),heder(VarSet),method(contains)",
"XXX",
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
6061 {
"eventfilter(name(yyy),header(VarSet),mehod(contains)",
"XXX",
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
6062 {
"eventfilter(name(yyy),header(VarSet),method(coains)",
"XXX",
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
6075static int strings_equal(
const char *str1,
const char *str2)
6077 if ((!str1 && str2) || (str1 && !str2)) {
6081 return str1 == str2 || !strcmp(str1, str2);
6093 info->name =
"eventfilter_test_creation";
6094 info->category =
"/main/manager/";
6095 info->summary =
"Test eventfilter creation";
6097 "This creates various eventfilters and tests to make sure they were created successfully.";
6105 if (!includefilters || !excludefilters) {
6110 for (i = 0; i <
ARRAY_LEN(parsing_filter_tests); i++) {
6115 int include_container_count = 0;
6116 int exclude_container_count = 0;
6123 includefilters, excludefilters);
6128 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6129 add_filter_result_enums[parsing_filter_tests[i].expected_add_filter_result],
6130 add_filter_result_enums[add_filter_res],
6131 add_filter_res != parsing_filter_tests[i].expected_add_filter_result ?
"FAIL" :
"PASS");
6134 if (add_filter_res != parsing_filter_tests[i].expected_add_filter_result) {
6136 "Unexpected add filter result '%s = %s'. Expected result: %s Actual result: %s\n",
6137 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6138 add_filter_result_enums[parsing_filter_tests[i].expected_add_filter_result],
6139 add_filter_result_enums[add_filter_res]);
6144 if (parsing_filter_tests[i].expected_add_filter_result !=
FILTER_SUCCESS) {
6153 if (parsing_filter_tests[i].expected_filter_entry.event_name) {
6154 parsing_filter_tests[i].expected_filter_entry.event_name_hash =
6155 ast_str_hash(parsing_filter_tests[i].expected_filter_entry.event_name);
6161 if (parsing_filter_tests[i].expected_filter_entry.is_excludefilter) {
6162 if (exclude_container_count != 1 || include_container_count != 0) {
6164 "Invalid container counts for exclude filter '%s = %s'. Exclude: %d Include: %d. Should be 1 and 0\n",
6165 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6166 exclude_container_count, include_container_count);
6173 if (include_container_count != 1 || exclude_container_count != 0) {
6175 "Invalid container counts for include filter '%s = %s'. Include: %d Exclude: %d. Should be 1 and 0\n",
6176 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6177 include_container_count, exclude_container_count);
6185 if (!filter_entry) {
6187 "Failed to find filter entry for '%s = %s' in %s filter container\n",
6188 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6189 parsing_filter_tests[i].expected_filter_entry.is_excludefilter ?
"exclude" :
"include");
6194 if (filter_entry->
match_type != parsing_filter_tests[i].expected_filter_entry.match_type) {
6196 "Failed to match filter type for '%s = %s'. Expected: %s Actual: %s\n",
6197 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6198 match_type_names[parsing_filter_tests[i].expected_filter_entry.match_type],
6204 if (!strings_equal(filter_entry->
event_name, parsing_filter_tests[i].expected_filter_entry.event_name)) {
6206 "Failed to match event name for '%s = %s'. Expected: '%s' Actual: '%s'\n",
6207 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6208 parsing_filter_tests[i].expected_filter_entry.event_name, filter_entry->
event_name);
6213 if (filter_entry->
event_name_hash != parsing_filter_tests[i].expected_filter_entry.event_name_hash) {
6215 "Event name hashes failed to match for '%s = %s'. Expected: %u Actual: %u\n",
6216 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6217 parsing_filter_tests[i].expected_filter_entry.event_name_hash, filter_entry->
event_name_hash);
6222 if (!strings_equal(filter_entry->
header_name, parsing_filter_tests[i].expected_filter_entry.header_name)) {
6224 "Failed to match header name for '%s = %s'. Expected: '%s' Actual: '%s'\n",
6225 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6226 parsing_filter_tests[i].expected_filter_entry.header_name, filter_entry->
header_name);
6231 switch (parsing_filter_tests[i].expected_filter_entry.match_type) {
6235 "Failed to compile regex filter for '%s = %s'\n",
6236 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter);
6244 "Unexpected regex filter or string for '%s = %s' with match_type 'none'\n",
6245 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter);
6256 "Unexpected regex filter or empty string for '%s = %s' with match_type '%s'\n",
6257 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6258 match_type_names[parsing_filter_tests[i].expected_filter_entry.match_type]);
6271 eqe =
ast_calloc(1,
sizeof(*eqe) + strlen(parsing_filter_tests[i].test_event_payload) + 1);
6278 strcpy(eqe->
eventdata, parsing_filter_tests[i].test_event_payload);
6281 if (
send_event != parsing_filter_tests[i].expected_should_send_event) {
6284 "Should send event failed to match for '%s = %s' payload '%s'. Expected: %s Actual: %s\n",
6285 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter, escaped,
6300struct test_filter_matching {
6301 const char *criteria;
6302 const char *pattern;
6318static struct test_filter_matching filters_for_matching[] = {
6319 {
"eventfilter(name(VarSet),method(none))",
""},
6320 {
"eventfilter(name(Newchannel),method(regex))",
"X[XYZ]X"},
6321 {
"eventfilter(name(Newchannel),method(regex))",
"X[abc]X"},
6322 {
"eventfilter(name(Newchannel),header(Someheader),method(regex))",
"ZZZ"},
6323 {
"eventfilter(action(exclude),name(Newchannel),method(regex))",
"X[a]X"},
6324 {
"eventfilter(action(exclude),name(Newchannel),method(regex))",
"X[Z]X"},
6325 {
"eventfilter(action(exclude),name(VarSet),header(Channel),method(regex))",
"YYY"},
6328struct test_event_matching{
6329 const char *event_name;
6330 const char *payload;
6331 int expected_should_send_event;
6334static struct test_event_matching events_for_matching[] = {
6335 {
"Newchannel",
"Event: Newchannel\r\nChannel: XXX\r\nSomeheader: YYY\r\n", 1 },
6336 {
"Newchannel",
"Event: Newchannel\r\nChannel: XZX\r\nSomeheader: YYY\r\n", 0 },
6337 {
"Newchannel",
"Event: Newchannel\r\nChannel: XaX\r\nSomeheader: YYY\r\n", 0 },
6338 {
"Newchannel",
"Event: Newchannel\r\nChannel: XbX\r\nSomeheader: YYY\r\n", 1 },
6339 {
"Newchannel",
"Event: Newchannel\r\nChannel: XcX\r\nSomeheader: YYY\r\n", 1 },
6340 {
"Newchannel",
"Event: Newchannel\r\nChannel: YYY\r\nSomeheader: YYY\r\n", 0 },
6341 {
"Newchannel",
"Event: Newchannel\r\nChannel: YYY\r\nSomeheader: ZZZ\r\n", 1 },
6342 {
"VarSet",
"Event: VarSet\r\nChannel: XXX\r\nSomeheader: YYY\r\n", 1 },
6343 {
"VarSet",
"Event: VarSet\r\nChannel: YYY\r\nSomeheader: YYY\r\n", 0 },
6355 info->name =
"eventfilter_test_matching";
6356 info->category =
"/main/manager/";
6357 info->summary =
"Test eventfilter matching";
6359 "This creates various eventfilters and tests to make sure they were matched successfully.";
6367 if (!includefilters || !excludefilters) {
6373 for (i = 0; i <
ARRAY_LEN(filters_for_matching); i++) {
6377 filters_for_matching[i].pattern, includefilters, excludefilters);
6381 "Unexpected add filter result '%s = %s'. Expected result: %s Actual result: %s\n",
6382 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6384 add_filter_result_enums[add_filter_res]);
6396 for (i = 0; i <
ARRAY_LEN(events_for_matching); i++) {
6400 eqe =
ast_calloc(1,
sizeof(*eqe) + strlen(events_for_matching[i].payload) + 1);
6406 strcpy(eqe->
eventdata, events_for_matching[i].payload);
6409 if (
send_event != events_for_matching[i].expected_should_send_event) {
6412 "Should send event failed to match for '%s'. Expected: %s Actual: %s\n",
6441 ast_debug(3,
"Received CloseSession event\n");
6467 for (x = 0; x < m->
hdrcount; x++) {
6468 if (strncasecmp(
"UserEvent:", m->
headers[x], strlen(
"UserEvent:")) &&
6469 strncasecmp(
"Action:", m->
headers[x], strlen(
"Action:"))) {
6486 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
6493 "AMIversion: %s\r\n"
6494 "AsteriskVersion: %s\r\n"
6495 "SystemName: %s\r\n"
6496 "CoreMaxCalls: %d\r\n"
6497 "CoreMaxLoadAvg: %f\r\n"
6498 "CoreRunUser: %s\r\n"
6499 "CoreRunGroup: %s\r\n"
6500 "CoreMaxFilehandles: %d\r\n"
6501 "CoreRealTimeEnabled: %s\r\n"
6502 "CoreCDRenabled: %s\r\n"
6503 "CoreHTTPenabled: %s\r\n"
6504 "SoundsSearchCustomDir: %s\r\n"
6528 char startuptime[150], startupdate[150];
6529 char reloadtime[150], reloaddate[150];
6533 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
6539 ast_strftime(startuptime,
sizeof(startuptime),
"%H:%M:%S", &tm);
6540 ast_strftime(startupdate,
sizeof(startupdate),
"%Y-%m-%d", &tm);
6542 ast_strftime(reloadtime,
sizeof(reloadtime),
"%H:%M:%S", &tm);
6543 ast_strftime(reloaddate,
sizeof(reloaddate),
"%Y-%m-%d", &tm);
6547 "CoreStartupDate: %s\r\n"
6548 "CoreStartupTime: %s\r\n"
6549 "CoreReloadDate: %s\r\n"
6550 "CoreReloadTime: %s\r\n"
6551 "CoreCurrentCalls: %d\r\n"
6552 "CoreProcessedCalls: %d\r\n"
6568 const char *
module = astman_get_header(m, "Module");
6608 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
6620 char durbuf[16] =
"";
6627 int duration, durh, durm, durs;
6630 durh = duration / 3600;
6631 durm = (duration % 3600) / 60;
6632 durs = duration % 60;
6633 snprintf(durbuf,
sizeof(durbuf),
"%02d:%02d:%02d", durh, durm, durs);
6637 "Event: CoreShowChannel\r\n"
6640 "Application: %s\r\n"
6641 "ApplicationData: %s\r\n"
6687 char *current_channel_uid;
6692 int add_channel_res;
6696 if (!strcmp(current_channel_uid, channel_snapshot->
base->
uniqueid)) {
6697 ao2_ref(current_channel_uid, -1);
6702 if (!current_channel_snapshot) {
6703 ast_debug(5,
"Unable to get channel snapshot\n");
6704 ao2_ref(current_channel_uid, -1);
6709 if (add_channel_res) {
6711 ao2_ref(current_channel_snapshot, -1);
6712 ao2_ref(current_channel_uid, -1);
6720 int size = strlen(current_channel_snapshot->
base->
name);
6721 char other_local[size + 1];
6726 other_local[size] =
'\0';
6729 if (!other_local_snapshot) {
6730 ast_debug(5,
"Unable to get other local channel snapshot\n");
6731 ao2_ref(current_channel_snapshot, -1);
6732 ao2_ref(current_channel_uid, -1);
6738 ao2_ref(current_channel_snapshot, -1);
6739 ao2_ref(current_channel_uid, -1);
6740 ao2_ref(other_local_snapshot, -1);
6745 if (other_bridge_snapshot) {
6749 ao2_ref(current_channel_snapshot, -1);
6750 ao2_ref(current_channel_uid, -1);
6751 ao2_ref(other_local_snapshot, -1);
6752 ao2_ref(other_bridge_snapshot, -1);
6770 char *current_channel_name;
6779 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n", actionid);
6790 if (!channel_snapshot) {
6803 if (!bridge_snapshot) {
6827 "Event: CoreShowChannelMap\r\n"
6830 "ConnectedChannel: %s\r\n\r\n",
6833 current_channel_name);
6861 const char *
module = astman_get_header(m, "Module");
6864 ast_debug(1,
"**** ModuleCheck .so file %s\n", module);
6876#if !defined(LOW_MEMORY)
6900 char *stripped_filename;
6916 real_path = realpath(path,
NULL);
6927 const char *
module = astman_get_header(m, "Module");
6931 if (!loadtype || strlen(loadtype) == 0) {
6934 if ((!module || strlen(module) == 0) && strcasecmp(loadtype,
"reload") != 0) {
6942 }
else if (res == -1) {
6947 if (!strcasecmp(loadtype,
"load")) {
6954 }
else if (!strcasecmp(loadtype,
"unload")) {
6961 }
else if (!strcasecmp(loadtype,
"refresh")) {
6968 }
else if (!strcasecmp(loadtype,
"reload")) {
6973 switch (reload_res) {
7019 for (x = 0; x < m->
hdrcount; ++x) {
7020 if (!strncasecmp(m->
headers[x],
"Secret", 6)) {
7049 const char *username;
7064 ast_log(
LOG_ERROR,
"Unable to process manager action '%s'. Asterisk is shutting down.\n", action);
7072 && strcasecmp(action,
"Login")
7073 && strcasecmp(action,
"Logoff")
7074 && strcasecmp(action,
"Challenge")) {
7085 && (!strcasecmp(action,
"Login")
7086 || !strcasecmp(action,
"Challenge"))) {
7092 if (
user && !
user->allowmultiplelogin) {
7119 if (mod_ref || !act_found->module) {
7121 ret = act_found->
func(s, m);
7140 ao2_t_ref(act_found, -1,
"done with found action object");
7145 snprintf(
buf,
sizeof(
buf),
"Invalid/unknown command: %s. Use Action: ListCommands to show available commands.", action);
7186 if (src[x] ==
'\r' && x+1 < s->
session->
inlen && src[x + 1] ==
'\n') {
7188 }
else if (src[x] ==
'\n') {
7193 memmove(output, src, x);
7212 if(time(&now) == -1) {
7241 ast_debug(1,
"Manager session has been kicked\n");
7312 if (time(&now) == -1) {
7327 }
else if (res > 0) {
7423 if(time(&
session->authstart) == -1) {
7476 time_t now = time(
NULL);
7494 ast_verb(2,
"HTTP Manager '%s' timed out from %s\n",
7557#define MANAGER_EVENT_BUF_INITSIZE 256
7572 const char *cat_str;
7576 int event_name_hash;
7580 ast_debug(3,
"AMI Event '%s' is globally disabled, skipping\n",
event);
7594 "Privilege: %s\r\n",
7600 "Timestamp: %ld.%06lu\r\n",
7601 (
long)now.tv_sec, (
unsigned long) now.tv_usec);
7607 "SequenceNumber: %d\r\n",
7617 "SystemName: %s\r\n",
7641 pthread_kill(
session->waiting_thread, SIGURG);
7693 const char *fmt, ...)
7707 file, line, func, fmt, ap);
7722 if (!strcasecmp(action, cur->
action)) {
7739 ao2_t_ref(cur, -1,
"action object removed from list");
7740 ast_verb(5,
"Manager unregistered action %s\n", action);
7754 switch(info->reason) {
7761 "StatusText: %s\r\n",
7780 info->presence_subtype,
7781 info->presence_message);
7807 ao2_t_ref(act, +1,
"action object added to list");
7851 ao2_t_ref(cur, -1,
"action object creation failed");
7856 ao2_t_ref(cur, -1,
"action object creation failed");
7861 ao2_t_ref(cur, -1,
"action object creation failed");
7868 cur->module =
module;
7915 ao2_t_ref(cur, -1,
"action object registration failed");
7919 ao2_t_ref(cur, -1,
"action object registration successful");
7999 if (nonce == 0 || username ==
NULL || stale ==
NULL) {
8011 if (!strcasecmp(
session->username, username) &&
session->managerid == nonce) {
8014 }
else if (!strcasecmp(
session->username, username) &&
session->oldnonce == nonce) {
8034 authed = (
session->authenticated != 0);
8061 if ((
session->managerid == ident) && (
session->readperm & perm)) {
8094 if ((
session->managerid == ident) && (
session->writeperm & perm)) {
8118 const char *save = src;
8119 int space =
sizeof(
buf);
8121 for ( ; *src || dst !=
buf ; src++) {
8122 if (*src ==
'\0' || space < 10) {
8126 space =
sizeof(
buf);
8133 if (save == src && isdigit(*src)) {
8139 }
else if (!isalnum(*src)) {
8148 strcpy(dst,
"<");
8153 strcpy(dst,
">");
8158 strcpy(dst,
""");
8163 strcpy(dst,
"'");
8168 strcpy(dst,
"&");
8174 *dst++ = mode ? tolower(*src) : *src;
8234 const char *dest =
NULL;
8236 const char *objtype =
NULL;
8245 for (v = get_vars; v; v = v->
next) {
8246 if (!strcasecmp(v->
name,
"ajaxdest")) {
8248 }
else if (!strcasecmp(v->
name,
"ajaxobjtype")) {
8256 objtype =
"generic";
8263 if (
in && *
in ==
'\n') {
8267 ast_debug(5,
"inobj %d in_data %d line <%s>\n", inobj, in_data,
val);
8279 "<tr><td colspan=\"2\"><hr></td></tr>\r\n");
8314 var =
"Opaque-data";
8331 if (vc->
count > 1) {
8337 if (!in_data || !*
in) {
8344 "<tr><td colspan=\"2\"><hr></td></tr>\r\n");
8355 ast_log(
LOG_ERROR,
"Attempted to close file/file descriptor on mansession without a valid file or file descriptor.\n");
8373 l = lseek(fd, 0, SEEK_CUR);
8375 if (MAP_FAILED == (
buf = mmap(
NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0))) {
8395 const struct ast_sockaddr *remote_address,
const char *uri,
8405 char template[] =
"/tmp/ast-http-XXXXXX";
8410 ast_http_error(ser, 501,
"Not Implemented",
"Attempt to use unimplemented / unsupported method");
8424 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8450 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (ast_str_create() out of memory)");
8451 goto generic_callback_out;
8455 fd = mkstemp(
template);
8458 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (mkstemp failed)");
8459 goto generic_callback_out;
8464 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (fdopen failed)");
8466 goto generic_callback_out;
8474 ast_http_error(ser, 413,
"Request Entity Too Large",
"Body too large");
8476 goto generic_callback_out;
8481 goto generic_callback_out;
8483 ast_http_error(ser, 400,
"Bad Request",
"Error parsing request body");
8485 goto generic_callback_out;
8508 "Content-type: text/%s\r\n"
8509 "Set-Cookie: mansession_id=\"%08x\"; Version=1; Max-Age=%d\r\n"
8510 "Pragma: SuppressEvents\r\n",
8523#define ROW_FMT "<tr><td colspan=\"2\" bgcolor=\"#f1f1ff\">%s</td></tr>\r\n"
8524#define TEST_STRING \
8525 "<form action=\"manager\" method=\"post\">\n\
8526 Action: <select name=\"action\">\n\
8527 <option value=\"\">-----></option>\n\
8528 <option value=\"login\">login</option>\n\
8529 <option value=\"command\">Command</option>\n\
8530 <option value=\"waitevent\">waitevent</option>\n\
8531 <option value=\"listcommands\">listcommands</option>\n\
8533 or <input name=\"action\"><br/>\n\
8534 CLI Command <input name=\"command\"><br>\n\
8535 user <input name=\"username\"> pass <input type=\"password\" name=\"secret\"><br>\n\
8536 <input type=\"submit\">\n</form>\n"
8539 ast_str_append(&
out, 0,
"<body bgcolor=\"#ffffff\"><table align=center bgcolor=\"#f1f1f1\" width=\"500\">\r\n");
8558 ast_debug(1,
"Need destroy, doing it now!\n");
8561 ast_debug(1,
"Need destroy, but can't do it yet!\n");
8564 pthread_kill(
session->waiting_thread, SIGURG);
8578generic_callback_out:
8607 const struct ast_sockaddr *remote_address,
const char *uri,
8614 char template[] =
"/tmp/ast-http-XXXXXX";
8620 time_t time_now = time(
NULL);
8621 unsigned long nonce = 0, nc;
8625 char resp_hash[256]=
"";
8627 char u_username[80];
8631 int u_displayconnects;
8634 ast_http_error(ser, 501,
"Not Implemented",
"Attempt to use unimplemented / unsupported method");
8639 for (v = headers; v; v = v->
next) {
8640 if (!strcasecmp(v->
name,
"Authorization")) {
8652 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8661 if (sscanf(
d.nonce,
"%30lx", &nonce) != 1) {
8681 ast_http_error(ser, 403,
"Permission denied",
"Permission denied");
8698 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8707 snprintf(resp,
sizeof(resp),
"%s:%08lx:%s:%s:auth:%s",
user->a1_hash, nonce,
d.nc,
d.cnonce, a2_hash);
8710 snprintf(resp,
sizeof(resp),
"%s:%08lx:%s",
user->a1_hash, nonce, a2_hash);
8715 if (strncasecmp(
d.response, resp_hash, strlen(resp_hash))) {
8727 u_readperm =
user->readperm;
8728 u_writeperm =
user->writeperm;
8729 u_displayconnects =
user->displayconnects;
8730 u_writetimeout =
user->writetimeout;
8740 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8750 session->readperm = u_readperm;
8751 session->writeperm = u_writeperm;
8752 session->writetimeout = u_writetimeout;
8754 if (u_displayconnects) {
8777 sscanf(
d.nc,
"%30lx", &nc);
8778 if (
session->nc >= nc || ((time_now -
session->noncetime) > 62) ) {
8789 session->noncetime = time_now;
8805 fd = mkstemp(
template);
8808 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (mkstemp failed)");
8809 goto auth_callback_out;
8814 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (fdopen failed)");
8816 goto auth_callback_out;
8824 ast_http_error(ser, 413,
"Request Entity Too Large",
"Body too large");
8826 goto auth_callback_out;
8831 goto auth_callback_out;
8833 ast_http_error(ser, 400,
"Bad Request",
"Error parsing request body");
8835 goto auth_callback_out;
8843 if (u_displayconnects) {
8858 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (ast_str_create() out of memory)");
8860 goto auth_callback_out;
8869 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
8871 "<title>Asterisk™ Manager Interface</title>\r\n"
8872 "</head><body style=\"background-color: #ffffff;\">\r\n"
8873 "<form method=\"POST\">\r\n"
8874 "<table align=\"center\" style=\"background-color: #f1f1f1;\" width=\"500\">\r\n"
8875 "<tr><th colspan=\"2\" style=\"background-color: #f1f1ff;\"><h1>Manager Tester</h1></th></tr>\r\n"
8876 "<tr><th colspan=\"2\" style=\"background-color: #f1f1ff;\">Action: <input name=\"action\" /> Cmd: <input name=\"command\" /><br>"
8877 "<input type=\"submit\" value=\"Send request\" /></th></tr>\r\n");
8911 ast_debug(1,
"Need destroy, doing it now!\n");
8961 .
description =
"Raw HTTP Manager Event Interface",
9020 .
description =
"Raw HTTP Manager Event Interface w/Digest authentication",
9029 .
description =
"HTML Manager Event Interface w/Digest authentication",
9038 .
description =
"XML Manager Event Interface w/Digest authentication",
9050 const char *login = (
char *)arg;
9051 int *no_sessions = data;
9053 if (strcasecmp(
session->username, login) == 0) {
9073 ast_log(
LOG_WARNING,
"AMI_CLIENT() requires two arguments: AMI_CLIENT(<name>[,<arg>])\n");
9088 if (!strcasecmp(
args.param,
"sessions")) {
9089 int no_sessions = 0;
9097 snprintf(
buf,
len,
"%d", no_sessions);
9110 .
name =
"AMI_CLIENT",
9141 .poll_timeout = 5000,
9143 .name =
"AMI server",
9153 .name =
"AMI TLS server",
9163 e->
command =
"manager show settings";
9165 "Usage: manager show settings\n"
9166 " Provides detailed list of the configuration of the Manager.\n";
9171#define FORMAT " %-25.25s %-15.55s\n"
9172#define FORMAT2 " %-25.25s %-15d\n"
9173#define FORMAT3 " %-25.25s %s\n"
9177 ast_cli(
a->fd,
"\nGlobal Settings:\n");
9178 ast_cli(
a->fd,
"----------------\n");
9209 int *max_len = data;
9212 if (
len > *max_len) {
9228 const char *dashes =
"--------------------------------------------------------------------------------";
9232 e->
command =
"manager show events";
9234 "Usage: manager show events\n"
9235 " Prints a listing of the available Asterisk manager interface events.\n";
9251 ast_cli(
a->fd,
"No manager event documentation loaded\n");
9259 ast_xml_doc_item_sort_fn,
NULL);
9260 if (!sorted_events) {
9275 ast_cli(
a->fd,
" %.*s %.*s %.*s \n", maxlen, dashes, maxlen, dashes, maxlen, dashes);
9279 if (++col % 3 == 0) {
9290 ast_cli(
a->fd,
"\n%d events registered.\n", col);
9300 char *since, *syntax, *provided_by, *description, *
synopsis, *seealso, *arguments;
9310 if (!
synopsis || !provided_by || !since || !description || !syntax || !arguments || !seealso) {
9311 ast_cli(
a->fd,
"Error: Memory allocation failed\n");
9316 "%s -= Info about Manager Event '%s' =- %s\n\n"
9358 e->
command =
"manager show event";
9360 "Usage: manager show event <eventname>\n"
9361 " Provides a detailed description a Manager interface event.\n";
9367 ast_cli(
a->fd,
"No manager event documentation loaded\n");
9376 length = strlen(
a->word);
9379 if (!strncasecmp(
a->word,
item->
name, length)) {
9397 ast_cli(
a->fd,
"Could not find event '%s'\n",
a->argv[3]);
9401 ast_cli(
a->fd,
"Event: %s\n",
a->argv[3]);
9472 if (
user->includefilters) {
9473 ao2_t_ref(
user->includefilters, -1,
"decrement ref for include container, should be last one");
9475 if (
user->excludefilters) {
9476 ao2_t_ref(
user->excludefilters, -1,
"decrement ref for exclude container, should be last one");
9491#ifdef TEST_FRAMEWORK
9546#ifdef TEST_FRAMEWORK
9548 test_suite_forwarder =
NULL;
9704 int newhttptimeout = 60;
9712 int tls_was_enabled = 0;
9713 int acl_subscription_flag = 0;
9772#ifdef TEST_FRAMEWORK
9788 if (temp_event_docs) {
9790 ao2_t_ref(temp_event_docs, -1,
"Remove creation ref - container holds only ref now");
9810 ast_log(
LOG_NOTICE,
"Unable to open AMI configuration manager.conf, or configuration is invalid.\n");
9815 if (!by_external_config) {
9832 if (strcasecmp(
var->name,
"tlscafile")
9833 && strcasecmp(
var->name,
"tlscapath")
9834 && strcasecmp(
var->name,
"tlscadir")
9835 && strcasecmp(
var->name,
"tlsverifyclient")
9836 && strcasecmp(
var->name,
"tlsdontverifyserver")
9837 && strcasecmp(
var->name,
"tlsclientmethod")
9838 && strcasecmp(
var->name,
"sslclientmethod")
9843 if (!strcasecmp(
var->name,
"enabled")) {
9845 }
else if (!strcasecmp(
var->name,
"webenabled")) {
9847 }
else if (!strcasecmp(
var->name,
"port")) {
9853 }
else if (!strcasecmp(
var->name,
"bindaddr")) {
9868 }
else if (!strcasecmp(
var->name,
"brokeneventsaction")) {
9870 }
else if (!strcasecmp(
var->name,
"allowmultiplelogin")) {
9872 }
else if (!strcasecmp(
var->name,
"displayconnects")) {
9874 }
else if (!strcasecmp(
var->name,
"timestampevents")) {
9876 }
else if (!strcasecmp(
var->name,
"debug")) {
9878 }
else if (!strcasecmp(
var->name,
"httptimeout")) {
9879 newhttptimeout = atoi(
val);
9880 }
else if (!strcasecmp(
var->name,
"authtimeout")) {
9881 int timeout = atoi(
var->value);
9888 }
else if (!strcasecmp(
var->name,
"authlimit")) {
9889 int limit = atoi(
var->value);
9896 }
else if (!strcasecmp(
var->name,
"channelvars")) {
9898 }
else if (!strcasecmp(
var->name,
"disabledevents")) {
9939 if (!strcasecmp(cat,
"general")) {
9953 user->writeperm = 0;
9958 user->writetimeout = 100;
9961 if (!
user->includefilters || !
user->excludefilters) {
9981 if (!strcasecmp(
var->name,
"secret")) {
9984 }
else if (!strcasecmp(
var->name,
"deny") ||
9985 !strcasecmp(
var->name,
"permit") ||
9986 !strcasecmp(
var->name,
"acl")) {
9991 ast_log(
LOG_ERROR,
"Invalid ACL '%s' for manager user '%s' on line %d. Deleting user\n",
9995 }
else if (!strcasecmp(
var->name,
"read") ) {
9997 }
else if (!strcasecmp(
var->name,
"write") ) {
9999 }
else if (!strcasecmp(
var->name,
"displayconnects") ) {
10001 }
else if (!strcasecmp(
var->name,
"allowmultiplelogin") ) {
10003 }
else if (!strcasecmp(
var->name,
"writetimeout")) {
10010 }
else if (!strcasecmp(
var->name,
"setvar")) {
10019 if ((varval = strchr(varname,
'='))) {
10023 user->chanvars = tmpvar;
10030 ast_debug(1,
"%s is an unknown option.\n",
var->name);
10039 if (acl_subscription_flag && !by_external_config) {
10088 if (newhttptimeout > 0) {
10124#ifdef TEST_FRAMEWORK
10166 if ((datastore->
uid !=
NULL) && !strcasecmp(
uid, datastore->
uid)) {
10179 if (!*fields_string) {
10181 if (!*fields_string) {
10197__attribute__((format(printf, 3, 4)))
10201 const
char *extra_fields_fmt,
10223 va_start(argp, extra_fields_fmt);
10236 .
requires =
"extconfig,acl,http",
Access Control of various sorts.
enum ast_acl_sense ast_apply_acl(struct ast_acl_list *acl_list, const struct ast_sockaddr *addr, const char *purpose)
Apply a set of rules to a given IP address.
struct stasis_message_type * ast_named_acl_change_type(void)
a stasis_message_type for changes against a named ACL or the set of all named ACLs
void ast_acl_output(int fd, struct ast_acl_list *acl, const char *prefix)
output an ACL to the provided fd
void ast_append_acl(const char *sense, const char *stuff, struct ast_acl_list **path, int *error, int *named_acl_flag)
Add a rule to an ACL struct.
int ast_acl_list_is_empty(struct ast_acl_list *acl_list)
Determines if an ACL is empty or if it contains entries.
struct ast_acl_list * ast_free_acl_list(struct ast_acl_list *acl)
Free a list of ACLs.
void ast_cli_unregister_multiple(void)
Generic Advice of Charge encode and decode routines.
void * ast_aoc_destroy_encoded(struct ast_aoc_encoded *encoded)
free an ast_aoc_encoded object
int ast_aoc_s_add_rate_duration(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name, unsigned long time, enum ast_aoc_time_scale time_scale, unsigned long granularity_time, enum ast_aoc_time_scale granularity_time_scale, int step_function)
Add AOC-S duration rate entry.
@ AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION
@ AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT
@ AST_AOC_CHARGED_ITEM_NA
@ AST_AOC_CHARGED_ITEM_USER_USER_INFO
@ AST_AOC_CHARGED_ITEM_CALL_SETUP
@ AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE
@ AST_AOC_CHARGED_ITEM_CALL_ATTEMPT
@ AST_AOC_CHARGE_CURRENCY
@ AST_AOC_TIME_SCALE_TEN_SECOND
@ AST_AOC_TIME_SCALE_TENTH_SECOND
@ AST_AOC_TIME_SCALE_MINUTE
@ AST_AOC_TIME_SCALE_SECOND
@ AST_AOC_TIME_SCALE_HOUR
@ AST_AOC_TIME_SCALE_HUNDREDTH_SECOND
@ AST_AOC_VOLUME_UNIT_OCTET
@ AST_AOC_VOLUME_UNIT_SEGMENT
@ AST_AOC_VOLUME_UNIT_MESSAGE
int ast_aoc_s_add_rate_special_charge_code(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, unsigned int code)
Add AOC-S special rate entry.
ast_aoc_currency_multiplier
Defines the currency multiplier for an aoc message.
@ AST_AOC_MULT_ONEHUNDREDTH
@ AST_AOC_MULT_ONETHOUSANDTH
struct ast_aoc_decoded * ast_aoc_create(const enum ast_aoc_type msg_type, const enum ast_aoc_charge_type charge_type, const enum ast_aoc_request requests)
creates a ast_aoc_decode object of a specific message type
void * ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded)
free an ast_aoc_decoded object
int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num, uint8_t plan)
set the charging association number for an AOC-E message
int ast_aoc_add_unit_entry(struct ast_aoc_decoded *decoded, const unsigned int amount_is_present, const unsigned int amount, const unsigned int type_is_present, const unsigned int type)
Adds a unit entry into the list of units.
ast_aoc_billing_id
Defines the billing id options for an aoc message.
@ AST_AOC_BILLING_CALL_FWD_BUSY
@ AST_AOC_BILLING_CALL_FWD_NO_REPLY
@ AST_AOC_BILLING_CALL_DEFLECTION
@ AST_AOC_BILLING_CREDIT_CARD
@ AST_AOC_BILLING_CALL_TRANSFER
@ AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL
@ AST_AOC_BILLING_REVERSE_CHARGE
int ast_aoc_s_add_rate_free(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, int from_beginning)
Add AOC-S indicating charge item is free.
int ast_aoc_set_billing_id(struct ast_aoc_decoded *decoded, const enum ast_aoc_billing_id id)
set the billing id for a AOC-D or AST_AOC_E message
int ast_aoc_s_add_special_arrangement(struct ast_aoc_decoded *decoded, unsigned int code)
Add AOC-S special arrangement entry.
int ast_aoc_set_currency_info(struct ast_aoc_decoded *decoded, const unsigned int amount, const enum ast_aoc_currency_multiplier multiplier, const char *name)
Sets the currency values for a AOC-D or AOC-E message.
int ast_aoc_set_association_id(struct ast_aoc_decoded *decoded, const int id)
set the charging association id for an AST_AOC_E message
int ast_aoc_s_add_rate_flat(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name)
Add AOC-S flat rate entry.
struct ast_aoc_encoded * ast_aoc_encode(struct ast_aoc_decoded *decoded, size_t *out_size, struct ast_channel *chan)
encodes a decoded aoc structure so it can be passed on the wire
int ast_aoc_set_total_type(struct ast_aoc_decoded *decoded, const enum ast_aoc_total_type type)
Sets the type of total for a AOC-D message.
int ast_aoc_s_add_rate_volume(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, enum ast_aoc_volume_unit volume_unit, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name)
Add AOC-S volume rate entry.
unsigned int ast_aoc_s_get_count(struct ast_aoc_decoded *decoded)
get the number rates associated with an AOC-S message
int ast_aoc_s_add_rate_na(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item)
Add AOC-S entry indicating charge item is not available.
@ AST_AOC_RATE_TYPE_VOLUME
@ AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING
@ AST_AOC_RATE_TYPE_SPECIAL_CODE
@ AST_AOC_RATE_TYPE_DURATION
static const struct adsi_event events[]
static volatile unsigned int seq
static int copy(char *infile, char *outfile)
Utility function to copy a file.
Asterisk version information.
const char * ast_get_version(void)
Retrieve the Asterisk version string.
char * strsep(char **str, const char *delims)
char * strcasestr(const char *, const char *)
Asterisk main include file. File version handling, generic pbx functions.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
int ast_shutting_down(void)
static struct ast_mansession session
void ast_std_free(void *ptr)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
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.
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)
struct ast_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan)
ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan)
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
int ast_check_hangup_locked(struct ast_channel *chan)
struct ast_channel * ast_channel_get_by_name_prefix(const char *name, size_t name_len)
Find a channel by a name prefix.
void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode)
Lock the given channel, then request softhangup on the channel with the given causecode.
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
const char * ast_channel_appl(const struct ast_channel *chan)
struct timeval ast_channel_creationtime(struct ast_channel *chan)
struct ast_channel * ast_channel_get_by_name(const char *search)
Find a channel by name or uniqueid.
int ast_active_channels(void)
returns number of active/allocated channels
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
#define ast_channel_unref(c)
Decrease channel reference count.
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
ast_group_t ast_channel_callgroup(const struct ast_channel *chan)
struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan)
void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Set when to hang a channel up.
#define ast_dummy_channel_alloc()
Create a fake channel structure.
@ AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT
struct ast_channel_iterator * ast_channel_iterator_all_new(void)
Create a new channel iterator.
#define ast_channel_unlock(chan)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
const char * ast_var_name(const struct ast_var_t *var)
const char * ast_var_value(const struct ast_var_t *var)
Standard Command Line Interface.
#define AST_CLI_YESNO(x)
Return Yes or No depending on the argument.
#define AST_CLI_DEFINE(fn, txt,...)
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_command(fd, s)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static struct ao2_container * codecs
Registered codecs.
static struct channel_usage channels
Local proxy channel special access.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Call Parking and Pickup API Includes code and algorithms from the Zapata library.
Generic File Format Support. Should be included by clients of the file handling routines....
static int md5(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int filter(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static int action_setvar(struct mansession *s, const struct message *m)
static int action_createconfig(struct mansession *s, const struct message *m)
static void purge_events(void)
static char * handle_showmancmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * match_type_names[]
static int manager_state_cb(const char *context, const char *exten, struct ast_state_cb_info *info, void *data)
static void mansession_unlock(struct mansession *s)
Unlock the 'mansession' structure.
static int action_loggerrotate(struct mansession *s, const struct message *m)
Manager command "LoggerRotate" - reloads and rotates the logger in the same manner as the CLI command...
int __ast_manager_event_multichan(int category, const char *event, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *fmt,...)
static int match_eventdata(struct event_filter_entry *entry, const char *eventdata)
Test eventdata against a filter entry.
#define GET_HEADER_LAST_MATCH
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
static int purge_sessions(int n_max)
remove at most n_max stale session from the list.
static int process_message(struct mansession *s, const struct message *m)
Process an AMI message, performing desired action. Return 0 on success, -1 on error that require the ...
static int strings_to_mask(const char *string)
static void print_event_instance(struct ast_cli_args *a, struct ast_xml_doc_item *instance)
static int __manager_event_sessions(struct ao2_container *sessions, int category, const char *event, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *fmt,...)
static struct ast_manager_user * get_manager_by_name_locked(const char *name)
static void acl_change_stasis_subscribe(void)
static char * handle_showmaneventq(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager list eventq.
static void log_action(const struct message *m, const char *action)
static struct mansession_session * build_mansession(const struct ast_sockaddr *addr)
Allocate manager session structure and add it to the list of sessions.
static void report_invalid_user(const struct mansession *s, const char *username)
static int append_event(const char *str, int event_name_hash, int category)
events are appended to a queue from where they can be dispatched to clients.
static int manager_enabled
int ast_manager_check_enabled(void)
Check if AMI is enabled.
static void astman_free_headers(struct message *m)
Free headers inside message structure, but not the message structure itself.
static int action_sendtext(struct mansession *s, const struct message *m)
static int action_mailboxcount(struct mansession *s, const struct message *m)
static void manager_json_to_ast_str(struct ast_json *obj, const char *key, struct ast_str **res, key_exclusion_cb exclusion_cb)
static int ast_manager_register_struct(struct manager_action *act)
static int queue_read_action_payload(struct ast_channel *chan, const unsigned char *payload, size_t payload_size, enum ast_frame_read_action action)
Queue a given read action containing a payload onto a channel.
static struct manager_action * action_find(const char *name)
static int action_getconfigjson(struct mansession *s, const struct message *m)
int ast_webmanager_check_enabled(void)
Check if AMI/HTTP is enabled.
void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg)
Send response in manager transaction.
static void report_failed_acl(const struct mansession *s, const char *username)
static int is_originate_app_permitted(const char *app, const char *data, int permission)
static int action_listcategories(struct mansession *s, const struct message *m)
static int action_hangup(struct mansession *s, const struct message *m)
static void mansession_lock(struct mansession *s)
Lock the 'mansession' structure.
static int action_listcommands(struct mansession *s, const struct message *m)
static void destroy_fast_originate_helper(struct fast_originate_helper *doomed)
static int action_atxfer(struct mansession *s, const struct message *m)
static int action_timeout(struct mansession *s, const struct message *m)
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
static struct stasis_subscription * acl_change_sub
static void generate_status(struct mansession *s, struct ast_channel *chan, char **vars, int varc, int all_variables, char *id_text, int *count)
static int do_message(struct mansession *s)
static struct originate_permissions_entry originate_app_permissions[]
void astman_send_error_va(struct mansession *s, const struct message *m, const char *fmt,...)
Send error in manager transaction (with va_args support)
static void manager_default_msg_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static int action_coresettings(struct mansession *s, const struct message *m)
Show PBX core settings information.
static int mansession_cmp_fn(void *obj, void *arg, int flags)
static int displayconnects
static int action_filter(struct mansession *s, const struct message *m)
Manager command to add an event filter to a manager session.
static int action_mailboxstatus(struct mansession *s, const struct message *m)
static void append_channel_vars(struct ast_str **pbuf, struct ast_channel *chan)
static int action_login(struct mansession *s, const struct message *m)
static int action_getvar(struct mansession *s, const struct message *m)
static int get_input(struct mansession *s, char *output)
static int action_blind_transfer(struct mansession *s, const struct message *m)
static const char * user_authority_to_str(int authority, struct ast_str **res)
Convert authority code to a list of options for a user. This will only display those authority codes ...
static int app_match(const char *app, const char *data, const char *search)
static struct mansession_session * unref_mansession(struct mansession_session *s)
Unreference manager session object. If no more references, then go ahead and delete it.
static int queue_match(const char *app, const char *data, const char *search)
#define ASTMAN_APPEND_BUF_INITSIZE
initial allocated size for the astman_append_buf and astman_send_*_va
void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj)
Publish an event to AMI.
static void session_destroy(struct mansession_session *s)
static int filter_cmp_fn(void *obj, void *arg, void *data, int flags)
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
static int appdata_match(const char *app, const char *data, const char *search)
struct stasis_message_router * ast_manager_get_message_router(void)
Get the stasis_message_router for AMI.
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
static void astman_send_response_full(struct mansession *s, const struct message *m, char *resp, char *msg, char *listflag)
send a response with an optional message, and terminate it with an empty line. m is used only to grab...
static void astman_append_json(struct mansession *s, const char *str)
#define MGR_SHOW_TERMINAL_WIDTH
static enum error_type handle_updates(struct mansession *s, const struct message *m, struct ast_config *cfg, const char *dfn)
helper function for action_updateconfig
static int action_extensionstate(struct mansession *s, const struct message *m)
static char * handle_showmanconn(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager list connected.
static int action_getconfig(struct mansession *s, const struct message *m)
static void event_filter_destructor(void *obj)
static void * session_do(void *data)
The body of the individual manager session. Call get_input() to read one line at a time (or be woken ...
static struct eventqent * advance_event(struct eventqent *e)
static int coreshowchannelmap_add_connected_channels(struct ao2_container *channel_map, struct ast_channel_snapshot *channel_snapshot, struct ast_bridge_snapshot *bridge_snapshot)
Recursive function to get all channels in a bridge. Follow local channels as well.
static enum add_filter_result manager_add_filter(const char *criteria, const char *filter_pattern, struct ao2_container *includefilters, struct ao2_container *excludefilters)
Add an event filter to a manager session.
static void session_destructor(void *obj)
static struct stasis_message_router * stasis_router
The stasis_message_router for all Stasis Message Bus API messages.
static void json_escape(char *out, const char *in)
static int manager_displayconnects(struct mansession_session *session)
Get displayconnects config option.
static int action_logoff(struct mansession *s, const struct message *m)
static char * handle_kickmanconn(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager kick session.
static int action_updateconfig(struct mansession *s, const struct message *m)
static void astman_start_ack(struct mansession *s, const struct message *m)
static const char * __astman_get_header(const struct message *m, char *var, int mode)
Return a matching header value.
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
static int file_in_modules_dir(const char *filename)
Check if the given file path is in the modules dir or not.
static void handle_parse_error(struct mansession *s, struct message *m, char *error)
static int manager_moduleload(struct mansession *s, const struct message *m)
static void acl_change_stasis_unsubscribe(void)
static int reload_module(void)
static void manager_json_array_with_key(struct ast_json *obj, const char *key, size_t index, struct ast_str **res, key_exclusion_cb exclusion_cb)
static void astman_append_headers(struct message *m, const struct ast_variable *params)
Append additional headers into the message structure from params.
static void report_failed_challenge_response(const struct mansession *s, const char *response, const char *expected_response)
#define any_manager_listeners(sessions)
static int action_reload(struct mansession *s, const struct message *m)
Send a reload event.
struct ast_variable * astman_get_variables(const struct message *m)
Get a linked list of the Variable: headers.
static int live_dangerously
Set to true (non-zero) to globally allow all dangerous AMI actions to run.
static int is_restricted_file(const char *filename)
Check if a file is restricted or not.
struct ast_str * ast_manager_str_from_json_object(struct ast_json *blob, key_exclusion_cb exclusion_cb)
Convert a JSON object into an AMI compatible string.
static struct eventqent * grab_last(void)
static int should_send_event(struct ao2_container *includefilters, struct ao2_container *excludefilters, struct eventqent *eqe)
static struct stasis_forward * rtp_topic_forwarder
The stasis_subscription for forwarding the RTP topic to the AMI topic.
static int action_aocmessage(struct mansession *s, const struct message *m)
static char * handle_showmanagers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int check_manager_session_inuse(const char *name)
static int check_blacklist(const char *cmd)
static 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 queue_sendtext_data(struct ast_channel *chan, const char *body, const char *content_type)
Queue a read action to send a text data message.
const char * astman_get_header(const struct message *m, char *var)
Return the first matching variable from an array.
#define GET_HEADER_SKIP_EMPTY
static enum ast_transport mansession_get_transport(const struct mansession *s)
static int function_capable_string_allowed_with_auths(const char *evaluating, int writepermlist)
Checks to see if a string which can be used to evaluate functions should be rejected.
static char * handle_showmanager(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int action_cancel_atxfer(struct mansession *s, const struct message *m)
static void report_req_not_allowed(const struct mansession *s, const char *action)
static char global_realm[MAXHOSTNAMELEN]
static int action_originate(struct mansession *s, const struct message *m)
static int send_string(struct mansession *s, char *string)
#define MAX_AUTH_PERM_STRING
static int action_userevent(struct mansession *s, const struct message *m)
static int action_command(struct mansession *s, const struct message *m)
Manager command "command" - execute CLI command.
static void report_inval_password(const struct mansession *s, const char *username)
static int ast_instring(const char *bigstr, const char *smallstr, const char delim)
#define MAX_BLACKLIST_CMD_LEN
Descriptor for a manager session, either on the AMI socket or over HTTP.
int ast_manager_register2(const char *action, int auth, int(*func)(struct mansession *s, const struct message *m), struct ast_module *module, const char *synopsis, const char *description)
register a new command with manager, including online help. This is the preferred way to register a m...
static int process_events(struct mansession *s)
static int broken_events_action
static void report_session_limit(const struct mansession *s)
static int unauth_sessions
static int set_eventmask(struct mansession *s, const char *eventmask)
Rather than braindead on,off this now can also accept a specific int mask value or a ',...
static const struct @396 command_blacklist[]
static int timestampevents
static void manager_generic_msg_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static struct ast_aoc_decoded * action_aoc_s_message(struct mansession *s, const struct message *m)
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
static char * handle_manager_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager reload.
static struct ast_aoc_decoded * action_aoc_de_message(struct mansession *s, const struct message *m)
static int authenticate(struct mansession *s, const struct message *m)
void astman_append(struct mansession *s, const char *fmt,...)
static void manager_json_obj_with_key(struct ast_json *obj, const char *key, const char *parent_key, struct ast_str **res, key_exclusion_cb exclusion_cb)
static char * handle_showmancmds(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager list commands.
#define EVENT_FLAG_SHUTDOWN
Fake event class used to end sessions at shutdown.
static int manager_modulecheck(struct mansession *s, const struct message *m)
Manager function to check if module is loaded.
static void astman_send_list_complete(struct mansession *s, const struct message *m, const char *event_name, int count)
static int async_goto_with_discard_bridge_after(struct ast_channel *chan, const char *context, const char *exten, int priority)
void astman_live_dangerously(int new_live_dangerously)
Enable/disable the inclusion of 'dangerous' configurations outside of the ast_config_AST_CONFIG_DIR.
int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg)
access for hooks to send action messages to ami
static int action_aoc_s_submessage(struct mansession *s, const struct message *m, struct ast_aoc_decoded *decoded)
static int webmanager_enabled
static struct ast_str * astman_send_list_complete_start_common(struct mansession *s, const struct message *m, const char *event_name, int count)
static int action_status(struct mansession *s, const struct message *m)
Manager "status" command to show channels.
static int get_perm(const char *instr)
static int action_coreshowchannels(struct mansession *s, const struct message *m)
Manager command "CoreShowChannels" - List currently defined channels and some information about them.
static struct ast_variable * man_do_variable_value(struct ast_variable *head, const char *hdr_val)
static int action_corestatus(struct mansession *s, const struct message *m)
Show PBX core status information.
static int queue_sendtext(struct ast_channel *chan, const char *body)
Queue a read action to send a text message.
static void action_destroy(void *obj)
static int action_challenge(struct mansession *s, const struct message *m)
static struct stasis_topic * manager_topic
A stasis_topic that all topics AMI cares about will be forwarded to.
static int action_waitevent(struct mansession *s, const struct message *m)
static void report_req_bad_format(const struct mansession *s, const char *action)
static int action_coreshowchannelmap(struct mansession *s, const struct message *m)
Manager command "CoreShowChannelMap" - Lists all channels connected to the specified channel.
mansession_message_parsing
static char * handle_mandebug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int action_ping(struct mansession *s, const struct message *m)
#define GET_HEADER_FIRST_MATCH
static int aocmessage_get_unit_entry(const struct message *m, struct ast_aoc_unit_entry *entry, unsigned int entry_num)
static int coreshowchannelmap_add_to_map(struct ao2_container *c, const char *s)
Helper function to add a channel name to the vector.
int ast_manager_hangup_helper(struct mansession *s, const struct message *m, manager_hangup_handler_t hangup_handler, manager_hangup_cause_validator_t cause_validator)
A manager helper function that hangs up a channel using a supplied channel type specific hangup funct...
static void report_auth_success(const struct mansession *s)
static void * fast_originate(void *data)
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
#define MANAGER_EVENT_BUF_INITSIZE
static const struct permalias perms[]
#define manager_event_sessions(sessions, category, event, contents,...)
static char * manager_disabledevents
static int __manager_event_sessions_va(struct ao2_container *sessions, int category, const char *event, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *fmt, va_list ap)
int ast_manager_unregister(const char *action)
support functions to register/unregister AMI action handlers,
@ 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.
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_FLAG_WITHCOMMENTS
@ CONFIG_FLAG_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_REMOVE_HEAD
#define AST_RWLIST_INSERT_AFTER
#define AST_RWLIST_REMOVE
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_RWLIST_TRAVERSE_SAFE_END
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_RWLIST_TRAVERSE
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_RWLIST_INSERT_HEAD
#define AST_RWLIST_INSERT_TAIL
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
Asterisk locking-related definitions:
#define AST_PTHREADT_NULL
#define ast_mutex_init(pmutex)
#define ast_mutex_unlock(a)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
#define ast_mutex_destroy(a)
#define ast_mutex_lock(a)
static int auth_mxml_http_callback(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
static int manager_subscriptions_init(void)
Initialize all Stasis Message Bus API topics and routers used by the various sub-components of AMI.
static struct ast_tls_config ami_tls_cfg
static void close_mansession_file(struct mansession *s)
static 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.
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.
@ AST_DYNSTR_BUILD_FAILED
int ast_in_delimited_string(const char *needle, const char *haystack, char delim)
Check if there is an exact match for 'needle' between delimiters in 'haystack'.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
int ast_str_append_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap)
Append to a dynamic string using a va_list.
char * ast_read_line_from_buffer(char **buffer)
Read lines from a string buffer.
#define AST_YESNO(x)
return Yes or No depending on the argument.
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
char * ast_escape_c_alloc(const char *s)
Escape standard 'C' sequences in the given string.
struct ao2_container * ast_str_container_alloc_options(enum ao2_alloc_opts opts, int buckets)
Allocates a hash container for bare strings.
int ast_str_container_add(struct ao2_container *str_container, const char *add)
Adds a string to a string container allocated by ast_str_container_alloc.
char * ast_strsep(char **s, const char sep, uint32_t flags)
Act like strsep but ignore separators inside quotes.
char *attribute_pure ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
int ast_regex_string_to_regex_pattern(const char *regex_string, struct ast_str **regex_pattern)
Given a string regex_string in the form of "/regex/", convert it into the form of "regex".
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
list of actions registered
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Wrapper for an ast_acl linked list.
Structure to pass both assignedid values to channel drivers.
Structure that contains a snapshot of information about a bridge.
struct ao2_container * channels
Structure that contains information about a bridge.
const ast_string_field uniqueid
struct ast_category * prev
char * file
The file name from whence this declaration was read.
struct timeval creationtime
const ast_string_field uniqueid
const ast_string_field name
const ast_string_field data
const ast_string_field appl
Structure representing a snapshot of channel state.
struct ast_channel_snapshot_dialplan * dialplan
struct ast_channel_snapshot_bridge * bridge
struct ast_channel_snapshot_base * base
Structure to describe a channel "technology", ie a channel driver See for examples:
Main Channel structure associated with a channel.
descriptor for a cli entry.
enum ast_frame_read_action action
Data structure associated with a custom dialplan function.
Structure for a data store type.
Structure for a data store object.
const struct ast_datastore_info * info
struct ast_datastore::@223 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_manager_user::@399 list
struct ast_acl_list * acl
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
struct eventqent::@397 eq_next
helper function for originate
struct ast_variable * vars
struct ast_format_cap * cap
struct ast_module *enum ast_doc_src docsrc
struct manager_action::@249 list
const ast_string_field description
struct ast_xml_doc_item * final_response
const ast_string_field synopsis
int(* func)(struct mansession *s, const struct message *m)
const ast_string_field seealso
const ast_string_field syntax
unsigned int registered
TRUE if the AMI action is registered and the callback can be called.
const ast_string_field arguments
struct ast_xml_doc_item * list_responses
struct ast_variable * chanvars
struct ao2_container * excludefilters
struct ast_iostream * stream
struct mansession_session::@398 list
struct timeval sessionstart_tv
struct eventqent * last_ev
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_wait_for_input(int fd, int ms)
int ast_parse_digest(const char *digest, struct ast_http_digest *d, int request, int pedantic)
Parse digest authorization header.
long int ast_random(void)
#define ast_pthread_create_detached(a, b, c, d)
#define ast_set_flag(p, flag)
void ast_md5_hash(char *output, const char *input)
Produces MD5 hash based on input string.
struct ast_xml_doc_item * ast_xmldoc_build_list_responses(const char *type, const char *name, const char *module)
Generate the [list responses] tag based on type of node ('application', 'function' or 'agi') and name...
char * ast_xmldoc_build_description(const char *type, const char *name, const char *module)
Generate description documentation from XML.
char * ast_xmldoc_build_syntax(const char *type, const char *name, const char *module)
Get the syntax for a specified application or function.
char * ast_xmldoc_build_arguments(const char *type, const char *name, const char *module)
Generate the [arguments] tag based on type of node ('application', 'function' or 'agi') and name.
char * ast_xmldoc_build_synopsis(const char *type, const char *name, const char *module)
Generate synopsis documentation from XML.
char * ast_xmldoc_build_since(const char *type, const char *name, const char *module)
Parse the <since> node content.
struct ao2_container * ast_xmldoc_build_documentation(const char *type)
Build the documentation for a particular source type.
char * ast_xmldoc_build_seealso(const char *type, const char *name, const char *module)
Parse the <see-also> node content.
char * ast_xmldoc_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...