[sr-dev] git:master:57e7b28b: siptrace: use SREV_NET_DATA_RECV event for incoming traffic with trace_mode=1
Daniel-Constantin Mierla
miconda at gmail.com
Mon Jan 11 22:50:56 CET 2016
Module: kamailio
Branch: master
Commit: 57e7b28bd811971f16154cee08acc2d2024dee76
URL: https://github.com/kamailio/kamailio/commit/57e7b28bd811971f16154cee08acc2d2024dee76
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-01-11T22:24:28+01:00
siptrace: use SREV_NET_DATA_RECV event for incoming traffic with trace_mode=1
---
Modified: modules/siptrace/siptrace.c
---
Diff: https://github.com/kamailio/kamailio/commit/57e7b28bd811971f16154cee08acc2d2024dee76.diff
Patch: https://github.com/kamailio/kamailio/commit/57e7b28bd811971f16154cee08acc2d2024dee76.patch
---
diff --git a/modules/siptrace/siptrace.c b/modules/siptrace/siptrace.c
index 7c689c3..613ea31 100644
--- a/modules/siptrace/siptrace.c
+++ b/modules/siptrace/siptrace.c
@@ -107,6 +107,7 @@ static void trace_sl_ack_in(sl_cbp_t *slcb);
static int trace_send_hep_duplicate(str *body, str *from, str *to, struct dest_info*);
static int pipport2su (char *pipport, union sockaddr_union *tmp_su, unsigned int *proto);
+int siptrace_net_data_recv(void *data);
int siptrace_net_data_send(void *data);
static int _siptrace_mode = 0;
@@ -454,6 +455,7 @@ static int mod_init(void)
}
if(_siptrace_mode==1) {
+ sr_event_register_cb(SREV_NET_DATA_RECV, siptrace_net_data_recv);
sr_event_register_cb(SREV_NET_DATA_SEND, siptrace_net_data_send);
}
return 0;
@@ -1914,6 +1916,48 @@ static int pipport2su (char *pipport, union sockaddr_union *tmp_su, unsigned int
return -1;
}
+
+/**
+ *
+ */
+int siptrace_net_data_recv(void *data)
+{
+ sr_net_info_t *nd;
+ struct _siptrace_data sto;
+
+ if(data==0)
+ return -1;
+
+ nd = (sr_net_info_t*)data;
+ if(nd->rcv==NULL || nd->data.s==NULL || nd->data.len<=0)
+ return -1;
+
+ memset(&sto, 0, sizeof(struct _siptrace_data));
+
+ sto.body.s = nd->data.s;
+ sto.body.len = nd->data.len;
+
+ siptrace_copy_proto(nd->rcv->proto, sto.fromip_buff);
+ strcat(sto.fromip_buff, ip_addr2a(&nd->rcv->src_ip));
+ strcat(sto.fromip_buff,":");
+ strcat(sto.fromip_buff, int2str(nd->rcv->src_port, NULL));
+ sto.fromip.s = sto.fromip_buff;
+ sto.fromip.len = strlen(sto.fromip_buff);
+
+ siptrace_copy_proto(nd->rcv->proto, sto.toip_buff);
+ strcat(sto.toip_buff, ip_addr2a(&nd->rcv->dst_ip));
+ strcat(sto.toip_buff,":");
+ strcat(sto.toip_buff, int2str(nd->rcv->dst_port, NULL));
+ sto.toip.s = sto.toip_buff;
+ sto.toip.len = strlen(sto.toip_buff);
+
+ sto.dir = "in";
+
+ trace_send_hep_duplicate(&sto.body, &sto.fromip, &sto.toip, NULL);
+ return 0;
+
+}
+
/**
*
*/
More information about the sr-dev
mailing list