52 #include "asterisk/_private.h"
58 #include <sys/types.h>
911 #define DEFAULT_REALM "asterisk"
927 #define MAX_BLACKLIST_CMD_LEN 2
928 static const struct {
931 {{
"module",
"load", NULL }},
932 {{
"module",
"unload", NULL }},
933 {{
"restart",
"gracefully", NULL }},
970 struct sockaddr_in sin;
978 struct timeval sessionstart_tv;
1027 unsigned int isfunc:1;
1077 struct manager_action *act;
1081 if (!strcasecmp(name, act->
action)) {
1082 ao2_t_ref(act, +1,
"found action object");
1114 return (webmanager_enabled && manager_enabled);
1123 struct eventqent *ret;
1143 struct eventqent *ev;
1203 strstr(evaluating,
"SHELL") ||
1204 strstr(evaluating,
"EVAL")
1242 if (authority &
perms[i].num) {
1259 static int ast_instring(
const char *bigstr,
const char *smallstr,
const char delim)
1261 const char *
val = bigstr, *next;
1264 if ((next = strchr(val, delim))) {
1265 if (!strncmp(val, smallstr, (next - val))) {
1271 return !strcmp(smallstr, val);
1273 }
while (*(val = (next + 1)));
1307 for (p =
string; *p; p++) {
1308 if (*p < '0' || *p >
'9') {
1313 return atoi(
string);
1332 int refcount =
ao2_ref(s, -1);
1333 if (manager_debug) {
1341 regex_t *regex_filter = obj;
1342 regfree(regex_filter);
1348 struct eventqent *eqe = session->
last_ev;
1357 if (session->
f != NULL) {
1393 newsession->
fd = -1;
1437 struct ast_manager_user *
user = NULL;
1440 if (!strcasecmp(user->
username, name)) {
1454 struct ast_manager_user *
user = NULL;
1473 char syntax_title[64], description_title[64], synopsis_title[64], seealso_title[64], arguments_title[64];
1478 e->
command =
"manager show command";
1480 "Usage: manager show command <actionname> [<actionname> [<actionname> [...]]]\n"
1481 " Shows the detailed description for a specific Asterisk manager interface command.\n";
1484 l = strlen(a->
word);
1488 if (!strncasecmp(a->
word, cur->
action, l) && ++which > a->
n) {
1512 for (num = 3; num < a->
argc; num++) {
1513 if (!strcasecmp(cur->
action, a->
argv[num])) {
1521 ast_cli(a->
fd,
"%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n",
1522 syntax_title, syntax,
1523 synopsis_title, synopsis,
1524 description_title, description,
1525 arguments_title, arguments,
1526 seealso_title, seealso);
1535 ast_cli(a->
fd,
"Action: %s\nSynopsis: %s\nPrivilege: %s\n%s\n",
1536 cur->
action, cur->synopsis,
1538 S_OR(cur->description,
""));
1552 e->
command =
"manager set debug [on|off]";
1553 e->
usage =
"Usage: manager set debug [on|off]\n Show, enable, disable debugging of the manager code.\n";
1560 ast_cli(a->
fd,
"manager debug is %s\n", manager_debug?
"on" :
"off");
1561 }
else if (a->
argc == 4) {
1562 if (!strcasecmp(a->
argv[3],
"on")) {
1564 }
else if (!strcasecmp(a->
argv[3],
"off")) {
1575 struct ast_manager_user *
user = NULL;
1583 e->
command =
"manager show user";
1585 " Usage: manager show user <user>\n"
1586 " Display all information related to the manager user specified.\n";
1589 l = strlen(a->
word);
1596 if ( !strncasecmp(a->
word, user->
username, l) && ++which > a->
n ) {
1612 ast_cli(a->
fd,
"There is no manager called %s\n", a->
argv[3]);
1624 "displayconnects: %s\n",
1626 (user->
secret ?
"<Set>" :
"(N/A)"),
1627 (user->
ha ?
"yes" :
"no"),
1639 struct ast_manager_user *
user = NULL;
1643 e->
command =
"manager show users";
1645 "Usage: manager show users\n"
1646 " Prints a listing of all managers that are currently configured on that\n"
1660 ast_cli(a->
fd,
"There are no manager users.\n");
1665 ast_cli(a->
fd,
"\nusername\n--------\n");
1675 "%d manager users configured.\n", count_amu);
1684 #define HSMC_FORMAT " %-15.15s %-15.15s %-55.55s\n"
1687 e->
command =
"manager show commands";
1689 "Usage: manager show commands\n"
1690 " Prints a listing of all the available Asterisk manager interface commands.\n";
1712 time_t now = time(NULL);
1713 #define HSMCONN_FORMAT1 " %-15.15s %-15.15s %-10.10s %-10.10s %-8.8s %-8.8s %-5.5s %-5.5s\n"
1714 #define HSMCONN_FORMAT2 " %-15.15s %-15.15s %-10d %-10d %-8d %-8d %-5.5d %-5.5d\n"
1720 e->
command =
"manager show connected";
1722 "Usage: manager show connected\n"
1723 " Prints a listing of the users that are currently connected to the\n"
1724 "Asterisk manager interface.\n";
1730 ast_cli(a->
fd,
HSMCONN_FORMAT1,
"Username",
"IP Address",
"Start",
"Elapsed",
"FileDes",
"HttpCnt",
"Read",
"Write");
1741 ast_cli(a->
fd,
"%d users connected.\n", count);
1750 struct eventqent *s;
1753 e->
command =
"manager show eventq";
1755 "Usage: manager show eventq\n"
1756 " Prints a listing of all events pending in the Asterisk manger\n"
1766 ast_cli(a->
fd,
"Event:\n%s", s->eventdata);
1778 e->
command =
"manager reload";
1780 "Usage: manager reload\n"
1781 " Reloads the manager configuration.\n";
1795 struct eventqent *next;
1806 #define GET_HEADER_FIRST_MATCH 0
1807 #define GET_HEADER_LAST_MATCH 1
1808 #define GET_HEADER_SKIP_EMPTY 2
1825 int x, l = strlen(var);
1826 const char *result =
"";
1832 for (x = 0; x < m->
hdrcount; x++) {
1833 const char *h = m->
headers[x];
1834 if (!strncasecmp(var, h, l) && h[l] ==
':') {
1835 const char *
value = h + l + 1;
1890 for (y = 0; y <
args.argc; y++) {
1895 if (!
args.vars[y]) {
1898 var = val =
args.vars[y];
1930 static const char var_hdr[] =
"Variable:";
1933 varlen = strlen(var_hdr);
1934 for (x = 0; x < m->
hdrcount; x++) {
1935 if (strncasecmp(var_hdr, m->
headers[x], varlen)) {
1973 curlen = strlen(src);
1974 for (x = 0; x < curlen; x++) {
1976 if (src[x] ==
'\r' && x+1 < curlen && src[x+1] ==
'\n')
1978 else if (src[x] ==
'\n')
1995 if (strcasecmp(action,
"login")) {
2010 ret = act_found->
func(&s, &m);
2017 ao2_t_ref(act_found, -1,
"done with found action object");
2063 #define ASTMAN_APPEND_BUF_INITSIZE 256
2081 if (s->
f != NULL || s->
session->
f != NULL) {
2084 ast_verbose(
"fd == -1 in astman_append, should not happen\n");
2104 #define MSG_MOREDATA ((char *)astman_send_response)
2186 struct sockaddr_in *sin_local)
2196 struct sockaddr_in sin_local;
2197 char session_id[32];
2201 .common.service =
"AMI",
2202 .common.account_id = username,
2204 .common.local_addr = {
2208 .common.remote_addr = {
2212 .common.session_id = session_id,
2215 snprintf(session_id,
sizeof(session_id),
"%p", s);
2222 struct sockaddr_in sin_local;
2223 char session_id[32];
2227 .common.service =
"AMI",
2228 .common.account_id = username,
2230 .common.local_addr = {
2234 .common.remote_addr = {
2238 .common.session_id = session_id,
2241 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2248 struct sockaddr_in sin_local;
2249 char session_id[32];
2253 .common.service =
"AMI",
2254 .common.account_id = username,
2256 .common.local_addr = {
2260 .common.remote_addr = {
2264 .common.session_id = session_id,
2267 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2274 struct sockaddr_in sin_local;
2275 char session_id[32];
2279 .common.service =
"AMI",
2282 .common.local_addr = {
2286 .common.remote_addr = {
2290 .common.session_id = session_id,
2293 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2300 struct sockaddr_in sin_local;
2301 char session_id[32];
2302 char request_type[64];
2306 .common.service =
"AMI",
2309 .common.local_addr = {
2313 .common.remote_addr = {
2317 .common.session_id = session_id,
2322 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2323 snprintf(request_type,
sizeof(request_type),
"Action: %s", action);
2330 struct sockaddr_in sin_local;
2331 char session_id[32];
2332 char request_type[64];
2336 .common.service =
"AMI",
2339 .common.local_addr = {
2343 .common.remote_addr = {
2347 .common.session_id = session_id,
2352 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2353 snprintf(request_type,
sizeof(request_type),
"Action: %s", action);
2359 const char *response,
const char *expected_response)
2361 struct sockaddr_in sin_local;
2362 char session_id[32];
2366 .common.service =
"AMI",
2369 .common.local_addr = {
2373 .common.remote_addr = {
2377 .common.session_id = session_id,
2384 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2391 struct sockaddr_in sin_local;
2392 char session_id[32];
2396 .common.service =
"AMI",
2399 .common.local_addr = {
2403 .common.remote_addr = {
2407 .common.session_id = session_id,
2410 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2427 struct ast_manager_user *
user = NULL;
2428 regex_t *regex_filter;
2452 char md5key[256] =
"";
2454 unsigned char digest[16];
2460 for (x = 0; x < 16; x++)
2461 len += sprintf(md5key + len,
"%2.2x", (
unsigned)digest[x]);
2462 if (!strcmp(md5key, key)) {
2468 ast_debug(1,
"MD5 authentication is not possible. challenge: '%s'\n",
2471 }
else if (user->
secret) {
2472 if (!strcmp(password, user->
secret)) {
2498 ao2_t_ref(regex_filter, -1,
"remove iterator ref");
2505 ao2_t_ref(regex_filter, -1,
"remove iterator ref");
2531 "Timestamp: %ld.%06lu\r\n"
2533 (
long) now.tv_sec, (
unsigned long) now.tv_usec);
2544 char *cur_category = NULL;
2565 astman_append(s,
"Category-%06d: %s\r\n", catcount, cur_category);
2602 astman_append(s,
"Category-%06d: %s\r\n", catcount, category);
2605 if (catcount == 0) {
2621 if (*in ==
'\\' || *in ==
'\"') {
2706 for (x = 0; x < 100000; x++) {
2707 unsigned int object = 0;
2709 snprintf(hdr,
sizeof(hdr),
"Action-%06d", x);
2714 snprintf(hdr,
sizeof(hdr),
"Cat-%06d", x);
2721 snprintf(hdr,
sizeof(hdr),
"Var-%06d", x);
2724 snprintf(hdr,
sizeof(hdr),
"Value-%06d", x);
2732 snprintf(hdr,
sizeof(hdr),
"Match-%06d", x);
2735 snprintf(hdr,
sizeof(hdr),
"Line-%06d", x);
2738 if (!strcasecmp(action,
"newcat")) {
2756 }
else if (!strcasecmp(action,
"renamecat")) {
2766 }
else if (!strcasecmp(action,
"delcat")) {
2771 }
else if (!strcasecmp(action,
"emptycat")) {
2776 }
else if (!strcasecmp(action,
"update")) {
2789 }
else if (!strcasecmp(action,
"delete")) {
2802 }
else if (!strcasecmp(action,
"append")) {
2815 if (
object || (match && !strcasecmp(match,
"object"))) {
2819 }
else if (!strcasecmp(action,
"insert")) {
2951 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n",
id);
2957 sscanf(timeouts,
"%30i", &timeout);
2975 time_t now = time(NULL);
2981 if (timeout < 0 || timeout > max) {
2992 ast_debug(1,
"Starting waiting for an event!\n");
2994 for (x = 0; x < timeout || timeout < 0; x++) {
3021 ast_debug(1,
"Finished waiting for an event!\n");
3036 "Event: WaitEventComplete\r\n"
3041 ast_debug(1,
"Abandoning event request!\n");
3075 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n",
id);
3081 if (broken_events_action) {
3087 if (!strcasecmp(
perms[x].label,
"all") && res ==
perms[x].
num) {
3092 "Events: On\r\n\r\n", id_text);
3093 }
else if (res == 0)
3095 "Events: Off\r\n\r\n", id_text);
3101 "Events: On\r\n\r\n", id_text);
3104 "Events: Off\r\n\r\n", id_text);
3144 "Status: Fully Booted\r\n\r\n", cat_str);
3153 if (!strcasecmp(authtype,
"MD5")) {
3181 causecode = strtol(cause, &endptr, 10);
3182 if (causecode < 0 || causecode > 127 || *endptr !=
'\0') {
3195 if (causecode > 0) {
3196 ast_debug(1,
"Setting hangupcause of channel %s to %d (is %d now)\n",
3249 char workspace[1024];
3269 workspace[0] =
'\0';
3270 if (varname[strlen(varname) - 1] ==
')') {
3274 ast_func_read(c, (
char *) varname, workspace,
sizeof(workspace));
3276 ast_log(
LOG_ERROR,
"Unable to allocate bogus channel for variable substitution. Function results may be blank.\n");
3278 ast_func_read(c, (
char *) varname, workspace,
sizeof(workspace));
3290 astman_append(s,
"Variable: %s\r\nValue: %s\r\n\r\n", varname,
S_OR(varval,
""));
3305 long elapsed_seconds = 0;
3317 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n",
id);
3355 for (i = 0; i < vars.argc; i++) {
3356 char valbuf[512], *ret = NULL;
3358 if (vars.name[i][strlen(vars.name[i]) - 1] ==
')') {
3367 ast_str_append(&str, 0,
"Variable: %s=%s\r\n", vars.name[i], ret);
3379 elapsed_seconds = now.tv_sec - c->
cdr->
start.tv_sec;
3383 "Privilege: Call\r\n"
3385 "CallerIDNum: %s\r\n"
3386 "CallerIDName: %s\r\n"
3387 "ConnectedLineNum: %s\r\n"
3388 "ConnectedLineName: %s\r\n"
3389 "Accountcode: %s\r\n"
3390 "ChannelState: %u\r\n"
3391 "ChannelStateDesc: %s\r\n"
3413 "Privilege: Call\r\n"
3415 "CallerIDNum: %s\r\n"
3416 "CallerIDName: %s\r\n"
3417 "ConnectedLineNum: %s\r\n"
3418 "ConnectedLineName: %s\r\n"
3449 "Event: StatusComplete\r\n"
3452 "\r\n", idText, channels);
3528 if (sscanf(priority,
"%30d", &pi) != 1) {
3546 if (sscanf(priority2,
"%30d", &pi2) != 1) {
3557 snprintf(buf,
sizeof(buf),
"Channel does not exist: %s", name);
3587 snprintf(buf,
sizeof(buf),
"ExtraChannel does not exist: %s", name2);
3654 char *feature_code = NULL;
3679 for (feature_code = atxfer_feature->
exten; feature_code && *feature_code; ++feature_code) {
3684 for (feature_code = (
char *)exten; feature_code && *feature_code; ++feature_code) {
3698 char *cmd_copy, *cur_cmd;
3710 cmd_words[i] = cur_cmd;
3736 char *buf = NULL, *final_buf = NULL;
3737 char template[] =
"/tmp/ast-ami-XXXXXX";
3751 if ((fd = mkstemp(
template)) < 0) {
3757 astman_append(s,
"Response: Follows\r\nPrivilege: Command\r\n");
3764 if ((l = lseek(fd, 0, SEEK_END)) < 0) {
3766 goto action_command_cleanup;
3773 if (!buf || !final_buf) {
3775 goto action_command_cleanup;
3778 if (lseek(fd, 0, SEEK_SET) < 0) {
3780 goto action_command_cleanup;
3783 if (read(fd, buf, l) < 0) {
3785 goto action_command_cleanup;
3790 final_buf[l] =
'\0';
3793 action_command_cleanup:
3877 "CallerIDNum: %s\r\n"
3878 "CallerIDName: %s\r\n",
3879 in->
idtext, res ?
"Failure" :
"Success",
3896 const char *unitamount;
3897 const char *unittype;
3900 memset(entry, 0,
sizeof(*entry));
3902 ast_str_set(&str, 0,
"UnitAmount(%u)", entry_num);
3931 const char *association_num =
astman_get_header(m,
"ChargingAssociationNumber");
3939 unsigned int _currencyamount = 0;
3940 int _association_id = 0;
3941 unsigned int _association_plan = 0;
3946 size_t encoded_size = 0;
3949 astman_send_error(s, m,
"Channel and PartialChannel are not specified. Specify at least one of these.");
3950 goto aocmessage_cleanup;
3959 goto aocmessage_cleanup;
3962 if (
ast_strlen_zero(msgtype) || (strcasecmp(msgtype,
"d") && strcasecmp(msgtype,
"e"))) {
3964 goto aocmessage_cleanup;
3969 goto aocmessage_cleanup;
3974 if (!strcasecmp(chargetype,
"NA")) {
3976 }
else if (!strcasecmp(chargetype,
"Free")) {
3978 }
else if (!strcasecmp(chargetype,
"Currency")) {
3980 }
else if (!strcasecmp(chargetype,
"Unit")) {
3984 goto aocmessage_cleanup;
3989 if (
ast_strlen_zero(currencyamount) || (sscanf(currencyamount,
"%30u", &_currencyamount) != 1)) {
3990 astman_send_error(s, m,
"Invalid CurrencyAmount, CurrencyAmount is a required when ChargeType is Currency");
3991 goto aocmessage_cleanup;
3995 astman_send_error(s, m,
"ChargeMultiplier unspecified, ChargeMultiplier is required when ChargeType is Currency.");
3996 goto aocmessage_cleanup;
3997 }
else if (!strcasecmp(mult,
"onethousandth")) {
3999 }
else if (!strcasecmp(mult,
"onehundredth")) {
4001 }
else if (!strcasecmp(mult,
"onetenth")) {
4003 }
else if (!strcasecmp(mult,
"one")) {
4005 }
else if (!strcasecmp(mult,
"ten")) {
4007 }
else if (!strcasecmp(mult,
"hundred")) {
4009 }
else if (!strcasecmp(mult,
"thousand")) {
4013 goto aocmessage_cleanup;
4020 goto aocmessage_cleanup;
4024 if (!
ast_strlen_zero(totaltype) && !strcasecmp(totaltype,
"subtotal")) {
4030 }
else if (!strcasecmp(aocbillingid,
"Normal")) {
4032 }
else if (!strcasecmp(aocbillingid,
"ReverseCharge")) {
4034 }
else if (!strcasecmp(aocbillingid,
"CreditCard")) {
4038 goto aocmessage_cleanup;
4043 }
else if (!strcasecmp(aocbillingid,
"Normal")) {
4045 }
else if (!strcasecmp(aocbillingid,
"ReverseCharge")) {
4047 }
else if (!strcasecmp(aocbillingid,
"CreditCard")) {
4049 }
else if (!strcasecmp(aocbillingid,
"CallFwdUnconditional")) {
4051 }
else if (!strcasecmp(aocbillingid,
"CallFwdBusy")) {
4053 }
else if (!strcasecmp(aocbillingid,
"CallFwdNoReply")) {
4055 }
else if (!strcasecmp(aocbillingid,
"CallDeflection")) {
4057 }
else if (!strcasecmp(aocbillingid,
"CallTransfer")) {
4061 goto aocmessage_cleanup;
4064 if (!
ast_strlen_zero(association_id) && (sscanf(association_id,
"%30d", &_association_id) != 1)) {
4066 goto aocmessage_cleanup;
4068 if (!
ast_strlen_zero(association_plan) && (sscanf(association_plan,
"%30u", &_association_plan) != 1)) {
4070 goto aocmessage_cleanup;
4073 if (_association_id) {
4087 for (i = 0; i < 32; i++) {
4097 astman_send_error(s, m,
"Invalid UnitAmount(0), At least one valid unit entry is required when ChargeType is set to Unit");
4098 goto aocmessage_cleanup;
4110 astman_send_error(s, m,
"Error encoding AOC message, could not queue onto channel");
4140 char *l = NULL, *n = NULL;
4154 if (!
ast_strlen_zero(priority) && (sscanf(priority,
"%30d", &pi) != 1)) {
4160 if (!
ast_strlen_zero(timeout) && (sscanf(timeout,
"%30d", &to) != 1)) {
4166 data = strchr(tmp,
'/');
4190 int bad_appdata = 0;
4203 (strstr(appdata,
"SHELL") && (bad_appdata = 1)) ||
4204 (strstr(appdata,
"EVAL") && (bad_appdata = 1))
4207 snprintf(error_buf,
sizeof(error_buf),
"Originate Access Forbidden: %s", bad_appdata ?
"Data" :
"Application");
4248 res =
ast_pbx_outgoing_app(tech, format, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
4251 if (exten && context && pi) {
4252 res =
ast_pbx_outgoing_exten(tech, format, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL);
4255 astman_send_error(s, m,
"Originate with 'Exten' requires 'Context' and 'Priority'");
4281 "Waiting: %d\r\n\r\n", mailbox, ret);
4288 int newmsgs = 0, oldmsgs = 0, urgentmsgs = 0;;
4298 "UrgMessages: %d\r\n"
4299 "NewMessages: %d\r\n"
4300 "OldMessages: %d\r\n"
4302 mailbox, urgentmsgs, newmsgs, oldmsgs);
4310 char hint[256] =
"";
4317 context =
"default";
4320 ast_get_hint(hint,
sizeof(hint) - 1, NULL, 0, NULL, context, exten);
4326 "Status: %d\r\n\r\n",
4327 exten, context, hint, status);
4336 struct timeval when = { timeout, 0 };
4343 if (!timeout || timeout < 0) {
4353 when.tv_usec = (timeout - when.tv_sec) * 1000000.0;
4367 regex_t *regex_filter = obj;
4368 const char *eventdata = arg;
4371 if (!regexec(regex_filter, eventdata, 0, NULL, 0)) {
4381 regex_t *regex_filter = obj;
4382 const char *eventdata = arg;
4385 if (!regexec(regex_filter, eventdata, 0, NULL, 0)) {
4398 ast_debug(3,
"Examining event:\n%s\n", eventdata);
4456 for (x = 0; x < m->
hdrcount; x++) {
4457 if (strncasecmp(
"UserEvent:", m->
headers[x], strlen(
"UserEvent:"))) {
4474 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
4481 "AMIversion: %s\r\n"
4482 "AsteriskVersion: %s\r\n"
4483 "SystemName: %s\r\n"
4484 "CoreMaxCalls: %d\r\n"
4485 "CoreMaxLoadAvg: %f\r\n"
4486 "CoreRunUser: %s\r\n"
4487 "CoreRunGroup: %s\r\n"
4488 "CoreMaxFilehandles: %d\r\n"
4489 "CoreRealTimeEnabled: %s\r\n"
4490 "CoreCDRenabled: %s\r\n"
4491 "CoreHTTPenabled: %s\r\n"
4514 char startuptime[150], startupdate[150];
4515 char reloadtime[150], reloaddate[150];
4519 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
4525 ast_strftime(startuptime,
sizeof(startuptime),
"%H:%M:%S", &tm);
4526 ast_strftime(startupdate,
sizeof(startupdate),
"%Y-%m-%d", &tm);
4528 ast_strftime(reloadtime,
sizeof(reloadtime),
"%H:%M:%S", &tm);
4529 ast_strftime(reloaddate,
sizeof(reloaddate),
"%Y-%m-%d", &tm);
4533 "CoreStartupDate: %s\r\n"
4534 "CoreStartupTime: %s\r\n"
4535 "CoreReloadDate: %s\r\n"
4536 "CoreReloadTime: %s\r\n"
4537 "CoreCurrentCalls: %d\r\n"
4583 int duration, durh, durm, durs;
4587 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
4601 char durbuf[10] =
"";
4608 durh = duration / 3600;
4609 durm = (duration % 3600) / 60;
4610 durs = duration % 60;
4611 snprintf(durbuf,
sizeof(durbuf),
"%02d:%02d:%02d", durh, durm, durs);
4615 "Event: CoreShowChannel\r\n"
4622 "ChannelState: %u\r\n"
4623 "ChannelStateDesc: %s\r\n"
4624 "Application: %s\r\n"
4625 "ApplicationData: %s\r\n"
4626 "CallerIDnum: %s\r\n"
4627 "CallerIDname: %s\r\n"
4628 "ConnectedLineNum: %s\r\n"
4629 "ConnectedLineName: %s\r\n"
4631 "AccountCode: %s\r\n"
4632 "BridgedChannel: %s\r\n"
4633 "BridgedUniqueID: %s\r\n"
4648 "Event: CoreShowChannelsComplete\r\n"
4649 "EventList: Complete\r\n"
4652 "\r\n", numchans, idText);
4666 #if !defined(LOW_MEMORY)
4669 char filename[PATH_MAX];
4673 if ((cut = strchr(filename,
'.'))) {
4676 cut = filename + strlen(filename);
4678 snprintf(cut, (
sizeof(filename) - strlen(filename)) - 1,
".so");
4685 snprintf(cut, (
sizeof(filename) - strlen(filename)) - 1,
".c");
4687 #if !defined(LOW_MEMORY)
4692 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n",
id);
4697 #if !defined(LOW_MEMORY)
4698 astman_append(s,
"Version: %s\r\n\r\n", version ? version :
"");
4709 if (!loadtype || strlen(loadtype) == 0) {
4712 if ((!module || strlen(module) == 0) && strcasecmp(loadtype,
"reload") != 0) {
4716 if (!strcasecmp(loadtype,
"load")) {
4723 }
else if (!strcasecmp(loadtype,
"unload")) {
4730 }
else if (!strcasecmp(loadtype,
"reload")) {
4735 }
else if (res == 1) {
4779 && strcasecmp(action,
"Login")
4780 && strcasecmp(action,
"Logoff")
4781 && strcasecmp(action,
"Challenge")) {
4791 if (!allowmultiplelogin
4793 && (!strcasecmp(action,
"Login")
4794 || !strcasecmp(action,
"Challenge"))) {
4820 ret = act_found->
func(s, m);
4838 ao2_t_ref(act_found, -1,
"done with found action object");
4843 snprintf(buf,
sizeof(buf),
"Invalid/unknown command: %s. Use Action: ListCommands to show available commands.", action);
4884 if (src[x] ==
'\r' && x+1 < s->
session->
inlen && src[x + 1] ==
'\n') {
4886 }
else if (src[x] ==
'\n') {
4891 memmove(output, src, x);
4908 if(time(&now) == -1) {
5005 if (time(&now) == -1) {
5012 if (displayconnects) {
5020 }
else if (res > 0) {
5059 for (idx = 0; idx < m.
hdrcount; ++idx) {
5082 struct sockaddr_in ser_remote_address_tmp;
5094 if (session == NULL) {
5103 p = getprotobyname(
"tcp");
5106 if( setsockopt(ser->
fd, p->p_proto, TCP_NODELAY, (
char *)&arg,
sizeof(arg) ) < 0 ) {
5107 ast_log(
LOG_WARNING,
"Failed to set manager tcp connection to TCP_NODELAY mode: %s\nSome manager actions may be slow to respond.\n", strerror(
errno));
5110 ast_log(
LOG_WARNING,
"Failed to set manager tcp connection to TCP_NODELAY, getprotobyname(\"tcp\") failed\nSome manager actions may be slow to respond.\n");
5114 flags = fcntl(ser->
fd, F_GETFL);
5115 flags |= O_NONBLOCK;
5116 fcntl(ser->
fd, F_SETFL, flags);
5125 session->
fd = s.
fd = ser->
fd;
5126 session->
f = s.
f = ser->
f;
5127 session->
sin = ser_remote_address_tmp;
5166 if (displayconnects) {
5184 time_t now = time(NULL);
5196 ast_verb(2,
"HTTP Manager '%s' timed out from %s\n",
5216 struct eventqent *tmp =
ast_malloc(
sizeof(*tmp) + strlen(str));
5229 strcpy(tmp->eventdata, str);
5242 struct manager_channel_variable *
var;
5266 #define MANAGER_EVENT_BUF_INITSIZE 256
5269 ast_channel **chans,
const char *file,
int line,
const char *func,
const char *fmt, ...)
5274 const char *cat_str;
5290 "Event: %s\r\nPrivilege: %s\r\n",
5293 if (timestampevents) {
5296 "Timestamp: %ld.%06lu\r\n",
5297 (
long)now.tv_sec, (
unsigned long) now.tv_usec);
5299 if (manager_debug) {
5302 "SequenceNumber: %d\r\n",
5305 "File: %s\r\nLine: %d\r\nFunc: %s\r\n", file, line, func);
5361 if (!strcasecmp(action, cur->
action)) {
5387 if (5 <= time(NULL) - now) {
5389 "Unregister manager action %s timed out waiting for %u active instances to complete\n",
5397 ao2_t_ref(cur, -1,
"action object removed from list");
5398 ast_verb(2,
"Manager unregistered action %s\n", action);
5408 ast_get_hint(hint,
sizeof(hint), NULL, 0, NULL, context, exten);
5410 manager_event(
EVENT_FLAG_CALL,
"ExtensionStatus",
"Exten: %s\r\nContext: %s\r\nHint: %s\r\nStatus: %d\r\n", exten, context, hint, state);
5434 ao2_t_ref(act, +1,
"action object added to list");
5461 if (doomed->synopsis) {
5478 ao2_t_ref(cur, -1,
"action object creation failed");
5520 ao2_t_ref(cur, -1,
"action object registration failed");
5524 ao2_t_ref(cur, -1,
"action object registration successful");
5597 if (nonce == 0 || username == NULL || stale == NULL) {
5607 }
else if (!strcasecmp(session->
username, username) && session->
oldnonce == nonce) {
5696 int space =
sizeof(buf);
5698 for ( ; *src || dst != buf ; src++) {
5699 if (*src ==
'\0' || space < 10) {
5703 space =
sizeof(buf);
5709 if ( (mode & 2) && !isalnum(*src)) {
5716 strcpy(dst,
"<");
5721 strcpy(dst,
">");
5726 strcpy(dst,
""");
5731 strcpy(dst,
"'");
5736 strcpy(dst,
"&");
5742 *dst++ = mode ? tolower(*src) : *
src;
5802 const char *dest = NULL;
5804 const char *objtype = NULL;
5813 for (v = get_vars; v; v = v->
next) {
5814 if (!strcasecmp(v->
name,
"ajaxdest")) {
5816 }
else if (!strcasecmp(v->
name,
"ajaxobjtype")) {
5824 objtype =
"generic";
5830 val =
strsep(&in,
"\r\n");
5831 if (in && *in ==
'\n') {
5835 ast_debug(5,
"inobj %d in_data %d line <%s>\n", inobj, in_data, val);
5847 "<tr><td colspan=\"2\"><hr></td></tr>\r\n");
5858 ast_str_append(out, 0,
"<response type='object' id='%s'><%s", dest, objtype);
5881 var =
"Opaque-data";
5887 if ((vc =
ao2_find(vco, var, 0))) {
5898 if (vc->
count > 1) {
5904 if (!in_data || !*in) {
5911 "<tr><td colspan=\"2\"><hr></td></tr>\r\n");
5924 }
else if (s->
fd != -1) {
5930 shutdown(s->
fd, SHUT_RDWR);
5936 ast_log(
LOG_ERROR,
"Attempted to close file/file descriptor on mansession without a valid file or file descriptor.\n");
5949 fprintf(s->
f,
"%c", 0);
5952 if ((l = ftell(s->
f)) > 0) {
5953 if (MAP_FAILED == (buf = mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, s->
fd, 0))) {
5973 struct sockaddr_in *remote_address,
const char *uri,
5982 char template[] =
"/tmp/ast-http-XXXXXX";
5983 struct ast_str *http_header = NULL, *out = NULL;
5989 ast_http_error(ser, 501,
"Not Implemented",
"Attempt to use unimplemented / unsupported method");
5994 for (v = cookies; v; v = v->
next) {
5995 if (!strcasecmp(v->
name,
"mansession_id")) {
5996 sscanf(v->
value,
"%30x", &ident);
6011 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)\n");
6015 session->
sin = *remote_address;
6036 if (http_header == NULL || out == NULL) {
6037 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (ast_str_create() out of memory)\n");
6038 goto generic_callback_out;
6042 s.
fd = mkstemp(
template);
6045 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (mkstemp failed)\n");
6046 goto generic_callback_out;
6048 s.
f = fdopen(s.
fd,
"w+");
6051 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (fdopen failed)\n");
6053 goto generic_callback_out;
6061 hdrlen = strlen(v->
name) + strlen(v->
value) + 3;
6078 if (displayconnects) {
6086 for (idx = 0; idx < m.
hdrcount; ++idx) {
6092 "Content-type: text/%s\r\n"
6093 "Cache-Control: no-cache;\r\n"
6094 "Set-Cookie: mansession_id=\"%08x\"; Version=1; Max-Age=%d\r\n"
6095 "Pragma: SuppressEvents\r\n",
6096 contenttype[format],
6108 #define ROW_FMT "<tr><td colspan=\"2\" bgcolor=\"#f1f1ff\">%s</td></tr>\r\n"
6109 #define TEST_STRING \
6110 "<form action=\"manager\" method=\"post\">\n\
6111 Action: <select name=\"action\">\n\
6112 <option value=\"\">-----></option>\n\
6113 <option value=\"login\">login</option>\n\
6114 <option value=\"command\">Command</option>\n\
6115 <option value=\"waitevent\">waitevent</option>\n\
6116 <option value=\"listcommands\">listcommands</option>\n\
6118 or <input name=\"action\"><br/>\n\
6119 CLI Command <input name=\"command\"><br>\n\
6120 user <input name=\"username\"> pass <input type=\"password\" name=\"secret\"><br>\n\
6121 <input type=\"submit\">\n</form>\n"
6123 ast_str_append(&out, 0,
"<title>Asterisk™ Manager Interface</title>");
6124 ast_str_append(&out, 0,
"<body bgcolor=\"#ffffff\"><table align=center bgcolor=\"#f1f1f1\" width=\"500\">\r\n");
6142 if (session->
inuse == 1) {
6143 ast_debug(1,
"Need destroy, doing it now!\n");
6146 ast_debug(1,
"Need destroy, but can't do it yet!\n");
6157 ast_http_send(ser, method, 200, NULL, http_header, out, 0, 0);
6158 http_header = out = NULL;
6160 generic_callback_out:
6171 if (session && blastaway) {
6173 }
else if (session && session->
f) {
6184 struct sockaddr_in *remote_address,
const char *uri,
6191 char template[] =
"/tmp/ast-http-XXXXXX";
6192 struct ast_str *http_header = NULL, *out = NULL;
6193 size_t result_size = 512;
6198 time_t time_now = time(NULL);
6199 unsigned long nonce = 0, nc;
6201 struct ast_manager_user *
user = NULL;
6203 char resp_hash[256]=
"";
6205 char u_username[80];
6209 int u_displayconnects;
6213 ast_http_error(ser, 501,
"Not Implemented",
"Attempt to use unimplemented / unsupported method");
6218 for (v = headers; v; v = v->
next) {
6219 if (!strcasecmp(v->
name,
"Authorization")) {
6230 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)\n");
6239 if (sscanf(d.
nonce,
"%30lx", &nonce) != 1) {
6259 ast_http_error(ser, 403,
"Permission denied",
"Permission denied\n");
6277 snprintf(resp,
sizeof(resp),
"%s:%08lx:%s:%s:auth:%s", user->
a1_hash, nonce, d.
nc, d.
cnonce, a2_hash);
6280 snprintf(resp,
sizeof(resp),
"%s:%08lx:%s", user->
a1_hash, nonce, a2_hash);
6285 if (strncasecmp(d.
response, resp_hash, strlen(resp_hash))) {
6309 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)\n");
6323 if (u_displayconnects) {
6346 sscanf(d.
nc,
"%30lx", &nc);
6347 if (session->
nc >= nc || ((time_now - session->
noncetime) > 62) ) {
6369 session->
sessiontimeout = time(NULL) + (httptimeout > 5 ? httptimeout : 5);
6374 s.
fd = mkstemp(
template);
6377 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (mkstemp failed)\n");
6378 goto auth_callback_out;
6380 s.
f = fdopen(s.
fd,
"w+");
6383 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (fdopen failed)\n");
6385 goto auth_callback_out;
6393 hdrlen = strlen(v->
name) + strlen(v->
value) + 3;
6405 if (u_displayconnects) {
6413 for (idx = 0; idx < m.
hdrcount; ++idx) {
6419 result_size = ftell(s.
f);
6425 if (http_header == NULL || out == NULL) {
6426 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (ast_str_create() out of memory)\n");
6427 goto auth_callback_out;
6430 ast_str_append(&http_header, 0,
"Content-type: text/%s\r\n", contenttype[format]);
6436 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
6438 "<title>Asterisk™ Manager Interface</title>\r\n"
6439 "</head><body style=\"background-color: #ffffff;\">\r\n"
6440 "<form method=\"POST\">\r\n"
6441 "<table align=\"center\" style=\"background-color: #f1f1f1;\" width=\"500\">\r\n"
6442 "<tr><th colspan=\"2\" style=\"background-color: #f1f1ff;\"><h1>Manager Tester</h1></th></tr>\r\n"
6443 "<tr><th colspan=\"2\" style=\"background-color: #f1f1ff;\">Action: <input name=\"action\" /> Cmd: <input name=\"command\" /><br>"
6444 "<input type=\"submit\" value=\"Send request\" /></th></tr>\r\n");
6455 ast_http_send(ser, method, 200, NULL, http_header, out, 0, 0);
6456 http_header = out = NULL;
6478 ast_debug(1,
"Need destroy, doing it now!\n");
6497 struct sockaddr_in ser_remote_address_tmp;
6508 struct sockaddr_in ser_remote_address_tmp;
6519 struct sockaddr_in ser_remote_address_tmp;
6528 .
description =
"Raw HTTP Manager Event Interface",
6556 struct sockaddr_in ser_remote_address_tmp;
6567 struct sockaddr_in ser_remote_address_tmp;
6578 struct sockaddr_in ser_remote_address_tmp;
6587 .
description =
"Raw HTTP Manager Event Interface w/Digest authentication",
6596 .
description =
"HTML Manager Event Interface w/Digest authentication",
6605 .
description =
"XML Manager Event Interface w/Digest authentication",
6629 .poll_timeout = 5000,
6631 .name =
"AMI server",
6641 .name =
"AMI TLS server",
6651 e->
command =
"manager show settings";
6653 "Usage: manager show settings\n"
6654 " Provides detailed list of the configuration of the Manager.\n";
6659 #define FORMAT " %-25.25s %-15.15s\n"
6660 #define FORMAT2 " %-25.25s %-15d\n"
6708 struct manager_channel_variable *mcv;
6722 while ((next =
strsep(&remaining,
",|"))) {
6723 if (!(mcv =
ast_calloc(1,
sizeof(*mcv) + strlen(next) + 1))) {
6726 strcpy(mcv->
name, next);
6727 if (strchr(next,
'(')) {
6753 struct ast_manager_user *
user;
6846 struct ast_manager_user *
user = NULL;
6851 struct sockaddr_in ami_desc_local_address_tmp = { 0, };
6852 struct sockaddr_in amis_desc_local_address_tmp = { 0, };
6853 int tls_was_enabled = 0;
6915 ast_log(
LOG_NOTICE,
"Unable to open AMI configuration manager.conf, or configuration is invalid.\n");
6925 ami_desc_local_address_tmp.sin_family = AF_INET;
6926 amis_desc_local_address_tmp.sin_family = AF_INET;
6934 if (strcasecmp(var->
name,
"tlscafile")
6935 && strcasecmp(var->
name,
"tlscapath")
6936 && strcasecmp(var->
name,
"tlscadir")
6937 && strcasecmp(var->
name,
"tlsverifyclient")
6938 && strcasecmp(var->
name,
"tlsdontverifyserver")
6939 && strcasecmp(var->
name,
"tlsclientmethod")
6940 && strcasecmp(var->
name,
"sslclientmethod")
6945 if (!strcasecmp(var->
name,
"enabled")) {
6947 }
else if (!strcasecmp(var->
name,
"webenabled")) {
6948 webmanager_enabled =
ast_true(val);
6949 }
else if (!strcasecmp(var->
name,
"port")) {
6950 ami_desc_local_address_tmp.sin_port = htons(atoi(val));
6951 }
else if (!strcasecmp(var->
name,
"bindaddr")) {
6952 if (!
inet_aton(val, &ami_desc_local_address_tmp.sin_addr)) {
6954 memset(&ami_desc_local_address_tmp.sin_addr, 0,
6955 sizeof(ami_desc_local_address_tmp.sin_addr));
6957 }
else if (!strcasecmp(var->
name,
"brokeneventsaction")) {
6958 broken_events_action =
ast_true(val);
6959 }
else if (!strcasecmp(var->
name,
"allowmultiplelogin")) {
6960 allowmultiplelogin =
ast_true(val);
6961 }
else if (!strcasecmp(var->
name,
"displayconnects")) {
6963 }
else if (!strcasecmp(var->
name,
"timestampevents")) {
6965 }
else if (!strcasecmp(var->
name,
"debug")) {
6967 }
else if (!strcasecmp(var->
name,
"httptimeout")) {
6968 newhttptimeout = atoi(val);
6969 }
else if (!strcasecmp(var->
name,
"authtimeout")) {
6970 int timeout = atoi(var->
value);
6975 authtimeout = timeout;
6977 }
else if (!strcasecmp(var->
name,
"authlimit")) {
6978 int limit = atoi(var->
value);
6985 }
else if (!strcasecmp(var->
name,
"channelvars")) {
6996 if (!amis_desc_local_address_tmp.sin_addr.s_addr) {
6997 amis_desc_local_address_tmp.sin_addr =
6998 ami_desc_local_address_tmp.sin_addr;
7001 if (!amis_desc_local_address_tmp.sin_port) {
7005 if (manager_enabled) {
7015 const char *hasmanager;
7019 if (!strcasecmp(cat,
"general")) {
7024 if ((!hasmanager && genhasmanager) ||
ast_true(hasmanager)) {
7035 if (!(user =
ast_calloc(1,
sizeof(*user)))) {
7061 if (!user_displayconnects) {
7064 if (!user_writetimeout) {
7079 if (user_displayconnects) {
7082 if (user_writetimeout) {
7083 int value = atoi(user_writetimeout);
7100 if (!strcasecmp(cat,
"general")) {
7106 if (!(user =
ast_calloc(1,
sizeof(*user)))) {
7138 for (;
var; var = var->
next) {
7139 if (!strcasecmp(var->
name,
"secret")) {
7142 }
else if (!strcasecmp(var->
name,
"deny") ||
7143 !strcasecmp(var->
name,
"permit")) {
7145 }
else if (!strcasecmp(var->
name,
"read") ) {
7147 }
else if (!strcasecmp(var->
name,
"write") ) {
7149 }
else if (!strcasecmp(var->
name,
"displayconnects") ) {
7151 }
else if (!strcasecmp(var->
name,
"writetimeout")) {
7158 }
else if (!strcasecmp(var->
name,
"eventfilter")) {
7163 if (value[0] ==
'!') {
7169 if (regcomp(new_filter, value, 0)) {
7170 ao2_t_ref(new_filter, -1,
"failed to make regex");
7172 if (is_blackfilter) {
7208 if (webmanager_enabled && manager_enabled) {
7232 if (newhttptimeout > 0) {
7233 httptimeout = newhttptimeout;
7237 "Module: Manager\r\n"
7239 "Message: Manager reload Requested\r\n",
7240 manager_enabled ?
"Enabled" :
"Disabled");
7255 struct manager_channel_variable *
var;
7293 if (datastore->
info != info) {
7302 if ((datastore->
uid != NULL) && !strcasecmp(uid, datastore->
uid)) {
#define ao2_t_ref(o, delta, tag)
Reference/unreference an object and return the old refcount.
helper function for originate
const ast_string_field cnonce
static int action_challenge(struct mansession *s, const struct message *m)
char exten[FEATURE_MAX_LEN]
static int get_input(struct mansession *s, char *output)
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
static char * handle_showmancmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct ao2_container * blackfilters
struct ast_datastore * astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a session.
static int action_command(struct mansession *s, const struct message *m)
Manager command "command" - execute CLI command.
int ast_variable_delete(struct ast_category *category, const char *variable, const char *match, const char *line)
int ast_get_hint(char *hint, int hintsize, char *name, int namesize, struct ast_channel *c, const char *context, const char *exten)
If an extension hint exists, return non-zero.
int ast_security_event_report(const struct ast_security_event_common *sec)
Report a security event.
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)
enum ast_security_event_type event_type
The security event sub-type.
struct ast_party_connected_line connected
Channel Connected Line ID information.
static void astman_append_json(struct mansession *s, const char *str)
static int action_mailboxstatus(struct mansession *s, const struct message *m)
Security Event Reporting API.
static const int DEFAULT_DISPLAYCONNECTS
int ast_category_delete(struct ast_config *cfg, const char *category)
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.
#define ao2_link(arg1, arg2)
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
const char * ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable)
Gets a variable.
static void mansession_unlock(struct mansession *s)
Unlock the 'mansession' structure.
int ast_realtime_enabled(void)
Check if there's any realtime engines loaded.
struct ast_party_caller caller
Channel Caller ID information.
char * strsep(char **str, const char *delims)
FYI FWIW, Successful authentication has occurred.
const ast_string_field tech
const ast_string_field account
enum ast_module_load_result ast_load_resource(const char *resource_name)
Load a module.
#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.
const ast_string_field uniqueid
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 ...
int astman_verify_session_readpermissions(uint32_t ident, int perm)
Verify a session's read permissions against a permission mask.
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...
#define ao2_t_alloc(data_size, destructor_fn, debug_msg)
Allocate and initialize an object.
int ast_ssl_setup(struct ast_tls_config *cfg)
Set up an SSL server.
#define ast_pthread_create_detached(a, b, c, d)
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.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Asterisk version information.
struct ast_party_id id
Connected party ID.
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)
static int action_userevent(struct mansession *s, const struct message *m)
int ast_careful_fwrite(FILE *f, int fd, const char *s, size_t len, int timeoutms)
Write data to a file stream with a timeout.
#define ast_channel_unref(c)
Decrease channel reference count.
int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg)
Registered hooks can call this function to invoke actions and they will receive responses through reg...
static void report_invalid_user(const struct mansession *s, const char *username)
#define ast_test_flag(p, flag)
void ast_manager_register_hook(struct manager_custom_hook *hook)
Add a custom hook to be called when an event is fired.
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.
#define GET_HEADER_LAST_MATCH
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.
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 ast_func_read2(struct ast_channel *chan, const char *function, struct ast_str **str, ssize_t maxlen)
executes a read operation on a function
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
char context[AST_MAX_CONTEXT]
int ast_apply_ha(const struct ast_ha *ha, const struct ast_sockaddr *addr)
Apply a set of rules to a given IP address.
int reload_manager(void)
Called by Asterisk module functions and the CLI command.
#define ao2_iterator_next(arg1)
int ast_app_has_voicemail(const char *mailbox, 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.
static int __init_manager(int reload)
#define ast_set_flag(p, flag)
int ast_check_hangup_locked(struct ast_channel *chan)
descriptor for a cli entry.
static struct ast_manager_user * get_manager_by_name_locked(const char *name)
static struct permalias perms[]
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
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 EVENT_FLAG_COMMAND
void ast_verbose(const char *fmt,...)
static int action_login(struct mansession *s, const struct message *m)
static int authenticate(struct mansession *s, const struct message *m)
#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).
struct eventqent * last_ev
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
int ast_category_insert(struct ast_config *config, struct ast_category *cat, const char *match)
Inserts new category.
struct ast_datastore_info * info
static int get_perm(const char *instr)
Structure for variables, used for configurations and for channel variables.
static int ast_manager_register_struct(struct manager_action *act)
ast_security_event_transport_type
Transport types.
void MD5Final(unsigned char digest[16], struct MD5Context *context)
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.
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_include_rename(struct ast_config *conf, const char *from_file, const char *to_file)
void * ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded)
free an ast_aoc_decoded object
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.
Configuration File Parser.
char * term_strip(char *outbuf, const char *inbuf, int maxout)
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_config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator)
static int manager_moduleload(struct mansession *s, const struct message *m)
static void report_session_limit(const struct mansession *s)
#define ao2_t_callback_data(arg1, arg2, arg3, arg4, arg5, arg6)
ao2_callback_data() is a generic function that applies cb_fn() to all objects in a container...
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)
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
static int action_aocmessage(struct mansession *s, const struct message *m)
static const int DEFAULT_AUTHTIMEOUT
const char * response
Response received.
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.
struct ast_str * ast_str_create(size_t init_len)
Create a malloc'ed dynamic length string.
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.
#define ast_mutex_lock(a)
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
static const int DEFAULT_MANAGERDEBUG
const char * ast_config_AST_RUN_USER
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags)
Create an iterator for a container.
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...
#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.
struct ast_security_event_common common
Common security event descriptor elements.
Structure for a data store object.
A request was made that is not allowed.
ast_aoc_currency_multiplier
Defines the currency multiplier for an aoc message.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
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[]
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
#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
int check_manager_enabled(void)
Check if AMI is enabled.
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
Definitions to aid in the use of thread local storage.
static int action_sendtext(struct mansession *s, const struct message *m)
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 *contents,...)
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
#define AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION
Event descriptor version.
struct ao2_container * blackfilters
list of users found in the config file
static int append_event(const char *str, int category)
static int action_atxfer(struct mansession *s, const struct message *m)
#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)
#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]
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
static int aocmessage_get_unit_entry(const struct message *m, struct ast_aoc_unit_entry *entry, unsigned int entry_num)
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...
void ast_config_destroy(struct ast_config *config)
Destroys a config.
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. This can be used to handle reference co...
static void manager_free_user(struct ast_manager_user *user)
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.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
static const int DEFAULT_BROKENEVENTSACTION
static int process_message(struct mansession *s, const struct message *m)
int ast_module_check(const char *name)
Check if module with the name given is loaded.
static struct ast_http_uri arawmanuri
String fields in structures.
static void ast_sockaddr_setnull(struct ast_sockaddr *addr)
Sets address addr to null.
#define ao2_t_link(arg1, arg2, arg3)
Add an object to a container.
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)
Get header from mananger transaction.
static struct mansession_session * find_session(uint32_t ident, int incinuse)
struct ast_category * ast_category_new(const char *name, const char *in_file, int lineno)
Create a category structure.
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)
#define CONFIG_STATUS_FILEMISSING
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 void append_channel_vars(struct ast_str **pbuf, struct ast_channel *chan)
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, const int fd, unsigned int static_content)
Generic function for sending http/1.1 response.
static struct ast_threadstorage manager_event_buf
internal representation of acl entries In principle user applications would have no need for this...
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.
struct ast_party_id id
Caller party ID.
static int action_getconfig(struct mansession *s, const struct message *m)
struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name)
Retrieve a category if it exists.
Support for Private Asterisk HTTP Servers.
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
static void destroy_fast_originate_helper(struct fast_originate_helper *doomed)
static int check_manager_session_inuse(const char *name)
#define AST_RWLIST_INSERT_HEAD
#define EVENT_FLAG_SYSTEM
static const int DEFAULT_ENABLED
const ast_string_field uri
#define ast_debug(level,...)
Log a DEBUG message.
struct ao2_container * whitefilters
struct ast_variable * ast_variables_reverse(struct ast_variable *var)
Reverse a variable list.
int astman_is_authed(uint32_t ident)
Determinie if a manager session ident is authenticated.
static int manager_modulecheck(struct mansession *s, const struct message *m)
void ast_category_destroy(struct ast_category *cat)
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 *)
General Asterisk PBX channel definitions.
static const int DEFAULT_TIMESTAMPEVENTS
Asterisk file paths, configured in asterisk.conf.
#define ast_sockaddr_from_sin(addr, sin)
Converts a struct sockaddr_in to a struct ast_sockaddr.
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 ...
const ast_string_field response
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define ast_manager_register_xml(a, b, c)
Register a manager callback using XML documentation to describe the manager.
#define AST_PTHREADT_NULL
static force_inline int attribute_pure ast_strlen_zero(const char *s)
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
Access Control of various sorts.
Request received with bad formatting.
#define ASTMAN_APPEND_BUF_INITSIZE
initial allocated size for the astman_append_buf
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)
static int action_coreshowchannels(struct mansession *s, const struct message *m)
Manager command "CoreShowChannels" - List currently defined channels and some information about them...
char * ast_category_browse(struct ast_config *config, const char *prev)
Goes through categories.
#define ao2_ref(o, delta)
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
long int ast_random(void)
#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 ast_lastreloadtime
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)
const ast_string_field cid_num
static struct mansession_session * find_session_by_nonce(const char *username, unsigned long nonce, int *stale)
int ast_manager_register2(const char *action, int authority, int(*func)(struct mansession *s, const struct message *m), const char *synopsis, const char *description)
Register a manager command with the manager interface.
const ast_string_field exten
static struct ast_http_uri managerxmluri
static struct ast_http_uri manageruri
A set of macros to manage forward-linked lists.
unsigned int active_count
ast_cli_command
calling arguments for new-style handlers.
struct ast_security_event_common common
Common security event descriptor elements.
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 ast_channel * _bridge
static struct ast_tls_config ami_tls_cfg
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
struct ast_variable * vars
static struct eventqent * advance_event(struct eventqent *e)
#define MSG_MOREDATA
send a response with an optional message, and terminate it with an empty line. m is used only to grab...
static int timestampevents
void ast_tcptls_stream_set_exclusive_input(struct ast_tcptls_stream *stream, int exclusive_input)
Set the TCP/TLS stream I/O if it can exclusively depend upon the set timeouts.
static struct ast_tcptls_session_args amis_desc
struct ast_tcptls_stream * stream_cookie
static void manager_shutdown(void)
Core PBX routines and definitions.
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
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_app_inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Determine number of urgent/new/old messages in a mailbox.
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
static int action_listcommands(struct mansession *s, const struct message *m)
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 AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define GET_HEADER_FIRST_MATCH
static enum ast_security_event_transport_type mansession_get_transport(const struct mansession *s)
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
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 ...
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
int ast_pbx_outgoing_exten(const char *type, format_t format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
#define EVENT_FLAG_CONFIG
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 ...
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 '...
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.
void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
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 struct ast_threadstorage manager_event_funcbuf
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
enum ast_channel_state _state
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
const ast_string_field appdata
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)
#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.
const ast_string_field name
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_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
#define ao2_alloc(data_size, destructor_fn)
static int action_waitevent(struct mansession *s, const struct message *m)
const ast_string_field nc
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_softhangup_nolock(struct ast_channel *chan, int reason)
Softly hangup up a channel (no channel lock)
static const int DEFAULT_WEBENABLED
struct ast_bridge * bridge
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#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 ao2_find(arg1, arg2, arg3)
#define ast_channel_unlock(chan)
static void event_filter_destructor(void *obj)
static void parse(struct mgcp_request *req)
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
int ast_module_reload(const char *name)
Reload asterisk modules.
int astman_verify_session_writepermissions(uint32_t ident, int perm)
Verify a session's write permissions against a permission mask.
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.
int(* func)(struct mansession *s, const struct message *m)
#define EVENT_FLAG_HOOKRESPONSE
static int broken_events_action
void * ast_aoc_destroy_encoded(struct ast_aoc_encoded *encoded)
free an ast_aoc_encoded object
#define AST_RWLIST_REMOVE_HEAD
int astman_datastore_add(struct mansession *s, struct ast_datastore *datastore)
Add a datastore to a session.
struct ast_security_event_common common
Common security event descriptor elements.
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...
int ast_str_append_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap)
Append to a dynamic string using a va_list.
char * ast_xmldoc_printable(const char *bwinput, int withcolors)
Colorize and put delimiters (instead of tags) to the xmldoc output.
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.
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)
structure to hold users read from users.conf
void ao2_iterator_destroy(struct ao2_iterator *i)
Destroy a container iterator.
static int action_coresettings(struct mansession *s, const struct message *m)
Show PBX core settings information.
int check_webmanager_enabled(void)
Check if AMI/HTTP is enabled.
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
Structure used to handle boolean flags.
static size_t get_params(va_list ap, const char ***params_ptr, const char ***vals_ptr, int warn)
Helper function to parse a va_list object into 2 dynamic arrays of strings, parameters and values...
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.
#define ast_clear_flag(p, flag)
const ast_string_field data
const ast_string_field context
static char cid_name[AST_MAX_EXTENSION]
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...
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_free_ha(struct ast_ha *ha)
Free a list of HAs.
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 void parsing(int size, unsigned char *buf, struct unistimsession *pte, struct sockaddr_in *addr_from)
const ast_string_field nonce
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
int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastore)
Remove a datastore from a session.
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[]
struct ast_flags ast_options
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 AST_FORMAT_SLINEAR
static int variable_count_cmp_fn(void *obj, void *vstr, int flags)
static int do_message(struct mansession *s)
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)
Standard Command Line Interface.
static struct ast_http_uri amanagerxmluri
static int manager_enabled
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.
#define ao2_container_alloc(arg1, arg2, arg3)
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.
static void mansession_lock(struct mansession *s)
Lock the 'mansession' structure.
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
static int auth_http_callback(struct ast_tcptls_session_instance *ser, enum ast_http_method method, enum output_format format, struct sockaddr_in *remote_address, const char *uri, struct ast_variable *get_params, struct ast_variable *headers)
#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)
static void free_channelvars(void)
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
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...
static int whitefilter_cmp_fn(void *obj, void *arg, void *data, int flags)
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.
const ast_string_field accountcode
Data structure associated with a single frame of data.
#define ast_manager_event_multichan(category, event, nchans, chans, contents,...)
int init_manager(void)
Called by Asterisk initialization.
const char * headers[AST_MAX_MANHEADERS]
static void session_destroy(struct mansession_session *s)
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.
struct mansession_session * session
#define AST_RWLIST_REMOVE
void ast_tcptls_stream_set_timeout_sequence(struct ast_tcptls_stream *stream, struct timeval start, int timeout)
Set the TCP/TLS stream I/O sequence timeout timer.
static void handle_parse_error(struct mansession *s, struct message *m, char *error)
struct ast_ha * ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error)
Add a new rule to a list of HAs.
Handy terminal functions for vt* terms.
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
#define ast_sockaddr_to_sin(addr, sin)
Converts a struct ast_sockaddr to a struct sockaddr_in.
int ast_wait_for_input(int fd, int ms)
#define AST_APP_ARG(name)
Define an application argument.
#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.
struct ast_variable * next
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 int manager_state_cb(char *context, char *exten, int state, void *data)
static struct mansession_session * build_mansession(struct sockaddr_in sin)
Allocate manager session structure and add it to the list of sessions.
static int generic_http_callback(struct ast_tcptls_session_instance *ser, enum ast_http_method method, enum output_format format, struct sockaddr_in *remote_address, const char *uri, struct ast_variable *get_params, struct ast_variable *headers)
#define ast_mutex_init(pmutex)
static int allowmultiplelogin
#define AST_CLI_YESNO(x)
return Yes or No depending on the argument. This is used in many places in CLI command, having a function to generate this helps maintaining a consistent output (and possibly emitting the output in other languages, at some point).
int check_cdr_enabled(void)
Return TRUE if CDR subsystem is enabled.
static const int DEFAULT_AUTHLIMIT
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
unsigned char valid
TRUE if the name information is valid/present.
struct ast_sockaddr local_address
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
void ast_category_append(struct ast_config *config, struct ast_category *cat)
#define CONFIG_STATUS_FILEINVALID
static char context[AST_MAX_CONTEXT]
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. ...
ast_http_method
HTTP Request methods known by Asterisk.
#define ast_mutex_destroy(a)
static int webmanager_enabled
int ast_pbx_outgoing_app(const char *type, format_t format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
void ast_variable_insert(struct ast_category *category, struct ast_variable *variable, const char *line)
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)
Registers a state change callback.
const char * ast_file_version_find(const char *file)
Find version for given module name.
struct ast_channel * ast_dummy_channel_alloc(void)
Create a fake channel structure.
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 manager_custom_hook * hook
void ast_category_rename(struct ast_category *cat, const char *name)
void ast_md5_hash(char *output, const char *input)
Produces MD5 hash based on input string.
#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.
void ast_tcptls_stream_set_timeout_disable(struct ast_tcptls_stream *stream)
Disable the TCP/TLS stream timeout timer.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Asterisk module definitions.
char * strcasestr(const char *, const char *)
static int manager_displayconnects(struct mansession_session *session)
Get displayconnects config option.
static void xml_copy_escape(struct ast_str **out, const char *src, int mode)
struct manager_channel_variable * next
static void manager_set_defaults(void)
static snd_pcm_format_t format
union ast_frame::@172 data
static struct @286 command_blacklist[]
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)
static int match(struct sockaddr_in *sin, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
static int mansession_cmp_fn(void *obj, void *arg, int flags)
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
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
#define ao2_unlink(arg1, arg2)
static struct sockaddr_in * mansession_encode_sin_local(const struct mansession *s, struct sockaddr_in *sin_local)
int inet_aton(const char *cp, struct in_addr *pin)
static int action_listcategories(struct mansession *s, const struct message *m)
static const int DEFAULT_HTTPTIMEOUT
#define AST_RWLIST_TRAVERSE_SAFE_END
#define AST_SECURITY_EVENT_SESSION_LIMIT_VERSION
Event descriptor version.
int ast_category_empty(struct ast_config *cfg, const char *category)
Removes and destroys all variables within a category.
static struct ast_http_uri rawmanuri
char exten[AST_MAX_EXTENSION]
Request denied because it's not allowed.
struct ast_call_feature * ast_find_call_feature(const char *name)
look for a call feature entry by its sname
struct ast_variable * ast_variable_new(const char *name, const char *value, const char *filename)
const char * request_type
Request type that was made.
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 void report_req_bad_format(const struct mansession *s, const char *action)
static int variable_count_hash_fn(const void *vvc, const int flags)
static char mailbox[AST_MAX_EXTENSION]
int ast_parse_allow_disallow(struct ast_codec_pref *pref, format_t *mask, const char *list, int allowing)
Parse an "allow" or "deny" line in a channel or device configuration and update the capabilities mask...
static void purge_sessions(int n_max)
remove at most n_max stale session from the list.
int ast_manager_unregister(char *action)
Unregister a registered manager command.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
struct ast_variable * ast_http_get_cookies(struct ast_variable *headers)
Get cookie from Request headers.
#define AST_SECURITY_EVENT_REQ_NOT_ALLOWED_VERSION
Event descriptor version.
#define CONFIG_STATUS_FILEUNCHANGED
#define ast_mutex_unlock(a)
static char * manager_channelvars
static int action_setvar(struct mansession *s, const struct message *m)
int ast_sendtext(struct ast_channel *chan, const char *text)
Sends text to a channel.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
struct ast_sockaddr remote_address
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 list transaction.
struct ast_party_number number
Subscriber phone number.