Skip to content

Commit

Permalink
nathelper: use advertised address if send socket has one
Browse files Browse the repository at this point in the history
- reported by emanuel Buu, GH#352

(cherry picked from commit 4da31d5)
  • Loading branch information
miconda committed Nov 4, 2015
1 parent a56e598 commit c5a53e0
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions modules/nathelper/sip_pinger.h
Expand Up @@ -123,10 +123,22 @@ static inline char* build_sipping(str *curi, struct socket_info* s, str *path,
static char buf[MAX_SIPPING_SIZE];
char *p;
int len;
str vaddr;
str vport;

if(s->useinfo.name.len>0)
vaddr = s->useinfo.name;
else
vaddr = s->address_str;

if(s->useinfo.port_no>0)
vport = s->useinfo.port_no_str;
else
vport = s->port_no_str;

if ( sipping_method.len + 1 + curi->len + s_len(" SIP/2.0"CRLF) +
s_len("Via: SIP/2.0/UDP ") + s->address_str.len +
1 + s->port_no_str.len + s_len(";branch=0") +
s_len("Via: SIP/2.0/UDP ") + vaddr.len +
1 + vport.len + s_len(";branch=0") +
(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 All @@ -149,12 +161,12 @@ static inline char* build_sipping(str *curi, struct socket_info* s, str *path,
if (s->address.af == AF_INET6) { /* Via header IP is a IPv6 reference */
append_fix( p, "[");
}
append_str( p, s->address_str.s, s->address_str.len);
append_str( p, vaddr.s, vaddr.len);
if (s->address.af == AF_INET6) {
append_fix( p, "]");
}
*(p++) = ':';
append_str( p, s->port_no_str.s, s->port_no_str.len);
append_str( p, vport.s, vport.len);
if (path->len) {
append_fix( p, ";branch=0"CRLF"Route: ");
append_str( p, path->s, path->len);
Expand Down

0 comments on commit c5a53e0

Please sign in to comment.