siptrace: search the send sock socket modparam in mod init
authorDaniel-Constantin Mierla <miconda@gmail.com>
Wed, 8 Apr 2020 12:40:54 +0000 (14:40 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Wed, 8 Apr 2020 12:59:09 +0000 (14:59 +0200)
src/modules/siptrace/siptrace.c
src/modules/siptrace/siptrace_hep.c
src/modules/siptrace/siptrace_send.c

index c3876c9..1b8613a 100644 (file)
@@ -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
index 267edf8..dbd3661 100644 (file)
@@ -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;
                }
index d0694b1..8c10bd5 100644 (file)
@@ -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);