mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-29 22:54:18 +00:00
SCA tweaks
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16271 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
ec892d4ad6
commit
b24c018c45
12 files changed
+139
-69
No files matched your search
@@ -3436,7 +3436,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
|
||||
if (sip &&
|
||||
sip->sip_from && sip->sip_from->a_url && sip->sip_from->a_url->url_user && sip->sip_from->a_url->url_host &&
|
||||
sip->sip_to && sip->sip_to->a_url && sip->sip_to->a_url->url_user && sip->sip_to->a_url->url_host) {
|
||||
sql = switch_mprintf("select 'appearance-index=1' from sip_subscriptions where expires > -1 && hostname='%q' and event='call-info' and "
|
||||
sql = switch_mprintf("select 'appearance-index=1' from sip_subscriptions where expires > -1 and hostname='%q' and event='call-info' and "
|
||||
"sub_to_user='%q' and sub_to_host='%q'",
|
||||
mod_sofia_globals.hostname, sip->sip_to->a_url->url_user, sip->sip_from->a_url->url_host);
|
||||
sofia_glue_execute_sql2str(profile, profile->ireg_mutex, sql, buf, sizeof(buf));
|
||||
@@ -4242,9 +4242,20 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
||||
switch_channel_presence(tech_pvt->channel, "unknown", "unhold", NULL);
|
||||
}
|
||||
} else if (switch_stristr("sendonly", r_sdp)) {
|
||||
const char *msg = "hold";
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
|
||||
const char *info = switch_channel_get_variable(channel, "presence_call_info");
|
||||
if (info) {
|
||||
if (switch_stristr("private", info)) {
|
||||
msg = "hold-private";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sofia_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||
switch_channel_set_flag(channel, CF_LEG_HOLDING);
|
||||
switch_channel_presence(tech_pvt->channel, "unknown", "hold", NULL);
|
||||
switch_channel_presence(tech_pvt->channel, "unknown", msg, NULL);
|
||||
}
|
||||
|
||||
switch_core_session_queue_message(other_session, msg);
|
||||
@@ -5693,6 +5704,11 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
if (!destination_number && sip->sip_to && sip->sip_to->a_url) {
|
||||
destination_number = sip->sip_to->a_url->url_user;
|
||||
}
|
||||
|
||||
/* The human network, OH THE HUMANITY!!! lets send invites with no number! */
|
||||
if (!destination_number && sip->sip_from && sip->sip_from->a_url) {
|
||||
destination_number = sip->sip_from->a_url->url_user;
|
||||
}
|
||||
|
||||
if (destination_number) {
|
||||
check_decode(destination_number, session);
|
||||
@@ -5957,20 +5973,36 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
char cid[512] = "";
|
||||
char *str;
|
||||
char *p = NULL;
|
||||
|
||||
|
||||
const char *user = NULL, *host = NULL;
|
||||
|
||||
if (sip->sip_to && sip->sip_to->a_url) {
|
||||
user = sip->sip_to->a_url->url_user;
|
||||
host = sip->sip_to->a_url->url_host;
|
||||
}
|
||||
|
||||
if (!user || !host) {
|
||||
if (sip->sip_from && sip->sip_from->a_url) {
|
||||
if (!user) user = sip->sip_from->a_url->url_user;
|
||||
if (!host) host = sip->sip_from->a_url->url_host;
|
||||
}
|
||||
}
|
||||
|
||||
if (user && host) {
|
||||
if ((p = strchr(call_info_str, ';'))) {
|
||||
p++;
|
||||
}
|
||||
|
||||
sql = switch_mprintf("select call_id from sip_dialogs where call_info='%q' and sip_from_user='%q' and sip_from_host='%q'",
|
||||
switch_str_nil(p), sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host);
|
||||
|
||||
sql = switch_mprintf("select call_id from sip_dialogs where call_info='%q' and sip_from_user='%q' and sip_from_host='%q' and call_id is not null",
|
||||
switch_str_nil(p), user, host);
|
||||
|
||||
if ((str = sofia_glue_execute_sql2str(profile, profile->ireg_mutex, sql, cid, sizeof(cid)))) {
|
||||
bnh = nua_handle_by_call_id(nua, str);
|
||||
}
|
||||
|
||||
if (mod_sofia_globals.debug_sla > 1) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "PICK SQL %s [%s] [%s] %d\n", sql, str, cid, !!bnh);
|
||||
}
|
||||
|
||||
free(sql);
|
||||
}
|
||||
}
|
||||
@@ -5991,7 +6023,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
private_object_t *b_tech_pvt = NULL;
|
||||
const char *app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);
|
||||
const char *data = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE);
|
||||
|
||||
|
||||
if (app && data && !strcasecmp(app, "conference")) {
|
||||
destination_number = switch_core_session_sprintf(b_session, "answer,conference:%s", data);
|
||||
dialplan = "inline";
|
||||
@@ -5999,7 +6031,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
if (switch_core_session_check_interface(b_session, sofia_endpoint_interface)) {
|
||||
b_tech_pvt = switch_core_session_get_private(b_session);
|
||||
}
|
||||
|
||||
|
||||
if ((uuid = switch_channel_get_variable(b_channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
|
||||
switch_channel_set_variable(b_channel, "presence_call_info", NULL);
|
||||
one_leg = 0;
|
||||
|
||||
@@ -3934,9 +3934,6 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
||||
"create index ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)",
|
||||
"create index ssa_aor on sip_shared_appearance_subscriptions (aor)",
|
||||
"create index ssd_profile_name on sip_shared_appearance_dialogs (profile_name)",
|
||||
"create index ssd_contact on sip_shared_appearance_dialogs (contact)",
|
||||
"create index ssd_presence_id on sip_shared_appearance_dialogs (presence_id)",
|
||||
"create index ssd_presence_data on sip_shared_appearance_dialogs (presence_data)",
|
||||
"create index ssd_hostname on sip_shared_appearance_dialogs (hostname)",
|
||||
"create index ssd_contact_str on sip_shared_appearance_dialogs (contact_str)",
|
||||
"create index ssd_call_id on sip_shared_appearance_dialogs (call_id)",
|
||||
@@ -3963,9 +3960,9 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
||||
"like '%%' and mwi_user like '%%' and mwi_host like '%%'",
|
||||
mod_sofia_globals.hostname);
|
||||
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_registrations", NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, reg_sql, NULL);
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_registrations", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, reg_sql, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -3973,7 +3970,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
||||
if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
|
||||
char *test2 = switch_mprintf("%s;%s", test_sql, test_sql);
|
||||
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test2, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test2, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "GREAT SCOTT!!! Cannot execute batched statements!\n"
|
||||
"If you are using mysql, make sure you are using MYODBC 3.51.18 or higher and enable FLAG_MULTI_STATEMENTS\n");
|
||||
sofia_clear_pflag(profile, PFLAG_SQL_IN_TRANS);
|
||||
@@ -3988,55 +3985,55 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
||||
test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip like '%%' and network_port like '%%'",
|
||||
mod_sofia_globals.hostname);
|
||||
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_subscriptions", NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, sub_sql, NULL);
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_subscriptions", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, sub_sql, NULL, NULL);
|
||||
}
|
||||
|
||||
free(test_sql);
|
||||
test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and expires > 0", mod_sofia_globals.hostname);
|
||||
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_dialogs", NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, dialog_sql, NULL);
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_dialogs", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, dialog_sql, NULL, NULL);
|
||||
}
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_presence where hostname='%q' ", mod_sofia_globals.hostname);
|
||||
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_presence", NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, pres_sql, NULL);
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_presence", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, pres_sql, NULL, NULL);
|
||||
}
|
||||
|
||||
free(test_sql);
|
||||
test_sql = switch_mprintf("delete from sip_authentication where hostname='%q' or last_nc >= 0", mod_sofia_globals.hostname);
|
||||
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_authentication", NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, auth_sql, NULL);
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_authentication", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, auth_sql, NULL, NULL);
|
||||
}
|
||||
free(test_sql);
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str='' or hostname='%q' and network_ip like '%%'",
|
||||
mod_sofia_globals.hostname);
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_shared_appearance_subscriptions", NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, shared_appearance_sql, NULL);
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_shared_appearance_subscriptions", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, shared_appearance_sql, NULL, NULL);
|
||||
}
|
||||
free(test_sql);
|
||||
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_shared_appearance_dialogs where contact_str='' or hostname='%q' and network_ip like '%%'",
|
||||
mod_sofia_globals.hostname);
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_shared_appearance_dialogs", NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, shared_appearance_dialogs_sql, NULL);
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_shared_appearance_dialogs", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, shared_appearance_dialogs_sql, NULL, NULL);
|
||||
}
|
||||
free(test_sql);
|
||||
|
||||
|
||||
for (x = 0; indexes[x]; x++) {
|
||||
switch_odbc_handle_exec(odbc_dbh, indexes[x], NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, indexes[x], NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -599,25 +599,37 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||
}
|
||||
|
||||
if (call_info) {
|
||||
const char *uuid = switch_event_get_header(event, "unique-id");
|
||||
|
||||
|
||||
#if 0
|
||||
if (mod_sofia_globals.debug_sla > 1) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SLA EVENT:\n");
|
||||
DUMP_EVENT(event);
|
||||
}
|
||||
#endif
|
||||
|
||||
sql = switch_mprintf("update sip_dialogs set call_info_state='%q' where hostname='%q' and sip_dialogs.sip_from_user='%q' "
|
||||
"and sip_dialogs.sip_from_host='%q' and call_info='%q'",
|
||||
call_info_state,
|
||||
mod_sofia_globals.hostname,
|
||||
euser, host, call_info);
|
||||
|
||||
if (uuid) {
|
||||
sql = switch_mprintf("update sip_dialogs set call_info_state='%q' where hostname='%q' and uuid='%q'",
|
||||
call_info_state,
|
||||
mod_sofia_globals.hostname,
|
||||
uuid);
|
||||
} else {
|
||||
sql = switch_mprintf("update sip_dialogs set call_info_state='%q' where hostname='%q' and sip_dialogs.sip_from_user='%q' "
|
||||
"and sip_dialogs.sip_from_host='%q' and call_info='%q'",
|
||||
call_info_state,
|
||||
mod_sofia_globals.hostname,
|
||||
euser, host, call_info);
|
||||
|
||||
}
|
||||
|
||||
if (mod_sofia_globals.debug_sla > 1) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "STATE SQL %s\n", sql);
|
||||
}
|
||||
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
|
||||
|
||||
|
||||
|
||||
if (mod_sofia_globals.debug_sla > 1) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "PROCESS PRESENCE EVENT\n");
|
||||
}
|
||||
|
||||
@@ -768,14 +768,23 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
||||
authorization = sip->sip_authorization;
|
||||
contact = sip->sip_contact;
|
||||
to = sip->sip_to;
|
||||
from = sip->sip_from;
|
||||
|
||||
if (from) {
|
||||
from_user = from->a_url->url_user;
|
||||
from_host = from->a_url->url_host;
|
||||
}
|
||||
|
||||
if (to) {
|
||||
to_user = to->a_url->url_user;
|
||||
to_host = to->a_url->url_host;
|
||||
}
|
||||
|
||||
if (!to_user) to_user = from_user;
|
||||
if (!to_host) to_host = from_host;
|
||||
|
||||
if (!to_user || !to_host) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can not do authorization without a complete from header\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can not do authorization without a complete header\n");
|
||||
nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), TAG_END());
|
||||
switch_goto_int(r, 1, end);
|
||||
}
|
||||
@@ -784,13 +793,6 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
||||
reg_host = to_host;
|
||||
}
|
||||
|
||||
from = sip->sip_from;
|
||||
|
||||
if (from) {
|
||||
from_user = from->a_url->url_user;
|
||||
from_host = from->a_url->url_host;
|
||||
}
|
||||
|
||||
if (contact->m_url) {
|
||||
const char *port = contact->m_url->url_port;
|
||||
char new_port[25] = "";
|
||||
|
||||
Reference in new issue
Block a user