154#undef sched_setscheduler 
  163#include <sys/resource.h> 
  167#if defined(HAVE_SYSINFO) 
  168#include <sys/sysinfo.h> 
  169#elif defined(HAVE_SYSCTL) 
  170#include <sys/param.h> 
  171#include <sys/sysctl.h> 
  172#include <sys/vmmeter.h> 
  173#if defined(__FreeBSD__) || defined(__DragonFly__) 
  174#include <vm/vm_param.h> 
  176#if defined(HAVE_SWAPCTL) 
  185#include <sys/loadavg.h> 
  189#include <sys/prctl.h> 
  191#include <sys/capability.h> 
  247#include "../defaults.h" 
  299#define AF_LOCAL AF_UNIX 
  300#define PF_LOCAL PF_UNIX 
  303#define AST_MAX_CONNECTS 128 
  307#define COPYRIGHT_TAG "Copyright (C) 1999 - 2025, Sangoma Technologies Corporation and others." 
  310#define WELCOME_MESSAGE \ 
  311    ast_verbose("Asterisk %s, " COPYRIGHT_TAG "\n" \ 
  312                "Created by Mark Spencer <markster@digium.com>\n" \ 
  313                "Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.\n" \ 
  314                "This is free software, with components licensed under the GNU General Public\n" \ 
  315                "License version 2 and other licenses; you are welcome to redistribute it under\n" \ 
  316                "certain conditions. Type 'core show license' for details.\n" \ 
  317                "=========================================================================\n", ast_get_version()) \ 
   310#define WELCOME_MESSAGE \ …   359static void asterisk_daemon(
