Merge branch 'master' into smgmaster

This commit is contained in:
Moises Silva
2011-09-15 09:53:55 -04:00
47 changed files with 1601 additions and 900 deletions
@@ -2317,17 +2317,25 @@ SWITCH_STANDARD_API(dual_transfer_function)
dest1 = argv[1];
dest2= argv[2];
if ((dp1 = strchr(dest1, '/'))) {
if ((dp1 = strstr(dest1, "/inline")) && *(dp1 + 7) == '\0') {
*dp1++ = '\0';
if ((context1 = strchr(dp1, '/'))) {
*context1++ = '\0';
} else {
if ((dp1 = strchr(dest1, '/'))) {
*dp1++ = '\0';
if ((context1 = strchr(dp1, '/'))) {
*context1++ = '\0';
}
}
}
if ((dp2 = strchr(dest2, '/'))) {
if ((dp2 = strstr(dest1, "/inline")) && *(dp2 + 7) == '\0') {
*dp2++ = '\0';
if ((context2 = strchr(dp2, '/'))) {
*context2++ = '\0';
} else {
if ((dp2 = strchr(dest2, '/'))) {
*dp2++ = '\0';
if ((context2 = strchr(dp2, '/'))) {
*context2++ = '\0';
}
}
}
@@ -3302,8 +3310,7 @@ SWITCH_STANDARD_API(break_function)
if (both) {
const char *quuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
if (quuid) {
qsession = switch_core_session_locate(quuid);
if (quuid && (qsession = switch_core_session_locate(quuid))) {
qchannel = switch_core_session_get_channel(qsession);
}
}
@@ -3899,7 +3906,7 @@ SWITCH_STANDARD_API(alias_function)
return SWITCH_STATUS_SUCCESS;
}
#define SHOW_SYNTAX "codec|endpoint|application|api|dialplan|file|timer|calls [count]|channels [count|like <match string>]|distinct_channels|aliases|complete|chat|management|modules|nat_map|say|interfaces|interface_types|tasks|limits"
#define SHOW_SYNTAX "codec|endpoint|application|api|dialplan|file|timer|calls [count]|channels [count|like <match string>]|calls|detailed_calls|bridged_calls|detailed_bridged_calls|aliases|complete|chat|management|modules|nat_map|say|interfaces|interface_types|tasks|limits"
SWITCH_STANDARD_API(show_function)
{
char sql[1024];
@@ -3988,7 +3995,7 @@ SWITCH_STANDARD_API(show_function)
sprintf(sql, "select name, description, syntax, ikey from interfaces where hostname='%s' and type = '%s' and description != '' order by type,name", hostname, command);
}
} else if (!strcasecmp(command, "calls")) {
sprintf(sql, "select * from calls where hostname='%s' order by call_created_epoch", hostname);
sprintf(sql, "select * from basic_calls where hostname='%s' order by call_created_epoch", hostname);
if (argv[1] && !strcasecmp(argv[1], "count")) {
holder.justcount = 1;
if (argv[3] && !strcasecmp(argv[2], "as")) {
@@ -4036,14 +4043,18 @@ SWITCH_STANDARD_API(show_function)
as = argv[3];
}
}
} else if (!strcasecmp(command, "distinct_channels")) {
sprintf(sql, "select * from channels left join calls on "
"channels.uuid=calls.caller_uuid where channels.hostname='%s' and channels.uuid not in (select callee_uuid from calls where hostname='%s') order by created_epoch", hostname, hostname);
} else if (!strcasecmp(command, "detailed_calls")) {
sprintf(sql, "select * from detailed_calls where hostname='%s' order by created_epoch", hostname);
if (argv[2] && !strcasecmp(argv[1], "as")) {
as = argv[2];
}
} else if (!strcasecmp(command, "detailed_calls")) {
sprintf(sql, "select * from detailed_calls where hostname='%s' order by created_epoch", hostname);
} else if (!strcasecmp(command, "bridged_calls")) {
sprintf(sql, "select * from basic_calls where b_uuid is not null and hostname='%s' order by created_epoch", hostname);
if (argv[2] && !strcasecmp(argv[1], "as")) {
as = argv[2];
}
} else if (!strcasecmp(command, "detailed_bridged_calls")) {
sprintf(sql, "select * from detailed_calls where b_uuid is not null and hostname='%s' order by created_epoch", hostname);
if (argv[2] && !strcasecmp(argv[1], "as")) {
as = argv[2];
}
@@ -4433,6 +4444,9 @@ SWITCH_STANDARD_API(uuid_fileman_function)
if (switch_ivr_get_file_handle(psession, &fh) == SWITCH_STATUS_SUCCESS) {
switch_ivr_process_fh(psession, cmd, fh);
switch_ivr_release_file_handle(psession, &fh);
stream->write_function(stream, "+OK\n");
} else {
stream->write_function(stream, "-ERR No File Handle!\n");
}
switch_core_session_rwunlock(psession);
@@ -5992,7 +5992,7 @@ SWITCH_STANDARD_APP(conference_function)
}
if (pstatus != SWITCH_STATUS_SUCCESS && pstatus != SWITCH_STATUS_BREAK) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot ask the user for a pin, ending call");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot ask the user for a pin, ending call\n");
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
@@ -735,7 +735,9 @@ static void terminate_session(switch_core_session_t **session, int line, switch_
}
switch_mutex_lock(tech_pvt->flag_mutex);
switch_set_flag(tech_pvt, TFLAG_TERM);
if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
switch_set_flag(tech_pvt, TFLAG_TERM);
}
switch_set_flag(tech_pvt, TFLAG_BYE);
switch_clear_flag(tech_pvt, TFLAG_IO);
switch_mutex_unlock(tech_pvt->flag_mutex);
+31 -3
View File
@@ -2016,8 +2016,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "SEND");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Callee-Name", name);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Callee-Number", number);
switch_channel_set_profile_var(channel, "callee_id_name", name);
switch_channel_set_profile_var(channel, "callee_id_number", number);
if (uuid) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid);
}
@@ -3434,6 +3436,17 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
goto done;
}
if (!strcasecmp(argv[1], "capture")) {
if (argc > 2) {
int value = switch_true(argv[2]);
nua_set_params(profile->nua, TPTAG_CAPT(value ? mod_sofia_globals.capture_server : NULL), TAG_END());
stream->write_function(stream, "%s sip capturing on %s", value ? "Enabled" : "Disabled", profile->name);
} else {
stream->write_function(stream, "Usage: sofia profile <name> capture <on/off>\n");
}
goto done;
}
if (!strcasecmp(argv[1], "watchdog")) {
if (argc > 2) {
int value = switch_true(argv[2]);
@@ -3995,6 +4008,7 @@ SWITCH_STANDARD_API(sofia_function)
static const char usage_string[] = "USAGE:\n"
"--------------------------------------------------------------------------------\n"
"sofia global siptrace <on|off>\n"
"sofia capture <on|off>\n"
" watchdog <on|off>\n\n"
"sofia profile <name> [start | stop | restart | rescan]\n"
" flush_inbound_reg [<call_id> | <[user]@domain>] [reboot]\n"
@@ -4003,6 +4017,7 @@ SWITCH_STANDARD_API(sofia_function)
" killgw <gateway name>\n"
" [stun-auto-disable | stun-enabled] [true | false]]\n"
" siptrace <on|off>\n"
" capture <on|off>\n"
" watchdog <on|off>\n\n"
"sofia <status|xmlstatus> profile <name> [reg <contact str>] | [pres <pres str>] | [user <user@domain>]\n"
"sofia <status|xmlstatus> gateway <name>\n\n"
@@ -4062,6 +4077,7 @@ SWITCH_STANDARD_API(sofia_function)
goto done;
} else if (!strcasecmp(argv[0], "global")) {
int ston = -1;
int cton = -1;
int wdon = -1;
if (argc > 1) {
@@ -4098,6 +4114,12 @@ SWITCH_STANDARD_API(sofia_function)
}
}
if (!strcasecmp(argv[1], "capture")) {
if (argc > 2) {
cton = switch_true(argv[2]);
}
}
if (!strcasecmp(argv[1], "watchdog")) {
if (argc > 2) {
wdon = switch_true(argv[2]);
@@ -4108,11 +4130,14 @@ SWITCH_STANDARD_API(sofia_function)
if (ston != -1) {
sofia_glue_global_siptrace(ston);
stream->write_function(stream, "+OK Global siptrace %s", ston ? "on" : "off");
} else if (cton != -1) {
sofia_glue_global_capture(cton);
stream->write_function(stream, "+OK Global capture %s", cton ? "on" : "off");
} else if (wdon != -1) {
sofia_glue_global_watchdog(wdon);
stream->write_function(stream, "+OK Global watchdog %s", wdon ? "on" : "off");
} else {
stream->write_function(stream, "-ERR Usage: siptrace <on|off>|watchdog <on|off>|debug <sla|presence|none");
stream->write_function(stream, "-ERR Usage: siptrace <on|off>|capture <on|off>|watchdog <on|off>|debug <sla|presence|none");
}
goto done;
@@ -5305,6 +5330,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
switch_console_set_complete("add sofia tracelevel ::[console:alert:crit:err:warning:notice:info:debug");
switch_console_set_complete("add sofia global siptrace ::[on:off");
switch_console_set_complete("add sofia global capture ::[on:off");
switch_console_set_complete("add sofia global watchdog ::[on:off");
switch_console_set_complete("add sofia global debug ::[presence:sla:none");
@@ -5325,6 +5351,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
switch_console_set_complete("add sofia profile ::sofia::list_profiles killgw ::sofia::list_profile_gateway");
switch_console_set_complete("add sofia profile ::sofia::list_profiles siptrace on");
switch_console_set_complete("add sofia profile ::sofia::list_profiles siptrace off");
switch_console_set_complete("add sofia profile ::sofia::list_profiles capture on");
switch_console_set_complete("add sofia profile ::sofia::list_profiles capture off");
switch_console_set_complete("add sofia profile ::sofia::list_profiles watchdog on");
switch_console_set_complete("add sofia profile ::sofia::list_profiles watchdog off");
+6 -2
View File
@@ -257,7 +257,8 @@ typedef enum {
PFLAG_NDLB_TO_IN_200_CONTACT = (1 << 0),
PFLAG_NDLB_BROKEN_AUTH_HASH = (1 << 1),
PFLAG_NDLB_SENDRECV_IN_SESSION = (1 << 2),
PFLAG_NDLB_ALLOW_BAD_IANANAME = (1 << 3)
PFLAG_NDLB_ALLOW_BAD_IANANAME = (1 << 3),
PFLAG_NDLB_ALLOW_NONDUP_SDP = (1 << 4)
} sofia_NDLB_t;
typedef enum {
@@ -314,12 +315,13 @@ typedef enum {
TFLAG_NOREPLY,
TFLAG_LIBERAL_DTMF,
TFLAG_GOT_ACK,
TFLAG_CAPTURE,
/* No new flags below this line */
TFLAG_MAX
} TFLAGS;
#define SOFIA_MAX_MSG_QUEUE 51
#define SOFIA_MSG_QUEUE_SIZE 1000
#define SOFIA_MSG_QUEUE_SIZE 5000
struct mod_sofia_globals {
switch_memory_pool_t *pool;
@@ -353,6 +355,7 @@ struct mod_sofia_globals {
int auto_restart;
int auto_nat;
int tracelevel;
char *capture_server;
int rewrite_multicasted_fs_path;
};
extern struct mod_sofia_globals mod_sofia_globals;
@@ -1114,6 +1117,7 @@ void sofia_glue_tech_simplify(private_object_t *tech_pvt);
switch_console_callback_match_t *sofia_reg_find_reg_url_multi(sofia_profile_t *profile, const char *user, const char *host);
switch_bool_t sofia_glue_profile_exists(const char *key);
void sofia_glue_global_siptrace(switch_bool_t on);
void sofia_glue_global_capture(switch_bool_t on);
void sofia_glue_global_watchdog(switch_bool_t on);
void sofia_glue_proxy_codec(switch_core_session_t *session, const char *r_sdp);
switch_status_t sofia_glue_sdp_map(const char *r_sdp, switch_event_t **fmtp, switch_event_t **pt);
+54 -16
View File
@@ -665,7 +665,11 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
return;
}
if (sip->sip_to) {
number = (char *) switch_channel_get_variable(channel, "callee_id_number");
name = (char *) switch_channel_get_variable(channel, "callee_id_name");
if (zstr(number) && sip->sip_to) {
number = sip->sip_to->a_url->url_user;
}
@@ -738,18 +742,6 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
goto end;
}
if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Callee-Name", name);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Callee-Number", number);
if (uuid) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid);
}
switch_channel_event_set_data(channel, event);
switch_event_fire(&event);
}
caller_profile = switch_channel_get_caller_profile(channel);
if (!strcmp(caller_profile->callee_id_name, name) && !strcmp(caller_profile->callee_id_number, number)) {
@@ -766,6 +758,17 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
}
if (send) {
if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV");
if (uuid) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid);
}
switch_channel_event_set_data(channel, event);
switch_event_fire(&event);
}
sofia_send_callee_id(session, NULL, NULL);
}
@@ -1789,6 +1792,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
NTATAG_SERVER_RPORT(profile->server_rport_level),
NTATAG_CLIENT_RPORT(profile->client_rport_level),
TPTAG_LOG(sofia_test_flag(profile, TFLAG_TPORT_LOG)),
TPTAG_CAPT(sofia_test_flag(profile, TFLAG_CAPTURE) ? mod_sofia_globals.capture_server : NULL),
TAG_IF(sofia_test_pflag(profile, PFLAG_SIPCOMPACT),
NTATAG_SIPFLAGS(MSG_DO_COMPACT)),
TAG_IF(profile->timer_t1, NTATAG_SIP_T1(profile->timer_t1)),
@@ -2709,6 +2713,9 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
mod_sofia_globals.rewrite_multicasted_fs_path = SWITCH_FALSE;
}
}
else if (!strcasecmp(var, "capture-server")) {
mod_sofia_globals.capture_server = switch_core_strdup(mod_sofia_globals.pool, val);
}
}
}
@@ -2787,6 +2794,13 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
sofia_clear_flag(profile, TFLAG_TPORT_LOG);
}
nua_set_params(profile->nua, TPTAG_LOG(sofia_test_flag(profile, TFLAG_TPORT_LOG)), TAG_END());
} else if (!strcasecmp(var, "sip-capture")) {
if (switch_true(val)) {
sofia_set_flag(profile, TFLAG_CAPTURE);
} else {
sofia_clear_flag(profile, TFLAG_CAPTURE);
}
nua_set_params(profile->nua, TPTAG_CAPT(sofia_test_flag(profile, TFLAG_CAPTURE) ? mod_sofia_globals.capture_server : NULL), TAG_END());
} else if (!strcasecmp(var, "send-message-query-on-register")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER);
@@ -2954,6 +2968,12 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
} else {
profile->ndlb &= ~PFLAG_NDLB_ALLOW_BAD_IANANAME;
}
} else if (!strcasecmp(var, "NDLB-allow-nondup-sdp")) {
if (switch_true(val)) {
profile->ndlb |= PFLAG_NDLB_ALLOW_NONDUP_SDP;
} else {
profile->ndlb &= ~PFLAG_NDLB_ALLOW_NONDUP_SDP;
}
} else if (!strcasecmp(var, "aggressive-nat-detection")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION);
@@ -3384,6 +3404,9 @@ switch_status_t config_sofia(int reload, char *profile_name)
mod_sofia_globals.rewrite_multicasted_fs_path = SWITCH_FALSE;
}
}
else if (!strcasecmp(var, "capture-server")) {
mod_sofia_globals.capture_server = switch_core_strdup(mod_sofia_globals.pool, val);
}
}
}
@@ -3462,6 +3485,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
profile->local_network = "localnet.auto";
sofia_set_flag(profile, TFLAG_ENABLE_SOA);
sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
profile->ndlb |= PFLAG_NDLB_ALLOW_NONDUP_SDP;
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
@@ -3475,6 +3499,9 @@ switch_status_t config_sofia(int reload, char *profile_name)
profile->shutdown_type = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "sip-trace") && switch_true(val)) {
sofia_set_flag(profile, TFLAG_TPORT_LOG);
} else if (!strcasecmp(var, "sip-capture") && switch_true(val)) {
sofia_set_flag(profile, TFLAG_CAPTURE);
nua_set_params(profile->nua, TPTAG_CAPT(mod_sofia_globals.capture_server), TAG_END());
} else if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) {
if (switch_odbc_available()) {
profile->odbc_dsn = switch_core_strdup(profile->pool, val);
@@ -3952,6 +3979,12 @@ switch_status_t config_sofia(int reload, char *profile_name)
} else {
profile->ndlb &= ~PFLAG_NDLB_ALLOW_BAD_IANANAME;
}
} else if (!strcasecmp(var, "NDLB-allow-nondup-sdp")) {
if (switch_true(val)) {
profile->ndlb |= PFLAG_NDLB_ALLOW_NONDUP_SDP;
} else {
profile->ndlb &= ~PFLAG_NDLB_ALLOW_NONDUP_SDP;
}
} else if (!strcasecmp(var, "pass-rfc2833")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_PASS_RFC2833);
@@ -5074,11 +5107,13 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
if (session) {
if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA) || switch_channel_test_flag(channel, CF_ANSWERED)) && (status == 180 || status == 183)) {
if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA) || switch_channel_test_flag(channel, CF_ANSWERED)) && (status == 180 || status == 183) && !r_sdp) {
/* Must you send 180 after 183 w/sdp ? sheesh */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel %s skipping state [%s][%d]\n",
switch_channel_get_name(channel), nua_callstate_name(ss_state), status);
goto done;
} else if (switch_channel_test_flag(channel, CF_EARLY_MEDIA) && (status == 180 || status == 183) && r_sdp) {
sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel %s entering state [%s][%d]\n",
@@ -5088,7 +5123,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
sdp_parser_t *parser;
sdp_session_t *sdp;
if (!zstr(tech_pvt->remote_sdp_str) && !strcmp(tech_pvt->remote_sdp_str, r_sdp)) {
if (!(profile->ndlb & PFLAG_NDLB_ALLOW_NONDUP_SDP) || (!zstr(tech_pvt->remote_sdp_str) && !strcmp(tech_pvt->remote_sdp_str, r_sdp))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Duplicate SDP\n%s\n", r_sdp);
is_dup_sdp = 1;
} else {
@@ -5176,7 +5211,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
sofia_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
switch_channel_mark_pre_answered(channel);
sofia_set_flag(tech_pvt, TFLAG_SDP);
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA) || sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
goto done;
}
@@ -5597,6 +5632,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Processing updated SDP\n");
sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error!\n");
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
@@ -5804,6 +5841,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
switch_snprintf(st, sizeof(st), "%d", cause);
switch_channel_set_variable(channel, "sip_term_cause", st);
switch_channel_hangup(channel, cause);
ss_state = nua_callstate_terminated;
}
+46 -7
View File
@@ -208,6 +208,7 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen,
if (!noptime) {
if (!cur_ptime) {
#if 0
if (ptime) {
if (ptime != imp->microseconds_per_packet / 1000) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
@@ -225,6 +226,11 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen,
} else {
ptime = imp->microseconds_per_packet / 1000;
}
#else
if (!ptime) {
ptime = imp->microseconds_per_packet / 1000;
}
#endif
} else {
if ((imp->microseconds_per_packet / 1000) != cur_ptime) {
continue;
@@ -544,7 +550,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
} else if (tech_pvt->num_codecs) {
int i;
int cur_ptime = 0, this_ptime = 0, cng_type = 0;
const char *mult;
if (!sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) && tech_pvt->cng_pt && use_cng) {
cng_type = tech_pvt->cng_pt;
@@ -553,8 +559,10 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
tech_pvt->cng_pt = 0;
}
}
if (!switch_true(switch_channel_get_variable(tech_pvt->channel, "sdp_m_per_ptime"))) {
mult = switch_channel_get_variable(tech_pvt->channel, "sdp_m_per_ptime");
if (mult && switch_false(mult)) {
char *bp = buf;
if ((!zstr(tech_pvt->local_crypto_key) && sofia_test_flag(tech_pvt, TFLAG_SECURE))) {
@@ -1855,7 +1863,12 @@ char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix
char *extra_headers = NULL;
switch_stream_handle_t stream = { 0 };
switch_event_header_t *hi = NULL;
const char *exclude_regex = NULL;
switch_regex_t *re = NULL;
int ovector[30] = {0};
int proceed;
exclude_regex = switch_channel_get_variable(channel, "exclude_outgoing_extra_header");
SWITCH_STANDARD_STREAM(stream);
if ((hi = switch_channel_variable_first(channel))) {
for (; hi; hi = hi->next) {
@@ -1863,8 +1876,13 @@ char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix
char *value = (char *) hi->value;
if (!strncasecmp(name, prefix, strlen(prefix))) {
const char *hname = name + strlen(prefix);
stream.write_function(&stream, "%s: %s\r\n", hname, value);
if ( !exclude_regex || !(proceed = switch_regex_perform(name, exclude_regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
const char *hname = name + strlen(prefix);
stream.write_function(&stream, "%s: %s\r\n", hname, value);
switch_regex_safe_free(re);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Ignoring Extra Header [%s] , matches exclude_outgoing_extra_header [%s]\n", name, exclude_regex);
}
}
}
switch_channel_variable_last(channel);
@@ -3031,7 +3049,6 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
flags &= ~SWITCH_RTP_FLAG_BYTESWAP;
}
if (tech_pvt->rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
//const char *ip = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE);
//const char *port = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE);
@@ -3099,7 +3116,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
const char *rport = NULL;
switch_port_t remote_rtcp_port = 0;
sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
if ((rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_audio_rtcp_port"))) {
remote_rtcp_port = (switch_port_t)atoi(rport);
@@ -3580,6 +3597,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
end:
sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
sofia_glue_tech_track(tech_pvt->profile, tech_pvt->session);
@@ -5240,6 +5258,27 @@ void sofia_glue_global_siptrace(switch_bool_t on)
}
void sofia_glue_global_capture(switch_bool_t on)
{
switch_hash_index_t *hi;
const void *var;
void *val;
sofia_profile_t *pptr;
switch_mutex_lock(mod_sofia_globals.hash_mutex);
if (mod_sofia_globals.profile_hash) {
for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
switch_hash_this(hi, &var, NULL, &val);
if ((pptr = (sofia_profile_t *) val)) {
nua_set_params(pptr->nua, TPTAG_CAPT(on ? mod_sofia_globals.capture_server : NULL), TAG_END());
}
}
}
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
}
void sofia_glue_global_watchdog(switch_bool_t on)
{
switch_hash_index_t *hi;
+11 -2
View File
@@ -1831,8 +1831,17 @@ void sofia_reg_handle_sip_r_register(int status,
const char *new_expires;
uint32_t expi;
if (contact->m_next) {
const char *sipip = profile->extsipip ? profile->extsipip : profile->sipip;
for (; contact && strcasecmp(contact->m_url->url_host, sipip); contact = contact->m_next);
char *full;
for (; contact; contact = contact->m_next) {
if ((full = sip_header_as_string(nh->nh_home, (void *) contact))) {
if (switch_stristr(sofia_private->gateway->register_contact, full)) {
break;
}
su_free(nh->nh_home, full);
}
}
}
if (!contact) {
+15
View File
@@ -2606,6 +2606,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_caller_extension_masquerade(switc
SWITCH_DECLARE(void) switch_channel_flip_cid(switch_channel_t *channel)
{
switch_event_t *event;
switch_mutex_lock(channel->profile_mutex);
if (channel->caller_profile->callee_id_name) {
switch_channel_set_variable(channel, "pre_transfer_caller_id_name", channel->caller_profile->caller_id_name);
@@ -2620,6 +2622,19 @@ SWITCH_DECLARE(void) switch_channel_flip_cid(switch_channel_t *channel)
channel->caller_profile->callee_id_number = SWITCH_BLANK_STRING;
switch_mutex_unlock(channel->profile_mutex);
if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV");
if (uuid) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid);
}
switch_channel_event_set_data(channel, event);
switch_event_fire(&event);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_INFO, "%s Flipping CID from \"%s\" <%s> to \"%s\" <%s>\n",
switch_channel_get_name(channel),
switch_str_nil(switch_channel_get_variable(channel, "pre_transfer_caller_id_name")),
+4 -1
View File
@@ -503,7 +503,7 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
if (channel) {
const char *val;
switch_codec_t *vid_read_codec = NULL, *read_codec = switch_core_session_get_read_codec(session);
const char *max_forwards = switch_core_session_sprintf(session, "%d", forwardval);
const char *ep, *max_forwards = switch_core_session_sprintf(session, "%d", forwardval);
switch_channel_set_variable(peer_channel, SWITCH_MAX_FORWARDS_VARIABLE, max_forwards);
@@ -523,6 +523,9 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
switch_snprintf(tmp, sizeof(tmp), "%s%s", rc, vrc);
switch_channel_set_variable(peer_channel, SWITCH_ORIGINATOR_CODEC_VARIABLE, tmp);
} else if ((ep = switch_channel_get_variable(channel, "ep_codec_string"))) {
printf("SET [%s] [%s]\n", switch_channel_get_name(peer_channel), ep);
switch_channel_set_variable(peer_channel, SWITCH_ORIGINATOR_CODEC_VARIABLE, ep);
}
switch_channel_set_variable(peer_channel, SWITCH_ORIGINATOR_VARIABLE, switch_core_session_get_uuid(session));
+170 -208
View File
@@ -1206,28 +1206,20 @@ static void core_event_handler(switch_event_t *event)
const char *uuid = switch_event_get_header(event, "unique-id");
if (uuid) {
new_sql() = switch_mprintf("delete from channels where uuid='%q' and hostname='%q'",
uuid, switch_core_get_switchname());
new_sql() = switch_mprintf("delete from channels where uuid='%q'",
uuid);
new_sql() = switch_mprintf("delete from calls where (caller_uuid='%q' or callee_uuid='%q') and hostname='%q'",
uuid, uuid, switch_core_get_switchname());
new_sql() = switch_mprintf("delete from calls where (caller_uuid='%q' or callee_uuid='%q')",
uuid, uuid);
}
}
break;
case SWITCH_EVENT_CHANNEL_UUID:
{
new_sql() = switch_mprintf("update channels set uuid='%q' where uuid='%q' and hostname='%q';"
"update calls set caller_uuid='%q' where caller_uuid='%q' and hostname='%q';"
"update calls set callee_uuid='%q' where callee_uuid='%q' and hostname='%q'",
new_sql() = switch_mprintf("update channels set uuid='%q' where uuid='%q'",
switch_event_get_header_nil(event, "unique-id"),
switch_event_get_header_nil(event, "old-unique-id"),
switch_core_get_switchname(),
switch_event_get_header_nil(event, "unique-id"),
switch_event_get_header_nil(event, "old-unique-id"),
switch_core_get_switchname(),
switch_event_get_header_nil(event, "unique-id"),
switch_event_get_header_nil(event, "old-unique-id"), switch_core_get_switchname()
switch_event_get_header_nil(event, "old-unique-id")
);
break;
}
@@ -1249,26 +1241,26 @@ static void core_event_handler(switch_event_t *event)
new_sql() =
switch_mprintf
("update channels set read_codec='%q',read_rate='%q',read_bit_rate='%q',write_codec='%q',write_rate='%q',write_bit_rate='%q' where uuid='%q' and hostname='%q'",
("update channels set read_codec='%q',read_rate='%q',read_bit_rate='%q',write_codec='%q',write_rate='%q',write_bit_rate='%q' where uuid='%q'",
switch_event_get_header_nil(event, "channel-read-codec-name"),
switch_event_get_header_nil(event, "channel-read-codec-rate"),
switch_event_get_header_nil(event, "channel-read-codec-bit-rate"),
switch_event_get_header_nil(event, "channel-write-codec-name"),
switch_event_get_header_nil(event, "channel-write-codec-rate"),
switch_event_get_header_nil(event, "channel-write-codec-bit-rate"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
break;
case SWITCH_EVENT_CHANNEL_HOLD:
case SWITCH_EVENT_CHANNEL_UNHOLD:
case SWITCH_EVENT_CHANNEL_EXECUTE: {
new_sql() = switch_mprintf("update channels set application='%q',application_data='%q',"
"presence_id='%q',presence_data='%q' where uuid='%q' and hostname='%q'",
"presence_id='%q',presence_data='%q' where uuid='%q'",
switch_event_get_header_nil(event, "application"),
switch_event_get_header_nil(event, "application-data"),
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname()
switch_event_get_header_nil(event, "unique-id")
);
}
@@ -1278,20 +1270,20 @@ static void core_event_handler(switch_event_t *event)
{
if ((extra_cols = parse_presence_data_cols(event))) {
new_sql() = switch_mprintf("update channels set "
"presence_id='%q',presence_data='%q', call_uuid='%q',%s where uuid='%q' and hostname='%q'",
"presence_id='%q',presence_data='%q', call_uuid='%q',%s where uuid='%q'",
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "channel-call-uuid"),
extra_cols,
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
free(extra_cols);
} else {
new_sql() = switch_mprintf("update channels set "
"presence_id='%q',presence_data='%q', call_uuid='%q' where uuid='%q' and hostname='%q'",
"presence_id='%q',presence_data='%q', call_uuid='%q' where uuid='%q'",
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "channel-call-uuid"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
}
}
@@ -1299,44 +1291,15 @@ static void core_event_handler(switch_event_t *event)
break;
case SWITCH_EVENT_CALL_UPDATE:
{
const char *name = NULL, *number = NULL, *direction;
int recv = 0;
direction = switch_event_get_header(event, "direction");
if (direction && strcasecmp(direction, "send")) {
recv = 1;
name = switch_event_get_header(event, "callee-name");
number = switch_event_get_header(event, "callee-number");
}
if (!name) {
name = switch_event_get_header(event, "caller-callee-id-name");
}
if (!number) {
number = switch_event_get_header(event, "caller-callee-id-number");
}
if (!zstr(name) && !zstr(number)) {
new_sql() = switch_mprintf("update channels set state='%s',callstate='%s',callee_name='%q',"
"callee_num='%q',callee_direction='%q' where uuid='%s' and hostname='%q'",
switch_event_get_header_nil(event, "channel-state"),
switch_event_get_header_nil(event, "channel-call-state"),
switch_str_nil(name),
switch_str_nil(number),
switch_event_get_header_nil(event, "direction"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
name = switch_event_get_header(event, "callee-name");
number = switch_event_get_header(event, "callee-number");
if (name && number && recv) {
new_sql() = switch_mprintf("update calls set callee_cid_name='%q',callee_cid_num='%q' where caller_uuid='%q'",
name, number, switch_event_get_header_nil(event, "unique-id"));
}
}
new_sql() = switch_mprintf("update channels set callee_name='%q',callee_num='%q',callee_direction='%q',"
"cid_name='%q',cid_num='%q' where uuid='%s'",
switch_event_get_header_nil(event, "caller-callee-id-name"),
switch_event_get_header_nil(event, "caller-callee-id-number"),
switch_event_get_header_nil(event, "direction"),
switch_event_get_header_nil(event, "caller-caller-id-name"),
switch_event_get_header_nil(event, "caller-caller-id-number"),
switch_event_get_header_nil(event, "unique-id")
);
}
break;
case SWITCH_EVENT_CHANNEL_CALLSTATE:
@@ -1349,9 +1312,9 @@ static void core_event_handler(switch_event_t *event)
}
if (callstate != CCS_DOWN && callstate != CCS_HANGUP) {
new_sql() = switch_mprintf("update channels set callstate='%q' where uuid='%q' and hostname='%q'",
new_sql() = switch_mprintf("update channels set callstate='%q' where uuid='%q'",
switch_event_get_header_nil(event, "channel-call-state"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
}
}
@@ -1373,12 +1336,14 @@ static void core_event_handler(switch_event_t *event)
break;
case CS_ROUTING:
if ((extra_cols = parse_presence_data_cols(event))) {
new_sql() = switch_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',"
new_sql() = switch_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',callee_name='%q',callee_num='%q',"
"ip_addr='%s',dest='%q',dialplan='%q',context='%q',presence_id='%q',presence_data='%q',%s "
"where uuid='%s' and hostname='%q'",
"where uuid='%s'",
switch_event_get_header_nil(event, "channel-state"),
switch_event_get_header_nil(event, "caller-caller-id-name"),
switch_event_get_header_nil(event, "caller-caller-id-number"),
switch_event_get_header_nil(event, "caller-callee-id-name"),
switch_event_get_header_nil(event, "caller-callee-id-number"),
switch_event_get_header_nil(event, "caller-network-addr"),
switch_event_get_header_nil(event, "caller-destination-number"),
switch_event_get_header_nil(event, "caller-dialplan"),
@@ -1386,28 +1351,30 @@ static void core_event_handler(switch_event_t *event)
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
extra_cols,
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
free(extra_cols);
} else {
new_sql() = switch_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',"
new_sql() = switch_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',callee_name='%q',callee_num='%q',"
"ip_addr='%s',dest='%q',dialplan='%q',context='%q',presence_id='%q',presence_data='%q' "
"where uuid='%s' and hostname='%q'",
"where uuid='%s'",
switch_event_get_header_nil(event, "channel-state"),
switch_event_get_header_nil(event, "caller-caller-id-name"),
switch_event_get_header_nil(event, "caller-caller-id-number"),
switch_event_get_header_nil(event, "caller-callee-id-name"),
switch_event_get_header_nil(event, "caller-callee-id-number"),
switch_event_get_header_nil(event, "caller-network-addr"),
switch_event_get_header_nil(event, "caller-destination-number"),
switch_event_get_header_nil(event, "caller-dialplan"),
switch_event_get_header_nil(event, "caller-context"),
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
}
break;
default:
new_sql() = switch_mprintf("update channels set state='%s' where uuid='%s' and hostname='%q'",
new_sql() = switch_mprintf("update channels set state='%s' where uuid='%s'",
switch_event_get_header_nil(event, "channel-state"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
break;
}
@@ -1417,60 +1384,19 @@ static void core_event_handler(switch_event_t *event)
}
case SWITCH_EVENT_CHANNEL_BRIDGE:
{
const char *callee_cid_name, *callee_cid_num, *direction;
char *func_name;
char *aleg_uuid, *bleg_uuid;
direction = switch_event_get_header(event, "other-leg-direction");
if (direction && !strcasecmp(direction, "outbound")) {
callee_cid_name = switch_event_get_header_nil(event, "Other-Leg-callee-id-name");
callee_cid_num = switch_event_get_header_nil(event, "Other-Leg-callee-id-number");
} else {
callee_cid_name = switch_event_get_header_nil(event, "Other-Leg-caller-id-name");
callee_cid_num = switch_event_get_header_nil(event, "Other-Leg-caller-id-number");
}
new_sql() = switch_mprintf("update channels set call_uuid='%q' where uuid='%s' and hostname='%q'",
new_sql() = switch_mprintf("update channels set call_uuid='%q' where uuid='%s'",
switch_event_get_header_nil(event, "channel-call-uuid"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
if (runtime.odbc_dbtype == DBTYPE_DEFAULT) {
func_name = "function";
}
else {
func_name = "call_function";
}
aleg_uuid = switch_event_get_header_nil(event, "caller-unique-id");
bleg_uuid = switch_event_get_header_nil(event, "Other-Leg-unique-id");
new_sql() = switch_mprintf("update channels set originatee='%s' where uuid='%s'", bleg_uuid, aleg_uuid);
new_sql() = switch_mprintf("update channels set originator='%s' where uuid='%s'", aleg_uuid, bleg_uuid);
new_sql() = switch_mprintf("insert into calls (call_uuid,call_created,call_created_epoch,%s,caller_cid_name,"
"caller_cid_num,caller_dest_num,caller_chan_name,caller_uuid,callee_cid_name,"
"callee_cid_num,callee_dest_num,callee_chan_name,callee_uuid,hostname) "
"values ('%s', '%s', '%ld', '%s','%q','%q','%q','%q','%s','%q','%q','%q','%q','%s','%q')",
func_name,
new_sql() = switch_mprintf("insert into calls (call_uuid,call_created,call_created_epoch,"
"caller_uuid,callee_uuid,hostname) "
"values ('%s','%s','%ld','%q','%q','%q')",
switch_event_get_header_nil(event, "channel-call-uuid"),
switch_event_get_header_nil(event, "event-date-local"),
(long) switch_epoch_time_now(NULL),
switch_event_get_header_nil(event, "event-calling-function"),
switch_event_get_header_nil(event, "caller-caller-id-name"),
switch_event_get_header_nil(event, "caller-caller-id-number"),
switch_event_get_header_nil(event, "caller-destination-number"),
switch_event_get_header_nil(event, "caller-channel-name"),
aleg_uuid,
callee_cid_name,
callee_cid_num,
switch_event_get_header_nil(event, "Other-Leg-destination-number"),
switch_event_get_header_nil(event, "Other-Leg-channel-name"),
bleg_uuid,
switch_event_get_header_nil(event, "caller-unique-id"),
switch_event_get_header_nil(event, "Other-Leg-unique-id"),
switch_core_get_switchname()
);
}
@@ -1479,12 +1405,8 @@ static void core_event_handler(switch_event_t *event)
{
char *uuid = switch_event_get_header_nil(event, "caller-unique-id");
new_sql() = switch_mprintf("delete from calls where (caller_uuid='%q' or callee_uuid='%q') and hostname='%q'",
uuid, uuid, switch_core_get_switchname());
new_sql() = switch_mprintf("update channels set originator=null,originatee=null where uuid='%s' or originator='%s' or originatee='%s'",
uuid, uuid, uuid);
new_sql() = switch_mprintf("delete from calls where (caller_uuid='%q' or callee_uuid='%q')",
uuid, uuid);
break;
}
case SWITCH_EVENT_SHUTDOWN:
@@ -1531,8 +1453,8 @@ static void core_event_handler(switch_event_t *event)
if (zstr(type)) {
break;
}
new_sql() = switch_mprintf("update channels set secure='%s' where uuid='%s' and hostname='%q'",
type, switch_event_get_header_nil(event, "caller-unique-id"), switch_core_get_switchname()
new_sql() = switch_mprintf("update channels set secure='%s' where uuid='%s'",
type, switch_event_get_header_nil(event, "caller-unique-id")
);
break;
}
@@ -1632,35 +1554,22 @@ static char create_channels_sql[] =
" callee_name VARCHAR(1024),\n"
" callee_num VARCHAR(256),\n"
" callee_direction VARCHAR(5),\n"
" call_uuid VARCHAR(256),\n"
" originator VARCHAR(256),\n"
" originatee VARCHAR(256)\n"
" call_uuid VARCHAR(256)\n"
");\n"
"create index ch_hn_index on channels (hostname);\n"
"create index chidx1 on channels (hostname);\n"
"create index uuindex on channels (uuid);\n"
"create index uuindex2 on channels (call_uuid);\n"
"create index uuindex3 on channels (originator);\n"
"create index uuindex4 on channels (originatee);\n";
"create index uuindex2 on channels (call_uuid);\n";
static char create_calls_sql[] =
"CREATE TABLE calls (\n"
" call_uuid VARCHAR(255),\n"
" call_created VARCHAR(128),\n"
" call_created_epoch INTEGER,\n"
" function VARCHAR(1024),\n"
" caller_cid_name VARCHAR(1024),\n"
" caller_cid_num VARCHAR(256),\n"
" caller_dest_num VARCHAR(256),\n"
" caller_chan_name VARCHAR(1024),\n"
" caller_uuid VARCHAR(256),\n"
" callee_cid_name VARCHAR(1024),\n"
" callee_cid_num VARCHAR(256),\n"
" callee_dest_num VARCHAR(256),\n"
" callee_chan_name VARCHAR(1024),\n"
" callee_uuid VARCHAR(256),\n"
" hostname VARCHAR(256)\n"
");\n"
"create index ca_hn_index on calls (hostname);\n"
"create index callsidx1 on calls (hostname);\n"
"create index eruuindex on calls (caller_uuid);\n"
"create index eeuuindex on calls (callee_uuid);\n"
"create index eeuuindex2 on calls (call_uuid);\n";
@@ -1709,67 +1618,119 @@ static char create_registrations_sql[] =
"create index regindex1 on registrations (reg_user,realm,hostname);\n";
static char view_sql[] =
static char detailed_calls_sql[] =
"create view detailed_calls as select "
"a.uuid uuid,\n"
"a.direction direction,\n"
"a.created created,\n"
"a.created_epoch created_epoch,\n"
"a.name name,\n"
"a.state state,\n"
"a.cid_name cid_name,\n"
"a.cid_num cid_num,\n"
"a.ip_addr ip_addr,\n"
"a.dest dest,\n"
"a.application application,\n"
"a.application_data application_data,\n"
"a.dialplan dialplan,\n"
"a.context context,\n"
"a.read_codec read_codec,\n"
"a.read_rate read_rate,\n"
"a.read_bit_rate read_bit_rate,\n"
"a.write_codec write_codec,\n"
"a.write_rate write_rate,\n"
"a.write_bit_rate write_bit_rate,\n"
"a.secure secure,\n"
"a.hostname hostname,\n"
"a.presence_id presence_id,\n"
"a.presence_data presence_data,\n"
"a.callstate callstate,\n"
"a.callee_name callee_name,\n"
"a.callee_num callee_num,\n"
"a.callee_direction callee_direction,\n"
"a.call_uuid call_uuid,\n"
"b.uuid b_uuid,\n"
"b.direction b_direction,\n"
"b.created b_created,\n"
"b.created_epoch b_created_epoch,\n"
"b.name b_name,\n"
"b.state b_state,\n"
"b.cid_name b_cid_name,\n"
"b.cid_num b_cid_num,\n"
"b.ip_addr b_ip_addr,\n"
"b.dest b_dest,\n"
"b.application b_application,\n"
"b.application_data b_application_data,\n"
"b.dialplan b_dialplan,\n"
"b.context b_context,\n"
"b.read_codec b_read_codec,\n"
"b.read_rate b_read_rate,\n"
"b.read_bit_rate b_read_bit_rate,\n"
"b.write_codec b_write_codec,\n"
"b.write_rate b_write_rate,\n"
"b.write_bit_rate b_write_bit_rate,\n"
"b.secure b_secure,\n"
"b.hostname b_hostname,\n"
"b.presence_id b_presence_id,\n"
"b.presence_data b_presence_data,\n"
"b.callstate b_callstate,\n"
"b.callee_name b_callee_name,\n"
"b.callee_num b_callee_num,\n"
"b.callee_direction b_callee_direction,\n"
"b.call_uuid b_call_uuid\n"
"from channels a left join channels b on a.originatee = b.uuid where a.originator is null";
"a.uuid as uuid,"
"a.direction as direction,"
"a.created as created,"
"a.created_epoch as created_epoch,"
"a.name as name,"
"a.state as state,"
"a.cid_name as cid_name,"
"a.cid_num as cid_num,"
"a.ip_addr as ip_addr,"
"a.dest as dest,"
"a.application as application,"
"a.application_data as application_data,"
"a.dialplan as dialplan,"
"a.context as context,"
"a.read_codec as read_codec,"
"a.read_rate as read_rate,"
"a.read_bit_rate as read_bit_rate,"
"a.write_codec as write_codec,"
"a.write_rate as write_rate,"
"a.write_bit_rate as write_bit_rate,"
"a.secure as secure,"
"a.hostname as hostname,"
"a.presence_id as presence_id,"
"a.presence_data as presence_data,"
"a.callstate as callstate,"
"a.callee_name as callee_name,"
"a.callee_num as callee_num,"
"a.callee_direction as callee_direction,"
"a.call_uuid as call_uuid,"
"b.uuid as b_uuid,"
"b.direction as b_direction,"
"b.created as b_created,"
"b.created_epoch as b_created_epoch,"
"b.name as b_name,"
"b.state as b_state,"
"b.cid_name as b_cid_name,"
"b.cid_num as b_cid_num,"
"b.ip_addr as b_ip_addr,"
"b.dest as b_dest,"
"b.application as b_application,"
"b.application_data as b_application_data,"
"b.dialplan as b_dialplan,"
"b.context as b_context,"
"b.read_codec as b_read_codec,"
"b.read_rate as b_read_rate,"
"b.read_bit_rate as b_read_bit_rate,"
"b.write_codec as b_write_codec,"
"b.write_rate as b_write_rate,"
"b.write_bit_rate as b_write_bit_rate,"
"b.secure as b_secure,"
"b.hostname as b_hostname,"
"b.presence_id as b_presence_id,"
"b.presence_data as b_presence_data,"
"b.callstate as b_callstate,"
"b.callee_name as b_callee_name,"
"b.callee_num as b_callee_num,"
"b.callee_direction as b_callee_direction,"
"b.call_uuid as b_call_uuid,"
"c.call_created_epoch as call_created_epoch "
"from channels a "
"left join calls c on a.uuid = c.caller_uuid and a.hostname = c.hostname "
"left join channels b on b.uuid = c.callee_uuid and b.hostname = c.hostname "
"where a.uuid = c.caller_uuid or a.uuid not in (select callee_uuid from calls)";
static char basic_calls_sql[] =
"create view basic_calls as select "
"a.uuid as uuid,"
"a.direction as direction,"
"a.created as created,"
"a.created_epoch as created_epoch,"
"a.name as name,"
"a.state as state,"
"a.cid_name as cid_name,"
"a.cid_num as cid_num,"
"a.ip_addr as ip_addr,"
"a.dest as dest,"
"a.presence_id as presence_id,"
"a.presence_data as presence_data,"
"a.callstate as callstate,"
"a.callee_name as callee_name,"
"a.callee_num as callee_num,"
"a.callee_direction as callee_direction,"
"a.call_uuid as call_uuid,"
"a.hostname as hostname,"
"b.uuid as b_uuid,"
"b.direction as b_direction,"
"b.created as b_created,"
"b.created_epoch as b_created_epoch,"
"b.name as b_name,"
"b.state as b_state,"
"b.cid_name as b_cid_name,"
"b.cid_num as b_cid_num,"
"b.ip_addr as b_ip_addr,"
"b.dest as b_dest,"
"b.presence_id as b_presence_id,"
"b.presence_data as b_presence_data,"
"b.callstate as b_callstate,"
"b.callee_name as b_callee_name,"
"b.callee_num as b_callee_num,"
"b.callee_direction as b_callee_direction,"
"c.call_created_epoch as call_created_epoch "
"from channels a "
"left join calls c on a.uuid = c.caller_uuid and a.hostname = c.hostname "
"left join channels b on b.uuid = c.callee_uuid and b.hostname = c.hostname "
"where a.uuid = c.caller_uuid or a.uuid not in (select callee_uuid from calls)";
SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires,
@@ -1911,8 +1872,9 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
case SCDB_TYPE_CORE_DB:
{
switch_cache_db_execute_sql(dbh, "drop table channels", NULL);
switch_cache_db_execute_sql(dbh, "drop view detailed_calls", NULL);
switch_cache_db_execute_sql(dbh, "drop table calls", NULL);
switch_cache_db_execute_sql(dbh, "drop view detailed_calls", NULL);
switch_cache_db_execute_sql(dbh, "drop view basic_calls", NULL);
switch_cache_db_execute_sql(dbh, "drop table interfaces", NULL);
switch_cache_db_execute_sql(dbh, "drop table tasks", NULL);
switch_cache_db_execute_sql(dbh, "PRAGMA synchronous=OFF;", NULL);
@@ -1937,8 +1899,8 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
{
char *err;
switch_cache_db_test_reactive(dbh, "select call_uuid, read_bit_rate from channels", "DROP TABLE channels", create_channels_sql);
switch_cache_db_test_reactive(dbh, "select * from detailed_calls", NULL, view_sql);
switch_cache_db_test_reactive(dbh, "select * from detailed_calls", "DROP VIEW detailed_calls", detailed_calls_sql);
switch_cache_db_test_reactive(dbh, "select * from basic_calls", "DROP VIEW basic_call", basic_calls_sql);
if (runtime.odbc_dbtype == DBTYPE_DEFAULT) {
switch_cache_db_test_reactive(dbh, "select call_uuid from calls", "DROP TABLE calls", create_calls_sql);
} else {
@@ -1971,11 +1933,11 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
case SCDB_TYPE_CORE_DB:
{
switch_cache_db_execute_sql(dbh, create_channels_sql, NULL);
switch_cache_db_execute_sql(dbh, view_sql, NULL);
switch_cache_db_execute_sql(dbh, create_calls_sql, NULL);
switch_cache_db_execute_sql(dbh, create_interfaces_sql, NULL);
switch_cache_db_execute_sql(dbh, create_tasks_sql, NULL);
switch_cache_db_execute_sql(dbh, detailed_calls_sql, NULL);
switch_cache_db_execute_sql(dbh, basic_calls_sql, NULL);
}
break;
}
+2 -1
View File
@@ -1148,7 +1148,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_s
}
if (switch_socket_bind(new_sock, rtp_session->local_addr) != SWITCH_STATUS_SUCCESS) {
*err = "Bind Error!";
char *em = switch_core_sprintf(rtp_session->pool, "Bind Error! %s:%d", host, port);
*err = em;
goto done;
}