Module: sip-router
Branch: master
Commit: 9d8df2527d13878cee23af5b14f142a0cc4cd878
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9d8df25…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue Aug 16 17:59:30 2011 +0200
siptrace: support to use sip_trace() in onsend_route
---
modules_k/siptrace/siptrace.c | 52 +++++++++++++++++++++++++++++-----------
1 files changed, 37 insertions(+), 15 deletions(-)
diff --git a/modules_k/siptrace/siptrace.c b/modules_k/siptrace/siptrace.c
index 5869e27..9b768e8 100644
--- a/modules_k/siptrace/siptrace.c
+++ b/modules_k/siptrace/siptrace.c
@@ -780,6 +780,7 @@ error:
static int sip_trace(struct sip_msg *msg, char *dir, char *s2)
{
struct _siptrace_data sto;
+ struct onsend_info *snd_inf = NULL;
if(msg==NULL) {
LM_DBG("nothing to trace\n");
@@ -798,8 +799,6 @@ static int sip_trace(struct sip_msg *msg, char *dir, char *s2)
if(sip_trace_prepare(msg)<0)
return -1;
- sto.body.s = msg->buf;
- sto.body.len = msg->len;
sto.callid = msg->callid->body;
if(msg->first_line.type==SIP_REQUEST) {
@@ -816,21 +815,44 @@ static int sip_trace(struct sip_msg *msg, char *dir, char *s2)
sto.status.len = 0;
}
- siptrace_copy_proto(msg->rcv.proto, sto.fromip_buff);
- strcat(sto.fromip_buff, ip_addr2a(&msg->rcv.src_ip));
- strcat(sto.fromip_buff,":");
- strcat(sto.fromip_buff, int2str(msg->rcv.src_port, NULL));
- sto.fromip.s = sto.fromip_buff;
- sto.fromip.len = strlen(sto.fromip_buff);
+ snd_inf=get_onsend_info();
+ if(snd_inf==NULL) {
+ sto.body.s = msg->buf;
+ sto.body.len = msg->len;
- siptrace_copy_proto(msg->rcv.proto, sto.toip_buff);
- strcat(sto.toip_buff, ip_addr2a(&msg->rcv.dst_ip));
- strcat(sto.toip_buff,":");
- strcat(sto.toip_buff, int2str(msg->rcv.dst_port, NULL));
- sto.toip.s = sto.toip_buff;
- sto.toip.len = strlen(sto.toip_buff);
+ siptrace_copy_proto(msg->rcv.proto, sto.fromip_buff);
+ strcat(sto.fromip_buff, ip_addr2a(&msg->rcv.src_ip));
+ strcat(sto.fromip_buff,":");
+ strcat(sto.fromip_buff, int2str(msg->rcv.src_port, NULL));
+ sto.fromip.s = sto.fromip_buff;
+ sto.fromip.len = strlen(sto.fromip_buff);
- sto.dir = (dir)?dir:"in";
+ siptrace_copy_proto(msg->rcv.proto, sto.toip_buff);
+ strcat(sto.toip_buff, ip_addr2a(&msg->rcv.dst_ip));
+ strcat(sto.toip_buff,":");
+ strcat(sto.toip_buff, int2str(msg->rcv.dst_port, NULL));
+ sto.toip.s = sto.toip_buff;
+ sto.toip.len = strlen(sto.toip_buff);
+
+ sto.dir = (dir)?dir:"in";
+ } else {
+ sto.body.s = snd_inf->buf;
+ sto.body.len = snd_inf->len;
+
+ strncpy(sto.fromip_buff, snd_inf->send_sock->sock_str.s,
+ snd_inf->send_sock->sock_str.len);
+ sto.fromip.s = sto.fromip_buff;
+ sto.fromip.len = strlen(sto.fromip_buff);
+
+ siptrace_copy_proto(snd_inf->send_sock->proto, sto.toip_buff);
+ strcat(sto.toip_buff, suip2a(snd_inf->to, sizeof(*snd_inf->to)));
+ strcat(sto.toip_buff,":");
+ strcat(sto.toip_buff, int2str((int)su_getport(snd_inf->to), NULL));
+ sto.toip.s = sto.toip_buff;
+ sto.toip.len = strlen(sto.toip_buff);
+
+ sto.dir = "out";
+ }
sto.fromtag = get_from(msg)->tag_value;