116#define AST_CLI_INITLEN 256
139 unsigned int res = 0;
143 if (!strcasecmp(ml->module, module)) {
156 unsigned int res = 0;
160 if (!strcasecmp(ml->module, module)) {
198 if (gid < 0 && uid < 0) {
204 if (user_perm->
gid != gid && user_perm->
uid != uid) {
210 ispattern = !regcomp(®exbuf, perm->
command, REG_EXTENDED | REG_NOSUB | REG_ICASE);
211 if (ispattern && regexec(®exbuf,
command, 0,
NULL, 0)) {
220 if (user_perm->
uid == uid) {
247 "Usage: module load <module name>\n"
248 " Loads the specified module into Asterisk.\n";
252 if (
a->pos != e->
args) {
257 if (
a->argc != e->
args + 1) {
261 ast_cli(
a->fd,
"Unable to load module %s\n",
a->argv[e->
args]);
276 "Usage: module reload [module ...]\n"
277 " Reloads configuration files for all listed modules which support\n"
278 " reloading, or for all supported modules if none are listed.\n";
284 if (
a->argc == e->
args) {
288 for (x = e->
args; x < a->argc; x++) {
292 ast_cli(
a->fd,
"No such module '%s'\n",
a->argv[x]);
295 ast_cli(
a->fd,
"The module '%s' does not support reloads\n",
a->argv[x]);
298 ast_cli(
a->fd,
"Asterisk cannot reload a module yet; request queued\n");
301 ast_cli(
a->fd,
"The module '%s' reported a reload failure\n",
a->argv[x]);
304 ast_cli(
a->fd,
"A module reload request is already in progress; please be patient\n");
307 ast_cli(
a->fd,
"The module '%s' was not properly initialized. Before reloading"
308 " the module, you must run \"module load %s\" and fix whatever is"
309 " preventing the module from being initialized.\n",
a->argv[x],
a->argv[x]);
312 ast_cli(
a->fd,
"Module '%s' reloaded successfully.\n",
a->argv[x]);
325 "Usage: core reload\n"
326 " Execute a global reload.\n";
333 if (
a->argc != e->
args) {
356 if (!strcasecmp(ml->module, module))
366 unsigned int prospective[2];
367 unsigned int part = strtoul(partial,
NULL, 10);
370 if (part < min || part >
max) {
374 for (i = 0; i < 21; i++) {
376 prospective[0] = prospective[1] = part;
380 prospective[0] = prospective[1] = part * 10 + (i - 1);
382 prospective[0] = (part * 10 + (i - 11)) * 10;
383 prospective[1] = prospective[0] + 9;
385 if (i < 11 && (prospective[0] <
min || prospective[0] >
max)) {
387 }
else if (prospective[1] <
min || prospective[0] >
max) {
393 snprintf(next,
sizeof(next),
"%u", prospective[0]);
395 snprintf(next,
sizeof(next),
"%u...", prospective[0] / 10);
403#define DEBUG_HANDLER 0
404#define TRACE_HANDLER 1
405#define VERBOSE_HANDLER 2
411 const char *what =
"";
421 what =
"Console verbose";
426 snprintf(was_buf,
sizeof(was_buf),
"%d", old_val);
432 if (old_val == cur_val) {
433 ast_cli(
a->fd,
"%s is still %s.\n", what, was);
439 snprintf(now_buf,
sizeof(now_buf),
"%d", cur_val);
445 ast_cli(
a->fd,
"%s was %s and is now %s.\n", what, was, now);
456 unsigned int module_option;
458 const char *handler_name;
460 if (
a->argc <= e->
args) {
468 handler_name =
"debug";
473 handler_name =
"trace";
476 if (
a->argc == e->
args + 1 && !strcasecmp(
a->argv[e->
args],
"off")) {
479 if (!strcasecmp(
a->argv[e->
args],
"atleast")) {
483 if (
a->argc != e->
args + atleast + 1 &&
a->argc != e->
args + atleast + 2) {
487 if (sscanf(
a->argv[e->
args + atleast],
"%30d", &newlevel) != 1) {
491 if (
a->argc == e->
args + atleast + 2) {
494 int mod_len = strlen(mod);
496 if (3 < mod_len && !strcasecmp(mod + mod_len - 3,
".so")) {
497 mod[mod_len - 3] =
'\0';
507 ast_cli(
a->fd,
"Core %s is still 0 for '%s'.\n", handler_name, mod);
515 ast_cli(
a->fd,
"Core %s was %u and has been set to 0 for '%s'.\n", handler_name,
522 if ((atleast && newlevel < ml->level) || ml->
level == newlevel) {
523 ast_cli(
a->fd,
"Core %s is still %u for '%s'.\n", handler_name, ml->
level, mod);
528 ml->
level = newlevel;
530 ml =
ast_calloc(1,
sizeof(*ml) + strlen(mod) + 1);
536 ml->
level = newlevel;
537 strcpy(ml->module, mod);
542 ast_cli(
a->fd,
"Core %s was %d and has been set to %u for '%s'.\n", handler_name,
543 oldval, ml->
level, ml->module);
561 oldval = *core_option;
562 if (!atleast || newlevel > *core_option) {
563 *core_option = newlevel;
575 const char *argv3 =
a->argv ?
S_OR(
a->argv[3],
"") :
"";
581 "Usage: core set debug [atleast] <level> [module]\n"
582 " core set debug off\n"
584 " Sets level of debug messages to be displayed or\n"
585 " sets a module name to display debug messages from.\n"
586 " 0 or off means no messages should be displayed.\n"
587 " Equivalent to -d[d[...]] on startup\n";
591 if (!strcasecmp(argv3,
"category")) {
595 if (!strcasecmp(argv3,
"atleast")) {
598 if (
a->pos == 3 || (
a->pos == 4 && atleast)) {
599 const char *pos =
a->pos == 3 ? argv3 :
S_OR(
a->argv[4],
"");
600 int numbermatch = (
ast_strlen_zero(pos) || strchr(
"123456789", pos[0])) ? 0 : 21;
602 if (
a->n < 21 && numbermatch == 0) {
604 }
else if (pos[0] ==
'0') {
608 }
else if (
a->n == (21 - numbermatch)) {
609 if (
a->pos == 3 && !strncasecmp(argv3,
"off", strlen(argv3))) {
611 }
else if (
a->pos == 3 && !strncasecmp(argv3,
"atleast", strlen(argv3))) {
614 }
else if (
a->n == (22 - numbermatch) &&
a->pos == 3 &&
ast_strlen_zero(argv3)) {
617 }
else if ((
a->pos == 4 && !atleast && strcasecmp(argv3,
"off") && strcasecmp(argv3,
"channel"))
618 || (
a->pos == 5 && atleast)) {
633 const char *argv3 =
a->argv ?
S_OR(
a->argv[3],
"") :
"";
639 "Usage: core set trace [atleast] <level> [module]\n"
640 " core set trace off\n"
642 " Sets level of trace messages to be displayed or\n"
643 " sets a module name to display trace messages from.\n"
644 " 0 or off means no messages should be displayed.\n";
648 if (!strcasecmp(argv3,
"atleast")) {
651 if (
a->pos == 3 || (
a->pos == 4 && atleast)) {
652 const char *pos =
a->pos == 3 ? argv3 :
S_OR(
a->argv[4],
"");
653 int numbermatch = (
ast_strlen_zero(pos) || strchr(
"123456789", pos[0])) ? 0 : 21;
655 if (
a->n < 21 && numbermatch == 0) {
657 }
else if (pos[0] ==
'0') {
661 }
else if (
a->n == (21 - numbermatch)) {
662 if (
a->pos == 3 && !strncasecmp(argv3,
"off", strlen(argv3))) {
664 }
else if (
a->pos == 3 && !strncasecmp(argv3,
"atleast", strlen(argv3))) {
667 }
else if (
a->n == (22 - numbermatch) &&
a->pos == 3 &&
ast_strlen_zero(argv3)) {
670 }
else if ((
a->pos == 4 && !atleast && strcasecmp(argv3,
"off") && strcasecmp(argv3,
"channel"))
671 || (
a->pos == 5 && atleast)) {
689 const char *argv3 =
a->argv ?
S_OR(
a->argv[3],
"") :
"";
693 e->
command =
"core set verbose";
695 "Usage: core set verbose [atleast] <level> [silent]\n"
696 " core set verbose off\n"
698 " Sets level of verbose messages to be displayed.\n"
699 " 0 or off means no verbose messages should be displayed.\n"
700 " The silent option means the command does not report what\n"
701 " happened to the verbose level.\n"
702 " Equivalent to -v[v[...]] on startup\n";
706 if (!strcasecmp(argv3,
"atleast")) {
709 if (
a->pos == 3 || (
a->pos == 4 && atleast)) {
710 const char *pos =
a->pos == 3 ? argv3 :
S_OR(
a->argv[4],
"");
711 int numbermatch = (
ast_strlen_zero(pos) || strchr(
"123456789", pos[0])) ? 0 : 21;
713 if (
a->n < 21 && numbermatch == 0) {
715 }
else if (pos[0] ==
'0') {
719 }
else if (
a->n == (21 - numbermatch)) {
720 if (
a->pos == 3 && !strncasecmp(argv3,
"off", strlen(argv3))) {
722 }
else if (
a->pos == 3 && !strncasecmp(argv3,
"atleast", strlen(argv3))) {
725 }
else if (
a->n == (22 - numbermatch) &&
a->pos == 3 &&
ast_strlen_zero(argv3)) {
728 }
else if ((
a->pos == 4 && !atleast && strcasecmp(argv3,
"off"))
729 || (
a->pos == 5 && atleast)) {
730 const char *pos =
S_OR(
a->argv[
a->pos],
"");
732 if (
a->n == 0 && !strncasecmp(pos,
"silent", strlen(pos))) {
742 if (
a->argc <= e->
args) {
746 if (
a->argc == e->
args + 1 && !strcasecmp(
a->argv[e->
args],
"off")) {
749 if (!strcasecmp(
a->argv[e->
args],
"atleast")) {
752 if (
a->argc == e->
args + atleast + 2
753 && !strcasecmp(
a->argv[e->
args + atleast + 1],
"silent")) {
756 if (
a->argc != e->
args + atleast + silent + 1) {
759 if (sscanf(
a->argv[e->
args + atleast],
"%30d", &newlevel) != 1) {
766 if (!atleast || newlevel > oldval) {
789 "Usage: logger mute\n"
790 " Disables logging output to the current console, making it possible to\n"
791 " gather information without being disturbed by scrolling lines.\n";
797 if (
a->argc < 2 ||
a->argc > 3)
800 if (
a->argc == 3 && !strcasecmp(
a->argv[2],
"silent"))
815 "Usage: module refresh <module name>\n"
816 " Unloads and loads the specified module into Asterisk.\n";
820 if (
a->pos != e->
args) {
825 if (
a->argc != e->
args + 1) {
829 ast_cli(
a->fd,
"Unable to unload resource %s\n",
a->argv[e->
args]);
833 ast_cli(
a->fd,
"Unable to load module %s\n",
a->argv[e->
args]);
836 ast_cli(
a->fd,
"Unloaded and loaded %s\n",
a->argv[e->
args]);
851 "Usage: module unload [-f|-h] <module_1> [<module_2> ... ]\n"
852 " Unloads the specified module from Asterisk. The -f\n"
853 " option causes the module to be unloaded even if it is\n"
854 " in use (may cause a crash) and the -h module causes the\n"
855 " module to be unloaded even if the module says it cannot, \n"
856 " which almost always will cause a crash.\n";
862 if (
a->argc < e->
args + 1)
869 else if (s[1] ==
'h')
873 if (
a->argc < e->
args + 2)
878 for (; x <
a->argc; x++) {
880 ast_cli(
a->fd,
"Unable to unload resource %s\n",
a->argv[x]);
883 ast_cli(
a->fd,
"Unloaded %s\n",
a->argv[x]);
889#define MODLIST_FORMAT "%-30s %-40.40s %-10d %-11s %13s\n"
890#define MODLIST_FORMAT2 "%-30s %-40.40s %-10s %-11s %13s\n"
914#define MINUTE (SECOND*60)
915#define HOUR (MINUTE*60)
918#define YEAR (DAY*365)
919#define NEEDCOMMA(x) ((x) ? ", " : "")
920 if (timeval.tv_sec < 0)
928 if (timeval.tv_sec >
YEAR) {
929 x = (timeval.tv_sec /
YEAR);
930 timeval.tv_sec -= (x *
YEAR);
933 if (timeval.tv_sec >
WEEK) {
934 x = (timeval.tv_sec /
WEEK);
935 timeval.tv_sec -= (x *
WEEK);
938 if (timeval.tv_sec >
DAY) {
939 x = (timeval.tv_sec /
DAY);
940 timeval.tv_sec -= (x *
DAY);
943 if (timeval.tv_sec >
HOUR) {
944 x = (timeval.tv_sec /
HOUR);
945 timeval.tv_sec -= (x *
HOUR);
948 if (timeval.tv_sec >
MINUTE) {
949 x = (timeval.tv_sec /
MINUTE);
950 timeval.tv_sec -= (x *
MINUTE);
977 e->
command =
"core show uptime [seconds]";
979 "Usage: core show uptime [seconds]\n"
980 " Shows Asterisk uptime information.\n"
981 " The seconds word returns the uptime in seconds only.\n";
988 if (
a->argc == e->
args && !strcasecmp(
a->argv[e->
args-1],
"seconds"))
990 else if (
a->argc == e->
args-1)
1009 e->
command =
"module show [like]";
1011 "Usage: module show [like keyword]\n"
1012 " Shows Asterisk modules currently in use, and usage statistics.\n";
1016 if (
a->pos == e->
args) {
1025 if (
a->argc == e->
args - 1)
1027 else if (
a->argc == e->
args + 1 && !strcasecmp(
a->argv[e->
args-1],
"like") )
1028 like =
a->argv[e->
args];
1040#undef MODLIST_FORMAT
1041#undef MODLIST_FORMAT2
1045 static const char *
const completions[] = {
"seconds",
NULL };
1047 int showuptime, printsec;
1051 e->
command =
"core show calls [uptime]";
1053 "Usage: core show calls [uptime [seconds]]\n"
1054 " Lists number of currently active calls and total number of calls\n"
1055 " processed through PBX since last restart. If 'uptime' is specified\n"
1056 " the system uptime is also displayed. If 'seconds' is specified in\n"
1057 " addition to 'uptime', the system uptime is displayed in seconds.\n";
1061 if (
a->pos != e->
args)
1067 if (
a->argc >= e->
args && !strcasecmp(
a->argv[e->
args-1],
"uptime")) {
1070 if (
a->argc == e->
args+1 && !strcasecmp(
a->argv[e->
args],
"seconds"))
1072 else if (
a->argc == e->
args)
1076 }
else if (
a->argc == e->
args-1) {
1083 ast_cli(
a->fd,
"%d of %d max active call%s (%5.2f%% of capacity)\n",
1101#define FORMAT_STRING "%-64.64s %-32.32s %-7.7s %-30.30s\n"
1102#define FORMAT_STRING2 "%-64.64s %-32.32s %-7.7s %-30.30s\n"
1103#define CONCISE_FORMAT_STRING "%s!%s!%s!%d!%s!%s!%s!%s!%s!%s!%d!%s!%s!%s\n"
1104#define VERBOSE_FORMAT_STRING "%-80.80s %-24.24s %-24.24s %4d %-7.7s %-12.12s %-25.25s %-15.15s %8.8s %-11.11s %-11.11s %-20.20s\n"
1105#define VERBOSE_FORMAT_STRING2 "%-80.80s %-24.24s %-24.24s %-4.4s %-7.7s %-12.12s %-25.25s %-15.15s %8.8s %-11.11s %-11.11s %-20.20s\n"
1110 int numchans = 0, concise = 0, verbose = 0, count = 0;
1114 e->
command =
"core show channels [concise|verbose|count]";
1116 "Usage: core show channels [concise|verbose|count]\n"
1117 " Lists currently defined channels and some information about them. If\n"
1118 " 'concise' is specified, the format is abridged and in a more easily\n"
1119 " machine parsable format. If 'verbose' is specified, the output includes\n"
1120 " more and longer fields. If 'count' is specified only the channel and call\n"
1121 " count is output.\n";
1128 if (
a->argc == e->
args) {
1129 if (!strcasecmp(
a->argv[e->
args-1],
"concise"))
1131 else if (!strcasecmp(
a->argv[e->
args-1],
"verbose"))
1133 else if (!strcasecmp(
a->argv[e->
args-1],
"count"))
1137 }
else if (
a->argc != e->
args - 1)
1143 if (!concise && !verbose)
1147 "CallerID",
"Duration",
"Accountcode",
"PeerAccount",
"BridgeID");
1152 char durbuf[16] =
"-";
1158 int durh = duration / 3600;
1159 int durm = (duration % 3600) / 60;
1160 int durs = duration % 60;
1161 snprintf(durbuf,
sizeof(durbuf),
"%02d:%02d:%02d", durh, durm, durs);
1163 snprintf(durbuf,
sizeof(durbuf),
"%d", duration);
1177 }
else if (verbose) {
1187 char locbuf[40] =
"(None)";
1188 char appdata[40] =
"(None)";
1204 ast_cli(
a->fd,
"%d active channel%s\n", numchans,
ESS(numchans));
1206 ast_cli(
a->fd,
"%d of %d max active call%s (%5.2f%% of capacity)\n",
1219#undef FORMAT_STRING2
1220#undef CONCISE_FORMAT_STRING
1221#undef VERBOSE_FORMAT_STRING
1222#undef VERBOSE_FORMAT_STRING2
1228 static const char *
const completions[] = {
"all",
NULL };
1233 e->
command =
"channel request hangup";
1235 "Usage: channel request hangup <channel>|<all>\n"
1236 " Request that a channel be hung up. The hangup takes effect\n"
1237 " the next time the driver reads or writes from the channel.\n"
1238 " If 'all' is specified instead of a channel name, all channels\n"
1239 " will see the hangup request.\n";
1242 if (
a->pos != e->
args) {
1256 if (!strcasecmp(
a->argv[3],
"all")) {
1275 ast_cli(
a->fd,
"%s is not a known channel\n",
a->argv[3]);
1286 struct passwd *pw =
NULL;
1291 e->
command =
"cli show permissions";
1293 "Usage: cli show permissions\n"
1294 " Shows CLI configured permissions.\n";
1303 pw = getpwuid(cp->
uid);
1305 ast_cli(
a->fd,
"user: %s [uid=%d]\n", pw->pw_name, cp->
uid);
1308 gr = getgrgid(cp->
gid);
1310 ast_cli(
a->fd,
"group: %s [gid=%d]\n", gr->gr_name, cp->
gid);
1331 e->
command =
"cli reload permissions";
1333 "Usage: cli reload permissions\n"
1334 " Reload the 'cli_permissions.conf' file.\n";
1348 struct passwd *pw =
NULL;
1350 int gid = -1, uid = -1;
1358 e->
command =
"cli check permissions";
1360 "Usage: cli check permissions {<username>|@<groupname>|<username>@<groupname>} [<command>]\n"
1361 " Check permissions config for a user@group or list the allowed commands for the specified user.\n"
1362 " The username or the groupname may be omitted.\n";
1366 return ast_cli_generator(
a->line + strlen(
"cli check permissions") + strlen(
a->argv[3]) + 1,
a->word,
a->n);
1378 gr = getgrnam(&
group[1]);
1388 ast_cli(
a->fd,
"You didn't supply a username\n");
1408 ast_cli(
a->fd,
"You are not allowed to run any command on Asterisk\n");
1412 ast_cli(
a->fd,
"%s '%s%s%s' is %s to run command: '%s'\n", uid >= 0 ?
"User" :
"Group",
tmp,
1413 group && uid >= 0 ?
"@" :
"",
1433 e->
command =
"_command matchesarray";
1435 "Usage: _command matchesarray \"<line>\" text \n"
1436 " This function is used internally to help with command completion and should.\n"
1437 " never be called by the user directly.\n";
1450 for (x=0; matches[x]; x++) {
1451 matchlen = strlen(matches[x]) + 1;
1452 if (
len + matchlen >= buflen) {
1453 buflen += matchlen * 3;
1460 len += sprintf(
buf +
len,
"%s ", matches[x]);
1497 ast_cli(
args->fd,
"Debugging %s on channel %s\n",
args->is_off ?
"disabled" :
"enabled",
1509 static const char *
const completions_all[] = {
"all",
NULL };
1510 static const char *
const completions_off[] = {
"off",
NULL };
1517 e->
command =
"core set debug channel";
1519 "Usage: core set debug channel <all|channel> [off]\n"
1520 " Enables/disables debugging on all or on a specific channel.\n";
1529 }
else if (
a->pos == 5) {
1539 }
else if (
a->argc == e->
args + 2) {
1541 if (!strcasecmp(
a->argv[e->
args + 1],
"off"))
1545 }
else if (
a->argc != e->
args + 1) {
1549 if (!strcasecmp(
"all",
a->argv[e->
args])) {
1567 ast_cli(
a->fd,
"Debugging on new channels is %s\n",
args.is_off ?
"disabled" :
"enabled");
1574 const char *argv4 =
a->argv ?
S_OR(
a->argv[4],
"") :
"";
1575 int offset = strncasecmp(argv4,
"off", strlen(argv4)) ? 0 : 1;
1579 e->
command =
"core set debug category";
1581 "Usage: core set debug category <category>[:<sublevel>] [category[:<sublevel] ...]\n"
1582 " core set debug category off [<category> [<category>] ...]\n\n"
1583 " Allows enabling and disabling debug logging categories.\n"
1584 " When a category is enabled all relevant debug messages are logged\n"
1585 " for a given category. However, if a sublevel is specified only\n"
1586 " those categorized messages at or below the coded debug sublevel\n"
1591 if (
a->pos < e->
args) {
1595 if (
a->pos == 4 && offset) {
1600 a->pos - e->
args,
a->word,
a->n - 1);
1603 if (
a->argc <= e->
args) {
1619 e->
command =
"no debug channel";
1628 if (
a->argc != e->
args + 1)
1647 long elapsed_seconds=0;
1648 int hour=0,
min=0, sec=0;
1655 char callid_buf[32];
1660 e->
command =
"core show channel";
1662 "Usage: core show channel <channel>\n"
1663 " Shows lots of information about the specified channel.\n";
1680 ast_cli(
a->fd,
"%s is not a known channel\n",
a->argv[3]);
1697 hour = elapsed_seconds / 3600;
1698 min = (elapsed_seconds % 3600) / 60;
1699 sec = elapsed_seconds % 60;
1700 snprintf(cdrtime,
sizeof(cdrtime),
"%dh%dm%ds", hour,
min, sec);
1702 strcpy(cdrtime,
"N/A");
1709 callid_buf[0] =
'\0';
1722 " Caller ID Name: %s\n"
1723 "Connected Line ID: %s\n"
1724 "Connected Line ID Name: %s\n"
1725 "Eff. Connected Line ID: %s\n"
1726 "Eff. Connected Line ID Name: %s\n"
1727 " DNID Digits: %s\n"
1730 " NativeFormats: %s\n"
1731 " WriteFormat: %s\n"
1733 " WriteTranscode: %s %s\n"
1734 " ReadTranscode: %s %s\n"
1735 " Time to Hangup: %ld\n"
1736 " Elapsed Time: %s\n"
1742 " Call Group: %llu\n"
1743 " Pickup Group: %llu\n"
1744 " Application: %s\n"
1746 " Call Identifer: %s\n",
1776 bridge ? bridge->
uniqueid :
"(Not bridged)",
1784 S_OR(callid_buf,
"(None)")
1819 for(v = metadata; v; v = v->
next) {
1843 int i, which = 0,
len;
1846 for (i = 0; choices[i]; i++) {
1847 if ((!
len || !strncasecmp(
word, choices[i],
len)) && ++which >
state) {
1862 int wordlen = strlen(
word), which = 0;
1897#define FORMAT_STRING "%-25s %-20s %-20s\n"
1902 int havepattern = 0;
1906 e->
command =
"group show channels";
1908 "Usage: group show channels [pattern]\n"
1909 " Lists all currently active channels with channel group(s) specified.\n"
1910 " Optional regular expression pattern is matched to group names for each\n"
1917 if (
a->argc < 3 ||
a->argc > 4)
1921 if (regcomp(®exbuf,
a->argv[3], REG_EXTENDED | REG_NOSUB))
1932 if (!havepattern || !regexec(®exbuf, gi->
group, 0,
NULL, 0)) {
1944 ast_cli(
a->fd,
"%d active channel%s\n", numchans,
ESS(numchans));
1953 e->
command =
"core waitfullybooted";
1955 "Usage: core waitfullybooted\n"
1956 " Wait until Asterisk has fully booted.\n";
1966 ast_cli(
a->fd,
"Asterisk has fully booted.\n");
1972#ifdef HAVE_MALLOC_TRIM
1988 extern int malloc_trim(
size_t __pad) __THROW;
1994 "Usage: malloc trim\n"
1995 " Try to give excess memory back to the OS.\n";
2001 if (malloc_trim(0)) {
2002 ast_cli(
a->fd,
"Returned some memory to the OS.\n");
2004 ast_cli(
a->fd,
"No memory returned to the OS.\n");
2040#ifdef HAVE_MALLOC_TRIM
2077 for (i = 0; e->
cmda[i]; i++)
2112 ast_log(
LOG_NOTICE,
"You must wait until last 'cli reload permissions' command finish\n");
2129 if (!strcasecmp(cat,
"general")) {
2132 if (!strcasecmp(v->
name,
"default_perm")) {
2141 if (cat[0] ==
'@') {
2143 gr = getgrnam(&cat[1]);
2160 if ((pw && cp_entry->
uid == pw->pw_uid) || (gr && cp_entry->
gid == gr->gr_gid)) {
2163 user_group = cp_entry;
2171 user_group =
ast_calloc(1,
sizeof(*user_group));
2175 user_group->
uid = (pw ? pw->pw_uid : -1);
2176 user_group->
gid = (gr ? gr->gr_gid : -1);
2178 if (!user_group->
perms) {
2189 if (!strcasecmp(v->
name,
"permit")) {
2195 }
else if (!strcasecmp(v->
name,
"deny")) {
2264 if (!strchr(
cli_rsvd, cli_word[0]))
2265 return (strcasecmp(cmd, cli_word) == 0) ? 1 : -1;
2268 if (l > 0 && cli_word[0] ==
'%') {
2281 if (pos != cli_word && strchr(
cli_rsvd, pos[-1]) && strchr(
cli_rsvd, pos[l])) {
2297 int pos,
int *actual)
2311 if (strncasecmp(token,
word, lw))
2324 if (strncasecmp(s,
word, lw))
2353 const char *
const *src = cmds;
2354 const char *
const *dst = e->cmda;
2356 for (;; dst++, src += n) {
2366 if (match_type != 0)
2381 if (src - cmds > matchlen) {
2382 matchlen = src - cmds;
2387 return e ? e : cand;
2392 static char cmdline[80];
2398 for (x = 0; argv[x]; x++) {
2399 myargv[x] = argv[x];
2404 ast_join(cmdline,
sizeof(cmdline), myargv);
2441 memset(
cmda,
'\0',
sizeof(e->
cmda));
2453 int i, lf, ret = -1;
2456 char **dst = (
char **)e->
cmda;
2468 memset(&
a,
'\0',
sizeof(
a));
2488 ast_log(
LOG_WARNING,
"Command '%s' already registered (or something close enough)\n",
2531 for (i = 0; i <
len; i++) {
2542 for (i = 0; i <
len; i++)
2554 char matchstr[80] =
"";
2561 len = strlen(matchstr);
2577 if (!found && matchstr[0])
2578 ast_cli(fd,
"No such command '%s'.\n", matchstr);
2589 e->
command =
"core show help";
2591 "Usage: core show help [topic]\n"
2592 " When called with a topic as an argument, displays usage\n"
2593 " information on the given command. If called without a\n"
2594 " topic, it provides a list of commands.\n";
2599 int l = strlen(
a->line);
2607 if (
a->argc == e->
args) {
2614 res =
help1(
a->fd,
a->argv + 3, 1 );
2621 ast_join(fullcmd,
sizeof(fullcmd),
a->argv + 3);
2622 ast_cli(
a->fd,
"No help text available for '%s'.\n", fullcmd);
2628static char *
parse_args(
const char *s,
int *argc,
const char *argv[],
int max,
int *trailingwhitespace)
2630 char *duplicate, *cur;
2637 if (trailingwhitespace ==
NULL)
2638 trailingwhitespace = &
dummy;
2639 *trailingwhitespace = 0;
2649 while (isspace(*s)) {
2660 if (*s ==
'"' && !escaped) {
2662 if (quoted && whitespace) {
2667 }
else if ((*s ==
' ' || *s ==
'\t') && !(quoted || escaped)) {
2676 }
else if (*s ==
'\\' && !escaped) {
2696 *trailingwhitespace = whitespace;
2763 char *retstr, *prevstr;
2776 ast_log(
LOG_ERROR,
"Failed to initialize threadstorage for completion.\n");
2786 goto vector_cleanup;
2801 max_equal = strlen(prevstr);
2812 if (!strcasecmp(prevstr, retstr)) {
2819 while (i < max_equal && toupper(prevstr[i]) == toupper(retstr[i])) {
2833 goto vector_cleanup;
2849 for (i = 0; dst[i]; i++) {
2850 if (dst[i][0] !=
'[')
2863 int x = 0, argindex, matchlen;
2866 char matchstr[80] =
"";
2878 ast_join(matchstr,
sizeof(matchstr)-1, argv);
2879 matchlen = strlen(matchstr);
2881 strcat(matchstr,
" ");
2889 int src = 0, dst = 0, n = 0;
2898 for (;src < argindex; dst++, src += n) {
2913 if (matchnum >
state)
2925 .line = matchstr, .word =
word,
2927 .n =
state - matchnum,
2978 .fd =
fd, .argc = x, .argv =
args+1 };
2980 if (duplicate ==
NULL)
2992 ast_cli(
fd,
"No such command '%s' (type 'core show help %s' for other possible commands)\n", s,
find_best(
args + 1));
2997 ast_cli(
fd,
"Command '%s' cannot be run during shutdown\n", s);
3004 ast_cli(
fd,
"You don't have permissions to run '%s' command\n",
tmp);
3012 args[0] = (
char *)e;
3021 ast_cli(
fd,
"%s",
S_OR(e->
usage,
"Invalid usage, but no usage information available.\n"));
3023 ast_cli(
fd,
"Command '%s' failed.\n", s);
3037 int x, y = 0, count = 0;
3039 for (x = 0; x < size; x++) {
Prototypes for public functions only of internal interest,.
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)
#define ast_strndup(str, len)
A wrapper for strndup()
#define ast_realloc(p, len)
A wrapper for realloc()
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
#define ao2_iterator_next(iter)
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.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
int ast_cdr_serialize_variables(const char *channel_name, struct ast_str **buf, char delim, char sep)
Serializes all the data and variables for a current CDR record.
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
static void dummy(char *unused,...)
General Asterisk PBX channel definitions.
const char * ast_channel_linkedid(const struct ast_channel *chan)
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_channel * ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
Call a function with every active channel.
@ AST_CHAN_TP_INTERNAL
Channels with this particular technology are an implementation detail of Asterisk and should generall...
const char * ast_channel_data(const struct ast_channel *chan)
unsigned int ast_channel_fin(const struct ast_channel *chan)
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.
#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.
int ast_channel_priority(const struct ast_channel *chan)
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
ast_callid ast_channel_callid(const struct ast_channel *chan)
const char * ast_channel_uniqueid(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
const char * ast_channel_appl(const struct ast_channel *chan)
struct timeval ast_channel_creationtime(struct ast_channel *chan)
void ast_channel_fin_set(struct ast_channel *chan, unsigned int value)
int ast_active_channels(void)
returns number of active/allocated channels
unsigned int ast_channel_fout(const struct ast_channel *chan)
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
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_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
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_SOFTHANGUP_EXPLICIT
ast_group_t ast_channel_callgroup(const struct ast_channel *chan)
struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan)
const char * ast_channel_language(const struct ast_channel *chan)
const char * ast_state2str(enum ast_channel_state state)
Gives the string form of a given channel state.
void ast_channel_fout_set(struct ast_channel *chan, unsigned int value)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
unsigned long global_fout
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.
const char * ast_channel_exten(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
ast_channel_state
ast_channel states
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_COMPLETE_EOF
#define AST_CLI_DEFINE(fn, txt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
const char * ast_codec_media_type2str(enum ast_media_type type)
Conversion function to take a media type and turn it into a string.
static struct channel_usage channels
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
unsigned int ast_trace_get_by_module(const char *module)
Get the trace level for a module.
struct ao2_container * ast_channel_cache_all(void)
struct ao2_container * ast_channel_cache_by_name(void)
Secondary channel cache, indexed by name.
struct ast_flags ast_options
@ AST_OPT_FLAG_TRACE_MODULE
@ AST_OPT_FLAG_DEBUG_MODULE
@ AST_OPT_FLAG_FULLY_BOOTED
static char prefix[MAX_PREFIX]
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
int ast_app_group_list_unlock(void)
Unlock the group count list.
struct ast_group_info * ast_app_group_list_head(void)
Get the head of the group count list.
int ast_app_group_list_rdlock(void)
Read Lock the group count list.
char * strsep(char **str, const char *delims)
char * strcasestr(const char *, const char *)
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.
#define CONFIG_STATUS_FILEUNCHANGED
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
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)
@ CONFIG_FLAG_FILEUNCHANGED
void ast_callid_strnprint(char *buffer, size_t buffer_size, ast_callid callid)
copy a string representation of the callid into a target string
void ast_console_toggle_mute(int fd, int silent)
mute or unmute a console from logging
int ast_verb_console_get(void)
Get this thread's console verbosity level.
void ast_verb_console_set(int verb_level)
Set this thread's console verbosity level.
A set of macros to manage forward-linked lists.
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
#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_REMOVE
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_RWLIST_TRAVERSE_SAFE_END
#define AST_RWLIST_HEAD(name, type)
Defines a structure to be used to hold a read/write list of specified type.
#define AST_RWLIST_HEAD_INIT_VALUE
Defines initial values for a declaration of AST_RWLIST_HEAD.
#define AST_RWLIST_INSERT_TAIL
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define AST_RWLIST_INSERT_BEFORE_CURRENT
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Asterisk locking-related definitions:
#define ast_rwlock_wrlock(a)
#define ast_rwlock_rdlock(a)
#define AST_RWLOCK_DEFINE_STATIC(rwlock)
#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_trylock(a)
#define ast_rwlock_unlock(a)
#define ast_mutex_lock(a)
#define AST_MUTEX_DEFINE_STATIC(mutex)
#define AST_LOG_CATEGORY_DISABLED
#define AST_LOG_CATEGORY_ENABLED
char * ast_debug_category_complete(const char *const *argv, int argc, const char *word, int state)
Add a unique (no duplicates) result to a request for completion for debug categories.
int ast_debug_category_set_sublevels(const char *const *names, size_t size, int default_sublevel)
Set one or more debug category's sublevel.
static char * handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void remove_shutdown_command(struct ast_cli_entry *e)
void ast_cli_print_timestr_fromseconds(int fd, int seconds, const char *prefix)
Print on cli a duration in seconds in format s year(s), s week(s), s day(s), s hour(s),...
static char * handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static ast_rwlock_t shutdown_commands_lock
void ast_cli_channels_init(void)
char * ast_cli_generator(const char *text, const char *word, int state)
Readline madness Useful for readline, that's about it.
static void cli_shutdown(void)
static char * handle_debug_or_trace(int handler, struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct ast_threadstorage ast_cli_buf
int ast_cli_unregister(struct ast_cli_entry *e)
Unregisters a command or an array of commands.
#define AST_CLI_INITLEN
Initial buffer size for resulting strings in ast_cli()
static void print_uptimestr(int fd, struct timeval timeval, const char *prefix, int printsec)
static char * handle_cli_reload_permissions(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
handles CLI command 'cli reload permissions'
static struct @332 shutdown_commands
static struct ast_cli_entry * find_cli(const char *const cmds[], int match_type)
static void cli_channels_shutdown(void)
static int modlist_modentry(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level)
static int channel_set_debug(void *obj, void *arg, void *data, int flags)
static int set_full_cmd(struct ast_cli_entry *e)
static struct ast_cli_entry cli_cli[]
static char * handle_trace(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
static char * find_best(const char *argv[])
static char * group_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct module_level_list debug_modules
static char * handle_cli_show_permissions(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
handles CLI command 'cli show permissions'
static struct module_level_list trace_modules
static char * handle_logger_mute(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_commandmatchesarray(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static ast_mutex_t permsconfiglock
mutex used to prevent a user from running the 'cli reload permissions' command while it is already ru...
static char * handle_load(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define VERBOSE_FORMAT_STRING2
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
static char * handle_showcalls(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
void ast_cli(int fd, const char *fmt,...)
static char * handle_modlist(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int __ast_cli_register(struct ast_cli_entry *e, struct ast_module *module)
static int word_match(const char *cmd, const char *cli_word)
static int allowed_on_shutdown(struct ast_cli_entry *e)
static char * handle_refresh(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define CONCISE_FORMAT_STRING
static char * complete_number(const char *partial, unsigned int min, unsigned int max, int n)
static char * help1(int fd, const char *const match[], int locked)
helper for final part of handle_help if locked = 1, assume the list is already locked
static char * handle_unload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static const char cli_rsvd[]
static int cli_default_perm
Default permissions value 1=Permit 0=Deny.
static char * handle_cli_check_permissions(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
handles CLI command 'cli check permissions'
char * ast_cli_complete(const char *word, const char *const choices[], int state)
char ** ast_cli_completion_matches(const char *text, const char *word)
Generates a NULL-terminated array of strings that 1) begin with the string in the second parameter,...
static char * handle_help(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int more_words(const char *const *dst)
returns true if there are more words to match
static struct ast_cli_entry cli_channels_cli[]
static int cli_has_permissions(int uid, int gid, const char *command)
int ast_cli_allow_at_shutdown(struct ast_cli_entry *e)
Allow a CLI command to be executed while Asterisk is shutting down.
char * ast_complete_channels(const char *line, const char *word, int pos, int state, int rpos)
Command completion for the list of active channels.
static void destroy_user_perms(void)
cleanup (free) cli_perms linkedlist.
void ast_builtins_init(void)
initialize the _full_cmd string in * each of the builtins.
static int cli_completion_vector_add(struct ast_vector_string *vec, char *value)
static char * handle_softhangup(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_core_set_debug_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
AST_THREADSTORAGE_RAW(completion_storage)
static char * handle_cli_malloc_trim(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_cli_command_multiple_full(int uid, int gid, int fd, size_t size, const char *s)
Executes multiple CLI commands Interpret strings separated by NULL and execute each one,...
static char * handle_cli_wait_fullybooted(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void status_debug_verbose(struct ast_cli_args *a, int handler, int old_val, int cur_val)
static char * handle_core_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * is_prefix(const char *word, const char *token, int pos, int *actual)
if word is a valid prefix for token, returns the pos-th match as a malloced string,...
static char * handle_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct ast_vector_string * ast_cli_completion_vector(const char *text, const char *word)
Generates a vector of strings for CLI completion.
static ast_mutex_t climodentrylock
static struct ast_cli_entry * cli_next(struct ast_cli_entry *e)
static char * __ast_cli_generator(const char *text, const char *word, int state, int lock)
static char * handle_showuptime(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * parse_args(const char *s, int *argc, const char *argv[], int max, int *trailingwhitespace)
static int cli_is_registered(struct ast_cli_entry *e)
static struct module_level * find_module_level(const char *module, struct module_level_list *mll)
Find the module level setting.
int ast_cli_perms_init(int reload)
static const char perms_config[]
CLI permissions config file.
static char * handle_debug_category(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_nodebugchan_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
unsigned int ast_debug_get_by_module(const char *module)
Get the debug level for a module.
static char * handle_verbose(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_cli_command_full(int uid, int gid, int fd, const char *s)
Interprets a command Interpret a command s, sending output to fd if uid:gid has permissions to run th...
#define VERBOSE_FORMAT_STRING
int __ast_cli_register_multiple(struct ast_cli_entry *e, int len, struct ast_module *module)
Asterisk module definitions.
int ast_update_module_list(int(*modentry)(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level), const char *like)
Ask for a list of modules, descriptions, use counts and status.
#define ast_module_unref(mod)
Release a reference to the module.
const char * ast_module_support_level_to_string(enum ast_module_support_level support_level)
int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode)
Unload a module.
char * ast_module_helper(const char *line, const char *word, int pos, int state, int rpos, enum ast_module_helper_type type)
Match modules names for the Asterisk cli.
enum ast_module_load_result ast_load_resource(const char *resource_name)
Load a module.
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_HELPER_RELOAD
@ AST_MODULE_HELPER_LOADED
@ AST_MODULE_HELPER_UNLOAD
@ AST_MODULE_HELPER_RUNNING
enum ast_module_reload_result ast_module_reload(const char *name)
Reload asterisk modules.
struct timeval ast_lastreloadtime
struct timeval ast_startuptime
Asterisk file paths, configured in asterisk.conf.
Core PBX routines and definitions.
int ast_active_calls(void)
Retrieve the number of active calls.
int ast_processed_calls(void)
Retrieve the total number of calls processed through the PBX since last restart.
const char * ast_stream_get_name(const struct ast_stream *stream)
Get the name of a stream.
const char * ast_stream_state2str(enum ast_stream_state state)
Convert the state of a stream into a string.
struct ast_stream * ast_stream_topology_get_stream(const struct ast_stream_topology *topology, unsigned int position)
Get a specific stream from the topology.
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
int ast_stream_get_group(const struct ast_stream *stream)
Get the stream group that a stream is part of.
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
struct ast_variable * ast_stream_get_metadata_list(const struct ast_stream *stream)
Get all stream metadata keys.
const struct ast_format_cap * ast_stream_get_formats(const struct ast_stream *stream)
Get the current negotiated formats of a stream.
char * ast_skip_nonblanks(const char *str)
Gets a pointer to first whitespace character in a string.
@ 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.
#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 force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_str_alloca(init_len)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
#define ast_join(s, len, w)
Join an array of strings into a single string.
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Structure that contains information about a bridge.
const ast_string_field uniqueid
struct timeval creationtime
const ast_string_field accountcode
const ast_string_field uniqueid
const ast_string_field name
const ast_string_field number
const ast_string_field data
const ast_string_field context
const ast_string_field exten
const ast_string_field appl
Structure representing a snapshot of channel state.
struct ast_channel_snapshot_dialplan * dialplan
struct ast_channel_snapshot_peer * peer
struct ast_channel_snapshot_bridge * bridge
struct ast_channel_snapshot_base * base
enum ast_channel_state state
struct ast_channel_snapshot_caller * caller
Main Channel structure associated with a channel.
descriptor for a cli entry.
struct ast_cli_entry::@212 list
int args
This gets set in ast_cli_register()
char *(* handler)(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
const char *const summary
struct ast_module * module
const char *const cmda[AST_MAX_CMD_LEN]
Structure used to handle boolean flags.
struct ast_group_info::@210 group_list
struct ast_channel * chan
Support for dynamic strings.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
String vector definitions.
List of restrictions per user.
struct cli_perm::@333 list
List of users and permissions.
map a debug or verbose level to a module name
list of users to apply restrictions.
struct cli_perm_head * perms
struct usergroup_cli_perm::@334 list
static void handler(const char *name, int response_code, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Definitions to aid in the use of thread local storage.
int ast_threadstorage_set_ptr(struct ast_threadstorage *ts, void *ptr)
Set a raw pointer from threadstorage.
void * ast_threadstorage_get_ptr(struct ast_threadstorage *ts)
Retrieve a raw pointer from threadstorage.
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
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().
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
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.
#define ast_test_flag(p, flag)
int ast_carefulwrite(int fd, char *s, int len, int timeoutms)
Try to write string, but wait no more than ms milliseconds before timing out.
#define ast_clear_flag(p, flag)
#define ast_set_flag(p, flag)
Vector container support.
#define AST_VECTOR_ELEM_CLEANUP_NOOP(elem)
Vector element cleanup that does nothing.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_INSERT_AT(vec, idx, elem)
Insert an element at a specific position in a vector, growing the vector if needed.
#define AST_VECTOR_STEAL_ELEMENTS(vec)
Steal the elements from a vector and reinitialize.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_VECTOR_REMOVE_ELEM_UNORDERED(vec, elem, cleanup)
Remove an element from a vector.
#define AST_VECTOR_ADD_SORTED(vec, elem, cmp)
Add an element into a sorted vector.
#define AST_VECTOR_REMOVE(vec, idx, preserve_ordered)
Remove an element from a vector by index.
#define AST_VECTOR_PTR_FREE(vec)
Deallocates this vector pointer.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
#define AST_VECTOR(name, type)
Define a vector structure.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.