Module: sip-router
Branch: master
Commit: ae8f15dcdea73156dbc704bc46908b76ba174393
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ae8f15d…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Aug 8 20:27:17 2012 +0200
nathelper(k): use usrloc ruid and aorhash to build from tag of SIP keepalives
- update due to last change in usrloc get all records API function
- these values can be used to identify the usrloc records (e.g., upon
handling the SIP keepalive reply)
---
modules_k/nathelper/nathelper.c | 10 +++++++++-
modules_k/nathelper/sip_pinger.h | 16 +++++++++++-----
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/modules_k/nathelper/nathelper.c b/modules_k/nathelper/nathelper.c
index 4afae00..e5bfc89 100644
--- a/modules_k/nathelper/nathelper.c
+++ b/modules_k/nathelper/nathelper.c
@@ -1676,6 +1676,8 @@ nh_timer(unsigned int ticks, void *timer_idx)
str c;
str opt;
str path;
+ str ruid;
+ unsigned int aorhash;
struct sip_uri curi;
struct hostent* he;
struct socket_info* send_sock;
@@ -1736,6 +1738,11 @@ nh_timer(unsigned int ticks, void *timer_idx)
memcpy( &(path.len), cp, sizeof(path.len));
path.s = path.len ? ((char*)cp + sizeof(path.len)) : NULL ;
cp = (char*)cp + sizeof(path.len) + path.len;
+ memcpy( &(ruid.len), cp, sizeof(ruid.len));
+ ruid.s = ruid.len ? ((char*)cp + sizeof(ruid.len)) : NULL ;
+ cp = (char*)cp + sizeof(ruid.len) + ruid.len;
+ memcpy( &aorhash, cp, sizeof(aorhash));
+ cp = (char*)cp + sizeof(aorhash);
/* determin the destination */
if ( path.len && (flags&sipping_flag)!=0 ) {
@@ -1782,7 +1789,8 @@ nh_timer(unsigned int ticks, void *timer_idx)
dst.send_sock=send_sock;
if ( (flags&sipping_flag)!=0 &&
- (opt.s=build_sipping( &c, send_sock, &path, &opt.len))!=0 ) {
+ (opt.s=build_sipping( &c, send_sock, &path, &ruid, aorhash,
+ &opt.len))!=0 ) {
if (udp_send(&dst, opt.s, opt.len)<0){
LM_ERR("sip udp_send failed\n");
}
diff --git a/modules_k/nathelper/sip_pinger.h b/modules_k/nathelper/sip_pinger.h
index dac6c8a..c6098b3 100644
--- a/modules_k/nathelper/sip_pinger.h
+++ b/modules_k/nathelper/sip_pinger.h
@@ -117,7 +117,7 @@ error:
/* build the buffer of a SIP ping request */
static inline char* build_sipping(str *curi, struct socket_info* s, str *path,
- int *len_p)
+ str *ruid, unsigned int aorhash, int *len_p)
{
#define s_len(_s) (sizeof(_s)-1)
static char buf[MAX_SIPPING_SIZE];
@@ -126,15 +126,16 @@ 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 ") + s->address_str.len +
- 1 + s->port_no_str.len + s_len(";branch=0") +
+ 1 + s->port_no_str.len + s_len(";branch=0") +
(path->len ? (s_len(CRLF"Route: ") + path->len) : 0) +
- s_len(CRLF"From: ") + sipping_from.len + s_len(";tag=") + 8 +
+ s_len(CRLF"From: ") + sipping_from.len + s_len(";tag=") +
+ sipping_from.len + 1 + 8 + 1 + 8 +
s_len(CRLF"To: ") + curi->len +
s_len(CRLF"Call-ID: ") + sipping_callid.len + 1 + 8 + 1 + 8 + 1 +
- s->address_str.len +
+ s->address_str.len +
s_len(CRLF"CSeq: 1 ") + sipping_method.len +
s_len(CRLF"Content-Length: 0" CRLF CRLF)
- > MAX_SIPPING_SIZE )
+ > MAX_SIPPING_SIZE )
{
LM_ERR("len exceeds %d\n",MAX_SIPPING_SIZE);
return 0;
@@ -157,6 +158,11 @@ static inline char* build_sipping(str *curi, struct socket_info* s,
str *path,
}
append_str( p, sipping_from.s, sipping_from.len);
append_fix( p, ";tag=");
+ append_str( p, ruid->s, ruid->len);
+ *(p++) = '-';
+ len = 8;
+ int2reverse_hex( &p, &len, aorhash );
+ *(p++) = '-';
len = 8;
int2reverse_hex( &p, &len, sipping_fromtag++ );
append_fix( p, CRLF"To: ");