]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
setting profile option multiple-registrations=contact key multi reg off the contact...
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 22 Oct 2008 17:40:43 +0000 (17:40 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 22 Oct 2008 17:40:43 +0000 (17:40 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10112 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index da2f44e8d060a31a6e2c4b8eb23e0a8101a9e3be..8572d357d918e4592cabfe9974e8cf55c299e4e0 100644 (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),
index ad038df0621fe6a5d94400347d35069b13b36573..ad6eb07d082359090d6d903cc6cb75a85256ab0e 100644 (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)) {
index ce339001fd1d19d14ec1a58fe7810de3cf67b69c..62fda58f5f6beb8c6fea0198fb725e3cee4fed6f 100644 (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,