switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_registrations", reg_sql);
free(test_sql);
- test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip!='-1'", mod_sofia_globals.hostname);
+ test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip!='-1' and network_port!='-1'", mod_sofia_globals.hostname);
switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_subscriptions", sub_sql);
free(test_sql);
} else if (profile->odbc_dsn) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
} else {
+ char *errmsg;
+
if (master) {
db = profile->master_db;
} else {
goto end;
}
}
- switch_core_db_persistant_execute(db, sql, 1);
+
+ switch_core_db_exec(db, sql, NULL, NULL, &errmsg);
+ if (errmsg) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n%s\n", errmsg, sql);
+ switch_core_db_free(errmsg);
+ }
if (!master) {
switch_core_db_close(db);
if (expires) {
long tmp = atol(expires);
if (tmp > 0) {
- exptime = tmp - switch_epoch_time_now(NULL) - SUB_OVERLAP;
+ exptime = tmp - switch_epoch_time_now(NULL);// - SUB_OVERLAP;
} else {
exptime = tmp;
}
switch_snprintf(exp_delta_str, sizeof(exp_delta_str), "%ld", exp_delta);
if (sofia_test_pflag(profile, PFLAG_MULTIREG)) {
- sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", call_id);
+ sql = switch_mprintf("delete from sip_subscriptions where call_id='%q' or (contact='%q' and and event='%q')", call_id, contact_str, event);
} else {
sql = switch_mprintf("delete from sip_subscriptions where "
"proto='%q' and sip_user='%q' and sip_host='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q' and hostname='%q'",
sql = switch_mprintf("insert into sip_subscriptions "
"(proto,sip_user,sip_host,sub_to_user,sub_to_host,presence_hosts,event,contact,call_id,full_from,"
- "full_via,expires,user_agent,accept,profile_name,hostname,network_ip) "
- "values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'%q','%q','%q','%q','%q')",
+ "full_via,expires,user_agent,accept,profile_name,hostname,network_port,network_ip) "
+ "values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'%q','%q','%q','%q','%d','%q')",
proto, from_user, from_host, to_user, to_host, profile->presence_hosts ? profile->presence_hosts : to_host,
event, contact_str, call_id, full_from, full_via,
- exp_delta * -1,
- full_agent, accept, profile->name,mod_sofia_globals.hostname, network_ip);
+ //sofia_test_pflag(profile, PFLAG_MULTIREG) ? switch_epoch_time_now(NULL) + exp_delta : exp_delta * -1,
+ switch_epoch_time_now(NULL) + exp_delta,
+ full_agent, accept, profile->name,mod_sofia_globals.hostname, network_port, network_ip);
-
if (mod_sofia_globals.debug_presence > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%s SUBSCRIBE %s@%s %s@%s\n", profile->name, from_user, from_host, to_user, to_host);
}
}
if (nh && nh->nh_ds && nh->nh_ds->ds_usage) {
- nua_dialog_usage_set_refresh_range(nh->nh_ds->ds_usage, exp_delta + SUB_OVERLAP, exp_delta + SUB_OVERLAP);
+ //nua_dialog_usage_set_refresh_range(nh->nh_ds->ds_usage, exp_delta + SUB_OVERLAP, exp_delta + SUB_OVERLAP);
+ nua_dialog_usage_set_refresh_range(nh->nh_ds->ds_usage, exp_delta, exp_delta);
}
nua_respond(nh, SIP_202_ACCEPTED,
}
-static unsigned long get_nc(const char *nc, sip_t const *sip)
-{
- unsigned long x;
- const char *ua = NULL;
-
- if (sip->sip_user_agent) {
- ua = sip->sip_user_agent->g_string;
- }
-
- /* sigh, polycom sends nc in base-10 rather than spec which says base-16*/
- if (ua && switch_stristr("polycom", ua)) {
- x = strtoul(nc, 0, 10);
- } else {
- x = strtoul(nc, 0, 16);
- }
-
- return x;
-}
-
auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
sip_authorization_t const *authorization,
sip_t const *sip,
if (zstr(np)) {
first = 1;
if (nc) {
- unsigned long x;
-
- x = get_nc(nc, sip);
- sql = switch_mprintf("select nonce from sip_authentication where nonce='%q' and last_nc + 1 >= %lu", nonce, x);
+ sql = switch_mprintf("select nonce from sip_authentication where nonce='%q' and last_nc < %lu", nonce, strtoul(nc, 0, 16));
} else {
sql = switch_mprintf("select nonce from sip_authentication where nonce='%q'", nonce);
}
if (nc && cnonce && qop) {
- unsigned long x;
char *sql;
- x = get_nc(nc, sip);
#if defined(_WIN32) && !defined(_WIN64)
#define LL_FMT "ll"
#else
#define LL_FMT "l"
#endif
sql = switch_mprintf("update sip_authentication set expires='%"LL_FMT"u',last_nc=%lu where nonce='%s'",
- switch_epoch_time_now(NULL) + (profile->nonce_ttl ? profile->nonce_ttl : exptime + 10), x, nonce);
+ switch_epoch_time_now(NULL) + (profile->nonce_ttl ? profile->nonce_ttl : exptime + 10), strtoul(nc, 0, 16), nonce);
switch_assert(sql != NULL);
sofia_glue_actually_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);