49 #include <switch_private.h> 51 #include <sys/resource.h> 56 #ifdef HAVE_SYS_PRCTL_H 57 #include <sys/prctl.h> 59 #ifdef SOLARIS_PRIVILEGES 74 #define pclose _pclose 78 #include <systemd/sd-daemon.h> 106 duration.
yr, duration.
yr == 1 ?
"" :
"s",
107 duration.
day, duration.
day == 1 ?
"" :
"s",
108 duration.
hr, duration.
hr == 1 ?
"" :
"s",
109 duration.
min, duration.
min == 1 ?
"" :
"s",
110 duration.
sec, duration.
sec == 1 ?
"" :
"s",
111 duration.
ms, duration.
ms == 1 ?
"" :
"s", duration.
mms, duration.
mms == 1 ?
"" :
"s");
134 char guess_ip4[256] =
"";
135 char guess_ip6[256] =
"";
136 char old_ip4[256] =
"";
137 char old_ip6[256] =
"";
138 int ok4 = 1, ok6 = 1;
146 if (
zstr(hostname)) {
148 }
else if (strcmp(hostname, runtime.
hostname)) {
171 if (!(ok4 = !strcmp(
main_ip4, guess_ip4))) {
187 if (!(ok6 = !strcmp(
main_ip6, guess_ip6))) {
209 if (ok4 == 2 || ok6 == 2) {
245 if ((runtime.
console = fopen(console,
"a")) == 0) {
246 fprintf(stderr,
"Cannot open output file %s.\n", console);
258 #ifdef HAVE_SYS_IOCTL_H 259 #include <sys/ioctl.h> 265 CONSOLE_SCREEN_BUFFER_INFO csbi;
268 if ((ret = GetConsoleScreenBufferInfo(GetStdHandle( STD_OUTPUT_HANDLE ), &csbi))) {
269 if (x) *x = csbi.dwSize.X;
270 if (y) *y = csbi.dwSize.Y;
273 #elif defined(TIOCGWINSZ) 275 ioctl(0, TIOCGWINSZ, &w);
277 if (x) *x = w.ws_col;
278 if (y) *y = w.ws_row;
294 int index, tmp_index = 0;
302 if (cur == state_handler) {
305 tmp[tmp_index++] =
cur;
310 for (index = 0; index < tmp_index; index++) {
374 var =
"freeswitch.local";
377 domain = strdup(var);
379 domain = (
char *) var;
406 char *val = NULL, *v;
421 char *val = NULL, *v;
453 char *v = strdup(value);
473 if (!val2 || strcmp(val, val2) != 0) {
478 }
else if (!
zstr(val2)) {
484 char *v = strdup(value);
608 mypool = pool ? 0 : 1;
643 GetModuleFileName(NULL, base_dir,
BUFSIZE);
644 lastbacklash = strrchr(base_dir,
'\\');
645 base_dir[(lastbacklash - base_dir)] =
'\0';
647 SetCurrentDirectory(base_dir);
649 strcpy(base_dir, tmp);
667 #ifdef SWITCH_MOD_DIR 678 #ifdef SWITCH_LIB_DIR 689 #ifdef SWITCH_CONF_DIR 700 #ifdef SWITCH_LOG_DIR 711 #ifdef SWITCH_RUN_DIR 722 #ifdef SWITCH_RECORDINGS_DIR 733 #ifdef SWITCH_SOUNDS_DIR 744 #ifdef SWITCH_STORAGE_DIR 755 #ifdef SWITCH_CACHE_DIR 777 #ifdef SWITCH_SCRIPT_DIR 788 #ifdef SWITCH_HTDOCS_DIR 799 #ifdef SWITCH_GRAMMAR_DIR 810 #ifdef SWITCH_FONTS_DIR 821 #ifdef SWITCH_IMAGES_DIR 832 #ifdef SWITCH_DATA_DIR 843 #ifdef SWITCH_LOCALSTATE_DIR 854 #ifdef SWITCH_CERTS_DIR 862 #ifdef SWITCH_TEMP_DIR 866 GetTempPath(dwBufSize, lpPathBuffer);
867 lpPathBuffer[strlen(lpPathBuffer)-1] = 0;
869 strcpy(lpPathBuffer, tmp);
912 #ifdef SOLARIS_PRIVILEGES 913 priv_set_t *basicset;
916 setpflags(PRIV_AWARE, 1);
919 basicset = priv_str_to_set(
"basic",
",", NULL);
920 if (setppriv(PRIV_SET, PRIV_EFFECTIVE, basicset) != 0) {
921 fprintf(stderr,
"ERROR: Failed to acquire basic privileges (%s)\n", strerror(errno));
925 if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_PROC_CLOCK_HIGHRES, NULL) < 0) {
926 fprintf(stderr,
"ERROR: Failed to acquire proc_clock_highres privilege (%s)\n", strerror(errno));
931 if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_SYS_RESOURCE, NULL) < 0) {
932 fprintf(stderr,
"ERROR: Failed to acquire sys_resource privilege (%s)\n", strerror(errno));
937 if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_FILE_DAC_SEARCH, NULL) < 0) {
938 fprintf(stderr,
"ERROR: Failed to acquire file_dac_search privilege (%s)\n", strerror(errno));
948 return SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS);
950 #if defined(USE_SCHED_SETSCHEDULER) && ! defined(SOLARIS_PRIVILEGES) 954 struct sched_param sched = { 0 };
955 sched.sched_priority = 0;
956 if (sched_setscheduler(0, SCHED_OTHER, &sched) < 0) {
957 fprintf(stderr,
"ERROR: Failed to set SCHED_OTHER scheduler (%s)\n", strerror(errno));
962 #ifdef HAVE_SETPRIORITY 966 if (setpriority(PRIO_PROCESS, getpid(), 19) < 0) {
967 fprintf(stderr,
"ERROR: Could not set nice level\n");
971 if (nice(19) != 19) {
972 fprintf(stderr,
"ERROR: Could not set nice level\n");
984 return SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
986 #ifdef USE_SCHED_SETSCHEDULER 991 struct sched_param sched = { 0 };
995 #ifdef SOLARIS_PRIVILEGES 997 if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_PROC_PRIOCNTL, NULL) < 0) {
998 #ifdef PRIV_PROC_PRIOUP 1000 fprintf(stderr,
"WARN: Failed to acquire proc_priocntl privilege (%s)\n", strerror(errno));
1001 if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_PROC_PRIOUP, NULL) < 0) {
1002 fprintf(stderr,
"ERROR: Failed to acquire proc_prioup privilege (%s)\n", strerror(errno));
1006 fprintf(stderr,
"ERROR: Failed to acquire proc_priocntl privilege (%s)\n", strerror(errno));
1011 if (sched_setscheduler(0, SCHED_FIFO, &sched) < 0) {
1012 fprintf(stderr,
"WARN: Failed to set SCHED_FIFO scheduler (%s)\n", strerror(errno));
1017 if (setpriority(PRIO_PROCESS, 0, -10) < 0) {
1018 fprintf(stderr,
"ERROR: Could not set nice level\n");
1025 #ifdef USE_SCHED_SETSCHEDULER 1026 if (sched_setscheduler(0, SCHED_FIFO, &sched) < 0) {
1027 fprintf(stderr,
"ERROR: Failed to set SCHED_FIFO scheduler (%s)\n", strerror(errno));
1028 sched.sched_priority = 0;
1029 if (sched_setscheduler(0, SCHED_OTHER, &sched) < 0 ) {
1030 fprintf(stderr,
"ERROR: Failed to set SCHED_OTHER scheduler (%s)\n", strerror(errno));
1036 #ifdef HAVE_SETPRIORITY 1040 if (setpriority(PRIO_PROCESS, getpid(), -10) < 0) {
1041 fprintf(stderr,
"ERROR: Could not set nice level\n");
1045 if (nice(-10) != -10) {
1046 fprintf(stderr,
"ERROR: Could not set nice level\n");
1068 runtime.
cpu_count = sysconf (_SC_NPROCESSORS_ONLN);
1070 SYSTEM_INFO sysinfo;
1071 GetSystemInfo( &sysinfo );
1072 runtime.
cpu_count = sysinfo.dwNumberOfProcessors;
1086 uid_t runas_uid = 0;
1087 gid_t runas_gid = 0;
1088 struct passwd *runas_pw = NULL;
1094 runas_pw = getpwnam(user);
1096 fprintf(stderr,
"ERROR: Unknown user \"%s\"\n", user);
1099 runas_uid = runas_pw->pw_uid;
1103 struct group *gr = NULL;
1108 gr = getgrnam(group);
1110 fprintf(stderr,
"ERROR: Unknown group \"%s\"\n", group);
1113 runas_gid = gr->gr_gid;
1116 if (runas_uid && getuid() == runas_uid && (!runas_gid || runas_gid == getgid())) {
1122 #ifdef SOLARIS_PRIVILEGES 1124 if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_PROC_SETID, NULL) < 0) {
1125 fprintf(stderr,
"ERROR: Failed to acquire proc_setid privilege (%s)\n", strerror(errno));
1129 #ifdef HAVE_SETGROUPS 1135 if (setgroups(0, NULL) < 0) {
1136 fprintf(stderr,
"ERROR: Failed to drop group access list\n");
1145 if (setgid(runas_gid) < 0) {
1146 fprintf(stderr,
"ERROR: Failed to change gid!\n");
1153 if (setgid(runas_pw->pw_gid) < 0) {
1154 fprintf(stderr,
"ERROR: Failed to change gid!\n");
1157 #ifdef HAVE_INITGROUPS 1162 if (initgroups(runas_pw->pw_name, runas_pw->pw_gid) < 0) {
1163 fprintf(stderr,
"ERROR: Failed to set group access list for user\n");
1172 if (setuid(runas_uid) < 0) {
1173 fprintf(stderr,
"ERROR: Failed to change uid!\n");
1176 #ifdef HAVE_SYS_PRCTL_H 1177 if (prctl(PR_SET_DUMPABLE, 1) < 0) {
1178 fprintf(stderr,
"ERROR: Failed to enable core dumps!\n");
1190 HANDLE shutdown_event;
1191 char path[256] =
"";
1195 switch_snprintf(path,
sizeof(path),
"Global\\Freeswitch.%d", getpid());
1196 shutdown_event = CreateEvent(NULL,
FALSE,
FALSE, path);
1197 if (shutdown_event) {
1198 WaitForSingleObject(shutdown_event, INFINITE);
1235 char *ext_list = NULL;
1237 char *argv[20] = { 0 };
1245 ext_list = strdup(ext);
1252 for (x = 0; x < argc; x++) {
1253 if (argv[x] && ptype) {
1257 if (!is_mapped_type) {
1274 char *cf =
"mime.types";
1276 char *line_buf = NULL;
1278 char *mime_path = NULL;
1283 fd = fopen(mime_path,
"rb");
1291 char *type = line_buf;
1293 if (*line_buf ==
'#') {
1297 if ((p = strchr(line_buf,
'\r')) || (p = strchr(line_buf,
'\n'))) {
1301 if ((p = strchr(type,
'\t')) || (p = strchr(type,
' '))) {
1304 while (*p ==
' ' || *p ==
'\t') {
1324 #ifdef HAVE_SETRLIMIT 1335 memset(&rlp, 0,
sizeof(rlp));
1338 setrlimit(RLIMIT_STACK, &rlp);
1341 memset(&rlp, 0,
sizeof(rlp));
1342 rlp.rlim_cur = 999999;
1343 rlp.rlim_max = 999999;
1344 setrlimit(RLIMIT_NOFILE, &rlp);
1346 memset(&rlp, 0,
sizeof(rlp));
1347 rlp.rlim_cur = RLIM_INFINITY;
1348 rlp.rlim_max = RLIM_INFINITY;
1350 setrlimit(RLIMIT_CPU, &rlp);
1351 setrlimit(RLIMIT_DATA, &rlp);
1352 setrlimit(RLIMIT_FSIZE, &rlp);
1354 setrlimit(RLIMIT_NPROC, &rlp);
1356 #ifdef RLIMIT_RTPRIO 1357 setrlimit(RLIMIT_RTPRIO, &rlp);
1360 #if !defined(__OpenBSD__) && !defined(__NetBSD__) 1361 setrlimit(RLIMIT_AS, &rlp);
1379 char *ipv6 = strchr(ip_str,
':');
1397 ip.
v4 = htonl(ip.
v4);
1406 }
else if (strchr(list_name,
'/')) {
1407 if (strchr(list_name,
',')) {
1408 char *list_name_dup = strdup(list_name);
1416 for (i = 0; i < argc; i++) {
1429 free(list_name_dup);
1454 switch_xml_t xml = NULL, x_lists = NULL, x_list = NULL, x_node = NULL, cfg = NULL;
1456 char guess_ip[16] =
"";
1458 char guess_mask[16] =
"";
1476 memset(&IP_LIST, 0,
sizeof(IP_LIST));
1481 tmp_name =
"rfc6598.auto";
1487 tmp_name =
"rfc1918.auto";
1496 tmp_name =
"wan.auto";
1508 tmp_name =
"wan_v6.auto";
1516 tmp_name =
"wan_v4.auto";
1529 tmp_name =
"any_v6.auto";
1536 tmp_name =
"any_v4.auto";
1543 tmp_name =
"nat.auto";
1555 tmp_name =
"loopback.auto";
1562 tmp_name =
"localnet.auto";
1599 const char *cidr = NULL, *host = NULL, *mask = NULL, *domain = NULL, *port = NULL;
1618 port_range.
port = atoi(port);
1623 for(i=0; i < argc; i++) {
1624 port_range.
ports[i] = atoi(argv[i]);
1660 if (
id && user_cidr) {
1675 if (
id && user_cidr) {
1689 }
else if (host && mask) {
1769 #ifdef HAVE_CPU_SET_MACROS 1775 if (!sched_setaffinity(0,
sizeof(
set), &
set)) {
1781 if (SetThreadAffinityMask(GetCurrentThread(), (DWORD_PTR) cpu)) {
1811 memset(&runtime, 0,
sizeof(runtime));
1835 flags &= ~SCF_LOG_DISABLE;
1847 runtime.
cpu_count = sysconf (_SC_NPROCESSORS_ONLN);
1850 SYSTEM_INFO sysinfo;
1851 GetSystemInfo( &sysinfo );
1852 runtime.
cpu_count = sysinfo.dwNumberOfProcessors;
1858 if (sqlite3_initialize() != SQLITE_OK) {
1859 *err =
"FATAL ERROR! Could not initialize SQLite\n";
1865 *err =
"FATAL ERROR! Could not initialize APR\n";
1870 *err =
"FATAL ERROR! Could not allocate memory pool\n";
1906 runtime.
flags |= flags;
1917 OpenSSL_add_all_algorithms();
2001 static void handle_SIGBUS(
int sig)
2036 if (!strcasecmp(name,
"opus")) {
2038 }
else if (!strncasecmp(name,
"h26", 3)) {
2040 }
else if (!strncasecmp(name,
"vp", 2)) {
2070 if (!strcasecmp(var,
"G723") || !strcasecmp(var,
"iLBC")) {
2093 if (!strcasecmp(var,
"loglevel")) {
2095 if (*val > 47 && *val < 58) {
2104 #ifdef HAVE_SETRLIMIT 2105 }
else if (!strcasecmp(var,
"dump-cores") &&
switch_true(val)) {
2107 memset(&rlp, 0,
sizeof(rlp));
2108 rlp.rlim_cur = RLIM_INFINITY;
2109 rlp.rlim_max = RLIM_INFINITY;
2110 setrlimit(RLIMIT_CORE, &rlp);
2112 }
else if (!strcasecmp(var,
"debug-level")) {
2113 int tmp = atoi(val);
2114 if (tmp > -1 && tmp < 11) {
2117 }
else if (!strcasecmp(var,
"max-db-handles")) {
2118 long tmp = atol(val);
2120 if (tmp > 4 && tmp < 5001) {
2125 }
else if (!strcasecmp(var,
"odbc-skip-autocommit-flip")) {
2129 }
else if (!strcasecmp(var,
"db-handle-timeout")) {
2130 long tmp = atol(val);
2132 if (tmp > 0 && tmp < 5001) {
2138 }
else if (!strcasecmp(var,
"event-heartbeat-interval")) {
2139 long tmp = atol(val);
2147 }
else if (!strcasecmp(var,
"multiple-registrations")) {
2149 }
else if (!strcasecmp(var,
"auto-create-schemas")) {
2155 }
else if (!strcasecmp(var,
"session-thread-pool")) {
2161 }
else if (!strcasecmp(var,
"auto-clear-sql")) {
2167 }
else if (!strcasecmp(var,
"api-expansion")) {
2173 }
else if (!strcasecmp(var,
"enable-early-hangup") &&
switch_true(val)) {
2175 }
else if (!strcasecmp(var,
"colorize-console") &&
switch_true(val)) {
2177 }
else if (!strcasecmp(var,
"core-db-pre-trans-execute") && !
zstr(val)) {
2179 }
else if (!strcasecmp(var,
"core-db-post-trans-execute") && !
zstr(val)) {
2181 }
else if (!strcasecmp(var,
"core-db-inner-pre-trans-execute") && !
zstr(val)) {
2183 }
else if (!strcasecmp(var,
"core-db-inner-post-trans-execute") && !
zstr(val)) {
2185 }
else if (!strcasecmp(var,
"dialplan-timestamps")) {
2191 }
else if (!strcasecmp(var,
"mailer-app") && !
zstr(val)) {
2193 }
else if (!strcasecmp(var,
"mailer-app-args") && val) {
2195 }
else if (!strcasecmp(var,
"sessions-per-second") && !
zstr(val)) {
2197 }
else if (!strcasecmp(var,
"max-dtmf-duration") && !
zstr(val)) {
2198 int tmp = atoi(val);
2202 }
else if (!strcasecmp(var,
"min-dtmf-duration") && !
zstr(val)) {
2203 int tmp = atoi(val);
2207 }
else if (!strcasecmp(var,
"default-dtmf-duration") && !
zstr(val)) {
2208 int tmp = atoi(val);
2212 }
else if (!strcasecmp(var,
"enable-use-system-time")) {
2214 }
else if (!strcasecmp(var,
"enable-monotonic-timing")) {
2216 }
else if (!strcasecmp(var,
"enable-softtimer-timerfd")) {
2222 if (strcasecmp(val,
"broadcast")) {
2224 }
else if (strcasecmp(val,
"fd-per-timer")) {
2230 }
else if (!strcasecmp(var,
"enable-clock-nanosleep")) {
2232 }
else if (!strcasecmp(var,
"enable-cond-yield")) {
2234 }
else if (!strcasecmp(var,
"enable-timer-matrix")) {
2236 }
else if (!strcasecmp(var,
"max-sessions") && !
zstr(val)) {
2238 }
else if (!strcasecmp(var,
"verbose-channel-events") && !
zstr(val)) {
2245 }
else if (!strcasecmp(var,
"threaded-system-exec") && !
zstr(val)) {
2256 }
else if (!strcasecmp(var,
"spawn-instead-of-system") && !
zstr(val)) {
2267 }
else if (!strcasecmp(var,
"exclude-error-log-from-xml-cdr") && !
zstr(val)) {
2274 }
else if (!strcasecmp(var,
"min-idle-cpu") && !
zstr(val)) {
2276 }
else if (!strcasecmp(var,
"tipping-point") && !
zstr(val)) {
2278 }
else if (!strcasecmp(var,
"cpu-idle-smoothing-depth") && !
zstr(val)) {
2280 }
else if (!strcasecmp(var,
"events-use-dispatch") && !
zstr(val)) {
2282 }
else if (!strcasecmp(var,
"initial-event-threads") && !
zstr(val)) {
2288 "Implicitly setting events-use-dispatch based on usage of this initial-event-threads parameter.\n");
2306 }
else if (!strcasecmp(var,
"1ms-timer") &&
switch_true(val)) {
2308 }
else if (!strcasecmp(var,
"timer-affinity") && !
zstr(val)) {
2309 if (!strcasecmp(val,
"disabled")) {
2314 }
else if (!strcasecmp(var,
"ice-resolve-candidate")) {
2316 }
else if (!strcasecmp(var,
"rtp-start-port") && !
zstr(val)) {
2318 }
else if (!strcasecmp(var,
"rtp-end-port") && !
zstr(val)) {
2320 }
else if (!strcasecmp(var,
"rtp-port-usage-robustness") &&
switch_true(val)) {
2322 }
else if (!strcasecmp(var,
"core-db-name") && !
zstr(val)) {
2324 }
else if (!strcasecmp(var,
"core-db-dsn") && !
zstr(val)) {
2326 }
else if (!strcasecmp(var,
"core-non-sqlite-db-required") && !
zstr(val)) {
2328 }
else if (!strcasecmp(var,
"core-dbtype") && !
zstr(val)) {
2329 if (!strcasecmp(val,
"MSSQL")) {
2334 }
else if (!strcasecmp(var,
"switchname") && !
zstr(val)) {
2337 }
else if (!strcasecmp(var,
"rtp-retain-crypto-keys")) {
2340 "rtp-retain-crypto-keys enabled. Could be used to decrypt secure media.\n");
2343 }
else if (!strcasecmp(var,
"caller-profile-soft-variables-uses-prefix") && !
zstr(val)) {
2350 }
else if (!strcasecmp(var,
"caller-profile-soft-lookup-values") && !
zstr(val)) {
2357 }
else if (!strcasecmp(var,
"event-channel-key-separator") && !
zstr(val)) {
2359 }
else if (!strcasecmp(var,
"event-channel-enable-hierarchy-deliver") && !
zstr(val)) {
2366 }
else if (!strcasecmp(var,
"event-channel-hierarchy-deliver-once") && !
zstr(val)) {
2373 }
else if (!strcasecmp(var,
"event-channel-log-undeliverable-json") && !
zstr(val)) {
2380 }
else if (!strcasecmp(var,
"max-audio-channels") && !
zstr(val)) {
2410 ".=============================================================.\n" 2411 "| _____ ______ _____ _____ ____ _ _ |\n" 2412 "| | ___| __ ___ ___/ ___\\ \\ / /_ _|_ _/ ___| | | | |\n" 2413 "| | |_ | '__/ _ \\/ _ \\___ \\\\ \\ /\\ / / | | | || | | |_| | |\n" 2414 "| | _|| | | __/ __/___) |\\ V V / | | | || |___| _ | |\n" 2415 "| |_| |_| \\___|\\___|____/ \\_/\\_/ |___| |_| \\____|_| |_| |\n" 2417 ".=============================================================." 2420 "| Anthony Minessale II, Michael Jerris, Brian West, Others |\n" 2421 "| FreeSWITCH (http://www.freeswitch.org) |\n" 2422 "| Paypal Donations Appreciated: paypal@freeswitch.org |\n" 2423 "| Brought to you by ClueCon http://www.cluecon.com/ |\n" 2424 ".=============================================================.\n" 2431 *err =
"NO SUITABLE DATABASE INTERFACE IS AVAILABLE TO SERVE 'core-db-dsn'!\n";
2436 *err =
"Error activating database";
2448 const char *use = NULL;
2472 *err =
"Cannot load modules";
2490 use = (x > 100) ?
cc :
cc_s;
2505 "\nFreeSWITCH Version %s (%s)\n\nFreeSWITCH Started\nMax Sessions [%u]\nSession Rate [%d]\nSQL [%s]\n",
2527 sd_notifyf(0,
"READY=1\n" 2528 "MAINPID=%lu\n", (
unsigned long) getpid());
2538 memset(duration, 0,
sizeof(*duration));
2539 duration->
mms = (uint32_t) (total_ms % 1000);
2540 duration->
ms = (uint32_t) (temp % 1000);
2542 duration->
sec = (uint32_t) (temp % 60);
2544 duration->
min = (uint32_t) (temp % 60);
2546 duration->
hr = (uint32_t) (temp % 24);
2548 duration->
day = (uint32_t) (temp % 365);
2549 duration->
yr = (uint32_t) (temp / 365);
2559 static void win_shutdown(
void)
2562 HANDLE shutdown_event;
2565 snprintf(path,
sizeof(path),
"Global\\Freeswitch.%d", getpid());
2568 shutdown_event = OpenEvent(EVENT_MODIFY_STATE,
FALSE, path);
2570 if (shutdown_event) {
2572 SetEvent(shutdown_event);
2574 CloseHandle(shutdown_event);
2582 signal(SIGINT, SIG_IGN);
2584 signal(SIGPIPE, SIG_IGN);
2587 signal(SIGALRM, SIG_IGN);
2590 signal(SIGQUIT, SIG_IGN);
2593 signal(SIGPOLL, SIG_IGN);
2596 signal(SIGIO, SIG_IGN);
2599 signal(SIGBUS, handle_SIGBUS);
2653 int *intval = (
int *) val;
2654 int oldintval = 0, newintval = 0;
2657 oldintval = *intval;
2667 char *arg = (
char *) val;
2668 char *tech = NULL, *prof = NULL;
2675 if ((prof = strchr(tech,
':'))) {
2679 if (!strcasecmp(tech,
"flush")) {
2684 if ((prof = strchr(tech,
':'))) {
2717 if (oldintval > -1) {
2729 if (oldintval > -1) {
2741 if (oldintval > -1) {
2836 "Shutdown in progress, %u session(s) remain.\nShutting down %s\n",
2854 sd_notifyf(0,
"STOPPING=1\n");
2913 if (oldintval > -1) {
2922 double *dval = (
double *) val;
2936 if (oldintval == -1) {
2961 if (oldintval > 0) {
2981 *intval = newintval;
2990 return runtime.
flags;
3151 #if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) 3153 struct rlimit rlim_save;
3155 memset(&rlim, 0,
sizeof(rlim));
3156 getrlimit(RLIMIT_STACK, &rlim);
3158 memset(&rlim_save, 0,
sizeof(rlim_save));
3159 getrlimit(RLIMIT_STACK, &rlim_save);
3161 rlim.rlim_cur = rlim.rlim_max;
3162 if (setrlimit(RLIMIT_STACK, &rlim) < 0) {
3168 dup2(sth->
fds[1], STDOUT_FILENO);
3171 sth->
ret = system(sth->
cmd);
3173 #if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) 3174 if (setrlimit(RLIMIT_STACK, &rlim_save) < 0) {
3233 #if defined(HAVE_GETDTABLESIZE) 3234 max = getdtablesize();
3236 max = sysconf(_SC_OPEN_MAX);
3249 for (i = 3; i < open_max; i++) {
3251 for (j = 0; j < keep_ttl; j++) {
3298 char *dcmd = strdup(cmd);
3299 #if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) 3301 struct rlimit rlim_save;
3310 waitpid(pid, NULL, 0);
3316 #if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__) 3317 memset(&rlim, 0,
sizeof(rlim));
3318 getrlimit(RLIMIT_STACK, &rlim);
3320 memset(&rlim_save, 0,
sizeof(rlim_save));
3321 getrlimit(RLIMIT_STACK, &rlim_save);
3323 rlim.rlim_cur = rlim.rlim_max;
3324 if (setrlimit(RLIMIT_STACK, &rlim) < 0) {
3329 if (system(dcmd) == -1) {
3351 if (spawn_instead_of_system) {
3369 extern char **environ;
3381 char *pdata = NULL, *argv[64];
3382 posix_spawn_file_actions_t action;
3383 posix_spawnattr_t *attr;
3386 struct pollfd pfds[2] = { {0} };
3396 argv[2] = (
char *)cmd;
3398 if (
zstr(argv[0])) {
3399 argv[0] =
"/bin/sh";
3402 if (!(pdata = strdup(cmd))) {
3411 if (!(attr = malloc(
sizeof(posix_spawnattr_t)))) {
3418 if (pipe(cout_pipe)) {
3425 if (pipe(cerr_pipe)) {
3427 close(cout_pipe[0]);
3428 close(cout_pipe[1]);
3435 memset(attr, 0,
sizeof(posix_spawnattr_t));
3436 posix_spawnattr_init(attr);
3437 posix_spawnattr_setflags(attr, POSIX_SPAWN_USEVFORK);
3439 posix_spawn_file_actions_init(&action);
3442 posix_spawn_file_actions_addclose(&action, cout_pipe[0]);
3443 posix_spawn_file_actions_addclose(&action, cerr_pipe[0]);
3444 posix_spawn_file_actions_adddup2(&action, cout_pipe[1], 1);
3445 posix_spawn_file_actions_adddup2(&action, cerr_pipe[1], 2);
3447 posix_spawn_file_actions_addclose(&action, cout_pipe[1]);
3448 posix_spawn_file_actions_addclose(&action, cerr_pipe[1]);
3451 if (posix_spawnp(&pid, argv[0], &action, attr, argv, environ) != 0) {
3455 close(cout_pipe[0]), close(cerr_pipe[0]);
3456 close(cout_pipe[1]), close(cerr_pipe[1]);
3460 close(cout_pipe[1]), close(cerr_pipe[1]);
3462 pfds[0] = (
struct pollfd) {
3468 pfds[1] = (
struct pollfd) {
3474 while (poll(pfds, 2, -1) > 0) {
3475 if (pfds[0].revents & POLLIN) {
3476 int bytes_read = read(cout_pipe[0], buffer,
sizeof(buffer));
3478 }
else if (pfds[1].revents & POLLIN) {
3479 int bytes_read = read(cerr_pipe[0], buffer,
sizeof(buffer));
3486 close(cout_pipe[0]), close(cerr_pipe[0]);
3490 if (waitpid(pid, &status, 0) != pid) {
3492 }
else if (status != 0) {
3498 posix_spawnattr_destroy(attr);
3500 posix_spawn_file_actions_destroy(&action);
3514 #ifdef HAVE_SETRLIMIT 3517 memset(&rlp, 0,
sizeof(rlp));
3518 getrlimit(RLIMIT_STACK, &rlp);
3520 *cur = rlp.rlim_cur;
3521 *max = rlp.rlim_max;
3544 if (spawn_instead_of_system){
3549 FILE* pipe = popen(cmd,
"r");
3550 if (!pipe)
return 1;
3552 while (!feof(pipe)) {
3553 while ((bytes = fread(buffer, 1, 128, pipe)) > 0) {
3554 if (stream != NULL) {
3572 uint16_t start_port = 0;
3583 uint16_t end_port = 0;
void switch_channel_global_uninit(void)
void switch_core_set_signal_handlers(void)
switch_memory_pool_t * switch_core_memory_init(void)
#define switch_core_permanent_strdup(_todup)
Copy a string using permanent memory allocation.
int32_t change_user_group(const char *user, const char *group)
Change user and/or group of the running process.
const char * switch_core_get_switchname(void)
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
void switch_time_sync(void)
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core's master pool.
switch_status_t switch_msrp_destroy(void)
uint32_t min_dtmf_duration
int32_t switch_core_sps(void)
char * core_db_inner_post_trans_execute
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
switch_status_t switch_core_mime_add_type(const char *type, const char *ext)
const char * switch_xml_attr_soft(_In_ switch_xml_t xml, _In_z_ const char *attr)
returns the value of the requested tag attribute, or "" if not found
static void check_ip(void)
switch_status_t switch_thread_cond_create(switch_thread_cond_t **cond, switch_memory_pool_t *pool)
switch_frame_t dummy_cng_frame
switch_memory_pool_t * pool
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
switch_status_t switch_xml_locate_domain(_In_z_ const char *domain_name, _In_opt_ switch_event_t *params, _Out_ switch_xml_t *root, _Out_ switch_xml_t *domain)
void switch_core_memory_reclaim_logger(void)
switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_t manage)
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
#define switch_test_subnet(_ip, _net, _mask)
void switch_core_dump_variables(switch_stream_handle_t *stream)
switch_status_t switch_event_add_header_string_nodup(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
switch_text_channel_t
A target to write log/debug info to.
void switch_nat_shutdown(void)
Shuts down the NAT Traversal System.
int32_t switch_core_sps_peak_fivemin(void)
#define SWITCH_CHANNEL_LOG
switch_time_t switch_core_uptime(void)
Number of microseconds the system has been up.
uint16_t switch_core_get_rtp_port_range_end_port(void)
Get RTP port range end value.
switch_status_t switch_core_hash_destroy(_Inout_ switch_hash_t **hash)
Destroy an existing hash table.
const char *const const double number
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
int32_t switch_core_sessions_peak(void)
const char * switch_xml_attr(_In_opt_ switch_xml_t xml, _In_opt_z_ const char *attr)
returns the value of the requested tag attribute, or NULL if not found
#define switch_event_del_header(_e, _h)
const switch_state_handler_table_t * state_handlers[SWITCH_MAX_STATE_HANDLERS]
uint32_t switch_core_sessions_per_second(_In_ uint32_t new_limit)
Set/Get Session Rate Limit.
switch_stream_handle_raw_write_function_t raw_write_function
int switch_core_test_flag(int flag)
#define switch_core_hash_init(_hash)
int switch_core_add_state_handler(const switch_state_handler_table_t *state_handler)
const char * switch_version_full(void)
void switch_ssl_init_ssl_locks(void)
void switch_time_set_nanosleep(switch_bool_t enable)
switch_status_t switch_network_list_create(switch_network_list_t **list, const char *name, switch_bool_t default_type, switch_memory_pool_t *pool)
switch_status_t switch_network_list_add_cidr_token(switch_network_list_t *list, const char *cidr_str, switch_bool_t ok, const char *token)
char * core_db_post_trans_execute
int32_t set_low_priority(void)
void switch_core_memory_stop(void)
switch_bool_t switch_core_running(void)
void switch_scheduler_task_thread_start(void)
Start the scheduler system.
int switch_parse_cidr(const char *string, ip_t *ip, ip_t *mask, uint32_t *bitp)
int switch_max_file_desc(void)
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
void switch_close_extra_files(int *keep, int keep_ttl)
uint32_t max_audio_channels
int switch_core_session_sync_clock(void)
switch_status_t switch_threadattr_stacksize_set(switch_threadattr_t *attr, switch_size_t stacksize)
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
switch_memory_pool_t * pool
switch_status_t switch_core_session_read_video_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
Read a video frame from a session.
switch_status_t switch_event_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt,...) PRINTF_FUNCTION(4
Add a header to an event.
Representation of an event.
void switch_core_set_globals(void)
Initiate Globals.
void switch_core_session_init(switch_memory_pool_t *pool)
switch_status_t switch_network_list_add_host_port_mask(switch_network_list_t *list, const char *host, const char *mask_str, switch_bool_t ok, switch_network_port_range_p port)
const char *const const char *const const cJSON *const value
#define switch_network_list_add_cidr(_list, _cidr_str, _ok)
switch_thread_rwlock_t * global_var_rwlock
switch_status_t switch_core_session_read_lock(_In_ switch_core_session_t *session)
Acquire a read lock on the session.
switch_bool_t switch_network_list_validate_ip6_port_token(switch_network_list_t *list, ip_t ip, int port, const char **token)
void switch_event_launch_dispatch_threads(uint32_t max)
switch_management_interface_t * switch_loadable_module_get_management_interface(const char *relative_oid)
Retrieve the management interface by it's registered name.
switch_status_t switch_core_destroy(void)
Destroy the core.
switch_event_t * global_vars
void switch_scheduler_task_thread_stop(void)
Stop the scheduler system.
uint32_t switch_default_ptime(const char *name, uint32_t number)
A representation of an XML tree.
switch_mutex_t * throttle_mutex
#define SWITCH_DEFAULT_DTMF_DURATION
switch_status_t switch_thread_cond_wait(switch_thread_cond_t *cond, switch_mutex_t *mutex)
uint32_t switch_core_cpu_count(void)
const char * switch_core_mime_type2ext(const char *mime)
switch_call_cause_t shutdown_cause
switch_status_t switch_console_shutdown(void)
switch_status_t switch_core_init_and_modload(switch_core_flag_t flags, switch_bool_t console, const char **err)
static void switch_load_core_config(const char *file)
switch_status_t switch_event_dup(switch_event_t **event, switch_event_t *todup)
Duplicate an event.
void switch_time_set_timerfd(int enable)
#define SWITCH_MAX_STATE_HANDLERS
static switch_thread_t * thread
switch_status_t switch_core_thread_set_cpu_affinity(int cpu)
switch_thread_cond_t * cond
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
switch_status_t switch_core_get_stacksizes(switch_size_t *cur, switch_size_t *max)
switch_port_t switch_rtp_set_start_port(switch_port_t port)
Set/Get RTP start port.
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
uint32_t switch_core_flag_t
uint32_t microseconds_per_tick
struct switch_runtime runtime
uint32_t switch_scheduler_add_task(time_t task_runtime, switch_scheduler_func_t func, const char *desc, const char *group, uint32_t cmd_id, void *cmd_arg, switch_scheduler_flag_t flags)
Schedule a task in the future.
void switch_core_sqldb_destroy(void)
switch_status_t switch_core_session_read_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
Read a frame from a session.
void switch_loadable_module_shutdown(void)
Shutdown the module backend and call the shutdown routine in all loaded modules.
int switch_stream_system(const char *cmd, switch_stream_handle_t *stream)
#define SWITCH_PREFIX_DIR
switch_hash_index_t * switch_core_mime_index(void)
switch_memory_pool_t * pool
uint16_t switch_core_get_rtp_port_range_start_port(void)
Get RTP port range start value.
switch_bool_t switch_check_network_list_ip_port_token(const char *ip_str, int port, const char *list_name, const char **token)
switch_size_t switch_core_session_id(void)
Provide the current session_id.
const switch_state_handler_table_t * switch_core_get_state_handler(int index)
uint32_t switch_core_max_dtmf_duration(uint32_t duration)
void switch_curl_destroy(void)
char * switch_core_get_domain(switch_bool_t dup)
#define SWITCH_SEQ_FYELLOW
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
switch_status_t switch_msrp_init(void)
switch_status_t switch_event_shutdown(void)
Stop the eventing system.
void switch_rtp_init(switch_memory_pool_t *pool)
Initilize the RTP System.
int switch_system(const char *cmd, switch_bool_t wait)
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
switch_status_t switch_event_init(switch_memory_pool_t *pool)
Start the eventing system.
#define switch_clear_flag(obj, flag)
Clear a flag on an arbitrary object while locked.
#define SWITCH_MUTEX_NESTED
uint32_t switch_core_min_dtmf_duration(uint32_t duration)
void switch_channel_global_init(switch_memory_pool_t *pool)
int32_t set_auto_priority(void)
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
static int switch_system_thread(const char *cmd, switch_bool_t wait)
switch_dbtype_t odbc_dbtype
void switch_nat_init(switch_memory_pool_t *pool, switch_bool_t mapping)
Initilize the NAT Traversal System.
#define SWITCH_PATH_SEPARATOR
switch_status_t switch_threadattr_detach_set(switch_threadattr_t *attr, int32_t on)
double switch_core_idle_cpu(void)
int32_t sessions_peak_fivemin
switch_status_t switch_network_list_add_host_mask(switch_network_list_t *list, const char *host, const char *mask_str, switch_bool_t ok)
static void *SWITCH_THREAD_FUNC switch_core_service_thread(switch_thread_t *thread, void *obj)
switch_status_t switch_core_get_variables(switch_event_t **event)
#define switch_yield(ms)
Wait a desired number of microseconds and yield the CPU.
char * event_channel_key_separator
switch_bool_t colorize_console
unsigned int switch_separate_string(_In_ char *buf, char delim, _Post_count_(return) char **array, unsigned int arraylen)
Separate a string into an array based on a character delimiter.
static char main_ip6[256]
static switch_bool_t switch_string_var_check(char *s, switch_bool_t disable)
char * switch_core_get_uuid(void)
Retrieve the unique identifier from the core.
switch_bool_t switch_testv6_subnet(ip_t _ip, ip_t _net, ip_t _mask)
int ports[MAX_NETWORK_PORTS]
switch_mutex_t * frame_read_mutex
#define SWITCH_MAX_DTMF_DURATION
void switch_time_set_matrix(switch_bool_t enable)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
switch_core_flag_t switch_core_flags(void)
return core flags
void switch_core_thread_session_end(switch_core_session_t *session)
void switch_core_session_uninit(void)
switch_log_level_t switch_log_str2level(_In_z_ const char *str)
Return the level number of the specified log level name.
void switch_core_setrlimits(void)
void switch_core_session_hupall(_In_ switch_call_cause_t cause)
Hangup all sessions.
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Abstract interface to a management module.
#define SWITCH_THREAD_STACKSIZE
#define SWITCH_SYSTEM_THREAD_STACKSIZE
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
void switch_core_memory_reclaim_all(void)
switch_port_t switch_rtp_set_end_port(switch_port_t port)
Set/Get RTP end port.
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
uint32_t switch_core_max_audio_channels(uint32_t limit)
int32_t set_normal_priority(void)
Set the maximum priority the process can obtain.
unsigned long switch_atoul(const char *nptr)
static void load_mime_types(void)
switch_status_t switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
void switch_core_sqldb_resume(void)
switch_status_t switch_console_init(switch_memory_pool_t *pool)
char * switch_network_ipv4_mapped_ipv6_addr(const char *ip_str)
int switch_spawn(const char *cmd, switch_bool_t wait)
static switch_ip_list_t IP_LIST
switch_hash_t * mime_type_exts
uint32_t event_heartbeat_interval
static void send_heartbeat(void)
An abstraction of a data frame.
void switch_core_set_variable(const char *varname, const char *value)
uint32_t db_handle_timeout
FILE * switch_core_data_channel(switch_text_channel_t channel)
Retrieve a FILE stream of a given text channel name.
switch_size_t switch_fp_read_dline(FILE *fd, char **buf, switch_size_t *len)
int switch_inet_pton(int af, const char *src, void *dst)
void switch_core_runtime_loop(int bg)
Run endlessly until the system is shutdown.
switch_mutex_t * session_hash_mutex
#define SWITCH_STANDARD_STREAM(s)
uint32_t switch_core_session_count(void)
Provide the total number of sessions.
double switch_core_min_idle_cpu(double new_limit)
#define MAX_NETWORK_PORTS
void switch_nat_late_init(void)
Initilize the rest of the NAT Traversal System.
static void handle_SIGHUP(int sig)
static char main_ip4[256]
static switch_status_t switch_event_create_plain(switch_event_t **event, switch_event_types_t event_id)
static int switch_system_fork(const char *cmd, switch_bool_t wait)
void * objs[SWITCH_MAX_CORE_THREAD_SESSION_OBJS]
void switch_core_memory_reclaim_events(void)
switch_status_t switch_xml_destroy(void)
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
int32_t set_realtime_priority(void)
switch_status_t switch_log_shutdown(void)
Shut down the logging engine.
switch_mutex_t * global_mutex
void switch_rtp_shutdown(void)
struct fspr_thread_mutex_t switch_mutex_t
void switch_core_sqldb_pause(void)
void switch_cache_db_flush_handles(void)
switch_status_t switch_thread_cond_signal(switch_thread_cond_t *cond)
switch_hash_t * mime_types
void *(SWITCH_THREAD_FUNC * switch_thread_start_t)(switch_thread_t *, void *)
#define SWITCH_DEFAULT_DIR_PERMS
uint32_t max_dtmf_duration
switch_status_t switch_core_sqldb_init(const char **err)
switch_bool_t switch_core_set_var_conditional(const char *varname, const char *value, const char *val2)
uint32_t switch_core_default_dtmf_duration(uint32_t duration)
void switch_uuid_format(char *buffer, const switch_uuid_t *uuid)
char * switch_core_get_variable_pdup(const char *varname, switch_memory_pool_t *pool)
uint32_t switch_core_session_limit(_In_ uint32_t new_limit)
Set/Get Session Limit.
switch_status_t switch_network_list_add_cidr_port_token(switch_network_list_t *list, const char *cidr_str, switch_bool_t ok, const char *token, switch_network_port_range_p port)
int32_t switch_core_sessions_peak_fivemin(void)
switch_stream_handle_write_function_t write_function
#define SWITCH_MIN_DTMF_DURATION
void switch_time_set_monotonic(switch_bool_t enable)
static void *SWITCH_THREAD_FUNC system_thread(switch_thread_t *thread, void *obj)
switch_status_t
Common return values.
const char *const const char *const path
char * switch_string_replace(const char *string, const char *search, const char *replace)
switch_xml_t switch_xml_open_cfg(_In_z_ const char *file_path, _Out_ switch_xml_t *node, _In_opt_ switch_event_t *params)
open a config in the core registry
const char * switch_core_get_hostname(void)
switch_status_t switch_dir_make_recursive(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool)
void switch_console_save_history(void)
static void switch_core_unset_variables(void)
void switch_odbc_skip_autocommit_flip(void)
void switch_core_sqldb_stop(void)
switch_status_t switch_core_hash_init_case(_Out_ switch_hash_t **hash, switch_bool_t case_sensitive)
Initialize a hash table.
#define switch_core_hash_insert(_h, _k, _d)
switch_log_level_t hard_log_level
void switch_time_calibrate_clock(void)
int32_t switch_core_sps_peak(void)
uint32_t default_dtmf_duration
#define SWITCH_SEQ_DEFAULT_COLOR
#define switch_event_create(event, id)
Create a new event assuming it will not be custom event and therefore hiding the unused parameters...
switch_bool_t switch_core_ready_outbound(void)
Determines if the core is ready to place outbound calls.
const char * switch_core_banner(void)
void switch_core_recovery_flush(const char *technology, const char *profile_name)
struct fspr_thread_cond_t switch_thread_cond_t
switch_filenames SWITCH_GLOBAL_filenames
void switch_uuid_get(switch_uuid_t *uuid)
switch_bool_t switch_network_list_validate_ip_port_token(switch_network_list_t *list, uint32_t ip, int port, const char **token)
#define switch_event_get_header(_e, _h)
switch_time_t switch_mono_micro_time_now(void)
#define switch_channel_set_flag(_c, _f)
switch_xml_t switch_xml_child(_In_ switch_xml_t xml, _In_z_ const char *name)
returns the first child tag (one level deeper) with the given name or NULL \ if not found ...
switch_status_t switch_core_init(switch_core_flag_t flags, switch_bool_t console, const char **err)
SWITCH_STANDARD_SCHED_FUNC(heartbeat_callback)
switch_directories SWITCH_GLOBAL_dirs
#define switch_set_string(_dst, _src)
void switch_time_set_use_system_time(switch_bool_t enable)
int switch_stream_system_fork(const char *cmd, switch_stream_handle_t *stream)
char * core_db_pre_trans_execute
uint32_t port_alloc_flags
int switch_stream_spawn(const char *cmd, switch_bool_t shell, switch_bool_t wait, switch_stream_handle_t *stream)
void switch_time_set_cond_yield(switch_bool_t enable)
const char * switch_core_mime_ext2type(const char *ext)
time_t switch_epoch_time_now(time_t *t)
Get the current epoch time.
switch_bool_t switch_check_network_list_ip_token(const char *ip_str, const char *list_name, const char **token)
switch_status_t switch_loadable_module_init(switch_bool_t autoload)
Initilize the module backend and load all the modules.
A generic object to pass as a thread's session object to allow mutiple arguements and a pool...
switch_mutex_t * uuid_mutex
char * switch_core_get_variable(const char *varname)
uint32_t switch_core_debug_level(void)
switch_status_t switch_thread_rwlock_create(switch_thread_rwlock_t **rwlock, switch_memory_pool_t *pool)
switch_memory_pool_t * memory_pool
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
switch_status_t switch_log_init(_In_ switch_memory_pool_t *pool, _In_ switch_bool_t colorize)
Initilize the logging engine.
switch_status_t switch_core_management_exec(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen)
Execute a management operation.
switch_status_t switch_threadattr_create(switch_threadattr_t **new_attr, switch_memory_pool_t *pool)
switch_status_t switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr, switch_thread_start_t func, void *data, switch_memory_pool_t *cont)
switch_status_t switch_console_execute(char *xcmd, int rec, switch_stream_handle_t *istream)
switch_status_t(* management_function)(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen)
switch_status_t switch_find_local_ip(_Out_opt_bytecapcount_(len) char *buf, _In_ int len, _In_opt_ int *mask, _In_ int family)
find local ip of the box
FILE * switch_core_get_console(void)
Get the output console.
struct fspr_pool_t switch_memory_pool_t
void switch_load_network_lists(switch_bool_t reload)
char * switch_core_get_variable_dup(const char *varname)
void switch_event_destroy(switch_event_t **event)
Destroy an event.
int32_t switch_core_set_process_privileges(void)
Switch on the privilege awareness for the process and request required privileges.
void switch_core_service_session_av(switch_core_session_t *session, switch_bool_t audio, switch_bool_t video)
uint32_t cpu_idle_smoothing_depth
void switch_core_memory_reclaim(void)
const char * switch_version_revision_human(void)
int32_t switch_core_session_ctl(switch_session_ctl_t cmd, void *val)
send a control message to the core
char * core_db_inner_pre_trans_execute
int multiple_registrations
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.
void switch_curl_init(void)
struct fspr_thread_t switch_thread_t
int switch_core_recovery_recover(const char *technology, const char *profile_name)
void switch_core_remove_state_handler(const switch_state_handler_table_t *state_handler)
void switch_core_state_machine_init(switch_memory_pool_t *pool)
#define switch_core_session_kill_channel(session, sig)
Send a signal to a channel.
switch_bool_t switch_core_ready_inbound(void)
Determines if the core is ready to take inbound calls.
#define switch_core_hash_first(_h)
switch_bool_t switch_core_ready(void)
Determines if the core is ready to take calls.
SWITCH_BEGIN_EXTERN_C char * switch_mprintf(const char *zFormat,...)
void switch_console_loop(void)
A simple comand loop that reads input from the terminal.
int32_t switch_core_sps_last(void)
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1]
void switch_core_measure_time(switch_time_t total_ms, switch_core_time_duration_t *duration)
Breakdown a number of milliseconds into various time spec.
switch_thread_t * switch_core_launch_thread(switch_thread_start_t func, void *obj, switch_memory_pool_t *pool)
void switch_ssl_destroy_ssl_locks(void)
switch_status_t switch_core_check_core_db_dsn(void)
Returns error if no suitable database interface found to serve core db dsn.
void switch_core_screen_size(int *x, int *y)
switch_management_action_t
switch_event_header_t * headers
uint32_t switch_default_rate(const char *name, uint32_t number)
switch_status_t switch_xml_init(_In_ switch_memory_pool_t *pool, _Out_ const char **err)
initilize the core XML backend
void switch_core_session_launch_thread(_In_ switch_core_session_t *session, _In_ void *(*func)(switch_thread_t *, void *), _In_opt_ void *obj)
Launch a thread designed to exist within the scope of a given session.
switch_memory_pool_t * pool
switch_status_t switch_core_set_console(const char *console)
Set the output console to the desired file.
switch_status_t switch_threadattr_priority_set(switch_threadattr_t *attr, switch_thread_priority_t priority)
const char * switch_core_get_event_channel_key_separator(void)