Module: kamailio
Branch: 4.3
Commit: 1bf1deba22242c3a578b39e5569fc2eb9e0d9816
URL: 
https://github.com/kamailio/kamailio/commit/1bf1deba22242c3a578b39e5569fc2eb9e0d9816

Author: Erik Davidson <erik.david...@corvisa.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2016-03-03T09:14:14+01:00

siptrace: Use the trace_local_ip setting in sip_trace()

(cherry picked from commit 93dcc5dca539803ad7ae94dc86829d10d3d3412c)

---

Modified: modules/siptrace/siptrace.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/1bf1deba22242c3a578b39e5569fc2eb9e0d9816.diff
Patch: 
https://github.com/kamailio/kamailio/commit/1bf1deba22242c3a578b39e5569fc2eb9e0d9816.patch

---

diff --git a/modules/siptrace/siptrace.c b/modules/siptrace/siptrace.c
index df6ceff..8e69f0e 100644
--- a/modules/siptrace/siptrace.c
+++ b/modules/siptrace/siptrace.c
@@ -1013,29 +1013,41 @@ static int sip_trace(struct sip_msg *msg, struct 
dest_info * dst, char *dir)
                sto.body.s = msg->buf;
                sto.body.len = msg->len;
 
-               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);
+               if (trace_local_ip.s && trace_local_ip.len > 0 && 
strncmp(sto.dir, "out", 3) == 0) {
+                       sto.fromip = trace_local_ip;
+               } else {
+                       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";
+               if (trace_local_ip.s && trace_local_ip.len > 0 && 
strncmp(sto.dir, "in", 2) == 0) {
+                       sto.toip = trace_local_ip;
+               } else {
+                       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);
+               }
        } 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);
+               if (trace_local_ip.s && trace_local_ip.len > 0) {
+                       sto.fromip = trace_local_ip;
+               } else {
+                       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)));


_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to