setting profile option multiple-registrations=contact key multi reg off the contact string

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10112 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-10-22 17:40:43 +00:00
parent 35d0476b5c
commit 40a050c6b7
3 changed files with 32 additions and 9 deletions

View File

@ -138,7 +138,7 @@ typedef enum {
PFLAG_BLIND_REG = (1 << 1),
PFLAG_AUTH_ALL = (1 << 2),
PFLAG_FULL_ID = (1 << 3),
PFLAG_USE_ME = (1 << 4),
PFLAG_MULTIREG_CONTACT = (1 << 4),
PFLAG_PASS_RFC2833 = (1 << 5),
PFLAG_DISABLE_TRANSCODING = (1 << 6),
PFLAG_REWRITE_TIMESTAMPS = (1 << 7),

View File

@ -1149,7 +1149,10 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
profile->pflags &= ~PFLAG_SECURE;
}
} else if (!strcasecmp(var, "multiple-registrations")) {
if (switch_true(val)) {
if (!strcasecmp(val, "contact")) {
profile->pflags |= PFLAG_MULTIREG;
profile->pflags |= PFLAG_MULTIREG_CONTACT;
} else if (switch_true(val)) {
profile->pflags |= PFLAG_MULTIREG;
} else {
profile->pflags &= ~PFLAG_MULTIREG;
@ -1605,8 +1608,13 @@ switch_status_t config_sofia(int reload, char *profile_name)
profile->pflags |= PFLAG_SECURE;
}
} else if (!strcasecmp(var, "multiple-registrations")) {
if (switch_true(val)) {
if (!strcasecmp(val, "contact")) {
profile->pflags |= PFLAG_MULTIREG;
profile->pflags |= PFLAG_MULTIREG_CONTACT;
} else if (switch_true(val)) {
profile->pflags |= PFLAG_MULTIREG;
} else {
profile->pflags &= ~PFLAG_MULTIREG;
}
} else if (!strcasecmp(var, "supress-cng") || !strcasecmp(var, "suppress-cng")) {
if (switch_true(val)) {

View File

@ -516,7 +516,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
const char *reg_host = profile->reg_db_domain;
char contact_str[1024] = "";
int nat_hack = 0;
uint8_t multi_reg = 0, avoid_multi_reg = 0;
uint8_t multi_reg = 0, multi_reg_contact = 0, avoid_multi_reg = 0;
uint8_t stale = 0, forbidden = 0;
auth_res_t auth_res;
long exptime = 60;
@ -776,6 +776,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
/* Does this profile supports multiple registrations ? */
multi_reg = ( sofia_test_pflag(profile, PFLAG_MULTIREG) ) ? 1 : 0;
multi_reg_contact = ( sofia_test_pflag(profile, PFLAG_MULTIREG_CONTACT) ) ? 1 : 0;
if ( multi_reg && avoid_multi_reg ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
@ -793,7 +794,11 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
}
if (multi_reg) {
sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id);
if (multi_reg_contact) {
sql = switch_mprintf("delete from sip_registrations where contact='%q'", contact_str);
} else {
sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id);
}
} else {
sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q' and hostname='%q'",
to_user, reg_host, mod_sofia_globals.hostname);
@ -856,13 +861,23 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
if ((p = strchr(icontact + 4, ':'))) {
*p = '\0';
}
if ((sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", call_id))) {
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
if (multi_reg_contact) {
sql = switch_mprintf("delete from sip_subscriptions where contact='%q'", contact_str);
} else {
sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", call_id);
}
if ((sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id))) {
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
if (multi_reg_contact) {
sql = switch_mprintf("delete from sip_registrations where contact='%q'", contact_str);
} else {
sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id);
}
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
switch_safe_free(icontact);
} else {
if ((sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and hostname='%q'", to_user, reg_host,