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"))
810 static const char *
const completions[] = {
"recursively",
NULL };
817 "Usage: module refresh <module name> [recursively]\n"
818 " Unloads and loads the specified module into Asterisk.\n"
819 " 'recursively' will attempt to unload any modules with\n"
820 " dependencies on this module for you and load them again\n"
825 if (
a->pos == e->
args) {
827 }
else if (
a->pos == e->
args + 1) {
832 if (
a->argc < 3 ||
a->argc > 4) {
838 ast_cli(
a->fd,
"Unable to %s resource %s\n", res > 0 ?
"unload" :
"load",
a->argv[e->
args]);
841 ast_cli(
a->fd,
"Unloaded and loaded %s\n",
a->argv[e->
args]);
856 "Usage: module unload [-f|-h] <module_1> [<module_2> ... ]\n"
857 " Unloads the specified module from Asterisk. The -f\n"
858 " option causes the module to be unloaded even if it is\n"
859 " in use (may cause a crash) and the -h module causes the\n"
860 " module to be unloaded even if the module says it cannot, \n"
861 " which almost always will cause a crash.\n";
867 if (
a->argc < e->
args + 1)
874 else if (s[1] ==
'h')
878 if (
a->argc < e->
args + 2)
883 for (; x <
a->argc; x++) {
885 ast_cli(
a->fd,
"Unable to unload resource %s\n",
a->argv[x]);
888 ast_cli(
a->fd,
"Unloaded %s\n",
a->argv[x]);
894#define MODLIST_FORMAT "%-30s %-40.40s %-10d %-11s %13s\n"
895#define MODLIST_FORMAT2 "%-30s %-40.40s %-10s %-11s %13s\n"
919#define MINUTE (SECOND*60)
920#define HOUR (MINUTE*60)
923#define YEAR (DAY*365)
924#define NEEDCOMMA(x) ((x) ? ", " : "")
925 if (timeval.tv_sec < 0)
933 if (timeval.tv_sec >
YEAR) {
934 x = (timeval.tv_sec /
YEAR);
935 timeval.tv_sec -= (x *
YEAR);
938 if (timeval.tv_sec >
WEEK) {
939 x = (timeval.tv_sec /
WEEK);
940 timeval.tv_sec -= (x *
WEEK);
943 if (timeval.tv_sec >
DAY) {
944 x = (timeval.tv_sec /
DAY);
945 timeval.tv_sec -= (x *
DAY);
948 if (timeval.tv_sec >
HOUR) {
949 x = (timeval.tv_sec /
HOUR);
950 timeval.tv_sec -= (x *
HOUR);
953 if (timeval.tv_sec >
MINUTE) {
954 x = (timeval.tv_sec /
MINUTE);
955 timeval.tv_sec -= (x *
MINUTE);
982 e->
command =
"core show uptime [seconds]";
984 "Usage: core show uptime [seconds]\n"
985 " Shows Asterisk uptime information.\n"
986 " The seconds word returns the uptime in seconds only.\n";
993 if (
a->argc == e->
args && !strcasecmp(
a->argv[e->
args-1],
"seconds"))
995 else if (
a->argc == e->
args-1)
1014 e->
command =
"module show [like]";
1016 "Usage: module show [like keyword]\n"
1017 " Shows Asterisk modules currently in use, and usage statistics.\n";
1021 if (
a->pos == e->
args) {
1030 if (
a->argc == e->
args - 1)
1032 else if (
a->argc == e->
args + 1 && !strcasecmp(
a->argv[e->
args-1],
"like") )
1033 like =
a->argv[e->
args];
1045#undef MODLIST_FORMAT
1046#undef MODLIST_FORMAT2
1050 static const char *
const completions[] = {
"seconds",
NULL };
1052 int showuptime, printsec;
1056 e->
command =
"core show calls [uptime]";
1058 "Usage: core show calls [uptime [seconds]]\n"
1059 " Lists number of currently active calls and total number of calls\n"
1060 " processed through PBX since last restart. If 'uptime' is specified\n"
1061 " the system uptime is also displayed. If 'seconds' is specified in\n"
1062 " addition to 'uptime', the system uptime is displayed in seconds.\n";
1066 if (
a->pos != e->
args)
1072 if (
a->argc >= e->
args && !strcasecmp(
a->argv[e->
args-1],
"uptime")) {
1075 if (
a->argc == e->
args+1 && !strcasecmp(
a->argv[e->
args],
"seconds"))
1077 else if (
a->argc == e->
args)
1081 }
else if (
a->argc == e->
args-1) {
1088 ast_cli(
a->fd,
"%d of %d max active call%s (%5.2f%% of capacity)\n",
1106#define FORMAT_STRING "%-64.64s %-32.32s %-7.7s %-30.30s\n"
1107#define FORMAT_STRING2 "%-64.64s %-32.32s %-7.7s %-30.30s\n"
1108#define CONCISE_FORMAT_STRING "%s!%s!%s!%d!%s!%s!%s!%s!%s!%s!%d!%s!%s!%s\n"
1109#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"
1110#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"
1115 int numchans = 0, concise = 0, verbose = 0, count = 0;
1119 e->
command =
"core show channels [concise|verbose|count]";
1121 "Usage: core show channels [concise|verbose|count]\n"
1122 " Lists currently defined channels and some information about them. If\n"
1123 " 'concise' is specified, the format is abridged and in a more easily\n"
1124 " machine parsable format. If 'verbose' is specified, the output includes\n"
1125 " more and longer fields. If 'count' is specified only the channel and call\n"
1126 " count is output.\n";
1133 if (
a->argc == e->
args) {
1134 if (!strcasecmp(
a->argv[e->
args-1],
"concise"))
1136 else if (!strcasecmp(
a->argv[e->
args-1],
"verbose"))
1138 else if (!strcasecmp(
a->argv[e->
args-1],
"count"))
1142 }
else if (
a->argc != e->
args - 1)
1148 if (!concise && !verbose)
1152 "CallerID",
"Duration",
"Accountcode",
"PeerAccount",
"BridgeID");
1157 char durbuf[16] =
"-";
1163 int durh = duration / 3600;
1164 int durm = (duration % 3600) / 60;
1165 int durs = duration % 60;
1166 snprintf(durbuf,
sizeof(durbuf),
"%02d:%02d:%02d", durh, durm, durs);
1168 snprintf(durbuf,
sizeof(durbuf),
"%d", duration);
1182 }
else if (verbose) {
1192 char locbuf[40] =
"(None)";
1193 char appdata[40] =
"(None)";
1209 ast_cli(
a->fd,
"%d active channel%s\n", numchans,
ESS(numchans));
1211 ast_cli(
a->fd,
"%d of %d max active call%s (%5.2f%% of capacity)\n",
1224#undef FORMAT_STRING2
1225#undef CONCISE_FORMAT_STRING
1226#undef VERBOSE_FORMAT_STRING
1227#undef VERBOSE_FORMAT_STRING2
1233 static const char *
const completions[] = {
"all",
NULL };
1238 e->
command =
"channel request hangup";
1240 "Usage: channel request hangup <channel>|<all>\n"
1241 " Request that a channel be hung up. The hangup takes effect\n"
1242 " the next time the driver reads or writes from the channel.\n"
1243 " If 'all' is specified instead of a channel name, all channels\n"
1244 " will see the hangup request.\n";
1247 if (
a->pos != e->
args) {
1261 if (!strcasecmp(
a->argv[3],
"all")) {
1280 ast_cli(
a->fd,
"%s is not a known channel\n",
a->argv[3]);
1291 struct passwd *pw =
NULL;
1296 e->
command =
"cli show permissions";
1298 "Usage: cli show permissions\n"
1299 " Shows CLI configured permissions.\n";
1308 pw = getpwuid(cp->
uid);
1310 ast_cli(
a->fd,
"user: %s [uid=%d]\n", pw->pw_name, cp->
uid);
1313 gr = getgrgid(cp->
gid);
1315 ast_cli(
a->fd,
"group: %s [gid=%d]\n", gr->gr_name, cp->
gid);
1336 e->
command =
"cli reload permissions";
1338 "Usage: cli reload permissions\n"
1339 " Reload the 'cli_permissions.conf' file.\n";
1353 struct passwd *pw =
NULL;
1355 int gid = -1, uid = -1;
1363 e->
command =
"cli check permissions";
1365 "Usage: cli check permissions {<username>|@<groupname>|<username>@<groupname>} [<command>]\n"
1366 " Check permissions config for a user@group or list the allowed commands for the specified user.\n"
1367 " The username or the groupname may be omitted.\n";
1371 return ast_cli_generator(
a->line + strlen(
"cli check permissions") + strlen(
a->argv[3]) + 1,
a->word,
a->n);
1383 gr = getgrnam(&
group[1]);
1393 ast_cli(
a->fd,
"You didn't supply a username\n");
1413 ast_cli(
a->fd,
"You are not allowed to run any command on Asterisk\n");
1417 ast_cli(
a->fd,
"%s '%s%s%s' is %s to run command: '%s'\n", uid >= 0 ?
"User" :
"Group",
tmp,
1418 group && uid >= 0 ?
"@" :
"",
1438 e->
command =
"_command matchesarray";
1440 "Usage: _command matchesarray \"<line>\" text \n"
1441 " This function is used internally to help with command completion and should.\n"
1442 " never be called by the user directly.\n";
1455 for (x=0; matches[x]; x++) {
1456 matchlen = strlen(matches[x]) + 1;
1457 if (
len + matchlen >= buflen) {
1458 buflen += matchlen * 3;
1465 len += sprintf(
buf +
len,
"%s ", matches[x]);
1502 ast_cli(
args->fd,
"Debugging %s on channel %s\n",
args->is_off ?
"disabled" :
"enabled",
1514 static const char *
const completions_all[] = {
"all",
NULL };
1515 static const char *
const completions_off[] = {
"off",
NULL };
1522 e->
command =
"core set debug channel";
1524 "Usage: core set debug channel <all|channel> [off]\n"
1525 " Enables/disables debugging on all or on a specific channel.\n";
1534 }
else if (
a->pos == 5) {
1544 }
else if (
a->argc == e->
args + 2) {
1546 if (!strcasecmp(
a->argv[e->
args + 1],
"off"))
1550 }
else if (
a->argc != e->
args + 1) {
1554 if (!strcasecmp(
"all",
a->argv[e->
args])) {
1572 ast_cli(
a->fd,
"Debugging on new channels is %s\n",
args.is_off ?
"disabled" :
"enabled");
1579 const char *argv4 =
a->argv ?
S_OR(
a->argv[4],
"") :
"";
1580 int offset = strncasecmp(argv4,
"off", strlen(argv4)) ? 0 : 1;
1584 e->
command =
"core set debug category";
1586 "Usage: core set debug category <category>[:<sublevel>] [category[:<sublevel] ...]\n"
1587 " core set debug category off [<category> [<category>] ...]\n\n"
1588 " Allows enabling and disabling debug logging categories.\n"
1589 " When a category is enabled all relevant debug messages are logged\n"
1590 " for a given category. However, if a sublevel is specified only\n"
1591 " those categorized messages at or below the coded debug sublevel\n"
1596 if (
a->pos < e->
args) {
1600 if (
a->pos == 4 && offset) {
1605 a->pos - e->
args,
a->word,
a->n - 1);
1608 if (
a->argc <= e->
args) {
1624 e->
command =
"no debug channel";
1633 if (
a->argc != e->
args + 1)
1652 long elapsed_seconds=0;
1653 int hour=0,
min=0, sec=0;
1660 char callid_buf[32];
1666 e->
command =
"core show channel";
1668 "Usage: core show channel <channel>\n"
1669 " Shows lots of information about the specified channel.\n";
1686 ast_cli(
a->fd,
"%s is not a known channel\n",
a->argv[3]);
1703 hour = elapsed_seconds / 3600;
1704 min = (elapsed_seconds % 3600) / 60;
1705 sec = elapsed_seconds % 60;
1706 snprintf(cdrtime,
sizeof(cdrtime),
"%dh%dm%ds", hour,
min, sec);
1708 strcpy(cdrtime,
"N/A");
1715 callid_buf[0] =
'\0';
1733 " Caller ID Name: %s\n"
1734 "Connected Line ID: %s\n"
1735 "Connected Line ID Name: %s\n"
1736 "Eff. Connected Line ID: %s\n"
1737 "Eff. Connected Line ID Name: %s\n"
1738 " DNID Digits: %s\n"
1741 " NativeFormats: %s\n"
1742 " WriteFormat: %s\n"
1744 " WriteTranscode: %s %s\n"
1745 " ReadTranscode: %s %s\n"
1746 " Time to Hangup: %ld\n"
1747 " Elapsed Time: %s\n"
1753 " Call Group: %llu\n"
1754 " Pickup Group: %llu\n"
1755 " Application: %s\n"
1757 " Call Identifer: %s\n",
1788 bridge ? bridge->
uniqueid :
"(Not bridged)",
1796 S_OR(callid_buf,
"(None)")
1831 for(v = metadata; v; v = v->
next) {
1855 int i, which = 0,
len;
1858 for (i = 0; choices[i]; i++) {
1859 if ((!
len || !strncasecmp(
word, choices[i],
len)) && ++which >
state) {
1874 int wordlen = strlen(
word), which = 0;
1909#define FORMAT_STRING "%-25s %-20s %-20s\n"
1914 int havepattern = 0;
1918 e->
command =
"group show channels";
1920 "Usage: group show channels [pattern]\n"
1921 " Lists all currently active channels with channel group(s) specified.\n"
1922 " Optional regular expression pattern is matched to group names for each\n"
1929 if (
a->argc < 3 ||
a->argc > 4)
1933 if (regcomp(®exbuf,
a->argv[3], REG_EXTENDED | REG_NOSUB))
1944 if (!havepattern || !regexec(®exbuf, gi->
group, 0,
NULL, 0)) {
1956 ast_cli(
a->fd,
"%d active channel%s\n", numchans,
ESS(numchans));
1965 e->
command =
"core waitfullybooted";
1967 "Usage: core waitfullybooted\n"
1968 " Wait until Asterisk has fully booted.\n";
1978 ast_cli(
a->fd,
"Asterisk has fully booted.\n");
1984#ifdef HAVE_MALLOC_TRIM
2000 extern int malloc_trim(
size_t __pad) __THROW;
2006 "Usage: malloc trim\n"
2007 " Try to give excess memory back to the OS.\n";
2013 if (malloc_trim(0)) {
2014 ast_cli(
a->fd,
"Returned some memory to the OS.\n");
2016 ast_cli(
a->fd,
"No memory returned to the OS.\n");
2052#ifdef HAVE_MALLOC_TRIM
2089 for (i = 0; e->
cmda[i]; i++)
2124 ast_log(
LOG_NOTICE,
"You must wait until last 'cli reload permissions' command finish\n");
2141 if (!strcasecmp(cat,
"general")) {
2144 if (!strcasecmp(v->
name,
"default_perm")) {
2153 if (cat[0] ==
'@') {
2155 gr = getgrnam(&cat[1]);
2172 if ((pw && cp_entry->
uid == pw->pw_uid) || (gr && cp_entry->
gid == gr->gr_gid)) {
2175 user_group = cp_entry;
2183 user_group =
ast_calloc(1,
sizeof(*user_group));
2187 user_group->
uid = (pw ? pw->pw_uid : -1);
2188 user_group->
gid = (gr ? gr->gr_gid : -1);
2190 if (!user_group->
perms) {
2201 if (!strcasecmp(v->
name,
"permit")) {
2207 }
else if (!strcasecmp(v->
name,
"deny")) {
2276 if (!strchr(
cli_rsvd, cli_word[0]))
2277 return (strcasecmp(cmd, cli_word) == 0) ? 1 : -1;
2280 if (l > 0 && cli_word[0] ==
'%') {
2293 if (pos != cli_word && strchr(
cli_rsvd, pos[-1]) && strchr(
cli_rsvd, pos[l])) {
2309 int pos,
int *actual)
2323 if (strncasecmp(token,
word, lw))
2336 if (strncasecmp(s,
word, lw))
2365 const char *
const *src = cmds;
2366 const char *
const *dst = e->cmda;
2368 for (;; dst++, src += n) {
2378 if (match_type != 0)
2393 if (src - cmds > matchlen) {
2394 matchlen = src - cmds;
2399 return e ? e : cand;
2404 static char cmdline[80];
2410 for (x = 0; argv[x]; x++) {
2411 myargv[x] = argv[x];
2416 ast_join(cmdline,
sizeof(cmdline), myargv);
2453 memset(
cmda,
'\0',
sizeof(e->
cmda));
2465 int i, lf, ret = -1;
2468 char **dst = (
char **)e->
cmda;
2480 memset(&
a,
'\0',
sizeof(
a));
2500 ast_log(
LOG_WARNING,
"Command '%s' already registered (or something close enough)\n",
2543 for (i = 0; i <
len; i++) {
2554 for (i = 0; i <
len; i++)
2566 char matchstr[80] =
"";
2573 len = strlen(matchstr);
2589 if (!found && matchstr[0])
2590 ast_cli(fd,
"No such command '%s'.\n", matchstr);
2601 e->
command =
"core show help";
2603 "Usage: core show help [topic]\n"
2604 " When called with a topic as an argument, displays usage\n"
2605 " information on the given command. If called without a\n"
2606 " topic, it provides a list of commands.\n";
2611 int l = strlen(
a->line);
2619 if (
a->argc == e->
args) {
2626 res =
help1(
a->fd,
a->argv + 3, 1 );
2633 ast_join(fullcmd,
sizeof(fullcmd),
a->argv + 3);
2634 ast_cli(
a->fd,
"No help text available for '%s'.\n", fullcmd);
2640static char *
parse_args(
const char *s,
int *argc,
const char *argv[],
int max,
int *trailingwhitespace)
2642 char *duplicate, *cur;
2649 if (trailingwhitespace ==
NULL)
2650 trailingwhitespace = &
dummy;
2651 *trailingwhitespace = 0;
2661 while (isspace(*s)) {
2672 if (*s ==
'"' && !escaped) {
2674 if (quoted && whitespace) {
2679 }
else if ((*s ==
' ' || *s ==
'\t') && !(quoted || escaped)) {
2688 }
else if (*s ==
'\\' && !escaped) {
2708 *trailingwhitespace = whitespace;
2775 char *retstr, *prevstr;
2788 ast_log(
LOG_ERROR,
"Failed to initialize threadstorage for completion.\n");
2798 goto vector_cleanup;
2813 max_equal = strlen(prevstr);
2824 if (!strcasecmp(prevstr, retstr)) {
2831 while (i < max_equal && toupper(prevstr[i]) == toupper(retstr[i])) {
2845 goto vector_cleanup;
2861 for (i = 0; dst[i]; i++) {
2862 if (dst[i][0] !=
'[')
2875 int x = 0, argindex, matchlen;
2878 char matchstr[80] =
"";
2890 ast_join(matchstr,
sizeof(matchstr)-1, argv);
2891 matchlen = strlen(matchstr);
2893 strcat(matchstr,
" ");
2901 int src = 0, dst = 0, n = 0;
2910 for (;src < argindex; dst++, src += n) {
2925 if (matchnum >
state)
2937 .line = matchstr, .word =
word,
2939 .n =
state - matchnum,
2990 .fd =
fd, .argc = x, .argv =
args+1 };
2992 if (duplicate ==
NULL)
3004 ast_cli(
fd,
"No such command '%s' (type 'core show help %s' for other possible commands)\n", s,
find_best(
args + 1));
3009 ast_cli(
fd,
"Command '%s' cannot be run during shutdown\n", s);
3016 ast_cli(
fd,
"You don't have permissions to run '%s' command\n",
tmp);
3024 args[0] = (
char *)e;
3033 ast_cli(
fd,
"%s",
S_OR(e->
usage,
"Invalid usage, but no usage information available.\n"));
3035 ast_cli(
fd,
"Command '%s' failed.\n", s);
3049 int x, y = 0, count = 0;
3051 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_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_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.
const char * ast_channel_tenantid(const struct ast_channel *chan)
#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.
int ast_refresh_resource(const char *resource_name, enum ast_module_unload_mode force, int recursive)
Unload and load a module again.
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)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
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.