62 #include <sys/types.h> 1483 #define DEFAULT_REALM "asterisk" 1501 #ifdef TEST_FRAMEWORK 1506 #define MGR_SHOW_TERMINAL_WIDTH 80 1508 #define MAX_VARS 128 1511 #define EVENT_FLAG_SHUTDOWN -1 1523 #define MAX_BLACKLIST_CMD_LEN 2 1524 static const struct {
1527 {{
"module",
"load",
NULL }},
1528 {{
"module",
"unload",
NULL }},
1529 {{
"restart",
"gracefully",
NULL }},
1536 if (!acl_change_sub) {
1590 struct timeval sessionstart_tv;
1710 if (!strcasecmp(name, act->
action)) {
1711 ao2_t_ref(act, +1,
"found action object");
1756 size_t index,
struct ast_str **res,
1766 const char *parent_key,
struct ast_str **res,
1771 ast_str_set(&key_str, 0,
"%s/%s", parent_key, key);
1794 if (exclusion_cb && key && exclusion_cb(key)) {
1808 key, j, res, exclusion_cb);
1817 key, res, exclusion_cb);
1832 #define manager_event_sessions(sessions, category, event, contents , ...) \ 1833 __manager_event_sessions(sessions, category, event, 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__) 1835 #define any_manager_listeners(sessions) \ 1836 ((sessions && ao2_container_count(sessions)) || !AST_RWLIST_EMPTY(&manager_hooks)) 1892 if (!event_buffer) {
1916 "class_type", class_type,
2043 #define MAX_AUTH_PERM_STRING 150 2050 strstr(evaluating,
"SHELL") ||
2051 strstr(evaluating,
"EVAL")
2092 if (authority &
perms[i].num) {
2112 static int ast_instring(
const char *bigstr,
const char *smallstr,
const char delim)
2114 const char *
val = bigstr, *next;
2117 if ((next = strchr(val, delim))) {
2118 if (!strncmp(val, smallstr, (next - val))) {
2124 return !strcmp(smallstr, val);
2126 }
while (*(val = (next + 1)));
2160 for (p =
string; *p; p++) {
2161 if (*p < '0' || *p >
'9') {
2166 return atoi(
string);
2185 int refcount =
ao2_ref(s, -1);
2187 ast_debug(1,
"Mansession: %p refcount now %d\n", s, refcount - 1);
2194 regex_t *regex_filter = obj;
2195 regfree(regex_filter);
2290 session =
ao2_find(sessions, (
char *) name, 0);
2310 if (!strcasecmp(user->
username, name)) {
2346 const char *auth_str;
2348 char syntax_title[64], description_title[64], synopsis_title[64], seealso_title[64];
2349 char arguments_title[64], privilege_title[64], final_response_title[64], list_responses_title[64];
2354 e->
command =
"manager show command";
2356 "Usage: manager show command <actionname> [<actionname> [<actionname> [...]]]\n" 2357 " Shows the detailed description for a specific Asterisk manager interface command.\n";
2360 l = strlen(a->
word);
2392 for (num = 3; num < a->
argc; num++) {
2393 if (!strcasecmp(cur->
action, a->
argv[num])) {
2406 if (!syntax || !synopsis || !description || !arguments
2407 || !seealso || !privilege || !responses) {
2415 ast_cli(a->
fd,
"Allocation failure.\n");
2421 ast_cli(a->
fd,
"%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n%s",
2422 syntax_title, syntax,
2423 synopsis_title, synopsis,
2424 description_title, description,
2425 arguments_title, arguments,
2426 seealso_title, seealso,
2427 privilege_title, privilege,
2428 list_responses_title);
2440 ast_cli(a->
fd,
"%s", final_response_title);
2459 ast_cli(a->
fd,
"Action: %s\nSynopsis: %s\nPrivilege: %s\n%s\n",
2476 e->
command =
"manager set debug [on|off]";
2477 e->
usage =
"Usage: manager set debug [on|off]\n Show, enable, disable debugging of the manager code.\n";
2485 }
else if (a->
argc == 4) {
2486 if (!strcasecmp(a->
argv[3],
"on")) {
2488 }
else if (!strcasecmp(a->
argv[3],
"off")) {
2507 e->
command =
"manager show user";
2509 " Usage: manager show user <user>\n" 2510 " Display all information related to the manager user specified.\n";
2513 l = strlen(a->
word);
2536 ast_cli(a->
fd,
"There is no manager called %s\n", a->
argv[3]);
2548 " displayconnects: %s\n" 2549 "allowmultiplelogin: %s\n",
2551 (user->
secret ?
"<Set>" :
"(N/A)"),
2576 e->
command =
"manager show users";
2578 "Usage: manager show users\n" 2579 " Prints a listing of all managers that are currently configured on that\n" 2593 ast_cli(a->
fd,
"There are no manager users.\n");
2598 ast_cli(a->
fd,
"\nusername\n--------\n");
2608 "%d manager users configured.\n", count_amu);
2617 int space_remaining;
2618 #define HSMC_FORMAT " %-*.*s %-.*s\n" 2621 e->
command =
"manager show commands";
2623 "Usage: manager show commands\n" 2624 " Prints a listing of all the available Asterisk manager interface commands.\n";
2632 int incoming_len = strlen(cur->
action);
2633 if (incoming_len > name_len) {
2634 name_len = incoming_len;
2639 if (space_remaining < 0) {
2640 space_remaining = 0;
2659 time_t now = time(
NULL);
2660 #define HSMCONN_FORMAT1 " %-15.15s %-55.55s %-10.10s %-10.10s %-8.8s %-8.8s %-5.5s %-5.5s\n" 2661 #define HSMCONN_FORMAT2 " %-15.15s %-55.55s %-10d %-10d %-8d %-8d %-5.5d %-5.5d\n" 2667 e->
command =
"manager show connected";
2669 "Usage: manager show connected\n" 2670 " Prints a listing of the users that are currently connected to the\n" 2671 "Asterisk manager interface.\n";
2677 ast_cli(a->
fd,
HSMCONN_FORMAT1,
"Username",
"IP Address",
"Start",
"Elapsed",
"FileDes",
"HttpCnt",
"Read",
"Write");
2699 ast_cli(a->
fd,
"%d users connected.\n", count);
2711 e->
command =
"manager show eventq";
2713 "Usage: manager show eventq\n" 2714 " Prints a listing of all events pending in the Asterisk manger\n" 2724 ast_cli(a->
fd,
"Event:\n%s", s->eventdata);
2738 e->
command =
"manager reload";
2740 "Usage: manager reload\n" 2741 " Reloads the manager configuration.\n";
2766 #define GET_HEADER_FIRST_MATCH 0 2767 #define GET_HEADER_LAST_MATCH 1 2768 #define GET_HEADER_SKIP_EMPTY 2 2785 int x, l = strlen(var);
2792 for (x = 0; x < m->
hdrcount; x++) {
2793 const char *h = m->
headers[x];
2794 if (!strncasecmp(var, h, l) && h[l] ==
':') {
2795 const char *
value = h + l + 1;
2878 for (y = 0; y <
args.argc; y++) {
2883 if (!
args.vars[y]) {
2886 var = val =
args.vars[y];
2918 static const char var_hdr[] =
"Variable:";
2921 varlen = strlen(var_hdr);
2922 for (x = 0; x < m->
hdrcount; x++) {
2923 if (strncasecmp(var_hdr, m->
headers[x], varlen)) {
2943 struct message m = { 0 };
2960 curlen = strlen(src);
2961 for (x = 0; x < curlen; x++) {
2963 if (src[x] ==
'\r' && x+1 < curlen && src[x+1] ==
'\n')
2965 else if (src[x] ==
'\n')
2984 if (!strcasecmp(action,
"login")) {
3007 if (!act_found->
module || mod_ref) {
3008 ret = act_found->
func(&s, &m);
3014 ao2_t_ref(act_found, -1,
"done with found action object");
3042 len = strlen(
string);
3066 #define ASTMAN_APPEND_BUF_INITSIZE 256 3073 ast_verbose(
"No connection stream in astman_append, should not happen\n");
3100 ast_verbose(
"No connection stream in astman_append, should not happen\n");
3114 #define MSG_MOREDATA ((char *)astman_send_response) 3216 ast_str_set(&buf, 0,
"Event: %s\r\n", event_name);
3221 "EventList: Complete\r\n" 3222 "ListItems: %d\r\n",
3287 char session_id[32];
3291 .common.service =
"AMI",
3292 .common.account_id = username,
3294 .common.local_addr = {
3298 .common.remote_addr = {
3302 .common.session_id = session_id,
3305 snprintf(session_id,
sizeof(session_id),
"%p", s);
3312 char session_id[32];
3316 .common.service =
"AMI",
3317 .common.account_id = username,
3319 .common.local_addr = {
3323 .common.remote_addr = {
3327 .common.session_id = session_id,
3330 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
3337 char session_id[32];
3341 .common.service =
"AMI",
3342 .common.account_id = username,
3344 .common.local_addr = {
3348 .common.remote_addr = {
3352 .common.session_id = session_id,
3355 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
3362 char session_id[32];
3366 .common.service =
"AMI",
3369 .common.local_addr = {
3373 .common.remote_addr = {
3377 .common.session_id = session_id,
3380 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
3387 char session_id[32];
3388 char request_type[64];
3392 .common.service =
"AMI",
3395 .common.local_addr = {
3399 .common.remote_addr = {
3403 .common.session_id = session_id,
3408 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
3409 snprintf(request_type,
sizeof(request_type),
"Action: %s", action);
3416 char session_id[32];
3421 .common.service =
"AMI",
3424 .common.local_addr = {
3428 .common.remote_addr = {
3432 .common.session_id = session_id,
3437 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
3438 snprintf(request_type,
sizeof(request_type),
"Action: %s", action);
3444 const char *response,
const char *expected_response)
3446 char session_id[32];
3450 .common.service =
"AMI",
3453 .common.local_addr = {
3457 .common.remote_addr = {
3461 .common.session_id = session_id,
3468 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
3475 char session_id[32];
3479 .common.service =
"AMI",
3482 .common.local_addr = {
3486 .common.remote_addr = {
3490 .common.session_id = session_id,
3493 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
3511 regex_t *regex_filter;
3532 char md5key[256] =
"";
3534 unsigned char digest[16];
3540 for (x = 0; x < 16; x++)
3541 len += sprintf(md5key + len,
"%02hhx", digest[x]);
3542 if (!strcmp(md5key, key)) {
3548 ast_debug(1,
"MD5 authentication is not possible. challenge: '%s'\n",
3551 }
else if (user->
secret) {
3552 if (!strcmp(password, user->
secret)) {
3581 ao2_t_ref(regex_filter, -1,
"remove iterator ref");
3588 ao2_t_ref(regex_filter, -1,
"remove iterator ref");
3614 "Timestamp: %ld.%06lu\r\n" 3616 (
long) now.tv_sec, (
unsigned long) now.tv_usec);
3626 const char *category_name;
3653 astman_append(s,
"Category-%06d: %s\r\n", catcount, category_name);
3710 if (catcount == 0) {
3724 if (*in ==
'\\' || *in ==
'\"') {
3757 const char *category_name;
3828 for (x = 0; x < 100000; x++) {
3829 unsigned int object = 0;
3833 int ignoreerror = 0;
3841 snprintf(hdr,
sizeof(hdr),
"Action-%06d", x);
3846 snprintf(hdr,
sizeof(hdr),
"Cat-%06d", x);
3853 snprintf(hdr,
sizeof(hdr),
"Var-%06d", x);
3856 snprintf(hdr,
sizeof(hdr),
"Value-%06d", x);
3864 snprintf(hdr,
sizeof(hdr),
"Match-%06d", x);
3867 snprintf(hdr,
sizeof(hdr),
"Line-%06d", x);
3870 snprintf(hdr,
sizeof(hdr),
"Options-%06d", x);
3873 char copy[strlen(options) + 1];
3874 strcpy(copy, options);
3877 if (!strcasecmp(
"allowdups", token)) {
3881 if (!strcasecmp(
"template", token)) {
3885 if (!strcasecmp(
"ignoreerror", token)) {
3908 if (!strcasecmp(action,
"newcat")) {
3910 char *tmpl_name =
NULL;
3950 if (category !=
NULL) {
3961 }
else if (!strcasecmp(action,
"renamecat")) {
3977 }
else if (!strcasecmp(action,
"delcat")) {
3984 if (!foundcat && !ignoreerror) {
3988 }
else if (!strcasecmp(action,
"emptycat")) {
3999 }
else if (!strcasecmp(action,
"update")) {
4023 }
else if (!strcasecmp(action,
"delete")) {
4043 if (!foundvar && !ignoreerror) {
4047 }
else if (!strcasecmp(action,
"append")) {
4059 if (
object || (match && !strcasecmp(match,
"object"))) {
4070 }
else if (!strcasecmp(action,
"insert")) {
4110 const char *preserve_effective_context_string =
astman_get_header(m,
"PreserveEffectiveContext");
4216 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n",
id);
4222 sscanf(timeouts,
"%30i", &timeout);
4243 time_t now = time(
NULL);
4249 if (timeout < 0 || timeout > max) {
4261 ast_debug(1,
"Starting waiting for an event!\n");
4263 for (x = 0; x < timeout || timeout < 0; x++) {
4292 ast_debug(1,
"Finished waiting for an event!\n");
4312 "Event: WaitEventComplete\r\n" 4318 ast_debug(1,
"Abandoning event request!\n");
4351 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n",
id);
4363 if (!strcasecmp(
perms[x].label,
"all") && res ==
perms[x].
num) {
4368 "Events: On\r\n\r\n", id_text);
4369 }
else if (res == 0)
4371 "Events: Off\r\n\r\n", id_text);
4377 "Events: On\r\n\r\n", id_text);
4380 "Events: Off\r\n\r\n", id_text);
4419 long lastreloaded = 0;
4425 uptime = tmp.tv_sec;
4430 lastreloaded = tmp.tv_sec;
4436 "LastReload: %ld\r\n" 4437 "Status: Fully Booted\r\n\r\n", cat_str, uptime, lastreloaded);
4446 if (!strcasecmp(authtype,
"MD5")) {
4471 int channels_matched = 0;
4479 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n",
id);
4486 causecode = strtol(cause, &endptr, 10);
4487 if (causecode < 0 || causecode > 127 || *endptr !=
'\0') {
4497 if (name_or_regex[0] !=
'/') {
4505 ast_verb(3,
"%sManager '%s' from %s, hanging up channel: %s\n",
4523 if (!regex_string) {
4530 astman_send_error(s, m,
"Regex format invalid, Channel param should be /regex/");
4536 if (regcomp(®exbuf,
ast_str_buffer(regex_string), REG_EXTENDED | REG_NOSUB)) {
4551 ast_verb(3,
"%sManager '%s' from %s, hanging up channel: %s\n",
4561 "Event: ChannelHungup\r\n" 4616 char workspace[1024];
4636 workspace[0] =
'\0';
4637 if (varname[strlen(varname) - 1] ==
')') {
4641 ast_func_read(c, (
char *) varname, workspace,
sizeof(workspace));
4643 ast_log(
LOG_ERROR,
"Unable to allocate bogus channel for variable substitution. Function results may be blank.\n");
4645 ast_func_read(c, (
char *) varname, workspace,
sizeof(workspace));
4657 astman_append(s,
"Variable: %s\r\nValue: %s\r\n\r\n", varname,
S_OR(varval,
""));
4665 long elapsed_seconds;
4683 if (!snapshot_str) {
4687 if (all_variables) {
4692 if (!variable_str) {
4701 for (i = 0; i < varc; i++) {
4702 char valbuf[512], *ret =
NULL;
4704 if (vars[i][strlen(vars[i]) - 1] ==
')') {
4705 if (
ast_func_read(chan, vars[i], valbuf,
sizeof(valbuf)) < 0) {
4713 ast_str_append(&variable_str, 0,
"Variable: %s=%s\r\n", vars[i], ret);
4717 if (all_variables) {
4731 "Privilege: Call\r\n" 4735 "EffectiveConnectedLineNum: %s\r\n" 4736 "EffectiveConnectedLineName: %s\r\n" 4737 "TimeToHangup: %ld\r\n" 4739 "Application: %s\r\n" 4741 "Nativeformats: %s\r\n" 4742 "Readformat: %s\r\n" 4744 "Writeformat: %s\r\n" 4745 "Writetrans: %s\r\n" 4746 "Callgroup: %llu\r\n" 4747 "Pickupgroup: %llu\r\n" 4768 (
long)elapsed_seconds,
4782 int all_variables = 0;
4795 all_variables =
ast_true(all_chan_variables);
4820 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n",
id);
4833 generate_status(s, chan, vars.name, vars.argc, all_variables, id_text, &channels);
4871 obj_size = payload_size +
sizeof(*obj);
4878 obj->action = action;
4879 obj->payload_size = payload_size;
4880 memcpy(obj->payload, payload, payload_size);
4912 const char *content_type)
5009 if (sscanf(priority,
"%30d", &pi) != 1) {
5027 if (sscanf(priority2,
"%30d", &pi2) != 1) {
5038 snprintf(buf,
sizeof(buf),
"Channel does not exist: %s", name);
5062 snprintf(buf,
sizeof(buf),
"ExtraChannel does not exist: %s", name2);
5201 for (digit = feature_code; *
digit; ++
digit) {
5239 if (!feature_code) {
5245 for (digit = feature_code; *
digit; ++
digit) {
5261 char *cmd_copy, *cur_cmd;
5273 cmd_words[i] = cur_cmd;
5298 char *
buf =
NULL, *final_buf =
NULL, *delim, *output;
5299 char template[] =
"/tmp/ast-ami-XXXXXX";
5313 if ((fd = mkstemp(
template)) < 0) {
5322 if ((len = lseek(fd, 0, SEEK_END)) < 0) {
5323 astman_append(s,
"Message: Failed to determine number of characters: %s\r\n", strerror(
errno));
5324 goto action_command_cleanup;
5331 if (!buf || !final_buf) {
5333 goto action_command_cleanup;
5336 if (lseek(fd, 0, SEEK_SET) < 0) {
5337 astman_append(s,
"Message: Failed to set position on temporary file: %s\r\n", strerror(
errno));
5338 goto action_command_cleanup;
5341 if (read(fd, buf, len) < 0) {
5342 astman_append(s,
"Message: Failed to read from temporary file: %s\r\n", strerror(
errno));
5343 goto action_command_cleanup;
5348 final_buf[
len] =
'\0';
5351 if (len && final_buf[len - 1] ==
'\n') {
5352 final_buf[len - 1] =
'\0';
5358 while ((output =
strsep(&delim,
"\n"))) {
5362 action_command_cleanup:
5451 "Application: %s\r\n" 5455 "CallerIDNum: %s\r\n" 5456 "CallerIDName: %s\r\n",
5457 in->
idtext, res ?
"Failure" :
"Success",
5473 "CallerIDNum: %s\r\n" 5474 "CallerIDName: %s\r\n",
5475 in->
idtext, res ?
"Failure" :
"Success",
5495 const char *unitamount;
5496 const char *unittype;
5499 memset(entry, 0,
sizeof(*entry));
5501 ast_str_set(&str, 0,
"UnitAmount(%u)", entry_num);
5530 const char *association_num =
astman_get_header(m,
"ChargingAssociationNumber");
5538 unsigned int _currencyamount = 0;
5539 int _association_id = 0;
5540 unsigned int _association_plan = 0;
5545 size_t encoded_size = 0;
5548 astman_send_error(s, m,
"Channel and PartialChannel are not specified. Specify at least one of these.");
5549 goto aocmessage_cleanup;
5558 goto aocmessage_cleanup;
5561 if (
ast_strlen_zero(msgtype) || (strcasecmp(msgtype,
"d") && strcasecmp(msgtype,
"e"))) {
5563 goto aocmessage_cleanup;
5568 goto aocmessage_cleanup;
5573 if (!strcasecmp(chargetype,
"NA")) {
5575 }
else if (!strcasecmp(chargetype,
"Free")) {
5577 }
else if (!strcasecmp(chargetype,
"Currency")) {
5579 }
else if (!strcasecmp(chargetype,
"Unit")) {
5583 goto aocmessage_cleanup;
5588 if (
ast_strlen_zero(currencyamount) || (sscanf(currencyamount,
"%30u", &_currencyamount) != 1)) {
5589 astman_send_error(s, m,
"Invalid CurrencyAmount, CurrencyAmount is a required when ChargeType is Currency");
5590 goto aocmessage_cleanup;
5594 astman_send_error(s, m,
"ChargeMultiplier unspecified, ChargeMultiplier is required when ChargeType is Currency.");
5595 goto aocmessage_cleanup;
5596 }
else if (!strcasecmp(mult,
"onethousandth")) {
5598 }
else if (!strcasecmp(mult,
"onehundredth")) {
5600 }
else if (!strcasecmp(mult,
"onetenth")) {
5602 }
else if (!strcasecmp(mult,
"one")) {
5604 }
else if (!strcasecmp(mult,
"ten")) {
5606 }
else if (!strcasecmp(mult,
"hundred")) {
5608 }
else if (!strcasecmp(mult,
"thousand")) {
5612 goto aocmessage_cleanup;
5619 goto aocmessage_cleanup;
5623 if (!
ast_strlen_zero(totaltype) && !strcasecmp(totaltype,
"subtotal")) {
5629 }
else if (!strcasecmp(aocbillingid,
"Normal")) {
5631 }
else if (!strcasecmp(aocbillingid,
"ReverseCharge")) {
5633 }
else if (!strcasecmp(aocbillingid,
"CreditCard")) {
5637 goto aocmessage_cleanup;
5642 }
else if (!strcasecmp(aocbillingid,
"Normal")) {
5644 }
else if (!strcasecmp(aocbillingid,
"ReverseCharge")) {
5646 }
else if (!strcasecmp(aocbillingid,
"CreditCard")) {
5648 }
else if (!strcasecmp(aocbillingid,
"CallFwdUnconditional")) {
5650 }
else if (!strcasecmp(aocbillingid,
"CallFwdBusy")) {
5652 }
else if (!strcasecmp(aocbillingid,
"CallFwdNoReply")) {
5654 }
else if (!strcasecmp(aocbillingid,
"CallDeflection")) {
5656 }
else if (!strcasecmp(aocbillingid,
"CallTransfer")) {
5660 goto aocmessage_cleanup;
5663 if (!
ast_strlen_zero(association_id) && (sscanf(association_id,
"%30d", &_association_id) != 1)) {
5665 goto aocmessage_cleanup;
5667 if (!
ast_strlen_zero(association_plan) && (sscanf(association_plan,
"%30u", &_association_plan) != 1)) {
5669 goto aocmessage_cleanup;
5672 if (_association_id) {
5686 for (i = 0; i < 32; i++) {
5696 astman_send_error(s, m,
"Invalid UnitAmount(0), At least one valid unit entry is required when ChargeType is set to Unit");
5697 goto aocmessage_cleanup;
5709 astman_send_error(s, m,
"Error encoding AOC message, could not queue onto channel");
5753 int bridge_early = 0;
5766 goto fast_orig_cleanup;
5772 goto fast_orig_cleanup;
5774 if (!
ast_strlen_zero(priority) && (sscanf(priority,
"%30d", &pi) != 1)) {
5778 goto fast_orig_cleanup;
5781 if (!
ast_strlen_zero(timeout) && (sscanf(timeout,
"%30d", &to) != 1)) {
5784 goto fast_orig_cleanup;
5788 data = strchr(tmp,
'/');
5792 goto fast_orig_cleanup;
5814 int bad_appdata = 0;
5828 (strstr(appdata,
"SHELL") && (bad_appdata = 1)) ||
5829 (strstr(appdata,
"EVAL") && (bad_appdata = 1))
5832 snprintf(error_buf,
sizeof(error_buf),
"Originate Access Forbidden: %s", bad_appdata ?
"Data" :
"Application");
5835 goto fast_orig_cleanup;
5840 if (exten && context && pi) {
5845 goto fast_orig_cleanup;
5860 for (v = vars; v->
next; v = v->
next );
5868 bridge_early =
ast_true(early_media);
5912 if (exten && context && pi) {
5915 l, n, vars, account,
NULL, bridge_early,
5919 astman_send_error(s, m,
"Originate with 'Exten' requires 'Context' and 'Priority'");
5922 goto fast_orig_cleanup;
5949 "Waiting: %d\r\n\r\n", mailbox, ret);
5956 int newmsgs = 0, oldmsgs = 0, urgentmsgs = 0;;
5966 "UrgMessages: %d\r\n" 5967 "NewMessages: %d\r\n" 5968 "OldMessages: %d\r\n" 5970 mailbox, urgentmsgs, newmsgs, oldmsgs);
5986 context =
"default";
5997 "StatusText: %s\r\n" 5999 exten, context, hint, status,
6036 "PresenceMessage: %s\r\n",
6049 struct timeval when = {
timeout, 0 };
6056 if (!timeout || timeout < 0) {
6066 when.tv_usec = (timeout - when.tv_sec) * 1000000.0;
6080 regex_t *regex_filter = obj;
6081 const char *eventdata = arg;
6084 if (!regexec(regex_filter, eventdata, 0,
NULL, 0)) {
6094 regex_t *regex_filter = obj;
6095 const char *eventdata = arg;
6098 if (!regexec(regex_filter, eventdata, 0,
NULL, 0)) {
6117 if (!strcasecmp(operation,
"Add")) {
6125 astman_send_error(s, m,
"Filter did not compile. Check the syntax of the filter given.");
6170 if (filter_pattern[0] ==
'!') {
6177 if (regcomp(new_filter, filter_pattern, REG_EXTENDED | REG_NOSUB)) {
6178 ao2_t_ref(new_filter, -1,
"failed to make regex");
6182 if (is_blackfilter) {
6183 ao2_t_link(blackfilters, new_filter,
"link new filter into black user container");
6185 ao2_t_link(whitefilters, new_filter,
"link new filter into white user container");
6198 ast_verbose(
"<-- Examining AMI event: -->\n%s\n", eventdata);
6200 ast_debug(3,
"Examining AMI event:\n%s\n", eventdata);
6237 ast_debug(3,
"Received CloseSession event\n");
6263 for (x = 0; x < m->
hdrcount; x++) {
6264 if (strncasecmp(
"UserEvent:", m->
headers[x], strlen(
"UserEvent:")) &&
6265 strncasecmp(
"Action:", m->
headers[x], strlen(
"Action:"))) {
6282 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
6289 "AMIversion: %s\r\n" 6290 "AsteriskVersion: %s\r\n" 6291 "SystemName: %s\r\n" 6292 "CoreMaxCalls: %d\r\n" 6293 "CoreMaxLoadAvg: %f\r\n" 6294 "CoreRunUser: %s\r\n" 6295 "CoreRunGroup: %s\r\n" 6296 "CoreMaxFilehandles: %d\r\n" 6297 "CoreRealTimeEnabled: %s\r\n" 6298 "CoreCDRenabled: %s\r\n" 6299 "CoreHTTPenabled: %s\r\n" 6322 char startuptime[150], startupdate[150];
6323 char reloadtime[150], reloaddate[150];
6327 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
6333 ast_strftime(startuptime,
sizeof(startuptime),
"%H:%M:%S", &tm);
6334 ast_strftime(startupdate,
sizeof(startupdate),
"%Y-%m-%d", &tm);
6336 ast_strftime(reloadtime,
sizeof(reloadtime),
"%H:%M:%S", &tm);
6337 ast_strftime(reloaddate,
sizeof(reloaddate),
"%Y-%m-%d", &tm);
6341 "CoreStartupDate: %s\r\n" 6342 "CoreStartupTime: %s\r\n" 6343 "CoreReloadDate: %s\r\n" 6344 "CoreReloadTime: %s\r\n" 6345 "CoreCurrentCalls: %d\r\n" 6400 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
6412 char durbuf[16] =
"";
6419 int duration, durh, durm, durs;
6422 durh = duration / 3600;
6423 durm = (duration % 3600) / 60;
6424 durs = duration % 60;
6425 snprintf(durbuf,
sizeof(durbuf),
"%02d:%02d:%02d", durh, durm, durs);
6429 "Event: CoreShowChannel\r\n" 6432 "Application: %s\r\n" 6433 "ApplicationData: %s\r\n" 6480 if ((cut = strchr(filename,
'.'))) {
6483 cut = filename + strlen(filename);
6485 snprintf(cut, (
sizeof(filename) - strlen(filename)) - 1,
".so");
6486 ast_debug(1,
"**** ModuleCheck .so file %s\n", filename);
6494 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n",
id);
6499 #if !defined(LOW_MEMORY) 6511 if (!loadtype || strlen(loadtype) == 0) {
6514 if ((!module || strlen(module) == 0) && strcasecmp(loadtype,
"reload") != 0) {
6518 if (!strcasecmp(loadtype,
"load")) {
6525 }
else if (!strcasecmp(loadtype,
"unload")) {
6532 }
else if (!strcasecmp(loadtype,
"reload")) {
6537 switch (reload_res) {
6568 static void log_action(
const struct message *m,
const char *action)
6582 for (x = 0; x < m->
hdrcount; ++x) {
6583 if (!strncasecmp(m->
headers[x],
"Secret", 6)) {
6612 const char *username;
6627 ast_log(
LOG_ERROR,
"Unable to process manager action '%s'. Asterisk is shutting down.\n", action);
6635 && strcasecmp(action,
"Login")
6636 && strcasecmp(action,
"Logoff")
6637 && strcasecmp(action,
"Challenge")) {
6648 && (!strcasecmp(action,
"Login")
6649 || !strcasecmp(action,
"Challenge"))) {
6682 if (mod_ref || !act_found->
module) {
6684 ret = act_found->
func(s, m);
6703 ao2_t_ref(act_found, -1,
"done with found action object");
6708 snprintf(buf,
sizeof(buf),
"Invalid/unknown command: %s. Use Action: ListCommands to show available commands.", action);
6749 if (src[x] ==
'\r' && x+1 < s->
session->
inlen && src[x + 1] ==
'\n') {
6751 }
else if (src[x] ==
'\n') {
6756 memmove(output, src, x);
6775 if(time(&now) == -1) {
6854 struct message m = { 0 };
6871 if (time(&now) == -1) {
6886 }
else if (res > 0) {
6956 if (session ==
NULL) {
7035 time_t now = time(
NULL);
7050 ast_verb(2,
"HTTP Manager '%s' timed out from %s\n",
7083 strcpy(tmp->eventdata, str);
7110 #define MANAGER_EVENT_BUF_INITSIZE 256 7125 const char *cat_str;
7138 "Privilege: %s\r\n",
7144 "Timestamp: %ld.%06lu\r\n",
7145 (
long)now.tv_sec, (
unsigned long) now.tv_usec);
7151 "SequenceNumber: %d\r\n",
7161 "SystemName: %s\r\n",
7228 file, line, func, fmt, ap);
7235 const char *fmt, ...)
7249 file, line, func, fmt, ap);
7264 if (!strcasecmp(action, cur->
action)) {
7281 ao2_t_ref(cur, -1,
"action object removed from list");
7282 ast_verb(2,
"Manager unregistered action %s\n", action);
7303 "StatusText: %s\r\n",
7349 ao2_t_ref(act, +1,
"action object added to list");
7395 ao2_t_ref(cur, -1,
"action object creation failed");
7441 ao2_t_ref(cur, -1,
"action object registration failed");
7445 ao2_t_ref(cur, -1,
"action object registration successful");
7525 if (nonce == 0 || username ==
NULL || stale ==
NULL) {
7540 }
else if (!strcasecmp(session->
username, username) && session->
oldnonce == nonce) {
7644 int space =
sizeof(
buf);
7646 for ( ; *src || dst !=
buf ; src++) {
7647 if (*src ==
'\0' || space < 10) {
7651 space =
sizeof(
buf);
7657 if ( (mode & 2) && !isalnum(*src)) {
7664 strcpy(dst,
"<");
7669 strcpy(dst,
">");
7674 strcpy(dst,
""");
7679 strcpy(dst,
"'");
7684 strcpy(dst,
"&");
7690 *dst++ = mode ? tolower(*src) : *src;
7750 const char *dest =
NULL;
7752 const char *objtype =
NULL;
7761 for (v = get_vars; v; v = v->
next) {
7762 if (!strcasecmp(v->
name,
"ajaxdest")) {
7764 }
else if (!strcasecmp(v->
name,
"ajaxobjtype")) {
7772 objtype =
"generic";
7778 val =
strsep(&in,
"\r\n");
7779 if (in && *in ==
'\n') {
7783 ast_debug(5,
"inobj %d in_data %d line <%s>\n", inobj, in_data, val);
7795 "<tr><td colspan=\"2\"><hr></td></tr>\r\n");
7806 ast_str_append(out, 0,
"<response type='object' id='%s'><%s", dest, objtype);
7830 var =
"Opaque-data";
7836 if ((vc =
ao2_find(vco, var, 0))) {
7847 if (vc->
count > 1) {
7853 if (!in_data || !*in) {
7860 "<tr><td colspan=\"2\"><hr></td></tr>\r\n");
7871 ast_log(
LOG_ERROR,
"Attempted to close file/file descriptor on mansession without a valid file or file descriptor.\n");
7889 l = lseek(fd, 0, SEEK_CUR);
7891 if (MAP_FAILED == (buf = mmap(
NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0))) {
7911 const struct ast_sockaddr *remote_address,
const char *uri,
7921 char template[] =
"/tmp/ast-http-XXXXXX";
7923 struct message m = { 0 };
7926 ast_http_error(ser, 501,
"Not Implemented",
"Attempt to use unimplemented / unsupported method");
7940 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
7964 if (http_header ==
NULL || out ==
NULL) {
7966 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (ast_str_create() out of memory)");
7967 goto generic_callback_out;
7971 fd = mkstemp(
template);
7974 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (mkstemp failed)");
7975 goto generic_callback_out;
7980 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (fdopen failed)");
7982 goto generic_callback_out;
7990 ast_http_error(ser, 413,
"Request Entity Too Large",
"Body too large");
7992 goto generic_callback_out;
7997 goto generic_callback_out;
7999 ast_http_error(ser, 400,
"Bad Request",
"Error parsing request body");
8001 goto generic_callback_out;
8024 "Content-type: text/%s\r\n" 8025 "Set-Cookie: mansession_id=\"%08x\"; Version=1; Max-Age=%d\r\n" 8026 "Pragma: SuppressEvents\r\n",
8027 contenttype[format],
8039 #define ROW_FMT "<tr><td colspan=\"2\" bgcolor=\"#f1f1ff\">%s</td></tr>\r\n" 8040 #define TEST_STRING \ 8041 "<form action=\"manager\" method=\"post\">\n\ 8042 Action: <select name=\"action\">\n\ 8043 <option value=\"\">-----></option>\n\ 8044 <option value=\"login\">login</option>\n\ 8045 <option value=\"command\">Command</option>\n\ 8046 <option value=\"waitevent\">waitevent</option>\n\ 8047 <option value=\"listcommands\">listcommands</option>\n\ 8049 or <input name=\"action\"><br/>\n\ 8050 CLI Command <input name=\"command\"><br>\n\ 8051 user <input name=\"username\"> pass <input type=\"password\" name=\"secret\"><br>\n\ 8052 <input type=\"submit\">\n</form>\n" 8054 ast_str_append(&out, 0,
"<title>Asterisk™ Manager Interface</title>");
8055 ast_str_append(&out, 0,
"<body bgcolor=\"#ffffff\"><table align=center bgcolor=\"#f1f1f1\" width=\"500\">\r\n");
8073 if (session->
inuse == 1) {
8074 ast_debug(1,
"Need destroy, doing it now!\n");
8077 ast_debug(1,
"Need destroy, but can't do it yet!\n");
8094 generic_callback_out:
8123 const struct ast_sockaddr *remote_address,
const char *uri,
8130 char template[] =
"/tmp/ast-http-XXXXXX";
8133 struct message m = { 0 };
8136 time_t time_now = time(
NULL);
8137 unsigned long nonce = 0, nc;
8141 char resp_hash[256]=
"";
8143 char u_username[80];
8147 int u_displayconnects;
8150 ast_http_error(ser, 501,
"Not Implemented",
"Attempt to use unimplemented / unsupported method");
8155 for (v = headers; v; v = v->
next) {
8156 if (!strcasecmp(v->
name,
"Authorization")) {
8168 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8177 if (sscanf(d.
nonce,
"%30lx", &nonce) != 1) {
8197 ast_http_error(ser, 403,
"Permission denied",
"Permission denied");
8214 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8223 snprintf(resp,
sizeof(resp),
"%s:%08lx:%s:%s:auth:%s", user->
a1_hash, nonce, d.
nc, d.
cnonce, a2_hash);
8226 snprintf(resp,
sizeof(resp),
"%s:%08lx:%s", user->
a1_hash, nonce, a2_hash);
8231 if (strncasecmp(d.
response, resp_hash, strlen(resp_hash))) {
8256 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8270 if (u_displayconnects) {
8293 sscanf(d.
nc,
"%30lx", &nc);
8294 if (session->
nc >= nc || ((time_now - session->
noncetime) > 62) ) {
8321 fd = mkstemp(
template);
8324 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (mkstemp failed)");
8325 goto auth_callback_out;
8330 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (fdopen failed)");
8332 goto auth_callback_out;
8340 ast_http_error(ser, 413,
"Request Entity Too Large",
"Body too large");
8342 goto auth_callback_out;
8347 goto auth_callback_out;
8349 ast_http_error(ser, 400,
"Bad Request",
"Error parsing request body");
8351 goto auth_callback_out;
8359 if (u_displayconnects) {
8372 if (http_header ==
NULL || out ==
NULL) {
8374 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (ast_str_create() out of memory)");
8376 goto auth_callback_out;
8379 ast_str_append(&http_header, 0,
"Content-type: text/%s\r\n", contenttype[format]);
8385 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n" 8387 "<title>Asterisk™ Manager Interface</title>\r\n" 8388 "</head><body style=\"background-color: #ffffff;\">\r\n" 8389 "<form method=\"POST\">\r\n" 8390 "<table align=\"center\" style=\"background-color: #f1f1f1;\" width=\"500\">\r\n" 8391 "<tr><th colspan=\"2\" style=\"background-color: #f1f1ff;\"><h1>Manager Tester</h1></th></tr>\r\n" 8392 "<tr><th colspan=\"2\" style=\"background-color: #f1f1ff;\">Action: <input name=\"action\" /> Cmd: <input name=\"command\" /><br>" 8393 "<input type=\"submit\" value=\"Send request\" /></th></tr>\r\n");
8427 ast_debug(1,
"Need destroy, doing it now!\n");
8477 .
description =
"Raw HTTP Manager Event Interface",
8536 .
description =
"Raw HTTP Manager Event Interface w/Digest authentication",
8545 .
description =
"HTML Manager Event Interface w/Digest authentication",
8554 .
description =
"XML Manager Event Interface w/Digest authentication",
8566 const char *login = (
char *)arg;
8567 int *no_sessions = data;
8569 if (strcasecmp(session->
username, login) == 0) {
8589 ast_log(
LOG_WARNING,
"AMI_CLIENT() requires two arguments: AMI_CLIENT(<name>[,<arg>])\n");
8604 if (!strcasecmp(
args.param,
"sessions")) {
8605 int no_sessions = 0;
8613 snprintf(buf, len,
"%d", no_sessions);
8626 .
name =
"AMI_CLIENT",
8647 .poll_timeout = 5000,
8649 .name =
"AMI server",
8659 .name =
"AMI TLS server",
8669 e->
command =
"manager show settings";
8671 "Usage: manager show settings\n" 8672 " Provides detailed list of the configuration of the Manager.\n";
8677 #define FORMAT " %-25.25s %-15.55s\n" 8678 #define FORMAT2 " %-25.25s %-15d\n" 8710 return strcmp((*item_a)->name, (*item_b)->name);
8720 int i = 0, totalitems = 0;
8724 e->
command =
"manager show events";
8726 "Usage: manager show events\n" 8727 " Prints a listing of the available Asterisk manager interface events.\n";
8743 ast_cli(a->
fd,
"No manager event documentation loaded\n");
8767 items[totalitems++] =
item;
8774 ast_cli(a->
fd,
" -------------------- -------------------- -------------------- \n");
8775 for (i = 0; i < totalitems; i++) {
8777 if ((i + 1) % 3 == 0) {
8782 if ((i + 1) % 3 != 0) {
8796 char syntax_title[64], description_title[64], synopsis_title[64], seealso_title[64], arguments_title[64];
8806 ast_cli(a->
fd,
"%s%s\n\n", synopsis_title, synopsis);
8811 ast_cli(a->
fd,
"%s%s\n\n", syntax_title, syntax);
8816 ast_cli(a->
fd,
"%s%s\n\n", description_title, description);
8821 ast_cli(a->
fd,
"%s%s\n\n", arguments_title, arguments);
8826 ast_cli(a->
fd,
"%s%s\n\n", seealso_title, seealso);
8839 e->
command =
"manager show event";
8841 "Usage: manager show event <eventname>\n" 8842 " Provides a detailed description a Manager interface event.\n";
8848 ast_cli(a->
fd,
"No manager event documentation loaded\n");
8857 length = strlen(a->
word);
8860 if (!strncasecmp(a->
word, item->
name, length)) {
9009 #ifdef TEST_FRAMEWORK 9011 test_suite_forwarder =
NULL;
9014 if (stasis_router) {
9016 stasis_router =
NULL;
9019 rtp_topic_forwarder =
NULL;
9021 security_topic_forwarder =
NULL;
9023 manager_topic =
NULL;
9059 if (!rtp_topic_forwarder) {
9064 if (!security_topic_forwarder) {
9069 if (!stasis_router) {
9150 int newhttptimeout = 60;
9158 int tls_was_enabled = 0;
9159 int acl_subscription_flag = 0;
9173 if (!manager_topic) {
9217 #ifdef TEST_FRAMEWORK 9232 if (temp_event_docs) {
9234 ao2_t_ref(temp_event_docs, -1,
"Remove creation ref - container holds only ref now");
9254 ast_log(
LOG_NOTICE,
"Unable to open AMI configuration manager.conf, or configuration is invalid.\n");
9259 if (!by_external_config) {
9276 if (strcasecmp(var->
name,
"tlscafile")
9277 && strcasecmp(var->
name,
"tlscapath")
9278 && strcasecmp(var->
name,
"tlscadir")
9279 && strcasecmp(var->
name,
"tlsverifyclient")
9280 && strcasecmp(var->
name,
"tlsdontverifyserver")
9281 && strcasecmp(var->
name,
"tlsclientmethod")
9282 && strcasecmp(var->
name,
"sslclientmethod")
9287 if (!strcasecmp(var->
name,
"enabled")) {
9289 }
else if (!strcasecmp(var->
name,
"webenabled")) {
9291 }
else if (!strcasecmp(var->
name,
"port")) {
9297 }
else if (!strcasecmp(var->
name,
"bindaddr")) {
9302 ast_log(
LOG_WARNING,
"Invalid address '%s' specified, default '%s' will be used\n", val,
9312 }
else if (!strcasecmp(var->
name,
"brokeneventsaction")) {
9314 }
else if (!strcasecmp(var->
name,
"allowmultiplelogin")) {
9316 }
else if (!strcasecmp(var->
name,
"displayconnects")) {
9318 }
else if (!strcasecmp(var->
name,
"timestampevents")) {
9320 }
else if (!strcasecmp(var->
name,
"debug")) {
9322 }
else if (!strcasecmp(var->
name,
"httptimeout")) {
9323 newhttptimeout = atoi(val);
9324 }
else if (!strcasecmp(var->
name,
"authtimeout")) {
9325 int timeout = atoi(var->
value);
9332 }
else if (!strcasecmp(var->
name,
"authlimit")) {
9333 int limit = atoi(var->
value);
9340 }
else if (!strcasecmp(var->
name,
"channelvars")) {
9381 const char *hasmanager;
9385 if (!strcasecmp(cat,
"general")) {
9390 if ((!hasmanager && genhasmanager) ||
ast_true(hasmanager)) {
9402 if (!(user =
ast_calloc(1,
sizeof(*user)))) {
9430 if (!user_displayconnects) {
9433 if (!user_allowmultiplelogin) {
9436 if (!user_writetimeout) {
9451 if (user_displayconnects) {
9454 if (user_allowmultiplelogin) {
9457 if (user_writetimeout) {
9458 int value = atoi(user_writetimeout);
9475 if (!strcasecmp(cat,
"general")) {
9481 if (!(user =
ast_calloc(1,
sizeof(*user)))) {
9516 for (;
var; var = var->
next) {
9517 if (!strcasecmp(var->
name,
"secret")) {
9520 }
else if (!strcasecmp(var->
name,
"deny") ||
9521 !strcasecmp(var->
name,
"permit") ||
9522 !strcasecmp(var->
name,
"acl")) {
9527 ast_log(
LOG_ERROR,
"Invalid ACL '%s' for manager user '%s' on line %d. Deleting user\n",
9531 }
else if (!strcasecmp(var->
name,
"read") ) {
9533 }
else if (!strcasecmp(var->
name,
"write") ) {
9535 }
else if (!strcasecmp(var->
name,
"displayconnects") ) {
9537 }
else if (!strcasecmp(var->
name,
"allowmultiplelogin") ) {
9539 }
else if (!strcasecmp(var->
name,
"writetimeout")) {
9546 }
else if (!strcasecmp(var->
name,
"setvar")) {
9555 if ((varval = strchr(varname,
'='))) {
9562 }
else if (!strcasecmp(var->
name,
"eventfilter")) {
9575 if (acl_subscription_flag && !by_external_config) {
9624 if (newhttptimeout > 0) {
9687 if (datastore->
info != info) {
9696 if ((datastore->
uid !=
NULL) && !strcasecmp(uid, datastore->
uid)) {
9709 if (!*fields_string) {
9711 if (!*fields_string) {
9716 return (
ast_str_append(fields_string, 0,
"%s: %s\r\n", header, value) < 0) ? -1 : 0;
9731 const
char *extra_fields_fmt,
9753 va_start(argp, extra_fields_fmt);
9766 .requires =
"extconfig,acl,http",
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.
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
int ast_category_is_template(const struct ast_category *category)
Check if category is a template.
#define ao2_t_ref(o, delta, tag)
Reference/unreference an object and return the old refcount.
static int load_module(void)
helper function for originate
size_t ast_msg_data_get_length(struct ast_msg_data *msg)
Get length of the structure.
const ast_string_field cnonce
static int action_challenge(struct mansession *s, const struct message *m)
struct ast_iostream * stream
struct ast_category * ast_category_new(const char *name, const char *in_file, int lineno)
Create a category.
static const char synopsis[]
static int get_input(struct mansession *s, char *output)
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...
struct ast_variable * next
struct ao2_container * ast_channel_cache_by_name(void)
Secondary channel cache, indexed by name.
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
struct ast_variable * ast_variables_reverse(struct ast_variable *var)
Reverse a variable list.
static char * handle_showmancmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct ao2_container * blackfilters
const ast_string_field data
Struct containing info for an AMI event to send out.
static int action_command(struct mansession *s, const struct message *m)
Manager command "command" - execute CLI command.
Information needed to identify an endpoint in a call.
enum sip_cc_notify_state state
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.
struct ao2_container * whitefilters
#define ast_channel_lock(chan)
int ast_func_read(struct ast_channel *chan, const char *function, char *workspace, size_t len)
executes a read operation on a function
static void close_mansession_file(struct mansession *s)
static char exten[AST_MAX_EXTENSION]
static const char * __astman_get_header(const struct message *m, char *var, int mode)
Return a matching header value.
Main Channel structure associated with a channel.
static int action_originate(struct mansession *s, const struct message *m)
An attempt at basic password authentication failed.
#define AST_CLI_DEFINE(fn, txt,...)
static int check_blacklist(const char *cmd)
char * str
Subscriber phone number (Malloced)
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
enum ast_security_event_type event_type
The security event sub-type.
static void astman_append_json(struct mansession *s, const char *str)
static int action_mailboxstatus(struct mansession *s, const struct message *m)
struct ast_channel_snapshot_base * base
Asterisk locking-related definitions:
void astman_append(struct mansession *s, const char *fmt,...)
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
Asterisk main include file. File version handling, generic pbx functions.
int ast_shutting_down(void)
const ast_string_field otherchannelid
const ast_string_field uniqueid
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
const char * presence_message
static void mansession_unlock(struct mansession *s)
Unlock the 'mansession' structure.
FYI FWIW, Successful authentication has occurred.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Security Event Reporting API.
const ast_string_field tech
void ast_variable_insert(struct ast_category *category, struct ast_variable *variable, const char *line)
static int subscribe_all(void)
const ast_string_field account
enum ast_module_load_result ast_load_resource(const char *resource_name)
Load a module.
int astman_verify_session_writepermissions(uint32_t ident, int perm)
Verify a session's write permissions against a permission mask.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized...
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.
const char * expected_response
Response expected to be received.
void ast_manager_unregister_hook(struct manager_custom_hook *hook)
Delete a custom hook to be called when an event is fired.
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 ...
String manipulation functions.
static void astman_start_ack(struct mansession *s, const struct message *m)
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
char * ast_get_chan_features_atxferabort(struct ast_channel *chan)
Get the transfer configuration option atxferabort.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
#define ao2_t_alloc(data_size, destructor_fn, debug_msg)
int ast_ssl_setup(struct ast_tls_config *cfg)
Set up an SSL server.
int ast_variable_delete(struct ast_category *category, const char *variable, const char *match, const char *line)
#define ast_pthread_create_detached(a, b, c, d)
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
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.
static struct ast_threadstorage userevent_buf
#define AST_RWLIST_INSERT_AFTER
static int action_reload(struct mansession *s, const struct message *m)
Send a reload event.
Asterisk version information.
static enum ast_transport mansession_get_transport(const struct mansession *s)
static int displayconnects
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
static struct ast_variable * man_do_variable_value(struct ast_variable *head, const char *hdr_val)
#define any_manager_listeners(sessions)
static int action_userevent(struct mansession *s, const struct message *m)
#define ast_channel_unref(c)
Decrease channel reference count.
const ast_string_field extra_fields
struct ast_xml_doc_item * next
int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg)
access for hooks to send action messages to ami
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.
static void report_invalid_user(const struct mansession *s, const char *username)
#define ast_test_flag(p, flag)
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
void ast_manager_register_hook(struct manager_custom_hook *hook)
Add a custom hook to be called when an event is fired.
static void manager_default_msg_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
struct mansession_session::mansession_datastores datastores
void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Set when to hang a channel up.
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
Support for translation of data formats. translate.c.
int ast_manager_check_enabled(void)
Check if AMI is enabled.
#define GET_HEADER_LAST_MATCH
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
static void manager_json_to_ast_str(struct ast_json *obj, const char *key, struct ast_str **res, key_exclusion_cb exclusion_cb)
ssize_t ast_iostream_write(struct ast_iostream *stream, const void *buffer, size_t count)
Write data to an iostream.
const char * ast_var_value(const struct ast_var_t *var)
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
void ast_http_auth(struct ast_tcptls_session_instance *ser, const char *realm, const unsigned long nonce, const unsigned long opaque, int stale, const char *text)
Send http "401 Unauthorized" response and close socket.
struct ast_party_name name
Subscriber name.
static void astman_append_headers(struct message *m, const struct ast_variable *params)
Append additional headers into the message structure from params.
An attempt at challenge/response auth failed.
static void json_escape(char *out, const char *in)
static int action_ping(struct mansession *s, const struct message *m)
const char * ast_get_version(void)
Retrieve the Asterisk version string.
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.
#define MAX_AUTH_PERM_STRING
static struct sessions sessions
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
struct ast_category * ast_category_delete(struct ast_config *cfg, struct ast_category *category)
Delete a category.
#define ao2_t_global_obj_replace_unref(holder, obj, tag)
Replace an ao2 object in the global holder, throwing away any old object.
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
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
const char * ast_var_name(const struct ast_var_t *var)
Iterator for JSON object key/values.
#define ast_set_flag(p, flag)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
int ast_check_hangup_locked(struct ast_channel *chan)
enum ast_module_reload_result ast_module_reload(const char *name)
Reload asterisk modules.
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
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().
ast_module_reload_result
Possible return types for ast_module_reload.
descriptor for a cli entry.
static struct ast_manager_user * get_manager_by_name_locked(const char *name)
int64_t ast_tvdiff_sec(struct timeval end, struct timeval start)
Computes the difference (in seconds) between two struct timeval instances.
int ast_http_uri_link(struct ast_http_uri *urihandler)
Register a URI handler.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define AST_TASKPROCESSOR_HIGH_WATER_LEVEL
#define ao2_callback(c, flags, cb_fn, arg)
int(* func)(struct mansession *s, const struct message *m)
#define CONFIG_STATUS_FILEINVALID
#define EVENT_FLAG_COMMAND
static int action_login(struct mansession *s, const struct message *m)
static int authenticate(struct mansession *s, const struct message *m)
struct ast_json_iter * ast_json_object_iter(struct ast_json *object)
Get an iterator pointing to the first field in a JSON object.
#define VERBOSITY_ATLEAST(level)
struct ast_tcptls_session_args * parent
static char * handle_showmanagers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
char * ast_xmldoc_build_description(const char *type, const char *name, const char *module)
Generate description documentation from XML.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
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.
struct eventqent * last_ev
enum ast_state_cb_update_reason reason
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...
static int get_perm(const char *instr)
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Structure for variables, used for configurations and for channel variables.
static int ast_manager_register_struct(struct manager_action *act)
void MD5Final(unsigned char digest[16], struct MD5Context *context)
Structure representing a snapshot of channel state.
static void manager_generic_msg_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
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.
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
static struct ast_str * astman_send_list_complete_start_common(struct mansession *s, const struct message *m, const char *event_name, int count)
struct ao2_container * ast_xmldoc_build_documentation(const char *type)
Build the documentation for a particular source type.
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
void ast_acl_output(int fd, struct ast_acl_list *acl, const char *prefix)
output an ACL to the provided fd
void ast_iostream_set_timeout_inactivity(struct ast_iostream *stream, int timeout)
Set the iostream inactivity timeout timer.
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.
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
Checking against an IP access control list failed.
static int action_createconfig(struct mansession *s, const struct message *m)
void ast_http_uri_unlink(struct ast_http_uri *urihandler)
Unregister a URI handler.
void * ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded)
free an ast_aoc_decoded object
Assume that the ao2_container is already locked.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
Structure to pass both assignedid values to channel drivers.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
#define ao2_t_global_obj_release(holder, tag)
Release the ao2 object held in the global holder.
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 ...
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)
Structure for a data store type.
Structure used to transport a message through the frame core.
static const struct @407 command_blacklist[]
char * term_strip(char *outbuf, const char *inbuf, int maxout)
Remove colorings from a specified string.
#define ao2_t_link(container, obj, tag)
Add an object to a container.
static void report_req_not_allowed(const struct mansession *s, const char *action)
char * str
Subscriber name (Malloced)
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
int ast_logger_rotate(void)
Reload logger while rotating log files.
struct ast_iostream * ast_iostream_from_fd(int *fd)
Create an iostream from a file descriptor.
static int manager_moduleload(struct mansession *s, const struct message *m)
static void report_session_limit(const struct mansession *s)
static const struct adsi_event events[]
struct ast_category * prev
struct ast_security_event_common common
Common security event descriptor elements.
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...
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static int action_aocmessage(struct mansession *s, const struct message *m)
static struct aco_type item
#define ao2_global_obj_ref(holder)
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
const char * response
Response received.
int ast_iostream_get_fd(struct ast_iostream *stream)
Get an iostream's file descriptor.
static int copy(char *infile, char *outfile)
Utility function to copy a file.
static int process_events(struct mansession *s)
static int action_getconfigjson(struct mansession *s, const struct message *m)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
arguments for the accepting thread
static char * handle_manager_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager show settings.
Wrapper for an ast_acl linked list.
#define ao2_alloc_options(data_size, destructor_fn, options)
#define ast_mutex_lock(a)
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
double ast_option_maxload
const char * ast_config_AST_RUN_USER
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 match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
#define ast_str_alloca(init_len)
const ast_string_field username
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
uint32_t ast_http_manid_from_vars(struct ast_variable *headers) attribute_pure
Return manager id, if exist, from request headers.
void ast_verbose(const char *fmt,...)
struct ast_security_event_common common
Common security event descriptor elements.
#define ast_strdup(str)
A wrapper for strdup()
Structure for a data store object.
A request was made that is not allowed.
static int queue_sendtext(struct ast_channel *chan, const char *body)
Queue a read action to send a text message.
ast_aoc_currency_multiplier
Defines the currency multiplier for an aoc message.
struct varshead * ast_channel_varshead(struct ast_channel *chan)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
static void session_destructor(void *obj)
static const char *const contenttype[]
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
#define MAX_BLACKLIST_CMD_LEN
Descriptor for a manager session, either on the AMI socket or over HTTP.
static struct ast_tcptls_session_args ami_desc
static void report_failed_challenge_response(const struct mansession *s, const char *response, const char *expected_response)
#define MANAGER_EVENT_BUF_INITSIZE
static struct stasis_topic * manager_topic
A stasis_topic that all topics AMI cares about will be forwarded to.
user descriptor, as read from the config file.
static int inbuf(struct baseio *bio, FILE *fi)
utility used by inchar(), for base_encode()
static int unauth_sessions
int ast_json_is_null(const struct ast_json *value)
Check if value is JSON null.
Definitions to aid in the use of thread local storage.
static int action_sendtext(struct mansession *s, const struct message *m)
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
struct ast_xml_doc_item * list_responses
Out-of-call text message support.
char * ast_xmldoc_build_synopsis(const char *type, const char *name, const char *module)
Generate synopsis documentation from XML.
Generic support for tcp/tls servers in Asterisk.
void ast_cli(int fd, const char *fmt,...)
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,...)
struct ast_format_cap * cap
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
#define AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION
Event descriptor version.
void ast_category_destroy(struct ast_category *cat)
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...
struct ao2_container * blackfilters
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...
list of users found in the config file
static int append_event(const char *str, int category)
events are appended to a queue from where they can be dispatched to clients.
static int action_atxfer(struct mansession *s, const struct message *m)
int manager_bridging_init(void)
Initialize support for AMI channel events.
#define EVENT_FLAG_DIALPLAN
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 void process_output(struct mansession *s, struct ast_str **out, struct ast_variable *params, enum output_format format)
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.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Socket address structure.
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...
static char cid_num[AST_MAX_EXTENSION]
static int aocmessage_get_unit_entry(const struct message *m, struct ast_aoc_unit_entry *entry, unsigned int entry_num)
static struct ast_str * password
struct ast_channel_snapshot_dialplan * dialplan
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 struct manager_action * action_find(const char *name)
#define ast_verb(level,...)
#define EVENT_FLAG_ORIGINATE
static struct mansession_session * unref_mansession(struct mansession_session *s)
Unreference manager session object. If no more references, then go ahead and delete it...
struct ast_trans_pvt * ast_channel_readtrans(const struct ast_channel *chan)
static int manager_state_cb(const char *context, const char *exten, struct ast_state_cb_info *info, void *data)
void MD5Init(struct MD5Context *context)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
STASIS_MESSAGE_TYPE_DEFN(ast_manager_get_generic_type)
Define AMI message types.
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.
static void manager_free_user(struct ast_manager_user *user)
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...
#define ast_string_field_ptr_build_va(x, ptr, fmt, args)
Set a field to a complex (built) value with prebuilt va_lists.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
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 char * handle_showmaneventq(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager list eventq.
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...
struct ast_module * module
struct ast_str * ast_category_get_templates(const struct ast_category *category)
Return the template names this category inherits from.
static int action_filter(struct mansession *s, const struct message *m)
Manager command to add an event filter to a manager session.
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 struct stasis_subscription * acl_change_sub
int ast_category_inherit(struct ast_category *existing, const struct ast_category *base)
Applies base (template) to category.
int ast_module_check(const char *name)
Check if module with the name given is loaded.
static struct ast_http_uri arawmanuri
static void ast_sockaddr_setnull(struct ast_sockaddr *addr)
Sets address addr to null.
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
struct ast_channel * ast_channel_get_by_name_prefix(const char *name, size_t name_len)
Find a channel by a name prefix.
const char * astman_get_header(const struct message *m, char *var)
Return the first matching variable from an array.
static struct mansession_session * find_session(uint32_t ident, int incinuse)
static struct ast_custom_function managerclient_function
description of AMI_CLIENT dialplan function
#define ast_module_unref(mod)
Release a reference to the module.
#define ast_strlen_zero(foo)
static const struct permalias perms[]
int ast_realtime_enabled(void)
Check if there's any realtime engines loaded.
int ast_webmanager_check_enabled(void)
Check if AMI/HTTP is enabled.
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
const char * manager_event
struct ast_variable * chanvars
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.
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.
const char * ast_config_AST_SYSTEM_NAME
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)
struct ast_manager_event_blob * stasis_message_to_ami(struct stasis_message *msg)
Build the AMI representation of the message.
ssize_t ast_iostream_read(struct ast_iostream *stream, void *buffer, size_t count)
Read data from an iostream.
int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num, uint8_t plan)
set the charging accociation number for an AOC-E message
static int action_events(struct mansession *s, const struct message *m)
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized, or having a 0 length.
static void append_channel_vars(struct ast_str **pbuf, struct ast_channel *chan)
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
static struct ast_threadstorage manager_event_buf
int ast_cdr_is_enabled(void)
Return TRUE if CDR subsystem is enabled.
const char * ast_config_AST_RUN_GROUP
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
An attempt at basic password auth failed.
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 action_getconfig(struct mansession *s, const struct message *m)
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)
Configuration File Parser.
Support for Private Asterisk HTTP Servers.
enum ast_extension_states exten_state
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
static void destroy_fast_originate_helper(struct fast_originate_helper *doomed)
void ast_category_rename(struct ast_category *cat, const char *name)
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
static int check_manager_session_inuse(const char *name)
#define AST_RWLIST_INSERT_HEAD
int ast_app_inboxcount2(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Determine number of urgent/new/old messages in a mailbox.
#define EVENT_FLAG_SYSTEM
const ast_string_field uri
#define ast_debug(level,...)
Log a DEBUG message.
struct stasis_message_type * ast_manager_get_generic_type(void)
Get the stasis_message_type for generic messages.
struct ao2_container * whitefilters
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
static int manager_modulecheck(struct mansession *s, const struct message *m)
Manager function to check if module is loaded.
Generic Advice of Charge encode and decode routines.
static int blackfilter_cmp_fn(void *obj, void *arg, void *data, int flags)
static void report_inval_password(const struct mansession *s, const char *username)
void * ast_tcptls_server_root(void *)
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.
int ast_iostream_close(struct ast_iostream *stream)
Close an iostream.
General Asterisk PBX channel definitions.
Asterisk JSON abstraction layer.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
static int action_blind_transfer(struct mansession *s, const struct message *m)
Asterisk file paths, configured in asterisk.conf.
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
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 ...
struct ast_json * ast_json_object_iter_value(struct ast_json_iter *iter)
Get the value from an iterator.
const ast_string_field response
const ast_string_field appl
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
enum ast_presence_state presence_state
static AO2_GLOBAL_OBJ_STATIC(mgr_sessions)
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
struct ast_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan)
const ast_string_field description
#define AST_PTHREADT_NULL
static struct ast_mansession session
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
#define ast_dummy_channel_alloc()
Create a fake channel structure.
Data structure associated with a custom dialplan function.
Access Control of various sorts.
Request received with bad formatting.
static struct ao2_container * codecs
Registered codecs.
#define ASTMAN_APPEND_BUF_INITSIZE
initial allocated size for the astman_append_buf and astman_send_*_va
Request denied because of a session limit.
unsigned int registered
TRUE if the AMI action is registered and the callback can be called.
#define AST_RWLIST_TRAVERSE
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Successful authentication.
#define AST_STRING_FIELD(name)
Declare a string field.
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_coreshowchannels(struct mansession *s, const struct message *m)
Manager command "CoreShowChannels" - List currently defined channels and some information about them...
#define ao2_ref(o, delta)
static int action_cancel_atxfer(struct mansession *s, const struct message *m)
const char * ast_extension_state2str(int extension_state)
Return string representation of the state of an extension.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
struct ast_variable * ast_category_first(struct ast_category *cat)
given a pointer to a category, return the root variable.
void ast_config_destroy(struct ast_config *config)
Destroys a config.
In case you didn't read that giant block of text above the mansession_session struct, the struct mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
const char * presence_subtype
long int ast_random(void)
const struct ast_datastore_info * info
#define GET_HEADER_SKIP_EMPTY
mansession_message_parsing
#define AST_SECURITY_EVENT_FAILED_ACL_VERSION
Event descriptor version.
enum mansession_message_parsing parsing
static char * handle_showmanager(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define AST_RWLIST_REMOVE_CURRENT
struct timeval creationtime
#define ast_strdupa(s)
duplicate a string in memory from the stack
struct timeval ast_lastreloadtime
struct ast_variable * chanvars
static int action_logoff(struct mansession *s, const struct message *m)
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)
int astman_verify_session_readpermissions(uint32_t ident, int perm)
Verify a session's read permissions against a permission mask.
const ast_string_field cid_num
static struct mansession_session * find_session_by_nonce(const char *username, unsigned long nonce, int *stale)
static void log_action(const struct message *m, const char *action)
static struct stasis_forward * test_suite_forwarder
The stasis_subscription for forwarding the Test topic to the AMI topic.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
static void manager_json_value_str_append(struct ast_json *value, const char *key, struct ast_str **res)
char * ast_strsep(char **s, const char sep, uint32_t flags)
Act like strsep but ignore separators inside quotes.
const ast_string_field exten
static struct ast_http_uri managerxmluri
static struct ast_http_uri manageruri
static void challenge(const char *realm, pjsip_tx_data *tdata, const pjsip_rx_data *rdata, int is_stale)
astobj2 callback for adding digest challenges to responses
A set of macros to manage forward-linked lists.
ast_cli_command
calling arguments for new-style handlers.
struct ast_security_event_common common
Common security event descriptor elements.
#define ast_malloc(len)
A wrapper for malloc()
static char * handle_manager_show_events(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
const char * ast_json_object_iter_key(struct ast_json_iter *iter)
Get the key from an iterator.
struct timeval sessionstart_tv
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)
struct ast_security_event_common common
Common security event descriptor elements.
static struct channel_usage channels
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
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
#define ast_variable_new(name, value, filename)
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_tls_config ami_tls_cfg
static int unload_module(void)
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
struct ast_variable * vars
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
static struct eventqent * advance_event(struct eventqent *e)
static int timestampevents
struct ast_str * ast_manager_build_channel_state_string(const struct ast_channel_snapshot *snapshot)
Generate the AMI message body from a channel snapshot.
static struct ast_tcptls_session_args amis_desc
int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastore)
Remove a datastore from a session.
static void print_event_instance(struct ast_cli_args *a, struct ast_xml_doc_item *instance)
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.
static void manager_shutdown(void)
Core PBX routines and definitions.
static int ast_xml_doc_item_cmp_fn(const void *a, const void *b)
describes a server instance
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
list of actions registered
#define stasis_message_router_create(topic)
void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg)
Send response in manager transaction.
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
int ast_acl_list_is_empty(struct ast_acl_list *acl_list)
Determines if an ACL is empty or if it contains entries.
#define CONFIG_STATUS_FILEUNCHANGED
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.
#define stasis_subscribe(topic, callback, data)
static int manager_subscriptions_init(void)
Initialize all Stasis Message Bus API topics and routers used by the various sub-components of AMI...
struct ast_str * description
static void acl_change_stasis_unsubscribe(void)
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
Colorize a specified string by adding terminal color codes.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
const char * ast_channel_uniqueid(const struct ast_channel *chan)
const ast_string_field arguments
struct ast_acl_list * acl
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)
static int action_listcommands(struct mansession *s, const struct message *m)
void ast_iostream_set_timeout_disable(struct ast_iostream *stream)
Disable the iostream timeout timer.
int ast_manager_unregister(const char *action)
support functions to register/unregister AMI action handlers,
void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len)
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define AST_SECURITY_EVENT_INVAL_ACCT_ID_VERSION
Event descriptor version.
#define GET_HEADER_FIRST_MATCH
static int __init_manager(int reload, int by_external_config)
Presence state management.
Structure that contains information about a bridge.
struct ast_tcptls_session_instance * tcptls_session
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
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.
static struct ast_threadstorage astman_append_buf
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 void astman_flush(struct mansession *s, struct ast_str *buf)
static void acl_change_stasis_subscribe(void)
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
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.
#define EVENT_FLAG_CONFIG
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
static int strings_to_mask(const char *string)
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
static char * handle_showmancmds(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager list commands.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
void ast_iostream_set_timeout_sequence(struct ast_iostream *stream, struct timeval start, int timeout)
Set the iostream I/O sequence timeout timer.
static int action_mailboxcount(struct mansession *s, const struct message *m)
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 '...
struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan)
#define ao2_unlink(container, obj)
const char * ast_config_AST_CONFIG_DIR
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.
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
static struct stasis_message_router * stasis_router
The stasis_message_router for all Stasis Message Bus API messages.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
#define ao2_global_obj_release(holder)
static struct templates templates
struct ast_acl_list * ast_free_acl_list(struct ast_acl_list *acl)
Free a list of ACLs.
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.
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 int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ao2_callback_data(container, flags, cb_fn, arg, data)
const ast_string_field appdata
int ast_category_insert(struct ast_config *config, struct ast_category *cat, const char *match)
Inserts new category.
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.
struct ast_variable * astman_get_variables(const struct message *m)
Get a linked list of the Variable: headers.
int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode)
Unload a module.
static void report_failed_acl(const struct mansession *s, const char *username)
struct stasis_topic * ast_test_suite_topic(void)
#define ao2_t_callback(c, flags, cb_fn, arg, tag)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container, as described below.
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 char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
const char * words[AST_MAX_CMD_LEN]
An attempt at challenge/response authentication failed.
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
void ast_include_rename(struct ast_config *conf, const char *from_file, const char *to_file)
#define ao2_iterator_next(iter)
#define ao2_alloc(data_size, destructor_fn)
struct stasis_message_router * ast_manager_get_message_router(void)
Get the stasis_message_router for AMI.
static int action_waitevent(struct mansession *s, const struct message *m)
struct timeval ast_channel_creationtime(struct ast_channel *chan)
const ast_string_field nc
static enum add_filter_result manager_add_filter(const char *filter_pattern, struct ao2_container *whitefilters, struct ao2_container *blackfilters)
Add an event filter to a manager session.
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
static int action_timeout(struct mansession *s, const struct message *m)
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...
char * strcasestr(const char *, const char *)
const char * ast_channel_appl(const struct ast_channel *chan)
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
int astman_is_authed(uint32_t ident)
Determinie if a manager session ident is authenticated.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
const ast_string_field name
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"...
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
static int action_getvar(struct mansession *s, const struct message *m)
static int match_filter(struct mansession *s, char *eventdata)
#define ast_channel_unlock(chan)
static void event_filter_destructor(void *obj)
static void parse(struct mgcp_request *req)
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
#define ast_calloc(num, len)
A wrapper for calloc()
int manager_endpoints_init(void)
Initialize support for AMI endpoint events.
const ast_string_field cid_name
static void report_auth_success(const struct mansession *s)
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.
#define EVENT_FLAG_SECURITY
Module could not be loaded properly.
#define EVENT_FLAG_HOOKRESPONSE
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *result,...)
The argument parsing routine.
struct stasis_forward * stasis_forward_cancel(struct stasis_forward *forward)
struct ast_iostream * stream
static void astman_free_headers(struct message *m)
Free headers inside message structure, but not the message structure itself.
static int broken_events_action
void * ast_aoc_destroy_encoded(struct ast_aoc_encoded *encoded)
free an ast_aoc_encoded object
enum ast_json_type ast_json_typeof(const struct ast_json *value)
Get the type of value.
#define AST_RWLIST_REMOVE_HEAD
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
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_security_event_common common
Common security event descriptor elements.
static struct stasis_forward * security_topic_forwarder
The stasis_subscription for forwarding the Security topic to the AMI topic.
const char * ast_get_http_method(enum ast_http_method method) attribute_pure
Return http method name string.
static void action_destroy(void *obj)
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...
#define ao2_find(container, arg, flags)
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.
An API for managing task processing threads that can be shared across modules.
#define manager_event_sessions(sessions, category, event, contents,...)
char * ast_xmldoc_printable(const char *bwinput, int withcolors)
Colorize and put delimiters (instead of tags) to the xmldoc output.
static int action_status(struct mansession *s, const struct message *m)
Manager "status" command to show channels.
static void purge_old_stuff(void *data)
cleanup code called at each iteration of server_root, guaranteed to happen every 5 seconds at most ...
#define DEFAULT_MANAGER_TLS_PORT
static int send_string(struct mansession *s, char *string)
int stasis_message_can_be_ami(struct stasis_message *msg)
Determine if the given message can be converted to AMI.
structure to hold users read from users.conf
static int action_coresettings(struct mansession *s, const struct message *m)
Show PBX core settings information.
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
Structure used to handle boolean flags.
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
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_seealso(const char *type, const char *name, const char *module)
Parse the <see-also> node content.
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". If folder is "INBOX", includes the number of messages in the "Urgent" folder.
const ast_string_field data
const ast_string_field context
struct ast_iostream * stream
static char cid_name[AST_MAX_EXTENSION]
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
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...
#define CONFIG_STATUS_FILEMISSING
Invalid account ID specified (invalid username, for example)
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_category_append(struct ast_config *config, struct ast_category *cat)
Appends a category to a config.
const char * ast_channel_data(const struct ast_channel *chan)
#define ast_module_running_ref(mod)
Hold a reference to the module if it is running.
struct ast_category * ast_category_new_template(const char *name, const char *in_file, int lineno)
Create a category making it a template.
struct timeval ast_startuptime
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
#define EVENT_FLAG_REPORTING
static int get_manager_sessions_cb(void *obj, void *arg, void *data, int flags)
Get number of logged in sessions for a login name.
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
static void parsing(int size, unsigned char *buf, struct unistimsession *pte, struct sockaddr_in *addr_from)
const ast_string_field nonce
#define ao2_global_obj_replace_unref(holder, obj)
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
struct ast_security_event_common common
Common security event descriptor elements.
static struct ast_http_uri amanageruri
struct ast_security_event_common common
Common security event descriptor elements.
#define AST_SECURITY_EVENT_INVAL_PASSWORD_VERSION
Event descriptor version.
#define AST_RWLIST_INSERT_TAIL
static void load_channelvars(struct ast_variable *var)
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
static struct ast_cli_entry cli_manager[]
#define AST_MAX_PUBLIC_UNIQUEID
struct ast_flags ast_options
int ast_category_empty(struct ast_category *category)
Removes and destroys all variables in a category.
char * strsep(char **str, const char *delims)
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.
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.
#define DEFAULT_MANAGER_PORT
#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...
static int variable_count_cmp_fn(void *obj, void *vstr, int flags)
static int do_message(struct mansession *s)
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...
static struct mansession_session * build_mansession(const struct ast_sockaddr *addr)
Allocate manager session structure and add it to the list of sessions.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
static struct eventqent * grab_last(void)
#define EVENT_FLAG_SHUTDOWN
Fake event class used to end sessions at shutdown.
Standard Command Line Interface.
static struct ast_http_uri amanagerxmluri
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
static int manager_enabled
#define MGR_SHOW_TERMINAL_WIDTH
static int action_updateconfig(struct mansession *s, const struct message *m)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
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.
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_extension_state(struct ast_channel *c, const char *context, const char *exten)
Uses hint and devicestate callback to get the state of an extension.
static int ast_instring(const char *bigstr, const char *smallstr, const char delim)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
static char * handle_manager_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager reload.
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.
static struct stasis_forward * rtp_topic_forwarder
The stasis_subscription for forwarding the RTP topic to the AMI topic.
const char * ast_channel_name(const struct ast_channel *chan)
static void mansession_lock(struct mansession *s)
Lock the 'mansession' structure.
struct ast_datastore * astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a session.
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
struct ast_channel_snapshot_bridge * bridge
int manager_system_init(void)
Initialize support for AMI system events.
struct stasis_topic * ast_rtp_topic(void)
Stasis Message Bus API topic for RTP and RTCP related messages
#define EVENT_FLAG_VERBOSE
struct ast_channel_iterator * ast_channel_iterator_destroy(struct ast_channel_iterator *i)
Destroy a channel iterator.
Definition of a URI handler.
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.
ast_aoc_billing_id
Defines the billing id options for an aoc message.
static void * fast_originate(void *data)
int astman_datastore_add(struct mansession *s, struct ast_datastore *datastore)
Add a datastore to a session.
#define AST_FEATURE_MAX_LEN
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.
size_t ast_json_array_size(const struct ast_json *array)
Get the size of a JSON array.
static int action_hangup(struct mansession *s, const struct message *m)
const ast_string_field app
static void purge_events(void)
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...
void ast_iostream_nonblock(struct ast_iostream *stream)
Make an iostream non-blocking.
static int whitefilter_cmp_fn(void *obj, void *arg, void *data, int flags)
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 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.
struct stasis_forward * sub
Data structure associated with a single frame of data.
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)
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
#define ast_manager_event_multichan(category, event, nchans, chans, contents,...)
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
const ast_string_field channelid
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...
const char * headers[AST_MAX_MANHEADERS]
static void session_destroy(struct mansession_session *s)
Abstract JSON element (object, array, string, int, ...).
int ast_parse_digest(const char *digest, struct ast_http_digest *d, int request, int pedantic)
Parse digest authorization header.
const ast_string_field idtext
static char global_realm[MAXHOSTNAMELEN]
#define AST_SECURITY_EVENT_REQ_BAD_FORMAT_VERSION
Event descriptor version.
ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan)
struct mansession_session * session
#define AST_RWLIST_REMOVE
static void handle_parse_error(struct mansession *s, struct message *m, char *error)
const char * ast_channel_context(const struct ast_channel *chan)
Handy terminal functions for vt* terms.
int error(const char *format,...)
static int action_extensionstate(struct mansession *s, const struct message *m)
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
Struct that contains the XML documentation for a particular item. Note that this is an ao2 ref counte...
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
int ast_wait_for_input(int fd, int ms)
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_SECURITY_EVENT_CHAL_RESP_FAILED_VERSION
Event descriptor version.
void ast_tcptls_server_stop(struct ast_tcptls_session_args *desc)
Shutdown a running server if there is one.
struct ast_tls_config * tls_cfg
static char * handle_manager_show_event(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ast_mutex_init(pmutex)
static int allowmultiplelogin
#define AST_CLI_YESNO(x)
Return Yes or No depending on the argument.
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
struct ast_str * arguments
unsigned char valid
TRUE if the name information is valid/present.
struct ast_sockaddr local_address
static char context[AST_MAX_CONTEXT]
ast_group_t ast_channel_callgroup(const struct ast_channel *chan)
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static int action_corestatus(struct mansession *s, const struct message *m)
Show PBX core status information.
Call Parking and Pickup API Includes code and algorithms from the Zapata library. ...
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
ast_http_method
HTTP Request methods known by Asterisk.
#define ast_mutex_destroy(a)
static int webmanager_enabled
static int filter(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name, const char *filter)
Retrieve a category if it exists.
int manager_channels_init(void)
Initialize support for AMI channel events.
const ast_string_field synopsis
struct ast_channel_iterator * ast_channel_iterator_all_new(void)
Create a new channel iterator.
int ast_extension_state_add(const char *context, const char *exten, ast_state_cb_type change_cb, void *data)
Add watcher for extension states.
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.
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.
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
ast_frame_read_action
Actions to indicate to, and be handled on channel read.
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...
struct ast_xml_doc_item * final_response
struct manager_custom_hook * hook
int ast_security_event_report(const struct ast_security_event_common *sec)
Report a security event.
void ast_md5_hash(char *output, const char *input)
Produces MD5 hash based on input string.
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
Pluggable RTP Architecture.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Asterisk module definitions.
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
static int manager_displayconnects(struct mansession_session *session)
Get displayconnects config option.
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
static void xml_copy_escape(struct ast_str **out, const char *src, int mode)
static void manager_set_defaults(void)
static snd_pcm_format_t format
int ast_active_channels(void)
returns number of active/allocated channels
static char * handle_mandebug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
void ast_http_request_close_on_completion(struct ast_tcptls_session_instance *ser)
Request the HTTP connection be closed after this HTTP request.
static int mansession_cmp_fn(void *obj, void *arg, int flags)
struct ast_json * ast_json_array_get(const struct ast_json *array, size_t index)
Get an element from an array.
static struct prometheus_metrics_provider provider
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
static void manager_event_blob_dtor(void *obj)
int manager_mwi_init(void)
Initialize support for AMI MWI events.
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.
struct ast_variable * ast_variables_dup(struct ast_variable *var)
Duplicate variable list.
unsigned char valid
TRUE if the number information is valid/present.
static int action_redirect(struct mansession *s, const struct message *m)
action_redirect: The redirect manager command
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
static int action_listcategories(struct mansession *s, const struct message *m)
#define AST_RWLIST_TRAVERSE_SAFE_END
#define AST_SECURITY_EVENT_SESSION_LIMIT_VERSION
Event descriptor version.
const ast_string_field seealso
static struct ast_http_uri rawmanuri
Request denied because it's not allowed.
const ast_string_field syntax
const char * request_type
Request type that was made.
const char * ast_category_get_name(const struct ast_category *category)
Return the name of the category.
Structure for mutex and tracking information.
static char * handle_showmanconn(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager list connected.
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.
static void report_req_bad_format(const struct mansession *s, const char *action)
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 int variable_count_hash_fn(const void *vvc, const int flags)
static void purge_sessions(int n_max)
remove at most n_max stale session from the list.
const char * ast_presence_state2str(enum ast_presence_state state)
Convert presence state to text string for output.
static int action_presencestate(struct mansession *s, const struct message *m)
void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj)
Publish an event to AMI.
#define AST_SECURITY_EVENT_REQ_NOT_ALLOWED_VERSION
Event descriptor version.
static int reload_module(void)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
struct ast_str * synopsis
#define ast_mutex_unlock(a)
static char * manager_channelvars
struct ast_json_iter * ast_json_object_iter_next(struct ast_json *object, struct ast_json_iter *iter)
Get the next iterator.
static int action_setvar(struct mansession *s, const struct message *m)
#define AST_APP_ARG(name)
Define an application argument.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
struct ast_sockaddr remote_address
static void astman_send_list_complete(struct mansession *s, const struct message *m, const char *event_name, int count)
#define EVENT_FLAG_MESSAGE
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
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.
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
struct ast_party_number number
Subscriber phone number.
#define ao2_link(container, obj)