Module: kamailio
Branch: master
Commit: 479ac8ed7e3c20254c2c3a449a9e23579689b0ab
URL: 
https://github.com/kamailio/kamailio/commit/479ac8ed7e3c20254c2c3a449a9e23579689b0ab

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2016-03-01T23:32:02+01:00

Merge pull request #524 from aphistic/fix-siptrace-aliasing

siptrace: Use the trace_local_ip setting in sip_trace()

---

Modified: modules/siptrace/siptrace.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/479ac8ed7e3c20254c2c3a449a9e23579689b0ab.diff
Patch: 
https://github.com/kamailio/kamailio/commit/479ac8ed7e3c20254c2c3a449a9e23579689b0ab.patch

---

diff --git a/modules/siptrace/siptrace.c b/modules/siptrace/siptrace.c
index 613ea31..4594e25 100644
--- a/modules/siptrace/siptrace.c
+++ b/modules/siptrace/siptrace.c
@@ -1022,29 +1022,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
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to