int isroot, 
const char *runuser, 
const char *rungroup);
 
  400static cap_t child_cap;
 
  411#if !defined(LOW_MEMORY) 
  429    new->id = pthread_self();
 
 
  443        if ((
void *) x->
id == 
id) {
 
 
  461    if (!(f = fopen(filename, 
"r"))) {
 
  465    while ((
c = fgetc(f)) != EOF) {
 
 
  481#if defined(HAVE_EACCESS) || defined(HAVE_EUIDACCESS) 
  487        e->
command = 
"core show settings";
 
  488        e->
usage = 
"Usage: core show settings\n" 
  489               "       Show core misc settings";
 
  498    ast_cli(
a->fd, 
"\nPBX Core settings\n");
 
  499    ast_cli(
a->fd, 
"-----------------\n");
 
  506        ast_cli(
a->fd, 
"  Maximum calls:               Not set\n");
 
  508    if (getrlimit(RLIMIT_NOFILE, &
limits)) {
 
  509        ast_cli(
a->fd, 
"  Maximum open file handles:   Error because of %s\n", strerror(
errno));
 
  510    } 
else if (
limits.rlim_cur == RLIM_INFINITY) {
 
  511        ast_cli(
a->fd, 
"  Maximum open file handles:   Unlimited\n");
 
  515        ast_cli(
a->fd, 
"  Maximum open file handles:   %d\n", (
int) 
limits.rlim_cur);
 
  523    print_file(
a->fd, 
"  Core dump file:              ", 
"/proc/sys/kernel/core_pattern");
 
  525#if defined(HAVE_SYSINFO) 
  538    ast_cli(
a->fd, 
"  Entity ID:                   %s\n", eid_str);
 
  539    ast_cli(
a->fd, 
"  PBX UUID:                    %s\n", pbx_uuid);
 
  543#if defined(HAVE_EACCESS) || defined(HAVE_EUIDACCESS) 
  544#if defined(HAVE_EUIDACCESS) && !defined(HAVE_EACCESS) 
  545#define eaccess euidaccess 
  547    if (!getcwd(dir, 
sizeof(dir))) {
 
  548        if (eaccess(dir, 
R_OK | X_OK | 
F_OK)) {
 
  549            ast_cli(
a->fd, 
"  Running directory:           %s\n", 
"Unable to access");
 
  551            ast_cli(
a->fd, 
"  Running directory:           %s (%s)\n", dir, 
"Unable to access");
 
  554        ast_cli(
a->fd, 
"  Running directory:           %s\n", dir);
 
  565#if !defined(LOW_MEMORY) 
  571        ast_cli(
a->fd, 
"  RTP dynamic payload types:   %u,%u-%u\n",
 
  575        ast_cli(
a->fd, 
"  RTP dynamic payload types:   %u-%u,%u-%u\n",
 
  579        ast_cli(
a->fd, 
"  RTP dynamic payload types:   %u-%u\n",
 
  582    ast_cli(
a->fd, 
"  Channel storage backend:     %s\n",
 
  584    ast_cli(
a->fd, 
"  Shell on remote consoles:    %s\n",
 
  596    ast_cli(
a->fd, 
"\n* Directories\n");
 
 
  621        e->
command = 
"core show threads";
 
  623            "Usage: core show threads\n" 
  624            "       List threads currently active in the system.\n";
 
  636    ast_cli(
a->fd, 
"%d threads listed.\n", count);
 
 
  640#if defined (HAVE_SYSCTL) && defined(HAVE_SWAPCTL) 
  645static int swapmode(
int *used, 
int *
total)
 
  647    struct swapent *swdev;
 
  648    int nswap, rnswap, i;
 
  650    nswap = swapctl(SWAP_NSWAP, 0, 0);
 
  658    rnswap = swapctl(SWAP_STATS, swdev, nswap);
 
  668    for (i = 0; i < nswap; i++) {
 
  669        if (swdev[i].se_flags & SWF_ENABLE) {
 
  670            *used += (swdev[i].se_inuse / (1024 / DEV_BSIZE));
 
  671            *
total += (swdev[i].se_nblks / (1024 / DEV_BSIZE));
 
  679#if defined(HAVE_SYSINFO) || defined(HAVE_SYSCTL) 
  683    uint64_t physmem, freeram;
 
  684#if defined(HAVE_SYSINFO) || defined(HAVE_SWAPCTL) 
  686    uint64_t freeswap = 0;
 
  690#if defined(HAVE_SYSINFO) 
  691    struct sysinfo sys_info;
 
  692#elif defined(HAVE_SYSCTL) 
  693    static int pageshift;
 
  694    struct vmtotal vmtotal;
 
  695    struct timeval  boottime;
 
  697    int mib[2], pagesize;
 
  698#if defined(HAVE_SWAPCTL) 
  706        e->
command = 
"core show sysinfo";
 
  708            "Usage: core show sysinfo\n" 
  709            "       List current system information.\n";
 
  715#if defined(HAVE_SYSINFO) 
  717    uptime = sys_info.uptime / 3600;
 
  718    physmem = sys_info.totalram * sys_info.mem_unit;
 
  719    freeram = (sys_info.freeram * sys_info.mem_unit) / 1024;
 
  720    totalswap = (sys_info.totalswap * sys_info.mem_unit) / 1024;
 
  721    freeswap = (sys_info.freeswap * sys_info.mem_unit) / 1024;
 
  722    nprocs = sys_info.procs;
 
  723#elif defined(HAVE_SYSCTL) 
  727    mib[1] = KERN_BOOTTIME;
 
  728    len = 
sizeof(boottime);
 
  729    if (sysctl(mib, 2, &boottime, &
len, 
NULL, 0) != -1) {
 
  730        uptime = now - boottime.tv_sec;
 
  732    uptime = uptime/3600;
 
  735#if defined(HW_PHYSMEM64) 
  736    mib[1] = HW_PHYSMEM64;
 
  740    len = 
sizeof(physmem);
 
  741    sysctl(mib, 2, &physmem, &
len, 
NULL, 0);
 
  743    pagesize = getpagesize();
 
  745    while (pagesize > 1) {
 
  756    len = 
sizeof(vmtotal);
 
  757    sysctl(mib, 2, &vmtotal, &
len, 
NULL, 0);
 
  758    freeram = (vmtotal.t_free << pageshift);
 
  760#if defined(HAVE_SWAPCTL) 
  761    swapmode(&usedswap, &totalswap);
 
  762    freeswap = (totalswap - usedswap);
 
  765#if defined(__OpenBSD__) 
  767    mib[1] = KERN_NPROCS;
 
  768    len = 
sizeof(nprocs);
 
  769    sysctl(mib, 2, &nprocs, &
len, 
NULL, 0);
 
  773    ast_cli(
a->fd, 
"\nSystem Statistics\n");
 
  774    ast_cli(
a->fd, 
"-----------------\n");
 
  775    ast_cli(
a->fd, 
"  System Uptime:             %ld hours\n", uptime);
 
  776    ast_cli(
a->fd, 
"  Total RAM:                 %" PRIu64 
" KiB\n", physmem / 1024);
 
  777    ast_cli(
a->fd, 
"  Free RAM:                  %" PRIu64 
" KiB\n", freeram);
 
  778#if defined(HAVE_SYSINFO) 
  779    ast_cli(
a->fd, 
"  Buffer RAM:                %" PRIu64 
" KiB\n", ((uint64_t) sys_info.bufferram * sys_info.mem_unit) / 1024);
 
  781#if defined(HAVE_SYSINFO) || defined(HAVE_SWAPCTL) 
  782    ast_cli(
a->fd, 
"  Total Swap Space:          %d KiB\n", totalswap);
 
  783    ast_cli(
a->fd, 
"  Free Swap Space:           %" PRIu64 
" KiB\n\n", freeswap);
 
  785    ast_cli(
a->fd, 
"  Number of Processes:       %d \n\n", nprocs);
 
 
  812#if !defined(LOW_MEMORY) 
 
  846#if !defined(LOW_MEMORY) 
 
  859#if !defined(LOW_MEMORY) 
  863#if defined ( __i686__) && (defined(__FreeBSD__) || defined(__NetBSD__) || defined(linux)) 
  864#if defined(__FreeBSD__) 
  865#include <machine/cpufunc.h> 
  866#elif defined(__NetBSD__) || defined(linux) 
  867static __inline uint64_t
 
  872    __asm __volatile(
".byte 0x0f, 0x31" : 
"=A" (rv));
 
  877static __inline uint64_t
 
  887#if !defined(LOW_MEMORY) 
 
  905#if !defined(LOW_MEMORY) 
  906#define DEFINE_PROFILE_MIN_MAX_VALUES min = 0; \ 
  907    max = prof_data->entries;\ 
  909        if (isdigit(a->argv[3][0])) { \ 
  910            min = atoi(a->argv[3]); \ 
  911            if (a->argc == 5 && strcmp(a->argv[4], "-")) \ 
  912                max = atoi(a->argv[4]); \ 
  914            search = a->argv[3]; \ 
  916    if (max > prof_data->entries) \ 
  917        max = prof_data->entries; 
   906#define DEFINE_PROFILE_MIN_MAX_VALUES min = 0; \ … 
  922    const char *search = 
NULL;
 
  925        e->command = 
"core show profile";
 
  926        e->usage = 
"Usage: core show profile\n" 
  927               "       show profile information";
 
  937    ast_cli(
a->fd, 
"profile values (%d, allocated %d)\n-------------------\n",
 
  939    ast_cli(
a->fd, 
"%6s   %8s  %10s %12s %12s  %s\n", 
"ID", 
"Scale", 
"Events",
 
  940            "Value", 
"Average", 
"Name");
 
  941    for (i = 
min; i < 
max; i++) {
 
  943        if (!search || strstr(entry->
name, search))
 
  944            ast_cli(
a->fd, 
"%6d: [%8ld] %10ld %12lld %12lld  %s\n",
 
 
  957    const char *search = 
NULL;
 
  960        e->
command = 
"core clear profile";
 
  961        e->
usage = 
"Usage: core clear profile\n" 
  962               "       clear profile information";
 
  972    for (i= 
min; i < 
max; i++) {
 
 
  980#undef DEFINE_PROFILE_MIN_MAX_VALUES 
  986    return ast_db_get(
"pbx", 
"UUID", pbx_uuid, length);
 
 
  993    int lastreloaded = 0;
 
  999        uptime = (int) tmp.tv_sec;
 
 1004        lastreloaded = (int) tmp.tv_sec;
 
 1008            "Status", 
"Fully Booted",
 
 1010            "LastReload", lastreloaded);
 
 
 1082    return write(fd, s, strlen(s) + 1);
 
 
 1088    return write(fd, s, strlen(s));
 
 
 1098    .sa_flags = SA_RESTART,
 
 
 1102    .sa_handler = SIG_IGN,
 
 
 1151#if defined(HAVE_WORKING_FORK) || defined(HAVE_WORKING_VFORK) 
 1154#ifdef HAVE_WORKING_FORK 
 1162        cap_set_proc(child_cap);
 
 1164#ifdef HAVE_WORKING_FORK 
 1172#ifdef HAVE_WORKING_FORK 
 
 1212#if defined(HAVE_WORKING_FORK) || defined(HAVE_WORKING_VFORK) 
 1217            res = waitpid(pid, &
status, 0);
 
 1222            if (
errno != EINTR) {
 
 
 1252        execl(
"/bin/sh", 
"/bin/sh", 
"-c", s, (
char *) 
NULL);
 
 
 1294                    ast_cli(fd, 
"Console is not muted anymore.\n");
 
 1298                    ast_cli(fd, 
"Console is muted.\n");
 
 1303    ast_cli(fd, 
"Couldn't find remote console.\n");
 
 
 1371    fputs(
string, stdout);
 
 
 1392#if defined(SO_PEERCRED) 
 1393#ifdef HAVE_STRUCT_SOCKPEERCRED_UID 
 1394#define HAVE_STRUCT_UCRED_UID 
 1395    struct sockpeercred cred;
 
 1399    socklen_t 
len = 
sizeof(cred);
 
 1401#if defined(HAVE_GETPEEREID) 
 1409    result = read(fd, buffer, size);
 
 1414#if defined(SO_PEERCRED) && (defined(HAVE_STRUCT_UCRED_UID) || defined(HAVE_STRUCT_UCRED_CR_UID)) 
 1415    if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &
len)) {
 
 1418#if defined(HAVE_STRUCT_UCRED_UID) 
 1426#elif defined(HAVE_GETPEEREID) 
 1427    if (getpeereid(fd, &uid, &gid)) {
 
 
 1442    struct console *con = vconsole;
 
 1446    const char * 
const end_buf = 
inbuf + 
sizeof(
inbuf);
 
 1447    char *start_read = 
inbuf;
 
 1449    struct pollfd fds[2];
 
 1457        fds[0].fd = con->
fd;
 
 1458        fds[0].events = POLLIN;
 
 1460        fds[1].fd = con->
p[0];
 
 1461        fds[1].events = POLLIN;
 
 1470        if (fds[0].revents) {
 
 1471            int cmds_read, bytes_read;
 
 1472            if ((bytes_read = 
read_credentials(con->
fd, start_read, end_buf - start_read, con)) < 1) {
 
 1476            if (strncmp(
inbuf, 
"cli quit after ", 15) == 0) {
 
 1485                if (start_read + bytes_read < end_buf) {
 
 1486                    start_read += bytes_read;
 
 1493            if (start_read[bytes_read - 1] == 
'\0') {
 
 1501            while (cmds_read-- && (start_read = strchr(start_read, 
'\0'))) {
 
 1504            memmove(
inbuf, start_read, end_buf - start_read);
 
 1505            start_read = end_buf - start_read + 
inbuf;
 
 1507        if (fds[1].revents) {
 
 1513            res = write(con->
fd, outbuf, res);
 
 1520        ast_verb(3, 
"Remote UNIX connection disconnected\n");
 
 
 1532    struct sockaddr_un sunaddr;
 
 1537    struct pollfd fds[1];
 
 1544        fds[0].events = POLLIN;
 
 1545        poll_result = 
ast_poll(fds, 1, -1);
 
 1546        pthread_testcancel();
 
 1547        if (poll_result < 0) {
 
 1548            if (
errno != EINTR) {
 
 1553        len = 
sizeof(sunaddr);
 
 1559#if defined(SO_PASSCRED) 
 1562            if (setsockopt(s, SOL_SOCKET, SO_PASSCRED, &sckopt, 
sizeof(sckopt)) < 0) {
 
 1574                        fdprint(s, 
"Server failed to create pipe\n");
 
 1592                        fdprint(s, 
"Server failed to spawn thread\n");
 
 1598                    fdprint(s, 
"No more connections allowed\n");
 
 1602                    ast_verb(3, 
"Remote UNIX connection\n");
 
 
 1612    struct sockaddr_un sunaddr;
 
 1634    memset(&sunaddr, 0, 
sizeof(sunaddr));
 
 1637    res = bind(
ast_socket, (
struct sockaddr *)&sunaddr, 
sizeof(sunaddr));
 
 
 1698    struct sockaddr_un sunaddr;
 
 1702        fprintf(stderr, 
"Unable to create socket: %s\n", strerror(
errno));
 
 1705    memset(&sunaddr, 0, 
sizeof(sunaddr));
 
 1708    res = connect(
ast_consock, (
struct sockaddr *)&sunaddr, 
sizeof(sunaddr));
 
 
 1734    int save_errno = 
errno;
 
 1743    printf(
"Received HUP signal -- Reloading configs\n");
 
 1746        fprintf(stderr, 
"hup_handler: write() failed: %s\n", strerror(
errno));
 
 
 1753    .sa_flags = SA_RESTART,
 
 
 1764    for (n = 0; waitpid(-1, &
status, WNOHANG) > 0; n++)
 
 1767        printf(
"Huh?  Child handler, but nobody there?\n");
 
 
 1773    .sa_flags = SA_RESTART,
 
 
 1779    if (getenv(
"TERM") && strstr(getenv(
"TERM"), 
"xterm"))
 
 1780        fprintf(stdout, 
"\033]2;%s\007", 
text);
 
 
 1785    if (getenv(
"TERM") && strstr(getenv(
"TERM"), 
"xterm"))
 
 1786        fprintf(stdout, 
"\033]1;%s\007", 
text);
 
 
 1797    return sched_getscheduler(0);
 
 1805    return (getpriority(PRIO_PROCESS, 0) < 0);
 
 
 1812#if !defined(__linux__) 
 1815#elif defined(LOW_MEMORY) 
 1820    struct sched_param 
sched;
 
 1821    char const *policy_str;
 
 1827        policy_str = 
"realtime";
 
 1828        sched.sched_priority = 10;
 
 1830        policy = SCHED_OTHER;
 
 1831        policy_str = 
"regular";
 
 1832        sched.sched_priority = 0;
 
 1835        ast_log(
LOG_WARNING, 
"Unable to set %s thread priority on main thread\n", policy_str);
 
 1838    ast_verb(1, 
"Setting %s thread priority on all threads\n", policy_str);
 
 
 1855    struct sched_param 
sched;
 
 1859        sched.sched_priority = 10;
 
 1864        sched.sched_priority = 0;
 
 1874            ast_verb(1, 
"Set to high priority\n");
 
 
 1895    int shutdown_aborted = 0;
 
 1901        shutdown_aborted = 1;
 
 1904    return shutdown_aborted;
 
 
 1932#define SHUTDOWN_TIMEOUT    15   
 1963            if (seconds < (now - start)) {
 
 
 1984        ast_verbose(
"Ignoring asterisk %s request, already in progress.\n", restart ? 
"restart" : 
"shutdown");
 
 2007            ast_verb(0, 
"Beginning asterisk %s....\n", restart ? 
"restart" : 
"shutdown");
 
 2016            ast_verb(0, 
"Waiting for inactivity to perform %s...\n", restart ? 
"restart" : 
"halt");
 
 2027            ast_verb(0, 
"Asterisk %s cancelled.\n", restart ? 
"restart" : 
"shutdown");
 
 
 2065        ast_verb(0, 
"Some modules could not be unloaded, switching to fast shutdown\n");
 
 2082        } 
else if (!restart) {
 
 2094                "Restart", restart ? 
"True" : 
"False");
 
 2099    ast_verb(0, 
"Asterisk %s ending (%d).\n",
 
 2102    ast_verb(0, 
"Executing last minute cleanups\n");
 
 2105    ast_debug(1, 
"Asterisk ending (%d).\n", num);
 
 2113        pthread_kill(
lthread, SIGURG);
 
 2124        ast_verb(0, 
"Preparing for Asterisk restart...\n");
 
 2126        for (i = 3; i < 32768; i++) {
 
 2127            fcntl(i, F_SETFD, FD_CLOEXEC);
 
 2129        ast_verb(0, 
"Asterisk is now restarting...\n");
 
 
 2158        fprintf(stderr, 
"quit_handler: write() failed: %s\n", strerror(
errno));
 
 
 2206    snprintf(outbuf, maxout, 
"%s%s%s%s%s%s",
 
 
 2222    state->verbose_line_level = 0;
 
 
 2236    unsigned int newline;
 
 2255        if ((s = strchr(
c, 
'\n'))) {
 
 2259            s = strchr(
c, 
'\0');
 
 2275        if (fwrite(
c, 
sizeof(
char), num, stdout) < num) {
 
 2289        state->verbose_line_level = 0;
 
 
 2336    while (isspace(*s)) {
 
 2343            printf(
"Shell access is disabled on remote consoles\n");
 
 2351    } 
else if ((strncasecmp(s, 
"quit", 4) == 0 || strncasecmp(s, 
"exit", 4) == 0) &&
 
 2352        (s[4] == 
'\0' || isspace(s[4]))) {
 
 
 2364        e->
command = 
"core show version";
 
 2366            "Usage: core show version\n" 
 2367            "       Shows Asterisk version information.\n";
 
 2375    ast_cli(
a->fd, 
"Asterisk %s built by %s @ %s on a %s running %s on %s\n",
 
 
 2387            "Usage: core stop now\n" 
 2388            "       Shuts down a running Asterisk immediately, hanging up all active calls .\n";
 
 2395    if (
a->argc != e->
args)
 
 
 2405        e->
command = 
"core stop gracefully";
 
 2407            "Usage: core stop gracefully\n" 
 2408            "       Causes Asterisk to not accept new calls, and exit when all\n" 
 2409            "       active calls have terminated normally.\n";
 
 2416    if (
a->argc != e->
args)
 
 
 2426        e->
command = 
"core stop when convenient";
 
 2428            "Usage: core stop when convenient\n" 
 2429            "       Causes Asterisk to perform a shutdown when all active calls have ended.\n";
 
 2436    if (
a->argc != e->
args)
 
 2438    ast_cli(
a->fd, 
"Waiting for inactivity to perform halt\n");
 
 
 2447        e->
command = 
"core restart now";
 
 2449            "Usage: core restart now\n" 
 2450            "       Causes Asterisk to hangup all calls and exec() itself performing a cold\n" 
 2458    if (
a->argc != e->
args)
 
 
 2468        e->
command = 
"core restart gracefully";
 
 2470            "Usage: core restart gracefully\n" 
 2471            "       Causes Asterisk to stop accepting new calls and exec() itself performing a cold\n" 
 2472            "       restart when all active calls have ended.\n";
 
 2479    if (
a->argc != e->
args)
 
 
 2489        e->
command = 
"core restart when convenient";
 
 2491            "Usage: core restart when convenient\n" 
 2492            "       Causes Asterisk to perform a cold restart when all active calls have ended.\n";
 
 2499    if (
a->argc != e->
args)
 
 2501    ast_cli(
a->fd, 
"Waiting for inactivity to perform restart\n");
 
 
 2510        e->
command = 
"core abort shutdown";
 
 2512            "Usage: core abort shutdown\n" 
 2513            "       Causes Asterisk to abort an executing shutdown or restart, and resume normal\n" 
 2514            "       call operations.\n";
 
 2521    if (
a->argc != e->
args)
 
 
 2535            "Usage: !<command>\n" 
 2536            "       Executes a given shell command\n";
 
 
 2548    "BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\n" 
 2549    "FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\n" 
 2550    "OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\n" 
 2551    "PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\n" 
 2552    "OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n" 
 2553    "MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\n" 
 2554    "TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\n" 
 2555    "PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\n" 
 2556    "REPAIR OR CORRECTION.\n" 
 2558    "IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n" 
 2559    "WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\n" 
 2560    "REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\n" 
 2561    "INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\n" 
 2562    "OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\n" 
 2563    "TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\n" 
 2564    "YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\n" 
 2565    "PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\n" 
 2566    "POSSIBILITY OF SUCH DAMAGES.\n" 
 
 2573        e->
command = 
"core show warranty";
 
 2575            "Usage: core show warranty\n" 
 2576            "       Shows the warranty (if any) for this copy of Asterisk.\n";
 
 
 2589    "This program is free software; you can redistribute it and/or modify\n" 
 2590    "it under the terms of the GNU General Public License version 2 as\n" 
 2591    "published by the Free Software Foundation.\n" 
 2593    "This program also contains components licensed under other licenses.\n" 
 2596    "This program is distributed in the hope that it will be useful,\n" 
 2597    "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" 
 2598    "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n" 
 2599    "GNU General Public License for more details.\n" 
 2601    "You should have received a copy of the GNU General Public License\n" 
 2602    "along with this program; if not, write to the Free Software\n" 
 2603    "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n" 
 
 2610        e->
command = 
"core show license";
 
 2612            "Usage: core show license\n" 
 2613            "       Shows the license(s) for this copy of Asterisk.\n";
 
 
 2624#define ASTERISK_PROMPT "*CLI> " 
 2649#if !defined(LOW_MEMORY) 
 2651#if defined(HAVE_SYSINFO) || defined(HAVE_SYSCTL) 
 
 2684        printf(
"log and verbose output currently muted ('logger mute' to unmute)\n");
 
 
 2688#ifdef HAVE_LIBEDIT_IS_UNICODE 
 2689#define CHAR_T_LIBEDIT wchar_t 
 2690#define CHAR_TO_LIBEDIT(c) btowc(c) 
 2692#define CHAR_T_LIBEDIT char 
 2693#define CHAR_TO_LIBEDIT(c) c 
 2700    struct pollfd fds[2];
 
 2703#define EL_BUF_SIZE 512 
 2709        fds[0].events = POLLIN;
 
 2711            fds[1].fd = STDIN_FILENO;
 
 2712            fds[1].events = POLLIN;
 
 2720            if (
errno == EINTR) {
 
 2723            fprintf(stderr, 
"poll failed: %s\n", strerror(
errno));
 
 2730            num_read = read(STDIN_FILENO, &
c, 1);
 
 2740        if (fds[0].revents) {
 
 2744                fprintf(stderr, 
"\nDisconnected from Asterisk server\n");
 
 2749                    int reconnects_per_second = 20;
 
 2751                    fprintf(stderr, 
"Attempting to reconnect for 30 seconds\n");
 
 2752                    for (tries = 0; tries < 30 * reconnects_per_second; tries++) {
 
 2754                            fprintf(stderr, 
"Reconnect succeeded after %.3f seconds\n", 1.0 / reconnects_per_second * tries);
 
 2761                        usleep(1000000 / reconnects_per_second);
 
 2763                    if (tries >= 30 * reconnects_per_second) {
 
 2764                        fprintf(stderr, 
"Failed to reconnect for 30 seconds.  Quitting.\n");
 
 2775                if (write(STDOUT_FILENO, 
"\r␛[0K", 5) < 0) {
 
 2781            if ((res < 
EL_BUF_SIZE - 1) && ((
buf[res-1] == 
'\n') || (res >= 2 && 
buf[res-2] == 
'\n'))) {
 
 
 2802    static int cli_prompt_changes = 0;
 
 2808    } 
else if (!cli_prompt_changes) {
 
 2814    if ((pfmt = getenv(
"ASTERISK_PROMPT"))) {
 
 2817        while (*t != 
'\0') {
 
 2821                struct ast_tm tm = { 0, };
 
 2828                    if (sscanf(t, 
"%30d;%30d%n", &fgcolor, &bgcolor, &i) == 2) {
 
 2831                    } 
else if (sscanf(t, 
"%30d%n", &fgcolor, &i) == 1) {
 
 2843                        cli_prompt_changes++;
 
 2847                    if ((gr = getgrgid(getgid()))) {
 
 2861                        if ((dotptr = strchr(
hostname, 
'.'))) {
 
 2869#ifdef HAVE_GETLOADAVG 
 2872                    if (sscanf(t, 
"%30d", &which) == 1 && which > 0 && which <= 3) {
 
 2876                        cli_prompt_changes++;
 
 2887                        cli_prompt_changes++;
 
 2891                    if ((pw = getpwuid(getuid()))) {
 
 
 2940            goto vector_cleanup;
 
 2945        goto vector_cleanup;
 
 
 2970        for (numoutputline = 0; numoutputline < limit && idx < 
AST_VECTOR_SIZE(matches); idx++) {
 
 2975        if (!numoutputline) {
 
 2979        fprintf(stdout, 
"\n");
 
 
 2989    int retval = CC_ERROR;
 
 2993    LineInfo *lf = (LineInfo *)el_line(editline);
 
 2995    savechr = *(
char *)lf->cursor;
 
 2996    *(
char *)lf->cursor = 
'\0';
 
 2997    ptr = (
char *)lf->cursor;
 
 2999        while (ptr > lf->buffer) {
 
 3000            if (isspace(*ptr)) {
 
 3008    len = lf->cursor - ptr;
 
 3011#define CMD_MATCHESARRAY "_COMMAND MATCHESARRAY \"%s\" \"%s\"" 
 3017        if (maxmbuf == -1) {
 
 3018            *((
char *) lf->cursor) = savechr;
 
 3020            return (
char *)(CC_ERROR);
 
 3029            if (mlen + 1024 > maxmbuf) {
 
 3031                maxmbuf = mlen + 1024;
 
 3035                    *((
char *) lf->cursor) = savechr;
 
 3037                    return (
char *)(CC_ERROR);
 
 3044                if (!strncmp(mbuf, 
"Usage:", 6)) {
 
 3075        int maxlen, match_len;
 
 3079            el_deletestr(editline, (
int) 
len);
 
 3080            el_insertstr(editline, best_match);
 
 3081            retval = CC_REFRESH;
 
 3086            el_insertstr(editline, 
" ");
 
 3087            retval = CC_REFRESH;
 
 3092                if (match_len > maxlen) {
 
 3097            fprintf(stdout, 
"\n");
 
 3099            retval = CC_REDISPLAY;
 
 3105    *((
char *) lf->cursor) = savechr;
 
 3107    return (
char *)(long)retval;
 
 
 3113    char *editor, *editrc = getenv(
"EDITRC");
 
 3115    if (!(editor = getenv(
"AST_EDITMODE"))) {
 
 3116        if (!(editor = getenv(
"AST_EDITOR"))) {
 
 3126    el = el_init(
"asterisk", stdin, stdout, stderr);
 
 3129    el_set(
el, EL_EDITMODE, 1);
 
 3130    el_set(
el, EL_EDITOR, editor);
 
 3136    history(
el_hist, &ev, H_SETSIZE, 100);
 
 3140    el_set(
el, EL_ADDFN, 
"ed-complete", 
"Complete argument", 
cli_complete);
 
 3142    el_set(
el, EL_BIND, 
"^I", 
"ed-complete", 
NULL);
 
 3144    el_set(
el, EL_BIND, 
"?", 
"ed-complete", 
NULL);
 
 3146    el_set(
el, EL_BIND, 
"^D", 
"ed-redisplay", 
NULL);
 
 3148    el_set(
el, EL_BIND, 
"\\e[3~", 
"ed-delete-next-char", 
NULL);
 
 3150    el_set(
el, EL_BIND, 
"\\e[1~", 
"ed-move-to-beg", 
NULL);
 
 3151    el_set(
el, EL_BIND, 
"\\e[4~", 
"ed-move-to-end", 
NULL);
 
 3153    el_set(
el, EL_BIND, 
"\\eOC", 
"vi-next-word", 
NULL);
 
 3154    el_set(
el, EL_BIND, 
"\\eOD", 
"vi-prev-word", 
NULL);
 
 3157        el_source(
el, editrc);
 
 
 3163#define MAX_HISTORY_COMMAND_LENGTH 256 
 3180    if (!history(
el_hist, &ev, H_FIRST) && strcmp(ev.str, stripped_buf) == 0) {
 
 3184    return history(
el_hist, &ev, H_ENTER, stripped_buf);
 
 
 3194    return (history(
el_hist, &ev, H_SAVE, filename));
 
 
 3205    if (access(filename, 
F_OK) == 0) {
 
 3206        return history(
el_hist, &ev, H_LOAD, filename);
 
 
 3215    struct passwd *pw = getpwuid(geteuid());
 
 3220        ast_log(
LOG_ERROR, 
"Unable to determine home directory.  History read/write disabled.\n");
 
 3226        ast_log(
LOG_ERROR, 
"Unable to create history file name.  History read/write disabled.\n");
 
 3230    ret = readwrite(
name);
 
 
 3258    char *stringp = 
NULL;
 
 3277        char prefix[] = 
"cli quit after ";
 
 3279        sprintf(tmp, 
"%s%s", 
prefix, data);
 
 3280        if (write(
ast_consock, tmp, strlen(tmp) + 1) < 0) {
 
 3289    cpid = 
strsep(&stringp, 
"/");
 
 3292        version = 
"<Version Unknown>";
 
 3304        int linefull = 1, prev_linefull = 1, prev_line_verbose = 0;
 
 3307        fds.events = POLLIN;
 
 3310        while (
ast_poll(&fds, 1, 60000) > 0) {
 
 3311            char buffer[512] = 
"", *curline = buffer, *nextline;
 
 3312            int not_written = 1;
 
 3318            if (read(
ast_consock, buffer, 
sizeof(buffer) - 1) <= 0) {
 
 3323                prev_linefull = linefull;
 
 3324                if ((nextline = strchr(curline, 
'\n'))) {
 
 3329                    nextline = strchr(curline, 
'\0');
 
 3343                if ((!prev_linefull && !prev_line_verbose) || (prev_linefull && *curline > 0)) {
 
 3344                    prev_line_verbose = 0;
 
 3346                    if (write(STDOUT_FILENO, curline, nextline - curline) < 0) {
 
 3350                    prev_line_verbose = 1;
 
 3374        ebuf = (
char *)el_gets(
el, &num);
 
 3380        if (!ebuf && write(1, 
"", 1) < 0)
 
 3384            if (ebuf[strlen(ebuf)-1] == 
'\n')
 
 3385                ebuf[strlen(ebuf)-1] = 
'\0';
 
 3395    printf(
"\nDisconnected from Asterisk server\n");
 
 
 3407    printf(
"Usage: asterisk [OPTIONS]\n");
 
 3408    printf(
"Valid Options:\n");
 
 3409    printf(
"   -V              Display version number and exit\n");
 
 3410    printf(
"   -C <configfile> Use an alternate configuration file\n");
 
 3411    printf(
"   -G <group>      Run as a group other than the caller\n");
 
 3412    printf(
"   -U <user>       Run as a user other than the caller\n");
 
 3413    printf(
"   -c              Provide console CLI\n");
 
 3414    printf(
"   -d              Increase debugging (multiple d's = more debugging)\n");
 
 3415#if HAVE_WORKING_FORK 
 3416    printf(
"   -f              Do not fork\n");
 
 3417    printf(
"   -F              Always fork\n");
 
 3419    printf(
"   -g              Dump core in case of a crash\n");
 
 3420    printf(
"   -h              This help screen\n");
 
 3421    printf(
"   -i              Initialize crypto keys at startup\n");
 
 3422    printf(
"   -L <load>       Limit the maximum load average before rejecting new calls\n");
 
 3423    printf(
"   -M <value>      Limit the maximum number of calls to the specified value\n");
 
 3424    printf(
"   -m              Mute debugging and console output on the console\n");
 
 3425    printf(
"   -n              Disable console colorization. Can be used only at startup.\n");
 
 3426    printf(
"   -p              Run as pseudo-realtime thread\n");
 
 3427    printf(
"   -q              Quiet mode (suppress output)\n");
 
 3428    printf(
"   -r              Connect to Asterisk on this machine\n");
 
 3429    printf(
"   -R              Same as -r, except attempt to reconnect if disconnected\n");
 
 3430    printf(
"   -s <socket>     Connect to Asterisk via socket <socket> (only valid with -r)\n");
 
 3431    printf(
"   -t              Record soundfiles in /var/tmp and move them where they\n");
 
 3432    printf(
"                   belong after they are done\n");
 
 3433    printf(
"   -T              Display the time in [Mmm dd hh:mm:ss] format for each line\n");
 
 3434    printf(
"                   of output to the CLI. Cannot be used with remote console mode.\n\n");
 
 3435    printf(
"   -v              Increase verbosity (multiple v's = more verbose)\n");
 
 3436    printf(
"   -x <cmd>        Execute command <cmd> (implies -r)\n");
 
 3437    printf(
"   -X              Enable use of #exec in asterisk.conf\n");
 
 3438    printf(
"   -W              Adjust terminal colors to compensate for a light background\n");
 
 
 3461        if (!strcasecmp(v->
name, 
"log_level")) {
 
 3469        } 
else if (!strcasecmp(v->
name, 
"cache_pools")) {
 
 
 3504    struct stat canary_stat;
 
 3512        if (stat(
canary_filename, &canary_stat) || now.tv_sec > canary_stat.st_mtime + 60) {
 
 3514                "The canary is no more.  He has ceased to be!  " 
 3515                "He's expired and gone to meet his maker!  " 
 3516                "He's a stiff!  Bereft of life, he rests in peace.  " 
 3517                "His metabolic processes are now history!  He's off the twig!  " 
 3518                "He's kicked the bucket.  He's shuffled off his mortal coil, " 
 3519                "run down the curtain, and joined the bleeding choir invisible!!  " 
 3520                "THIS is an EX-CANARY.  (Reducing priority)\n");
 
 
 3549    "fully-booted,yes,true,y,t,1,on" 
 
 3566    fd = open(
"/dev/null", O_RDWR);
 
 
 3603            ast_verbose(
"Running under group '%s'\n", rungroup);
 
 
 3617    int isroot = 1, rundir_exists = 0;
 
 3622    static const char *getopt_settings = 
"BC:cde:FfG:ghIiL:M:mnpqRrs:TtU:VvWXx:";
 
 3626        fprintf(stderr, 
"Truncating argument size to %d\n", (
int)
ARRAY_LEN(
_argv) - 1);
 
 3629    for (x = 0; x < argc; x++)
 
 3637    if (argv[0] && (strstr(argv[0], 
"rasterisk")) != 
NULL) {
 
 3643    while ((
c = getopt(argc, argv, getopt_settings)) != -1) {
 
 3688    while ((
c = getopt(argc, argv, getopt_settings)) != -1) {
 
 3709#if defined(HAVE_SYSINFO) 
 3716#if HAVE_WORKING_FORK 
 3735                "NOTICE: The -I option is no longer needed.\n" 
 3736                "  It will always be enabled if you have a timing module loaded.\n");
 
 3809        while ((
c = getopt(argc, argv, getopt_settings)) != -1) {
 
 3846                fprintf(stderr, 
"'%c' option is not compatible with remote console mode and has no effect.\n", 
c);
 
 3851            fprintf(stderr, 
"\n"); 
 
 3859        strcpy(argv[0], 
"rasterisk");
 
 3860        for (x = 1; x < argc; x++) {
 
 3861            argv[x] = argv[0] + 10;
 
 3866        fprintf(stderr, 
"The 'languageprefix' option in asterisk.conf is deprecated; in a future release it will be removed, and your sound files will need to be organized in the 'new style' language layout.\n");
 
 3870        fprintf(stderr, 
"'alwaysfork' is not compatible with console or remote console mode; ignored\n");
 
 3875        memset(&l, 0, 
sizeof(l));
 
 3876        l.rlim_cur = RLIM_INFINITY;
 
 3877        l.rlim_max = RLIM_INFINITY;
 
 3878        if (setrlimit(RLIMIT_CORE, &l)) {
 
 3879            fprintf(stderr, 
"Unable to disable core size resource limit: %s\n", strerror(
errno));
 
 3883    if (getrlimit(RLIMIT_NOFILE, &l)) {
 
 3884        fprintf(stderr, 
"Unable to check file descriptor limit: %s\n", strerror(
errno));
 
 3887#if !defined(CONFIGURE_RAN_AS_ROOT) 
 3892        struct timeval tv = { 0, };
 
 3894        if (l.rlim_cur <= FD_SETSIZE) {
 
 3900        if (!(fd = open(
"/dev/null", O_RDONLY))) {
 
 3901            fprintf(stderr, 
"Cannot open a file descriptor at boot? %s\n", strerror(
errno));
 
 3905        fd2 = ((l.rlim_cur > 
sizeof(readers) * 8) ? 
sizeof(readers) * 8 : l.rlim_cur) - 1;
 
 3906        if (dup2(fd, fd2) < 0) {
 
 3907            fprintf(stderr, 
"Cannot open maximum file descriptor %d at boot? %s\n", fd2, strerror(
errno));
 
 3915            fprintf(stderr, 
"Maximum select()able file descriptor is %d\n", FD_SETSIZE);
 
 3921#elif defined(HAVE_VARIABLE_FDSET) 
 3938        if (
errno == EEXIST) {
 
 3941            fprintf(stderr, 
"Unable to create socket file directory.  Remote consoles will not be able to connect! (%s)\n", strerror(x));
 
 3951    if (isroot && rungroup) {
 
 3953        gr = getgrnam(rungroup);
 
 3955            fprintf(stderr, 
"No such group '%s'!\n", rungroup);
 
 3959            fprintf(stderr, 
"Unable to chgrp run directory to %d (%s)\n", (
int) gr->gr_gid, rungroup);
 
 3961        if (setgid(gr->gr_gid)) {
 
 3962            fprintf(stderr, 
"Unable to setgid to %d (%s)\n", (
int)gr->gr_gid, rungroup);
 
 3965        if (setgroups(0, 
NULL)) {
 
 3966            fprintf(stderr, 
"Unable to drop unneeded groups\n");
 
 3976        pw = getpwnam(runuser);
 
 3978            fprintf(stderr, 
"No such user '%s'!\n", runuser);
 
 3982            fprintf(stderr, 
"Unable to chown run directory to %d (%s)\n", (
int) pw->pw_uid, runuser);
 
 3985        if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0)) {
 
 3990        if (!isroot && pw->pw_uid != geteuid()) {
 
 3991            fprintf(stderr, 
"Asterisk started as nonroot, but runuser '%s' requested.\n", runuser);
 
 3995            if (setgid(pw->pw_gid)) {
 
 3996                fprintf(stderr, 
"Unable to setgid to %d!\n", (
int)pw->pw_gid);
 
 3999            if (isroot && initgroups(pw->pw_name, pw->pw_gid)) {
 
 4000                fprintf(stderr, 
"Unable to init groups for '%s'\n", runuser);
 
 4004        if (setuid(pw->pw_uid)) {
 
 4005            fprintf(stderr, 
"Unable to setuid to %d (%s)\n", (
int)pw->pw_uid, runuser);
 
 4012            cap = cap_from_text(
"cap_net_admin=eip");
 
 4014            if (cap_set_proc(cap)) {
 
 4015                fprintf(stderr, 
"Unable to install capabilities.\n");
 
 4017            if (cap_free(cap)) {
 
 4018                fprintf(stderr, 
"Unable to drop capabilities.\n");
 
 4028        if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0) {
 
 4029            fprintf(stderr, 
"Unable to set the process for core dumps after changing to a non-root user. %s\n", strerror(
errno));
 
 4035#if defined(HAVE_EACCESS) || defined(HAVE_EUIDACCESS) 
 4037        if (!getcwd(dir, 
sizeof(dir)) || eaccess(dir, 
R_OK | X_OK | 
F_OK)) {
 
 4038            fprintf(stderr, 
"Unable to access the running directory (%s).  Changing to '/' for compatibility.\n", strerror(
errno));
 
 4043                fprintf(stderr, 
"chdir(\"/\") failed?!! %s\n", strerror(
errno));
 
 4050                fprintf(stderr, 
"Unable to chdir(\"/\") ?!! %s\n", strerror(
errno));
 
 4082            fprintf(stderr, 
"Asterisk already running on %s.  Use 'asterisk -r' to connect.\n", 
ast_config_AST_SOCKET);
 
 4093    child_cap = cap_from_text(
"cap_net_admin-eip");
 
 4098    cap_free(child_cap);
 
 
 4109            fprintf(stderr, 
"%s initialization failed.  ASTERISK EXITING!\n%s", 
name, 
term_quit());
 
 4112        exit(init_result == -2 ? 2 : 1);
 
 
 4132#if HAVE_WORKING_FORK 
 4134#ifndef HAVE_SBIN_LAUNCHD 
 4135        if (daemon(1, 0) < 0) {
 
 4136            fprintf(stderr, 
"daemon() failed: %s\n", strerror(
errno));
 
 4141        fprintf(stderr, 
"Mac OS X detected.  Use 'launchctl load /Library/LaunchDaemon/org.asterisk.asterisk.plist'.\n");
 
 4170            char canary_binary[
PATH_MAX], ppid[12];
 
 4173            signal(SIGCHLD, SIG_DFL);
 
 4174            signal(SIGPIPE, SIG_DFL);
 
 4178            snprintf(ppid, 
sizeof(ppid), 
"%d", (
int) 
ast_mainpid);
 
 4187            pthread_t dont_care;
 
 4238    ast_verb(0, 
"PBX UUID: %s\n", pbx_uuid);
 
 4255#ifdef TEST_FRAMEWORK 
 4274    (void) sigemptyset(&sigs);
 
 4275    (void) sigaddset(&sigs, SIGHUP);
 
 4276    (void) sigaddset(&sigs, SIGTERM);
 
 4277    (void) sigaddset(&sigs, SIGINT);
 
 4278    (void) sigaddset(&sigs, SIGPIPE);
 
 4279    (void) sigaddset(&sigs, SIGWINCH);
 
 4280    pthread_sigmask(SIG_BLOCK, &sigs, 
NULL);
 
 4290    srand((
unsigned int) getpid() + (
unsigned int) time(
NULL));
 
 4363    pthread_sigmask(SIG_UNBLOCK, &sigs, 
NULL);
 
 4391        snprintf(title, 
sizeof(title), 
"Asterisk Console on '%s' (pid %ld)", 
hostname, (
long)
ast_mainpid);
 
 4407            buf = (
char *) el_gets(
el, &num);
 
 4409            if (!
buf && write(1, 
"", 1) < 0)
 
 4413                if (
buf[strlen(
buf)-1] == 
'\n')
 
 4414                    buf[strlen(
buf)-1] = 
'\0';
 
 
Prototypes for public functions only of internal interest,.
int load_pbx_variables(void)
void threadstorage_init(void)
void ast_process_pending_reloads(void)
Process reload requests received during startup.
int modules_shutdown(void)
int ast_bridging_init(void)
Initialize the bridging system.
void dnsmgr_start_refresh(void)
int ast_timing_init(void)
int ast_device_state_engine_init(void)
Initialize the device state engine in separate thread.
void ast_cli_channels_init(void)
void ast_msg_shutdown(void)
void logger_queue_start(void)
Start the ast_queue_log() logger.
void load_asterisk_conf(void)
void ast_stun_init(void)
Initialize the STUN system in Asterisk.
void set_asterisk_conf_path(const char *path)
int load_pbx_functions_cli(void)
void load_astmm_phase_2(void)
Initialize malloc debug phase 2.
int load_pbx_hangup_handler(void)
int ast_local_init(void)
Initialize the local proxy channel.
int load_pbx_builtins(void)
int load_pbx_switch(void)
int ast_rtp_engine_init(void)
initializes the rtp engine arrays
int ast_xmldoc_load_documentation(void)
Load XML documentation. Provided by xmldoc.c.
int ast_named_locks_init(void)
int ast_taskpool_init(void)
int ast_channels_init(void)
void clean_time_zones(void)
void load_astmm_phase_1(void)
Initialize malloc debug phase 1.
void ast_builtins_init(void)
initialize the _full_cmd string in * each of the builtins.
void ast_autoservice_init(void)
int ast_endpoint_init(void)
Endpoint support initialization.
int ast_dns_system_resolver_init(void)
Initializes the resolver.
int ast_cli_perms_init(int reload)
void set_socket_path(const char *path)
int ast_parking_stasis_init(void)
initializes the rtp engine arrays
Access Control of various sorts.
void ast_cli_unregister_multiple(void)
A-Law to Signed linear conversion.
void ast_alaw_init(void)
To init the alaw to slinear conversion stuff, this needs to be run.
void ast_alertpipe_close(int alert_pipe[2])
Close an alert pipe.
ssize_t ast_alertpipe_write(int alert_pipe[2])
Write an event to an alert pipe.
int ast_alertpipe_init(int alert_pipe[2])
Initialize an alert pipe.
ast_alert_status_t ast_alertpipe_read(int alert_pipe[2])
Read an event from an alert pipe.
Generic Advice of Charge encode and decode routines.
int ast_aoc_cli_init(void)
enable aoc cli options
Asterisk version information.
const char * ast_get_build_opts(void)
const char * ast_get_version(void)
Retrieve the Asterisk version string.
const char * ast_get_build_opts_all(void)
Persistent data storage (akin to *doze registry)
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
int setenv(const char *name, const char *value, int overwrite)
int getloadavg(double *list, int nelem)
char * strsep(char **str, const char *delims)
static int ast_el_add_history(const char *)
static char * remotehostname
static char * handle_stop_gracefully(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void __ast_unregister_atexit(void(*func)(void))
static char * cli_complete(EditLine *editline, int ch)
int64_t ast_mark(int i, int startstop)
static int ast_socket_is_sd
int ast_shutdown_final(void)
static void canary_exit(void)
static shutdown_nice_t shuttingdown
static void check_init(int init_result, const char *name)
static void __remote_quit_handler(int num)
static void _urg_handler(int num)
Urgent handler.
static char * show_license(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_show_threads(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void ast_run_atexits(int run_cleanups)
static int console_state_init(void *ptr)
static struct profile_data * prof_data
@ STARTUP_COMMANDS_PRE_MODULE
@ STARTUP_COMMANDS_PRE_INIT
@ STARTUP_COMMANDS_FULLY_BOOTED
static char * handle_stop_when_convenient(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int remoteconsolehandler(const char *s)
static struct ast_str * prompt
static void publish_fully_booted(void)
static int show_version(void)
static void main_atexit(void)
static int safe_exec_wait(pid_t pid)
wait for spawned application to complete and unreplace sigchld
int ast_add_profile(const char *name, uint64_t scale)
allocates a counter with a given name and scale.
static void ast_cli_display_match_list(struct ast_vector_string *matches, int max)
static void _hup_handler(int num)
static char * handle_version(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static unsigned int safe_system_level
Keep track of how many threads are currently trying to wait*() on a child process.
static void ast_network_puts_mutable(const char *string, int level, int sublevel)
log the string to all attached network console clients
static char randompool[256]
static char * handle_show_sysinfo(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Give an overview of system statistics.
#define WELCOME_MESSAGE
Welcome message when starting a CLI interface.
int ast_safe_execvp(int dualfork, const char *file, char *const argv[])
Safely spawn an external program while closing file descriptors.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
static void set_header(char *outbuf, int maxout, char level)
static int ast_el_read_char(EditLine *editline, CHAR_T_LIBEDIT *cp)
static char * handle_stop_now(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char canary_filename[128]
static __inline uint64_t rdtsc(void)
static struct sigaction child_handler
int ast_set_priority(int pri)
We set ourselves to a high priority, that we might pre-empt everything else. If your PBX has heavy ac...
static void asterisk_daemon(int isroot, const char *runuser, const char *rungroup)
void ast_console_toggle_loglevel(int fd, int level, int state)
enable or disable a logging level to a specified console
static char * handle_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Give an overview of core settings.
static int has_priority(void)
Check whether we were set to high(er) priority.
void ast_console_toggle_mute(int fd, int silent)
mute or unmute a console from logging
static void send_rasterisk_connect_commands(void)
static struct @318 sig_flags
static struct sigaction safe_system_prev_handler
static char * handle_bang(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct sigaction hup_handler
static pthread_t mon_sig_flags
static int fdprint(int fd, const char *s)
static pthread_t consolethread
static void * netconsole(void *vconsole)
static int ast_el_initialize(void)
static int set_priority_all(int pri)
Set priority on all known threads.
static void ast_begin_shutdown(void)
static char * handle_restart_now(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_restart_when_convenient(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int ast_el_read_history(const char *)
static char * handle_abort_shutdown(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_shutting_down(void)
static void _child_handler(int sig)
void ast_console_puts_mutable(const char *string, int level)
log the string to the root console, and all attached network console clients
int ast_pbx_uuid_get(char *pbx_uuid, int length)
Retrieve the PBX UUID.
void ast_replace_sigchld(void)
Replace the SIGCHLD handler.
int ast_cancel_shutdown(void)
Cancel an existing shutdown and return to normal operation.
static void ast_network_puts(const char *string)
write the string to all attached console clients
static int read_credentials(int fd, char *buffer, size_t size, struct console *con)
read() function supporting the reception of user credentials.
#define CHAR_TO_LIBEDIT(c)
static int shutdown_pending
static void _null_sig_handler(int sig)
NULL handler so we can collect the child exit status.
static void process_histfile(int(*readwrite)(const char *filename))
static int sig_alert_pipe[2]
struct timeval ast_lastreloadtime
static const char warranty_lines[]
void ast_console_puts(const char *string)
write the string to the root console, and all attached network console clients
void ast_unregister_atexit(void(*func)(void))
Unregister a function registered with ast_register_atexit().
static int console_print(const char *s)
static void quit_handler(int num, shutdown_nice_t niceness, int restart)
static char * handle_restart_gracefully(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void * monitor_sig_flags(void *unused)
static char * show_warranty(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define MAX_HISTORY_COMMAND_LENGTH
void ast_register_thread(char *name)
static void ast_remotecontrol(char *data)
static int print_file(int fd, char *desc, const char *filename)
Print the contents of a file.
void ast_unregister_thread(void *id)
static void consolehandler(const char *s)
static struct ast_cli_entry cli_asterisk_shutdown[]
Shutdown Asterisk CLI commands.
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
static ast_mutex_t safe_system_lock
static pid_t safe_exec_prep(int dualfork)
fork and perform other preparations for spawning applications
int ast_safe_system(const char *s)
Safely spawn an OS shell command while closing file descriptors.
static int ast_all_zeros(const char *s)
static int can_safely_quit(shutdown_nice_t niceness, int restart)
static char * cli_prompt(EditLine *editline)
static void set_title(char *text)
Set an X-term or screen title.
static int register_atexit(void(*func)(void), int is_cleanup)
static char * handle_clear_profile(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int wait_for_channels_to_die(shutdown_nice_t niceness, int seconds)
static int ast_makesocket(void)
#define DEFINE_PROFILE_MIN_MAX_VALUES
unsigned int need_quit_handler
static int ast_tryconnect(void)
static void * canary_thread(void *unused)
static void * listener(void *unused)
static struct ast_cli_entry cli_asterisk[]
static int fdsend(int fd, const char *s)
static int ast_el_write_history(const char *)
static int show_cli_help(void)
static void ast_el_read_default_histfile(void)
static char * handle_show_profile(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void env_init(void)
struct timeval ast_startuptime
static const char * startup_commands_phase_str[]
static void read_pjproject_startup_options(void)
static const char license_lines[]
void ast_unreplace_sigchld(void)
Restore the SIGCHLD handler.
static void really_quit(int num, shutdown_nice_t niceness, int restart)
static void ast_el_write_default_histfile(void)
static int multi_thread_safe
static struct ast_vector_string * ast_el_strtoarr(char *buf)
static void __quit_handler(int num)
void ast_console_puts_mutable_full(const char *message, int level, int sublevel)
log the string to the console, and all attached console clients
static void set_icon(char *text)
static void print_intro_message(const char *runuser, const char *rungroup)
static struct sigaction ignore_sig_handler
static struct sigaction null_sig_handler
struct console consoles[AST_MAX_CONNECTS]
int64_t ast_profile(int i, int64_t delta)
static struct sigaction urg_handler
static void run_startup_commands(enum startup_commands_phase phase)
Asterisk main include file. File version handling, generic pbx functions.
#define sched_setscheduler
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#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
void ast_free_ptr(void *ptr)
free() wrapper
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ast_calloc(num, len)
A wrapper for calloc()
int ast_bucket_init(void)
Initialize bucket support.
const char * ast_build_os
const char * ast_build_machine
const char * ast_build_hostname
const char * ast_build_user
const char * ast_build_date
const char * ast_build_kernel
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
void callerid_init(void)
CallerID Initialization.
int ast_cdr_is_enabled(void)
Return TRUE if CDR subsystem is enabled.
void ast_cdr_engine_term(void)
static char version[AST_MAX_EXTENSION]
General Asterisk PBX channel definitions.
void ast_softhangup_all(void)
Soft hangup all active channels.
const char * ast_channel_get_current_storage_driver_name(void)
Get the name of the current channel storage driver.
int ast_undestroyed_channels(void)
int ast_active_channels(void)
returns number of active/allocated channels
static int active_channels(struct ast_channelstorage_instance *driver)
returns number of active/allocated channels
Standard Command Line Interface.
#define AST_CLI_COMPLETE_EOF
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_command(fd, s)
int ast_cli_allow_at_shutdown(struct ast_cli_entry *e)
Allow a CLI command to be executed while Asterisk is shutting down.
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,...
struct ast_vector_string * ast_cli_completion_vector(const char *text, const char *word)
Generates a vector of strings for CLI completion.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
int ast_codec_init(void)
Initialize codec support within the core.
int ast_codec_builtin_init(void)
Initialize built-in codecs within the core.
int devstate_init(void)
Initialize the device state core.
Generic File Format Support. Should be included by clients of the file handling routines....
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_manager_check_enabled(void)
Check if AMI is enabled.
int ast_webmanager_check_enabled(void)
Check if AMI/HTTP is enabled.
void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj)
Publish an event to AMI.
void ast_init_logger_for_socket_console(void)
load logger.conf configuration for console socket connections
int ast_option_rtpusedynamic
int ast_option_disable_remote_console_shell
int ast_option_pjproject_log_level
struct ast_flags64 ast_options
double ast_option_maxload
unsigned int ast_option_rtpptdynamic
unsigned int option_dtmfminduration
int ast_option_pjproject_cache_pools
@ AST_OPT_FLAG_HIGH_PRIORITY
@ AST_OPT_FLAG_EXEC_INCLUDES
@ AST_OPT_FLAG_ALWAYS_FORK
@ AST_OPT_FLAG_CACHE_RECORD_FILES
@ AST_OPT_FLAG_FULLY_BOOTED
@ AST_OPT_FLAG_FORCE_BLACK_BACKGROUND
@ AST_OPT_FLAG_LIGHT_BACKGROUND
static char prefix[MAX_PREFIX]
General Asterisk channel definitions for image handling.
int ast_image_init(void)
Initialize image stuff Initializes all the various image stuff. Basically just registers the cli stuf...
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
int app_init(void)
Initialize the application core.
void ast_close_fds_above_n(int n)
Common routine for child processes, to close all fds prior to exec(2)
Configuration File Parser.
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
#define CONFIG_STATUS_FILEMISSING
int ast_realtime_enabled(void)
Check if there's any realtime engines loaded.
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
int register_config_cli(void)
Exposed initialization method for core process.
void ast_verb_console_unregister(void)
Unregister this thread's console verbosity level.
void ast_verb_console_register(int *level)
Register this thread's console verbosity level pointer.
#define ast_debug(level,...)
Log a DEBUG message.
#define VERBOSE_PREFIX_10
int ast_is_logger_initialized(void)
Test if logger is initialized.
#define ast_verb(level,...)
int ast_verb_console_get(void)
Get this thread's console verbosity level.
const char * ast_logger_get_dateformat(void)
Get the logger configured date format.
#define VERBOSE_MAGIC2LEVEL(x)
#define VERBOSE_HASMAGIC(x)
I/O Management (derived from Cheops-NG)
int ast_get_termcols(int fd)
Columns of Terminal.
int ast_sd_notify(const char *state)
a wrapper for sd_notify(): notify systemd of any state changes.
int ast_sd_get_fd_un(int type, const char *path)
Find a listening AF_LOCAL file descriptor provided by socket activation.
Asterisk JSON abstraction layer.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
int ast_json_init(void)
Initialize the JSON library.
A set of macros to manage forward-linked lists.
#define AST_RWLIST_REMOVE_CURRENT
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
#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_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_RWLIST_TRAVERSE_SAFE_END
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_LOCK(head)
Locks a list.
#define AST_RWLIST_TRAVERSE
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define AST_RWLIST_INSERT_HEAD
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
Asterisk locking-related definitions:
#define AST_PTHREADT_NULL
#define ast_mutex_unlock(a)
#define ast_mutex_lock(a)
#define AST_MUTEX_DEFINE_STATIC(mutex)
static char * levels[NUMLOGLEVELS]
Logging channels used in the Asterisk logging system.
static char hostname[MAXHOSTNAMELEN]
#define WEXITSTATUS(status)
#define WIFEXITED(status)
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define EVENT_FLAG_SYSTEM
Asterisk module definitions.
enum ast_module_reload_result ast_module_reload(const char *name)
Reload asterisk modules.
int mwi_init(void)
Initialize the mwi core.
Wrapper for network related headers, masking differences between various operating systems....
Options provided by main asterisk program.
#define ast_opt_dump_core
int ast_language_is_prefix
The following variable controls the layout of localized sound files. If 0, use the historical layout ...
#define MAX_PJ_LOG_MAX_LEVEL
#define ast_opt_transcode_via_slin
#define ast_opt_reconnect
#define DEFAULT_PJPROJECT_CACHE_POOLS
#define ast_opt_generic_plc_on_equal_codecs
#define ast_opt_hide_connect
#define ast_opt_high_priority
#define ast_opt_timestamp
#define ast_opt_always_fork
#define ast_opt_hide_messaging_ami_events
#define ast_opt_sounds_search_custom
#define DEFAULT_PJ_LOG_MAX_LEVEL
#define ast_opt_generic_plc
#define ast_opt_cache_media_frames
#define ast_opt_exec_includes
char ast_defaultlanguage[]
#define ast_opt_transmit_silence
Asterisk file paths, configured in asterisk.conf.
const char * ast_config_AST_KEY_DIR
const char * ast_config_AST_CACHE_DIR
const char * ast_config_AST_RUN_GROUP
const char * ast_config_AST_SOCKET
const char * ast_config_AST_RUN_USER
const char * ast_config_AST_CTL_PERMISSIONS
const char * ast_config_AST_CTL_GROUP
const char * ast_config_AST_MODULE_DIR
const char * ast_config_AST_PID
const char * ast_config_AST_RUN_DIR
const char * ast_config_AST_DATA_DIR
const char * ast_config_AST_CONFIG_DIR
const char * ast_config_AST_SPOOL_DIR
const char * ast_config_AST_AGI_DIR
const char * ast_config_AST_VAR_DIR
const char * ast_config_AST_SYSTEM_NAME
const char * ast_config_AST_SBIN_DIR
const char * ast_config_AST_CONFIG_FILE
const char * ast_config_AST_LOG_DIR
const char * ast_config_AST_CTL_OWNER
const char * ast_config_AST_DB
Core PBX routines and definitions.
int ast_pickup_init(void)
Initialize pickup.
#define ast_poll(a, b, c)
Presence state management.
int ast_presence_state_engine_init(void)
Pluggable RTP Architecture.
#define AST_RTP_PT_LAST_REASSIGN
#define AST_RTP_PT_FIRST_DYNAMIC
Scheduler Routines (derived from cheops)
Security Event Reporting API.
int ast_security_stasis_init(void)
initializes stasis topic/event types for ast_security_topic and ast_security_event_type
unsigned int ast_FD_SETSIZE
static int ast_select(int nfds, ast_fdset *rfds, ast_fdset *wfds, ast_fdset *efds, struct timeval *tvp)
Waits for activity on a group of channels.
Sorcery Data Access Layer API.
int ast_sorcery_init(void)
Initialize the sorcery API.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
int stasis_init(void)
Initialize the Stasis subsystem.
int ast_endpoint_stasis_init(void)
Initialization function for endpoint stasis support.
int ast_stasis_system_init(void)
Initialize the stasis system topic and message types.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
static force_inline char * ast_str_to_lower(char *str)
Convert a string to all lower-case.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"....
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
int ast_in_delimited_string(const char *needle, const char *haystack, char delim)
Check if there is an exact match for 'needle' between delimiters in 'haystack'.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
struct ast_atexit::@319 list
descriptor for a cli entry.
int args
This gets set in ast_cli_register()
Structure used to handle boolean flags.
Abstract JSON element (object, array, string, int, ...).
Support for dynamic strings.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
String vector definitions.
struct profile_entry e[0]
struct thread_list_t::@320 list
TTY/TDD Generation support.
Handy terminal functions for vt* terms.
const char * term_quit(void)
int ast_term_color_code(struct ast_str **str, int fgcolor, int bgcolor)
Append a color sequence to an ast_str.
const char * ast_term_reset(void)
Returns the terminal reset code.
const char * ast_term_color(int fgcolor, int bgcolor)
Return a color sequence string.
const char * term_end(void)
#define COLORIZE(fg, bg, str)
#define COLORIZE_FMT
Shortcut macros for coloring a set of text.
#define AST_THREADSTORAGE_CUSTOM(a, b, c)
Define a thread storage variable, with custom initialization and cleanup.
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Support for translation of data formats. translate.c.
int ast_translate_init(void)
Initialize the translation matrix and index to format conversion table.
u-Law to Signed linear conversion
void ast_ulaw_init(void)
Set up mu-law conversion table.
UTF-8 information and validation functions.
int ast_utf8_init(void)
Register UTF-8 tests.
static int inbuf(struct baseio *bio, FILE *fi)
utility used by inchar(), for base_encode()
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_clear_flag64(p, flag)
#define ast_pthread_create_background(a, b, c, d)
char * ast_eid_to_str(char *s, int maxlen, struct ast_eid *eid)
Convert an EID to a string.
int ast_get_tid(void)
Get current thread ID.
#define ast_pthread_create_detached(a, b, c, d)
#define ast_fd_set_flags(fd, flags)
Set flags on the given file descriptor.
#define ast_pthread_create_detached_background(a, b, c, d)
#define ast_set_flag64(p, flag)
struct ast_eid ast_eid_default
Global EID.
Universally unique identifier support.
void ast_uuid_init(void)
Initialize the UUID system.
char * ast_uuid_generate_str(char *buf, size_t size)
Generate a UUID string.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_PTR_FREE(vec)
Deallocates this vector pointer.
#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_GET(vec, idx)
Get an element from a vector.
Asterisk XML Documentation API.