[sr-dev] git:master:4da31d56: nathelper: use advertised address if send socket has one
Daniel-Constantin Mierla
miconda at gmail.com
Sun Oct 4 06:31:12 CEST 2015
Module: kamailio
Branch: master
Commit: 4da31d56f4b1e18fc4232c5174637c858c75e9db
URL: https://github.com/kamailio/kamailio/commit/4da31d56f4b1e18fc4232c5174637c858c75e9db
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-10-04T06:28:39+02:00
nathelper: use advertised address if send socket has one
- reported by emanuel Buu, GH#352
---
Modified: modules/nathelper/sip_pinger.h
---
Diff: https://github.com/kamailio/kamailio/commit/4da31d56f4b1e18fc4232c5174637c858c75e9db.diff
Patch: https://github.com/kamailio/kamailio/commit/4da31d56f4b1e18fc4232c5174637c858c75e9db.patch
---
diff --git a/modules/nathelper/sip_pinger.h b/modules/nathelper/sip_pinger.h
index fc18f96..9db8144 100644
--- a/modules/nathelper/sip_pinger.h
+++ b/modules/nathelper/sip_pinger.h
@@ -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 +
@@ -146,9 +158,9 @@ static inline char* build_sipping(str *curi, struct socket_info* s, str *path,
*(p++) = ' ';
append_str( p, curi->s, curi->len);
append_fix( p, " SIP/2.0"CRLF"Via: SIP/2.0/UDP ");
- append_str( p, s->address_str.s, s->address_str.len);
+ append_str( p, vaddr.s, vaddr.len);
*(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);
More information about the sr-dev
mailing list