[sr-dev] git:master:5261c1d0: nat_traversal: set via branch according to "z9hG4bK..." format (instead of "branch=0")

Dmitri Savolainen savolainen at erinaco.ru
Mon Jun 27 15:00:38 CEST 2016


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

Author: Dmitri Savolainen <savolainen at erinaco.ru>
Committer: Dmitri Savolainen <savolainen at erinaco.ru>
Date: 2016-06-27T12:53:01+03:00

nat_traversal: set via branch according to "z9hG4bK..." format (instead of "branch=0")

---

Modified: modules/nat_traversal/nat_traversal.c

---

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

---

diff --git a/modules/nat_traversal/nat_traversal.c b/modules/nat_traversal/nat_traversal.c
index 0acdd17..fb1dd30 100644
--- a/modules/nat_traversal/nat_traversal.c
+++ b/modules/nat_traversal/nat_traversal.c
@@ -1508,6 +1508,8 @@ ClientNatTest(struct sip_msg *msg, unsigned int tests)
 
 
 #define FROM_PREFIX "sip:keepalive@"
+#define MAX_BRANCHID 9999999
+#define MIN_BRANCHID 1000000
 
 static void
 send_keepalive(NAT_Contact *contact)
@@ -1536,7 +1538,7 @@ send_keepalive(NAT_Contact *contact)
 
     len = snprintf(buffer, sizeof(buffer),
                    "%s %s SIP/2.0\r\n"
-                   "Via: SIP/2.0/UDP %.*s:%d;branch=0\r\n"
+                   "Via: SIP/2.0/UDP %.*s:%d;branch=z9hG4bK%ld\r\n"
                    "From: %s;tag=%x\r\n"
                    "To: %s\r\n"
                    "Call-ID: %s-%x-%x@%.*s\r\n"
@@ -1546,6 +1548,7 @@ send_keepalive(NAT_Contact *contact)
                    keepalive_params.method, contact->uri,
                    contact->socket->address_str.len,
                    contact->socket->address_str.s, contact->socket->port_no,
+                   (long)(rand()/(float)RAND_MAX * (MAX_BRANCHID-MIN_BRANCHID) + MIN_BRANCHID),
                    from_uri, keepalive_params.from_tag++,
                    contact->uri, keepalive_params.callid_prefix,
                    keepalive_params.callid_counter++, get_ticks(),




More information about the sr-dev mailing list