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

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2025-12-11T13:45:23+01:00

tm: new parameter ack_branch_mode to control via branch value for local ACK of 
200ok

- if 0 (default), reuse the local INVITE transaction md5 hash (existing 
behaviour)
- if 1, change some characters to make it different than INVITE
  transaction md5, to work with UAs demanding it to be different, being
  separate transaction from specs point of view

---

Modified: src/modules/tm/t_msgbuilder.c
Modified: src/modules/tm/tm.c

---

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

---

diff --git a/src/modules/tm/t_msgbuilder.c b/src/modules/tm/t_msgbuilder.c
index 6075fdbade2..1e665b1366e 100644
--- a/src/modules/tm/t_msgbuilder.c
+++ b/src/modules/tm/t_msgbuilder.c
@@ -73,6 +73,7 @@
        } while(0)
 
 extern int tm_headers_mode;
+extern int tm_ack_branch_mode;
 
 /* Build a local request based on a previous request; main
  * customers of this function are local ACK and local CANCEL
@@ -1818,6 +1819,34 @@ int t_calc_branch(struct cell *t, int b, char *branch, 
int *branch_len)
                        t->hash_index, 0, t->md5, NULL, b, branch, branch_len);
 }
 
+int t_calc_branch_ack(struct cell *t, int b, char *branch, int *branch_len)
+{
+       char md5b[MD5_LEN + 1];
+       int i = 0;
+
+       if(tm_ack_branch_mode == 1) {
+               memcpy(md5b, t->md5, MD5_LEN);
+               md5b[MD5_LEN] = '\0';
+               for(i = MD5_LEN - 1; i < 4; i--) {
+                       if(md5b[i] >= '0' && md5b[i] < '9') {
+                               md5b[i] = md5b[i] + 1;
+                       } else if(md5b[i] == '9') {
+                               md5b[i] = '0';
+                       } else if(md5b[i] >= 'a' && md5b[i] < 'z') {
+                               md5b[i] = md5b[i] + 1;
+                       } else if(md5b[i] == 'z') {
+                               md5b[i] = 'a';
+                       } else if(md5b[i] >= 'A' && md5b[i] < 'Z') {
+                               md5b[i] = md5b[i] + 1;
+                       } else if(md5b[i] == 'z') {
+                               md5b[i] = 'A';
+                       }
+               }
+       }
+
+       return branch_builder(t->hash_index, 0, md5b, NULL, b, branch, 
branch_len);
+}
+
 /**
  * build CANCEL from UAC side
  */
diff --git a/src/modules/tm/tm.c b/src/modules/tm/tm.c
index c91cb981b65..dc0718cc8d8 100644
--- a/src/modules/tm/tm.c
+++ b/src/modules/tm/tm.c
@@ -253,6 +253,8 @@ int tm_dns_reuse_rcv_socket = 0;
 
 int tm_headers_mode = 0;
 
+int tm_ack_branch_mode = 0;
+
 static rpc_export_t tm_rpc[];
 
 str tm_event_callback = STR_NULL;
@@ -523,6 +525,7 @@ static param_export_t params[] = {
        {"e2e_cancel_reason", PARAM_INT, &default_tm_cfg.e2e_cancel_reason},
        {"e2e_cancel_hop_by_hop", PARAM_INT, &tm_e2e_cancel_hop_by_hop},
        {"headers_mode", PARAM_INT, &tm_headers_mode},
+       {"ack_branch_mode", PARAM_INT, &tm_ack_branch_mode},
        {"xavp_contact", PARAM_STR, &ulattrs_xavp_name},
        {"event_callback", PARAM_STR, &tm_event_callback},
        {"relay_100", PARAM_INT, &default_tm_cfg.relay_100},

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to