ソースを参照

ims_usrloc_scscf: Add capability to skip a specific realm (#2951)

* ims_usrloc_scscf: Add capability to skip a specific realm

Capability to skip realm in NOTIFY's Message body reginfo tag.
Added realm(string) and skip_realm(int) parameters.

* Update ims_usrloc_scscf_admin.xml

Revert changes for user_data_xsd
alexyosifov 3 年 前
コミット
d39bbb080b

+ 24 - 0
src/modules/ims_usrloc_scscf/doc/ims_usrloc_scscf_admin.xml

@@ -318,6 +318,30 @@
         </programlisting>
       </example>
     </section>
+
+    <section id="ims_usrloc_scscf.p.realm">
+      <title>realm (string)</title>
+      <para> </para>
+      <para><emphasis> Default value is NULL </emphasis></para>
+      <example>
+        <title>Set <varname>realm</varname> parameter</title>
+        <programlisting format="linespecific">
+        modparam("ims_usrloc_scscf", "realm", "kamailio-ims.org")
+        </programlisting>
+      </example>
+    </section>
+
+    <section id="ims_usrloc_scscf.p.skip_realm">
+      <title>skip_realm (int)</title>
+      <para>Skipping defined network name in the <varname>realm</varname> for NOTIFY's Message body reginfo tag. </para>
+      <para><emphasis> Default value is 0 </emphasis></para>
+      <example>
+        <title>Set <varname>skip_realm</varname> parameter</title>
+        <programlisting format="linespecific">
+        modparam("ims_usrloc_scscf", "skip_realm", 1)
+        </programlisting>
+      </example>
+    </section>
   </section>
 
   <section>

+ 5 - 0
src/modules/ims_usrloc_scscf/ims_usrloc_scscf_mod.c

@@ -125,6 +125,9 @@ shtable_t sub_dialog_table;
 
 int contact_delete_delay = 30;   //If contact is put into delay delete state this is how long we delay before deleting
 
+char* cscf_realm = 0;
+int skip_cscf_realm = 0;
+
 new_shtable_t pres_new_shtable;
 insert_shtable_t pres_insert_shtable;
 search_shtable_t pres_search_shtable;
@@ -170,6 +173,8 @@ static param_export_t params[] = {
     {"db_mode",				INT_PARAM, &db_mode},
     {"db_url", 				PARAM_STR, &db_url},
     {"timer_procs",             INT_PARAM, &ul_timer_procs},
+	{"realm",               PARAM_STRING, &cscf_realm},
+	{"skip_realm",          INT_PARAM, &skip_cscf_realm},
 	{0, 0, 0}
 };
 

+ 42 - 17
src/modules/ims_usrloc_scscf/udomain.c

@@ -79,6 +79,9 @@ extern int subs_hash_size;
 
 extern int contact_delete_delay;
 
+extern char* cscf_realm;
+extern int skip_cscf_realm;
+
 /*!
  * \brief Create a new domain structure
  * \param  _n is pointer to str representing name of the domain, the string is
@@ -706,6 +709,7 @@ int get_impus_from_subscription_as_string(udomain_t* _d, impurecord_t* impu_rec,
     ims_public_identity* impi;
     int bytes_needed = 0;
     int len = 0;
+    char* p = NULL;
 
     LM_DBG("getting IMPU subscription set\n");
 
@@ -723,18 +727,30 @@ int get_impus_from_subscription_as_string(udomain_t* _d, impurecord_t* impu_rec,
     for (i = 0; i < impu_rec->s->service_profiles_cnt; i++) {
         for (j = 0; j < impu_rec->s->service_profiles[i].public_identities_cnt; j++) {
             impi = &(impu_rec->s->service_profiles[i].public_identities[j]);
-            LM_DBG("Got Record %.*s (%i)\n", impi->public_identity.len,
-              impi->public_identity.s, impi->public_identity.len);
 
-            if (barring < 0) {
-                //get all records
-                bytes_needed += impi->public_identity.len;
-                (*num_impus)++;
+            if (skip_cscf_realm && cscf_realm) {
+                p = strstr(impi->public_identity.s, cscf_realm);
+            } else {
+                p = NULL;
+            }
+
+            if (p) {
+                LM_DBG("Skip Record %.*s (%i)\n", impi->public_identity.len,
+              impi->public_identity.s, impi->public_identity.len);
             } else {
-                if (impi->barring == barring) {
-                    //add the record to the list
+                LM_DBG("Got Record %.*s (%i)\n", impi->public_identity.len,
+                impi->public_identity.s, impi->public_identity.len);
+
+                if (barring < 0) {
+                    //get all records
                     bytes_needed += impi->public_identity.len;
                     (*num_impus)++;
+                } else {
+                    if (impi->barring == barring) {
+                        //add the record to the list
+                        bytes_needed += impi->public_identity.len;
+                        (*num_impus)++;
+                    }
                 }
             }
         }
@@ -761,21 +777,30 @@ int get_impus_from_subscription_as_string(udomain_t* _d, impurecord_t* impu_rec,
     for (i = 0; i < impu_rec->s->service_profiles_cnt; i++) {
         for (j = 0; j < impu_rec->s->service_profiles[i].public_identities_cnt; j++) {
             impi = &(impu_rec->s->service_profiles[i].public_identities[j]);
-            if (barring < 0) {
-                //get all records
-                (*impus)[count].s = ptr;
-                memcpy(ptr, impi->public_identity.s, impi->public_identity.len);
-                (*impus)[count].len = impi->public_identity.len;
-                ptr += impi->public_identity.len;
-                count++;
+
+            if (skip_cscf_realm && cscf_realm) {
+                p = strstr(impi->public_identity.s, cscf_realm);
             } else {
-                if (impi->barring == barring) {
-                    //add the record to the list
+                p = NULL;
+            }
+
+            if (p == NULL) {
+                if (barring < 0) {
+                    //get all records
                     (*impus)[count].s = ptr;
                     memcpy(ptr, impi->public_identity.s, impi->public_identity.len);
                     (*impus)[count].len = impi->public_identity.len;
                     ptr += impi->public_identity.len;
                     count++;
+                } else {
+                    if (impi->barring == barring) {
+                        //add the record to the list
+                        (*impus)[count].s = ptr;
+                        memcpy(ptr, impi->public_identity.s, impi->public_identity.len);
+                        (*impus)[count].len = impi->public_identity.len;
+                        ptr += impi->public_identity.len;
+                        count++;
+                    }
                 }
             }
         }