forked from Mirrors/freeswitch
Compare commits
20 Commits
master
...
coverity_1
Author | SHA1 | Date |
---|---|---|
Jakub Karolczyk | d91bc3906f | |
Jakub Karolczyk | 639dab4edf | |
Jakub Karolczyk | fcbbf5df42 | |
Jakub Karolczyk | c750913edf | |
Jakub Karolczyk | c36ee94b13 | |
Jakub Karolczyk | 1464f1b1e7 | |
Jakub Karolczyk | 8f8850c75b | |
Jakub Karolczyk | 13822d8d50 | |
Jakub Karolczyk | 39014f6b3b | |
Jakub Karolczyk | 7025af9fb5 | |
Dragos Oancea | 6def61e68a | |
Dragos Oancea | 87d9c91194 | |
Dragos Oancea | 057234f768 | |
Dragos Oancea | 2e9dc04c10 | |
Dragos Oancea | f62a341b5d | |
Dragos Oancea | 1b0c47416c | |
Dragos Oancea | 084b790115 | |
Dragos Oancea | 142da7c9bd | |
Dragos Oancea | eb59ea0e46 | |
Dragos Oancea | af342cf3d5 |
|
@ -112,6 +112,10 @@ extern int compute_table(void)
|
|||
|
||||
acos_table_file = fopen(ACOS_TABLE_FILENAME, "w");
|
||||
|
||||
if (!acos_table_file) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
for (i = 0; i < ACOS_TABLE_LENGTH; i++) {
|
||||
f = acosf(float_from_index(i));
|
||||
res = fwrite(&f, sizeof(f), 1, acos_table_file);
|
||||
|
@ -124,10 +128,12 @@ extern int compute_table(void)
|
|||
if (res != 0) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
fclose(acos_table_file);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -144,8 +150,9 @@ extern int init_fast_acosf(void)
|
|||
* or some other error occured */
|
||||
errsv = errno;
|
||||
strerror_r(errsv, err, 150);
|
||||
if (errsv != ENOENT) return -1;
|
||||
else {
|
||||
if (errsv != ENOENT) {
|
||||
return -1;
|
||||
} else {
|
||||
switch_log_printf(
|
||||
SWITCH_CHANNEL_LOG,
|
||||
SWITCH_LOG_NOTICE,
|
||||
|
@ -170,6 +177,7 @@ extern int init_fast_acosf(void)
|
|||
acos_table = (float *) mmap(
|
||||
NULL, /* kernel chooses the address at which to create the mapping */
|
||||
ACOS_TABLE_LENGTH * sizeof(float), PROT_READ, MAP_SHARED, acos_fd, 0);
|
||||
fclose(acos_fp);
|
||||
if (acos_table == MAP_FAILED) return -4;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1138,6 +1138,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load) {
|
|||
|
||||
switch_application_interface_t *app_interface;
|
||||
switch_api_interface_t *api_interface;
|
||||
|
||||
if (pool == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No memory pool assigned!\n");
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
|
@ -1147,10 +1153,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load) {
|
|||
}
|
||||
|
||||
memset(&avmd_globals, 0, sizeof(avmd_globals));
|
||||
if (pool == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No memory pool assigned!\n");
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
switch_mutex_init(&avmd_globals.mutex, SWITCH_MUTEX_NESTED, pool);
|
||||
avmd_globals.pool = pool;
|
||||
|
||||
|
|
|
@ -4584,7 +4584,7 @@ SWITCH_STANDARD_APP(wait_for_silence_function)
|
|||
timeout_ms = switch_atoui(argv[3]);
|
||||
}
|
||||
|
||||
if (thresh > 0 && silence_hits > 0 && listen_hits >= 0) {
|
||||
if (thresh > 0 && silence_hits > 0 && listen_hits > 0) {
|
||||
switch_ivr_wait_for_silence(session, thresh, silence_hits, listen_hits, timeout_ms, argv[4]);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -130,6 +130,7 @@ static void translate_number(char *number, char *profile, char **translated, swi
|
|||
hi = switch_core_hash_find_rdlock(globals.translate_profiles, (const char *)profile, globals.profile_hash_rwlock);
|
||||
if (!hi) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "can't find key for profile matching [%s]\n", profile);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -142,6 +143,7 @@ static void translate_number(char *number, char *profile, char **translated, swi
|
|||
switch_regex_safe_free(re);
|
||||
goto end;
|
||||
}
|
||||
|
||||
memset(substituted, 0, len);
|
||||
|
||||
switch_perform_substitution(re, proceed, rule->replace, number, substituted, len, ovector);
|
||||
|
@ -153,14 +155,15 @@ static void translate_number(char *number, char *profile, char **translated, swi
|
|||
} else if (event) {
|
||||
subbed = switch_event_expand_headers(event, substituted);
|
||||
}
|
||||
|
||||
switch_safe_free(substituted);
|
||||
if (session) {
|
||||
substituted = switch_core_session_strdup(session, subbed);
|
||||
} else {
|
||||
substituted = switch_core_strdup(pool, subbed);
|
||||
}
|
||||
if (subbed != substituted) {
|
||||
switch_safe_free(subbed);
|
||||
}
|
||||
|
||||
switch_safe_free(subbed);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -772,10 +772,6 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||
|
||||
end:
|
||||
|
||||
if (mutex) {
|
||||
switch_mutex_unlock(mutex);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -815,8 +815,12 @@ sres_record_t ** dig_addr_simple(struct dig *dig,
|
|||
uint16_t type)
|
||||
{
|
||||
sres_record_t **answers = NULL;
|
||||
int error;
|
||||
|
||||
sres_blocking_query(dig->sres, type, host, 0, &answers);
|
||||
error = sres_blocking_query(dig->sres, type, host, 0, &answers);
|
||||
if (error < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return answers;
|
||||
}
|
||||
|
|
|
@ -1998,7 +1998,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_erlang_event_runtime)
|
|||
struct ei_cnode_s ec;
|
||||
ErlConnect conn;
|
||||
int clientfd;
|
||||
switch_os_socket_t epmdfd;
|
||||
switch_os_socket_t epmdfd = SWITCH_SOCK_INVALID;
|
||||
switch_socket_t *epmd_sock = NULL;
|
||||
|
||||
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
|
||||
|
|
|
@ -564,13 +564,16 @@ switch_status_t kazoo_config_fetch_handler(kazoo_config_ptr definitions, kazoo_c
|
|||
switch_memory_pool_t *pool = NULL;
|
||||
|
||||
char *name = (char *) switch_xml_attr_soft(cfg, "name");
|
||||
|
||||
if (zstr(name)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "missing name in profile\n");
|
||||
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error allocation pool for new profile : %s\n", name);
|
||||
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
|
@ -582,6 +585,7 @@ switch_status_t kazoo_config_fetch_handler(kazoo_config_ptr definitions, kazoo_c
|
|||
fetch_section = switch_xml_parse_section_string(name);
|
||||
|
||||
if ((params = switch_xml_child(cfg, "params")) != NULL) {
|
||||
|
||||
for (param = switch_xml_child(params, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
@ -605,7 +609,9 @@ switch_status_t kazoo_config_fetch_handler(kazoo_config_ptr definitions, kazoo_c
|
|||
}
|
||||
|
||||
if (fetch_section == SWITCH_XML_SECTION_RESULT) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Fetch Profile[%s] invalid fetch-section: %s\n", name, switch_xml_toxml(cfg, SWITCH_FALSE));
|
||||
char *tmp = switch_xml_toxml(cfg, SWITCH_FALSE);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Fetch Profile[%s] invalid fetch-section: %s\n", name, tmp);
|
||||
free(tmp);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -622,17 +628,20 @@ switch_status_t kazoo_config_fetch_handler(kazoo_config_ptr definitions, kazoo_c
|
|||
}
|
||||
}
|
||||
|
||||
if(ptr)
|
||||
if (ptr) {
|
||||
*ptr = profile;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "fetch handler profile %s successfully configured\n", name);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
err:
|
||||
/* Cleanup */
|
||||
if(pool) {
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
}
|
||||
if(pool) {
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_GENERR;
|
||||
|
||||
}
|
||||
|
|
|
@ -233,9 +233,11 @@ cJSON * kazoo_event_add_field_to_json(cJSON *dst, switch_event_t *src, kazoo_fie
|
|||
} else if((header = switch_event_get_header_ptr(src, field->name)) != NULL) {
|
||||
if (header->idx) {
|
||||
item = cJSON_CreateArray();
|
||||
|
||||
for(i = 0; i < header->idx; i++) {
|
||||
cJSON_AddItemToArray(item, kazoo_event_json_value(field->out_type, header->array[i]));
|
||||
}
|
||||
|
||||
kazoo_cJSON_AddItemToObject(dst, field->as ? field->as : field->name, item);
|
||||
} else if (field->out_type_as_array) {
|
||||
item = cJSON_CreateArray();
|
||||
|
@ -251,13 +253,13 @@ cJSON * kazoo_event_add_field_to_json(cJSON *dst, switch_event_t *src, kazoo_fie
|
|||
expanded = kz_event_expand_headers(src, field->value);
|
||||
if(expanded != NULL && !zstr(expanded)) {
|
||||
item = kazoo_event_add_json_value(dst, field, field->as ? field->as : field->name, expanded);
|
||||
if(expanded != field->value) {
|
||||
free(expanded);
|
||||
}
|
||||
}
|
||||
|
||||
switch_safe_free(expanded);
|
||||
break;
|
||||
|
||||
case FIELD_FIRST_OF:
|
||||
|
||||
for(n = 0; n < field->list.size; n++) {
|
||||
if(*field->list.value[n] == '#') {
|
||||
item = kazoo_event_add_json_value(dst, field, field->as ? field->as : field->name, ++field->list.value[n]);
|
||||
|
@ -267,33 +269,41 @@ cJSON * kazoo_event_add_field_to_json(cJSON *dst, switch_event_t *src, kazoo_fie
|
|||
if(header) {
|
||||
if (header->idx) {
|
||||
item = cJSON_CreateArray();
|
||||
|
||||
for(i = 0; i < header->idx; i++) {
|
||||
cJSON_AddItemToArray(item, kazoo_event_json_value(field->out_type, header->array[i]));
|
||||
}
|
||||
|
||||
kazoo_cJSON_AddItemToObject(dst, field->as ? field->as : field->name, item);
|
||||
} else {
|
||||
item = kazoo_event_add_json_value(dst, field, field->as ? field->as : field->name, header->value);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case FIELD_PREFIX:
|
||||
|
||||
for (header = src->headers; header; header = header->next) {
|
||||
if(!strncmp(header->name, field->name, strlen(field->name))) {
|
||||
if (header->idx) {
|
||||
cJSON *array = cJSON_CreateArray();
|
||||
|
||||
for(i = 0; i < header->idx; i++) {
|
||||
cJSON_AddItemToArray(array, kazoo_event_json_value(field->out_type, header->array[i]));
|
||||
}
|
||||
|
||||
kazoo_cJSON_AddItemToObject(dst, field->exclude_prefix ? header->name+strlen(field->name) : header->name, array);
|
||||
} else {
|
||||
kazoo_event_add_json_value(dst, field, field->exclude_prefix ? header->name+strlen(field->name) : header->name, header->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case FIELD_STATIC:
|
||||
|
@ -308,7 +318,7 @@ cJSON * kazoo_event_add_field_to_json(cJSON *dst, switch_event_t *src, kazoo_fie
|
|||
break;
|
||||
}
|
||||
|
||||
return item;
|
||||
return item;
|
||||
}
|
||||
|
||||
static switch_status_t kazoo_event_add_fields_to_json(kazoo_logging_ptr logging, cJSON *dst, switch_event_t *src, kazoo_field_ptr field) {
|
||||
|
|
|
@ -1097,23 +1097,27 @@ static switch_status_t handle_request_fetch_reply(ei_node_t *ei_node, erlang_pid
|
|||
if (ei_decode_atom_safe(buf->buff, &buf->index, section_str)
|
||||
|| !(section = switch_xml_parse_section_string(section_str))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring a fetch reply without a configuration section\n");
|
||||
|
||||
return erlang_response_badarg(rbuf);
|
||||
}
|
||||
|
||||
if (ei_decode_string_or_binary_limited(buf->buff, &buf->index, sizeof(uuid_str), uuid_str)
|
||||
|| zstr_buf(uuid_str)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring a fetch reply without request UUID\n");
|
||||
|
||||
return erlang_response_badarg(rbuf);
|
||||
}
|
||||
|
||||
if (ei_decode_string_or_binary(buf->buff, &buf->index, &xml_str)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring a fetch reply without XML : %s \n", uuid_str);
|
||||
|
||||
return erlang_response_badarg(rbuf);
|
||||
}
|
||||
|
||||
if (zstr(xml_str)) {
|
||||
switch_safe_free(xml_str);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring an empty fetch reply : %s\n", uuid_str);
|
||||
|
||||
return erlang_response_badarg(rbuf);
|
||||
}
|
||||
|
||||
|
@ -1138,13 +1142,19 @@ static switch_status_t handle_request_fetch_reply(ei_node_t *ei_node, erlang_pid
|
|||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received fetch reply %s for an unknown configuration section: %s : %s\n", uuid_str, section_str, xml_str);
|
||||
switch_safe_free(xml_str);
|
||||
|
||||
return erlang_response_badarg(rbuf);
|
||||
}
|
||||
|
||||
if (result == SWITCH_STATUS_SUCCESS) {
|
||||
switch_safe_free(xml_str);
|
||||
|
||||
return erlang_response_ok(rbuf);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received fetch reply %s is unknown or has expired : %s\n", uuid_str, xml_str);
|
||||
switch_safe_free(xml_str);
|
||||
|
||||
return erlang_response_baduuid(rbuf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,9 +165,11 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
|
|||
}
|
||||
|
||||
if (channel) {
|
||||
const char *disable_flag = switch_channel_get_variable(channel, "disable_radius_start");
|
||||
const char* disable_flag = switch_channel_get_variable(channel, "disable_radius_start");
|
||||
|
||||
if (switch_true(disable_flag)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[mod_radius_cdr] Not Sending RADIUS Start\n");
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -250,6 +252,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (profile->caller_id_number) {
|
||||
if (rc_avpair_add(rad_config, &send, PW_FS_SRC, (void *) profile->caller_id_number, -1, PW_FS_PEC) == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Src: %s\n", profile->caller_id_number);
|
||||
|
@ -257,6 +260,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (profile->caller_id_name) {
|
||||
if (rc_avpair_add(rad_config, &send, PW_FS_CLID, (void *) profile->caller_id_name, -1, PW_FS_PEC) == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-CLID: %s\n", profile->caller_id_name);
|
||||
|
@ -264,6 +268,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (profile->destination_number) {
|
||||
if (rc_avpair_add(rad_config, &send, PW_FS_DST, (void *) profile->destination_number, -1, PW_FS_PEC) == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Dst: %s\n", profile->destination_number);
|
||||
|
@ -271,6 +276,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (profile->dialplan) {
|
||||
if (rc_avpair_add(rad_config, &send, PW_FS_DIALPLAN, (void *) profile->dialplan, -1, PW_FS_PEC) == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Dialplan: %s\n", profile->dialplan);
|
||||
|
@ -278,6 +284,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (profile->network_addr) {
|
||||
inet_pton(AF_INET, (void *) profile->network_addr, &framed_addr);
|
||||
framed_addr = htonl(framed_addr);
|
||||
|
@ -287,6 +294,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (profile->rdnis) {
|
||||
if (rc_avpair_add(rad_config, &send, PW_FS_RDNIS, (void *) profile->rdnis, -1, PW_FS_PEC) == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-RDNIS: %s\n", profile->rdnis);
|
||||
|
@ -294,6 +302,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (profile->context) {
|
||||
if (rc_avpair_add(rad_config, &send, PW_FS_CONTEXT, (void *) profile->context, -1, PW_FS_PEC) == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Context: %s\n", profile->context);
|
||||
|
@ -301,6 +310,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (profile->ani) {
|
||||
if (rc_avpair_add(rad_config, &send, PW_FS_ANI, (void *) profile->ani, -1, PW_FS_PEC) == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-ANI: %s\n", profile->ani);
|
||||
|
@ -308,6 +318,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (profile->aniii) {
|
||||
if (rc_avpair_add(rad_config, &send, PW_FS_ANIII, (void *) profile->aniii, -1, PW_FS_PEC) == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-ANIII: %s\n", profile->aniii);
|
||||
|
@ -315,6 +326,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (profile->source) {
|
||||
if (rc_avpair_add(rad_config, &send, PW_FS_SOURCE, (void *) profile->source, -1, PW_FS_PEC) == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Source: %s\n", profile->source);
|
||||
|
@ -322,6 +334,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (callstartdate > 0) {
|
||||
switch_time_exp_tz(&tm, callstartdate, requested_tm.tm_gmtoff);
|
||||
switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d",
|
||||
|
@ -380,25 +393,33 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
|
|||
}
|
||||
|
||||
if (radius_avpair) {
|
||||
char *radius_avpair_data_tmp = NULL;
|
||||
|
||||
radius_avpair_data = strdup(radius_avpair + (strncmp(radius_avpair, "ARRAY::", 7) ? 0 : 7));
|
||||
radius_avpair_data_tmp = radius_avpair_data;
|
||||
|
||||
do {
|
||||
delim = strstr(radius_avpair_data, "|:");
|
||||
delim = strstr(radius_avpair_data_tmp, "|:");
|
||||
|
||||
if (delim) {
|
||||
*delim = '\0';
|
||||
}
|
||||
|
||||
if (rc_avpair_add(rad_config, &send, PW_FS_AVPAIR, (void *) radius_avpair_data, -1, PW_FS_PEC) == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Freeswitch-AVPair: %s\n", radius_avpair_data);
|
||||
if (rc_avpair_add(rad_config, &send, PW_FS_AVPAIR, (void *)radius_avpair_data_tmp, -1, PW_FS_PEC) == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Freeswitch-AVPair: %s\n", radius_avpair_data_tmp);
|
||||
rc_destroy(rad_config);
|
||||
switch_safe_free(radius_avpair_data);
|
||||
goto end;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "added Freeswitch-AVPair: %s\n", radius_avpair_data);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "added Freeswitch-AVPair: %s\n", radius_avpair_data_tmp);
|
||||
|
||||
if (delim) {
|
||||
radius_avpair_data = delim + 2;
|
||||
radius_avpair_data_tmp = delim + 2;
|
||||
}
|
||||
} while (delim);
|
||||
|
||||
switch_safe_free(radius_avpair_data);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -413,11 +434,13 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
|
|||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "[mod_radius_cdr] RADIUS Accounting Failed\n");
|
||||
retval = SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
rc_avpair_free(send);
|
||||
rc_destroy(rad_config);
|
||||
end:
|
||||
switch_xml_free(cdr);
|
||||
switch_thread_rwlock_unlock(globals.rwlock);
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
|
|
|
@ -4784,19 +4784,23 @@ static void send_console_command(struct rayo_client *client, const char *to, con
|
|||
if (!iks_find_attrib(iq, "type")) {
|
||||
iks_insert_attrib(iq, "type", "set");
|
||||
}
|
||||
|
||||
if (!iks_find_attrib(iq, "id")) {
|
||||
iks_insert_attrib_printf(iq, "id", "console-%i", RAYO_SEQ_NEXT(client));
|
||||
}
|
||||
|
||||
iks_insert_attrib(iq, "from", RAYO_JID(client));
|
||||
|
||||
/* send command */
|
||||
str = iks_string(iks_stack(iq), iq);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nSEND: to %s, %s\n", to, str);
|
||||
iks_free(str);
|
||||
rayo_client_command_recv(client, iq);
|
||||
iks_delete(command);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "bad request xml\n");
|
||||
}
|
||||
|
||||
iks_parser_delete(p);
|
||||
}
|
||||
|
||||
|
|
|
@ -654,6 +654,7 @@ static switch_status_t switch_opusstream_stream_decode(opus_stream_context_t *co
|
|||
}
|
||||
switch_goto_status(SWITCH_STATUS_SUCCESS, end);
|
||||
}
|
||||
break;
|
||||
case OP_EREAD: /*An underlying read operation failed. This may signal a truncation attack from an <https:> source.*/
|
||||
|
||||
case OP_EFAULT: /* An internal memory allocation failed. */
|
||||
|
|
|
@ -189,107 +189,108 @@ SWITCH_STANDARD_APP(java_function)
|
|||
|
||||
static switch_status_t load_config(JavaVMOption **javaOptions, int *optionCount, vm_control_t * vmControl)
|
||||
{
|
||||
switch_xml_t cfg, xml;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_xml_t cfg, xml;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
char *derr = NULL;
|
||||
|
||||
xml = switch_xml_open_cfg("java.conf", &cfg, NULL);
|
||||
if (xml)
|
||||
{
|
||||
switch_xml_t javavm;
|
||||
switch_xml_t options;
|
||||
switch_xml_t startup;
|
||||
switch_xml_t shutdown;
|
||||
xml = switch_xml_open_cfg("java.conf", &cfg, NULL);
|
||||
if (xml) {
|
||||
switch_xml_t javavm;
|
||||
switch_xml_t options;
|
||||
switch_xml_t startup;
|
||||
switch_xml_t shutdown;
|
||||
|
||||
javavm = switch_xml_child(cfg, "javavm");
|
||||
if (javavm != NULL)
|
||||
{
|
||||
const char *path = switch_xml_attr_soft(javavm, "path");
|
||||
if (path != NULL)
|
||||
{
|
||||
javavm = switch_xml_child(cfg, "javavm");
|
||||
if (javavm != NULL) {
|
||||
const char *path = switch_xml_attr_soft(javavm, "path");
|
||||
|
||||
if (path != NULL) {
|
||||
javaVMHandle = switch_dso_open(path, 0, &derr);
|
||||
if (derr || !javaVMHandle) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading %s\n", path);
|
||||
switch_safe_free(derr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM path specified in java.conf.xml\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM specified in java.conf.xml\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto close;
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM path specified in java.conf.xml\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM specified in java.conf.xml\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto close;
|
||||
}
|
||||
|
||||
options = switch_xml_child(cfg, "options");
|
||||
if (options != NULL) {
|
||||
switch_xml_t option;
|
||||
int i = 0;
|
||||
|
||||
*optionCount = 0;
|
||||
|
||||
for (option = switch_xml_child(options, "option"); option; option = option->next) {
|
||||
const char *value = switch_xml_attr_soft(option, "value");
|
||||
|
||||
if (value != NULL) {
|
||||
++*optionCount;
|
||||
}
|
||||
}
|
||||
|
||||
*optionCount += 1;
|
||||
*javaOptions = switch_core_alloc(memoryPool, (switch_size_t)(*optionCount * sizeof(JavaVMOption)));
|
||||
if (*javaOptions == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto close;
|
||||
}
|
||||
|
||||
for (option = switch_xml_child(options, "option"); option; option = option->next) {
|
||||
const char *value = switch_xml_attr_soft(option, "value");
|
||||
|
||||
if (value == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
(*javaOptions)[i].optionString = switch_core_strdup(memoryPool, value);
|
||||
if ((*javaOptions)[i].optionString == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto close;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
options = switch_xml_child(cfg, "options");
|
||||
if (options != NULL)
|
||||
{
|
||||
switch_xml_t option;
|
||||
int i = 0;
|
||||
*optionCount = 0;
|
||||
for (option = switch_xml_child(options, "option"); option; option = option->next)
|
||||
{
|
||||
const char *value = switch_xml_attr_soft(option, "value");
|
||||
if (value != NULL)
|
||||
++*optionCount;
|
||||
}
|
||||
*optionCount += 1;
|
||||
*javaOptions = switch_core_alloc(memoryPool, (switch_size_t)(*optionCount * sizeof(JavaVMOption)));
|
||||
if (*javaOptions == NULL)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto close;
|
||||
}
|
||||
for (option = switch_xml_child(options, "option"); option; option = option->next)
|
||||
{
|
||||
const char *value = switch_xml_attr_soft(option, "value");
|
||||
if (value == NULL)
|
||||
continue;
|
||||
(*javaOptions)[i].optionString = switch_core_strdup(memoryPool, value);
|
||||
if ((*javaOptions)[i].optionString == NULL)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto close;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
(*javaOptions)[i].optionString = switch_core_sprintf(memoryPool, "-Djava.library.path=%s", SWITCH_GLOBAL_dirs.mod_dir);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
<startup class="net/cog/fs/system/Control" method="startup" arg="start up arg"/>
|
||||
<shutdown class="net/cog/fs/system/Control" method="shutdown" arg="shutdown arg"/>
|
||||
*/
|
||||
/*
|
||||
<startup class="net/cog/fs/system/Control" method="startup" arg="start up arg"/>
|
||||
<shutdown class="net/cog/fs/system/Control" method="shutdown" arg="shutdown arg"/>
|
||||
*/
|
||||
|
||||
memset(vmControl, 0, sizeof(struct vm_control));
|
||||
startup = switch_xml_child(cfg, "startup");
|
||||
if (startup != NULL) {
|
||||
vmControl->startup.class = switch_xml_attr_soft(startup, "class");
|
||||
vmControl->startup.method = switch_xml_attr_soft(startup, "method");
|
||||
vmControl->startup.arg = switch_xml_attr_soft(startup, "arg");
|
||||
}
|
||||
shutdown = switch_xml_child(cfg, "shutdown");
|
||||
if (shutdown != NULL) {
|
||||
vmControl->shutdown.class = switch_xml_attr_soft(shutdown, "class");
|
||||
vmControl->shutdown.method = switch_xml_attr_soft(shutdown, "method");
|
||||
vmControl->shutdown.arg = switch_xml_attr_soft(shutdown, "arg");
|
||||
}
|
||||
memset(vmControl, 0, sizeof(struct vm_control));
|
||||
startup = switch_xml_child(cfg, "startup");
|
||||
if (startup != NULL) {
|
||||
vmControl->startup.class = switch_xml_attr_soft(startup, "class");
|
||||
vmControl->startup.method = switch_xml_attr_soft(startup, "method");
|
||||
vmControl->startup.arg = switch_xml_attr_soft(startup, "arg");
|
||||
}
|
||||
|
||||
close:
|
||||
switch_xml_free(xml);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening java.conf.xml\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
return status;
|
||||
shutdown = switch_xml_child(cfg, "shutdown");
|
||||
if (shutdown != NULL) {
|
||||
vmControl->shutdown.class = switch_xml_attr_soft(shutdown, "class");
|
||||
vmControl->shutdown.method = switch_xml_attr_soft(shutdown, "method");
|
||||
vmControl->shutdown.arg = switch_xml_attr_soft(shutdown, "arg");
|
||||
}
|
||||
|
||||
close:
|
||||
switch_xml_free(xml);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening java.conf.xml\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static switch_status_t create_java_vm(JavaVMOption *options, int optionCount, vm_control_t * vmControl)
|
||||
|
|
|
@ -169,6 +169,7 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLHash)
|
|||
} else {
|
||||
/* The var exists, but is wrong type - exit with error */
|
||||
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Second argument is the name of an existing var of the wrong type"));
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (info.Length() > 1 && info[1]->IsArray()) {
|
||||
|
@ -177,6 +178,7 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLHash)
|
|||
} else if (info.Length() > 1) {
|
||||
/* The var exists, but is wrong type - exit with error */
|
||||
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Second argument is of the wrong type"));
|
||||
|
||||
return;
|
||||
} else {
|
||||
/* Second argument doesn't exist, this is also ok. The hash will be returned as the result */
|
||||
|
@ -185,6 +187,11 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLHash)
|
|||
}
|
||||
|
||||
curl_handle = switch_curl_easy_init();
|
||||
if (!curl_handle) {
|
||||
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Failed to initiate curl easy session."));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strncasecmp(js_safe_str(*url), "https", 5)) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
|
@ -224,14 +231,22 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLFile)
|
|||
const char *url = NULL, *filename = NULL;
|
||||
String::Utf8Value str1(info[0]);
|
||||
String::Utf8Value str2(info[1]);
|
||||
|
||||
url = js_safe_str(*str1);
|
||||
filename = js_safe_str(*str2);
|
||||
|
||||
curl_handle = switch_curl_easy_init();
|
||||
if (!curl_handle) {
|
||||
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Failed to initiate curl easy session."));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strncasecmp(url, "https", 5)) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
}
|
||||
|
||||
config_data.isolate = info.GetIsolate();
|
||||
|
||||
if ((config_data.fileHandle = open(filename, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
|
||||
|
@ -245,13 +260,14 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLFile)
|
|||
|
||||
switch_curl_easy_perform(curl_handle);
|
||||
|
||||
switch_curl_easy_cleanup(curl_handle);
|
||||
close(config_data.fileHandle);
|
||||
info.GetReturnValue().Set(true);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open file [%s]\n", filename);
|
||||
info.GetReturnValue().Set(false);
|
||||
}
|
||||
|
||||
switch_curl_easy_cleanup(curl_handle);
|
||||
} else {
|
||||
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Invalid arguments"));
|
||||
}
|
||||
|
@ -270,12 +286,19 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURL)
|
|||
if (info.Length() >= 1) {
|
||||
const char *url;
|
||||
String::Utf8Value str(info[0]);
|
||||
|
||||
url = js_safe_str(*str);
|
||||
if (info.Length() > 1) {
|
||||
buffer_size = info[1]->Int32Value();
|
||||
}
|
||||
|
||||
curl_handle = switch_curl_easy_init();
|
||||
if (!curl_handle) {
|
||||
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Failed to initiate curl easy session."));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strncasecmp(url, "https", 5)) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
|
@ -289,6 +312,7 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURL)
|
|||
if (config_data.buffer == NULL) {
|
||||
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Failed to allocate data buffer."));
|
||||
switch_curl_easy_cleanup(curl_handle);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ static void check_ip(void)
|
|||
} else if (strcmp(hostname, runtime.hostname)) {
|
||||
if (switch_event_create(&event, SWITCH_EVENT_TRAP) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "condition", "hostname-change");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "old-hostname", hostname ? hostname : "nil");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "old-hostname", hostname);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "new-hostname", runtime.hostname);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
|
|
@ -160,8 +160,6 @@ SWITCH_DECLARE(switch_status_t) switch_packetizer_feed_extradata(switch_packetiz
|
|||
p += 5;
|
||||
left -= 5;
|
||||
|
||||
if (left < 0) return SWITCH_STATUS_FALSE;
|
||||
|
||||
//sps
|
||||
n_sps = *p & 0x1f;
|
||||
p += 1;
|
||||
|
|
|
@ -1353,7 +1353,6 @@ SWITCH_DECLARE(void) switch_srtp_err_to_txt(srtp_err_status_t stat, char **msg)
|
|||
else if (stat == srtp_err_status_read_fail) *msg="couldn't read data";
|
||||
else if (stat == srtp_err_status_write_fail) *msg="couldn't write data";
|
||||
else if (stat == srtp_err_status_parse_err) *msg="error parsing data";
|
||||
else if (stat == srtp_err_status_write_fail) *msg="couldn't read data";
|
||||
else if (stat == srtp_err_status_encode_err) *msg="error encoding data";
|
||||
else if (stat == srtp_err_status_semaphore_err) *msg="error while using semaphores";
|
||||
else if (stat == srtp_err_status_pfkey_err) *msg="error while using pfkey ";
|
||||
|
@ -4947,7 +4946,7 @@ SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp_t *rtp_session)
|
|||
}
|
||||
|
||||
if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) {
|
||||
if (rtp_session->rtcp_sock_input && rtp_session->rtcp_sock_input != rtp_session->sock_input) {
|
||||
if (rtp_session->sock_input && rtp_session->rtcp_sock_input && rtp_session->rtcp_sock_input != rtp_session->sock_input) {
|
||||
ping_socket(rtp_session);
|
||||
switch_socket_shutdown(rtp_session->rtcp_sock_input, SWITCH_SHUTDOWN_READWRITE);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue