From 9cf72b541e8184b2911b0bd78f9aee71cd6d44b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Dragi=C4=87?= Date: Sun, 7 Sep 2014 16:43:00 +0200 Subject: [PATCH 01/32] FS-6799 fix reading sms in index 0 --- .../mod_gsmopen/gsmopen_protocol.cpp | 66 +++++++++---------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp index 12b6903e94..8e618c50ab 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp +++ b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp @@ -1154,45 +1154,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 From d5f9de4fa3b656f694de047719a08af758fc259a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Dragi=C4=87?= Date: Thu, 11 Sep 2014 22:33:28 +0200 Subject: [PATCH 02/32] mod_gsmopen: add AT+COPS support to get operator name. For now expose the info in gsmopen_dump and events. --- src/mod/endpoints/mod_gsmopen/gsmopen.h | 2 ++ .../mod_gsmopen/gsmopen_protocol.cpp | 26 +++++++++++++++++++ src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp | 3 +++ 3 files changed, 31 insertions(+) diff --git a/src/mod/endpoints/mod_gsmopen/gsmopen.h b/src/mod/endpoints/mod_gsmopen/gsmopen.h index f56866a587..6ba413e3b1 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmopen.h +++ b/src/mod/endpoints/mod_gsmopen/gsmopen.h @@ -449,6 +449,8 @@ struct private_object { int requesting_imei; char imsi[128]; int requesting_imsi; + char operator_name[128]; + int requesting_operator_name; 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..7533e40a5b 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp +++ b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp @@ -358,6 +358,15 @@ 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); + } + /* IMEI */ tech_pvt->requesting_imei = 1; res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+GSN"); @@ -1006,6 +1015,23 @@ 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], "+CMGW:", 6) == 0)) { int err; diff --git a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp index a92303351a..73478826e7 100644 --- a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp +++ b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp @@ -2422,6 +2422,7 @@ SWITCH_STANDARD_API(gsmopen_dump_function) stream->write_function(stream, "got_signal = %s\n", value); snprintf(value, sizeof(value) - 1, "%d", tech_pvt->running); stream->write_function(stream, "running = %s\n", value); + 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); @@ -2480,6 +2481,7 @@ SWITCH_STANDARD_API(gsmopen_dump_function) stream->write_function(stream, "got_signal = %s\n", value); snprintf(value, sizeof(value) - 1, "%d", tech_pvt->running); stream->write_function(stream, "running = %s\n", value); + 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); @@ -2809,6 +2811,7 @@ int dump_event_full(private_t *tech_pvt, int is_alarm, int alarm_code, const cha switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "got_signal", 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, "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); From 9423953e028f8dd319a790ba1e5fdca37ff0cb2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Dragi=C4=87?= Date: Sun, 14 Sep 2014 12:24:19 +0200 Subject: [PATCH 03/32] FS-6820 mod_gsmopen: fix total interfaces count when executing gsm reload --- src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp index a92303351a..dfc354435c 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]; From 79b3cdfc967376511d113d6386e450a5f7ab0db2 Mon Sep 17 00:00:00 2001 From: Brian West Date: Thu, 18 Sep 2014 17:54:22 -0500 Subject: [PATCH 04/32] update to strong hash and keysize --- docs/how_to_make_your_own_ca_correctly.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 10c840368972abefe2607dc2bb7d05668644f3ac Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Fri, 19 Sep 2014 04:29:34 +0000 Subject: [PATCH 05/32] Document guidelines for proposing a new module --- docs/SubmittingPatches | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/SubmittingPatches b/docs/SubmittingPatches index f60483fc0b..f16ac085d2 100644 --- a/docs/SubmittingPatches +++ b/docs/SubmittingPatches @@ -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... --------------- From 4dc7f92aff804447154fde712a312eda67a2e97b Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Fri, 19 Sep 2014 06:38:35 +0000 Subject: [PATCH 06/32] Update document to HTTPS URLs --- docs/SubmittingPatches | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/SubmittingPatches b/docs/SubmittingPatches index f16ac085d2..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: @@ -214,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 From 79d962f38e29daec3e0bc66b4a9dbfd95e8acb82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Dragi=C4=87?= Date: Thu, 11 Sep 2014 22:50:22 +0200 Subject: [PATCH 07/32] mod_gsmopen: add support for reading own number from ON phonebook using AT+CNUM --- src/mod/endpoints/mod_gsmopen/gsmopen.h | 2 + .../mod_gsmopen/gsmopen_protocol.cpp | 43 +++++++++++++++++++ src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp | 3 ++ 3 files changed, 48 insertions(+) diff --git a/src/mod/endpoints/mod_gsmopen/gsmopen.h b/src/mod/endpoints/mod_gsmopen/gsmopen.h index 6ba413e3b1..97731c676d 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmopen.h +++ b/src/mod/endpoints/mod_gsmopen/gsmopen.h @@ -451,6 +451,8 @@ struct private_object { int requesting_imsi; char operator_name[128]; int requesting_operator_name; + char subscriber_number[128]; + int requesting_subscriber_number; 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 7533e40a5b..5f0efb9121 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp +++ b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp @@ -367,6 +367,14 @@ int gsmopen_serial_config_AT(private_t *tech_pvt) 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"); @@ -1032,6 +1040,41 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us 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; diff --git a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp index 73478826e7..c9af03e3b1 100644 --- a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp +++ b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp @@ -2422,6 +2422,7 @@ SWITCH_STANDARD_API(gsmopen_dump_function) stream->write_function(stream, "got_signal = %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, "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); @@ -2481,6 +2482,7 @@ SWITCH_STANDARD_API(gsmopen_dump_function) stream->write_function(stream, "got_signal = %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, "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); @@ -2811,6 +2813,7 @@ int dump_event_full(private_t *tech_pvt, int is_alarm, int alarm_code, const cha switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "got_signal", 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, "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); From 13a595a15e5b4c4529e6a4fcef7c599368577a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Dragi=C4=87?= Date: Thu, 11 Sep 2014 23:14:09 +0200 Subject: [PATCH 08/32] mod_gsmopen: get device manufacturer, model and firmware version info. --- src/mod/endpoints/mod_gsmopen/gsmopen.h | 6 ++++ .../mod_gsmopen/gsmopen_protocol.cpp | 34 ++++++++++++++++++- src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp | 9 +++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_gsmopen/gsmopen.h b/src/mod/endpoints/mod_gsmopen/gsmopen.h index 97731c676d..9b632f9654 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmopen.h +++ b/src/mod/endpoints/mod_gsmopen/gsmopen.h @@ -453,6 +453,12 @@ struct private_object { 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 5f0efb9121..0880c64854 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) { @@ -1682,13 +1694,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 c9af03e3b1..4a8ed76c4f 100644 --- a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp +++ b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp @@ -2423,6 +2423,9 @@ SWITCH_STANDARD_API(gsmopen_dump_function) 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); @@ -2483,6 +2486,9 @@ SWITCH_STANDARD_API(gsmopen_dump_function) 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); @@ -2814,6 +2820,9 @@ int dump_event_full(private_t *tech_pvt, int is_alarm, int alarm_code, const cha 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); From 4aa7c98d5a9dc20c23f2fac6cae0b9bddb0615d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Dragi=C4=87?= Date: Thu, 11 Sep 2014 23:29:21 +0200 Subject: [PATCH 09/32] mod_gsmopen: convert reported RSSI from AT+CSQ to dBm. Add to gsmopen_dump and events. --- src/mod/endpoints/mod_gsmopen/gsmopen.h | 1 + src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp | 6 ++++++ src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/src/mod/endpoints/mod_gsmopen/gsmopen.h b/src/mod/endpoints/mod_gsmopen/gsmopen.h index 9b632f9654..80bee58265 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmopen.h +++ b/src/mod/endpoints/mod_gsmopen/gsmopen.h @@ -445,6 +445,7 @@ struct private_object { int roaming_registered; int not_registered; int got_signal; + int signal_strength; char imei[128]; int requesting_imei; char imsi[128]; diff --git a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp index 0880c64854..4b68b0a786 100644 --- a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp +++ b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp @@ -996,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 */ + } + } } diff --git a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp index 4a8ed76c4f..797f3399d1 100644 --- a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp +++ b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp @@ -2420,6 +2420,8 @@ 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); @@ -2483,6 +2485,8 @@ 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); @@ -2817,6 +2821,8 @@ 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); From a9b2e061dcd1d95322d27e169ac2f0016aa628a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Dragi=C4=87?= Date: Thu, 11 Sep 2014 23:52:00 +0200 Subject: [PATCH 10/32] mod_gsmopen: clean up "gsm list" output a little Replace tabs with spaces and add two columns, operator and imei. --- src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp index 797f3399d1..76db924b25 100644 --- a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp +++ b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp @@ -2224,8 +2224,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 +2238,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, From 1bb0b8e16d114f943e02101230bf8b6517b9c1f4 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 23 Sep 2014 03:56:59 +0500 Subject: [PATCH 11/32] fix leak in lua when script does not execute properly in xml_binding handler --- src/mod/languages/mod_lua/mod_lua.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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; } From 0cc7bc8db62b4abf099e6d92fe0c577010e3bce4 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 22 Sep 2014 23:41:47 +0000 Subject: [PATCH 12/32] Add missing CURLOPT_NOSIGNAL options To work correctly in a multi-threaded environment, curl needs to be used with CURLOPT_NOSIGNAL set to 1. If it's left at zero, the default, then curl will use signals to deal with timeouts which will often result in a crash. ref: http://curl.haxx.se/libcurl/c/libcurl-tutorial.html#Multi-threading ref: http://curl.haxx.se/libcurl/c/CURLOPT_NOSIGNAL.html ref: http://stackoverflow.com/questions/9191668/error-longjmp-causes-uninitialized-stack-frame ref: https://bugzilla.redhat.com/show_bug.cgi?id=539809 ref: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=570436 --- src/mod/applications/mod_snom/mod_snom.c | 1 + src/mod/languages/mod_v8/src/fsglobal.cpp | 2 ++ 2 files changed, 3 insertions(+) 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/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); From 59e71341db61718b33be025df6c205359254a76e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 23 Sep 2014 20:17:20 +0500 Subject: [PATCH 13/32] fix possible buffer overrun in websocket uri and sync the ws.c between sofia and verto --- libs/sofia-sip/.update | 2 +- .../libsofia-sip-ua/tport/tport_type_ws.c | 2 +- libs/sofia-sip/libsofia-sip-ua/tport/ws.c | 22 ++++++++----------- libs/sofia-sip/libsofia-sip-ua/tport/ws.h | 3 ++- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index 66c9d49924..d87400bf8e 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Sat Aug 16 01:34:24 CDT 2014 +Tue Sep 23 20:16:55 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..6e91ff6493 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 @@ -269,7 +264,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; @@ -317,15 +312,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; @@ -543,7 +538,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 +546,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; diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.h b/libs/sofia-sip/libsofia-sip-ua/tport/ws.h index b4d30b47f2..37a3b9e401 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.h +++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.h @@ -88,6 +88,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 +102,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); From e8d68668994f5c245a0522295da1c8d9dcdbc49e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 23 Sep 2014 21:01:25 +0500 Subject: [PATCH 14/32] use the more reliable offset_pos counter in file position parsing for seek in scripts --- src/switch_ivr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 9e72c8477fbc1e7ff0f7700aa259b1e6c9938057 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 24 Sep 2014 01:09:44 +0500 Subject: [PATCH 15/32] fix possible buffer overrun in websocket uri and sync the ws.c between sofia and verto (missing code from last commit) --- libs/sofia-sip/.update | 2 +- libs/sofia-sip/libsofia-sip-ua/tport/ws.c | 14 ++++++++++---- libs/sofia-sip/libsofia-sip-ua/tport/ws.h | 1 + src/mod/endpoints/mod_verto/ws.c | 14 ++++++++++---- src/mod/endpoints/mod_verto/ws.h | 1 + 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index d87400bf8e..cb2691c2a1 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Tue Sep 23 20:16:55 CDT 2014 +Wed Sep 24 01:09:42 CDT 2014 diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c index 6e91ff6493..2fcd7021c0 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c @@ -241,7 +241,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 +275,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)); @@ -615,6 +616,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 37a3b9e401..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; diff --git a/src/mod/endpoints/mod_verto/ws.c b/src/mod/endpoints/mod_verto/ws.c index 6e91ff6493..2fcd7021c0 100644 --- a/src/mod/endpoints/mod_verto/ws.c +++ b/src/mod/endpoints/mod_verto/ws.c @@ -241,7 +241,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 +275,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)); @@ -615,6 +616,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; From 7d7223e931977ab380f17537cc4498811d25bf6d Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Tue, 23 Sep 2014 16:40:46 -0400 Subject: [PATCH 16/32] FS-6842 #resolve mod_graylog2: added send-uncompressed-header param- set to true for logstash support --- .../conf/autoload_configs/graylog2.conf.xml | 4 ++- src/mod/loggers/mod_graylog2/mod_graylog2.c | 25 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) 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); } From e02e41a5c1f95b1fe6ada50fc0051fb524fe90b4 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 23 Sep 2014 18:08:34 -0400 Subject: [PATCH 17/32] don't package mod_cluechoo and don't build/load by default --- build/modules.conf.in | 2 +- conf/vanilla/autoload_configs/modules.conf.xml | 2 +- debian/bootstrap.sh | 3 +-- debian/control-modules | 5 ----- 4 files changed, 3 insertions(+), 9 deletions(-) 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/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/debian/control-modules b/debian/control-modules index 9246317117..715565c811 100644 --- a/debian/control-modules +++ b/debian/control-modules @@ -30,11 +30,6 @@ Description: Caller ID name lookup This module provides an API for querying caller ID name and location data. -Module: applications/mod_cluechoo -Description: Clue Choo - This demo module renders a Clue Choo train on the FreeSWITCH console. -Build-Depends: libncurses5-dev - Module: applications/mod_commands Description: Command module This module provides miscellaneous API commands. From c018c28738153349d17397b00beb462d2ce4c7f2 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 24 Sep 2014 20:40:22 +0500 Subject: [PATCH 18/32] FS-6851 #resolve --- src/switch_channel.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; } From cd67dfc630637a2902b2aafee3ab60bfac832d67 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Wed, 24 Sep 2014 19:22:02 +0000 Subject: [PATCH 19/32] Add mod_cluechoo back to debian/control-modules The debian/control-modules file is a comprehensive list of modules, not a list of modules which are built. Our build tools verify the file is comprehensive, so modules can't be removed from here unless we're taking them out of tree. Partially revert "don't package mod_cluechoo and don't build/load by default" This partially reverts commit e02e41a5c1f95b1fe6ada50fc0051fb524fe90b4. --- debian/control-modules | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debian/control-modules b/debian/control-modules index 715565c811..9246317117 100644 --- a/debian/control-modules +++ b/debian/control-modules @@ -30,6 +30,11 @@ Description: Caller ID name lookup This module provides an API for querying caller ID name and location data. +Module: applications/mod_cluechoo +Description: Clue Choo + This demo module renders a Clue Choo train on the FreeSWITCH console. +Build-Depends: libncurses5-dev + Module: applications/mod_commands Description: Command module This module provides miscellaneous API commands. From 051772e4ae574c52adfca95d3811e2a06bc0e2e8 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Thu, 25 Sep 2014 10:47:18 +0000 Subject: [PATCH 20/32] Add fs_cli option to disable use of history file With this commit, passing -Q to fs_cli will cause fs_cli to not load or save the command history file (~/.fs_cli_history). This can be useful e.g. on read-only systems. This can also be set in the fs_cli configuration file with the option `no-history-file`. --- libs/esl/fs_cli.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) 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 From 13d9e99ae772ced3d3f4e825201558c88a5cccd1 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Thu, 25 Sep 2014 13:18:02 +0000 Subject: [PATCH 21/32] Handle gcc quirk with parameter checking At least some versions of GCC appear to take any -Wno-foo option without error even if that option is not supported. But they will error out if -Wno-error=foo is used. This sounds like a GCC bug, but we'll work around it and test for the feature both ways. Thanks-to: Matteo Brancaleoni FS-6850 #resolve --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index dbb5a925f2..857a59e7a5 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])]) From 221af936d88b5eb79e0a706dab64cb882e650e4f Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Tue, 23 Sep 2014 09:01:27 -0500 Subject: [PATCH 22/32] bump freeswitch verson in doxygen conf --- docs/Doxygen.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From f7de058acdf2bdd915ea0b9c0db1634e4a84434c Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 25 Sep 2014 21:43:57 +0500 Subject: [PATCH 23/32] FS-6854 #resolve --- libs/sofia-sip/.update | 2 +- libs/sofia-sip/libsofia-sip-ua/tport/ws.c | 20 +++++++++++++++----- src/mod/endpoints/mod_verto/ws.c | 20 +++++++++++++++----- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index cb2691c2a1..63605e55a1 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Wed Sep 24 01:09:42 CDT 2014 +Thu Sep 25 21:43:53 CDT 2014 diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c index 2fcd7021c0..7f4318e543 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c @@ -332,19 +332,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); @@ -354,10 +357,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; } diff --git a/src/mod/endpoints/mod_verto/ws.c b/src/mod/endpoints/mod_verto/ws.c index 2fcd7021c0..7f4318e543 100644 --- a/src/mod/endpoints/mod_verto/ws.c +++ b/src/mod/endpoints/mod_verto/ws.c @@ -332,19 +332,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); @@ -354,10 +357,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; } From 4eb64cb107c14ef5a89dba9ef97d24667fc1341d Mon Sep 17 00:00:00 2001 From: Russell Treleaven Date: Thu, 25 Sep 2014 14:05:44 -0400 Subject: [PATCH 24/32] make vanilla configuration gateways easier to understand for new users having the same gateway definition bound to the ipv6 and ipv4 external profiles caused confusion for some new users. Also having a gateway bound to the internal profile was a bit confusing. fs-6859 --- conf/vanilla/sip_profiles/external-ipv6.xml | 2 +- .../sip_profiles/{internal => external-ipv6}/example.xml | 7 ++++--- conf/vanilla/sip_profiles/internal.xml | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) rename conf/vanilla/sip_profiles/{internal => external-ipv6}/example.xml (90%) 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 90% rename from conf/vanilla/sip_profiles/internal/example.xml rename to conf/vanilla/sip_profiles/external-ipv6/example.xml index a5cbd7d2b7..0497bcd1e1 100644 --- a/conf/vanilla/sip_profiles/internal/example.xml +++ b/conf/vanilla/sip_profiles/external-ipv6/example.xml @@ -28,10 +28,11 @@ - - - + + + + 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 @@ - From 07671917697ddbcf774cc6185feb61f38d9e2b05 Mon Sep 17 00:00:00 2001 From: Brian West Date: Thu, 25 Sep 2014 15:10:11 -0500 Subject: [PATCH 25/32] FS-6803 try this, less is more --- .../mod_translate/mod_translate.c | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) 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; From 7c89c21153534fa04da170fc1453b5f0f93cf7bb Mon Sep 17 00:00:00 2001 From: Brian West Date: Fri, 26 Sep 2014 09:00:09 -0500 Subject: [PATCH 26/32] FS-6860 #resolve this was fixed once but was lost in the last sync --- libs/sofia-sip/libsofia-sip-ua/tport/ws.c | 5 +++++ src/mod/endpoints/mod_verto/ws.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c index 7f4318e543..6fa69d2161 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/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 diff --git a/src/mod/endpoints/mod_verto/ws.c b/src/mod/endpoints/mod_verto/ws.c index 7f4318e543..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 From e4f77140d2aebef47671dd3b2f028930c7ee1f86 Mon Sep 17 00:00:00 2001 From: Russell Treleaven Date: Fri, 26 Sep 2014 13:54:52 -0400 Subject: [PATCH 27/32] make the gateway parameters to make the gateways samples the same It was noticed that the sample gateways were diferent. Brian West suggest that I merge all the parameters into both examples. fs-6859 --- conf/vanilla/sip_profiles/external-ipv6/example.xml | 5 ++++- conf/vanilla/sip_profiles/external/example.xml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/conf/vanilla/sip_profiles/external-ipv6/example.xml b/conf/vanilla/sip_profiles/external-ipv6/example.xml index 0497bcd1e1..d8fe39539a 100644 --- a/conf/vanilla/sip_profiles/external-ipv6/example.xml +++ b/conf/vanilla/sip_profiles/external-ipv6/example.xml @@ -28,11 +28,14 @@ + + - + + 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 @@ + + - + + From c1e9b0d41455e34c3daa8752bb41a97d368710c1 Mon Sep 17 00:00:00 2001 From: Darren Schreiber Date: Sat, 27 Sep 2014 15:01:39 -0700 Subject: [PATCH 28/32] expose apr socket put --- src/include/switch_apr.h | 1 + src/switch_apr.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/include/switch_apr.h b/src/include/switch_apr.h index 50096d5aff..ea08dc797b 100644 --- a/src/include/switch_apr.h +++ b/src/include/switch_apr.h @@ -1406,6 +1406,7 @@ 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_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); SWITCH_DECLARE(switch_status_t) switch_os_sock_put(switch_socket_t **sock, switch_os_socket_t *thesock, switch_memory_pool_t *pool); /** diff --git a/src/switch_apr.c b/src/switch_apr.c index e77be82897..bad894604c 100644 --- a/src/switch_apr.c +++ b/src/switch_apr.c @@ -663,6 +663,11 @@ SWITCH_DECLARE(switch_status_t) switch_os_sock_get(switch_os_socket_t *thesock, 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); From dac4afbfdb717ffca55cddc661119efeb19f1ea7 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Sun, 28 Sep 2014 10:40:57 -0400 Subject: [PATCH 29/32] this was alraedy in there, whoops --- src/include/switch_apr.h | 1 - src/switch_apr.c | 5 ----- 2 files changed, 6 deletions(-) diff --git a/src/include/switch_apr.h b/src/include/switch_apr.h index ea08dc797b..0f872e2296 100644 --- a/src/include/switch_apr.h +++ b/src/include/switch_apr.h @@ -1408,7 +1408,6 @@ SWITCH_DECLARE(switch_status_t) switch_match_glob(const char *pattern, switch_ar SWITCH_DECLARE(switch_status_t) switch_os_sock_get(switch_os_socket_t *thesock, 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); -SWITCH_DECLARE(switch_status_t) switch_os_sock_put(switch_socket_t **sock, switch_os_socket_t *thesock, switch_memory_pool_t *pool); /** * Create an anonymous pipe. * @param in The file descriptor to use as input to the pipe. diff --git a/src/switch_apr.c b/src/switch_apr.c index bad894604c..5e7dc52dbd 100644 --- a/src/switch_apr.c +++ b/src/switch_apr.c @@ -653,11 +653,6 @@ 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); From d619017621bc223599fdb6e927077914f6aabfc8 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 29 Sep 2014 19:20:55 +0500 Subject: [PATCH 30/32] FS-6757 FS-6713 FS-6868 FS-6863 FS-6858 5 bugs one typo. From commit 1b612fecb6e8db11da9b15c5522b87e7b642423d --- src/switch_core_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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--; } } From e94af49e1e482158208679591fc8ebc7c1dc3639 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 29 Sep 2014 19:26:01 +0500 Subject: [PATCH 31/32] revert --- src/switch_core_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_core_io.c b/src/switch_core_io.c index 29e47a2dd9..337ccfc7fb 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_write_buffer, fill_data, len); + switch_buffer_write(bp->raw_read_buffer, fill_data, len); tdiff--; } } From da51603a2c0c432e5ed126e8fa35f3e8e7e411d9 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 29 Sep 2014 19:26:32 +0500 Subject: [PATCH 32/32] FS-6757 FS-6713 FS-6868 FS-6863 FS-6858 #resolve #comment 5 bugs one typo. From commit 1b612fecb6e8db11da9b15c5522b87e7b642423d --- src/switch_core_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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--; } }