Skip to content

Commit

Permalink
nathelper: set via branch according to "z9hG4bK..." format (instead o…
Browse files Browse the repository at this point in the history
…f "branch=0")

(cherry picked from commit 1edb429)
  • Loading branch information
snen authored and miconda committed Jun 27, 2016
1 parent 00f6c9f commit ffd5b68
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions modules/nathelper/sip_pinger.h
Expand Up @@ -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;
Expand All @@ -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 +
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ffd5b68

Please sign in to comment.