Module: kamailio
Branch: master
Commit: a83ec38863fca0473685b81f708938660a08da81
URL: 
https://github.com/kamailio/kamailio/commit/a83ec38863fca0473685b81f708938660a08da81

Author: Stefan Mititelu <stefan.mitit...@net2phone.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2025-02-21T08:53:34+01:00

dmq_usrloc: add modparam for cflags replication

---

Modified: src/modules/dmq_usrloc/dmq_usrloc.c
Modified: src/modules/dmq_usrloc/doc/dmq_usrloc_admin.xml
Modified: src/modules/dmq_usrloc/usrloc_sync.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/a83ec38863fca0473685b81f708938660a08da81.diff
Patch: 
https://github.com/kamailio/kamailio/commit/a83ec38863fca0473685b81f708938660a08da81.patch

---

diff --git a/src/modules/dmq_usrloc/dmq_usrloc.c 
b/src/modules/dmq_usrloc/dmq_usrloc.c
index 8c4544b1633..a568d3d3148 100644
--- a/src/modules/dmq_usrloc/dmq_usrloc.c
+++ b/src/modules/dmq_usrloc/dmq_usrloc.c
@@ -37,6 +37,7 @@ static int child_init(int);
 int dmq_usrloc_enable = 0;
 int _dmq_usrloc_sync = 1;
 int _dmq_usrloc_replicate_socket_info = 0;
+int _dmq_usrloc_replicate_cflags = 1;
 int _dmq_usrloc_batch_size = 0;
 int _dmq_usrloc_batch_msg_contacts = 1;
 int _dmq_usrloc_batch_msg_size = 60000;
@@ -54,6 +55,7 @@ static param_export_t params[] = {
        {"enable", PARAM_INT, &dmq_usrloc_enable},
        {"sync", PARAM_INT, &_dmq_usrloc_sync},
        {"replicate_socket_info", PARAM_INT, 
&_dmq_usrloc_replicate_socket_info},
+       {"replicate_cflags", PARAM_INT, &_dmq_usrloc_replicate_cflags},
        {"batch_msg_contacts", PARAM_INT, &_dmq_usrloc_batch_msg_contacts},
        {"batch_msg_size", PARAM_INT, &_dmq_usrloc_batch_msg_size},
        {"batch_size", PARAM_INT, &_dmq_usrloc_batch_size},
diff --git a/src/modules/dmq_usrloc/doc/dmq_usrloc_admin.xml 
b/src/modules/dmq_usrloc/doc/dmq_usrloc_admin.xml
index ff612b32eda..5d6727b5c83 100644
--- a/src/modules/dmq_usrloc/doc/dmq_usrloc_admin.xml
+++ b/src/modules/dmq_usrloc/doc/dmq_usrloc_admin.xml
@@ -292,6 +292,44 @@ modparam("dmq_usrloc", "replicate_socket_info", 1)
 </programlisting>
        </example>
        </section>
+       <section id="usrloc_dmq.p.replicate_cflags">
+               <title><varname>replicate_cflags</varname> (int)</title>
+               <para>
+                       The parameter controls whether the cflags replication 
is active or not.
+                       This is important for anycast scenarios.
+                       The value can be:
+                       <itemizedlist>
+                       <listitem>
+                       <para>
+                               0 - disabled
+                       </para>
+                       </listitem>
+                       <listitem>
+                       <para>
+                               1 - enabled, replicate cflags
+                       </para>
+                       </listitem>
+                       <listitem>
+                       <para>
+                               > 1 - enabled, set cflags corresponding to this 
value, on replicated peers
+                       </para>
+                       </listitem>
+                       </itemizedlist>
+               </para>
+               <para>
+               <emphasis>
+                       Default value is 1.
+               </emphasis>
+               </para>
+               <example>
+               <title>Set <varname>replicate_cflags</varname> parameter</title>
+               <programlisting format="linespecific">
+...
+modparam("dmq_usrloc", "replicate_cflags", 97) # will set cflags corresponding 
to 1 + 32 + 64
+...
+               </programlisting>
+               </example>
+       </section>
        <section id="usrloc_dmq.p.usrloc_delete">
                <title><varname>usrloc_delete</varname> (int)</title>
                <para>
diff --git a/src/modules/dmq_usrloc/usrloc_sync.c 
b/src/modules/dmq_usrloc/usrloc_sync.c
index 73017c52877..1760616aed5 100644
--- a/src/modules/dmq_usrloc/usrloc_sync.c
+++ b/src/modules/dmq_usrloc/usrloc_sync.c
@@ -60,6 +60,7 @@ static void srjson_to_xavp(srjson_t *json, sr_xavp_t **xavp);
 
 extern int _dmq_usrloc_sync;
 extern int _dmq_usrloc_replicate_socket_info;
+extern int _dmq_usrloc_replicate_cflags;
 extern int _dmq_usrloc_batch_msg_contacts;
 extern int _dmq_usrloc_batch_msg_size;
 extern int _dmq_usrloc_batch_size;
@@ -421,7 +422,12 @@ static int usrloc_dmq_execute_action(srjson_t 
*jdoc_action, dmq_node_t *node)
                } else if(strcmp(it->string, "flags") == 0) {
                        flags = SRJSON_GET_UINT(it);
                } else if(strcmp(it->string, "cflags") == 0) {
-                       cflags = SRJSON_GET_UINT(it);
+                       if(_dmq_usrloc_replicate_cflags == 1) {
+                               cflags = SRJSON_GET_UINT(it);
+                       } else if(_dmq_usrloc_replicate_cflags > 1) {
+                               cflags = _dmq_usrloc_replicate_cflags;
+                       }
+                       // else don't replicate cflags
                } else if(strcmp(it->string, "q") == 0) {
                        q = SRJSON_GET_UINT(it);
                } else if(strcmp(it->string, "last_modified") == 0) {

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to