Merge branch 'master' into smgmaster

Conflicts:
	src/switch_core_sqldb.c
This commit is contained in:
Moises Silva committed 2010-09-17 18:55:11 -04:00
commit a94590bbc7
57 files changed
+5183 -711

No files matched your search

+2
View File
@@ -233,6 +233,8 @@ struct switch_runtime {
switch_profile_timer_t *profile_timer;
double profile_time;
double min_idle_time;
int sql_buffer_len;
int max_sql_buffer_len;
};
extern struct switch_runtime runtime;
+1 -1
View File
@@ -38,7 +38,7 @@
/**
* @defgroup config Config File Parser
* @ingroup core1
* This module implements a basic interface and file format parser it may be depricated in favor of database entries
* This module implements a basic interface and file format parser it may be deprecated in favor of database entries
* or expanded to tie to external handlers in the future as necessary.
* <pre>
*
+1 -1
View File
@@ -92,7 +92,7 @@ SWITCH_BEGIN_EXTERN_C
\brief Initilize the module backend and load all the modules
\return SWITCH_STATUS_SUCCESS when complete
*/
SWITCH_DECLARE(switch_status_t) switch_loadable_module_init(void);
SWITCH_DECLARE(switch_status_t) switch_loadable_module_init(switch_bool_t autoload);
/*!
\brief Shutdown the module backend and call the shutdown routine in all loaded modules
+9 -1
View File
@@ -255,7 +255,8 @@ typedef enum {
SCF_USE_CLOCK_RT = (1 << 10),
SCF_VERBOSE_EVENTS = (1 << 11),
SCF_USE_WIN32_MONOTONIC = (1 << 12),
SCF_AUTO_SCHEMAS = (1 << 13)
SCF_AUTO_SCHEMAS = (1 << 13),
SCF_MINIMAL = (1 << 14)
} switch_core_flag_enum_t;
typedef uint32_t switch_core_flag_t;
@@ -479,9 +480,16 @@ typedef struct {
switch_size_t flush_packet_count;
} switch_rtp_numbers_t;
typedef struct {
uint32_t packet_count;
uint32_t octet_count;
} switch_rtcp_numbers_t;
typedef struct {
switch_rtp_numbers_t inbound;
switch_rtp_numbers_t outbound;
switch_rtcp_numbers_t rtcp;
} switch_rtp_stats_t;
typedef enum {
+8
View File
@@ -680,7 +680,15 @@ SWITCH_DECLARE(switch_bool_t) switch_network_list_validate_ip_token(switch_netwo
SWITCH_DECLARE(int) switch_inet_pton(int af, const char *src, void *dst);
SWITCH_DECLARE(const char *) switch_dow_int2str(int val);
SWITCH_DECLARE(int) switch_dow_str2int(const char *exp);
SWITCH_DECLARE(int) switch_dow_cmp(const char *exp, int val);
SWITCH_DECLARE(int) switch_number_cmp(const char *exp, int val);
SWITCH_DECLARE(int) switch_tod_cmp(const char *exp, int val);
SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts);
SWITCH_DECLARE(void) switch_split_date(const char *exp, int *year, int *month, int *day);
SWITCH_DECLARE(void) switch_split_time(const char *exp, int *hour, int *min, int *sec);
/*!
\brief Split a user@domain string as user and domain
+1
View File
@@ -331,6 +331,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(_In_ uint8_t reload, _Out_ con
///\return SWITCH_STATUS_SUCCESS if successful
SWITCH_DECLARE(switch_status_t) switch_xml_init(_In_ switch_memory_pool_t *pool, _Out_ const char **err);
SWITCH_DECLARE(switch_status_t) switch_xml_reload(const char **err);
SWITCH_DECLARE(switch_status_t) switch_xml_destroy(void);
@@ -1259,7 +1259,7 @@ static switch_status_t load_config(void)
if (!strcasecmp(var, "debug")) {
globals.debug = atoi(val);
} else if (!strcasecmp(var, "odbc-dsn")) {
globals.odbc_dsn = strdup(switch_xml_attr(param, "odbc-dsn"));
globals.odbc_dsn = strdup(val);
if (!zstr(globals.odbc_dsn)) {
if ((globals.odbc_user = strchr(globals.odbc_dsn, ':'))) {
@@ -605,11 +605,12 @@ SWITCH_STANDARD_API(in_group_function)
SWITCH_STANDARD_API(user_data_function)
{
switch_xml_t x_domain, xml = NULL, x_user = NULL, x_param, x_params;
switch_xml_t x_domain, xml = NULL, x_user = NULL, x_group = NULL, x_param, x_params;
int argc;
char *mydata = NULL, *argv[3], *key = NULL, *type = NULL, *user, *domain;
char delim = ' ';
const char *container = "params", *elem = "param";
const char *result = NULL;
switch_event_t *params = NULL;
if (zstr(cmd) || !(mydata = strdup(cmd))) {
@@ -637,10 +638,10 @@ SWITCH_STANDARD_API(user_data_function)
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "domain", domain);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "type", type);
if (key && type && switch_xml_locate_user("id", user, domain, NULL, &xml, &x_domain, &x_user, NULL, params) == SWITCH_STATUS_SUCCESS) {
if (key && type && switch_xml_locate_user("id", user, domain, NULL, &xml, &x_domain, &x_user, &x_group, params) == SWITCH_STATUS_SUCCESS) {
if (!strcmp(type, "attr")) {
const char *attr = switch_xml_attr_soft(x_user, key);
stream->write_function(stream, "%s", attr);
result = attr;
goto end;
}
@@ -649,33 +650,45 @@ SWITCH_STANDARD_API(user_data_function)
elem = "variable";
}
if ((x_params = switch_xml_child(x_user, container))) {
for (x_param = switch_xml_child(x_params, elem); x_param; x_param = x_param->next) {
const char *var = switch_xml_attr(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
if (var && val && !strcasecmp(var, key)) {
stream->write_function(stream, "%s", val);
goto end;
}
}
}
if ((x_params = switch_xml_child(x_domain, container))) {
for (x_param = switch_xml_child(x_params, elem); x_param; x_param = x_param->next) {
const char *var = switch_xml_attr(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
if (var && val && !strcasecmp(var, key)) {
stream->write_function(stream, "%s", val);
goto end;
result = val;
}
}
}
if (x_group && (x_params = switch_xml_child(x_group, container))) {
for (x_param = switch_xml_child(x_params, elem); x_param; x_param = x_param->next) {
const char *var = switch_xml_attr(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
if (var && val && !strcasecmp(var, key)) {
result = val;
}
}
}
if ((x_params = switch_xml_child(x_user, container))) {
for (x_param = switch_xml_child(x_params, elem); x_param; x_param = x_param->next) {
const char *var = switch_xml_attr(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
if (var && val && !strcasecmp(var, key)) {
result = val;
}
}
}
}
end:
if (result) {
stream->write_function(stream, "%s", result);
}
switch_xml_free(xml);
switch_safe_free(mydata);
switch_event_destroy(&params);
@@ -1166,17 +1179,18 @@ SWITCH_STANDARD_API(xml_locate_function)
SWITCH_STANDARD_API(reload_acl_function)
{
const char *err;
switch_xml_t xml_root;
if (cmd && !strcmp(cmd, "reloadxml")) {
if ((xml_root = switch_xml_open_root(1, &err))) {
switch_xml_free(xml_root);
}
if (cmd && !strcasecmp(cmd, "reloadxml")) {
stream->write_function(stream, "This option is deprecated, we now always reloadxml.\n");
}
if (switch_xml_reload(&err) == SWITCH_STATUS_SUCCESS) {
switch_load_network_lists(SWITCH_TRUE);
stream->write_function(stream, "+OK acl reloaded\n");
} else {
stream->write_function(stream, "-Error [%s]\n", err);
}
switch_load_network_lists(SWITCH_TRUE);
stream->write_function(stream, "+OK acl reloaded\n");
return SWITCH_STATUS_SUCCESS;
}
@@ -1374,7 +1388,7 @@ SWITCH_STANDARD_API(cond_function)
argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0])));
if (argc != 3) {
if (! (argc >= 2 && argc <= 3)) {
goto error;
}
@@ -1451,7 +1465,12 @@ SWITCH_STANDARD_API(cond_function)
}
switch_safe_free(s_a);
switch_safe_free(s_b);
stream->write_function(stream, "%s", is_true ? argv[1] : argv[2]);
if ((argc == 2 && !is_true)) {
stream->write_function(stream, "");
} else {
stream->write_function(stream, "%s", is_true ? argv[1] : argv[2]);
}
goto ok;
}
@@ -1720,6 +1739,10 @@ SWITCH_STANDARD_API(load_function)
return SWITCH_STATUS_SUCCESS;
}
if (switch_xml_reload(&err) == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "+OK Reloading XML\n");
}
if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) cmd, SWITCH_TRUE, &err) == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "+OK\n");
} else {
@@ -1814,6 +1837,10 @@ SWITCH_STANDARD_API(reload_function)
stream->write_function(stream, "-ERR unloading module [%s]\n", err);
}
if (switch_xml_reload(&err) == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "+OK Reloading XML\n");
}
if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) cmd, SWITCH_TRUE, &err) == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "+OK module loaded\n");
} else {
@@ -1825,13 +1852,9 @@ SWITCH_STANDARD_API(reload_function)
SWITCH_STANDARD_API(reload_xml_function)
{
const char *err;
switch_xml_t xml_root;
if ((xml_root = switch_xml_open_root(1, &err))) {
switch_xml_free(xml_root);
}
const char *err = "";
switch_xml_reload(&err);
stream->write_function(stream, "+OK [%s]\n", err);
return SWITCH_STATUS_SUCCESS;
@@ -4551,7 +4574,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
SWITCH_ADD_API(commands_api_interface, "originate", "Originate a Call", originate_function, ORIGINATE_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "pause", "Pause", pause_function, PAUSE_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "regex", "Eval a regex", regex_function, "<data>|<pattern>[|<subst string>]");
SWITCH_ADD_API(commands_api_interface, "reloadacl", "Reload ACL", reload_acl_function, "[reloadxml]");
SWITCH_ADD_API(commands_api_interface, "reloadacl", "Reload ACL", reload_acl_function, "");
SWITCH_ADD_API(commands_api_interface, "reload", "Reload Module", reload_function, UNLOAD_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "reloadxml", "Reload XML", reload_xml_function, "");
SWITCH_ADD_API(commands_api_interface, "replace", "replace a string", replace_function, "<data>|<string1>|<string2>");
@@ -99,7 +99,7 @@ typedef enum {
CALLER_CONTROL_DEAF_MUTE,
CALLER_CONTROL_ENERGY_UP,
CALLER_CONTROL_ENERGY_EQU_CONF,
CALLER_CONTROL_ENERGEY_DN,
CALLER_CONTROL_ENERGY_DN,
CALLER_CONTROL_VOL_TALK_UP,
CALLER_CONTROL_VOL_TALK_ZERO,
CALLER_CONTROL_VOL_TALK_DN,
@@ -121,7 +121,7 @@ typedef struct conference_member conference_member_t;
struct call_list {
char *string;
int itteration;
int iteration;
struct call_list *next;
};
typedef struct call_list call_list_t;
@@ -717,7 +717,7 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe
if (call_list) {
char saymsg[1024];
switch_snprintf(saymsg, sizeof(saymsg), "Auto Calling %d parties", call_list->itteration);
switch_snprintf(saymsg, sizeof(saymsg), "Auto Calling %d parties", call_list->iteration);
conference_member_say(member, saymsg, 0);
} else {
if (zstr(conference->special_announce)) {
@@ -2298,7 +2298,7 @@ static caller_control_fn_table_t ccfntbl[] = {
{"deaf mute", "*", CALLER_CONTROL_DEAF_MUTE, conference_loop_fn_deafmute_toggle},
{"energy up", "9", CALLER_CONTROL_ENERGY_UP, conference_loop_fn_energy_up},
{"energy equ", "8", CALLER_CONTROL_ENERGY_EQU_CONF, conference_loop_fn_energy_equ_conf},
{"energy dn", "7", CALLER_CONTROL_ENERGEY_DN, conference_loop_fn_energy_dn},
{"energy dn", "7", CALLER_CONTROL_ENERGY_DN, conference_loop_fn_energy_dn},
{"vol talk up", "3", CALLER_CONTROL_VOL_TALK_UP, conference_loop_fn_volume_talk_up},
{"vol talk zero", "2", CALLER_CONTROL_VOL_TALK_ZERO, conference_loop_fn_volume_talk_zero},
{"vol talk dn", "1", CALLER_CONTROL_VOL_TALK_DN, conference_loop_fn_volume_talk_dn},
@@ -5199,9 +5199,9 @@ SWITCH_STANDARD_APP(conference_auto_function)
np->string = switch_core_session_strdup(session, data);
if (call_list) {
np->next = call_list;
np->itteration = call_list->itteration + 1;
np->iteration = call_list->iteration + 1;
} else {
np->itteration = 1;
np->iteration = 1;
}
call_list = np;
}
@@ -884,6 +884,18 @@ SWITCH_STANDARD_APP(directory_function)
if (strcasecmp(profile->search_order, "last_name")) {
s_param.search_by_last_name = 0;
}
{
const char *var_search_order = switch_channel_get_variable(channel, "directory_search_order");
if (var_search_order) {
if (!strcasecmp(var_search_order, "first_name")) {
s_param.search_by_last_name = 0;
} else {
s_param.search_by_last_name = 1;
}
}
}
attempts = profile->max_menu_attempt;
s_param.try_again = 1;
while (switch_channel_ready(channel) && (s_param.try_again && attempts-- > 0)) {
-1
View File
@@ -1571,7 +1571,6 @@ SWITCH_STANDARD_APP(lcr_app_function)
switch_channel_set_variable(channel, vbuf, cur_route->carrier_name);
switch_snprintf(vbuf, sizeof(vbuf), "lcr_codec_%d", cnt);
switch_channel_set_variable(channel, vbuf, cur_route->codec);
cnt++;
if (cur_route->next) {
if (routes.profile->enable_sip_redir) {
dig_stream.write_function(&dig_stream, "%s,", cur_route->dialstring);
@@ -74,6 +74,8 @@ static struct {
char header[50];
char *prepend_string;
char *spool;
switch_thread_cond_t *cond;
switch_mutex_t *cond_mutex;
} globals;
struct pvt_s {
@@ -121,24 +123,16 @@ static struct {
static int add_pvt(pvt_t *pvt)
{
int r = 0;
uint32_t sanity = 50;
switch_mutex_lock(t38_state_list.mutex);
if (!t38_state_list.thread_running) {
launch_timer_thread();
while(--sanity && !t38_state_list.thread_running) {
switch_yield(10000);
}
}
switch_mutex_unlock(t38_state_list.mutex);
if (t38_state_list.thread_running) {
switch_mutex_lock(t38_state_list.mutex);
pvt->next = t38_state_list.head;
t38_state_list.head = pvt;
switch_mutex_unlock(t38_state_list.mutex);
r = 1;
switch_thread_cond_broadcast(globals.cond);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error launching thread\n");
}
return r;
@@ -151,9 +145,9 @@ static int del_pvt(pvt_t *del_pvt)
pvt_t *p, *l = NULL;
int r = 0;
if (!t38_state_list.thread_running) goto end;
switch_mutex_lock(t38_state_list.mutex);
for (p = t38_state_list.head; p; p = p->next) {
if (p == del_pvt) {
if (l) {
@@ -163,42 +157,48 @@ static int del_pvt(pvt_t *del_pvt)
}
p->next = NULL;
r = 1;
goto end;
break;
}
l = p;
}
end:
switch_mutex_unlock(t38_state_list.mutex);
return r;
switch_thread_cond_broadcast(globals.cond);
return r;
}
static void *SWITCH_THREAD_FUNC timer_thread_run(switch_thread_t *thread, void *obj)
{
switch_timer_t timer = { 0 };
pvt_t *pvt;
int samples = 240;
int ms = 30;
int samples = 160;
int ms = 20;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "timer thread started.\n");
switch_mutex_lock(t38_state_list.mutex);
t38_state_list.thread_running = 1;
switch_mutex_unlock(t38_state_list.mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FAX timer thread started.\n");
if (switch_core_timer_init(&timer, "soft", ms, samples, NULL) != SWITCH_STATUS_SUCCESS) {
return NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "timer init failed.\n");
goto end;
}
t38_state_list.thread_running = 1;
while(t38_state_list.thread_running) {
switch_mutex_lock(globals.cond_mutex);
switch_mutex_lock(t38_state_list.mutex);
if (!t38_state_list.head) {
switch_mutex_unlock(t38_state_list.mutex);
goto end;
switch_thread_cond_wait(globals.cond, globals.cond_mutex);
switch_core_timer_sync(&timer);
continue;
}
for (pvt = t38_state_list.head; pvt; pvt = pvt->next) {
@@ -214,10 +214,15 @@ static void *SWITCH_THREAD_FUNC timer_thread_run(switch_thread_t *thread, void *
end:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "timer thread ended.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FAX timer thread ended.\n");
switch_mutex_lock(t38_state_list.mutex);
t38_state_list.thread_running = 0;
switch_core_timer_destroy(&timer);
switch_mutex_unlock(t38_state_list.mutex);
if (timer.timer_interface) {
switch_core_timer_destroy(&timer);
}
return NULL;
}
@@ -468,49 +473,61 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
}
break;
case T38_MODE:
if (pvt->t38_state == NULL) {
pvt->t38_state = (t38_terminal_state_t *) switch_core_session_alloc(pvt->session, sizeof(t38_terminal_state_t));
}
if (pvt->t38_state == NULL) {
return SWITCH_STATUS_FALSE;
}
if (pvt->udptl_state == NULL) {
pvt->udptl_state = (udptl_state_t *) switch_core_session_alloc(pvt->session, sizeof(udptl_state_t));
}
if (pvt->udptl_state == NULL) {
t38_terminal_free(pvt->t38_state);
pvt->t38_state = NULL;
return SWITCH_STATUS_FALSE;
}
{
switch_core_session_message_t msg = { 0 };
/* add to timer thread processing */
add_pvt(pvt);
if (pvt->t38_state == NULL) {
pvt->t38_state = (t38_terminal_state_t *) switch_core_session_alloc(pvt->session, sizeof(t38_terminal_state_t));
}
if (pvt->t38_state == NULL) {
return SWITCH_STATUS_FALSE;
}
if (pvt->udptl_state == NULL) {
pvt->udptl_state = (udptl_state_t *) switch_core_session_alloc(pvt->session, sizeof(udptl_state_t));
}
if (pvt->udptl_state == NULL) {
t38_terminal_free(pvt->t38_state);
pvt->t38_state = NULL;
return SWITCH_STATUS_FALSE;
}
t38 = pvt->t38_state;
t30 = t38_terminal_get_t30_state(t38);
memset(t38, 0, sizeof(t38_terminal_state_t));
if (t38_terminal_init(t38, pvt->caller, t38_tx_packet_handler, pvt) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my T.38 structs\n");
return SWITCH_STATUS_FALSE;
}
pvt->t38_core = t38_terminal_get_t38_core_state(pvt->t38_state);
if (udptl_init(pvt->udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY, 3, 3,
(udptl_rx_packet_handler_t *) t38_core_rx_ifp_packet, (void *) pvt->t38_core) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my UDPTL structs\n");
return SWITCH_STATUS_FALSE;
}
msg.from = __FILE__;
msg.message_id = SWITCH_MESSAGE_INDICATE_UDPTL_MODE;
switch_core_session_receive_message(pvt->session, &msg);
t38 = pvt->t38_state;
t30 = t38_terminal_get_t30_state(t38);
/* add to timer thread processing */
if (!add_pvt(pvt)) {
if (channel) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
}
span_log_set_message_handler(&t38->logging, spanfax_log_message);
span_log_set_message_handler(&t30->logging, spanfax_log_message);
memset(t38, 0, sizeof(t38_terminal_state_t));
if (t38_terminal_init(t38, pvt->caller, t38_tx_packet_handler, pvt) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my T.38 structs\n");
return SWITCH_STATUS_FALSE;
}
pvt->t38_core = t38_terminal_get_t38_core_state(pvt->t38_state);
if (udptl_init(pvt->udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY, 3, 3,
(udptl_rx_packet_handler_t *) t38_core_rx_ifp_packet, (void *) pvt->t38_core) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize my UDPTL structs\n");
return SWITCH_STATUS_FALSE;
}
span_log_set_message_handler(&t38->logging, spanfax_log_message);
span_log_set_message_handler(&t30->logging, spanfax_log_message);
if (pvt->verbose) {
span_log_set_level(&t38->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
span_log_set_level(&t30->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
}
if (pvt->verbose) {
span_log_set_level(&t38->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
span_log_set_level(&t30->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
}
}
break;
case T38_GATEWAY_MODE:
if (pvt->t38_gateway_state == NULL) {
@@ -1145,8 +1162,6 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat
//switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "READ %d udptl bytes\n", read_frame->packetlen);
udptl_rx_packet(pvt->udptl_state, read_frame->packet, read_frame->packetlen);
}
}
continue;
@@ -1282,6 +1297,8 @@ void mod_spandsp_fax_event_handler(switch_event_t *event)
void mod_spandsp_fax_load(switch_memory_pool_t *pool)
{
uint32_t sanity = 200;
memset(&globals, 0, sizeof(globals));
memset(&t38_state_list, 0, sizeof(t38_state_list));
@@ -1289,6 +1306,9 @@ void mod_spandsp_fax_load(switch_memory_pool_t *pool)
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
switch_mutex_init(&t38_state_list.mutex, SWITCH_MUTEX_NESTED, globals.pool);
switch_mutex_init(&globals.cond_mutex, SWITCH_MUTEX_NESTED, globals.pool);
switch_thread_cond_create(&globals.cond, globals.pool);
globals.enable_t38 = 1;
globals.total_sessions = 0;
@@ -1301,10 +1321,22 @@ void mod_spandsp_fax_load(switch_memory_pool_t *pool)
strncpy(globals.header, "SpanDSP Fax Header", sizeof(globals.header) - 1);
load_configuration(0);
launch_timer_thread();
while(--sanity && !t38_state_list.thread_running) {
switch_yield(20000);
}
}
void mod_spandsp_fax_shutdown(void)
{
switch_status_t tstatus = SWITCH_STATUS_SUCCESS;
t38_state_list.thread_running = 0;
switch_thread_cond_broadcast(globals.cond);
switch_thread_join(&tstatus, t38_state_list.thread);
memset(&globals, 0, sizeof(globals));
}
@@ -1659,8 +1691,8 @@ static switch_status_t t38_gateway_on_reset(switch_core_session_t *session)
switch_channel_clear_flag(channel, CF_REDIRECT);
if (switch_channel_test_app_flag(channel, CF_APP_TAGGED)) {
switch_channel_clear_app_flag(channel, CF_APP_TAGGED);
if (switch_channel_test_app_flag_key("T38", channel, CF_APP_TAGGED)) {
switch_channel_clear_app_flag_key("T38", channel, CF_APP_TAGGED);
switch_channel_set_state(channel, CS_CONSUME_MEDIA);
} else {
switch_channel_set_state(channel, CS_SOFT_EXECUTE);
@@ -1697,6 +1729,9 @@ switch_bool_t t38_gateway_start(switch_core_session_t *session, const char *app,
switch_channel_set_variable(channel, "t38_peer", switch_core_session_get_uuid(other_session));
switch_channel_set_variable(other_channel, "t38_peer", switch_core_session_get_uuid(session));
switch_channel_set_variable(peer ? other_channel : channel, "t38_gateway_format", "audio");
switch_channel_set_variable(peer ? channel : other_channel, "t38_gateway_format", "udptl");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s starting gateway mode to %s\n",
switch_channel_get_name(peer ? channel : other_channel),
@@ -1709,8 +1744,8 @@ switch_bool_t t38_gateway_start(switch_core_session_t *session, const char *app,
switch_channel_add_state_handler(channel, &t38_gateway_state_handlers);
switch_channel_add_state_handler(other_channel, &t38_gateway_state_handlers);
switch_channel_set_app_flag(peer ? channel : other_channel, CF_APP_TAGGED);
switch_channel_clear_app_flag(peer ? other_channel : channel, CF_APP_TAGGED);
switch_channel_set_app_flag_key("T38", peer ? channel : other_channel, CF_APP_TAGGED);
switch_channel_clear_app_flag_key("T38", peer ? other_channel : channel, CF_APP_TAGGED);
switch_channel_set_flag(channel, CF_REDIRECT);
switch_channel_set_state(channel, CS_RESET);
@@ -824,7 +824,8 @@ static switch_status_t control_playback(switch_core_session_t *session, void *in
if (!cc->noexit
&& (dtmf->digit == *cc->profile->delete_file_key || dtmf->digit == *cc->profile->save_file_key
|| dtmf->digit == *cc->profile->prev_msg_key || dtmf->digit == *cc->profile->next_msg_key
|| dtmf->digit == *cc->profile->terminator_key || dtmf->digit == *cc->profile->skip_info_key)) {
|| dtmf->digit == *cc->profile->terminator_key || dtmf->digit == *cc->profile->skip_info_key
|| dtmf->digit == *cc->profile->email_key || dtmf->digit == *cc->profile->forward_key)) {
*cc->buf = dtmf->digit;
return SWITCH_STATUS_BREAK;
}
@@ -2686,23 +2687,29 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
if ((domain = strchr(user, '@'))) {
*domain++ = '\0';
} else {
domain = user;
}
if ((profile_name = strchr(domain, '@'))) {
*profile_name++ = '\0';
} else {
profile_name = domain;
if ((profile_name = strchr(domain, '@'))) {
*profile_name++ = '\0';
} else {
profile_name = domain;
}
}
if (switch_stristr("group=", user)) {
user += 6;
isgroup++;
} else if (user == domain) {
} else if (switch_stristr("domain=", user)) {
user += 7;
domain = user;
profile_name = domain;
isall++;
}
if (zstr(domain)) {
domain = switch_core_get_variable("domain");
profile_name = domain;
}
if (!(user && domain)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid syntax [%s][%s]\n", switch_str_nil(user), switch_str_nil(domain));
status = SWITCH_STATUS_FALSE;
@@ -2746,6 +2753,7 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate domain %s\n", domain);
status = SWITCH_STATUS_FALSE;
switch_event_destroy(&my_params);
profile_rwunlock(profile);
goto end;
}
@@ -3164,7 +3172,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
switch_event_destroy(&vars);
if (status == SWITCH_STATUS_SUCCESS) {
if ((vm_cc = switch_channel_get_variable(channel, "vm_cc"))) {
char *cmd = switch_core_session_sprintf(session, "%s %s %s %s %s@%s %s",
char *cmd = switch_core_session_sprintf(session, "%s %s %s '%s' %s@%s %s",
vm_cc, file_path, caller_id_number, caller_id_name, id, domain_name, read_flags);
if (voicemail_inject(cmd, session) == SWITCH_STATUS_SUCCESS) {
@@ -3961,7 +3969,7 @@ static void do_web(vm_profile_t *profile, const char *user_in, const char *domai
}
}
#define VM_INJECT_USAGE "[group=]<box> <sound_file> [<cid_num>] [<cid_name>]"
#define VM_INJECT_USAGE "[group=<group>[@domain]|domain=<domain>|<box>[@<domain>]] <sound_file> [<cid_num>] [<cid_name>]"
SWITCH_STANDARD_API(voicemail_inject_api_function)
{
if (voicemail_inject(cmd, session) == SWITCH_STATUS_SUCCESS) {
+1
View File
@@ -1,3 +1,4 @@
fix crashes on FSH323Connection calls in on_hangup routine in different threads.
move PTrace level set to FSH323EndPoint::Initialise
partially apply patch from from Peter Olsson, Remove UnLock() when TryLock() failed and DEBUG_RTP_PACKETS directive.
apply changes from mod_h323-patch.diff by Peter Olsson.
+19 -5
View File
@@ -24,7 +24,7 @@
*
* mod_h323.cpp -- H323 endpoint
*
* Version 0.0.55
* Version 0.0.56
*/
//#define DEBUG_RTP_PACKETS
@@ -747,6 +747,17 @@ FSH323Connection::~FSH323Connection()
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
}
void FSH323Connection::AttachSignalChannel(const PString & token,
H323Transport * channel,
PBoolean answeringCall)
{
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
tech_pvt->token = strdup((const char *)token);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"---------->token = %s [%p]\n",(const char *)token,this);
H323Connection::AttachSignalChannel(token,channel,answeringCall);
}
void FSH323Connection::OnSetLocalCapabilities()
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnSetLocalCapabilities() [%p]\n",this);
@@ -2321,8 +2332,9 @@ static switch_status_t on_hangup(switch_core_session_t *session)
switch_channel_t *channel = switch_core_session_get_channel(session);
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(session);
FSH323Connection *me = tech_pvt->me;
FSH323EndPoint & ep = h323_process->GetH323EndPoint();
tech_pvt->me = NULL;
if (me) {
if (me->m_rtp_resetting == 1) {
switch_core_session_unlock_codec_read(session);
@@ -2340,12 +2352,12 @@ static switch_status_t on_hangup(switch_core_session_t *session)
me->CloseAllLogicalChannels(false);
me->Unlock();
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----->%s\n",(const char *)(me->GetCallToken()));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----->%s\n",(const char *)(tech_pvt->token));
Q931::CauseValues cause = (Q931::CauseValues)switch_channel_get_cause_q850(channel);
int trylock = me->TryLock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> () = %d\n",trylock);
if (trylock == 1) {
const PString currentToken(me->GetCallToken());
const PString currentToken(tech_pvt->token);
FSH323Connection *connection = (FSH323Connection *)me->GetEndPoint()->FindConnectionWithLock(currentToken);
if (connection) {
connection->Unlock();
@@ -2356,8 +2368,10 @@ static switch_status_t on_hangup(switch_core_session_t *session)
} else if (trylock == -1) {
/* Failed to lock - just go on */
}
const PString currentToken(tech_pvt->token);
me->SetQ931Cause(cause);
me->ClearCallSynchronous(NULL, H323TranslateToCallEndReason(cause, UINT_MAX));
// me->ClearCallSynchronous(NULL, H323TranslateToCallEndReason(cause, UINT_MAX));
ep.ClearCall(currentToken, H323TranslateToCallEndReason(cause, UINT_MAX));
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
// switch_mutex_lock(tech_pvt->h323_mutex);
}
+6 -1
View File
@@ -184,6 +184,7 @@ typedef struct {
switch_mutex_t *h323_io_mutex;
FSH323Connection *me;
char *token;
} h323_private_t;
#define DECLARE_CALLBACK0(name) \
@@ -306,7 +307,11 @@ class FSH323Connection:public H323Connection {
unsigned callReference, switch_caller_profile_t *outbound_profile,
switch_core_session_t *fsSession, switch_channel_t *fsChannel);
~FSH323Connection();
virtual void AttachSignalChannel(
const PString & token,
H323Transport * channel,
PBoolean answeringCall
);
virtual H323Channel *CreateRealTimeLogicalChannel(const H323Capability & capability,
H323Channel::Directions dir,
unsigned sessionID, const H245_H2250LogicalChannelParameters * param, RTP_QOS * rtpqos = NULL);
+19 -24
View File
@@ -85,6 +85,10 @@ static switch_status_t sofia_on_init(switch_core_session_t *session)
sofia_glue_tech_absorb_sdp(tech_pvt);
}
if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING) || sofia_test_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE)) {
sofia_set_flag(tech_pvt, TFLAG_RECOVERED);
}
if (sofia_test_flag(tech_pvt, TFLAG_OUTBOUND) || sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) {
const char *var;
@@ -717,6 +721,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
TAG_IF(sticky, NUTAG_PROXY(tech_pvt->record_route)),
TAG_IF(cid, SIPTAG_HEADER_STR(cid)),
NUTAG_SESSION_TIMER(session_timeout),
TAG_IF(session_timeout, NUTAG_SESSION_REFRESHER(nua_remote_refresher)),
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
SIPTAG_CALL_INFO_STR(switch_channel_get_variable(tech_pvt->channel, SOFIA_SIP_HEADER_PREFIX "call_info")),
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
@@ -732,6 +737,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
TAG_IF(sticky, NUTAG_PROXY(tech_pvt->record_route)),
TAG_IF(cid, SIPTAG_HEADER_STR(cid)),
NUTAG_SESSION_TIMER(session_timeout),
TAG_IF(session_timeout, NUTAG_SESSION_REFRESHER(nua_remote_refresher)),
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
SIPTAG_CALL_INFO_STR(switch_channel_get_variable(tech_pvt->channel, SOFIA_SIP_HEADER_PREFIX "call_info")),
SIPTAG_CONTENT_TYPE_STR("application/sdp"),
@@ -2951,7 +2957,6 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
sofia_profile_t *profile = NULL;
char *profile_name = argv[0];
const char *err;
switch_xml_t xml_root;
if (argc < 2) {
stream->write_function(stream, "Invalid Args!\n");
@@ -2959,12 +2964,10 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
}
if (!strcasecmp(argv[1], "start")) {
if (argc > 2 && !strcasecmp(argv[2], "reloadxml")) {
if ((xml_root = switch_xml_open_root(1, &err))) {
switch_xml_free(xml_root);
}
stream->write_function(stream, "Reload XML [%s]\n", err);
}
switch_xml_reload(&err);
stream->write_function(stream, "Reload XML [%s]\n", err);
if (config_sofia(1, argv[0]) == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "%s started successfully\n", argv[0]);
} else {
@@ -3039,12 +3042,8 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
if (!strcasecmp(argv[1], "rescan")) {
if (argc > 2 && !strcasecmp(argv[2], "reloadxml")) {
if ((xml_root = switch_xml_open_root(1, &err))) {
switch_xml_free(xml_root);
}
stream->write_function(stream, "Reload XML [%s]\n", err);
}
switch_xml_reload(&err);
stream->write_function(stream, "Reload XML [%s]\n", err);
if (reconfig_sofia(profile) == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "+OK scan complete\n");
@@ -3141,12 +3140,8 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
profile->name, rsec, remain, remain == 1 ? "" : "s");
} else {
if (argc > 2 && !strcasecmp(argv[2], "reloadxml")) {
if ((xml_root = switch_xml_open_root(1, &err))) {
switch_xml_free(xml_root);
}
stream->write_function(stream, "Reload XML [%s]\n", err);
}
switch_xml_reload(&err);
stream->write_function(stream, "Reload XML [%s]\n", err);
if (!strcasecmp(argv[1], "stop")) {
sofia_clear_pflag_locked(profile, PFLAG_RUNNING);
@@ -3576,7 +3571,7 @@ SWITCH_STANDARD_API(sofia_function)
const char *usage_string = "USAGE:\n"
"--------------------------------------------------------------------------------\n"
"sofia help\n"
"sofia profile <profile_name> [[start|stop|restart|rescan] [reloadxml]|"
"sofia profile <profile_name> [[start|stop|restart|rescan]|"
"flush_inbound_reg [<call_id>] [reboot]|"
"[register|unregister] [<gateway name>|all]|"
"killgw <gateway name>|"
@@ -4717,10 +4712,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
switch_console_set_complete("add sofia profile");
switch_console_set_complete("add sofia profile restart all");
switch_console_set_complete("add sofia profile ::sofia::list_profiles start reloadxml");
switch_console_set_complete("add sofia profile ::sofia::list_profiles stop reloadxml");
switch_console_set_complete("add sofia profile ::sofia::list_profiles rescan reloadxml");
switch_console_set_complete("add sofia profile ::sofia::list_profiles restart reloadxml");
switch_console_set_complete("add sofia profile ::sofia::list_profiles start");
switch_console_set_complete("add sofia profile ::sofia::list_profiles stop");
switch_console_set_complete("add sofia profile ::sofia::list_profiles rescan");
switch_console_set_complete("add sofia profile ::sofia::list_profiles restart");
switch_console_set_complete("add sofia profile ::sofia::list_profiles flush_inbound_reg");
switch_console_set_complete("add sofia profile ::sofia::list_profiles register ::sofia::list_profile_gateway");
+3
View File
@@ -106,6 +106,7 @@ typedef struct private_object private_object_t;
#define SOFIA_CRYPTO_MANDATORY_VARIABLE "sip_crypto_mandatory"
#define FREESWITCH_SUPPORT "update_display"
#include <switch_stun.h>
#include <sofia-sip/nua.h>
#include <sofia-sip/sip_status.h>
#include <sofia-sip/sdp.h>
@@ -199,6 +200,7 @@ typedef enum {
PFLAG_DISABLE_NAPTR,
PFLAG_AUTOFLUSH,
PFLAG_NAT_OPTIONS_PING,
PFLAG_ALL_REG_OPTIONS_PING,
PFLAG_AUTOFIX_TIMING,
PFLAG_MESSAGE_QUERY_ON_REGISTER,
PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER,
@@ -275,6 +277,7 @@ typedef enum {
TFLAG_RECOVERING,
TFLAG_RECOVERING_BRIDGE,
TFLAG_T38_PASSTHRU,
TFLAG_RECOVERED,
/* No new flags below this line */
TFLAG_MAX
} TFLAGS;
+71 -19
View File
@@ -1225,7 +1225,7 @@ static void sofia_perform_profile_start_failure(sofia_profile_t *profile, char *
#define sofia_profile_start_failure(p, xp) sofia_perform_profile_start_failure(p, xp, __FILE__, __LINE__)
#define SQLLEN 1024 * 64
#define SQLLEN 1024 * 1024
void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread, void *obj)
{
sofia_profile_t *profile = (sofia_profile_t *) obj;
@@ -1233,11 +1233,12 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread
uint32_t gateway_loops = 0;
int loops = 0;
uint32_t qsize;
void *pop;
void *pop = NULL;
int loop_count = 0;
switch_size_t sql_len = SQLLEN;
switch_size_t sql_len = 1024 * 32;
char *tmp, *sqlbuf = NULL;
char *sql = NULL;
if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
sqlbuf = (char *) malloc(sql_len);
}
@@ -1253,37 +1254,43 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread
while ((mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING)) || qsize) {
if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
if (qsize > 0 && (qsize >= 1024 || ++loop_count >= profile->trans_timeout)) {
if (qsize > 0 && (qsize >= 1024 || ++loop_count >= (int)profile->trans_timeout)) {
switch_size_t newlen;
uint32_t itterations = 0;
uint32_t iterations = 0;
switch_size_t len = 0;
switch_mutex_lock(profile->ireg_mutex);
//sofia_glue_actually_execute_sql(profile, "begin;\n", NULL);
while (switch_queue_trypop(profile->sql_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
char *sql = (char *) pop;
while (sql || (switch_queue_trypop(profile->sql_queue, &pop) == SWITCH_STATUS_SUCCESS && pop)) {
if (!sql) sql = (char *) pop;
newlen = strlen(sql) + 2;
iterations++;
if (newlen + 10 < SQLLEN) {
itterations++;
if (len + newlen + 10 > sql_len) {
sql_len = len + 10 + SQLLEN;
if (len + newlen + 10 > sql_len) {
int new_mlen = len + newlen + 10 + 10240;
if (new_mlen < SQLLEN) {
sql_len = new_mlen;
if (!(tmp = realloc(sqlbuf, sql_len))) {
abort();
break;
}
sqlbuf = tmp;
} else {
goto skip;
}
sprintf(sqlbuf + len, "%s;\n", sql);
len += newlen;
}
free(pop);
sprintf(sqlbuf + len, "%s;\n", sql);
len += newlen;
free(sql);
sql = NULL;
}
skip:
//printf("TRANS:\n%s\n", sqlbuf);
sofia_glue_actually_execute_sql_trans(profile, sqlbuf, NULL);
//sofia_glue_actually_execute_sql(profile, "commit;\n", NULL);
@@ -2549,6 +2556,12 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
} else {
sofia_clear_pflag(profile, PFLAG_NAT_OPTIONS_PING);
}
} else if (!strcasecmp(var, "all-reg-options-ping")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_ALL_REG_OPTIONS_PING);
} else {
sofia_clear_pflag(profile, PFLAG_ALL_REG_OPTIONS_PING);
}
} else if (!strcasecmp(var, "inbound-codec-negotiation")) {
if (!strcasecmp(val, "greedy")) {
sofia_set_pflag(profile, PFLAG_GREEDY);
@@ -2860,7 +2873,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
goto done;
}
profile->trans_timeout = 500;
profile->trans_timeout = 100;
profile->auto_rtp_bugs = RTP_BUG_CISCO_SKIP_MARK_BIT_2833;// | RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833;
@@ -3303,6 +3316,12 @@ switch_status_t config_sofia(int reload, char *profile_name)
} else {
sofia_clear_pflag(profile, PFLAG_NAT_OPTIONS_PING);
}
} else if (!strcasecmp(var, "all-options-ping")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_ALL_REG_OPTIONS_PING);
} else {
sofia_clear_pflag(profile, PFLAG_ALL_REG_OPTIONS_PING);
}
} else if (!strcasecmp(var, "inbound-codec-negotiation")) {
if (!strcasecmp(val, "greedy")) {
sofia_set_pflag(profile, PFLAG_GREEDY);
@@ -4521,7 +4540,20 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
break;
case nua_callstate_completing:
nua_ack(nh, TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
{
if (sofia_test_pflag(profile, PFLAG_TRACK_CALLS)) {
const char *invite_full_via = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_via");
const char *invite_route_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_route_uri");
nua_ack(nh,
TAG_IF(!zstr(invite_full_via), SIPTAG_VIA_STR(invite_full_via)),
TAG_IF(!zstr(invite_route_uri), SIPTAG_ROUTE_STR(invite_route_uri)),
TAG_END());
} else {
nua_ack(nh, TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
}
}
goto done;
case nua_callstate_received:
if (!sofia_test_flag(tech_pvt, TFLAG_SDP)) {
@@ -5901,6 +5933,26 @@ void sofia_handle_sip_i_reinvite(switch_core_session_t *session,
{
char *call_info = NULL;
if (session && profile && sip && sofia_test_pflag(profile, PFLAG_TRACK_CALLS)) {
switch_channel_t *channel = switch_core_session_get_channel(session);
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
char network_ip[80];
int network_port = 0;
char via_space[2048];
char branch[16] = "";
sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
switch_stun_random_string(branch, sizeof(branch) - 1, "0123456789abcdef");
switch_snprintf(via_space, sizeof(via_space), "SIP/2.0/UDP %s;rport=%d;branch=%s", network_ip, network_port, branch);
switch_channel_set_variable(channel, "sip_full_via", via_space);
switch_channel_set_variable_printf(channel, "sip_network_port", "%d", network_port);
switch_channel_set_variable_printf(channel, "sip_recieved_port", "%d", network_port);
switch_channel_set_variable_printf(channel, "sip_via_rport", "%d", network_port);
sofia_glue_tech_track(tech_pvt->profile, session);
}
if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
switch_channel_t *channel = switch_core_session_get_channel(session);
if (channel && sip->sip_call_info) {
+25 -9
View File
@@ -1658,7 +1658,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
sofia_private_t *sofia_private;
char *invite_contact = NULL, *to_str, *use_from_str, *from_str;
const char *t_var;
char *rpid_domain = "cluecon.com", *p;
char *rpid_domain = NULL, *p;
const char *priv = "off";
const char *screen = "no";
const char *invite_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_params");
@@ -1670,6 +1670,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
const char *from_var = switch_channel_get_variable(tech_pvt->channel, "sip_from_uri");
const char *from_display = switch_channel_get_variable(tech_pvt->channel, "sip_from_display");
const char *invite_req_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_req_uri");
const char *invite_domain = switch_channel_get_variable(tech_pvt->channel, "sip_invite_domain");
const char *use_name, *use_number;
if (zstr(tech_pvt->dest)) {
@@ -1688,7 +1689,6 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
if (!tech_pvt->from_str) {
const char *sipip;
const char *format;
const char *alt = NULL;
sipip = tech_pvt->profile->sipip;
@@ -1698,8 +1698,8 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
format = strchr(sipip, ':') ? "\"%s\" <sip:%s%s[%s]>" : "\"%s\" <sip:%s%s%s>";
if ((alt = switch_channel_get_variable(channel, "sip_invite_domain"))) {
sipip = alt;
if (!zstr(invite_domain)) {
sipip = invite_domain;
}
tech_pvt->from_str = switch_core_session_sprintf(tech_pvt->session, format, cid_name, cid_num, !zstr(cid_num) ? "@" : "", sipip);
@@ -1739,6 +1739,10 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
}
}
if (!zstr(invite_domain)) {
rpid_domain = (char *)invite_domain;
}
if (zstr(rpid_domain)) {
rpid_domain = "cluecon.com";
}
@@ -2055,10 +2059,16 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA);
}
if (sofia_test_flag(tech_pvt, TFLAG_RECOVERED)) {
session_timeout = 0;
}
if (sofia_use_soa(tech_pvt)) {
nua_invite(tech_pvt->nh,
NUTAG_AUTOANSWER(0),
NUTAG_SESSION_TIMER(session_timeout),
TAG_IF(session_timeout, NUTAG_SESSION_REFRESHER(nua_remote_refresher)),
TAG_IF(sofia_test_flag(tech_pvt, TFLAG_RECOVERED), NUTAG_INVITE_TIMER(UINT_MAX)),
TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
TAG_IF(tech_pvt->redirected, NUTAG_URL(tech_pvt->redirected)),
@@ -2087,6 +2097,8 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
nua_invite(tech_pvt->nh,
NUTAG_AUTOANSWER(0),
NUTAG_SESSION_TIMER(session_timeout),
TAG_IF(session_timeout, NUTAG_SESSION_REFRESHER(nua_remote_refresher)),
TAG_IF(sofia_test_flag(tech_pvt, TFLAG_RECOVERED), NUTAG_INVITE_TIMER(UINT_MAX)),
TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
TAG_IF(tech_pvt->redirected, NUTAG_URL(tech_pvt->redirected)),
@@ -2230,6 +2242,9 @@ static void set_stats(switch_rtp_t *rtp_session, private_object_t *tech_pvt, con
add_stat(stats->outbound.dtmf_packet_count, "out_dtmf_packet_count");
add_stat(stats->outbound.cng_packet_count, "out_cng_packet_count");
add_stat(stats->rtcp.packet_count, "rtcp_packet_count");
add_stat(stats->rtcp.octet_count, "rtcp_octet_count");
}
}
@@ -3579,11 +3594,12 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
if (sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_HOLD) ||
((val = switch_channel_get_variable(tech_pvt->channel, "sip_disable_hold")) && switch_true(val))) {
sendonly = 0;
}
} else {
if (!tech_pvt->hold_laps) {
tech_pvt->hold_laps++;
sofia_glue_toggle_hold(tech_pvt, sendonly);
if (!tech_pvt->hold_laps) {
tech_pvt->hold_laps++;
sofia_glue_toggle_hold(tech_pvt, sendonly);
}
}
for (m = sdp->sdp_media; m; m = m->m_next) {
@@ -4644,7 +4660,7 @@ void sofia_glue_tech_untrack(sofia_profile_t *profile, switch_core_session_t *se
}
}
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
sofia_clear_flag(tech_pvt, TFLAG_TRACKED);
switch_safe_free(sql);
+7 -3
View File
@@ -1442,7 +1442,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
op = switch_event_get_header(helper->event, "Caller-Callee-ID-Number");
}
if (!op) {
if (zstr(op)) {
op = switch_event_get_header(helper->event, "Caller-Destination-Number");
}
@@ -1452,7 +1452,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
if (!strcmp(astate, "early")) {
if (zstr(op)) {
switch_snprintf(status_line, sizeof(status_line), "%s %s", what, status);
switch_snprintf(status_line, sizeof(status_line), "%sing", what);
} else {
switch_snprintf(status_line, sizeof(status_line), "%s %s", what, op);
}
@@ -2043,7 +2043,11 @@ void sofia_presence_handle_sip_i_subscribe(int status,
from_host = "n/a";
}
exp_delta = profile->force_subscription_expires ? profile->force_subscription_expires : (sip->sip_expires ? sip->sip_expires->ex_delta : 3600);
if ((exp_delta = sip->sip_expires ? sip->sip_expires->ex_delta : 3600)) {
if (profile->force_subscription_expires) {
exp_delta = profile->force_subscription_expires;
}
}
if (exp_delta) {
exp_abs = (long) switch_epoch_time_now(NULL) + exp_delta;
+131 -119
View File
@@ -438,11 +438,14 @@ int sofia_reg_nat_callback(void *pArg, int argc, char **argv, char **columnNames
switch_snprintf(to, sizeof(to), "sip:%s@%s", argv[1], argv[2]);
dst = sofia_glue_get_destination(argv[3]);
switch_assert(dst);
nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(profile->url), SIPTAG_TO_STR(to), NUTAG_URL(dst->contact), SIPTAG_CONTACT_STR(profile->url),
TAG_END());
nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
nua_options(nh, TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)), TAG_END());
nua_options(nh,
NTATAG_SIP_T2(5000),
NTATAG_SIP_T4(10000),
TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)), TAG_END());
sofia_glue_free_destination(dst);
@@ -514,7 +517,7 @@ int sofia_reg_del_callback(void *pArg, int argc, char **argv, char **columnNames
switch_event_fire(&s_event);
}
if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_OUT) == SWITCH_STATUS_SUCCESS) {
if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "rpid", "away");
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "login", profile->url);
@@ -637,15 +640,14 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
}
sofia_glue_actually_execute_sql(profile, sql, NULL);
if (now) {
switch_snprintf(sql, sizeof(sql),
"select call_id from sip_subscriptions where (expires = -1 or (expires > 0 and expires <= %ld)) and hostname='%s'", (long) now,
mod_sofia_globals.hostname);
} else {
switch_snprintf(sql, sizeof(sql), "select call_id from sip_subscriptions where expires >= -1 and hostname='%s'", mod_sofia_globals.hostname);
switch_snprintf(sql, sizeof(sql), "select sub_to_user,sub_to_host,call_id from sip_subscriptions where expires >= -1 and hostname='%s'",
mod_sofia_globals.hostname);
}
sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_sub_del_callback, profile);
@@ -670,13 +672,21 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
sofia_glue_actually_execute_sql(profile, sql, NULL);
if (now && sofia_test_pflag(profile, PFLAG_NAT_OPTIONS_PING)) {
switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid,"
"expires,user_agent,server_user,server_host,profile_name"
" from sip_registrations where (status like '%%NAT%%' "
"or contact like '%%fs_nat=true%%') and hostname='%s'", mod_sofia_globals.hostname);
sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_nat_callback, profile);
if (now) {
if (sofia_test_pflag(profile, PFLAG_ALL_REG_OPTIONS_PING)) {
switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid,"
"expires,user_agent,server_user,server_host,profile_name"
" from sip_registrations where hostname='%s'", mod_sofia_globals.hostname);
sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_nat_callback, profile);
} else if (sofia_test_pflag(profile, PFLAG_NAT_OPTIONS_PING)) {
switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid,"
"expires,user_agent,server_user,server_host,profile_name"
" from sip_registrations where (status like '%%NAT%%' "
"or contact like '%%fs_nat=yes%%') and hostname='%s'", mod_sofia_globals.hostname);
sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_nat_callback, profile);
}
}
switch_mutex_unlock(profile->ireg_mutex);
@@ -810,6 +820,9 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
switch_event_t *auth_params = NULL;
int r = 0;
long reg_count = 0;
int delete_subs = 1;
const char *agent = "unknown";
/* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */
switch_assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL);
@@ -826,6 +839,14 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
to = sip->sip_to;
from = sip->sip_from;
if (sip->sip_user_agent) {
agent = sip->sip_user_agent->g_string;
if (switch_stristr("snom", agent)) {
delete_subs = 0;
}
}
if (from) {
from_user = from->a_url->url_user;
from_host = from->a_url->url_host;
@@ -1135,7 +1156,6 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
}
if (exptime) {
const char *agent = "dunno";
char guess_ip4[256];
const char *username = "unknown";
const char *realm = reg_host;
@@ -1145,19 +1165,15 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
realm = switch_event_get_header(auth_params, "sip_auth_realm");
}
if (sip->sip_user_agent) {
agent = sip->sip_user_agent->g_string;
}
if (multi_reg) {
#ifdef DEL_SUBS
if (reg_count == 1) {
sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and contact='%q'",
to_user, sub_host, contact_str);
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
if (delete_subs) {
if (reg_count == 1) {
sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and contact='%q'",
to_user, sub_host, contact_str);
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
}
}
#endif
if (multi_reg_contact) {
@@ -1167,10 +1183,10 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id);
}
} else {
#ifdef DEL_SUBS
sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q'", to_user, sub_host);
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
#endif
if (delete_subs) {
sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q'", to_user, sub_host);
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
}
sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", to_user, reg_host);
}
switch_mutex_lock(profile->ireg_mutex);
@@ -1185,7 +1201,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
"mwi_user,mwi_host, orig_server_host, orig_hostname) "
"values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q','%q','%q')",
call_id, to_user, reg_host, profile->presence_hosts ? profile->presence_hosts : reg_host,
contact_str, reg_desc, rpid, (long) switch_epoch_time_now(NULL) + (long) exptime * 2,
contact_str, reg_desc, rpid, (long) switch_epoch_time_now(NULL) + (long) exptime + 60,
agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm,
mwi_user, mwi_host, guess_ip4, mod_sofia_globals.hostname);
@@ -1290,16 +1306,16 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
if ((p = strchr(icontact + 4, ':'))) {
*p = '\0';
}
#ifdef DEL_SUBS
if (multi_reg_contact) {
sql =
switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and contact='%q'", to_user, sub_host, contact_str);
} else {
sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", call_id);
}
if (delete_subs) {
if (multi_reg_contact) {
sql =
switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and contact='%q'", to_user, sub_host, contact_str);
} else {
sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", call_id);
}
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
#endif
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
}
if (multi_reg_contact) {
sql =
@@ -1312,11 +1328,11 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
switch_safe_free(icontact);
} else {
#ifdef DEL_SUBS
if ((sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q'", to_user, sub_host))) {
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
if (delete_subs) {
if ((sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q'", to_user, sub_host))) {
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
}
}
#endif
if ((sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", to_user, reg_host))) {
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
}
@@ -2292,9 +2308,9 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, "mwi-account", mwi_account);
}
if ((uparams = switch_xml_child(user, "params"))) {
if ((dparams = switch_xml_child(domain, "params"))) {
xparams_type[i] = 0;
xparams[i++] = uparams;
xparams[i++] = dparams;
}
if (group && (gparams = switch_xml_child(group, "params"))) {
@@ -2302,102 +2318,98 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
xparams[i++] = gparams;
}
if ((dparams = switch_xml_child(domain, "params"))) {
if ((uparams = switch_xml_child(user, "params"))) {
xparams_type[i] = 0;
xparams[i++] = dparams;
}
if ((uparams = switch_xml_child(user, "variables"))) {
xparams_type[i] = 1;
xparams[i++] = uparams;
}
if (group && (gparams = switch_xml_child(group, "variables"))) {
xparams_type[i] = 1;
xparams[i++] = gparams;
}
if ((dparams = switch_xml_child(domain, "variables"))) {
xparams_type[i] = 1;
xparams[i++] = dparams;
}
if (group && (gparams = switch_xml_child(group, "variables"))) {
xparams_type[i] = 1;
xparams[i++] = gparams;
}
if ((uparams = switch_xml_child(user, "variables"))) {
xparams_type[i] = 1;
xparams[i++] = uparams;
}
if (i <= 6) {
int j = 0;
const char *gw_val = NULL;
for (j = 0; j < i; j++) {
for (param = switch_xml_child(xparams[j], (xparams_type[j] ? "variable" : "param")); param; param = param->next) {
const char *var = switch_xml_attr_soft(param, "name");
const char *val = switch_xml_attr_soft(param, "value");
sofia_gateway_t *gateway_ptr = NULL;
if (!zstr(var) && !zstr(val) && (xparams_type[j] == 1 || !strncasecmp(var, "sip-", 4) || !strcasecmp(var, "register-gateway"))) {
if (!switch_event_get_header(*v_event, var)) {
if (profile->debug) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "event_add_header -> '%s' = '%s'\n", var, val);
}
switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, var, val);
} else {
continue;
if (profile->debug) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "event_add_header -> '%s' = '%s'\n", var, val);
}
if (!strcasecmp(var, "register-gateway")) {
if (!strcasecmp(val, "all")) {
switch_xml_t gateways_tag, gateway_tag;
if ((gateways_tag = switch_xml_child(user, "gateways"))) {
for (gateway_tag = switch_xml_child(gateways_tag, "gateway"); gateway_tag; gateway_tag = gateway_tag->next) {
char *name = (char *) switch_xml_attr_soft(gateway_tag, "name");
if (zstr(name)) {
name = "anonymous";
}
if ((gateway_ptr = sofia_reg_find_gateway(name))) {
reg_state_t ostate = gateway_ptr->state;
gateway_ptr->retry = 0;
if (exptime) {
gateway_ptr->state = REG_STATE_UNREGED;
} else {
gateway_ptr->state = REG_STATE_UNREGISTER;
}
if (ostate != gateway_ptr->state) {
sofia_reg_fire_custom_gateway_state_event(gateway_ptr, 0, NULL);
}
sofia_reg_release_gateway(gateway_ptr);
}
}
}
} else {
int x, argc;
char *mydata, *argv[50];
mydata = strdup(val);
switch_assert(mydata != NULL);
argc = switch_separate_string(mydata, ',', argv, (sizeof(argv) / sizeof(argv[0])));
for (x = 0; x < argc; x++) {
if ((gateway_ptr = sofia_reg_find_gateway((char *) argv[x]))) {
reg_state_t ostate = gateway_ptr->state;
gateway_ptr->retry = 0;
if (exptime) {
gateway_ptr->state = REG_STATE_UNREGED;
} else {
gateway_ptr->state = REG_STATE_UNREGISTER;
}
if (ostate != gateway_ptr->state) {
sofia_reg_fire_custom_gateway_state_event(gateway_ptr, 0, NULL);
}
sofia_reg_release_gateway(gateway_ptr);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Gateway '%s' not found.\n", argv[x]);
}
}
free(mydata);
switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, var, val);
}
}
}
if ((gw_val = switch_event_get_header(*v_event, "register-gateway"))) {
sofia_gateway_t *gateway_ptr = NULL;
if (!strcasecmp(gw_val, "all")) {
switch_xml_t gateways_tag, gateway_tag;
if ((gateways_tag = switch_xml_child(user, "gateways"))) {
for (gateway_tag = switch_xml_child(gateways_tag, "gateway"); gateway_tag; gateway_tag = gateway_tag->next) {
char *name = (char *) switch_xml_attr_soft(gateway_tag, "name");
if (zstr(name)) {
name = "anonymous";
}
if ((gateway_ptr = sofia_reg_find_gateway(name))) {
reg_state_t ostate = gateway_ptr->state;
gateway_ptr->retry = 0;
if (exptime) {
gateway_ptr->state = REG_STATE_UNREGED;
} else {
gateway_ptr->state = REG_STATE_UNREGISTER;
}
if (ostate != gateway_ptr->state) {
sofia_reg_fire_custom_gateway_state_event(gateway_ptr, 0, NULL);
}
sofia_reg_release_gateway(gateway_ptr);
}
}
}
} else {
int x, argc;
char *mydata, *argv[50];
mydata = strdup(gw_val);
switch_assert(mydata != NULL);
argc = switch_separate_string(mydata, ',', argv, (sizeof(argv) / sizeof(argv[0])));
for (x = 0; x < argc; x++) {
if ((gateway_ptr = sofia_reg_find_gateway((char *) argv[x]))) {
reg_state_t ostate = gateway_ptr->state;
gateway_ptr->retry = 0;
if (exptime) {
gateway_ptr->state = REG_STATE_UNREGED;
} else {
gateway_ptr->state = REG_STATE_UNREGISTER;
}
if (ostate != gateway_ptr->state) {
sofia_reg_fire_custom_gateway_state_event(gateway_ptr, 0, NULL);
}
sofia_reg_release_gateway(gateway_ptr);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Gateway '%s' not found.\n", argv[x]);
}
}
free(mydata);
}
}
}
+9 -2
View File
@@ -19,8 +19,15 @@
/* Lua function typemap */
%typemap(in,checkfn="lua_isfunction") SWIGLUA_FN
%{ $1.L=L; $1.idx=$input; %}
%typemap(in, checkfn = "lua_isfunction") SWIGLUA_FN {
$1.L = L;
$1.idx = $input;
}
%typemap(default) SWIGLUA_FN {
SWIGLUA_FN default_swiglua_fn = { 0 };
$1 = default_swiglua_fn;
}
%ignore SwitchToMempool;
+8 -3
View File
@@ -367,10 +367,15 @@ int Dbh::query_callback(void *pArg, int argc, char **argv, char **cargv)
bool Dbh::query(char *sql, SWIGLUA_FN lua_fun)
{
if (connected) {
if (switch_cache_db_execute_sql_callback(dbh, sql, query_callback, &lua_fun, NULL) == SWITCH_STATUS_SUCCESS) {
return true;
if (lua_fun.L) {
if (switch_cache_db_execute_sql_callback(dbh, sql, query_callback, &lua_fun, NULL) == SWITCH_STATUS_SUCCESS) {
return true;
}
} else { /* if no lua_fun arg is passed from Lua, an empty initialized struct will be sent - see freeswitch.i */
if (switch_cache_db_execute_sql(dbh, sql, NULL) == SWITCH_STATUS_SUCCESS) {
return true;
}
}
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "no workie workie :(\n");
return false;
}
+1 -1
View File
@@ -588,7 +588,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_lua_load)
SWITCH_ADD_API(api_interface, "luarun", "run a script", luarun_api_function, "<script>");
SWITCH_ADD_API(api_interface, "lua", "run a script as an api function", lua_api_function, "<script>");
SWITCH_ADD_APP(app_interface, "lua", "Launch LUA ivr", "Run a lua ivr on a channel", lua_function, "<script>", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "lua", "Launch LUA ivr", "Run a lua ivr on a channel", lua_function, "<script>", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
SWITCH_ADD_DIALPLAN(dp_interface, "LUA", lua_dialplan_hunt);
+14 -3
View File
@@ -7191,17 +7191,28 @@ static int _wrap_Dbh_query(lua_State* L) {
SWIGLUA_FN arg3 ;
bool result;
SWIG_check_num_args("query",3,3)
{
SWIGLUA_FN default_swiglua_fn = {
0
};
arg3 = default_swiglua_fn;
}
SWIG_check_num_args("query",2,3)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("query",1,"LUA::Dbh *");
if(!lua_isstring(L,2)) SWIG_fail_arg("query",2,"char *");
if(!lua_isfunction(L,3)) SWIG_fail_arg("query",3,"SWIGLUA_FN");
if(lua_gettop(L)>=3 && !lua_isfunction(L,3)) SWIG_fail_arg("query",3,"SWIGLUA_FN");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){
SWIG_fail_ptr("Dbh_query",1,SWIGTYPE_p_LUA__Dbh);
}
arg2 = (char *)lua_tostring(L, 2);
(&arg3)->L=L; (&arg3)->idx=3;
if(lua_gettop(L)>=3){
{
(&arg3)->L = L;
(&arg3)->idx = 3;
}
}
result = (bool)(arg1)->query(arg2,arg3);
SWIG_arg=0;
lua_pushboolean(L,(int)(result==true)); SWIG_arg++;
+4 -1
View File
@@ -193,7 +193,10 @@ char * SWIG_csharp_string_callback(const char * str) {
%include switch_core_db.h
%include switch_regex.h
%include switch_core.h
//%include switch_loadable_module.h // todo: Sort out some linking issues
%ignore switch_module_runtime;
%ignore switch_module_load;
%ignore switch_module_shutdown;
%include switch_loadable_module.h // note: Above three ignore lines sort out some linking issues
%include switch_console.h // Has unsupported varargs functions
%include switch_utils.h
%include switch_caller.h
@@ -2813,6 +2813,68 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_rtp_numbers_t(void * jarg1) {
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtcp_numbers_t_packet_count_set(void * jarg1, unsigned long jarg2) {
switch_rtcp_numbers_t *arg1 = (switch_rtcp_numbers_t *) 0 ;
uint32_t arg2 ;
arg1 = (switch_rtcp_numbers_t *)jarg1;
arg2 = (uint32_t)jarg2;
if (arg1) (arg1)->packet_count = arg2;
}
SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_rtcp_numbers_t_packet_count_get(void * jarg1) {
unsigned long jresult ;
switch_rtcp_numbers_t *arg1 = (switch_rtcp_numbers_t *) 0 ;
uint32_t result;
arg1 = (switch_rtcp_numbers_t *)jarg1;
result = (uint32_t) ((arg1)->packet_count);
jresult = (unsigned long)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtcp_numbers_t_octet_count_set(void * jarg1, unsigned long jarg2) {
switch_rtcp_numbers_t *arg1 = (switch_rtcp_numbers_t *) 0 ;
uint32_t arg2 ;
arg1 = (switch_rtcp_numbers_t *)jarg1;
arg2 = (uint32_t)jarg2;
if (arg1) (arg1)->octet_count = arg2;
}
SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_rtcp_numbers_t_octet_count_get(void * jarg1) {
unsigned long jresult ;
switch_rtcp_numbers_t *arg1 = (switch_rtcp_numbers_t *) 0 ;
uint32_t result;
arg1 = (switch_rtcp_numbers_t *)jarg1;
result = (uint32_t) ((arg1)->octet_count);
jresult = (unsigned long)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_rtcp_numbers_t() {
void * jresult ;
switch_rtcp_numbers_t *result = 0 ;
result = (switch_rtcp_numbers_t *)new switch_rtcp_numbers_t();
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_rtcp_numbers_t(void * jarg1) {
switch_rtcp_numbers_t *arg1 = (switch_rtcp_numbers_t *) 0 ;
arg1 = (switch_rtcp_numbers_t *)jarg1;
delete arg1;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_stats_t_inbound_set(void * jarg1, void * jarg2) {
switch_rtp_stats_t *arg1 = (switch_rtp_stats_t *) 0 ;
switch_rtp_numbers_t *arg2 = (switch_rtp_numbers_t *) 0 ;
@@ -2857,6 +2919,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_stats_t_outbound_get(void * jarg
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_stats_t_rtcp_set(void * jarg1, void * jarg2) {
switch_rtp_stats_t *arg1 = (switch_rtp_stats_t *) 0 ;
switch_rtcp_numbers_t *arg2 = (switch_rtcp_numbers_t *) 0 ;
arg1 = (switch_rtp_stats_t *)jarg1;
arg2 = (switch_rtcp_numbers_t *)jarg2;
if (arg1) (arg1)->rtcp = *arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_stats_t_rtcp_get(void * jarg1) {
void * jresult ;
switch_rtp_stats_t *arg1 = (switch_rtp_stats_t *) 0 ;
switch_rtcp_numbers_t *result = 0 ;
arg1 = (switch_rtp_stats_t *)jarg1;
result = (switch_rtcp_numbers_t *)& ((arg1)->rtcp);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_rtp_stats_t() {
void * jresult ;
switch_rtp_stats_t *result = 0 ;
@@ -10097,6 +10181,840 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_in_thread(void * jarg1) {
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_module_name_set(void * jarg1, char * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
char *arg2 = (char *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (char *)jarg2;
{
if (arg2) {
arg1->module_name = (char const *) (new char[strlen((const char *)arg2)+1]);
strcpy((char *)arg1->module_name, (const char *)arg2);
} else {
arg1->module_name = 0;
}
}
}
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_loadable_module_interface_module_name_get(void * jarg1) {
char * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
char *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (char *) ((arg1)->module_name);
jresult = SWIG_csharp_string_callback((const char *)result);
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_endpoint_interface_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_endpoint_interface_t *arg2 = (switch_endpoint_interface_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_endpoint_interface_t *)jarg2;
if (arg1) (arg1)->endpoint_interface = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_endpoint_interface_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_endpoint_interface_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_endpoint_interface_t *) ((arg1)->endpoint_interface);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_timer_interface_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_timer_interface_t *arg2 = (switch_timer_interface_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_timer_interface_t *)jarg2;
if (arg1) (arg1)->timer_interface = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_timer_interface_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_timer_interface_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_timer_interface_t *) ((arg1)->timer_interface);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_dialplan_interface_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_dialplan_interface_t *arg2 = (switch_dialplan_interface_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_dialplan_interface_t *)jarg2;
if (arg1) (arg1)->dialplan_interface = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_dialplan_interface_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_dialplan_interface_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_dialplan_interface_t *) ((arg1)->dialplan_interface);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_codec_interface_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_codec_interface_t *arg2 = (switch_codec_interface_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_codec_interface_t *)jarg2;
if (arg1) (arg1)->codec_interface = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_codec_interface_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_codec_interface_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_codec_interface_t *) ((arg1)->codec_interface);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_application_interface_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_application_interface_t *arg2 = (switch_application_interface_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_application_interface_t *)jarg2;
if (arg1) (arg1)->application_interface = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_application_interface_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_application_interface_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_application_interface_t *) ((arg1)->application_interface);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_api_interface_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_api_interface_t *arg2 = (switch_api_interface_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_api_interface_t *)jarg2;
if (arg1) (arg1)->api_interface = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_api_interface_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_api_interface_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_api_interface_t *) ((arg1)->api_interface);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_file_interface_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_file_interface_t *arg2 = (switch_file_interface_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_file_interface_t *)jarg2;
if (arg1) (arg1)->file_interface = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_file_interface_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_file_interface_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_file_interface_t *) ((arg1)->file_interface);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_speech_interface_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_speech_interface_t *arg2 = (switch_speech_interface_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_speech_interface_t *)jarg2;
if (arg1) (arg1)->speech_interface = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_speech_interface_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_speech_interface_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_speech_interface_t *) ((arg1)->speech_interface);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_directory_interface_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_directory_interface_t *arg2 = (switch_directory_interface_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_directory_interface_t *)jarg2;
if (arg1) (arg1)->directory_interface = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_directory_interface_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_directory_interface_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_directory_interface_t *) ((arg1)->directory_interface);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_chat_interface_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_chat_interface_t *arg2 = (switch_chat_interface_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_chat_interface_t *)jarg2;
if (arg1) (arg1)->chat_interface = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_chat_interface_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_chat_interface_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_chat_interface_t *) ((arg1)->chat_interface);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_say_interface_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_say_interface_t *arg2 = (switch_say_interface_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_say_interface_t *)jarg2;
if (arg1) (arg1)->say_interface = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_say_interface_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_say_interface_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_say_interface_t *) ((arg1)->say_interface);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_asr_interface_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_asr_interface_t *arg2 = (switch_asr_interface_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_asr_interface_t *)jarg2;
if (arg1) (arg1)->asr_interface = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_asr_interface_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_asr_interface_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_asr_interface_t *) ((arg1)->asr_interface);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_management_interface_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_management_interface_t *arg2 = (switch_management_interface_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_management_interface_t *)jarg2;
if (arg1) (arg1)->management_interface = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_management_interface_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_management_interface_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_management_interface_t *) ((arg1)->management_interface);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_limit_interface_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_limit_interface_t *arg2 = (switch_limit_interface_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_limit_interface_t *)jarg2;
if (arg1) (arg1)->limit_interface = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_limit_interface_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_limit_interface_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_limit_interface_t *) ((arg1)->limit_interface);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_rwlock_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_thread_rwlock_t *arg2 = (switch_thread_rwlock_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_thread_rwlock_t *)jarg2;
if (arg1) (arg1)->rwlock = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_rwlock_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_thread_rwlock_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_thread_rwlock_t *) ((arg1)->rwlock);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_refs_set(void * jarg1, int jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
int arg2 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (int)jarg2;
if (arg1) (arg1)->refs = arg2;
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_interface_refs_get(void * jarg1) {
int jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
int result;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (int) ((arg1)->refs);
jresult = result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_pool_set(void * jarg1, void * jarg2) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_memory_pool_t *arg2 = (switch_memory_pool_t *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
arg2 = (switch_memory_pool_t *)jarg2;
if (arg1) (arg1)->pool = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_pool_get(void * jarg1) {
void * jresult ;
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
switch_memory_pool_t *result = 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
result = (switch_memory_pool_t *) ((arg1)->pool);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_loadable_module_interface() {
void * jresult ;
switch_loadable_module_interface *result = 0 ;
result = (switch_loadable_module_interface *)new switch_loadable_module_interface();
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_loadable_module_interface(void * jarg1) {
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
arg1 = (switch_loadable_module_interface *)jarg1;
delete arg1;
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_init(int jarg1) {
int jresult ;
switch_bool_t arg1 ;
switch_status_t result;
arg1 = (switch_bool_t)jarg1;
result = (switch_status_t)switch_loadable_module_init(arg1);
jresult = result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_shutdown() {
switch_loadable_module_shutdown();
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_endpoint_interface(char * jarg1) {
void * jresult ;
char *arg1 = (char *) 0 ;
switch_endpoint_interface_t *result = 0 ;
arg1 = (char *)jarg1;
result = (switch_endpoint_interface_t *)switch_loadable_module_get_endpoint_interface((char const *)arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_codec_interface(char * jarg1) {
void * jresult ;
char *arg1 = (char *) 0 ;
switch_codec_interface_t *result = 0 ;
arg1 = (char *)jarg1;
result = (switch_codec_interface_t *)switch_loadable_module_get_codec_interface((char const *)arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_dialplan_interface(char * jarg1) {
void * jresult ;
char *arg1 = (char *) 0 ;
switch_dialplan_interface_t *result = 0 ;
arg1 = (char *)jarg1;
result = (switch_dialplan_interface_t *)switch_loadable_module_get_dialplan_interface((char const *)arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_enumerate_available(char * jarg1, void * jarg2, void * jarg3) {
int jresult ;
char *arg1 = (char *) 0 ;
switch_modulename_callback_func_t arg2 = (switch_modulename_callback_func_t) 0 ;
void *arg3 = (void *) 0 ;
switch_status_t result;
arg1 = (char *)jarg1;
arg2 = (switch_modulename_callback_func_t)jarg2;
arg3 = (void *)jarg3;
result = (switch_status_t)switch_loadable_module_enumerate_available((char const *)arg1,arg2,arg3);
jresult = result;
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_enumerate_loaded(void * jarg1, void * jarg2) {
int jresult ;
switch_modulename_callback_func_t arg1 = (switch_modulename_callback_func_t) 0 ;
void *arg2 = (void *) 0 ;
switch_status_t result;
arg1 = (switch_modulename_callback_func_t)jarg1;
arg2 = (void *)jarg2;
result = (switch_status_t)switch_loadable_module_enumerate_loaded(arg1,arg2);
jresult = result;
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_build_dynamic(char * jarg1, void * jarg2, void * jarg3, void * jarg4, int jarg5) {
int jresult ;
char *arg1 = (char *) 0 ;
switch_module_load_t arg2 = (switch_module_load_t) 0 ;
switch_module_runtime_t arg3 = (switch_module_runtime_t) 0 ;
switch_module_shutdown_t arg4 = (switch_module_shutdown_t) 0 ;
switch_bool_t arg5 ;
switch_status_t result;
arg1 = (char *)jarg1;
arg2 = (switch_module_load_t)jarg2;
arg3 = (switch_module_runtime_t)jarg3;
arg4 = (switch_module_shutdown_t)jarg4;
arg5 = (switch_bool_t)jarg5;
result = (switch_status_t)switch_loadable_module_build_dynamic(arg1,arg2,arg3,arg4,arg5);
jresult = result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_timer_interface(char * jarg1) {
void * jresult ;
char *arg1 = (char *) 0 ;
switch_timer_interface_t *result = 0 ;
arg1 = (char *)jarg1;
result = (switch_timer_interface_t *)switch_loadable_module_get_timer_interface((char const *)arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_application_interface(char * jarg1) {
void * jresult ;
char *arg1 = (char *) 0 ;
switch_application_interface_t *result = 0 ;
arg1 = (char *)jarg1;
result = (switch_application_interface_t *)switch_loadable_module_get_application_interface((char const *)arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_api_interface(char * jarg1) {
void * jresult ;
char *arg1 = (char *) 0 ;
switch_api_interface_t *result = 0 ;
arg1 = (char *)jarg1;
result = (switch_api_interface_t *)switch_loadable_module_get_api_interface((char const *)arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_file_interface(char * jarg1) {
void * jresult ;
char *arg1 = (char *) 0 ;
switch_file_interface_t *result = 0 ;
arg1 = (char *)jarg1;
result = (switch_file_interface_t *)switch_loadable_module_get_file_interface((char const *)arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_speech_interface(char * jarg1) {
void * jresult ;
char *arg1 = (char *) 0 ;
switch_speech_interface_t *result = 0 ;
arg1 = (char *)jarg1;
result = (switch_speech_interface_t *)switch_loadable_module_get_speech_interface((char const *)arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_asr_interface(char * jarg1) {
void * jresult ;
char *arg1 = (char *) 0 ;
switch_asr_interface_t *result = 0 ;
arg1 = (char *)jarg1;
result = (switch_asr_interface_t *)switch_loadable_module_get_asr_interface((char const *)arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_directory_interface(char * jarg1) {
void * jresult ;
char *arg1 = (char *) 0 ;
switch_directory_interface_t *result = 0 ;
arg1 = (char *)jarg1;
result = (switch_directory_interface_t *)switch_loadable_module_get_directory_interface((char const *)arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_chat_interface(char * jarg1) {
void * jresult ;
char *arg1 = (char *) 0 ;
switch_chat_interface_t *result = 0 ;
arg1 = (char *)jarg1;
result = (switch_chat_interface_t *)switch_loadable_module_get_chat_interface((char const *)arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_say_interface(char * jarg1) {
void * jresult ;
char *arg1 = (char *) 0 ;
switch_say_interface_t *result = 0 ;
arg1 = (char *)jarg1;
result = (switch_say_interface_t *)switch_loadable_module_get_say_interface((char const *)arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_management_interface(char * jarg1) {
void * jresult ;
char *arg1 = (char *) 0 ;
switch_management_interface_t *result = 0 ;
arg1 = (char *)jarg1;
result = (switch_management_interface_t *)switch_loadable_module_get_management_interface((char const *)arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_limit_interface(char * jarg1) {
void * jresult ;
char *arg1 = (char *) 0 ;
switch_limit_interface_t *result = 0 ;
arg1 = (char *)jarg1;
result = (switch_limit_interface_t *)switch_loadable_module_get_limit_interface((char const *)arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_get_codecs(void * jarg1, int jarg2) {
int jresult ;
switch_codec_implementation_t **arg1 = (switch_codec_implementation_t **) 0 ;
int arg2 ;
int result;
arg1 = (switch_codec_implementation_t **)jarg1;
arg2 = (int)jarg2;
result = (int)switch_loadable_module_get_codecs((switch_codec_implementation const **)arg1,arg2);
jresult = result;
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_get_codecs_sorted(void * jarg1, int jarg2, void * jarg3, int jarg4) {
int jresult ;
switch_codec_implementation_t **arg1 = (switch_codec_implementation_t **) 0 ;
int arg2 ;
char **arg3 = (char **) 0 ;
int arg4 ;
int result;
arg1 = (switch_codec_implementation_t **)jarg1;
arg2 = (int)jarg2;
arg3 = (char **)jarg3;
arg4 = (int)jarg4;
result = (int)switch_loadable_module_get_codecs_sorted((switch_codec_implementation const **)arg1,arg2,arg3,arg4);
jresult = result;
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_api_execute(char * jarg1, char * jarg2, void * jarg3, void * jarg4) {
int jresult ;
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
switch_core_session_t *arg3 = (switch_core_session_t *) 0 ;
switch_stream_handle_t *arg4 = (switch_stream_handle_t *) 0 ;
switch_status_t result;
arg1 = (char *)jarg1;
arg2 = (char *)jarg2;
arg3 = (switch_core_session_t *)jarg3;
arg4 = (switch_stream_handle_t *)jarg4;
result = (switch_status_t)switch_api_execute((char const *)arg1,(char const *)arg2,arg3,arg4);
jresult = result;
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_load_module(char * jarg1, char * jarg2, int jarg3, void * jarg4) {
int jresult ;
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
switch_bool_t arg3 ;
char **arg4 = (char **) 0 ;
switch_status_t result;
arg1 = (char *)jarg1;
arg2 = (char *)jarg2;
arg3 = (switch_bool_t)jarg3;
arg4 = (char **)jarg4;
result = (switch_status_t)switch_loadable_module_load_module(arg1,arg2,arg3,(char const **)arg4);
jresult = result;
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_exists(char * jarg1) {
int jresult ;
char *arg1 = (char *) 0 ;
switch_status_t result;
arg1 = (char *)jarg1;
result = (switch_status_t)switch_loadable_module_exists((char const *)arg1);
jresult = result;
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_unload_module(char * jarg1, char * jarg2, int jarg3, void * jarg4) {
int jresult ;
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
switch_bool_t arg3 ;
char **arg4 = (char **) 0 ;
switch_status_t result;
arg1 = (char *)jarg1;
arg2 = (char *)jarg2;
arg3 = (switch_bool_t)jarg3;
arg4 = (char **)jarg4;
result = (switch_status_t)switch_loadable_module_unload_module(arg1,arg2,arg3,(char const **)arg4);
jresult = result;
return jresult;
}
SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_core_codec_next_id() {
unsigned long jresult ;
uint32_t result;
result = (uint32_t)switch_core_codec_next_id();
jresult = (unsigned long)result;
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_check_interval(unsigned long jarg1, unsigned long jarg2) {
int jresult ;
uint32_t arg1 ;
uint32_t arg2 ;
int result;
arg1 = (uint32_t)jarg1;
arg2 = (uint32_t)jarg2;
result = (int)switch_check_interval(arg1,arg2);
jresult = result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_codec_add_implementation(void * jarg1, void * jarg2, int jarg3, unsigned char jarg4, char * jarg5, char * jarg6, unsigned long jarg7, unsigned long jarg8, int jarg9, int jarg10, unsigned long jarg11, unsigned long jarg12, unsigned long jarg13, unsigned char jarg14, int jarg15, void * jarg16, void * jarg17, void * jarg18, void * jarg19) {
switch_memory_pool_t *arg1 = (switch_memory_pool_t *) 0 ;
switch_codec_interface_t *arg2 = (switch_codec_interface_t *) 0 ;
switch_codec_type_t arg3 ;
switch_payload_t arg4 ;
char *arg5 = (char *) 0 ;
char *arg6 = (char *) 0 ;
uint32_t arg7 ;
uint32_t arg8 ;
int arg9 ;
int arg10 ;
uint32_t arg11 ;
uint32_t arg12 ;
uint32_t arg13 ;
uint8_t arg14 ;
int arg15 ;
switch_core_codec_init_func_t arg16 = (switch_core_codec_init_func_t) 0 ;
switch_core_codec_encode_func_t arg17 = (switch_core_codec_encode_func_t) 0 ;
switch_core_codec_decode_func_t arg18 = (switch_core_codec_decode_func_t) 0 ;
switch_core_codec_destroy_func_t arg19 = (switch_core_codec_destroy_func_t) 0 ;
arg1 = (switch_memory_pool_t *)jarg1;
arg2 = (switch_codec_interface_t *)jarg2;
arg3 = (switch_codec_type_t)jarg3;
arg4 = (switch_payload_t)jarg4;
arg5 = (char *)jarg5;
arg6 = (char *)jarg6;
arg7 = (uint32_t)jarg7;
arg8 = (uint32_t)jarg8;
arg9 = (int)jarg9;
arg10 = (int)jarg10;
arg11 = (uint32_t)jarg11;
arg12 = (uint32_t)jarg12;
arg13 = (uint32_t)jarg13;
arg14 = (uint8_t)jarg14;
arg15 = (int)jarg15;
arg16 = (switch_core_codec_init_func_t)jarg16;
arg17 = (switch_core_codec_encode_func_t)jarg17;
arg18 = (switch_core_codec_decode_func_t)jarg18;
arg19 = (switch_core_codec_destroy_func_t)jarg19;
switch_core_codec_add_implementation(arg1,arg2,arg3,arg4,(char const *)arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15,arg16,arg17,arg18,arg19);
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_codec_ready(void * jarg1) {
int jresult ;
switch_codec_t *arg1 = (switch_codec_t *) 0 ;
switch_bool_t result;
arg1 = (switch_codec_t *)jarg1;
result = (switch_bool_t)switch_core_codec_ready(arg1);
jresult = result;
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CMD_CHUNK_LEN_get() {
int jresult ;
int result;
@@ -12218,6 +13136,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_caller_profile_originatee_caller_pro
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_origination_caller_profile_set(void * jarg1, void * jarg2) {
switch_caller_profile *arg1 = (switch_caller_profile *) 0 ;
switch_caller_profile *arg2 = (switch_caller_profile *) 0 ;
arg1 = (switch_caller_profile *)jarg1;
arg2 = (switch_caller_profile *)jarg2;
if (arg1) (arg1)->origination_caller_profile = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_caller_profile_origination_caller_profile_get(void * jarg1) {
void * jresult ;
switch_caller_profile *arg1 = (switch_caller_profile *) 0 ;
switch_caller_profile *result = 0 ;
arg1 = (switch_caller_profile *)jarg1;
result = (switch_caller_profile *) ((arg1)->origination_caller_profile);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_caller_profile_hunt_caller_profile_set(void * jarg1, void * jarg2) {
switch_caller_profile *arg1 = (switch_caller_profile *) 0 ;
switch_caller_profile *arg2 = (switch_caller_profile *) 0 ;
@@ -21387,6 +22327,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_get_originatee_caller_profil
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_set_origination_caller_profile(void * jarg1, void * jarg2) {
switch_channel_t *arg1 = (switch_channel_t *) 0 ;
switch_caller_profile_t *arg2 = (switch_caller_profile_t *) 0 ;
arg1 = (switch_channel_t *)jarg1;
arg2 = (switch_caller_profile_t *)jarg2;
switch_channel_set_origination_caller_profile(arg1,arg2);
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_get_origination_caller_profile(void * jarg1) {
void * jresult ;
switch_channel_t *arg1 = (switch_channel_t *) 0 ;
switch_caller_profile_t *result = 0 ;
arg1 = (switch_channel_t *)jarg1;
result = (switch_caller_profile_t *)switch_channel_get_origination_caller_profile(arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_channel_get_uuid(void * jarg1) {
char * jresult ;
switch_channel_t *arg1 = (switch_channel_t *) 0 ;
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -275,7 +275,6 @@ static abyss_bool is_authorized(const TSession * r, const char *command)
err = 686;
status = "EXECUTION OF SPECIFIED API COMMAND NOT PERMITTED IN USER ACCOUNT";
if (!user_attributes(user, domain_name, NULL, NULL, NULL, &allowed_commands)) {
goto end;
@@ -305,11 +304,6 @@ static abyss_bool is_authorized(const TSession * r, const char *command)
if (!ok) {
ResponseStatus(r, err);
if (status) {
ResponseError2(r, status);
} else {
ResponseError(r);
}
}
+11 -6
View File
@@ -1291,19 +1291,24 @@ SWITCH_DECLARE(int) switch_channel_test_private_flag(switch_channel_t *channel,
SWITCH_DECLARE(void) switch_channel_set_app_flag_key(const char *key, switch_channel_t *channel, uint32_t flags)
{
uint32_t *flagp = NULL;
switch_byte_t new = 0;
switch_assert(channel != NULL);
switch_mutex_lock(channel->flag_mutex);
if (channel->app_flag_hash) {
flagp = switch_core_hash_find(channel->app_flag_hash, key);
} else {
if (!channel->app_flag_hash) {
switch_core_hash_init(&channel->app_flag_hash, switch_core_session_get_pool(channel->session));
new++;
}
if (new || !(flagp = switch_core_hash_find(channel->app_flag_hash, key))) {
flagp = switch_core_session_alloc(channel->session, sizeof(uint32_t));
switch_core_hash_insert(channel->app_flag_hash, key, flagp);
}
if (flagp) *flagp |= flags;
switch_assert(flagp);
*flagp |= flags;
switch_mutex_unlock(channel->flag_mutex);
}
+37 -2
View File
@@ -1225,7 +1225,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
}
runtime.runlevel++;
runtime.sql_buffer_len = 1024 * 32;
runtime.max_sql_buffer_len = 1024 * 1024;
runtime.dummy_cng_frame.data = runtime.dummy_data;
runtime.dummy_cng_frame.datalen = sizeof(runtime.dummy_data);
runtime.dummy_cng_frame.buflen = sizeof(runtime.dummy_data);
@@ -1321,6 +1322,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
switch_log_init(runtime.memory_pool, runtime.colorize_console);
if (flags & SCF_MINIMAL) return SWITCH_STATUS_SUCCESS;
runtime.tipping_point = 5000;
runtime.timer_affinity = -1;
@@ -1444,6 +1447,37 @@ static void switch_load_core_config(const char *file)
if (tmp > -1 && tmp < 11) {
switch_core_session_ctl(SCSC_DEBUG_LEVEL, &tmp);
}
} else if (!strcasecmp(var, "sql-buffer-len")) {
int tmp = atoi(val);
if (end_of(val) == 'k') {
tmp *= 1024;
} else if (end_of(val) == 'm') {
tmp *= (1024 * 1024);
}
if (tmp >= 32000 && tmp < 10500000) {
runtime.sql_buffer_len = tmp;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "sql-buffer-len: Value is not within rage 32k to 10m\n");
}
} else if (!strcasecmp(var, "max-sql-buffer-len")) {
int tmp = atoi(val);
if (end_of(val) == 'k') {
tmp *= 1024;
} else if (end_of(val) == 'm') {
tmp *= (1024 * 1024);
}
if (tmp < runtime.sql_buffer_len) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Value is not larger than sql-buffer-len\n");
} else if (tmp >= 32000 && tmp < 10500000) {
runtime.sql_buffer_len = tmp;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "max-sql-buffer-len: Value is not within rage 32k to 10m\n");
}
} else if (!strcasecmp(var, "auto-create-schemas")) {
if (switch_true(val)) {
switch_set_flag((&runtime), SCF_AUTO_SCHEMAS);
@@ -1614,7 +1648,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bringing up environment.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Loading Modules.\n");
if (switch_loadable_module_init() != SWITCH_STATUS_SUCCESS) {
if (switch_loadable_module_init(SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
*err = "Cannot load modules";
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Error: %s\n", *err);
return SWITCH_STATUS_GENERR;
@@ -1922,6 +1956,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
switch_scheduler_task_thread_stop();
switch_rtp_shutdown();
if (switch_test_flag((&runtime), SCF_USE_AUTO_NAT)) {
switch_nat_shutdown();
}
+1 -1
View File
@@ -173,7 +173,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
}
if (fh->samplerate && rate && fh->samplerate != rate) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Sample rate doesn't match\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "File %s sample rate %d doesn't match requested rate %d\n", file_path, fh->samplerate, rate);
if ((flags & SWITCH_FILE_FLAG_READ)) {
fh->samplerate = rate;
}
+56 -41
View File
@@ -35,8 +35,6 @@
#include <switch.h>
#include "private/switch_core_pvt.h"
#define SQLLEN 1024*1024
static struct {
switch_cache_db_handle_t *event_db;
switch_queue_t *sql_queue[2];
@@ -48,6 +46,8 @@ static struct {
switch_mutex_t *io_mutex;
switch_mutex_t *dbh_mutex;
switch_hash_t *dbh_hash;
switch_thread_cond_t *cond;
switch_mutex_t *cond_mutex;
} sql_manager;
@@ -346,7 +346,7 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h
{
if (!switch_odbc_available()) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure! OBDC NOT AVAILABLE!\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure! ODBC NOT AVAILABLE!\n");
goto end;
}
@@ -539,7 +539,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_hand
switch (dbh->type) {
default:
{
status = switch_cache_db_execute_sql_chunked(dbh, (char *) sql, SQLLEN, err);
status = switch_cache_db_execute_sql_chunked(dbh, (char *) sql, 32768, err);
}
break;
}
@@ -850,19 +850,18 @@ SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_hand
static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread, void *obj)
{
void *pop;
uint32_t itterations = 0;
uint8_t trans = 0, nothing_in_queue = 0;
uint32_t target = 100000;
switch_size_t len = 0, sql_len = SQLLEN;
char *sqlbuf = (char *) malloc(sql_len);
void *pop = NULL;
uint32_t iterations = 0;
uint8_t trans = 0;
uint32_t target = 20000;
switch_size_t len = 0, sql_len = runtime.sql_buffer_len;
char *tmp, *sqlbuf = (char *) malloc(sql_len);
char *sql = NULL;
switch_size_t newlen;
int lc = 0;
uint32_t loops = 0, sec = 0;
uint32_t l1 = 1000;
uint32_t sanity = 120;
int item_remained = 0;
switch_assert(sqlbuf);
@@ -887,6 +886,9 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
sql_manager.thread_running = 1;
while (sql_manager.thread_running == 1) {
switch_mutex_lock(sql_manager.cond_mutex);
if (++loops == l1) {
if (++sec == SQL_CACHE_TIMEOUT) {
sql_close(switch_epoch_time_now(NULL));
@@ -900,63 +902,71 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
continue;
}
//printf("SIZE %d %d\n", switch_queue_size(sql_manager.sql_queue[0]), switch_queue_size(sql_manager.sql_queue[1]));
if (item_remained || switch_queue_trypop(sql_manager.sql_queue[0], &pop) == SWITCH_STATUS_SUCCESS ||
if (sql || switch_queue_trypop(sql_manager.sql_queue[0], &pop) == SWITCH_STATUS_SUCCESS ||
switch_queue_trypop(sql_manager.sql_queue[1], &pop) == SWITCH_STATUS_SUCCESS) {
if (item_remained) {
item_remained = 0;
} else {
sql = (char *) pop;
}
if (!sql) sql = (char *) pop;
if (sql) {
newlen = strlen(sql) + 2;
if (itterations == 0) {
if (iterations == 0) {
trans = 1;
}
/* ignore abnormally large strings sql strings as potential buffer overflow */
if (newlen < SQLLEN) {
itterations++;
if (len + newlen > sql_len) {
int new_mlen = len + newlen + 10240;
if (len + newlen < sql_len) {
sprintf(sqlbuf + len, "%s;\n", sql);
len += newlen;
if (new_mlen < runtime.max_sql_buffer_len) {
sql_len = new_mlen;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10,
"REALLOC %ld %d %d\n", (long int)sql_len, switch_queue_size(sql_manager.sql_queue[0]),
switch_queue_size(sql_manager.sql_queue[1]));
if (!(tmp = realloc(sqlbuf, sql_len))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL thread ending on mem err\n");
abort();
break;
}
sqlbuf = tmp;
} else {
item_remained = 1;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10,
"SAVE %d %d\n", switch_queue_size(sql_manager.sql_queue[0]), switch_queue_size(sql_manager.sql_queue[1]));
goto skip;
}
}
if (!item_remained) {
free(sql);
}
iterations++;
sprintf(sqlbuf + len, "%s;\n", sql);
len += newlen;
free(sql);
sql = NULL;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "SQL thread ending\n");
break;
}
} else {
nothing_in_queue = 1;
}
if ((item_remained || (trans && ((itterations == target) || (nothing_in_queue && ++lc >= 500)))) &&
(sql_manager.event_db->native_handle.core_db_dbh)) {
skip:
lc = sql ? 1 : 0 + switch_queue_size(sql_manager.sql_queue[0]) + switch_queue_size(sql_manager.sql_queue[1]);
if (trans && iterations && (iterations > target || !lc)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10,
"RUN %d %d %d\n", switch_queue_size(sql_manager.sql_queue[0]), switch_queue_size(sql_manager.sql_queue[1]), iterations);
if (switch_cache_db_persistant_execute_trans(sql_manager.event_db, sqlbuf, 1) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL thread unable to commit transaction, records lost!\n");
}
itterations = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "DONE\n");
iterations = 0;
trans = 0;
nothing_in_queue = 0;
len = 0;
*sqlbuf = '\0';
lc = 0;
switch_yield(400000);
}
if (nothing_in_queue) {
switch_cond_next();
if (!lc) {
switch_thread_cond_wait(sql_manager.cond, sql_manager.cond_mutex);
}
}
@@ -1389,6 +1399,7 @@ static void core_event_handler(switch_event_t *event)
switch_queue_push(sql_manager.sql_queue[0], sql[i]);
}
sql[i] = NULL;
switch_thread_cond_broadcast(sql_manager.cond);
}
}
}
@@ -1511,6 +1522,9 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
switch_mutex_init(&sql_manager.dbh_mutex, SWITCH_MUTEX_NESTED, sql_manager.memory_pool);
switch_mutex_init(&sql_manager.io_mutex, SWITCH_MUTEX_NESTED, sql_manager.memory_pool);
switch_mutex_init(&sql_manager.cond_mutex, SWITCH_MUTEX_NESTED, sql_manager.memory_pool);
switch_thread_cond_create(&sql_manager.cond, sql_manager.memory_pool);
switch_core_hash_init(&sql_manager.dbh_hash, sql_manager.memory_pool);
@@ -1659,6 +1673,7 @@ void switch_core_sqldb_stop(void)
switch_queue_push(sql_manager.sql_queue[0], NULL);
switch_queue_push(sql_manager.sql_queue[1], NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Waiting for unfinished SQL transactions\n");
switch_thread_cond_broadcast(sql_manager.cond);
}
sql_manager.thread_running = -1;
+1
View File
@@ -2175,6 +2175,7 @@ SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint3
if ((jb_frame = stfu_n_read_a_frame(jb))) {
write_frame.data = jb_frame->data;
write_frame.datalen = (uint32_t) jb_frame->dlen;
write_frame.buflen = (uint32_t) jb_frame->dlen;
status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) {
break;
+18 -4
View File
@@ -214,12 +214,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_me
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, switch_ivr_action_t ivr_action, const char *arg, const char *bind)
{
switch_ivr_menu_action_t *action;
switch_ivr_menu_action_t *action, *ap;
uint32_t len;
if ((action = switch_core_alloc(menu->pool, sizeof(*action)))) {
action->bind = switch_core_strdup(menu->pool, bind);
action->next = menu->actions;
action->arg = switch_core_strdup(menu->pool, arg);
if (*action->bind == '/') {
action->re = 1;
@@ -230,7 +229,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *m
}
}
action->ivr_action = ivr_action;
if (menu->actions) {
for(ap = menu->actions; ap && ap->next; ap = ap->next);
ap->next = action;
} else {
menu->actions = action;
}
return SWITCH_STATUS_SUCCESS;
}
@@ -240,13 +246,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *m
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t *menu,
switch_ivr_menu_action_function_t *function, const char *arg, const char *bind)
{
switch_ivr_menu_action_t *action;
switch_ivr_menu_action_t *action, *ap;
uint32_t len;
if ((action = switch_core_alloc(menu->pool, sizeof(*action)))) {
action->bind = switch_core_strdup(menu->pool, bind);
action->next = menu->actions;
action->arg = switch_core_strdup(menu->pool, arg);
if (*action->bind == '/') {
action->re = 1;
} else {
@@ -255,8 +261,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t
menu->inlen = len;
}
}
action->function = function;
if (menu->actions) {
for(ap = menu->actions; ap && ap->next; ap = ap->next);
ap->next = action;
} else {
menu->actions = action;
}
return SWITCH_STATUS_SUCCESS;
}
+14 -3
View File
@@ -1218,7 +1218,7 @@ static void switch_loadable_module_path_init()
}
#endif
SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
SWITCH_DECLARE(switch_status_t) switch_loadable_module_init(switch_bool_t autoload)
{
apr_finfo_t finfo = { 0 };
@@ -1268,6 +1268,8 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
switch_core_hash_init_nocase(&loadable_modules.dialplan_hash, loadable_modules.pool);
switch_mutex_init(&loadable_modules.mutex, SWITCH_MUTEX_NESTED, loadable_modules.pool);
if (!autoload) return SWITCH_STATUS_SUCCESS;
switch_loadable_module_load_module("", "CORE_SOFTTIMER_MODULE", SWITCH_FALSE, &err);
switch_loadable_module_load_module("", "CORE_PCM_MODULE", SWITCH_FALSE, &err);
@@ -1277,6 +1279,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
for (ld = switch_xml_child(mods, "load"); ld; ld = ld->next) {
switch_bool_t global = SWITCH_FALSE;
const char *val = switch_xml_attr_soft(ld, "module");
const char *path = switch_xml_attr_soft(ld, "path");
const char *critical = switch_xml_attr_soft(ld, "critical");
const char *sglobal = switch_xml_attr_soft(ld, "global");
if (zstr(val) || (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT))) {
@@ -1285,7 +1288,10 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
}
global = switch_true(sglobal);
if (switch_loadable_module_load_module_ex((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val, SWITCH_FALSE, global, &err) == SWITCH_STATUS_FALSE) {
if (path && zstr(path)) {
path = SWITCH_GLOBAL_dirs.mod_dir;
}
if (switch_loadable_module_load_module_ex((char *) path, (char *) val, SWITCH_FALSE, global, &err) == SWITCH_STATUS_FALSE) {
if (critical && switch_true(critical)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to load critical module '%s', abort()\n", val);
abort();
@@ -1307,13 +1313,18 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
for (ld = switch_xml_child(mods, "load"); ld; ld = ld->next) {
switch_bool_t global = SWITCH_FALSE;
const char *val = switch_xml_attr_soft(ld, "module");
const char *path = switch_xml_attr_soft(ld, "path");
const char *sglobal = switch_xml_attr_soft(ld, "global");
if (zstr(val) || (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val);
continue;
}
global = switch_true(sglobal);
switch_loadable_module_load_module_ex((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val, SWITCH_FALSE, global, &err);
if (path && zstr(path)) {
path = SWITCH_GLOBAL_dirs.mod_dir;
}
switch_loadable_module_load_module_ex((char *) path, (char *) val, SWITCH_FALSE, global, &err);
count++;
}
}
+1 -1
View File
@@ -690,7 +690,7 @@ SWITCH_DECLARE(void) switch_nat_late_init(void)
{
if (nat_globals_perm.running == 1) {
switch_scheduler_add_task(switch_epoch_time_now(NULL) + NAT_REFRESH_INTERVAL, switch_nat_republish_sched, "nat_republish", "core", 0, NULL,
SSHF_NONE);
SSHF_OWN_THREAD);
}
}
+7
View File
@@ -662,6 +662,10 @@ SWITCH_DECLARE(void) switch_rtp_shutdown(void)
const void *var;
void *val;
if (!global_init) {
return;
}
switch_mutex_lock(port_lock);
for (hi = switch_hash_first(NULL, alloc_hash); hi; hi = switch_hash_next(hi)) {
@@ -2191,6 +2195,9 @@ static switch_status_t read_rtcp_packet(switch_rtp_t *rtp_session, switch_size_t
rtp_session->rtcp_fresh_frame = 1;
rtp_session->stats.rtcp.packet_count += sr->pc;
rtp_session->stats.rtcp.octet_count += sr->oc;
/* sender report */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10,"Received a SR with %d report blocks, " \
"length in words = %d, " \
+250
View File
@@ -2090,6 +2090,137 @@ SWITCH_DECLARE(char *) switch_url_decode(char *s)
return s;
}
SWITCH_DECLARE(void) switch_split_time(const char *exp, int *hour, int *min, int *sec)
{
char *dup = strdup(exp);
char *shour = NULL;
char *smin = NULL;
char *ssec = NULL;
switch_assert(dup);
shour = dup;
if ((smin=strchr(dup, ':'))) {
*smin++ = '\0';
if ((ssec=strchr(smin, ':'))) {
*ssec++ = '\0';
} else {
ssec = "00";
}
if (hour && shour) {
*hour = atol(shour);
}
if (min && smin) {
*min = atol(smin);
}
if (sec && ssec) {
*sec = atol(ssec);
}
}
switch_safe_free(dup);
return;
}
SWITCH_DECLARE(void) switch_split_date(const char *exp, int *year, int *month, int *day)
{
char *dup = strdup(exp);
char *syear = NULL;
char *smonth = NULL;
char *sday = NULL;
switch_assert(dup);
syear = dup;
if ((smonth=strchr(dup, '-'))) {
*smonth++ = '\0';
if ((sday=strchr(smonth, '-'))) {
*sday++ = '\0';
if (year && syear) {
*year = atol(syear);
}
if (month && smonth) {
*month = atol(smonth);
}
if (day && sday) {
*day = atol(sday);
}
}
}
switch_safe_free(dup);
return;
}
/* Ex exp value "2009-10-10 14:33:22~2009-11-10 17:32:31" */
SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts)
{
char *dup = strdup(exp);
char *sStart;
char *sEnd;
char *sDate;
char *sTime;
switch_time_t tsStart;
switch_time_t tsEnd;
switch_assert(dup);
sStart = dup;
if ((sEnd=strchr(dup, '~'))) {
*sEnd++ = '\0';
sDate = sStart;
if ((sTime=strchr(sStart, ' '))) {
struct tm tmTmp;
int year, month, day;
int hour, min, sec;
*sTime++ = '\0';
switch_split_date(sDate, &year, &month, &day);
switch_split_time(sTime, &hour, &min, &sec);
tmTmp.tm_year = year;
tmTmp.tm_mon = month;
tmTmp.tm_mday = day;
tmTmp.tm_hour = hour;
tmTmp.tm_min = min;
tmTmp.tm_sec = sec;
tmTmp.tm_isdst = 0;
tsStart = mktime(&tmTmp);
sDate = sEnd;
if ((sTime=strchr(sEnd, ' '))) {
struct tm tmTmp;
int year, month, day;
int hour, min, sec;
*sTime++ = '\0';
switch_split_date(sDate, &year, &month, &day);
switch_split_time(sTime, &hour, &min, &sec);
tmTmp.tm_year = year;
tmTmp.tm_mon = month;
tmTmp.tm_mday = day;
tmTmp.tm_hour = hour;
tmTmp.tm_min = min;
tmTmp.tm_sec = sec;
tmTmp.tm_isdst = 0;
tsEnd = mktime(&tmTmp);
if (tsStart <= *ts && tsEnd > *ts) {
switch_safe_free(dup);
return 1;
}
}
}
}
switch_safe_free(dup);
return 0;
}
/* Written by Marc Espie, public domain */
#define SWITCH_CTYPE_NUM_CHARS 256
@@ -2335,6 +2466,82 @@ SWITCH_DECLARE(int) switch_isxdigit(int c)
return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] & (_N | _X)));
}
static const char *DOW[] = {
"sat",
"sun",
"mon",
"tue",
"wed",
"thu",
"fri",
"sat",
"sun",
NULL
};
SWITCH_DECLARE(const char *) switch_dow_int2str(int val) {
if (val >= sizeof(DOW) / sizeof (const char*)) {
return NULL;
}
return DOW[val];
}
SWITCH_DECLARE(int) switch_dow_str2int(const char *exp) {
int ret = -1;
int x = -1;
for (x = 0;; x++) {
if (!DOW[x]) {
break;
}
if (!strcasecmp(DOW[x], exp)) {
ret = x;
break;
}
}
return ret;
}
SWITCH_DECLARE(int) switch_dow_cmp(const char *exp, int val)
{
char *dup = strdup(exp);
char *p_start;
char *p_end;
int ret = 0;
int start, end;
switch_assert(dup);
p_start = dup;
if ((p_end=strchr(dup, '-'))) {
*p_end++ = '\0';
} else {
p_end = p_start;
}
if (strlen(p_start) == 3) {
start = switch_dow_str2int(p_start);
} else {
start = atol(p_start);
}
if (strlen(p_end) == 3) {
end = switch_dow_str2int(p_end);
} else {
end = atol(p_end);
}
/* Following used for this example : mon-sat = 2-0, so we need to make 0(sat) + 7 */
if (end < start) {
end += 7;
}
if (start != -1 && end != -1 && val >= start && val <= end) {
ret = 1;
}
switch_safe_free(dup);
return ret;
}
SWITCH_DECLARE(int) switch_number_cmp(const char *exp, int val)
{
char *p;
@@ -2375,6 +2582,49 @@ SWITCH_DECLARE(int) switch_number_cmp(const char *exp, int val)
}
SWITCH_DECLARE(int) switch_tod_cmp(const char *exp, int val)
{
char *dup = strdup(exp);
char *minh;
char *minm;
char *mins;
char *maxh;
char *maxm;
char *maxs;
switch_assert(dup);
minh = dup;
if ((minm=strchr(dup, ':'))) {
*minm++ = '\0';
if ((maxh=strchr(minm, '-'))) {
if ((maxm=strchr(maxh, ':'))) {
*maxh++ = '\0';
*maxm++ = '\0';
/* Check if min/max seconds are present */
if ((mins=strchr(minm, ':'))) {
*mins++ = '\0';
} else {
mins = "00";
}
if ((maxs=strchr(maxm, ':'))) {
*maxs++ = '\0';
} else {
maxs = "00";
}
if (val >= (atol(minh) * 60 * 60) + (atol(minm) * 60) + atol(mins) && val < (atol(maxh) * 60 * 60) + (atol(maxm) * 60) + atol(maxs)) {
switch_safe_free(dup);
return 1;
}
}
}
}
switch_safe_free(dup);
return 0;
}
SWITCH_DECLARE(int) switch_split_user_domain(char *in, char **user, char **domain)
{
char *p = NULL, *h = NULL, *u = in;
+34 -2
View File
@@ -2039,6 +2039,18 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload, const char **e
return r;
}
SWITCH_DECLARE(switch_status_t) switch_xml_reload(const char **err)
{
switch_xml_t xml_root;
if ((xml_root = switch_xml_open_root(1, err))) {
switch_xml_free(xml_root);
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_GENERR;
}
SWITCH_DECLARE(switch_status_t) switch_xml_init(switch_memory_pool_t *pool, const char **err)
{
switch_xml_t xml;
@@ -2640,6 +2652,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_cut(switch_xml_t xml)
SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond) {
const char *xdt = switch_xml_attr(xcond, "date-time");
const char *xyear = switch_xml_attr(xcond, "year");
const char *xyday = switch_xml_attr(xcond, "yday");
const char *xmon = switch_xml_attr(xcond, "mon");
@@ -2650,6 +2663,7 @@ SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond) {
const char *xhour = switch_xml_attr(xcond, "hour");
const char *xminute = switch_xml_attr(xcond, "minute");
const char *xminday = switch_xml_attr(xcond, "minute-of-day");
const char *xtod = switch_xml_attr(xcond, "time-of-day");
switch_time_t ts = switch_micro_time_now();
int time_match = -1;
@@ -2657,6 +2671,15 @@ SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond) {
switch_time_exp_lt(&tm, ts);
if (time_match && xdt) {
char tmpdate[80];
switch_size_t retsize;
switch_strftime(tmpdate, &retsize, sizeof(tmpdate), "%Y-%m-%d %H:%M:%S", &tm);
time_match = switch_fulldate_cmp(xdt, &ts);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"XML DateTime Check: date time[%s] =~ %s (%s)\n", tmpdate, xdt, time_match ? "PASS" : "FAIL");
}
if (time_match && xyear) {
int test = tm.tm_year + 1900;
time_match = switch_number_cmp(xyear, test);
@@ -2710,9 +2733,9 @@ SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond) {
if (time_match && xwday) {
int test = tm.tm_wday + 1;
time_match = switch_number_cmp(xwday, test);
time_match = switch_dow_cmp(xwday, test);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
"XML DateTime Check: day of week[%d] =~ %s (%s)\n", test, xwday, time_match ? "PASS" : "FAIL");
"XML DateTime Check: day of week[%s] =~ %s (%s)\n", switch_dow_int2str(test), xwday, time_match ? "PASS" : "FAIL");
}
if (time_match && xhour) {
int test = tm.tm_hour;
@@ -2735,6 +2758,15 @@ SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond) {
"XML DateTime Check: minute of day[%d] =~ %s (%s)\n", test, xminday, time_match ? "PASS" : "FAIL");
}
if (time_match && xtod) {
int test = (tm.tm_hour * 60 * 60) + (tm.tm_min * 60) + tm.tm_sec;
char tmpdate[10];
switch_snprintf(tmpdate, 6, "%d:%d:%d", tm.tm_hour, tm.tm_min, tm.tm_sec);
time_match = switch_tod_cmp(xtod, test);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
"XML DateTime Check: time of day[%s] =~ %s (%s)\n", tmpdate, xtod, time_match ? "PASS" : "FAIL");
}
return time_match;
}
+193
View File
@@ -0,0 +1,193 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Pawel Pierscionek <pawel@voiceworks.pl>
* Bret McDanel <trixter AT 0xdecafbad.com>
*
*
* tone2wav.c -- Generate a .wav from teletone spec
*
*/
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif
#ifndef WIN32
#ifdef HAVE_SETRLIMIT
#include <sys/resource.h>
#endif
#endif
#include <switch.h>
#include <switch_version.h>
/* Picky compiler */
#ifdef __ICC
#pragma warning (disable:167)
#endif
static int teletone_handler(teletone_generation_session_t *ts, teletone_tone_map_t *map)
{
switch_file_handle_t *fh = (switch_file_handle_t *) ts->user_data;
int wrote;
switch_size_t len;
wrote = teletone_mux_tones(ts, map);
len = wrote;
if (switch_core_file_write(fh, ts->buffer, &len) != SWITCH_STATUS_SUCCESS) {
return -1;
}
return 0;
}
#define fail() r = 255; goto end
/* the main application entry point */
int main(int argc, char *argv[])
{
teletone_generation_session_t ts;
int file_flags = SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT;
int r = 0;
int rate = 8000;
char *file = NULL, *script = NULL;
switch_file_handle_t fh = { 0 };
const char *err = NULL;
switch_bool_t verbose = SWITCH_FALSE;
int i = 0, c = 1, help = 0;
for(i = 1; i < argc; i++) {
if (!strstr(argv[i], "-")) break;
if (!strcmp(argv[i], "-v")) {
verbose = SWITCH_TRUE;
}
if (!strcmp(argv[i], "-s")) {
c = 2;
}
if (!strcmp(argv[i], "-h")) {
help = 1;
}
if (!strncmp(argv[i], "-R", 2)) {
char *p = argv[i] + 2;
if (p) {
int tmp = atoi(p);
if (tmp > 0) {
rate = tmp;
}
}
}
}
if (argc - i != 2 || help) {
char *app = NULL;
if (!help) printf("Invalid input!\n");
if ((app = strrchr(argv[0], '/'))) {
app++;
} else {
app = argv[0];
}
printf("USAGE: %s [options] <file> <tones>\n", app);
printf("================================================================================\n");
printf("Options:\n"
"-s\t\tStereo\n"
"-h\t\tHelp\n"
"-R<rate>\tSet Rate (8000,16000,32000,48000) etc.\n"
"-v\t\tVerbose Logging\n"
"<file>\t\tAny file supported by libsndfile\n"
"<tones>\t\tA valid teletone script http://wiki.freeswitch.org/wiki/TGML"
"\n\n\n"
);
return 255;
}
file = argv[i];
script = argv[i+1];
if (switch_core_init(SCF_MINIMAL, verbose, &err) != SWITCH_STATUS_SUCCESS) {
printf("Cannot init core [%s]\n", err);
fail();
}
switch_loadable_module_init(SWITCH_FALSE);
if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) "mod_sndfile", SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
printf("Cannot init mod_sndfile [%s]\n", err);
fail();
}
if (switch_core_file_open(&fh, file, c, rate, file_flags, NULL) != SWITCH_STATUS_SUCCESS) {
printf("Cannot open file %s\n", file);
fail();
}
teletone_init_session(&ts, 0, teletone_handler, &fh);
ts.rate = rate;
ts.channels = c;
ts.duration = 250 * (rate / 1000 / c);
ts.wait = 50 * (rate / 1000 / c);
if (verbose) {
ts.debug = 10;
ts.debug_stream = stdout;
}
teletone_run(&ts, script);
teletone_destroy_session(&ts);
switch_core_file_close(&fh);
printf("File: %s generated.....\n\nPlease support:\nFreeSWITCH http://www.freeswitch.org\nClueCon http://www.cluecon.com\n", file);
end:
switch_core_destroy();
return r;
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
*/