diff --git a/build/modules.conf.in b/build/modules.conf.in
index 71ece983ef..66b649f6f3 100644
--- a/build/modules.conf.in
+++ b/build/modules.conf.in
@@ -4,7 +4,7 @@
#applications/mod_blacklist
#applications/mod_callcenter
#applications/mod_cidlookup
-applications/mod_cluechoo
+#applications/mod_cluechoo
applications/mod_commands
applications/mod_conference
#applications/mod_curl
diff --git a/conf/vanilla/autoload_configs/modules.conf.xml b/conf/vanilla/autoload_configs/modules.conf.xml
index d8a0b5cc68..e5a297e8af 100644
--- a/conf/vanilla/autoload_configs/modules.conf.xml
+++ b/conf/vanilla/autoload_configs/modules.conf.xml
@@ -60,7 +60,7 @@
-
+
diff --git a/conf/vanilla/sip_profiles/external-ipv6.xml b/conf/vanilla/sip_profiles/external-ipv6.xml
index 6182246763..7dc5906c5f 100644
--- a/conf/vanilla/sip_profiles/external-ipv6.xml
+++ b/conf/vanilla/sip_profiles/external-ipv6.xml
@@ -2,7 +2,7 @@
-
+
diff --git a/conf/vanilla/sip_profiles/internal/example.xml b/conf/vanilla/sip_profiles/external-ipv6/example.xml
similarity index 91%
rename from conf/vanilla/sip_profiles/internal/example.xml
rename to conf/vanilla/sip_profiles/external-ipv6/example.xml
index a5cbd7d2b7..d8fe39539a 100644
--- a/conf/vanilla/sip_profiles/internal/example.xml
+++ b/conf/vanilla/sip_profiles/external-ipv6/example.xml
@@ -33,5 +33,9 @@
+
+
+
+
diff --git a/conf/vanilla/sip_profiles/external/example.xml b/conf/vanilla/sip_profiles/external/example.xml
index 0497bcd1e1..d8fe39539a 100644
--- a/conf/vanilla/sip_profiles/external/example.xml
+++ b/conf/vanilla/sip_profiles/external/example.xml
@@ -28,11 +28,14 @@
+
+
-
+
+
diff --git a/conf/vanilla/sip_profiles/internal.xml b/conf/vanilla/sip_profiles/internal.xml
index 9e6a93ae2a..a848cb9583 100644
--- a/conf/vanilla/sip_profiles/internal.xml
+++ b/conf/vanilla/sip_profiles/internal.xml
@@ -15,7 +15,6 @@
-
diff --git a/configure.ac b/configure.ac
index 9a8c2191ee..2508f9c1c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -342,7 +342,7 @@ if test "$ax_cv_c_compiler_vendor" = "gnu"; then
saved_CFLAGS="$CFLAGS"
AC_CACHE_CHECK([whether compiler supports -Wno-unused-result],
[ac_cv_gcc_supports_w_no_unused_result], [
- CFLAGS="$CFLAGS -Wno-unused-result"
+ CFLAGS="$CFLAGS -Wno-unused-result -Wno-error=unused-result"
AC_TRY_COMPILE([],[return 0;],
[ac_cv_gcc_supports_w_no_unused_result=yes],
[ac_cv_gcc_supports_w_no_unused_result=no])])
diff --git a/debian/bootstrap.sh b/debian/bootstrap.sh
index e9b77825a0..bc7da61c3f 100755
--- a/debian/bootstrap.sh
+++ b/debian/bootstrap.sh
@@ -15,6 +15,7 @@ avoid_mods=(
applications/mod_osp
applications/mod_rad_auth
applications/mod_skel
+ applications/mod_cluechoo
asr_tts/mod_cepstral
codecs/mod_com_g729
codecs/mod_ilbc
@@ -433,7 +434,6 @@ Depends: \${misc:Depends}, freeswitch (= \${binary:Version}),
freeswitch-mod-voicemail (= \${binary:Version}),
freeswitch-mod-esf (= \${binary:Version}),
freeswitch-mod-fsv (= \${binary:Version}),
- freeswitch-mod-cluechoo (= \${binary:Version}),
freeswitch-mod-valet-parking (= \${binary:Version}),
freeswitch-mod-httapi (= \${binary:Version}),
freeswitch-mod-dialplan-xml (= \${binary:Version}),
@@ -564,7 +564,6 @@ Recommends:
freeswitch-mod-blacklist (= \${binary:Version}),
freeswitch-mod-callcenter (= \${binary:Version}),
freeswitch-mod-cidlookup (= \${binary:Version}),
- freeswitch-mod-cluechoo (= \${binary:Version}),
freeswitch-mod-commands (= \${binary:Version}),
freeswitch-mod-conference (= \${binary:Version}),
freeswitch-mod-curl (= \${binary:Version}),
diff --git a/docs/Doxygen.conf b/docs/Doxygen.conf
index c087478179..41920106dc 100644
--- a/docs/Doxygen.conf
+++ b/docs/Doxygen.conf
@@ -31,7 +31,7 @@ PROJECT_NAME = "FreeSWITCH API Documentation"
# This could be handy for archiving the generated documentation or
# if some version control system is used.
-PROJECT_NUMBER = 1.0.6
+PROJECT_NUMBER = 1.5.14b
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
diff --git a/docs/SubmittingPatches b/docs/SubmittingPatches
index f60483fc0b..b6d7648278 100644
--- a/docs/SubmittingPatches
+++ b/docs/SubmittingPatches
@@ -38,12 +38,12 @@ Create a Pull Request
---------------------
# navigate to the FreeSWITCH JIRA
- chromium http://jira.freeswitch.org/
+ chromium https://jira.freeswitch.org/
# create an account in JIRA and create a new issue
# navigate to FreeSWITCH Stash
- chromium http://stash.freeswitch.org/
+ chromium https://stash.freeswitch.org/
# create an account in Stash; create a forked FS repository; read
# the details here:
@@ -156,6 +156,26 @@ submitting the commits to us. Random "update branch to master" merges
make our history hard to understand and make it more difficult to
isolate regressions with `git-bisect`.
+New Module Checklist
+--------------------
+
+When proposing a new module:
+
+ * Add a `Makefile.am` for the module
+ * Add the module to the FS `configure.ac`
+ * Add the module to `build/modules.conf.in` (commented out)
+ * Describe the module in as much detail as possible in the comments
+ at the top of the module
+ * Add our whitespace footer to the module files; ensure the \*.[ch]
+ module files use tabs for indentation and are free of trailing
+ whitespace (e.g. in Emacs, run `M-x whitespace-mode`, then `M-x
+ whitespace-cleanup`)
+ * Remove any unused code left over from debugging
+ * Ensure symbols not meant to be exported are declared `static`
+ * Don't add any files to `conf/vanilla`
+ * Write a commit message body describing the module, why it's useful,
+ what it does, how it works, and any parts not yet implemented
+
Do As We Say...
---------------
@@ -194,4 +214,4 @@ Finally, feel free to join us in our weekly conference call. Many of
the core developers are often on the call and you'll have an
opportunity at the beginning or end of the call to ask your questions:
-> http://wiki.freeswitch.org/wiki/Weekly_Conference_Call
+> https://wiki.freeswitch.org/wiki/Weekly_Conference_Call
diff --git a/docs/how_to_make_your_own_ca_correctly.txt b/docs/how_to_make_your_own_ca_correctly.txt
index 55c3546e4d..ff616867bc 100644
--- a/docs/how_to_make_your_own_ca_correctly.txt
+++ b/docs/how_to_make_your_own_ca_correctly.txt
@@ -5,8 +5,8 @@ Here is how I did it.
wget http://www.openssl.org/contrib/ssl.ca-0.1.tar.gz
tar zxfv ssl.ca-0.1.tar.gz
cd ssl.ca-0.1/
-perl -i -pe 's/md5/sha1/g' *.sh
-perl -i -pe 's/1024/2048/g' *.sh
+perl -i -pe 's/md5/sha2/g' *.sh
+perl -i -pe 's/1024/4096/g' *.sh
./new-root-ca.sh
./new-server-cert.sh self.bkw.org
./sign-server-cert.sh self.bkw.org
diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c
index 43c186b728..3610ae5219 100644
--- a/libs/esl/fs_cli.c
+++ b/libs/esl/fs_cli.c
@@ -61,6 +61,7 @@ typedef struct {
int log_uuid;
int log_uuid_length;
int quiet;
+ int use_history_file;
int batch_mode;
char prompt_color[12];
char input_text_color[12];
@@ -1222,6 +1223,7 @@ static void read_config(const char *dft_cfile, const char *cfile) {
esl_set_string(profiles[pcount].prompt_color, prompt_color);
esl_set_string(profiles[pcount].input_text_color, input_text_color);
esl_set_string(profiles[pcount].output_text_color, output_text_color);
+ profiles[pcount].use_history_file = 1;
esl_log(ESL_LOG_DEBUG, "Found Profile [%s]\n", profiles[pcount].name);
pcount++;
}
@@ -1257,6 +1259,8 @@ static void read_config(const char *dft_cfile, const char *cfile) {
}
} else if(!strcasecmp(var, "quiet")) {
profiles[pcount-1].quiet = esl_true(val);
+ } else if(!strcasecmp(var, "no-history-file")) {
+ profiles[pcount-1].use_history_file = !esl_true(val);
} else if(!strcasecmp(var, "prompt-color")) {
esl_set_string(profiles[pcount-1].prompt_color, match_color(val));
} else if(!strcasecmp(var, "input-text-color")) {
@@ -1298,6 +1302,8 @@ int main(int argc, char *argv[])
const char *line = NULL;
char cmd_str[1024] = "";
cli_profile_t *profile = NULL;
+ int argv_use_history_file = 1;
+ int use_history_file = 0;
#ifndef WIN32
char hfile[512] = "/tmp/fs_cli_history";
char cfile[512] = "/etc/fs_cli.conf";
@@ -1324,6 +1330,7 @@ int main(int argc, char *argv[])
{"log-uuid-short", 0, 0, 'S'},
{"quiet", 0, 0, 'q'},
{"batchmode", 0, 0, 'b'},
+ {"no-history-file", 0, 0, 'Q'},
{"retry", 0, 0, 'r'},
{"interrupt", 0, 0, 'i'},
{"reconnect", 0, 0, 'R'},
@@ -1381,6 +1388,7 @@ int main(int argc, char *argv[])
esl_set_string(internal_profile.prompt_color, prompt_color);
esl_set_string(internal_profile.input_text_color, input_text_color);
esl_set_string(internal_profile.output_text_color, output_text_color);
+ internal_profile.use_history_file = 1;
if (home) {
snprintf(hfile, sizeof(hfile), "%s/.fs_cli_history", home);
snprintf(cfile, sizeof(cfile), "%s/.fs_cli_conf", home);
@@ -1395,7 +1403,7 @@ int main(int argc, char *argv[])
esl_global_set_default_logger(6); /* default debug level to 6 (info) */
for(;;) {
int option_index = 0;
- opt = getopt_long(argc, argv, "H:P:u:p:d:x:l:USt:T:qrRhib?n", options, &option_index);
+ opt = getopt_long(argc, argv, "H:P:u:p:d:x:l:USt:T:qQrRhib?n", options, &option_index);
if (opt == -1) break;
switch (opt) {
case 'H':
@@ -1450,6 +1458,9 @@ int main(int argc, char *argv[])
case 'b':
argv_batch = 1;
break;
+ case 'Q':
+ argv_use_history_file = 0;
+ break;
case 'i':
allow_ctl_c = 1;
break;
@@ -1505,6 +1516,9 @@ int main(int argc, char *argv[])
profile->batch_mode = 1;
feature_level=0;
}
+ if (argv_use_history_file && profile->use_history_file) {
+ use_history_file = 1;
+ }
if (*argv_loglevel) {
esl_set_string(profile->loglevel, argv_loglevel);
profile->quiet = 0;
@@ -1658,7 +1672,7 @@ int main(int argc, char *argv[])
}
history(myhistory, &ev, H_SETSIZE, 800);
el_set(el, EL_HIST, history, myhistory);
- history(myhistory, &ev, H_LOAD, hfile);
+ if (use_history_file) history(myhistory, &ev, H_LOAD, hfile);
el_source(el, NULL);
#endif
#ifdef WIN32
@@ -1712,7 +1726,7 @@ int main(int argc, char *argv[])
}
#ifdef HAVE_LIBEDIT
done:
- history(myhistory, &ev, H_SAVE, hfile);
+ if (use_history_file) history(myhistory, &ev, H_SAVE, hfile);
history_end(myhistory);
el_end(el);
#endif
diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update
index 66c9d49924..63605e55a1 100644
--- a/libs/sofia-sip/.update
+++ b/libs/sofia-sip/.update
@@ -1 +1 @@
-Sat Aug 16 01:34:24 CDT 2014
+Thu Sep 25 21:43:53 CDT 2014
diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c
index 9ee2b29f41..2866899fd3 100644
--- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c
+++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c
@@ -475,7 +475,7 @@ int tport_ws_init_secondary(tport_t *self, int socket, int accepted,
memset(&wstp->ws, 0, sizeof(wstp->ws));
- if (ws_init(&wstp->ws, socket, wstp->ws_secure ? wspri->ssl_ctx : NULL, 0, 0) < 0) {
+ if (ws_init(&wstp->ws, socket, wstp->ws_secure ? wspri->ssl_ctx : NULL, 0, 0, 0) < 0) {
ws_destroy(&wstp->ws);
wstp->ws_initialized = -1;
return *return_reason = "WS_INIT", -1;
diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c
index b96c6c140a..6fa69d2161 100644
--- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c
+++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c
@@ -1,11 +1,6 @@
#include "ws.h"
#include
-#ifdef _MSC_VER
-/* warning C4706: assignment within conditional expression*/
-#pragma warning(disable: 4706)
-#endif
-
#ifndef _MSC_VER
#include
#endif
@@ -16,6 +11,11 @@
#define ms_sleep(x) Sleep( x );
#endif
+#ifdef _MSC_VER
+/* warning C4706: assignment within conditional expression*/
+#pragma warning(disable: 4706)
+#endif
+
#define WS_BLOCK 1
#define WS_NOBLOCK 0
@@ -246,7 +246,6 @@ int ws_handshake(wsh_t *wsh)
char version[5] = "";
char proto[256] = "";
char proto_buf[384] = "";
- char uri[256] = "";
char input[256] = "";
unsigned char output[SHA1_HASH_SIZE] = "";
char b64[256] = "";
@@ -269,7 +268,7 @@ int ws_handshake(wsh_t *wsh)
goto err;
}
- *(wsh->buffer+bytes) = '\0';
+ *(wsh->buffer + wsh->datalen) = '\0';
if (strncasecmp(wsh->buffer, "GET ", 4)) {
goto err;
@@ -281,9 +280,11 @@ int ws_handshake(wsh_t *wsh)
if (!e) {
goto err;
}
-
- strncpy(uri, p, e-p);
-
+
+ wsh->uri = malloc((e-p) + 1);
+ strncpy(wsh->uri, p, e-p);
+ *(wsh->uri + (e-p)) = '\0';
+
cheezy_get_var(wsh->buffer, "Sec-WebSocket-Key", key, sizeof(key));
cheezy_get_var(wsh->buffer, "Sec-WebSocket-Version", version, sizeof(version));
cheezy_get_var(wsh->buffer, "Sec-WebSocket-Protocol", proto, sizeof(proto));
@@ -317,15 +318,15 @@ int ws_handshake(wsh_t *wsh)
err:
- snprintf(respond, sizeof(respond), "HTTP/1.1 400 Bad Request\r\n"
- "Sec-WebSocket-Version: 13\r\n\r\n");
+ if (!wsh->stay_open) {
- //printf("ERR:\n%s\n", respond);
+ snprintf(respond, sizeof(respond), "HTTP/1.1 400 Bad Request\r\n"
+ "Sec-WebSocket-Version: 13\r\n\r\n");
+ ws_raw_write(wsh, respond, strlen(respond));
- ws_raw_write(wsh, respond, strlen(respond));
-
- ws_close(wsh, WS_NONE);
+ ws_close(wsh, WS_NONE);
+ }
return -1;
@@ -336,19 +337,22 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block)
ssize_t r;
int err = 0;
+ wsh->x++;
+ if (wsh->x > 250) ms_sleep(1);
+
if (wsh->ssl) {
do {
r = SSL_read(wsh->ssl, data, bytes);
- ms_sleep(10);
-
if (r == -1) {
err = SSL_get_error(wsh->ssl, r);
-
+
if (!block && err == SSL_ERROR_WANT_READ) {
r = -2;
goto end;
}
+
+ if (block) ms_sleep(10);
}
} while (r == -1 && err == SSL_ERROR_WANT_READ && wsh->x < 100);
@@ -358,10 +362,17 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block)
do {
r = recv(wsh->sock, data, bytes, 0);
- ms_sleep(10);
+ if (r == -1) {
+ if (!block && xp_is_blocking(xp_errno())) {
+ r = -2;
+ goto end;
+ }
+
+ if (block) ms_sleep(10);
+ }
} while (r == -1 && xp_is_blocking(xp_errno()) && wsh->x < 100);
- if (wsh->x >= 100) {
+ if (wsh->x >= 1000 || (block && wsh->x >= 100)) {
r = -1;
}
@@ -543,7 +554,7 @@ static int establish_logical_layer(wsh_t *wsh)
}
-int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock, int block)
+int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock, int block, int stay_open)
{
memset(wsh, 0, sizeof(*wsh));
@@ -551,6 +562,7 @@ int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock, int
wsh->block = block;
wsh->sanity = 5000;
wsh->ssl_ctx = ssl_ctx;
+ wsh->stay_open = stay_open;
if (!ssl_ctx) {
ssl_ctx = ws_globals.ssl_ctx;
@@ -619,6 +631,11 @@ ssize_t ws_close(wsh_t *wsh, int16_t reason)
wsh->down = 1;
+ if (wsh->uri) {
+ free(wsh->uri);
+ wsh->uri = NULL;
+ }
+
if (reason && wsh->sock != ws_sock_invalid) {
uint16_t *u16;
uint8_t fr[4] = {WSOC_CLOSE | 0x80, 2, 0};
diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.h b/libs/sofia-sip/libsofia-sip-ua/tport/ws.h
index b4d30b47f2..7f5f5c48b4 100644
--- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.h
+++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.h
@@ -72,6 +72,7 @@ typedef struct wsh_s {
ws_socket_t sock;
char buffer[65536];
char wbuffer[65536];
+ char *uri;
size_t buflen;
ssize_t datalen;
ssize_t wdatalen;
@@ -88,6 +89,7 @@ typedef struct wsh_s {
int sanity;
int secure_established;
int logical_established;
+ int stay_open;
int x;
void *write_buffer;
size_t write_buffer_len;
@@ -101,7 +103,7 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block);
ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes);
ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data);
ssize_t ws_write_frame(wsh_t *wsh, ws_opcode_t oc, void *data, size_t bytes);
-int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock, int block);
+int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock, int block, int stay_open);
ssize_t ws_close(wsh_t *wsh, int16_t reason);
void ws_destroy(wsh_t *wsh);
void init_ssl(void);
diff --git a/src/include/switch_apr.h b/src/include/switch_apr.h
index 50096d5aff..0f872e2296 100644
--- a/src/include/switch_apr.h
+++ b/src/include/switch_apr.h
@@ -1406,8 +1406,8 @@ SWITCH_DECLARE(switch_interval_time_t) switch_interval_time_from_timeval(struct
SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **pollfd, switch_socket_t *sock, int16_t flags, void *client_data, switch_memory_pool_t *pool);
SWITCH_DECLARE(switch_status_t) switch_match_glob(const char *pattern, switch_array_header_t ** result, switch_memory_pool_t *pool);
SWITCH_DECLARE(switch_status_t) switch_os_sock_get(switch_os_socket_t *thesock, switch_socket_t *sock);
-SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t ** sa, switch_bool_t remote, switch_socket_t *sock);
SWITCH_DECLARE(switch_status_t) switch_os_sock_put(switch_socket_t **sock, switch_os_socket_t *thesock, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t ** sa, switch_bool_t remote, switch_socket_t *sock);
/**
* Create an anonymous pipe.
* @param in The file descriptor to use as input to the pipe.
diff --git a/src/mod/applications/mod_snom/mod_snom.c b/src/mod/applications/mod_snom/mod_snom.c
index 89a29af00a..81e51a7688 100644
--- a/src/mod/applications/mod_snom/mod_snom.c
+++ b/src/mod/applications/mod_snom/mod_snom.c
@@ -192,6 +192,7 @@ SWITCH_STANDARD_API(snom_command_api_function)
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-curl/1.0");
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 15);
+ curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
if (argc == 5) {
userpwd = switch_mprintf("%s:%s",argv[3],argv[4]);
diff --git a/src/mod/applications/mod_translate/mod_translate.c b/src/mod/applications/mod_translate/mod_translate.c
index 7180ea1d6b..61feecd36d 100644
--- a/src/mod/applications/mod_translate/mod_translate.c
+++ b/src/mod/applications/mod_translate/mod_translate.c
@@ -117,9 +117,9 @@ static void translate_number(char *number, char *profile, char **translated, swi
translate_rule_t *hi = NULL;
translate_rule_t *rule = NULL;
switch_regex_t *re = NULL;
- int proceed = 0, ovector[30], subbedlen = 0;
- char *substituted = NULL, *subbed = NULL, *session_malloc = NULL;
- uint32_t len = 1024;
+ int proceed = 0, ovector[30];
+ char *substituted = NULL, *subbed = NULL;
+ uint32_t len = 0;
if (!profile) {
profile = "US";
@@ -136,14 +136,14 @@ static void translate_number(char *number, char *profile, char **translated, swi
for (rule = hi; rule; rule = rule->next) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s =~ /%s/\n", number, rule->regex);
if ((proceed = switch_regex_perform(number, rule->regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s matched %s, replacing with %s\n", number, rule->regex, rule->replace);
- if (!(substituted = switch_core_session_alloc(session, len))) {
+ len = (uint32_t) (strlen(number) + strlen(rule->replace) + 10) * proceed;
+ if (!(substituted = malloc(len))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
switch_regex_safe_free(re);
goto end;
}
memset(substituted, 0, len);
-
+
switch_perform_substitution(re, proceed, rule->replace, number, substituted, len, ovector);
if ((switch_string_var_check_const(substituted) || switch_string_has_escaped_data(substituted))) {
@@ -154,16 +154,11 @@ static void translate_number(char *number, char *profile, char **translated, swi
subbed = switch_event_expand_headers(event, substituted);
}
- subbedlen = strlen(subbed) + 1;
- session_malloc = (char *)switch_core_session_alloc(session, subbedlen);
- memset(session_malloc, 0, subbedlen);
- strncpy(session_malloc, subbed, subbedlen);
- if (subbed != substituted)
- {
+ substituted = switch_core_session_strdup(session, subbed);
+
+ if (subbed != substituted) {
switch_safe_free(subbed);
}
-
- substituted = session_malloc;
}
break;
diff --git a/src/mod/endpoints/mod_gsmopen/gsmopen.h b/src/mod/endpoints/mod_gsmopen/gsmopen.h
index f56866a587..80bee58265 100644
--- a/src/mod/endpoints/mod_gsmopen/gsmopen.h
+++ b/src/mod/endpoints/mod_gsmopen/gsmopen.h
@@ -445,10 +445,21 @@ struct private_object {
int roaming_registered;
int not_registered;
int got_signal;
+ int signal_strength;
char imei[128];
int requesting_imei;
char imsi[128];
int requesting_imsi;
+ char operator_name[128];
+ int requesting_operator_name;
+ char subscriber_number[128];
+ int requesting_subscriber_number;
+ char device_mfg[128];
+ int requesting_device_mfg;
+ char device_model[128];
+ int requesting_device_model;
+ char device_firmware[128];
+ int requesting_device_firmware;
int network_creg_not_supported;
char creg[128];
diff --git a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp
index 12b6903e94..eb2e8c75d5 100644
--- a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp
+++ b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp
@@ -330,17 +330,29 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
}
/* phone manufacturer */
+ tech_pvt->requesting_device_mfg = 1;
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CGMI");
+ tech_pvt->requesting_device_mfg = 0;
if (res) {
DEBUGA_GSMOPEN("AT+CGMI failed\n", GSMOPEN_P_LOG);
}
/* phone model */
+ tech_pvt->requesting_device_model = 1;
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CGMM");
+ tech_pvt->requesting_device_model = 0;
if (res) {
DEBUGA_GSMOPEN("AT+CGMM failed\n", GSMOPEN_P_LOG);
}
+ /* phone firmware */
+ tech_pvt->requesting_device_firmware = 1;
+ res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CGMR");
+ tech_pvt->requesting_device_firmware = 0;
+ if (res) {
+ DEBUGA_GSMOPEN("AT+CGMR failed\n", GSMOPEN_P_LOG);
+ }
+
/* signal network registration with a +CREG unsolicited msg */
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CREG=1");
if (res) {
@@ -358,6 +370,23 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
if (res) {
DEBUGA_GSMOPEN("AT+CSQ failed\n", GSMOPEN_P_LOG);
}
+
+ /* operator name */
+ tech_pvt->requesting_operator_name = 1;
+ res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+COPS?");
+ tech_pvt->requesting_operator_name = 0;
+ if (res) {
+ DEBUGA_GSMOPEN("AT+COPS? failed\n", GSMOPEN_P_LOG);
+ }
+
+ /* subscriber number */
+ tech_pvt->requesting_subscriber_number = 1;
+ res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CNUM");
+ tech_pvt->requesting_subscriber_number = 0;
+ if (res) {
+ DEBUGA_GSMOPEN("AT+CNUM failed, continue\n", GSMOPEN_P_LOG);
+ }
+
/* IMEI */
tech_pvt->requesting_imei = 1;
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+GSN");
@@ -967,6 +996,12 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
tech_pvt->got_signal = 2;
}
+ if (signal_quality == 99) {
+ tech_pvt->signal_strength = 0;
+ } else {
+ tech_pvt->signal_strength = (signal_quality * 2) - 113; /* RSSI [dBm] = reported_value * 2 - 113dB */
+ }
+
}
}
@@ -1006,6 +1041,58 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
}
+ if ((strncmp(tech_pvt->line_array.result[i], "+COPS:", 6) == 0)) {
+ int mode, format, rat, err;
+ char oper[128] = "";
+ mode = format = rat = err = 0;
+
+ err = sscanf(&tech_pvt->line_array.result[i][6], "%d,%d,%*[\"]%[^\"]%*[\"],%d", &mode, &format, &oper, &rat);
+ if (err < 3) {
+ DEBUGA_GSMOPEN("|%s| is not formatted as: |+COPS: xx,yy,ssss,nn|\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
+ } else if (option_debug > 1) {
+ DEBUGA_GSMOPEN("|%s| +COPS: : Mode %d, Format %d, Operator %s, Rat %d\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i], mode, format, oper, rat);
+ }
+
+ /* if we are requesting the operator name, copy it over */
+ if (tech_pvt->requesting_operator_name)
+ strncpy(tech_pvt->operator_name, oper, sizeof(tech_pvt->operator_name));
+ }
+
+ if ((strncmp(tech_pvt->line_array.result[i], "+CNUM:", 6) == 0) || (strncmp(tech_pvt->line_array.result[i], "ERROR+CNUM:", 11) == 0)) {
+ int skip_chars, err, type;
+ char number[128] = "";
+ char *in_ptr, *out_ptr;
+
+ skip_chars = err = type = 0;
+ in_ptr = out_ptr = number;
+
+ /* +CNUM or ERROR+CNUM ? */
+ if ((strncmp(tech_pvt->line_array.result[i], "+CNUM:", 6) == 0))
+ skip_chars = 7;
+ else
+ skip_chars = 12;
+
+ err = sscanf(&tech_pvt->line_array.result[i][skip_chars], "%*[^,],%[^,],%d", &number, &type);
+
+ /* Remove any double quotes */
+ while (*in_ptr) {
+ if (*in_ptr != '\"') *out_ptr++ = *in_ptr;
+ in_ptr++;
+ }
+ *out_ptr = '\0';
+
+ if (err < 2) {
+ DEBUGA_GSMOPEN("|%s| is not formatted as: |+CNUM: \"Name\", \"+39025458068\", 145|\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
+ } else if (option_debug) {
+ DEBUGA_GSMOPEN("|%s| +CNUM: Subscriber number = %s, Type = %d\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i], number, type);
+ }
+
+ /* Copy only the first number listed if there are more then one */
+ if (tech_pvt->requesting_subscriber_number && !strlen(tech_pvt->subscriber_number))
+ strncpy(tech_pvt->subscriber_number, number, sizeof(tech_pvt->subscriber_number));
+
+ }
+
if ((strncmp(tech_pvt->line_array.result[i], "+CMGW:", 6) == 0)) {
int err;
@@ -1154,45 +1241,43 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
tech_pvt->unread_sms_msg_id = pos;
gsmopen_sleep(1000);
- if (tech_pvt->unread_sms_msg_id) {
- char at_command[256];
+ char at_command[256];
- if (tech_pvt->no_ucs2 == 0) {
- int res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"UCS2\"");
- if (res) {
- ERRORA("AT+CSCS=\"UCS2\" (set TE messages to ucs2) didn't get OK from the phone, continuing\n", GSMOPEN_P_LOG);
- //memset(tech_pvt->sms_message, 0, sizeof(tech_pvt->sms_message));
- }
- }
-
- memset(at_command, 0, sizeof(at_command));
- sprintf(at_command, "AT+CMGR=%d", tech_pvt->unread_sms_msg_id);
- memset(tech_pvt->sms_message, 0, sizeof(tech_pvt->sms_message));
-
- tech_pvt->reading_sms_msg = 1;
- int res = gsmopen_serial_write_AT_ack(tech_pvt, at_command);
- tech_pvt->reading_sms_msg = 0;
+ if (tech_pvt->no_ucs2 == 0) {
+ int res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"UCS2\"");
if (res) {
- ERRORA("AT+CMGR (read SMS) didn't get OK from the phone, message sent was:|||%s|||\n", GSMOPEN_P_LOG, at_command);
+ ERRORA("AT+CSCS=\"UCS2\" (set TE messages to ucs2) didn't get OK from the phone, continuing\n", GSMOPEN_P_LOG);
+ //memset(tech_pvt->sms_message, 0, sizeof(tech_pvt->sms_message));
}
- memset(at_command, 0, sizeof(at_command));
- sprintf(at_command, "AT+CMGD=%d", tech_pvt->unread_sms_msg_id); /* delete the message */
- tech_pvt->unread_sms_msg_id = 0;
- res = gsmopen_serial_write_AT_ack(tech_pvt, at_command);
+ }
+
+ memset(at_command, 0, sizeof(at_command));
+ sprintf(at_command, "AT+CMGR=%d", tech_pvt->unread_sms_msg_id);
+ memset(tech_pvt->sms_message, 0, sizeof(tech_pvt->sms_message));
+
+ tech_pvt->reading_sms_msg = 1;
+ int res = gsmopen_serial_write_AT_ack(tech_pvt, at_command);
+ tech_pvt->reading_sms_msg = 0;
+ if (res) {
+ ERRORA("AT+CMGR (read SMS) didn't get OK from the phone, message sent was:|||%s|||\n", GSMOPEN_P_LOG, at_command);
+ }
+ memset(at_command, 0, sizeof(at_command));
+ sprintf(at_command, "AT+CMGD=%d", tech_pvt->unread_sms_msg_id); /* delete the message */
+ tech_pvt->unread_sms_msg_id = 0;
+ res = gsmopen_serial_write_AT_ack(tech_pvt, at_command);
+ if (res) {
+ ERRORA("AT+CMGD (Delete SMS) didn't get OK from the phone, message sent was:|||%s|||\n", GSMOPEN_P_LOG, at_command);
+ }
+
+ res = sms_incoming(tech_pvt);
+
+ if (tech_pvt->phone_callflow == CALLFLOW_CALL_IDLE && tech_pvt->interface_state == GSMOPEN_STATE_DOWN && tech_pvt->owner == NULL) {
+ /* we're not in a call, neither calling */
+ res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CKPD=\"EEE\"");
if (res) {
- ERRORA("AT+CMGD (Delete SMS) didn't get OK from the phone, message sent was:|||%s|||\n", GSMOPEN_P_LOG, at_command);
+ DEBUGA_GSMOPEN("AT+CKPD=\"EEE\" (cellphone screen back to user) didn't get OK from the phone\n", GSMOPEN_P_LOG);
}
-
- res = sms_incoming(tech_pvt);
-
- if (tech_pvt->phone_callflow == CALLFLOW_CALL_IDLE && tech_pvt->interface_state == GSMOPEN_STATE_DOWN && tech_pvt->owner == NULL) {
- /* we're not in a call, neither calling */
- res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CKPD=\"EEE\"");
- if (res) {
- DEBUGA_GSMOPEN("AT+CKPD=\"EEE\" (cellphone screen back to user) didn't get OK from the phone\n", GSMOPEN_P_LOG);
- }
- }
- } //unread_msg_id
+ }
} //CMTI well formatted
@@ -1613,13 +1698,33 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
}
}
- /* if we are requesting IMSI, put the line into the imei buffer if the line is not "OK" or "ERROR" */
+ /* if we are requesting IMSI, put the line into the imsi buffer if the line is not "OK" or "ERROR" */
if (tech_pvt->requesting_imsi && at_ack == -1) {
if (strlen(tech_pvt->line_array.result[i])) { /* we are reading the IMSI */
strncpy(tech_pvt->imsi, tech_pvt->line_array.result[i], sizeof(tech_pvt->imsi));
}
}
+ /* if we are requesting device manufacturer, model or firmware version,
+ * put the line into the buffer if the line is not "OK" or "ERROR" */
+ if (tech_pvt->requesting_device_mfg && at_ack == -1) {
+ if (strlen(tech_pvt->line_array.result[i])) {
+ strncpy(tech_pvt->device_mfg, tech_pvt->line_array.result[i], sizeof(tech_pvt->device_mfg));
+ }
+ }
+
+ if (tech_pvt->requesting_device_model && at_ack == -1) {
+ if (strlen(tech_pvt->line_array.result[i])) {
+ strncpy(tech_pvt->device_model, tech_pvt->line_array.result[i], sizeof(tech_pvt->device_model));
+ }
+ }
+
+ if (tech_pvt->requesting_device_firmware && at_ack == -1) {
+ if (strlen(tech_pvt->line_array.result[i])) {
+ strncpy(tech_pvt->device_firmware, tech_pvt->line_array.result[i], sizeof(tech_pvt->device_firmware));
+ }
+ }
+
/* if we are reading an sms message from memory, put the line into the sms buffer if the line is not "OK" or "ERROR" */
if (tech_pvt->reading_sms_msg > 1 && at_ack == -1) {
diff --git a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp
index 37e160c674..82b2eb39c6 100644
--- a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp
+++ b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp
@@ -1694,14 +1694,15 @@ static switch_status_t load_config(int reload_type)
switch_sleep(100000);
WARNINGA("STARTED interface_id=%u\n", GSMOPEN_P_LOG, interface_id);
+ /* How many real intterfaces */
+ globals.real_interfaces++;
+
}
}
for (i = 0; i < GSMOPEN_MAX_INTERFACES; i++) {
if (strlen(globals.GSMOPEN_INTERFACES[i].name)) {
- /* How many real intterfaces */
- globals.real_interfaces++;
tech_pvt = &globals.GSMOPEN_INTERFACES[i];
@@ -2224,8 +2225,8 @@ SWITCH_STANDARD_API(gsm_function)
unsigned int ob_failed = 0;
char next_flag_char = ' ';
- stream->write_function(stream, "F ID\t Name \tIB (F/T) OB (F/T)\tState\tCallFlw\t\tUUID\n");
- stream->write_function(stream, "= ====\t ======== \t======= =======\t======\t============\t======\n");
+ stream->write_function(stream, "F ID Name Operator IMEI IB (F/T) OB (F/T) State CallFlw UUID\n");
+ stream->write_function(stream, "= == ========== ================ =============== ========= ========= ======= =============== ====\n");
for (i = 0; i < GSMOPEN_MAX_INTERFACES; i++) {
@@ -2238,9 +2239,11 @@ SWITCH_STANDARD_API(gsm_function)
stream->write_function(stream,
- "%c %d\t[%6s]\t%3u/%u\t%6u/%u\t%s\t%s\t%s\n",
+ "%c %-2d %-10s %-16.16s %-15s %4u/%-4u %4u/%-4u %-7s %-15s %s\n",
next_flag_char,
i, globals.GSMOPEN_INTERFACES[i].name,
+ globals.GSMOPEN_INTERFACES[i].operator_name,
+ globals.GSMOPEN_INTERFACES[i].imei,
globals.GSMOPEN_INTERFACES[i].ib_failed_calls,
globals.GSMOPEN_INTERFACES[i].ib_calls,
globals.GSMOPEN_INTERFACES[i].ob_failed_calls,
@@ -2420,8 +2423,15 @@ SWITCH_STANDARD_API(gsmopen_dump_function)
}
snprintf(value, sizeof(value) - 1, "%d", tech_pvt->got_signal);
stream->write_function(stream, "got_signal = %s\n", value);
+ snprintf(value, sizeof(value) - 1, "%d", tech_pvt->signal_strength);
+ stream->write_function(stream, "signal_strength = %s\n", value);
snprintf(value, sizeof(value) - 1, "%d", tech_pvt->running);
stream->write_function(stream, "running = %s\n", value);
+ stream->write_function(stream, "subscriber_number = %s\n", tech_pvt->subscriber_number);
+ stream->write_function(stream, "device_manufacturer = %s\n", tech_pvt->device_mfg);
+ stream->write_function(stream, "device_model = %s\n", tech_pvt->device_model);
+ stream->write_function(stream, "device_firmware = %s\n", tech_pvt->device_firmware);
+ stream->write_function(stream, "operator = %s\n", tech_pvt->operator_name);
stream->write_function(stream, "imei = %s\n", tech_pvt->imei);
stream->write_function(stream, "imsi = %s\n", tech_pvt->imsi);
snprintf(value, sizeof(value) - 1, "%d", tech_pvt->controldev_dead);
@@ -2478,8 +2488,15 @@ SWITCH_STANDARD_API(gsmopen_dump_function)
}
snprintf(value, sizeof(value) - 1, "%d", tech_pvt->got_signal);
stream->write_function(stream, "got_signal = %s\n", value);
+ snprintf(value, sizeof(value) - 1, "%d", tech_pvt->signal_strength);
+ stream->write_function(stream, "signal_strength = %s\n", value);
snprintf(value, sizeof(value) - 1, "%d", tech_pvt->running);
stream->write_function(stream, "running = %s\n", value);
+ stream->write_function(stream, "subscriber_number = %s\n", tech_pvt->subscriber_number);
+ stream->write_function(stream, "device_manufacturer = %s\n", tech_pvt->device_mfg);
+ stream->write_function(stream, "device_model = %s\n", tech_pvt->device_model);
+ stream->write_function(stream, "device_firmware = %s\n", tech_pvt->device_firmware);
+ stream->write_function(stream, "operator = %s\n", tech_pvt->operator_name);
stream->write_function(stream, "imei = %s\n", tech_pvt->imei);
stream->write_function(stream, "imsi = %s\n", tech_pvt->imsi);
snprintf(value, sizeof(value) - 1, "%d", tech_pvt->controldev_dead);
@@ -2807,8 +2824,15 @@ int dump_event_full(private_t *tech_pvt, int is_alarm, int alarm_code, const cha
}
snprintf(value, sizeof(value) - 1, "%d", tech_pvt->got_signal);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "got_signal", value);
+ snprintf(value, sizeof(value) - 1, "%d", tech_pvt->signal_strength);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "signal_strength", value);
snprintf(value, sizeof(value) - 1, "%d", tech_pvt->running);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "running", value);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subscriber_number", tech_pvt->subscriber_number);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "device_manufacturer", tech_pvt->device_mfg);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "device_model", tech_pvt->device_model);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "device_firmware", tech_pvt->device_firmware);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "operator", tech_pvt->operator_name);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "imei", tech_pvt->imei);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "imsi", tech_pvt->imsi);
snprintf(value, sizeof(value) - 1, "%d", tech_pvt->controldev_dead);
diff --git a/src/mod/endpoints/mod_verto/ws.c b/src/mod/endpoints/mod_verto/ws.c
index 6e91ff6493..6fa69d2161 100644
--- a/src/mod/endpoints/mod_verto/ws.c
+++ b/src/mod/endpoints/mod_verto/ws.c
@@ -11,6 +11,11 @@
#define ms_sleep(x) Sleep( x );
#endif
+#ifdef _MSC_VER
+/* warning C4706: assignment within conditional expression*/
+#pragma warning(disable: 4706)
+#endif
+
#define WS_BLOCK 1
#define WS_NOBLOCK 0
@@ -241,7 +246,6 @@ int ws_handshake(wsh_t *wsh)
char version[5] = "";
char proto[256] = "";
char proto_buf[384] = "";
- char uri[256] = "";
char input[256] = "";
unsigned char output[SHA1_HASH_SIZE] = "";
char b64[256] = "";
@@ -276,9 +280,11 @@ int ws_handshake(wsh_t *wsh)
if (!e) {
goto err;
}
-
- strncpy(uri, p, e-p);
-
+
+ wsh->uri = malloc((e-p) + 1);
+ strncpy(wsh->uri, p, e-p);
+ *(wsh->uri + (e-p)) = '\0';
+
cheezy_get_var(wsh->buffer, "Sec-WebSocket-Key", key, sizeof(key));
cheezy_get_var(wsh->buffer, "Sec-WebSocket-Version", version, sizeof(version));
cheezy_get_var(wsh->buffer, "Sec-WebSocket-Protocol", proto, sizeof(proto));
@@ -331,19 +337,22 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block)
ssize_t r;
int err = 0;
+ wsh->x++;
+ if (wsh->x > 250) ms_sleep(1);
+
if (wsh->ssl) {
do {
r = SSL_read(wsh->ssl, data, bytes);
- ms_sleep(10);
-
if (r == -1) {
err = SSL_get_error(wsh->ssl, r);
-
+
if (!block && err == SSL_ERROR_WANT_READ) {
r = -2;
goto end;
}
+
+ if (block) ms_sleep(10);
}
} while (r == -1 && err == SSL_ERROR_WANT_READ && wsh->x < 100);
@@ -353,10 +362,17 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block)
do {
r = recv(wsh->sock, data, bytes, 0);
- ms_sleep(10);
+ if (r == -1) {
+ if (!block && xp_is_blocking(xp_errno())) {
+ r = -2;
+ goto end;
+ }
+
+ if (block) ms_sleep(10);
+ }
} while (r == -1 && xp_is_blocking(xp_errno()) && wsh->x < 100);
- if (wsh->x >= 100) {
+ if (wsh->x >= 1000 || (block && wsh->x >= 100)) {
r = -1;
}
@@ -615,6 +631,11 @@ ssize_t ws_close(wsh_t *wsh, int16_t reason)
wsh->down = 1;
+ if (wsh->uri) {
+ free(wsh->uri);
+ wsh->uri = NULL;
+ }
+
if (reason && wsh->sock != ws_sock_invalid) {
uint16_t *u16;
uint8_t fr[4] = {WSOC_CLOSE | 0x80, 2, 0};
diff --git a/src/mod/endpoints/mod_verto/ws.h b/src/mod/endpoints/mod_verto/ws.h
index 37a3b9e401..7f5f5c48b4 100644
--- a/src/mod/endpoints/mod_verto/ws.h
+++ b/src/mod/endpoints/mod_verto/ws.h
@@ -72,6 +72,7 @@ typedef struct wsh_s {
ws_socket_t sock;
char buffer[65536];
char wbuffer[65536];
+ char *uri;
size_t buflen;
ssize_t datalen;
ssize_t wdatalen;
diff --git a/src/mod/languages/mod_lua/mod_lua.cpp b/src/mod/languages/mod_lua/mod_lua.cpp
index 95e6adbc9f..be68a43eb4 100644
--- a/src/mod/languages/mod_lua/mod_lua.cpp
+++ b/src/mod/languages/mod_lua/mod_lua.cpp
@@ -236,13 +236,14 @@ static switch_xml_t lua_fetch(const char *section,
{
switch_xml_t xml = NULL;
+ char *mycmd = NULL;
if (!zstr(globals.xml_handler)) {
lua_State *L = lua_init();
- char *mycmd = strdup(globals.xml_handler);
const char *str;
int error;
+ mycmd = strdup(globals.xml_handler);
switch_assert(mycmd);
lua_newtable(L);
@@ -267,7 +268,7 @@ static switch_xml_t lua_fetch(const char *section,
if((error = lua_parse_and_execute(L, mycmd))){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "LUA script parse/execute error!\n");
- return NULL;
+ goto end;
}
lua_getglobal(L, "XML_STRING");
@@ -285,9 +286,13 @@ static switch_xml_t lua_fetch(const char *section,
}
lua_uninit(L);
- free(mycmd);
+
}
+ end:
+
+ switch_safe_free(mycmd);
+
return xml;
}
diff --git a/src/mod/languages/mod_v8/src/fsglobal.cpp b/src/mod/languages/mod_v8/src/fsglobal.cpp
index 5fbc04c2be..38948c1843 100644
--- a/src/mod/languages/mod_v8/src/fsglobal.cpp
+++ b/src/mod/languages/mod_v8/src/fsglobal.cpp
@@ -237,6 +237,7 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLFile)
if ((config_data.fileHandle = open(filename, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
switch_curl_easy_setopt(curl_handle, CURLOPT_URL, url);
switch_curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
+ switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
switch_curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10);
switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, FSGlobal::FileCallback);
switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &config_data);
@@ -293,6 +294,7 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURL)
switch_curl_easy_setopt(curl_handle, CURLOPT_URL, url);
switch_curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
+ switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
switch_curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10);
switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, FSGlobal::FetchUrlCallback);
switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &config_data);
diff --git a/src/mod/loggers/mod_graylog2/conf/autoload_configs/graylog2.conf.xml b/src/mod/loggers/mod_graylog2/conf/autoload_configs/graylog2.conf.xml
index 76623e13bd..0a05482bf8 100644
--- a/src/mod/loggers/mod_graylog2/conf/autoload_configs/graylog2.conf.xml
+++ b/src/mod/loggers/mod_graylog2/conf/autoload_configs/graylog2.conf.xml
@@ -11,11 +11,13 @@
+
+
-
+
diff --git a/src/mod/loggers/mod_graylog2/mod_graylog2.c b/src/mod/loggers/mod_graylog2/mod_graylog2.c
index e799eda2cf..3db5c1fd2f 100644
--- a/src/mod/loggers/mod_graylog2/mod_graylog2.c
+++ b/src/mod/loggers/mod_graylog2/mod_graylog2.c
@@ -36,6 +36,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_graylog2_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_graylog2_shutdown);
SWITCH_MODULE_DEFINITION(mod_graylog2, mod_graylog2_load, mod_graylog2_shutdown, NULL);
+#define MAX_GELF_LOG_LEN 8192
+#define UNCOMPRESSED_MAGIC "\037\074"
+#define UNCOMPRESSED_MAGIC_LEN 2
+
static struct {
/** memory pool for this module */
switch_memory_pool_t *pool;
@@ -53,6 +57,8 @@ static struct {
switch_queue_t *log_queue;
/** Fields to automatically add to session logs */
switch_event_t *session_fields;
+ /** If true, byte header for uncompressed GELF is sent. Might be required if using logstash */
+ int send_uncompressed_header;
} globals;
/**
@@ -227,10 +233,19 @@ static void *SWITCH_THREAD_FUNC deliver_graylog2_thread(switch_thread_t *thread,
if (switch_queue_pop(globals.log_queue, (void *)&log) == SWITCH_STATUS_SUCCESS) {
if (!zstr(log)) {
switch_size_t len = strlen(log);
- if (len <= 8192) {
- switch_socket_send_nonblock(graylog2_sock, (void *)log, &len);
+ switch_size_t max_len = globals.send_uncompressed_header ? MAX_GELF_LOG_LEN - UNCOMPRESSED_MAGIC_LEN : MAX_GELF_LOG_LEN;
+ if (len <= max_len) {
+ if (globals.send_uncompressed_header) {
+ char buf[MAX_GELF_LOG_LEN];
+ memcpy(buf, UNCOMPRESSED_MAGIC, UNCOMPRESSED_MAGIC_LEN);
+ memcpy(buf + UNCOMPRESSED_MAGIC_LEN, log, len);
+ len += UNCOMPRESSED_MAGIC_LEN;
+ switch_socket_send_nonblock(graylog2_sock, (void *)buf, &len);
+ } else {
+ switch_socket_send_nonblock(graylog2_sock, (void *)log, &len);
+ }
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Skipping log with length > 8192 bytes\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Skipping large log\n");
}
}
switch_safe_free(log);
@@ -313,6 +328,7 @@ static switch_status_t do_config(void)
globals.log_level = SWITCH_LOG_WARNING;
globals.server_host = "127.0.0.1";
globals.server_port = 12201;
+ globals.send_uncompressed_header = 0;
if ((settings = switch_xml_child(cfg, "settings"))) {
switch_xml_t param;
@@ -353,6 +369,9 @@ static switch_status_t do_config(void)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\" = \"%s\"\n", name, value);
globals.log_level = log_level;
}
+ } else if (!strcasecmp(name, "send-uncompressed-header")) {
+ globals.send_uncompressed_header = switch_true(value);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\" = \"%s\"\n", name, value);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring unknown param: \"%s\"\n", name);
}
diff --git a/src/switch_apr.c b/src/switch_apr.c
index e77be82897..5e7dc52dbd 100644
--- a/src/switch_apr.c
+++ b/src/switch_apr.c
@@ -653,16 +653,16 @@ SWITCH_DECLARE(switch_interval_time_t) switch_interval_time_from_timeval(struct
/* socket stubs */
-SWITCH_DECLARE(switch_status_t) switch_os_sock_put(switch_socket_t **sock, switch_os_socket_t *thesock, switch_memory_pool_t *pool)
-{
- return apr_os_sock_put(sock, thesock, pool);
-}
-
SWITCH_DECLARE(switch_status_t) switch_os_sock_get(switch_os_socket_t *thesock, switch_socket_t *sock)
{
return apr_os_sock_get(thesock, sock);
}
+SWITCH_DECLARE(switch_status_t) switch_os_sock_put(switch_socket_t **sock, switch_os_socket_t *thesock, switch_memory_pool_t *pool)
+{
+ return apr_os_sock_put(sock, thesock, pool);
+}
+
SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t ** sa, switch_bool_t remote, switch_socket_t *sock)
{
return apr_socket_addr_get(sa, (apr_interface_e) remote, sock);
diff --git a/src/switch_channel.c b/src/switch_channel.c
index d983110791..bfd20abc91 100644
--- a/src/switch_channel.c
+++ b/src/switch_channel.c
@@ -4203,7 +4203,11 @@ SWITCH_DECLARE(switch_status_t) switch_channel_get_variables(switch_channel_t *c
{
switch_status_t status;
switch_mutex_lock(channel->profile_mutex);
- status = switch_event_dup(event, channel->variables);
+ if (channel->variables) {
+ status = switch_event_dup(event, channel->variables);
+ } else {
+ status = switch_event_create(event, SWITCH_EVENT_CHANNEL_DATA);
+ }
switch_mutex_unlock(channel->profile_mutex);
return status;
}
diff --git a/src/switch_core_io.c b/src/switch_core_io.c
index 337ccfc7fb..29e47a2dd9 100644
--- a/src/switch_core_io.c
+++ b/src/switch_core_io.c
@@ -1410,7 +1410,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
switch_time_t tdiff = diff;
while(tdiff > 1) {
- switch_buffer_write(bp->raw_read_buffer, fill_data, len);
+ switch_buffer_write(bp->raw_write_buffer, fill_data, len);
tdiff--;
}
}
diff --git a/src/switch_ivr.c b/src/switch_ivr.c
index 52661e2e1e..a08bb0a40d 100644
--- a/src/switch_ivr.c
+++ b/src/switch_ivr.c
@@ -3434,7 +3434,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_process_fh(switch_core_session_t *ses
}
samps = step * (fhp->native_rate / 1000);
- target = (int32_t)fhp->pos + samps;
+ target = (int32_t)fhp->offset_pos + samps;
if (target < 0) {
target = 0;