178#define DEFAULT_REALM "asterisk"
206#define MGR_SHOW_TERMINAL_WIDTH 80
211#define EVENT_FLAG_SHUTDOWN -1
223#define MAX_BLACKLIST_CMD_LEN 2
227 {{
"module",
"load",
NULL }},
228 {{
"module",
"unload",
NULL }},
229 {{
"restart",
"gracefully",
NULL }},
417 const char *filter_pattern,
struct ao2_container *includefilters,
444 ao2_t_ref(act, +1,
"found action object");
489 size_t index,
struct ast_str **res,
499 const char *parent_key,
struct ast_str **res,
504 ast_str_set(&key_str, 0,
"%s/%s", parent_key, key);
527 if (exclusion_cb && key && exclusion_cb(key)) {
541 key, j, res, exclusion_cb);
550 key, res, exclusion_cb);
565#define manager_event_sessions(sessions, category, event, contents , ...) \
566 __manager_event_sessions(sessions, category, event, 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__)
568#define any_manager_listeners(sessions) \
569 ((sessions && ao2_container_count(sessions)) || !AST_RWLIST_EMPTY(&manager_hooks))
650 "class_type", class_type,
777#define MAX_AUTH_PERM_STRING 150
784 strstr(evaluating,
"SHELL") ||
785 strstr(evaluating,
"EVAL")
826 if (authority &
perms[i].num) {
846static int ast_instring(
const char *bigstr,
const char *smallstr,
const char delim)
848 const char *
val = bigstr, *next;
851 if ((next = strchr(
val, delim))) {
852 if (!strncmp(
val, smallstr, (next -
val))) {
858 return !strcmp(smallstr,
val);
860 }
while (*(
val = (next + 1)));
894 for (p =
string; *p; p++) {
895 if (*p < '0' || *p >
'9') {
921 ast_debug(1,
"Mansession: %p refcount now %d\n", s, refcount - 1);
929 if (
entry->regex_filter) {
930 regfree(
entry->regex_filter);
958 ao2_t_ref(
session->includefilters, -1,
"decrement ref for include container, should be last one");
962 ao2_t_ref(
session->excludefilters, -1,
"decrement ref for exclude container, should be last one");
1050 if (!strcasecmp(
user->username,
name)) {
1069 ret =
user->displayconnects;
1086 const char *auth_str;
1088 char syntax_title[64], description_title[64], synopsis_title[64], seealso_title[64];
1089 char arguments_title[64], privilege_title[64], final_response_title[64], list_responses_title[64];
1094 e->
command =
"manager show command";
1096 "Usage: manager show command <actionname> [<actionname> [<actionname> [...]]]\n"
1097 " Shows the detailed description for a specific Asterisk manager interface command.\n";
1100 l = strlen(
a->word);
1103 if (!strncasecmp(
a->word, cur->
action, l)) {
1132 for (num = 3; num <
a->argc; num++) {
1133 if (!strcasecmp(cur->
action,
a->argv[num])) {
1146 if (!syntax || !
synopsis || !description || !arguments
1147 || !seealso || !privilege || !responses) {
1155 ast_cli(
a->fd,
"Allocation failure.\n");
1161 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",
1162 syntax_title, syntax,
1164 description_title, description,
1165 arguments_title, arguments,
1166 seealso_title, seealso,
1167 privilege_title, privilege,
1168 list_responses_title);
1171 ast_cli(
a->fd,
"%s\n\n", responses);
1180 ast_cli(
a->fd,
"%s", final_response_title);
1183 ast_cli(
a->fd,
"%s\n\n", responses);
1199 ast_cli(
a->fd,
"Action: %s\nSynopsis: %s\nPrivilege: %s\n%s\n",
1216 e->
command =
"manager set debug [on|off]";
1217 e->
usage =
"Usage: manager set debug [on|off]\n Show, enable, disable debugging of the manager code.\n";
1225 }
else if (
a->argc == 4) {
1226 if (!strcasecmp(
a->argv[3],
"on")) {
1228 }
else if (!strcasecmp(
a->argv[3],
"off")) {
1247 e->
command =
"manager show user";
1249 " Usage: manager show user <user>\n"
1250 " Display all information related to the manager user specified.\n";
1253 l = strlen(
a->word);
1259 if (!strncasecmp(
a->word,
user->username, l)) {
1276 ast_cli(
a->fd,
"There is no manager called %s\n",
a->argv[3]);
1288 " displayconnects: %s\n"
1289 "allowmultiplelogin: %s\n",
1291 (
user->secret ?
"<Set>" :
"(N/A)"),
1295 (
user->displayconnects ?
"yes" :
"no"),
1296 (
user->allowmultiplelogin ?
"yes" :
"no"));
1298 for (v =
user->chanvars ; v ; v = v->
next) {
1316 e->
command =
"manager show users";
1318 "Usage: manager show users\n"
1319 " Prints a listing of all managers that are currently configured on that\n"
1333 ast_cli(
a->fd,
"There are no manager users.\n");
1338 ast_cli(
a->fd,
"\nusername\n--------\n");
1347 ast_cli(
a->fd,
"-------------------\n"
1348 "%d manager users configured.\n", count_amu);
1357 int space_remaining;
1358#define HSMC_FORMAT " %-*.*s %-.*s\n"
1361 e->
command =
"manager show commands";
1363 "Usage: manager show commands\n"
1364 " Prints a listing of all the available Asterisk manager interface commands.\n";
1372 int incoming_len = strlen(cur->
action);
1373 if (incoming_len > name_len) {
1374 name_len = incoming_len;
1379 if (space_remaining < 0) {
1380 space_remaining = 0;
1405 e->
command =
"manager kick session";
1407 "Usage: manager kick session <file descriptor>\n"
1408 " Kick an active Asterisk Manager Interface session\n";
1418 fd = atoi(
a->argv[3]);
1420 ast_cli(
a->fd,
"Invalid AMI file descriptor: %s\n",
a->argv[3]);
1433 ast_cli(
a->fd,
"Manager session using file descriptor %d has already been kicked\n", fd);
1440 ast_cli(
a->fd,
"Kicking manager session connected using file descriptor %d\n", fd);
1444 pthread_kill(
session->waiting_thread, SIGURG);
1459 ast_cli(
a->fd,
"No manager session found using file descriptor %d\n", fd);
1469 time_t now = time(
NULL);
1470#define HSMCONN_FORMAT1 " %-15.15s %-55.55s %-10.10s %-10.10s %-8.8s %-8.8s %-10.10s %-10.10s\n"
1471#define HSMCONN_FORMAT2 " %-15.15s %-55.55s %-10d %-10d %-8d %-8d %-10.10d %-10.10d\n"
1477 e->
command =
"manager show connected";
1479 "Usage: manager show connected\n"
1480 " Prints a listing of the users that are currently connected to the\n"
1481 "Asterisk manager interface.\n";
1487 ast_cli(
a->fd,
HSMCONN_FORMAT1,
"Username",
"IP Address",
"Start",
"Elapsed",
"FileDes",
"HttpCnt",
"ReadPerms",
"WritePerms");
1497 (
int) (
session->sessionstart),
1498 (
int) (now -
session->sessionstart),
1509 ast_cli(
a->fd,
"%d users connected.\n", count);
1521 e->
command =
"manager show eventq";
1523 "Usage: manager show eventq\n"
1524 " Prints a listing of all events pending in the Asterisk manger\n"
1534 ast_cli(
a->fd,
"Event:\n%s", s->eventdata);
1548 e->
command =
"manager reload";
1550 "Usage: manager reload\n"
1551 " Reloads the manager configuration.\n";
1576#define GET_HEADER_FIRST_MATCH 0
1577#define GET_HEADER_LAST_MATCH 1
1578#define GET_HEADER_SKIP_EMPTY 2
1595 int x, l = strlen(
var);
1602 for (x = 0; x < m->
hdrcount; x++) {
1603 const char *h = m->
headers[x];
1604 if (!strncasecmp(
var, h, l) && h[l] ==
':') {
1605 const char *
value = h + l + 1;
1688 for (y = 0; y <
args.argc; y++) {
1693 if (!
args.vars[y]) {
1728 static const char var_hdr[] =
"Variable:";
1731 varlen = strlen(var_hdr);
1732 for (x = 0; x < m->
hdrcount; x++) {
1733 if (strncasecmp(var_hdr, m->
headers[x], varlen)) {
1770 curlen = strlen(src);
1771 for (x = 0; x < curlen; x++) {
1773 if (src[x] ==
'\r' && x+1 < curlen && src[x+1] ==
'\n')
1775 else if (src[x] ==
'\n')
1794 if (!strcasecmp(action,
"login")) {
1817 if (!act_found->
module || mod_ref) {
1818 ret = act_found->
func(&s, &m);
1824 ao2_t_ref(act_found, -1,
"done with found action object");
1852 len = strlen(
string);
1876#define ASTMAN_APPEND_BUF_INITSIZE 256
1883 ast_verbose(
"No connection stream in astman_append, should not happen\n");
1910 ast_verbose(
"No connection stream in astman_append, should not happen\n");
1924#define MSG_MOREDATA ((char *)astman_send_response)
2031 "EventList: Complete\r\n"
2032 "ListItems: %d\r\n",
2097 char session_id[32];
2101 .common.service =
"AMI",
2102 .common.account_id = username,
2104 .common.local_addr = {
2108 .common.remote_addr = {
2112 .common.session_id = session_id,
2115 snprintf(session_id,
sizeof(session_id),
"%p", s);
2122 char session_id[32];
2126 .common.service =
"AMI",
2127 .common.account_id = username,
2129 .common.local_addr = {
2133 .common.remote_addr = {
2137 .common.session_id = session_id,
2140 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2147 char session_id[32];
2151 .common.service =
"AMI",
2152 .common.account_id = username,
2154 .common.local_addr = {
2158 .common.remote_addr = {
2162 .common.session_id = session_id,
2165 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2172 char session_id[32];
2176 .common.service =
"AMI",
2179 .common.local_addr = {
2183 .common.remote_addr = {
2187 .common.session_id = session_id,
2190 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2197 char session_id[32];
2198 char request_type[64];
2202 .common.service =
"AMI",
2205 .common.local_addr = {
2209 .common.remote_addr = {
2213 .common.session_id = session_id,
2218 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2226 char session_id[32];
2231 .common.service =
"AMI",
2234 .common.local_addr = {
2238 .common.remote_addr = {
2242 .common.session_id = session_id,
2247 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2254 const char *response,
const char *expected_response)
2256 char session_id[32];
2260 .common.service =
"AMI",
2263 .common.local_addr = {
2267 .common.remote_addr = {
2271 .common.session_id = session_id,
2278 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2285 char session_id[32];
2289 .common.service =
"AMI",
2292 .common.local_addr = {
2296 .common.remote_addr = {
2300 .common.session_id = session_id,
2303 snprintf(session_id,
sizeof(session_id),
"%p", s->
session);
2321 regex_t *regex_filter;
2342 char md5key[256] =
"";
2344 unsigned char digest[16];
2350 for (x = 0; x < 16; x++)
2351 len += sprintf(md5key +
len,
"%02hhx", digest[x]);
2352 if (!strcmp(md5key, key)) {
2358 ast_debug(1,
"MD5 authentication is not possible. challenge: '%s'\n",
2361 }
else if (
user->secret) {
2362 if (!strcmp(password,
user->secret)) {
2384 if (
user->chanvars) {
2391 ao2_t_ref(regex_filter, -1,
"remove iterator ref");
2398 ao2_t_ref(regex_filter, -1,
"remove iterator ref");
2424 "Timestamp: %ld.%06lu\r\n"
2426 (
long) now.tv_sec, (
unsigned long) now.tv_usec);
2453 char *stripped_filename;
2464 if (stripped_filename[0] ==
'/') {
2465 real_path = realpath(stripped_filename,
NULL);
2470 real_path = realpath(path,
NULL);
2490 const char *category_name;
2507 }
else if (ret == -1) {
2527 astman_append(s,
"Category-%06d: %s\r\n", catcount, category_name);
2584 if (catcount == 0) {
2598 if (*
in ==
'\\' || *
in ==
'\"') {
2629 const char *category_name;
2705 for (x = 0; x < 100000; x++) {
2706 unsigned int object = 0;
2710 int ignoreerror = 0;
2718 snprintf(hdr,
sizeof(hdr),
"Action-%06d", x);
2723 snprintf(hdr,
sizeof(hdr),
"Cat-%06d", x);
2730 snprintf(hdr,
sizeof(hdr),
"Var-%06d", x);
2733 snprintf(hdr,
sizeof(hdr),
"Value-%06d", x);
2741 snprintf(hdr,
sizeof(hdr),
"Match-%06d", x);
2744 snprintf(hdr,
sizeof(hdr),
"Line-%06d", x);
2747 snprintf(hdr,
sizeof(hdr),
"Options-%06d", x);
2754 if (!strcasecmp(
"allowdups", token)) {
2758 if (!strcasecmp(
"template", token)) {
2762 if (!strcasecmp(
"ignoreerror", token)) {
2785 if (!strcasecmp(action,
"newcat")) {
2787 char *tmpl_name =
NULL;
2827 if (category !=
NULL) {
2838 }
else if (!strcasecmp(action,
"renamecat")) {
2854 }
else if (!strcasecmp(action,
"delcat")) {
2861 if (!foundcat && !ignoreerror) {
2865 }
else if (!strcasecmp(action,
"emptycat")) {
2876 }
else if (!strcasecmp(action,
"update")) {
2900 }
else if (!strcasecmp(action,
"delete")) {
2920 if (!foundvar && !ignoreerror) {
2924 }
else if (!strcasecmp(action,
"append")) {
2936 if (
object || (
match && !strcasecmp(
match,
"object"))) {
2947 }
else if (!strcasecmp(action,
"insert")) {
2987 const char *preserve_effective_context_string =
astman_get_header(m,
"PreserveEffectiveContext");
3098 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n",
id);
3104 sscanf(timeouts,
"%30i", &timeout);
3125 time_t now = time(
NULL);
3131 if (timeout < 0 || timeout >
max) {
3143 ast_debug(1,
"Starting waiting for an event!\n");
3145 for (x = 0; x < timeout || timeout < 0; x++) {
3174 ast_debug(1,
"Finished waiting for an event!\n");
3194 "Event: WaitEventComplete\r\n"
3200 ast_debug(1,
"Abandoning event request!\n");
3233 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n",
id);
3245 if (!strcasecmp(
perms[x].label,
"all") && res ==
perms[x].
num) {
3250 "Events: On\r\n\r\n", id_text);
3251 }
else if (res == 0)
3253 "Events: Off\r\n\r\n", id_text);
3259 "Events: On\r\n\r\n", id_text);
3262 "Events: Off\r\n\r\n", id_text);
3301 long lastreloaded = 0;
3307 uptime =
tmp.tv_sec;
3312 lastreloaded =
tmp.tv_sec;
3318 "LastReload: %ld\r\n"
3319 "Status: Fully Booted\r\n\r\n", cat_str, uptime, lastreloaded);
3328 if (!strcasecmp(authtype,
"MD5")) {
3355 int channels_matched = 0;
3363 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n",
id);
3368 if (cause_validator) {
3369 causecode = cause_validator(name_or_regex, cause);
3372 causecode = strtol(cause, &endptr, 10);
3373 if (causecode < 0 || causecode > 127 || *endptr !=
'\0') {
3383 if (name_or_regex[0] !=
'/') {
3391 ast_verb(3,
"%sManager '%s' from %s, hanging up channel: %s\n",
3397 hangup_handler(
c, causecode);
3409 if (!regex_string) {
3416 astman_send_error(s, m,
"Regex format invalid, Channel param should be /regex/");
3422 if (regcomp(®exbuf,
ast_str_buffer(regex_string), REG_EXTENDED | REG_NOSUB)) {
3437 ast_verb(3,
"%sManager '%s' from %s, hanging up channel: %s\n",
3443 hangup_handler(
c, causecode);
3447 "Event: ChannelHungup\r\n"
3508 char workspace[1024];
3528 workspace[0] =
'\0';
3529 if (varname[strlen(varname) - 1] ==
')') {
3533 ast_func_read(
c, (
char *) varname, workspace,
sizeof(workspace));
3535 ast_log(
LOG_ERROR,
"Unable to allocate bogus channel for variable substitution. Function results may be blank.\n");
3537 ast_func_read(
c, (
char *) varname, workspace,
sizeof(workspace));
3549 astman_append(s,
"Variable: %s\r\nValue: %s\r\n\r\n", varname,
S_OR(varval,
""));
3557 long elapsed_seconds;
3575 if (!snapshot_str) {
3579 if (all_variables) {
3584 if (!variable_str) {
3593 for (i = 0; i < varc; i++) {
3594 char valbuf[512], *ret =
NULL;
3596 if (vars[i][strlen(vars[i]) - 1] ==
')') {
3597 if (
ast_func_read(chan, vars[i], valbuf,
sizeof(valbuf)) < 0) {
3605 ast_str_append(&variable_str, 0,
"Variable: %s=%s\r\n", vars[i], ret);
3609 if (all_variables) {
3623 "Privilege: Call\r\n"
3627 "EffectiveConnectedLineNum: %s\r\n"
3628 "EffectiveConnectedLineName: %s\r\n"
3629 "TimeToHangup: %ld\r\n"
3631 "Application: %s\r\n"
3633 "Nativeformats: %s\r\n"
3634 "Readformat: %s\r\n"
3636 "Writeformat: %s\r\n"
3637 "Writetrans: %s\r\n"
3638 "Callgroup: %llu\r\n"
3639 "Pickupgroup: %llu\r\n"
3660 (
long)elapsed_seconds,
3674 int all_variables = 0;
3687 all_variables =
ast_true(all_chan_variables);
3712 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n",
id);
3764 obj_size = payload_size +
sizeof(*obj);
3773 memcpy(obj->
payload, payload, payload_size);
3807 const char *content_type)
3904 if (sscanf(
priority,
"%30d", &pi) != 1) {
3922 if (sscanf(priority2,
"%30d", &pi2) != 1) {
3933 snprintf(
buf,
sizeof(
buf),
"Channel does not exist: %s",
name);
3957 snprintf(
buf,
sizeof(
buf),
"ExtraChannel does not exist: %s", name2);
4134 if (!feature_code) {
4156 char *cmd_copy, *cur_cmd;
4168 cmd_words[i] = cur_cmd;
4193 char *
buf =
NULL, *final_buf =
NULL, *delim, *output;
4194 char template[] =
"/tmp/ast-ami-XXXXXX";
4208 if ((fd = mkstemp(
template)) < 0) {
4217 if ((
len = lseek(fd, 0, SEEK_END)) < 0) {
4218 astman_append(s,
"Message: Failed to determine number of characters: %s\r\n", strerror(
errno));
4219 goto action_command_cleanup;
4226 if (!
buf || !final_buf) {
4228 goto action_command_cleanup;
4231 if (lseek(fd, 0, SEEK_SET) < 0) {
4232 astman_append(s,
"Message: Failed to set position on temporary file: %s\r\n", strerror(
errno));
4233 goto action_command_cleanup;
4236 if (read(fd,
buf,
len) < 0) {
4237 astman_append(s,
"Message: Failed to read from temporary file: %s\r\n", strerror(
errno));
4238 goto action_command_cleanup;
4243 final_buf[
len] =
'\0';
4246 if (
len && final_buf[
len - 1] ==
'\n') {
4247 final_buf[
len - 1] =
'\0';
4253 while ((output =
strsep(&delim,
"\n"))) {
4257action_command_cleanup:
4315 .uniqueid2 =
in->otherchannelid
4320 in->timeout,
in->app,
in->appdata, &reason,
4324 in->vars,
in->account, &chan, &assignedids);
4327 in->timeout,
in->context,
in->exten,
in->priority, &reason,
4331 in->vars,
in->account, &chan,
in->early_media, &assignedids);
4344 "Application: %s\r\n"
4348 "CallerIDNum: %s\r\n"
4349 "CallerIDName: %s\r\n",
4350 in->idtext, res ?
"Failure" :
"Success",
4352 in->app,
in->appdata, reason,
4354 S_OR(
in->cid_num,
"<unknown>"),
4355 S_OR(
in->cid_name,
"<unknown>")
4366 "CallerIDNum: %s\r\n"
4367 "CallerIDName: %s\r\n",
4368 in->idtext, res ?
"Failure" :
"Success",
4370 in->context,
in->exten, reason,
4372 S_OR(
in->cid_num,
"<unknown>"),
4373 S_OR(
in->cid_name,
"<unknown>")
4388 const char *unitamount;
4389 const char *unittype;
4401 entry->valid_amount = 1;
4405 entry->valid_type = 1;
4421 const char *association_num =
astman_get_header(m,
"ChargingAssociationNumber");
4429 unsigned int _currencyamount = 0;
4430 int _association_id = 0;
4431 unsigned int _association_plan = 0;
4437 goto aocmessage_cleanup;
4442 if (!strcasecmp(chargetype,
"NA")) {
4444 }
else if (!strcasecmp(chargetype,
"Free")) {
4446 }
else if (!strcasecmp(chargetype,
"Currency")) {
4448 }
else if (!strcasecmp(chargetype,
"Unit")) {
4452 goto aocmessage_cleanup;
4457 if (
ast_strlen_zero(currencyamount) || (sscanf(currencyamount,
"%30u", &_currencyamount) != 1)) {
4458 astman_send_error(s, m,
"Invalid CurrencyAmount, CurrencyAmount is a required when ChargeType is Currency");
4459 goto aocmessage_cleanup;
4463 astman_send_error(s, m,
"ChargeMultiplier unspecified, ChargeMultiplier is required when ChargeType is Currency.");
4464 goto aocmessage_cleanup;
4465 }
else if (!strcasecmp(mult,
"onethousandth")) {
4467 }
else if (!strcasecmp(mult,
"onehundredth")) {
4469 }
else if (!strcasecmp(mult,
"onetenth")) {
4471 }
else if (!strcasecmp(mult,
"one")) {
4473 }
else if (!strcasecmp(mult,
"ten")) {
4475 }
else if (!strcasecmp(mult,
"hundred")) {
4477 }
else if (!strcasecmp(mult,
"thousand")) {
4481 goto aocmessage_cleanup;
4488 goto aocmessage_cleanup;
4492 if (!
ast_strlen_zero(totaltype) && !strcasecmp(totaltype,
"subtotal")) {
4498 }
else if (!strcasecmp(aocbillingid,
"Normal")) {
4500 }
else if (!strcasecmp(aocbillingid,
"ReverseCharge")) {
4502 }
else if (!strcasecmp(aocbillingid,
"CreditCard")) {
4506 goto aocmessage_cleanup;
4511 }
else if (!strcasecmp(aocbillingid,
"Normal")) {
4513 }
else if (!strcasecmp(aocbillingid,
"ReverseCharge")) {
4515 }
else if (!strcasecmp(aocbillingid,
"CreditCard")) {
4517 }
else if (!strcasecmp(aocbillingid,
"CallFwdUnconditional")) {
4519 }
else if (!strcasecmp(aocbillingid,
"CallFwdBusy")) {
4521 }
else if (!strcasecmp(aocbillingid,
"CallFwdNoReply")) {
4523 }
else if (!strcasecmp(aocbillingid,
"CallDeflection")) {
4525 }
else if (!strcasecmp(aocbillingid,
"CallTransfer")) {
4529 goto aocmessage_cleanup;
4532 if (!
ast_strlen_zero(association_id) && (sscanf(association_id,
"%30d", &_association_id) != 1)) {
4534 goto aocmessage_cleanup;
4536 if (!
ast_strlen_zero(association_plan) && (sscanf(association_plan,
"%30u", &_association_plan) != 1)) {
4538 goto aocmessage_cleanup;
4541 if (_association_id) {
4555 for (i = 0; i < 32; i++) {
4565 astman_send_error(s, m,
"Invalid UnitAmount(0), At least one valid unit entry is required when ChargeType is set to Unit");
4566 goto aocmessage_cleanup;
4601 unsigned int _currencyamount = 0;
4603 unsigned int _time = 0;
4605 unsigned int _granularity = 0;
4612 goto aocmessage_cleanup;
4617 goto aocmessage_cleanup;
4620 if (!strcasecmp(chargeditem,
"NA")) {
4622 }
else if (!strcasecmp(chargeditem,
"SpecialArrangement")) {
4624 }
else if (!strcasecmp(chargeditem,
"BasicCommunication")) {
4626 }
else if (!strcasecmp(chargeditem,
"CallAttempt")) {
4628 }
else if (!strcasecmp(chargeditem,
"CallSetup")) {
4630 }
else if (!strcasecmp(chargeditem,
"UserUserInfo")) {
4632 }
else if (!strcasecmp(chargeditem,
"SupplementaryService")) {
4636 goto aocmessage_cleanup;
4639 if (!strcasecmp(ratetype,
"NA")) {
4641 }
else if (!strcasecmp(ratetype,
"Free")) {
4643 }
else if (!strcasecmp(ratetype,
"FreeFromBeginning")) {
4645 }
else if (!strcasecmp(ratetype,
"Duration")) {
4647 }
else if (!strcasecmp(ratetype,
"Flat")) {
4649 }
else if (!strcasecmp(ratetype,
"Volume")) {
4651 }
else if (!strcasecmp(ratetype,
"SpecialCode")) {
4655 goto aocmessage_cleanup;
4659 if (
ast_strlen_zero(currencyamount) || (sscanf(currencyamount,
"%30u",
4660 &_currencyamount) != 1)) {
4661 astman_send_error(s, m,
"Invalid CurrencyAmount, CurrencyAmount is a required when RateType is non-free");
4662 goto aocmessage_cleanup;
4666 astman_send_error(s, m,
"ChargeMultiplier unspecified, ChargeMultiplier is required when ChargeType is Currency.");
4667 goto aocmessage_cleanup;
4668 }
else if (!strcasecmp(mult,
"onethousandth")) {
4670 }
else if (!strcasecmp(mult,
"onehundredth")) {
4672 }
else if (!strcasecmp(mult,
"onetenth")) {
4674 }
else if (!strcasecmp(mult,
"one")) {
4676 }
else if (!strcasecmp(mult,
"ten")) {
4678 }
else if (!strcasecmp(mult,
"hundred")) {
4680 }
else if (!strcasecmp(mult,
"thousand")) {
4684 goto aocmessage_cleanup;
4690 astman_send_error(s, m,
"TimeScale unspecified, TimeScale is required when RateType is Duration.");
4691 goto aocmessage_cleanup;
4692 }
else if (!strcasecmp(timescale,
"onehundredthsecond")) {
4694 }
else if (!strcasecmp(timescale,
"onetenthsecond")) {
4696 }
else if (!strcasecmp(timescale,
"second")) {
4698 }
else if (!strcasecmp(timescale,
"tenseconds")) {
4700 }
else if (!strcasecmp(timescale,
"minute")) {
4702 }
else if (!strcasecmp(timescale,
"hour")) {
4704 }
else if (!strcasecmp(timescale,
"day")) {
4708 goto aocmessage_cleanup;
4712 astman_send_error(s, m,
"Invalid Time, Time is a required when RateType is Duration");
4713 goto aocmessage_cleanup;
4717 if ((sscanf(time,
"%30u", &_granularity) != 1)) {
4719 goto aocmessage_cleanup;
4723 astman_send_error(s, m,
"Invalid GranularityTimeScale, GranularityTimeScale is a required when Granularity is specified");
4724 }
else if (!strcasecmp(granularitytimescale,
"onehundredthsecond")) {
4726 }
else if (!strcasecmp(granularitytimescale,
"onetenthsecond")) {
4728 }
else if (!strcasecmp(granularitytimescale,
"second")) {
4730 }
else if (!strcasecmp(granularitytimescale,
"tenseconds")) {
4732 }
else if (!strcasecmp(granularitytimescale,
"minute")) {
4734 }
else if (!strcasecmp(granularitytimescale,
"hour")) {
4736 }
else if (!strcasecmp(granularitytimescale,
"day")) {
4740 goto aocmessage_cleanup;
4744 if (
ast_strlen_zero(chargingtype) || strcasecmp(chargingtype,
"continuouscharging") == 0) {
4746 }
else if (strcasecmp(chargingtype,
"stepfunction") == 0 ) {
4750 goto aocmessage_cleanup;
4756 astman_send_error(s, m,
"VolumeUnit unspecified, VolumeUnit is required when RateType is Volume.");
4757 goto aocmessage_cleanup;
4758 }
else if (!strcasecmp(timescale,
"octet")) {
4760 }
else if (!strcasecmp(timescale,
"segment")) {
4762 }
else if (!strcasecmp(timescale,
"message")) {
4766 goto aocmessage_cleanup;
4773 astman_send_error(s, m,
"Invalid Code, Code is a required when ChargedItem is SpecialArrangement and when RateType is SpecialCode");
4774 goto aocmessage_cleanup;
4782 currencyname, _time, _scale, _granularity, _granularity_time_scale, _step);
4788 _mult, currencyname);
4812 static const char hdr[] =
"ChargedItem:";
4818 goto aocmessage_cleanup;
4821 hdrlen = strlen(hdr);
4822 for (x = 0; x < m->
hdrcount; x++) {
4823 if (strncasecmp(hdr, m->
headers[x], hdrlen) == 0) {
4826 goto aocmessage_cleanup;
4837 goto aocmessage_cleanup;
4859 size_t encoded_size = 0;
4862 astman_send_error(s, m,
"Channel and PartialChannel are not specified. Specify at least one of these.");
4863 goto aocmessage_cleanup;
4872 goto aocmessage_cleanup;
4875 if (strcasecmp(msgtype,
"d") == 0 || strcasecmp(msgtype,
"e") == 0) {
4878 else if (strcasecmp(msgtype,
"s") == 0) {
4883 goto aocmessage_cleanup;
4887 goto aocmessage_cleanup;
4894 astman_send_error(s, m,
"Error encoding AOC message, could not queue onto channel");
4911 int (*searchfn)(
const char *
app,
const char *data,
const char *search);
4948 return !!(strstr(data, search));
5050#ifdef TEST_FRAMEWORK
5051#define ALL_PERMISSIONS (INT_MAX)
5052#define NO_PERMISSIONS (0)
5059 info->name =
"originate_permissions_test";
5060 info->category =
"/main/manager/";
5061 info->summary =
"Test permissions for originate action";
5063 "Make sure that dialplan apps/functions that need special "
5064 "permissions are prohibited if the user doesn't have the permission.";
5080 NULL, ALL_PERMISSIONS),
"exec check permission failed");
5086 NULL, NO_PERMISSIONS),
"exec permission check failed");
5097 NULL, NO_PERMISSIONS),
"Queue permission check failed");
5099 "somequeue,CcdHh,someURL,tt-monkeys,100,,gosub,rule,666",
5104 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5107 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5110 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5111 ALL_PERMISSIONS),
"Queue permission check failed");
5115 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5116 NO_PERMISSIONS),
"Queue permission check failed");
5118 "somequeue,CcdHh,someURL,tt-monkeys,100,SomeAGIScript,gosub,rule,666",
5127 "aaa DB bbb", ALL_PERMISSIONS),
"exec permission check failed");
5129 "aaaDBbbb", NO_PERMISSIONS),
"exec permission check failed");
5131 "aaa DB bbb", NO_PERMISSIONS),
"exec permission check failed");
5134 "aaa db bbb", NO_PERMISSIONS),
"exec permission check failed");
5138#undef ALL_PERMISSIONS
5139#undef NO_PERMISSIONS
5174 int bridge_early = 0;
5187 goto fast_orig_cleanup;
5193 goto fast_orig_cleanup;
5199 goto fast_orig_cleanup;
5202 if (!
ast_strlen_zero(timeout) && (sscanf(timeout,
"%30d", &to) != 1)) {
5205 goto fast_orig_cleanup;
5209 data = strchr(
tmp,
'/');
5213 goto fast_orig_cleanup;
5238 goto fast_orig_cleanup;
5248 goto fast_orig_cleanup;
5263 for (v = vars; v->
next; v = v->
next );
5269 bridge_early =
ast_true(early_media);
5316 l, n, vars, account,
NULL, bridge_early,
5320 astman_send_error(s, m,
"Originate with 'Exten' requires 'Context' and 'Priority'");
5323 goto fast_orig_cleanup;
5350 "Waiting: %d\r\n\r\n",
mailbox, ret);
5357 int newmsgs = 0, oldmsgs = 0, urgentmsgs = 0;;
5367 "UrgMessages: %d\r\n"
5368 "NewMessages: %d\r\n"
5369 "OldMessages: %d\r\n"
5371 mailbox, urgentmsgs, newmsgs, oldmsgs);
5398 "StatusText: %s\r\n"
5437 "PresenceMessage: %s\r\n",
5450 struct timeval when = { timeout, 0 };
5457 if (!timeout || timeout < 0) {
5467 when.tv_usec = (timeout - when.tv_sec) * 1000000.0;
5489 switch(
entry->match_type) {
5491 return regexec(
entry->regex_filter, eventdata, 0,
NULL, 0) == 0;
5497 return strstr(eventdata,
entry->string_filter) !=
NULL;
5499 return strcmp(eventdata,
entry->string_filter) == 0;
5511 char *line_buffer_start =
NULL;
5512 char *line_buffer =
NULL;
5530 line_buffer_start =
ast_strdup(eqe->eventdata);
5531 line_buffer = line_buffer_start;
5532 if (!line_buffer_start) {
5546 line_buffer_start =
NULL;
5604 if (!strcasecmp(operation,
"Add")) {
5612 S_COR(have_match,
"(",
""),
S_OR(match_criteria,
""),
5613 S_COR(have_match,
")",
""));
5615 astman_send_error(s, m,
"Internal Error. Failed to allocate storage for filter type");
5627 "Filter did not compile. Check the syntax of the filter given.");
5631 "Filter was formatted incorrectly. Check the syntax of the filter given.");
5665 const char *criteria,
const char *filter_pattern,
5671 char *options_start =
NULL;
5672 SCOPE_ENTER(3,
"manager_add_filter(%s, %s, %p, %p)", criteria, filter_pattern, includefilters, excludefilters);
5674 if (!filter_entry) {
5689 if (!filter_pattern) {
5699 if (filter_pattern[0] ==
'!') {
5700 filter_entry->is_excludefilter = 1;
5712 options_start = strstr(criteria,
"(");
5719 "'%s = %s': Legacy filter with no filter pattern specified\n",
5720 criteria, filter_pattern);
5723 if (options_start) {
5728 char *saveptr =
NULL;
5729 char *option =
NULL;
5730 enum found_options {
5731 action_found = (1 << 0),
5732 name_found = (1 << 1),
5733 header_found = (1 << 2),
5734 method_found = (1 << 3),
5736 enum found_options options_found = 0;
5743 "'%s = %s': Filter options not formatted correctly\n",
5744 criteria, filter_pattern);
5752 while ((option = strtok_r(temp,
" ,)", &saveptr))) {
5753 if (!strncmp(option,
"action", 6)) {
5754 char *
method = strstr(option,
"(");
5757 criteria, filter_pattern);
5761 if (!strcmp(
method,
"include")) {
5762 filter_entry->is_excludefilter = 0;
5763 }
else if (!strcmp(
method,
"exclude")) {
5764 filter_entry->is_excludefilter = 1;
5767 criteria, filter_pattern,
method);
5769 options_found |= action_found;
5770 }
else if (!strncmp(option,
"name", 4)) {
5771 char *event_name = strstr(option,
"(");
5776 criteria, filter_pattern);
5778 filter_entry->event_name =
ast_strdup(event_name);
5779 filter_entry->event_name_hash =
ast_str_hash(event_name);
5780 options_found |= name_found;
5781 }
else if (!strncmp(option,
"header", 6)) {
5782 char *header_name = strstr(option,
"(");
5787 criteria, filter_pattern);
5790 filter_entry->header_name =
ast_malloc(strlen(header_name) + 2);
5791 if (!filter_entry->header_name) {
5794 sprintf(filter_entry->header_name,
"%s:", header_name);
5796 filter_entry->header_name =
ast_strdup(header_name);
5798 options_found |= header_found;
5799 }
else if (!strncmp(option,
"method", 6)) {
5800 char *
method = strstr(option,
"(");
5805 criteria, filter_pattern);
5807 if (!strcmp(
method,
"regex")) {
5809 }
else if (!strcmp(
method,
"exact")) {
5811 }
else if (!strcmp(
method,
"starts_with")) {
5813 }
else if (!strcmp(
method,
"ends_with")) {
5815 }
else if (!strcmp(
method,
"contains")) {
5817 }
else if (!strcmp(
method,
"none")) {
5821 criteria, filter_pattern,
method);
5823 options_found |= method_found;
5826 criteria, filter_pattern, option);
5830 if (!options_found) {
5832 "'%s = %s': No action, name, header, or method option found\n",
5833 criteria, filter_pattern);
5837 "'%s = %s': method can't be '%s' with no filter pattern\n",
5842 "'%s = %s': method can't be 'none' with a filter pattern\n",
5843 criteria, filter_pattern);
5845 if (!(options_found & name_found) && !(options_found & header_found) &&
5848 "'%s = %s': No name or header option found and no filter pattern\n",
5849 criteria, filter_pattern);
5855 filter_entry->regex_filter =
ast_calloc(1,
sizeof(regex_t));
5856 if (!filter_entry->regex_filter) {
5859 if (regcomp(filter_entry->regex_filter, filter_pattern, REG_EXTENDED | REG_NOSUB)) {
5863 filter_entry->string_filter =
ast_strdup(filter_pattern);
5868 "conf entry: %s = %s\n"
5869 "event_name: %s (hash: %d)\n"
5872 "regex_filter: %p\n"
5873 "string filter: %s\n"
5874 "is excludefilter: %d\n",
5875 criteria, filter_pattern,
5876 S_OR(filter_entry->event_name,
"<not used>"),
5877 filter_entry->event_name_hash,
5878 S_OR(filter_entry->header_name,
"<not used>"),
5880 filter_entry->regex_filter,
5881 filter_entry->string_filter,
5882 filter_entry->is_excludefilter);
5884 if (filter_entry->is_excludefilter) {
5885 ao2_t_link(excludefilters, filter_entry,
"link new filter into exclude user container");
5887 ao2_t_link(includefilters, filter_entry,
"link new filter into include user container");
5893#ifdef TEST_FRAMEWORK
5895struct test_filter_data {
5896 const char *criteria;
5900 const char *test_event_name;
5901 const char *test_event_payload;
5902 int expected_should_send_event;
5905static char *add_filter_result_enums[] = {
5912#define TEST_EVENT_NEWCHANNEL "Newchannel", "Event: Newchannel\r\nChannel: XXX\r\nSomeheader: YYY\r\n"
5913#define TEST_EVENT_VARSET "VarSet", "Event: VarSet\r\nChannel: ABC\r\nSomeheader: XXX\r\n"
5914#define TEST_EVENT_NONE "", ""
5916static struct test_filter_data parsing_filter_tests[] = {
5924 {
"eventfilter(name(Newchannel),method(regex))",
"X[XYZ]X",
FILTER_SUCCESS,
5926 {
"eventfilter(name(Newchannel),method(regex))",
"X[abc]X",
FILTER_SUCCESS,
5928 {
"eventfilter(action(exclude),name(Newchannel),method(regex))",
"X[XYZ]X",
FILTER_SUCCESS,
5930 {
"eventfilter(action(exclude),name(Newchannel),method(regex))",
"X[abc]X",
FILTER_SUCCESS,
5932 {
"eventfilter(action(include),name(VarSet),header(Channel),method(starts_with))",
"AB",
FILTER_SUCCESS,
5934 {
"eventfilter(action(include),name(VarSet),header(Channel),method(ends_with))",
"BC",
FILTER_SUCCESS,
5936 {
"eventfilter(action(include),name(VarSet),header(Channel),method(exact))",
"ABC",
FILTER_SUCCESS,
5938 {
"eventfilter(action(include),name(VarSet),header(Channel),method(exact))",
"XXX",
FILTER_SUCCESS,
5940 {
"eventfilter(name(VarSet),header(Channel),method(exact))",
"!ZZZ",
FILTER_SUCCESS,
5942 {
"eventfilter(action(exclude),name(VarSet),header(Channel),method(exact))",
"ZZZ",
FILTER_SUCCESS,
5944 {
"eventfilter(action(include),name(VarSet),header(Someheader),method(exact))",
"!XXX",
FILTER_SUCCESS,
5953 {
"eventfilter(nnnn(yyy),header(VarSet),method(contains)",
"XXX",
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
5954 {
"eventfilter(name(yyy),heder(VarSet),method(contains)",
"XXX",
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
5955 {
"eventfilter(name(yyy),header(VarSet),mehod(contains)",
"XXX",
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
5956 {
"eventfilter(name(yyy),header(VarSet),method(coains)",
"XXX",
FILTER_FORMAT_ERROR, { 0, }, TEST_EVENT_NONE, 0},
5969static int strings_equal(
const char *str1,
const char *str2)
5971 if ((!str1 && str2) || (str1 && !str2)) {
5975 return str1 == str2 || !strcmp(str1, str2);
5987 info->name =
"eventfilter_test_creation";
5988 info->category =
"/main/manager/";
5989 info->summary =
"Test eventfilter creation";
5991 "This creates various eventfilters and tests to make sure they were created successfully.";
5999 if (!includefilters || !excludefilters) {
6004 for (i = 0; i <
ARRAY_LEN(parsing_filter_tests); i++) {
6009 int include_container_count = 0;
6010 int exclude_container_count = 0;
6017 includefilters, excludefilters);
6022 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6023 add_filter_result_enums[parsing_filter_tests[i].expected_add_filter_result],
6024 add_filter_result_enums[add_filter_res],
6025 add_filter_res != parsing_filter_tests[i].expected_add_filter_result ?
"FAIL" :
"PASS");
6028 if (add_filter_res != parsing_filter_tests[i].expected_add_filter_result) {
6030 "Unexpected add filter result '%s = %s'. Expected result: %s Actual result: %s\n",
6031 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6032 add_filter_result_enums[parsing_filter_tests[i].expected_add_filter_result],
6033 add_filter_result_enums[add_filter_res]);
6038 if (parsing_filter_tests[i].expected_add_filter_result !=
FILTER_SUCCESS) {
6047 if (parsing_filter_tests[i].expected_filter_entry.event_name) {
6048 parsing_filter_tests[i].expected_filter_entry.event_name_hash =
6049 ast_str_hash(parsing_filter_tests[i].expected_filter_entry.event_name);
6055 if (parsing_filter_tests[i].expected_filter_entry.is_excludefilter) {
6056 if (exclude_container_count != 1 || include_container_count != 0) {
6058 "Invalid container counts for exclude filter '%s = %s'. Exclude: %d Include: %d. Should be 1 and 0\n",
6059 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6060 exclude_container_count, include_container_count);
6067 if (include_container_count != 1 || exclude_container_count != 0) {
6069 "Invalid container counts for include filter '%s = %s'. Include: %d Exclude: %d. Should be 1 and 0\n",
6070 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6071 include_container_count, exclude_container_count);
6079 if (!filter_entry) {
6081 "Failed to find filter entry for '%s = %s' in %s filter container\n",
6082 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6083 parsing_filter_tests[i].expected_filter_entry.is_excludefilter ?
"exclude" :
"include");
6088 if (filter_entry->
match_type != parsing_filter_tests[i].expected_filter_entry.match_type) {
6090 "Failed to match filter type for '%s = %s'. Expected: %s Actual: %s\n",
6091 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6092 match_type_names[parsing_filter_tests[i].expected_filter_entry.match_type],
6098 if (!strings_equal(filter_entry->
event_name, parsing_filter_tests[i].expected_filter_entry.event_name)) {
6100 "Failed to match event name for '%s = %s'. Expected: '%s' Actual: '%s'\n",
6101 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6102 parsing_filter_tests[i].expected_filter_entry.event_name, filter_entry->
event_name);
6107 if (filter_entry->
event_name_hash != parsing_filter_tests[i].expected_filter_entry.event_name_hash) {
6109 "Event name hashes failed to match for '%s = %s'. Expected: %u Actual: %u\n",
6110 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6111 parsing_filter_tests[i].expected_filter_entry.event_name_hash, filter_entry->
event_name_hash);
6116 if (!strings_equal(filter_entry->
header_name, parsing_filter_tests[i].expected_filter_entry.header_name)) {
6118 "Failed to match header name for '%s = %s'. Expected: '%s' Actual: '%s'\n",
6119 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6120 parsing_filter_tests[i].expected_filter_entry.header_name, filter_entry->
header_name);
6125 switch (parsing_filter_tests[i].expected_filter_entry.match_type) {
6129 "Failed to compile regex filter for '%s = %s'\n",
6130 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter);
6138 "Unexpected regex filter or string for '%s = %s' with match_type 'none'\n",
6139 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter);
6150 "Unexpected regex filter or empty string for '%s = %s' with match_type '%s'\n",
6151 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6152 match_type_names[parsing_filter_tests[i].expected_filter_entry.match_type]);
6165 eqe =
ast_calloc(1,
sizeof(*eqe) + strlen(parsing_filter_tests[i].test_event_payload) + 1);
6172 strcpy(eqe->eventdata, parsing_filter_tests[i].test_event_payload);
6175 if (send_event != parsing_filter_tests[i].expected_should_send_event) {
6178 "Should send event failed to match for '%s = %s' payload '%s'. Expected: %s Actual: %s\n",
6179 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter, escaped,
6180 AST_YESNO(parsing_filter_tests[i].expected_should_send_event),
AST_YESNO(send_event));
6194struct test_filter_matching {
6195 const char *criteria;
6196 const char *pattern;
6212static struct test_filter_matching filters_for_matching[] = {
6213 {
"eventfilter(name(VarSet),method(none))",
""},
6214 {
"eventfilter(name(Newchannel),method(regex))",
"X[XYZ]X"},
6215 {
"eventfilter(name(Newchannel),method(regex))",
"X[abc]X"},
6216 {
"eventfilter(name(Newchannel),header(Someheader),method(regex))",
"ZZZ"},
6217 {
"eventfilter(action(exclude),name(Newchannel),method(regex))",
"X[a]X"},
6218 {
"eventfilter(action(exclude),name(Newchannel),method(regex))",
"X[Z]X"},
6219 {
"eventfilter(action(exclude),name(VarSet),header(Channel),method(regex))",
"YYY"},
6222struct test_event_matching{
6223 const char *event_name;
6224 const char *payload;
6225 int expected_should_send_event;
6228static struct test_event_matching events_for_matching[] = {
6229 {
"Newchannel",
"Event: Newchannel\r\nChannel: XXX\r\nSomeheader: YYY\r\n", 1 },
6230 {
"Newchannel",
"Event: Newchannel\r\nChannel: XZX\r\nSomeheader: YYY\r\n", 0 },
6231 {
"Newchannel",
"Event: Newchannel\r\nChannel: XaX\r\nSomeheader: YYY\r\n", 0 },
6232 {
"Newchannel",
"Event: Newchannel\r\nChannel: XbX\r\nSomeheader: YYY\r\n", 1 },
6233 {
"Newchannel",
"Event: Newchannel\r\nChannel: XcX\r\nSomeheader: YYY\r\n", 1 },
6234 {
"Newchannel",
"Event: Newchannel\r\nChannel: YYY\r\nSomeheader: YYY\r\n", 0 },
6235 {
"Newchannel",
"Event: Newchannel\r\nChannel: YYY\r\nSomeheader: ZZZ\r\n", 1 },
6236 {
"VarSet",
"Event: VarSet\r\nChannel: XXX\r\nSomeheader: YYY\r\n", 1 },
6237 {
"VarSet",
"Event: VarSet\r\nChannel: YYY\r\nSomeheader: YYY\r\n", 0 },
6249 info->name =
"eventfilter_test_matching";
6250 info->category =
"/main/manager/";
6251 info->summary =
"Test eventfilter matching";
6253 "This creates various eventfilters and tests to make sure they were matched successfully.";
6261 if (!includefilters || !excludefilters) {
6267 for (i = 0; i <
ARRAY_LEN(filters_for_matching); i++) {
6271 filters_for_matching[i].pattern, includefilters, excludefilters);
6275 "Unexpected add filter result '%s = %s'. Expected result: %s Actual result: %s\n",
6276 parsing_filter_tests[i].criteria, parsing_filter_tests[i].
filter,
6278 add_filter_result_enums[add_filter_res]);
6290 for (i = 0; i <
ARRAY_LEN(events_for_matching); i++) {
6294 eqe =
ast_calloc(1,
sizeof(*eqe) + strlen(events_for_matching[i].payload) + 1);
6300 strcpy(eqe->eventdata, events_for_matching[i].payload);
6303 if (send_event != events_for_matching[i].expected_should_send_event) {
6306 "Should send event failed to match for '%s'. Expected: %s Actual: %s\n",
6308 AST_YESNO(events_for_matching[i].expected_should_send_event),
AST_YESNO(send_event));
6335 ast_debug(3,
"Received CloseSession event\n");
6361 for (x = 0; x < m->
hdrcount; x++) {
6362 if (strncasecmp(
"UserEvent:", m->
headers[x], strlen(
"UserEvent:")) &&
6363 strncasecmp(
"Action:", m->
headers[x], strlen(
"Action:"))) {
6380 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
6387 "AMIversion: %s\r\n"
6388 "AsteriskVersion: %s\r\n"
6389 "SystemName: %s\r\n"
6390 "CoreMaxCalls: %d\r\n"
6391 "CoreMaxLoadAvg: %f\r\n"
6392 "CoreRunUser: %s\r\n"
6393 "CoreRunGroup: %s\r\n"
6394 "CoreMaxFilehandles: %d\r\n"
6395 "CoreRealTimeEnabled: %s\r\n"
6396 "CoreCDRenabled: %s\r\n"
6397 "CoreHTTPenabled: %s\r\n"
6398 "SoundsSearchCustomDir: %s\r\n"
6422 char startuptime[150], startupdate[150];
6423 char reloadtime[150], reloaddate[150];
6427 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
6433 ast_strftime(startuptime,
sizeof(startuptime),
"%H:%M:%S", &tm);
6434 ast_strftime(startupdate,
sizeof(startupdate),
"%Y-%m-%d", &tm);
6436 ast_strftime(reloadtime,
sizeof(reloadtime),
"%H:%M:%S", &tm);
6437 ast_strftime(reloaddate,
sizeof(reloaddate),
"%Y-%m-%d", &tm);
6441 "CoreStartupDate: %s\r\n"
6442 "CoreStartupTime: %s\r\n"
6443 "CoreReloadDate: %s\r\n"
6444 "CoreReloadTime: %s\r\n"
6445 "CoreCurrentCalls: %d\r\n"
6446 "CoreProcessedCalls: %d\r\n"
6502 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n", actionid);
6514 char durbuf[16] =
"";
6521 int duration, durh, durm, durs;
6524 durh = duration / 3600;
6525 durm = (duration % 3600) / 60;
6526 durs = duration % 60;
6527 snprintf(durbuf,
sizeof(durbuf),
"%02d:%02d:%02d", durh, durm, durs);
6531 "Event: CoreShowChannel\r\n"
6534 "Application: %s\r\n"
6535 "ApplicationData: %s\r\n"
6581 char *current_channel_uid;
6586 int add_channel_res;
6590 if (!strcmp(current_channel_uid, channel_snapshot->
base->
uniqueid)) {
6591 ao2_ref(current_channel_uid, -1);
6596 if (!current_channel_snapshot) {
6597 ast_debug(5,
"Unable to get channel snapshot\n");
6598 ao2_ref(current_channel_uid, -1);
6603 if (add_channel_res) {
6605 ao2_ref(current_channel_snapshot, -1);
6606 ao2_ref(current_channel_uid, -1);
6614 int size = strlen(current_channel_snapshot->
base->
name);
6615 char other_local[size + 1];
6620 other_local[size] =
'\0';
6623 if (!other_local_snapshot) {
6624 ast_debug(5,
"Unable to get other local channel snapshot\n");
6625 ao2_ref(current_channel_snapshot, -1);
6626 ao2_ref(current_channel_uid, -1);
6632 ao2_ref(current_channel_snapshot, -1);
6633 ao2_ref(current_channel_uid, -1);
6634 ao2_ref(other_local_snapshot, -1);
6639 if (other_bridge_snapshot) {
6643 ao2_ref(current_channel_snapshot, -1);
6644 ao2_ref(current_channel_uid, -1);
6645 ao2_ref(other_local_snapshot, -1);
6646 ao2_ref(other_bridge_snapshot, -1);
6664 char *current_channel_name;
6673 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n", actionid);
6684 if (!channel_snapshot) {
6697 if (!bridge_snapshot) {
6721 "Event: CoreShowChannelMap\r\n"
6724 "ConnectedChannel: %s\r\n\r\n",
6727 current_channel_name);
6758 ast_debug(1,
"**** ModuleCheck .so file %s\n", module);
6770#if !defined(LOW_MEMORY)
6794 char *stripped_filename;
6810 real_path = realpath(path,
NULL);
6825 if (!loadtype || strlen(loadtype) == 0) {
6828 if ((!module || strlen(module) == 0) && strcasecmp(loadtype,
"reload") != 0) {
6836 }
else if (res == -1) {
6841 if (!strcasecmp(loadtype,
"load")) {
6848 }
else if (!strcasecmp(loadtype,
"unload")) {
6855 }
else if (!strcasecmp(loadtype,
"refresh")) {
6862 }
else if (!strcasecmp(loadtype,
"reload")) {
6867 switch (reload_res) {
6913 for (x = 0; x < m->
hdrcount; ++x) {
6914 if (!strncasecmp(m->
headers[x],
"Secret", 6)) {
6943 const char *username;
6958 ast_log(
LOG_ERROR,
"Unable to process manager action '%s'. Asterisk is shutting down.\n", action);
6966 && strcasecmp(action,
"Login")
6967 && strcasecmp(action,
"Logoff")
6968 && strcasecmp(action,
"Challenge")) {
6979 && (!strcasecmp(action,
"Login")
6980 || !strcasecmp(action,
"Challenge"))) {
6986 if (
user && !
user->allowmultiplelogin) {
7013 if (mod_ref || !act_found->
module) {
7015 ret = act_found->
func(s, m);
7034 ao2_t_ref(act_found, -1,
"done with found action object");
7039 snprintf(
buf,
sizeof(
buf),
"Invalid/unknown command: %s. Use Action: ListCommands to show available commands.", action);
7080 if (src[x] ==
'\r' && x+1 < s->
session->
inlen && src[x + 1] ==
'\n') {
7082 }
else if (src[x] ==
'\n') {
7087 memmove(output, src, x);
7106 if(time(&now) == -1) {
7135 ast_debug(1,
"Manager session has been kicked\n");
7206 if (time(&now) == -1) {
7221 }
else if (res > 0) {
7317 if(time(&
session->authstart) == -1) {
7370 time_t now = time(
NULL);
7386 ast_verb(2,
"HTTP Manager '%s' timed out from %s\n",
7417 tmp->category = category;
7420 tmp->event_name_hash = event_name_hash;
7422 strcpy(
tmp->eventdata,
str);
7449#define MANAGER_EVENT_BUF_INITSIZE 256
7464 const char *cat_str;
7468 int event_name_hash;
7472 ast_debug(3,
"AMI Event '%s' is globally disabled, skipping\n",
event);
7486 "Privilege: %s\r\n",
7492 "Timestamp: %ld.%06lu\r\n",
7493 (
long)now.tv_sec, (
unsigned long) now.tv_usec);
7499 "SequenceNumber: %d\r\n",
7509 "SystemName: %s\r\n",
7533 pthread_kill(
session->waiting_thread, SIGURG);
7585 const char *fmt, ...)
7599 file, line, func, fmt, ap);
7614 if (!strcasecmp(action, cur->
action)) {
7631 ao2_t_ref(cur, -1,
"action object removed from list");
7632 ast_verb(5,
"Manager unregistered action %s\n", action);
7646 switch(
info->reason) {
7653 "StatusText: %s\r\n",
7672 info->presence_subtype,
7673 info->presence_message);
7699 ao2_t_ref(act, +1,
"action object added to list");
7743 ao2_t_ref(cur, -1,
"action object creation failed");
7789 ao2_t_ref(cur, -1,
"action object registration failed");
7793 ao2_t_ref(cur, -1,
"action object registration successful");
7873 if (nonce == 0 || username ==
NULL || stale ==
NULL) {
7885 if (!strcasecmp(
session->username, username) &&
session->managerid == nonce) {
7888 }
else if (!strcasecmp(
session->username, username) &&
session->oldnonce == nonce) {
7908 authed = (
session->authenticated != 0);
7935 if ((
session->managerid == ident) && (
session->readperm & perm)) {
7968 if ((
session->managerid == ident) && (
session->writeperm & perm)) {
7992 const char *save = src;
7993 int space =
sizeof(
buf);
7995 for ( ; *src || dst !=
buf ; src++) {
7996 if (*src ==
'\0' || space < 10) {
8000 space =
sizeof(
buf);
8007 if (save == src && isdigit(*src)) {
8013 }
else if (!isalnum(*src)) {
8022 strcpy(dst,
"<");
8027 strcpy(dst,
">");
8032 strcpy(dst,
""");
8037 strcpy(dst,
"'");
8042 strcpy(dst,
"&");
8048 *dst++ = mode ? tolower(*src) : *src;
8108 const char *dest =
NULL;
8110 const char *objtype =
NULL;
8119 for (v = get_vars; v; v = v->
next) {
8120 if (!strcasecmp(v->
name,
"ajaxdest")) {
8122 }
else if (!strcasecmp(v->
name,
"ajaxobjtype")) {
8130 objtype =
"generic";
8137 if (
in && *
in ==
'\n') {
8141 ast_debug(5,
"inobj %d in_data %d line <%s>\n", inobj, in_data,
val);
8153 "<tr><td colspan=\"2\"><hr></td></tr>\r\n");
8188 var =
"Opaque-data";
8205 if (vc->
count > 1) {
8211 if (!in_data || !*
in) {
8218 "<tr><td colspan=\"2\"><hr></td></tr>\r\n");
8229 ast_log(
LOG_ERROR,
"Attempted to close file/file descriptor on mansession without a valid file or file descriptor.\n");
8247 l = lseek(fd, 0, SEEK_CUR);
8249 if (MAP_FAILED == (
buf = mmap(
NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0))) {
8269 const struct ast_sockaddr *remote_address,
const char *uri,
8279 char template[] =
"/tmp/ast-http-XXXXXX";
8284 ast_http_error(ser, 501,
"Not Implemented",
"Attempt to use unimplemented / unsupported method");
8298 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8324 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (ast_str_create() out of memory)");
8325 goto generic_callback_out;
8329 fd = mkstemp(
template);
8332 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (mkstemp failed)");
8333 goto generic_callback_out;
8338 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (fdopen failed)");
8340 goto generic_callback_out;
8348 ast_http_error(ser, 413,
"Request Entity Too Large",
"Body too large");
8350 goto generic_callback_out;
8355 goto generic_callback_out;
8357 ast_http_error(ser, 400,
"Bad Request",
"Error parsing request body");
8359 goto generic_callback_out;
8382 "Content-type: text/%s\r\n"
8383 "Set-Cookie: mansession_id=\"%08x\"; Version=1; Max-Age=%d\r\n"
8384 "Pragma: SuppressEvents\r\n",
8397#define ROW_FMT "<tr><td colspan=\"2\" bgcolor=\"#f1f1ff\">%s</td></tr>\r\n"
8398#define TEST_STRING \
8399 "<form action=\"manager\" method=\"post\">\n\
8400 Action: <select name=\"action\">\n\
8401 <option value=\"\">-----></option>\n\
8402 <option value=\"login\">login</option>\n\
8403 <option value=\"command\">Command</option>\n\
8404 <option value=\"waitevent\">waitevent</option>\n\
8405 <option value=\"listcommands\">listcommands</option>\n\
8407 or <input name=\"action\"><br/>\n\
8408 CLI Command <input name=\"command\"><br>\n\
8409 user <input name=\"username\"> pass <input type=\"password\" name=\"secret\"><br>\n\
8410 <input type=\"submit\">\n</form>\n"
8413 ast_str_append(&
out, 0,
"<body bgcolor=\"#ffffff\"><table align=center bgcolor=\"#f1f1f1\" width=\"500\">\r\n");
8432 ast_debug(1,
"Need destroy, doing it now!\n");
8435 ast_debug(1,
"Need destroy, but can't do it yet!\n");
8438 pthread_kill(
session->waiting_thread, SIGURG);
8452generic_callback_out:
8481 const struct ast_sockaddr *remote_address,
const char *uri,
8488 char template[] =
"/tmp/ast-http-XXXXXX";
8494 time_t time_now = time(
NULL);
8495 unsigned long nonce = 0, nc;
8499 char resp_hash[256]=
"";
8501 char u_username[80];
8505 int u_displayconnects;
8508 ast_http_error(ser, 501,
"Not Implemented",
"Attempt to use unimplemented / unsupported method");
8513 for (v = headers; v; v = v->
next) {
8514 if (!strcasecmp(v->
name,
"Authorization")) {
8526 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8535 if (sscanf(
d.nonce,
"%30lx", &nonce) != 1) {
8555 ast_http_error(ser, 403,
"Permission denied",
"Permission denied");
8572 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8581 snprintf(resp,
sizeof(resp),
"%s:%08lx:%s:%s:auth:%s",
user->a1_hash, nonce,
d.nc,
d.cnonce, a2_hash);
8584 snprintf(resp,
sizeof(resp),
"%s:%08lx:%s",
user->a1_hash, nonce, a2_hash);
8589 if (strncasecmp(
d.response, resp_hash, strlen(resp_hash))) {
8601 u_readperm =
user->readperm;
8602 u_writeperm =
user->writeperm;
8603 u_displayconnects =
user->displayconnects;
8604 u_writetimeout =
user->writetimeout;
8614 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (out of memory)");
8624 session->readperm = u_readperm;
8625 session->writeperm = u_writeperm;
8626 session->writetimeout = u_writetimeout;
8628 if (u_displayconnects) {
8651 sscanf(
d.nc,
"%30lx", &nc);
8652 if (
session->nc >= nc || ((time_now -
session->noncetime) > 62) ) {
8663 session->noncetime = time_now;
8679 fd = mkstemp(
template);
8682 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (mkstemp failed)");
8683 goto auth_callback_out;
8688 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (fdopen failed)");
8690 goto auth_callback_out;
8698 ast_http_error(ser, 413,
"Request Entity Too Large",
"Body too large");
8700 goto auth_callback_out;
8705 goto auth_callback_out;
8707 ast_http_error(ser, 400,
"Bad Request",
"Error parsing request body");
8709 goto auth_callback_out;
8717 if (u_displayconnects) {
8732 ast_http_error(ser, 500,
"Server Error",
"Internal Server Error (ast_str_create() out of memory)");
8734 goto auth_callback_out;
8743 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
8745 "<title>Asterisk™ Manager Interface</title>\r\n"
8746 "</head><body style=\"background-color: #ffffff;\">\r\n"
8747 "<form method=\"POST\">\r\n"
8748 "<table align=\"center\" style=\"background-color: #f1f1f1;\" width=\"500\">\r\n"
8749 "<tr><th colspan=\"2\" style=\"background-color: #f1f1ff;\"><h1>Manager Tester</h1></th></tr>\r\n"
8750 "<tr><th colspan=\"2\" style=\"background-color: #f1f1ff;\">Action: <input name=\"action\" /> Cmd: <input name=\"command\" /><br>"
8751 "<input type=\"submit\" value=\"Send request\" /></th></tr>\r\n");
8785 ast_debug(1,
"Need destroy, doing it now!\n");
8835 .
description =
"Raw HTTP Manager Event Interface",
8894 .
description =
"Raw HTTP Manager Event Interface w/Digest authentication",
8903 .
description =
"HTML Manager Event Interface w/Digest authentication",
8912 .
description =
"XML Manager Event Interface w/Digest authentication",
8924 const char *login = (
char *)arg;
8925 int *no_sessions = data;
8927 if (strcasecmp(
session->username, login) == 0) {
8947 ast_log(
LOG_WARNING,
"AMI_CLIENT() requires two arguments: AMI_CLIENT(<name>[,<arg>])\n");
8962 if (!strcasecmp(
args.param,
"sessions")) {
8963 int no_sessions = 0;
8971 snprintf(
buf,
len,
"%d", no_sessions);
8984 .
name =
"AMI_CLIENT",
9015 .poll_timeout = 5000,
9017 .name =
"AMI server",
9027 .name =
"AMI TLS server",
9037 e->
command =
"manager show settings";
9039 "Usage: manager show settings\n"
9040 " Provides detailed list of the configuration of the Manager.\n";
9045#define FORMAT " %-25.25s %-15.55s\n"
9046#define FORMAT2 " %-25.25s %-15d\n"
9047#define FORMAT3 " %-25.25s %s\n"
9051 ast_cli(
a->fd,
"\nGlobal Settings:\n");
9052 ast_cli(
a->fd,
"----------------\n");
9081 return strcmp((*item_a)->name, (*item_b)->name);
9091 int i = 0, totalitems = 0;
9095 e->
command =
"manager show events";
9097 "Usage: manager show events\n"
9098 " Prints a listing of the available Asterisk manager interface events.\n";
9114 ast_cli(
a->fd,
"No manager event documentation loaded\n");
9138 items[totalitems++] =
item;
9145 ast_cli(
a->fd,
" -------------------- -------------------- -------------------- \n");
9146 for (i = 0; i < totalitems; i++) {
9148 if ((i + 1) % 3 == 0) {
9153 if ((i + 1) % 3 != 0) {
9167 char syntax_title[64], description_title[64], synopsis_title[64], seealso_title[64], arguments_title[64];
9182 ast_cli(
a->fd,
"%s%s\n\n", syntax_title, syntax);
9187 ast_cli(
a->fd,
"%s%s\n\n", description_title, description);
9192 ast_cli(
a->fd,
"%s%s\n\n", arguments_title, arguments);
9197 ast_cli(
a->fd,
"%s%s\n\n", seealso_title, seealso);
9210 e->
command =
"manager show event";
9212 "Usage: manager show event <eventname>\n"
9213 " Provides a detailed description a Manager interface event.\n";
9219 ast_cli(
a->fd,
"No manager event documentation loaded\n");
9228 length = strlen(
a->word);
9231 if (!strncasecmp(
a->word,
item->
name, length)) {
9249 ast_cli(
a->fd,
"Could not find event '%s'\n",
a->argv[3]);
9253 ast_cli(
a->fd,
"Event: %s\n",
a->argv[3]);
9324 if (
user->includefilters) {
9325 ao2_t_ref(
user->includefilters, -1,
"decrement ref for include container, should be last one");
9327 if (
user->excludefilters) {
9328 ao2_t_ref(
user->excludefilters, -1,
"decrement ref for exclude container, should be last one");
9343#ifdef TEST_FRAMEWORK
9398#ifdef TEST_FRAMEWORK
9400 test_suite_forwarder =
NULL;
9540 int newhttptimeout = 60;
9548 int tls_was_enabled = 0;
9549 int acl_subscription_flag = 0;
9608#ifdef TEST_FRAMEWORK
9624 if (temp_event_docs) {
9626 ao2_t_ref(temp_event_docs, -1,
"Remove creation ref - container holds only ref now");
9646 ast_log(
LOG_NOTICE,
"Unable to open AMI configuration manager.conf, or configuration is invalid.\n");
9651 if (!by_external_config) {
9668 if (strcasecmp(
var->name,
"tlscafile")
9669 && strcasecmp(
var->name,
"tlscapath")
9670 && strcasecmp(
var->name,
"tlscadir")
9671 && strcasecmp(
var->name,
"tlsverifyclient")
9672 && strcasecmp(
var->name,
"tlsdontverifyserver")
9673 && strcasecmp(
var->name,
"tlsclientmethod")
9674 && strcasecmp(
var->name,
"sslclientmethod")
9679 if (!strcasecmp(
var->name,
"enabled")) {
9681 }
else if (!strcasecmp(
var->name,
"webenabled")) {
9683 }
else if (!strcasecmp(
var->name,
"port")) {
9689 }
else if (!strcasecmp(
var->name,
"bindaddr")) {
9704 }
else if (!strcasecmp(
var->name,
"brokeneventsaction")) {
9706 }
else if (!strcasecmp(
var->name,
"allowmultiplelogin")) {
9708 }
else if (!strcasecmp(
var->name,
"displayconnects")) {
9710 }
else if (!strcasecmp(
var->name,
"timestampevents")) {
9712 }
else if (!strcasecmp(
var->name,
"debug")) {
9714 }
else if (!strcasecmp(
var->name,
"httptimeout")) {
9715 newhttptimeout = atoi(
val);
9716 }
else if (!strcasecmp(
var->name,
"authtimeout")) {
9717 int timeout = atoi(
var->value);
9724 }
else if (!strcasecmp(
var->name,
"authlimit")) {
9725 int limit = atoi(
var->value);
9732 }
else if (!strcasecmp(
var->name,
"channelvars")) {
9734 }
else if (!strcasecmp(
var->name,
"disabledevents")) {
9775 const char *hasmanager;
9779 if (!strcasecmp(cat,
"general")) {
9784 if ((!hasmanager && genhasmanager) ||
ast_true(hasmanager)) {
9806 user->readperm = -1;
9807 user->writeperm = -1;
9812 user->writetimeout = 100;
9824 if (!user_displayconnects) {
9827 if (!user_allowmultiplelogin) {
9830 if (!user_writetimeout) {
9845 if (user_displayconnects) {
9846 user->displayconnects =
ast_true(user_displayconnects);
9848 if (user_allowmultiplelogin) {
9849 user->allowmultiplelogin =
ast_true(user_allowmultiplelogin);
9851 if (user_writetimeout) {
9852 int value = atoi(user_writetimeout);
9869 if (!strcasecmp(cat,
"general")) {
9883 user->writeperm = 0;
9888 user->writetimeout = 100;
9891 if (!
user->includefilters || !
user->excludefilters) {
9911 if (!strcasecmp(
var->name,
"secret")) {
9914 }
else if (!strcasecmp(
var->name,
"deny") ||
9915 !strcasecmp(
var->name,
"permit") ||
9916 !strcasecmp(
var->name,
"acl")) {
9921 ast_log(
LOG_ERROR,
"Invalid ACL '%s' for manager user '%s' on line %d. Deleting user\n",
9925 }
else if (!strcasecmp(
var->name,
"read") ) {
9927 }
else if (!strcasecmp(
var->name,
"write") ) {
9929 }
else if (!strcasecmp(
var->name,
"displayconnects") ) {
9931 }
else if (!strcasecmp(
var->name,
"allowmultiplelogin") ) {
9933 }
else if (!strcasecmp(
var->name,
"writetimeout")) {
9940 }
else if (!strcasecmp(
var->name,
"setvar")) {
9949 if ((varval = strchr(varname,
'='))) {
9953 user->chanvars = tmpvar;
9969 if (acl_subscription_flag && !by_external_config) {
10018 if (newhttptimeout > 0) {
10054#ifdef TEST_FRAMEWORK
10096 if ((datastore->
uid !=
NULL) && !strcasecmp(
uid, datastore->
uid)) {
10109 if (!*fields_string) {
10111 if (!*fields_string) {
10127__attribute__((format(printf, 3, 4)))
10131 const
char *extra_fields_fmt,
10153 va_start(argp, extra_fields_fmt);
10166 .
requires =
"extconfig,acl,http",
Access Control of various sorts.
enum ast_acl_sense ast_apply_acl(struct ast_acl_list *acl_list, const struct ast_sockaddr *addr, const char *purpose)
Apply a set of rules to a given IP address.
struct stasis_message_type * ast_named_acl_change_type(void)
a stasis_message_type for changes against a named ACL or the set of all named ACLs
void ast_acl_output(int fd, struct ast_acl_list *acl, const char *prefix)
output an ACL to the provided fd
void ast_append_acl(const char *sense, const char *stuff, struct ast_acl_list **path, int *error, int *named_acl_flag)
Add a rule to an ACL struct.
int ast_acl_list_is_empty(struct ast_acl_list *acl_list)
Determines if an ACL is empty or if it contains entries.
struct ast_acl_list * ast_free_acl_list(struct ast_acl_list *acl)
Free a list of ACLs.
Generic Advice of Charge encode and decode routines.
void * ast_aoc_destroy_encoded(struct ast_aoc_encoded *encoded)
free an ast_aoc_encoded object
int ast_aoc_s_add_rate_duration(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name, unsigned long time, enum ast_aoc_time_scale time_scale, unsigned long granularity_time, enum ast_aoc_time_scale granularity_time_scale, int step_function)
Add AOC-S duration rate entry.
@ AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION
@ AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT
@ AST_AOC_CHARGED_ITEM_NA
@ AST_AOC_CHARGED_ITEM_USER_USER_INFO
@ AST_AOC_CHARGED_ITEM_CALL_SETUP
@ AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE
@ AST_AOC_CHARGED_ITEM_CALL_ATTEMPT
@ AST_AOC_CHARGE_CURRENCY
@ AST_AOC_TIME_SCALE_TEN_SECOND
@ AST_AOC_TIME_SCALE_TENTH_SECOND
@ AST_AOC_TIME_SCALE_MINUTE
@ AST_AOC_TIME_SCALE_SECOND
@ AST_AOC_TIME_SCALE_HOUR
@ AST_AOC_TIME_SCALE_HUNDREDTH_SECOND
@ AST_AOC_VOLUME_UNIT_OCTET
@ AST_AOC_VOLUME_UNIT_SEGMENT
@ AST_AOC_VOLUME_UNIT_MESSAGE
int ast_aoc_s_add_rate_special_charge_code(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, unsigned int code)
Add AOC-S special rate entry.
ast_aoc_currency_multiplier
Defines the currency multiplier for an aoc message.
@ AST_AOC_MULT_ONEHUNDREDTH
@ AST_AOC_MULT_ONETHOUSANDTH
struct ast_aoc_decoded * ast_aoc_create(const enum ast_aoc_type msg_type, const enum ast_aoc_charge_type charge_type, const enum ast_aoc_request requests)
creates a ast_aoc_decode object of a specific message type
void * ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded)
free an ast_aoc_decoded object
int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num, uint8_t plan)
set the charging association number for an AOC-E message
int ast_aoc_add_unit_entry(struct ast_aoc_decoded *decoded, const unsigned int amount_is_present, const unsigned int amount, const unsigned int type_is_present, const unsigned int type)
Adds a unit entry into the list of units.
ast_aoc_billing_id
Defines the billing id options for an aoc message.
@ AST_AOC_BILLING_CALL_FWD_BUSY
@ AST_AOC_BILLING_CALL_FWD_NO_REPLY
@ AST_AOC_BILLING_CALL_DEFLECTION
@ AST_AOC_BILLING_CREDIT_CARD
@ AST_AOC_BILLING_CALL_TRANSFER
@ AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL
@ AST_AOC_BILLING_REVERSE_CHARGE
int ast_aoc_s_add_rate_free(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, int from_beginning)
Add AOC-S indicating charge item is free.
int ast_aoc_set_billing_id(struct ast_aoc_decoded *decoded, const enum ast_aoc_billing_id id)
set the billing id for a AOC-D or AST_AOC_E message
int ast_aoc_s_add_special_arrangement(struct ast_aoc_decoded *decoded, unsigned int code)
Add AOC-S special arrangement entry.
int ast_aoc_set_currency_info(struct ast_aoc_decoded *decoded, const unsigned int amount, const enum ast_aoc_currency_multiplier multiplier, const char *name)
Sets the currency values for a AOC-D or AOC-E message.
int ast_aoc_set_association_id(struct ast_aoc_decoded *decoded, const int id)
set the charging association id for an AST_AOC_E message
int ast_aoc_s_add_rate_flat(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name)
Add AOC-S flat rate entry.
struct ast_aoc_encoded * ast_aoc_encode(struct ast_aoc_decoded *decoded, size_t *out_size, struct ast_channel *chan)
encodes a decoded aoc structure so it can be passed on the wire
int ast_aoc_set_total_type(struct ast_aoc_decoded *decoded, const enum ast_aoc_total_type type)
Sets the type of total for a AOC-D message.
int ast_aoc_s_add_rate_volume(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, enum ast_aoc_volume_unit volume_unit, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name)
Add AOC-S volume rate entry.
unsigned int ast_aoc_s_get_count(struct ast_aoc_decoded *decoded)
get the number rates associated with an AOC-S message
int ast_aoc_s_add_rate_na(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item)
Add AOC-S entry indicating charge item is not available.
@ AST_AOC_RATE_TYPE_VOLUME
@ AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING
@ AST_AOC_RATE_TYPE_SPECIAL_CODE
@ AST_AOC_RATE_TYPE_DURATION
static const struct adsi_event events[]
static volatile unsigned int seq
static int copy(char *infile, char *outfile)
Utility function to copy a file.
Asterisk version information.
const char * ast_get_version(void)
Retrieve the Asterisk version string.
Asterisk main include file. File version handling, generic pbx functions.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
int ast_shutting_down(void)
static struct ast_mansession session
void ast_std_free(void *ptr)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
#define ao2_t_ref(o, delta, tag)
#define ao2_iterator_next(iter)
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_NOLOCK
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define ao2_global_obj_replace_unref(holder, obj)
Replace an ao2 object in the global holder, throwing away any old object.
#define ao2_t_global_obj_replace_unref(holder, obj, tag)
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_callback_data(container, flags, cb_fn, arg, data)
#define ao2_unlink(container, obj)
Remove an object from a container.
#define ao2_t_link(container, obj, tag)
#define ao2_global_obj_ref(holder)
Get a reference to the object stored in the global holder.
#define ao2_find(container, arg, flags)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc_options(data_size, destructor_fn, options)
#define ao2_t_callback_data(container, flags, cb_fn, arg, data, tag)
ao2_callback_data() is a generic function that applies cb_fn() to all objects in a container....
#define ao2_global_obj_release(holder)
Release the ao2 object held in the global holder.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ao2_t_alloc(data_size, destructor_fn, debug_msg)
@ OBJ_SEARCH_OBJECT
The arg parameter is an object of the same type.
@ OBJ_NOLOCK
Assume that the ao2_container is already locked.
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a list container.
#define ao2_alloc(data_size, destructor_fn)
#define ao2_t_global_obj_release(holder, tag)
#define ao2_t_callback(c, flags, cb_fn, arg, tag)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
@ AO2_CONTAINER_ALLOC_OPT_DUPS_OBJ_REJECT
Reject duplicate objects in container.
enum ast_transfer_result ast_bridge_transfer_blind(int is_external, struct ast_channel *transferer, const char *exten, const char *context, transfer_channel_cb new_channel_cb, void *user_data)
Blind transfer target to the extension and context provided.
@ AST_BRIDGE_TRANSFER_NOT_PERMITTED
@ AST_BRIDGE_TRANSFER_SUCCESS
@ AST_BRIDGE_TRANSFER_INVALID
@ AST_BRIDGE_TRANSFER_FAIL
static struct prometheus_metrics_provider provider
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s,...
int ast_cdr_is_enabled(void)
Return TRUE if CDR subsystem is enabled.
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
static struct unistimsession * sessions
General Asterisk PBX channel definitions.
struct varshead * ast_channel_get_manager_vars(struct ast_channel *chan)
Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
const char * ast_channel_name(const struct ast_channel *chan)
#define AST_MAX_PUBLIC_UNIQUEID
const char * ast_channel_data(const struct ast_channel *chan)
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Clear a flag on a channel.
struct varshead * ast_channel_varshead(struct ast_channel *chan)
struct ast_channel_iterator * ast_channel_iterator_destroy(struct ast_channel_iterator *i)
Destroy a channel iterator.
void ast_channel_set_manager_vars(size_t varc, char **vars)
Sets the variables to be stored in the manager_vars field of all snapshots.
#define ast_channel_lock(chan)
struct ast_trans_pvt * ast_channel_readtrans(const struct ast_channel *chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
struct ast_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan)
ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan)
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
int ast_check_hangup_locked(struct ast_channel *chan)
struct ast_channel * ast_channel_get_by_name_prefix(const char *name, size_t name_len)
Find a channel by a name prefix.
void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode)
Lock the given channel, then request softhangup on the channel with the given causecode.
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
const char * ast_channel_appl(const struct ast_channel *chan)
struct timeval ast_channel_creationtime(struct ast_channel *chan)
int ast_active_channels(void)
returns number of active/allocated channels
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
#define ast_channel_unref(c)
Decrease channel reference count.
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
ast_group_t ast_channel_callgroup(const struct ast_channel *chan)
struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan)
void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Set when to hang a channel up.
#define ast_dummy_channel_alloc()
Create a fake channel structure.
@ AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
struct ast_channel_iterator * ast_channel_iterator_all_new(void)
Create a new channel iterator.
#define ast_channel_unlock(chan)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
const char * ast_var_name(const struct ast_var_t *var)
const char * ast_var_value(const struct ast_var_t *var)
Standard Command Line Interface.
#define AST_CLI_YESNO(x)
Return Yes or No depending on the argument.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define AST_CLI_DEFINE(fn, txt,...)
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
void ast_cli(int fd, const char *fmt,...)
ast_cli_command
calling arguments for new-style handlers.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static struct ao2_container * codecs
Registered codecs.
static struct channel_usage channels
Local proxy channel special access.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
void ast_verbose(const char *fmt,...)
Call Parking and Pickup API Includes code and algorithms from the Zapata library.
Generic File Format Support. Should be included by clients of the file handling routines....
static int md5(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int filter(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static int action_setvar(struct mansession *s, const struct message *m)
static int action_createconfig(struct mansession *s, const struct message *m)
static void purge_events(void)
static char * handle_showmancmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * match_type_names[]
static int manager_state_cb(const char *context, const char *exten, struct ast_state_cb_info *info, void *data)
static void mansession_unlock(struct mansession *s)
Unlock the 'mansession' structure.
static int action_loggerrotate(struct mansession *s, const struct message *m)
Manager command "LoggerRotate" - reloads and rotates the logger in the same manner as the CLI command...
int __ast_manager_event_multichan(int category, const char *event, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *fmt,...)
static int match_eventdata(struct event_filter_entry *entry, const char *eventdata)
Test eventdata against a filter entry.
#define GET_HEADER_LAST_MATCH
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
static int purge_sessions(int n_max)
remove at most n_max stale session from the list.
static int process_message(struct mansession *s, const struct message *m)
Process an AMI message, performing desired action. Return 0 on success, -1 on error that require the ...
static int strings_to_mask(const char *string)
static void print_event_instance(struct ast_cli_args *a, struct ast_xml_doc_item *instance)
static int __manager_event_sessions(struct ao2_container *sessions, int category, const char *event, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *fmt,...)
static struct ast_manager_user * get_manager_by_name_locked(const char *name)
static void acl_change_stasis_subscribe(void)
static char * handle_showmaneventq(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager list eventq.
static void log_action(const struct message *m, const char *action)
static struct mansession_session * build_mansession(const struct ast_sockaddr *addr)
Allocate manager session structure and add it to the list of sessions.
static void report_invalid_user(const struct mansession *s, const char *username)
static int append_event(const char *str, int event_name_hash, int category)
events are appended to a queue from where they can be dispatched to clients.
static int manager_enabled
int ast_manager_check_enabled(void)
Check if AMI is enabled.
static void astman_free_headers(struct message *m)
Free headers inside message structure, but not the message structure itself.
static int action_sendtext(struct mansession *s, const struct message *m)
static int action_mailboxcount(struct mansession *s, const struct message *m)
static void manager_json_to_ast_str(struct ast_json *obj, const char *key, struct ast_str **res, key_exclusion_cb exclusion_cb)
static int ast_manager_register_struct(struct manager_action *act)
static int queue_read_action_payload(struct ast_channel *chan, const unsigned char *payload, size_t payload_size, enum ast_frame_read_action action)
Queue a given read action containing a payload onto a channel.
static AO2_GLOBAL_OBJ_STATIC(mgr_sessions)
static struct manager_action * action_find(const char *name)
static int action_getconfigjson(struct mansession *s, const struct message *m)
int ast_webmanager_check_enabled(void)
Check if AMI/HTTP is enabled.
static const struct @371 command_blacklist[]
void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg)
Send response in manager transaction.
static void report_failed_acl(const struct mansession *s, const char *username)
static int is_originate_app_permitted(const char *app, const char *data, int permission)
static int action_listcategories(struct mansession *s, const struct message *m)
static int action_hangup(struct mansession *s, const struct message *m)
static void mansession_lock(struct mansession *s)
Lock the 'mansession' structure.
static int action_listcommands(struct mansession *s, const struct message *m)
static void destroy_fast_originate_helper(struct fast_originate_helper *doomed)
static int action_atxfer(struct mansession *s, const struct message *m)
static struct ast_threadstorage manager_event_buf
static int action_timeout(struct mansession *s, const struct message *m)
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
static struct stasis_subscription * acl_change_sub
static void generate_status(struct mansession *s, struct ast_channel *chan, char **vars, int varc, int all_variables, char *id_text, int *count)
static int do_message(struct mansession *s)
static struct originate_permissions_entry originate_app_permissions[]
void astman_send_error_va(struct mansession *s, const struct message *m, const char *fmt,...)
Send error in manager transaction (with va_args support)
static void manager_default_msg_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static int action_coresettings(struct mansession *s, const struct message *m)
Show PBX core settings information.
static int mansession_cmp_fn(void *obj, void *arg, int flags)
static int displayconnects
static int action_filter(struct mansession *s, const struct message *m)
Manager command to add an event filter to a manager session.
static int action_mailboxstatus(struct mansession *s, const struct message *m)
static void append_channel_vars(struct ast_str **pbuf, struct ast_channel *chan)
static int action_login(struct mansession *s, const struct message *m)
static int action_getvar(struct mansession *s, const struct message *m)
static int get_input(struct mansession *s, char *output)
static int action_blind_transfer(struct mansession *s, const struct message *m)
static const char * user_authority_to_str(int authority, struct ast_str **res)
Convert authority code to a list of options for a user. This will only display those authority codes ...
static int app_match(const char *app, const char *data, const char *search)
static struct mansession_session * unref_mansession(struct mansession_session *s)
Unreference manager session object. If no more references, then go ahead and delete it.
static int queue_match(const char *app, const char *data, const char *search)
#define ASTMAN_APPEND_BUF_INITSIZE
initial allocated size for the astman_append_buf and astman_send_*_va
void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj)
Publish an event to AMI.
static void session_destroy(struct mansession_session *s)
static int filter_cmp_fn(void *obj, void *arg, void *data, int flags)
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
static int appdata_match(const char *app, const char *data, const char *search)
struct stasis_message_router * ast_manager_get_message_router(void)
Get the stasis_message_router for AMI.
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
static void astman_send_response_full(struct mansession *s, const struct message *m, char *resp, char *msg, char *listflag)
send a response with an optional message, and terminate it with an empty line. m is used only to grab...
static void astman_append_json(struct mansession *s, const char *str)
#define MGR_SHOW_TERMINAL_WIDTH
static enum error_type handle_updates(struct mansession *s, const struct message *m, struct ast_config *cfg, const char *dfn)
helper function for action_updateconfig
static int action_extensionstate(struct mansession *s, const struct message *m)
static char * handle_showmanconn(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager list connected.
static int action_getconfig(struct mansession *s, const struct message *m)
static void event_filter_destructor(void *obj)
static void * session_do(void *data)
The body of the individual manager session. Call get_input() to read one line at a time (or be woken ...
static struct eventqent * advance_event(struct eventqent *e)
static struct ast_threadstorage astman_append_buf
static int restrictedFile(const char *filename)
Check if a file is restricted or not.
static int coreshowchannelmap_add_connected_channels(struct ao2_container *channel_map, struct ast_channel_snapshot *channel_snapshot, struct ast_bridge_snapshot *bridge_snapshot)
Recursive function to get all channels in a bridge. Follow local channels as well.
static enum add_filter_result manager_add_filter(const char *criteria, const char *filter_pattern, struct ao2_container *includefilters, struct ao2_container *excludefilters)
Add an event filter to a manager session.
static void session_destructor(void *obj)
static struct stasis_message_router * stasis_router
The stasis_message_router for all Stasis Message Bus API messages.
static void json_escape(char *out, const char *in)
static int manager_displayconnects(struct mansession_session *session)
Get displayconnects config option.
static int action_logoff(struct mansession *s, const struct message *m)
static char * handle_kickmanconn(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager kick session.
static int action_updateconfig(struct mansession *s, const struct message *m)
static void astman_start_ack(struct mansession *s, const struct message *m)
static const char * __astman_get_header(const struct message *m, char *var, int mode)
Return a matching header value.
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
static int file_in_modules_dir(const char *filename)
Check if the given file path is in the modules dir or not.
STASIS_MESSAGE_TYPE_DEFN(ast_manager_get_generic_type)
Define AMI message types.
static void handle_parse_error(struct mansession *s, struct message *m, char *error)
static int manager_moduleload(struct mansession *s, const struct message *m)
static void acl_change_stasis_unsubscribe(void)
static int reload_module(void)
static void manager_json_array_with_key(struct ast_json *obj, const char *key, size_t index, struct ast_str **res, key_exclusion_cb exclusion_cb)
static void astman_append_headers(struct message *m, const struct ast_variable *params)
Append additional headers into the message structure from params.
static void report_failed_challenge_response(const struct mansession *s, const char *response, const char *expected_response)
#define any_manager_listeners(sessions)
static int action_reload(struct mansession *s, const struct message *m)
Send a reload event.
struct ast_variable * astman_get_variables(const struct message *m)
Get a linked list of the Variable: headers.
static int live_dangerously
Set to true (non-zero) to globally allow all dangerous AMI actions to run.
struct ast_str * ast_manager_str_from_json_object(struct ast_json *blob, key_exclusion_cb exclusion_cb)
Convert a JSON object into an AMI compatible string.
static struct eventqent * grab_last(void)
static int should_send_event(struct ao2_container *includefilters, struct ao2_container *excludefilters, struct eventqent *eqe)
static struct stasis_forward * rtp_topic_forwarder
The stasis_subscription for forwarding the RTP topic to the AMI topic.
static int action_aocmessage(struct mansession *s, const struct message *m)
static char * handle_showmanagers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int check_manager_session_inuse(const char *name)
static int check_blacklist(const char *cmd)
static int action_events(struct mansession *s, const struct message *m)
void ast_manager_unregister_hook(struct manager_custom_hook *hook)
Delete a custom hook to be called when an event is fired.
static void astman_flush(struct mansession *s, struct ast_str *buf)
static const char * authority_to_str(int authority, struct ast_str **res)
Convert authority code to a list of options. Note that the EVENT_FLAG_ALL authority will always be re...
static int action_redirect(struct mansession *s, const struct message *m)
action_redirect: The redirect manager command
static struct stasis_forward * security_topic_forwarder
The stasis_subscription for forwarding the Security topic to the AMI topic.
static int action_presencestate(struct mansession *s, const struct message *m)
struct ast_variable * astman_get_variables_order(const struct message *m, enum variable_orders order)
Get a linked list of the Variable: headers with order specified.
static char * manager_channelvars
void ast_manager_register_hook(struct manager_custom_hook *hook)
Add a custom hook to be called when an event is fired.
static int allowmultiplelogin
static void manager_json_value_str_append(struct ast_json *value, const char *key, struct ast_str **res)
static int queue_sendtext_data(struct ast_channel *chan, const char *body, const char *content_type)
Queue a read action to send a text data message.
const char * astman_get_header(const struct message *m, char *var)
Return the first matching variable from an array.
#define GET_HEADER_SKIP_EMPTY
static struct ast_threadstorage userevent_buf
static enum ast_transport mansession_get_transport(const struct mansession *s)
static int function_capable_string_allowed_with_auths(const char *evaluating, int writepermlist)
Checks to see if a string which can be used to evaluate functions should be rejected.
static char * handle_showmanager(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int action_cancel_atxfer(struct mansession *s, const struct message *m)
static void report_req_not_allowed(const struct mansession *s, const char *action)
static char global_realm[MAXHOSTNAMELEN]
static int action_originate(struct mansession *s, const struct message *m)
static int send_string(struct mansession *s, char *string)
#define MAX_AUTH_PERM_STRING
static int action_userevent(struct mansession *s, const struct message *m)
static int action_command(struct mansession *s, const struct message *m)
Manager command "command" - execute CLI command.
static void report_inval_password(const struct mansession *s, const char *username)
static int ast_instring(const char *bigstr, const char *smallstr, const char delim)
#define MAX_BLACKLIST_CMD_LEN
Descriptor for a manager session, either on the AMI socket or over HTTP.
int ast_manager_register2(const char *action, int auth, int(*func)(struct mansession *s, const struct message *m), struct ast_module *module, const char *synopsis, const char *description)
register a new command with manager, including online help. This is the preferred way to register a m...
static int process_events(struct mansession *s)
static int broken_events_action
static void report_session_limit(const struct mansession *s)
static int unauth_sessions
static int set_eventmask(struct mansession *s, const char *eventmask)
Rather than braindead on,off this now can also accept a specific int mask value or a ',...
static int timestampevents
static void manager_generic_msg_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static struct ast_aoc_decoded * action_aoc_s_message(struct mansession *s, const struct message *m)
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
static char * handle_manager_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager reload.
static struct ast_aoc_decoded * action_aoc_de_message(struct mansession *s, const struct message *m)
static int authenticate(struct mansession *s, const struct message *m)
void astman_append(struct mansession *s, const char *fmt,...)
static void manager_json_obj_with_key(struct ast_json *obj, const char *key, const char *parent_key, struct ast_str **res, key_exclusion_cb exclusion_cb)
static char * handle_showmancmds(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager list commands.
#define EVENT_FLAG_SHUTDOWN
Fake event class used to end sessions at shutdown.
static int manager_modulecheck(struct mansession *s, const struct message *m)
Manager function to check if module is loaded.
static void astman_send_list_complete(struct mansession *s, const struct message *m, const char *event_name, int count)
void astman_live_dangerously(int new_live_dangerously)
Enable/disable the inclusion of 'dangerous' configurations outside of the ast_config_AST_CONFIG_DIR.
int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg)
access for hooks to send action messages to ami
static int action_aoc_s_submessage(struct mansession *s, const struct message *m, struct ast_aoc_decoded *decoded)
static int webmanager_enabled
static struct ast_str * astman_send_list_complete_start_common(struct mansession *s, const struct message *m, const char *event_name, int count)
static int action_status(struct mansession *s, const struct message *m)
Manager "status" command to show channels.
static int get_perm(const char *instr)
static int action_coreshowchannels(struct mansession *s, const struct message *m)
Manager command "CoreShowChannels" - List currently defined channels and some information about them.
static struct ast_variable * man_do_variable_value(struct ast_variable *head, const char *hdr_val)
static int action_corestatus(struct mansession *s, const struct message *m)
Show PBX core status information.
static int queue_sendtext(struct ast_channel *chan, const char *body)
Queue a read action to send a text message.
static void action_destroy(void *obj)
static int action_challenge(struct mansession *s, const struct message *m)
static struct stasis_topic * manager_topic
A stasis_topic that all topics AMI cares about will be forwarded to.
static int action_waitevent(struct mansession *s, const struct message *m)
static void report_req_bad_format(const struct mansession *s, const char *action)
static int action_coreshowchannelmap(struct mansession *s, const struct message *m)
Manager command "CoreShowChannelMap" - Lists all channels connected to the specified channel.
mansession_message_parsing
static char * handle_mandebug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int action_ping(struct mansession *s, const struct message *m)
#define GET_HEADER_FIRST_MATCH
static int aocmessage_get_unit_entry(const struct message *m, struct ast_aoc_unit_entry *entry, unsigned int entry_num)
static int coreshowchannelmap_add_to_map(struct ao2_container *c, const char *s)
Helper function to add a channel name to the vector.
int ast_manager_hangup_helper(struct mansession *s, const struct message *m, manager_hangup_handler_t hangup_handler, manager_hangup_cause_validator_t cause_validator)
A manager helper function that hangs up a channel using a supplied channel type specific hangup funct...
static void report_auth_success(const struct mansession *s)
static void * fast_originate(void *data)
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
#define MANAGER_EVENT_BUF_INITSIZE
static const struct permalias perms[]
#define manager_event_sessions(sessions, category, event, contents,...)
static char * manager_disabledevents
static int __manager_event_sessions_va(struct ao2_container *sessions, int category, const char *event, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *fmt, va_list ap)
int ast_manager_unregister(const char *action)
support functions to register/unregister AMI action handlers,
@ FILTER_MATCH_STARTS_WITH
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
#define SCOPE_EXIT_LOG_RTN_VALUE(__value, __log_level,...)
#define SCOPE_ENTER(level,...)
struct ast_channel_snapshot * ast_channel_snapshot_get_latest(const char *uniqueid)
Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object,...
struct ast_channel_snapshot * ast_channel_snapshot_get_latest_by_name(const char *name)
Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object,...
struct ao2_container * ast_channel_cache_by_name(void)
Secondary channel cache, indexed by name.
struct ast_msg_data * ast_msg_data_alloc2(enum ast_msg_data_source_type source_type, const char *to, const char *from, const char *content_type, const char *body)
Allocates an ast_msg_data structure.
size_t ast_msg_data_get_length(struct ast_msg_data *msg)
Get length of the structure.
@ AST_MSG_DATA_SOURCE_TYPE_UNKNOWN
double ast_option_maxload
struct ast_flags ast_options
@ AST_OPT_FLAG_FULLY_BOOTED
Support for Private Asterisk HTTP Servers.
void ast_http_send(struct ast_tcptls_session_instance *ser, enum ast_http_method method, int status_code, const char *status_title, struct ast_str *http_header, struct ast_str *out, int fd, unsigned int static_content)
Generic function for sending HTTP/1.1 response.
struct ast_variable * ast_http_get_post_vars(struct ast_tcptls_session_instance *ser, struct ast_variable *headers)
Get post variables from client Request Entity-Body, if content type is application/x-www-form-urlenco...
ast_http_method
HTTP Request methods known by Asterisk.
void ast_http_uri_unlink(struct ast_http_uri *urihandler)
Unregister a URI handler.
uint32_t ast_http_manid_from_vars(struct ast_variable *headers) attribute_pure
Return manager id, if exist, from request headers.
const char * ast_get_http_method(enum ast_http_method method) attribute_pure
Return http method name string.
void ast_http_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.
void ast_http_request_close_on_completion(struct ast_tcptls_session_instance *ser)
Request the HTTP connection be closed after this HTTP request.
void ast_http_error(struct ast_tcptls_session_instance *ser, int status, const char *title, const char *text)
Send HTTP error message and close socket.
int ast_http_uri_link(struct ast_http_uri *urihandler)
Register a URI handler.
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
int ast_app_has_voicemail(const char *mailboxes, const char *folder)
Determine if a given mailbox has any voicemail If folder is NULL, defaults to "INBOX"....
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
int ast_app_inboxcount2(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Determine number of urgent/new/old messages in a mailbox.
char * strsep(char **str, const char *delims)
char * strcasestr(const char *, const char *)
Configuration File Parser.
void ast_include_rename(struct ast_config *conf, const char *from_file, const char *to_file)
int ast_category_inherit(struct ast_category *existing, const struct ast_category *base)
Applies base (template) to category.
const char * ast_category_get_name(const struct ast_category *category)
Return the name of the category.
struct ast_category * ast_category_new_template(const char *name, const char *in_file, int lineno)
Create a category making it a template.
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
struct ast_category * ast_category_delete(struct ast_config *cfg, struct ast_category *cat)
Delete a category.
int ast_config_text_file_save2(const char *filename, const struct ast_config *cfg, const char *generator, uint32_t flags)
Save a config text file.
void ast_category_rename(struct ast_category *cat, const char *name)
int ast_variable_delete(struct ast_category *category, const char *variable, const char *match, const char *line)
#define CONFIG_STATUS_FILEMISSING
int ast_category_insert(struct ast_config *config, struct ast_category *cat, const char *match)
Inserts new category.
void ast_category_append(struct ast_config *config, struct ast_category *category)
Appends a category to a config.
void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
int ast_variable_update(struct ast_category *category, const char *variable, const char *value, const char *match, unsigned int object)
Update variable value within a config.
struct ast_variable * ast_variables_reverse(struct ast_variable *var)
Reverse a variable list.
int ast_realtime_enabled(void)
Check if there's any realtime engines loaded.
struct ast_category * ast_category_new(const char *name, const char *in_file, int lineno)
Create a category.
#define ast_variable_new(name, value, filename)
struct ast_str * ast_category_get_templates(const struct ast_category *category)
Return the template names this category inherits from.
#define CONFIG_STATUS_FILEUNCHANGED
@ CONFIG_SAVE_FLAG_PRESERVE_EFFECTIVE_CONTEXT
#define CONFIG_STATUS_FILEINVALID
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *p_result,...)
The argument parsing routine.
struct ast_variable * ast_variables_dup(struct ast_variable *var)
Duplicate variable list.
void ast_category_destroy(struct ast_category *cat)
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
int ast_category_empty(struct ast_category *category)
Removes and destroys all variables in a category.
int ast_category_is_template(const struct ast_category *category)
Check if category is a template.
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
struct ast_variable * ast_category_first(struct ast_category *cat)
given a pointer to a category, return the root variable.
void ast_variable_insert(struct ast_category *category, struct ast_variable *variable, const char *line)
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name, const char *filter)
Retrieve a category if it exists.
@ CONFIG_FLAG_WITHCOMMENTS
@ CONFIG_FLAG_FILEUNCHANGED
struct ast_category * ast_category_browse_filtered(struct ast_config *config, const char *category_name, struct ast_category *prev, const char *filter)
Browse categories with filters.
#define AST_FEATURE_MAX_LEN
int ast_get_builtin_feature(struct ast_channel *chan, const char *feature, char *buf, size_t len)
Get the DTMF code for a builtin feature.
char * ast_get_chan_features_atxferabort(struct ast_channel *chan)
Get the transfer configuration option atxferabort.
ast_frame_read_action
Actions to indicate to, and be handled on channel read.
@ AST_FRAME_READ_ACTION_SEND_TEXT
@ AST_FRAME_READ_ACTION_SEND_TEXT_DATA
@ AST_CONTROL_READ_ACTION
int ast_logger_rotate(void)
Reload logger while rotating log files.
#define ast_debug(level,...)
Log a DEBUG message.
#define VERBOSITY_ATLEAST(level)
#define ast_verb(level,...)
void ast_iostream_set_timeout_inactivity(struct ast_iostream *stream, int timeout)
Set the iostream inactivity timeout timer.
struct ast_iostream * ast_iostream_from_fd(int *fd)
Create an iostream from a file descriptor.
ssize_t ast_iostream_write(struct ast_iostream *stream, const void *buffer, size_t count)
Write data to an iostream.
int ast_iostream_get_fd(struct ast_iostream *stream)
Get an iostream's file descriptor.
void ast_iostream_set_exclusive_input(struct ast_iostream *stream, int exclusive_input)
Set the iostream if it can exclusively depend upon the set timeouts.
ssize_t ast_iostream_read(struct ast_iostream *stream, void *buffer, size_t count)
Read data from an iostream.
void ast_iostream_set_timeout_sequence(struct ast_iostream *stream, struct timeval start, int timeout)
Set the iostream I/O sequence timeout timer.
void ast_iostream_nonblock(struct ast_iostream *stream)
Make an iostream non-blocking.
int ast_iostream_close(struct ast_iostream *stream)
Close an iostream.
void ast_iostream_set_timeout_disable(struct ast_iostream *stream)
Disable the iostream timeout timer.
Asterisk JSON abstraction layer.
struct ast_json * ast_json_object_iter_value(struct ast_json_iter *iter)
Get the value from an iterator.
enum ast_json_type ast_json_typeof(const struct ast_json *value)
Get the type of value.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_json_iter * ast_json_object_iter_next(struct ast_json *object, struct ast_json_iter *iter)
Get the next iterator.
struct ast_json * ast_json_array_get(const struct ast_json *array, size_t index)
Get an element from an array.
struct ast_json_payload * ast_json_payload_create(struct ast_json *json)
Create an ao2 object to pass json blobs as data payloads for stasis.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
struct ast_json_iter * ast_json_object_iter(struct ast_json *object)
Get an iterator pointing to the first field in a JSON object.
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
const char * ast_json_object_iter_key(struct ast_json_iter *iter)
Get the key from an iterator.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
size_t ast_json_array_size(const struct ast_json *array)
Get the size of a JSON array.
int ast_json_is_null(const struct ast_json *value)
Check if value is JSON null.
A set of macros to manage forward-linked lists.
#define AST_RWLIST_REMOVE_CURRENT
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized.
#define AST_RWLIST_REMOVE_HEAD
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_RWLIST_INSERT_AFTER
#define AST_RWLIST_REMOVE
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_RWLIST_TRAVERSE_SAFE_END
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_RWLIST_TRAVERSE
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_RWLIST_INSERT_HEAD
#define AST_RWLIST_INSERT_TAIL
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
Asterisk locking-related definitions:
#define AST_PTHREADT_NULL
#define ast_mutex_init(pmutex)
#define ast_mutex_unlock(a)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
#define ast_mutex_destroy(a)
#define ast_mutex_lock(a)
static int auth_mxml_http_callback(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
static int manager_subscriptions_init(void)
Initialize all Stasis Message Bus API topics and routers used by the various sub-components of AMI.
static struct ast_tls_config ami_tls_cfg
static void close_mansession_file(struct mansession *s)
static int ast_xml_doc_item_cmp_fn(const void *a, const void *b)
static struct ast_tcptls_session_args ami_desc
static struct ast_http_uri managerxmluri
const char * words[AST_MAX_CMD_LEN]
static char * handle_manager_show_events(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int manager_http_callback(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
int astman_verify_session_writepermissions(uint32_t ident, int perm)
Verify a session's write permissions against a permission mask.
static int __init_manager(int reload, int by_external_config)
static struct ast_tcptls_session_args amis_desc
static void xml_copy_escape(struct ast_str **out, const char *src, int mode)
static struct ast_custom_function managerclient_function
description of AMI_CLIENT dialplan function
static void purge_old_stuff(void *data)
cleanup code called at each iteration of server_root, guaranteed to happen every 5 seconds at most
struct ast_datastore * astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a session.
static struct mansession_session * find_session(uint32_t ident, int incinuse)
static int mxml_http_callback(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
int ast_str_append_event_header(struct ast_str **fields_string, const char *header, const char *value)
append an event header to an ast string
int astman_datastore_add(struct mansession *s, struct ast_datastore *datastore)
Add a datastore to a session.
static int variable_count_cmp_fn(void *obj, void *vstr, int flags)
static char * handle_manager_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command manager show settings.
static void manager_event_blob_dtor(void *obj)
static void load_channelvars(struct ast_variable *var)
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
static struct mansession_session * find_session_by_nonce(const char *username, unsigned long nonce, int *stale)
int astman_verify_session_readpermissions(uint32_t ident, int perm)
Verify a session's read permissions against a permission mask.
static struct ast_http_uri manageruri
static void manager_set_defaults(void)
static void manager_shutdown(void)
static void process_output(struct mansession *s, struct ast_str **out, struct ast_variable *params, enum output_format format)
static int rawman_http_callback(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
static char * handle_manager_show_event(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int function_amiclient(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
${AMI_CLIENT()} Dialplan function - reads manager client data
static int auth_rawman_http_callback(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
static int load_module(void)
static struct ast_http_uri arawmanuri
static void xml_translate(struct ast_str **out, char *in, struct ast_variable *get_vars, enum output_format format)
Convert the input into XML or HTML. The input is supposed to be a sequence of lines of the form Name:...
static int variable_count_hash_fn(const void *vvc, const int flags)
int astman_is_authed(uint32_t ident)
Determine if a manager session ident is authenticated.
static struct ast_http_uri rawmanuri
static struct ast_cli_entry cli_manager[]
static int unload_module(void)
static void manager_free_user(struct ast_manager_user *user)
static int auth_manager_http_callback(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
static int auth_http_callback(struct ast_tcptls_session_instance *ser, enum ast_http_method method, enum output_format format, const struct ast_sockaddr *remote_address, const char *uri, struct ast_variable *get_params, struct ast_variable *headers)
static struct ast_http_uri amanageruri
static int get_manager_sessions_cb(void *obj, void *arg, void *data, int flags)
Get number of logged in sessions for a login name.
static int subscribe_all(void)
static const char *const contenttype[]
static struct ast_http_uri amanagerxmluri
static int generic_http_callback(struct ast_tcptls_session_instance *ser, enum ast_http_method method, enum output_format format, const struct ast_sockaddr *remote_address, const char *uri, struct ast_variable *get_params, struct ast_variable *headers)
int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastore)
Remove a datastore from a session.
static void load_disabledevents(struct ast_variable *var)
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define EVENT_FLAG_VERBOSE
#define EVENT_FLAG_REPORTING
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
struct ast_str * ast_manager_build_channel_state_string(const struct ast_channel_snapshot *snapshot)
Generate the AMI message body from a channel snapshot.
int manager_mwi_init(void)
Initialize support for AMI MWI events.
#define EVENT_FLAG_CONFIG
int manager_bridging_init(void)
Initialize support for AMI channel events.
#define EVENT_FLAG_SYSTEM
#define EVENT_FLAG_SECURITY
int manager_endpoints_init(void)
Initialize support for AMI endpoint events.
void(* manager_hangup_handler_t)(struct ast_channel *chan, int causecode)
Callback used by ast_manager_hangup_helper that will actually hangup a channel.
int(* key_exclusion_cb)(const char *key)
Callback used to determine whether a key should be skipped when converting a JSON object to a manager...
struct stasis_message_type * ast_manager_get_generic_type(void)
Get the stasis_message_type for generic messages.
#define DEFAULT_MANAGER_PORT
int manager_system_init(void)
Initialize support for AMI system events.
#define EVENT_FLAG_HOOKRESPONSE
#define ast_manager_event_multichan(category, event, nchans, chans, contents,...)
#define DEFAULT_MANAGER_TLS_PORT
#define EVENT_FLAG_MESSAGE
#define EVENT_FLAG_COMMAND
int manager_channels_init(void)
Initialize support for AMI channel events.
#define EVENT_FLAG_DIALPLAN
#define EVENT_FLAG_ORIGINATE
struct ast_str * ast_manager_build_channel_state_string_prefix(const struct ast_channel_snapshot *snapshot, const char *prefix)
Generate the AMI message body from a channel snapshot.
int(* manager_hangup_cause_validator_t)(const char *channel_name, const char *cause)
Callback used by ast_manager_hangup_helper that will validate the cause code.
void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len)
void MD5Init(struct MD5Context *context)
void MD5Final(unsigned char digest[16], struct MD5Context *context)
Out-of-call text message support.
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define ast_module_unref(mod)
Release a reference to the module.
int ast_module_check(const char *name)
Check if module with the name given is loaded.
int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode)
Unload a module.
enum ast_module_load_result ast_load_resource(const char *resource_name)
Load a module.
int ast_refresh_resource(const char *resource_name, enum ast_module_unload_mode force, int recursive)
Unload and load a module again.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
ast_module_reload_result
Possible return types for ast_module_reload.
@ AST_MODULE_RELOAD_IN_PROGRESS
@ AST_MODULE_RELOAD_QUEUED
@ AST_MODULE_RELOAD_SUCCESS
@ AST_MODULE_RELOAD_ERROR
@ AST_MODULE_RELOAD_NOT_IMPLEMENTED
@ AST_MODULE_RELOAD_NOT_FOUND
@ AST_MODULE_RELOAD_UNINITIALIZED
#define ast_module_running_ref(mod)
Hold a reference to the module if it is running.
@ AST_MODULE_LOAD_FAILURE
Module could not be loaded properly.
@ AST_MODULE_LOAD_SUCCESS
enum ast_module_reload_result ast_module_reload(const char *name)
Reload asterisk modules.
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized,...
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
static void ast_sockaddr_setnull(struct ast_sockaddr *addr)
Sets address addr to null.
struct timeval ast_lastreloadtime
struct timeval ast_startuptime
#define ast_opt_sounds_search_custom
Asterisk file paths, configured in asterisk.conf.
const char * ast_config_AST_RUN_GROUP
const char * ast_config_AST_RUN_USER
const char * ast_config_AST_MODULE_DIR
const char * ast_config_AST_CONFIG_DIR
const char * ast_config_AST_SYSTEM_NAME
Core PBX routines and definitions.
int ast_findlabel_extension(struct ast_channel *c, const char *context, const char *exten, const char *label, const char *callerid)
Find the priority of an extension that has the specified label.
int ast_pbx_outgoing_exten_predial(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, int early_media, const struct ast_assigned_ids *assignedids, const char *predial_callee)
const char * ast_extension_state2str(int extension_state)
Return string representation of the state of an extension.
int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, const struct ast_assigned_ids *assignedids)
Synchronously or asynchronously make an outbound call and execute an application on the channel.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, int early_media, const struct ast_assigned_ids *assignedids)
Synchronously or asynchronously make an outbound call and send it to a particular extension.
int ast_processed_calls(void)
Retrieve the total number of calls processed through the PBX since last restart.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_func_read(struct ast_channel *chan, const char *function, char *workspace, size_t len)
executes a read operation on a function
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp)
Retrieve the value of a builtin variable or variable from the channel variable stack.
@ AST_HINT_UPDATE_PRESENCE
int ast_extension_state_add(const char *context, const char *exten, ast_state_cb_type change_cb, void *data)
Add watcher for extension states.
int ast_get_hint(char *hint, int hintsize, char *name, int namesize, struct ast_channel *c, const char *context, const char *exten)
If an extension hint exists, return non-zero.
int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
int ast_extension_state(struct ast_channel *c, const char *context, const char *exten)
Uses hint and devicestate callback to get the state of an extension.
Presence state management.
const char * ast_presence_state2str(enum ast_presence_state state)
Convert presence state to text string for output.
static struct templates templates
struct stasis_forward * sub
Pluggable RTP Architecture.
struct stasis_topic * ast_rtp_topic(void)
Stasis Message Bus API topic for RTP and RTCP related messages
Security Event Reporting API.
int ast_security_event_report(const struct ast_security_event_common *sec)
Report a security event.
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
#define AST_SECURITY_EVENT_CHAL_RESP_FAILED_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_SESSION_LIMIT_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_REQ_NOT_ALLOWED_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_REQ_BAD_FORMAT_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_FAILED_ACL_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_INVAL_PASSWORD_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_INVAL_ACCT_ID_VERSION
Event descriptor version.
@ AST_SECURITY_EVENT_INVAL_PASSWORD
An attempt at basic password authentication failed.
@ AST_SECURITY_EVENT_SESSION_LIMIT
Session limit reached.
@ AST_SECURITY_EVENT_FAILED_ACL
Failed ACL.
@ AST_SECURITY_EVENT_REQ_NOT_ALLOWED
A request was made that is not allowed.
@ AST_SECURITY_EVENT_CHAL_RESP_FAILED
An attempt at challenge/response authentication failed.
@ AST_SECURITY_EVENT_REQ_BAD_FORMAT
Request received with bad formatting.
@ AST_SECURITY_EVENT_SUCCESSFUL_AUTH
FYI FWIW, Successful authentication has occurred.
@ AST_SECURITY_EVENT_INVAL_ACCT_ID
Invalid Account ID.
#define AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION
Event descriptor version.
struct ast_manager_event_blob * stasis_message_to_ami(struct stasis_message *msg)
Build the AMI representation of the message.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
@ STASIS_SUBSCRIPTION_FILTER_SELECTIVE
struct stasis_forward * stasis_forward_cancel(struct stasis_forward *forward)
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
@ STASIS_SUBSCRIPTION_FORMATTER_AMI
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
struct stasis_forward * stasis_forward_all(struct stasis_topic *from_topic, struct stasis_topic *to_topic)
Create a subscription which forwards all messages from one topic to another.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
#define stasis_subscribe(topic, callback, data)
int stasis_message_can_be_ami(struct stasis_message *msg)
Determine if the given message can be converted to AMI.
struct ast_bridge_snapshot * ast_bridge_get_snapshot_by_uniqueid(const char *bridge_id)
Returns the current snapshot for the bridge.
int stasis_message_router_set_congestion_limits(struct stasis_message_router *router, long low_water, long high_water)
Set the high and low alert water marks of the stasis message router.
#define stasis_message_router_create(topic)
Create a new message router object.
int stasis_message_router_add(struct stasis_message_router *router, struct stasis_message_type *message_type, stasis_subscription_cb callback, void *data)
Add a route to a message router.
void stasis_message_router_unsubscribe_and_join(struct stasis_message_router *router)
Unsubscribe the router from the upstream topic, blocking until the final message has been processed.
void stasis_message_router_set_formatters_default(struct stasis_message_router *router, stasis_subscription_cb callback, void *data, enum stasis_subscription_message_formatters formatters)
Sets the default route of a router with formatters.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define ast_string_field_ptr_build_va(x, ptr, fmt, args)
Set a field to a complex (built) value with prebuilt va_lists.
#define AST_STRING_FIELD(name)
Declare a string field.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
String manipulation functions.
@ AST_DYNSTR_BUILD_FAILED
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
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.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
static int force_inline attribute_pure ast_ends_with(const char *str, const char *suffix)
Checks whether a string ends with another.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"....
#define ast_str_alloca(init_len)
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
int ast_in_delimited_string(const char *needle, const char *haystack, char delim)
Check if there is an exact match for 'needle' between delimiters in 'haystack'.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
int ast_str_append_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap)
Append to a dynamic string using a va_list.
char * ast_read_line_from_buffer(char **buffer)
Read lines from a string buffer.
#define AST_YESNO(x)
return Yes or No depending on the argument.
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
char * ast_escape_c_alloc(const char *s)
Escape standard 'C' sequences in the given string.
struct ao2_container * ast_str_container_alloc_options(enum ao2_alloc_opts opts, int buckets)
Allocates a hash container for bare strings.
int ast_str_container_add(struct ao2_container *str_container, const char *add)
Adds a string to a string container allocated by ast_str_container_alloc.
char * ast_strsep(char **s, const char sep, uint32_t flags)
Act like strsep but ignore separators inside quotes.
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
int ast_regex_string_to_regex_pattern(const char *regex_string, struct ast_str **regex_pattern)
Given a string regex_string in the form of "/regex/", convert it into the form of "regex".
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
list of actions registered
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Wrapper for an ast_acl linked list.
Structure to pass both assignedid values to channel drivers.
Structure that contains a snapshot of information about a bridge.
struct ao2_container * channels
Structure that contains information about a bridge.
const ast_string_field uniqueid
struct ast_category * prev
struct timeval creationtime
const ast_string_field uniqueid
const ast_string_field name
const ast_string_field data
const ast_string_field appl
Structure representing a snapshot of channel state.
struct ast_channel_snapshot_dialplan * dialplan
struct ast_channel_snapshot_bridge * bridge
struct ast_channel_snapshot_base * base
Main Channel structure associated with a channel.
const ast_string_field name
descriptor for a cli entry.
enum ast_frame_read_action action
Data structure associated with a custom dialplan function.
Structure for a data store type.
Structure for a data store object.
const struct ast_datastore_info * info
Structure used to handle boolean flags.
Data structure associated with a single frame of data.
Definition of a URI handler.
Iterator for JSON object key/values.
Abstract JSON element (object, array, string, int, ...).
Struct containing info for an AMI event to send out.
const ast_string_field extra_fields
const char * manager_event
user descriptor, as read from the config file.
struct ast_variable * chanvars
struct ao2_container * excludefilters
struct ast_acl_list * acl
struct ao2_container * includefilters
Structure used to transport a message through the frame core.
Structure for mutex and tracking information.
Information needed to identify an endpoint in a call.
struct ast_party_name name
Subscriber name.
struct ast_party_number number
Subscriber phone number.
unsigned char valid
TRUE if the name information is valid/present.
char * str
Subscriber name (Malloced)
unsigned char valid
TRUE if the number information is valid/present.
char * str
Subscriber phone number (Malloced)
An attempt at challenge/response auth failed.
const char * response
Response received.
struct ast_security_event_common common
Common security event descriptor elements.
const char * expected_response
Response expected to be received.
enum ast_security_event_type event_type
The security event sub-type.
Checking against an IP access control list failed.
struct ast_security_event_common common
Common security event descriptor elements.
Invalid account ID specified (invalid username, for example)
struct ast_security_event_common common
Common security event descriptor elements.
An attempt at basic password auth failed.
struct ast_security_event_common common
Common security event descriptor elements.
Request denied because it's not allowed.
struct ast_security_event_common common
Common security event descriptor elements.
const char * request_type
Request type that was made.
Request denied because of a session limit.
Successful authentication.
struct ast_security_event_common common
Common security event descriptor elements.
Socket address structure.
Support for dynamic strings.
arguments for the accepting thread
struct ast_sockaddr local_address
struct ast_tls_config * tls_cfg
describes a server instance
struct ast_iostream * stream
struct ast_sockaddr remote_address
struct ast_tcptls_session_args * parent
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
Struct that contains the XML documentation for a particular item. Note that this is an ao2 ref counte...
struct ast_xml_doc_item * next
struct ast_str * arguments
struct ast_str * description
const ast_string_field name
struct ast_str * synopsis
unsigned int event_name_hash
enum event_filter_match_type match_type
helper function for originate
struct ast_variable * vars
struct ast_format_cap * cap
const ast_string_field description
struct ast_module * module
struct ast_xml_doc_item * final_response
const ast_string_field synopsis
int(* func)(struct mansession *s, const struct message *m)
const ast_string_field seealso
const ast_string_field syntax
unsigned int registered
TRUE if the AMI action is registered and the callback can be called.
const ast_string_field arguments
struct ast_xml_doc_item * list_responses
struct ast_variable * chanvars
struct ao2_container * excludefilters
struct ast_iostream * stream
struct timeval sessionstart_tv
struct eventqent * last_ev
struct mansession_session::mansession_datastores datastores
struct mansession_session::@372 list
struct ao2_container * includefilters
In case you didn't read that giant block of text above the mansession_session struct,...
struct ast_iostream * stream
struct manager_custom_hook * hook
struct mansession_session * session
enum mansession_message_parsing parsing
struct ast_tcptls_session_instance * tcptls_session
const char * headers[AST_MAX_MANHEADERS]
structure to hold users read from users.conf
list of users found in the config file
An API for managing task processing threads that can be shared across modules.
#define AST_TASKPROCESSOR_HIGH_WATER_LEVEL
Generic support for tcp/tls servers in Asterisk.
void * ast_tcptls_server_root(void *)
void ast_tcptls_server_stop(struct ast_tcptls_session_args *desc)
Shutdown a running server if there is one.
int ast_ssl_setup(struct ast_tls_config *cfg)
Set up an SSL server.
void ast_tcptls_server_start(struct ast_tcptls_session_args *desc)
This is a generic (re)start routine for a TCP server, which does the socket/bind/listen and starts a ...
int ast_tls_read_conf(struct ast_tls_config *tls_cfg, struct ast_tcptls_session_args *tls_desc, const char *varname, const char *value)
Used to parse conf files containing tls/ssl options.
Handy terminal functions for vt* terms.
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
Colorize a specified string by adding terminal color codes.
char * term_strip(char *outbuf, const char *inbuf, int maxout)
Remove colorings from a specified string.
#define ast_test_debug(test, fmt,...)
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
#define AST_TEST_DEFINE(hdr)
static struct aco_type item
Definitions to aid in the use of thread local storage.
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
int64_t ast_tvdiff_sec(struct timeval end, struct timeval start)
Computes the difference (in seconds) between two struct timeval instances.
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Support for translation of data formats. translate.c.
const char * ast_translate_path_to_str(struct ast_trans_pvt *t, struct ast_str **str)
Puts a string representation of the translation path into outbuf.
int error(const char *format,...)
#define ast_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
int ast_wait_for_input(int fd, int ms)
int ast_parse_digest(const char *digest, struct ast_http_digest *d, int request, int pedantic)
Parse digest authorization header.
long int ast_random(void)
#define ast_pthread_create_detached(a, b, c, d)
#define ast_set_flag(p, flag)
void ast_md5_hash(char *output, const char *input)
Produces MD5 hash based on input string.
struct ast_xml_doc_item * ast_xmldoc_build_list_responses(const char *type, const char *name, const char *module)
Generate the [list responses] tag based on type of node ('application', 'function' or 'agi') and name...
char * ast_xmldoc_build_description(const char *type, const char *name, const char *module)
Generate description documentation from XML.
char * ast_xmldoc_build_syntax(const char *type, const char *name, const char *module)
Get the syntax for a specified application or function.
char * ast_xmldoc_build_arguments(const char *type, const char *name, const char *module)
Generate the [arguments] tag based on type of node ('application', 'function' or 'agi') and name.
char * ast_xmldoc_build_synopsis(const char *type, const char *name, const char *module)
Generate synopsis documentation from XML.
struct ao2_container * ast_xmldoc_build_documentation(const char *type)
Build the documentation for a particular source type.
char * ast_xmldoc_build_seealso(const char *type, const char *name, const char *module)
Parse the <see-also> node content.
char * ast_xmldoc_printable(const char *bwinput, int withcolors)
Colorize and put delimiters (instead of tags) to the xmldoc output.
struct ast_xml_doc_item * ast_xmldoc_build_final_response(const char *type, const char *name, const char *module)
Generate the [final response] tag based on type of node ('application', 'function' or 'agi') and name...