[sr-dev] git:master:1edb4298: nathelper: set via branch according to "z9hG4bK..." format (instead of "branch=0")

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


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

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

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

---

Modified: modules/nathelper/sip_pinger.h

---

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

---

diff --git a/modules/nathelper/sip_pinger.h b/modules/nathelper/sip_pinger.h
index 7cd5e0c..5166a75 100644
--- a/modules/nathelper/sip_pinger.h
+++ b/modules/nathelper/sip_pinger.h
@@ -116,6 +116,9 @@ static inline char* build_sipping(str *curi, struct socket_info* s, str *path,
 								str *ruid, unsigned int aorhash, int *len_p)
 {
 #define s_len(_s) (sizeof(_s)-1)
+#define MAX_BRANCHID 9999999
+#define MIN_BRANCHID 1000000
+#define LEN_BRANCHID 7  /* NOTE: this must be sync with the MX and MIN values !! */
 	static char buf[MAX_SIPPING_SIZE];
 	char *p;
 	int len;
@@ -135,7 +138,7 @@ static inline char* build_sipping(str *curi, struct socket_info* s, str *path,
 	if ( sipping_method.len + 1 + curi->len + s_len(" SIP/2.0"CRLF) +
 		s_len("Via: SIP/2.0/UDP ") + vaddr.len +
 				((s->address.af==AF_INET6)?2:0) +
-				1 + vport.len + s_len(";branch=0") +
+				1 + vport.len + s_len(";branch=z9hG4bK") + LEN_BRANCHID +
 		(path->len ? (s_len(CRLF"Route: ") + path->len) : 0) +
 		s_len(CRLF"From: ") +  sipping_from.len + s_len(";tag=") +
 				ruid->len + 1 + 8 + 1 + 8 +
@@ -164,13 +167,16 @@ static inline char* build_sipping(str *curi, struct socket_info* s, str *path,
 	}
 	*(p++) = ':';
 	append_str( p, vport.s, vport.len);
+	append_fix( p, ";branch=z9hG4bK");
+	int2bstr(
+		(long)(rand()/(float)RAND_MAX * (MAX_BRANCHID-MIN_BRANCHID) + MIN_BRANCHID),
+		p+LEN_BRANCHID-INT2STR_MAX_LEN+1, NULL);
+	p += LEN_BRANCHID;
 	if (path->len) {
-		append_fix( p, ";branch=0"CRLF"Route: ");
+		append_fix( p, CRLF"Route: ");
 		append_str( p, path->s, path->len);
-		append_fix( p, CRLF"From: ");
-	} else {
-		append_fix( p, ";branch=0"CRLF"From: ");
 	}
+	append_fix( p, CRLF"From: ");
 	append_str( p, sipping_from.s, sipping_from.len);
 	append_fix( p, ";tag=");
 	append_str( p, ruid->s, ruid->len);




More information about the sr-dev mailing list