Module: kamailio
Branch: master
Commit: 1f524060fdba9093166e44cd462501fe38f64935
URL:
https://github.com/kamailio/kamailio/commit/1f524060fdba9093166e44cd462501f…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-04-08T14:59:09+02:00
siptrace: search the send sock socket modparam in mod init
---
Modified: src/modules/siptrace/siptrace.c
Modified: src/modules/siptrace/siptrace_hep.c
Modified: src/modules/siptrace/siptrace_send.c
---
Diff:
https://github.com/kamailio/kamailio/commit/1f524060fdba9093166e44cd462501f…
Patch:
https://github.com/kamailio/kamailio/commit/1f524060fdba9093166e44cd462501f…
---
diff --git a/src/modules/siptrace/siptrace.c b/src/modules/siptrace/siptrace.c
index c3876c9108..1b8613ae99 100644
--- a/src/modules/siptrace/siptrace.c
+++ b/src/modules/siptrace/siptrace.c
@@ -171,6 +171,7 @@ int trace_xheaders_read = 0;
str trace_send_sock_str = {0, 0};
sip_uri_t *trace_send_sock_uri = 0;
+socket_info_t *trace_send_sock_info = 0;
str trace_dup_uri_str = {0, 0};
sip_uri_t *trace_dup_uri = 0;
@@ -365,6 +366,9 @@ static int mod_init(void)
if(!trace_send_sock_uri->port_no) {
trace_send_sock_uri->port_no = SIP_PORT;
}
+ trace_send_sock_info = grep_sock_info(&trace_send_sock_uri->host,
+ trace_send_sock_uri->port_no,
+ trace_send_sock_uri->proto);
}
if(_siptrace_init_mode==SIPTRACE_INIT_MODE_ALL
diff --git a/src/modules/siptrace/siptrace_hep.c b/src/modules/siptrace/siptrace_hep.c
index 267edf8b74..dbd3661a6b 100644
--- a/src/modules/siptrace/siptrace_hep.c
+++ b/src/modules/siptrace/siptrace_hep.c
@@ -43,6 +43,7 @@ extern int hep_vendor_id;
extern str hep_auth_key_str;
extern str trace_send_sock_str;
extern sip_uri_t *trace_send_sock_uri;
+extern socket_info_t *trace_send_sock_info;
extern str trace_dup_uri_str;
extern sip_uri_t *trace_dup_uri;
@@ -588,13 +589,18 @@ int hlog(struct sip_msg *msg, str *correlationid, str *message)
if(trace_send_sock_str.s) {
LM_DBG("send sock activated, grep for the sock_info\n");
- si = grep_sock_info(&trace_send_sock_uri->host,
- trace_send_sock_uri->port_no,
- trace_send_sock_uri->proto);
+ if(trace_send_sock_info) {
+ si = trace_send_sock_info;
+ } else {
+ si = grep_sock_info(&trace_send_sock_uri->host,
+ trace_send_sock_uri->port_no,
+ trace_send_sock_uri->proto);
+ }
if(!si) {
- LM_WARN("cannot grep socket info\n");
+ LM_WARN("local socket not found for: [%.*s]\n",
+ trace_send_sock_str.len, trace_send_sock_str.s);
} else {
- LM_DBG("found socket while grep: [%.*s] [%.*s]\n", si->name.len,
+ LM_DBG("using local send socket: [%.*s] [%.*s]\n", si->name.len,
si->name.s, si->address_str.len, si->address_str.s);
dst.send_sock = si;
}
diff --git a/src/modules/siptrace/siptrace_send.c b/src/modules/siptrace/siptrace_send.c
index d0694b1d44..8c10bd5f0e 100644
--- a/src/modules/siptrace/siptrace_send.c
+++ b/src/modules/siptrace/siptrace_send.c
@@ -42,6 +42,7 @@ extern str trace_dup_uri_str;
extern sip_uri_t *trace_dup_uri;
extern str trace_send_sock_str;
extern sip_uri_t *trace_send_sock_uri;
+extern socket_info_t *trace_send_sock_info;
/**
*
@@ -316,13 +317,18 @@ int trace_send_duplicate(char *buf, int len, dest_info_t *dst2)
if(pdst->send_sock == NULL) {
if(trace_send_sock_str.s) {
LM_DBG("send sock activated, grep for the sock_info\n");
- pdst->send_sock = grep_sock_info(&trace_send_sock_uri->host,
- trace_send_sock_uri->port_no,
- trace_send_sock_uri->proto);
+ if(trace_send_sock_info) {
+ pdst->send_sock = trace_send_sock_info;
+ } else {
+ pdst->send_sock = grep_sock_info(&trace_send_sock_uri->host,
+ trace_send_sock_uri->port_no,
+ trace_send_sock_uri->proto);
+ }
if(!pdst->send_sock) {
- LM_WARN("cannot grep socket info\n");
+ LM_WARN("local socket not found for: [%.*s]\n",
+ trace_send_sock_str.len, trace_send_sock_str.s);
} else {
- LM_DBG("found socket while grep: [%.*s] [%.*s]\n",
+ LM_DBG("using local send socket: [%.*s] [%.*s]\n",
pdst->send_sock->name.len,
pdst->send_sock->name.s, pdst->send_sock->address_str.len,
pdst->send_sock->address_str.s);