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

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2025-08-05T20:22:27+02:00

dispatcher: set from-tag for keepalives

---

Modified: src/modules/dispatcher/dispatch.c

---

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

---

diff --git a/src/modules/dispatcher/dispatch.c 
b/src/modules/dispatcher/dispatch.c
index 4c0d729310d..be4ed27d9d5 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -4205,6 +4205,23 @@ static inline int ds_ping_result_helper(ds_set_t *node, 
int j)
        return 0;
 }
 
+/**
+ *
+ */
+char *ds_rand_str4(void)
+{
+       int i;
+       static char obuf[6];
+       const char ibuf[] = "abcdefghijklmnopqrstuvwxyz0123456789";
+
+       for(i = 0; i < 4; i++) {
+               obuf[i] = ibuf[ksr_xrand() % 36];
+       }
+       obuf[4] = '\0';
+
+       return obuf;
+}
+
 /**
  *
  */
@@ -4216,6 +4233,8 @@ void ds_ping_set(ds_set_t *node)
        str obproxy;
        int state;
        ds_rctx_t rctx;
+       char ftbuf[64];
+       str ftag;
 
        if(!node)
                return;
@@ -4285,6 +4304,16 @@ void ds_ping_set(ds_set_t *node)
                                LM_DBG("Default outbound proxy: %.*s\n", 
ds_outbound_proxy.len,
                                                ds_outbound_proxy.s);
                        }
+                       ftag.len = snprintf(ftbuf, 64, "%.*s-%s", 
node->dlist[j].suid.len,
+                                       node->dlist[j].suid.s, ds_rand_str4());
+                       if(ftag.len <= 0) {
+                               LM_ERR("failed to generate the from-tag - set 
#%d URI %.*s\n",
+                                               node->id, 
node->dlist[j].uri.len, node->dlist[j].uri.s);
+                               continue;
+                       } else {
+                               ftag.s = ftbuf;
+                               uac_r.fromtag = &ftag;
+                       }
 
                        gettimeofday(&node->dlist[j].latency_stats.start, NULL);
 

_______________________________________________
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