Browse code

siptrace: search the send sock socket modparam in mod init

Daniel-Constantin Mierla authored on 08/04/2020 12:40:54
Showing 3 changed files
... ...
@@ -171,6 +171,7 @@ int trace_xheaders_read = 0;
171 171
 
172 172
 str trace_send_sock_str = {0, 0};
173 173
 sip_uri_t *trace_send_sock_uri = 0;
174
+socket_info_t *trace_send_sock_info = 0;
174 175
 
175 176
 str trace_dup_uri_str = {0, 0};
176 177
 sip_uri_t *trace_dup_uri = 0;
... ...
@@ -365,6 +366,9 @@ static int mod_init(void)
365 366
 		if(!trace_send_sock_uri->port_no) {
366 367
 			trace_send_sock_uri->port_no = SIP_PORT;
367 368
 		}
369
+		trace_send_sock_info = grep_sock_info(&trace_send_sock_uri->host,
370
+				trace_send_sock_uri->port_no,
371
+				trace_send_sock_uri->proto);
368 372
 	}
369 373
 
370 374
 	if(_siptrace_init_mode==SIPTRACE_INIT_MODE_ALL
... ...
@@ -43,6 +43,7 @@ extern int hep_vendor_id;
43 43
 extern str hep_auth_key_str;
44 44
 extern str trace_send_sock_str;
45 45
 extern sip_uri_t *trace_send_sock_uri;
46
+extern socket_info_t *trace_send_sock_info;
46 47
 extern str trace_dup_uri_str;
47 48
 extern sip_uri_t *trace_dup_uri;
48 49
 
... ...
@@ -588,13 +589,18 @@ int hlog(struct sip_msg *msg, str *correlationid, str *message)
588 589
 
589 590
 	if(trace_send_sock_str.s) {
590 591
 		LM_DBG("send sock activated, grep for the sock_info\n");
591
-		si = grep_sock_info(&trace_send_sock_uri->host,
592
-				trace_send_sock_uri->port_no,
593
-				trace_send_sock_uri->proto);
592
+		if(trace_send_sock_info) {
593
+			si = trace_send_sock_info;
594
+		} else {
595
+			si = grep_sock_info(&trace_send_sock_uri->host,
596
+					trace_send_sock_uri->port_no,
597
+					trace_send_sock_uri->proto);
598
+		}
594 599
 		if(!si) {
595
-			LM_WARN("cannot grep socket info\n");
600
+			LM_WARN("local socket not found for: [%.*s]\n",
601
+					trace_send_sock_str.len, trace_send_sock_str.s);
596 602
 		} else {
597
-			LM_DBG("found socket while grep: [%.*s] [%.*s]\n", si->name.len,
603
+			LM_DBG("using local send socket: [%.*s] [%.*s]\n", si->name.len,
598 604
 					si->name.s, si->address_str.len, si->address_str.s);
599 605
 			dst.send_sock = si;
600 606
 		}
... ...
@@ -42,6 +42,7 @@ extern str trace_dup_uri_str;
42 42
 extern sip_uri_t *trace_dup_uri;
43 43
 extern str trace_send_sock_str;
44 44
 extern sip_uri_t *trace_send_sock_uri;
45
+extern socket_info_t *trace_send_sock_info;
45 46
 
46 47
 /**
47 48
  *
... ...
@@ -316,13 +317,18 @@ int trace_send_duplicate(char *buf, int len, dest_info_t *dst2)
316 317
 	if(pdst->send_sock == NULL) {
317 318
 		if(trace_send_sock_str.s) {
318 319
 			LM_DBG("send sock activated, grep for the sock_info\n");
319
-			pdst->send_sock = grep_sock_info(&trace_send_sock_uri->host,
320
-					trace_send_sock_uri->port_no,
321
-					trace_send_sock_uri->proto);
320
+			if(trace_send_sock_info) {
321
+				pdst->send_sock = trace_send_sock_info;
322
+			} else {
323
+				pdst->send_sock = grep_sock_info(&trace_send_sock_uri->host,
324
+						trace_send_sock_uri->port_no,
325
+						trace_send_sock_uri->proto);
326
+			}
322 327
 			if(!pdst->send_sock) {
323
-				LM_WARN("cannot grep socket info\n");
328
+				LM_WARN("local socket not found for: [%.*s]\n",
329
+						trace_send_sock_str.len, trace_send_sock_str.s);
324 330
 			} else {
325
-				LM_DBG("found socket while grep: [%.*s] [%.*s]\n",
331
+				LM_DBG("using local send socket: [%.*s] [%.*s]\n",
326 332
 						pdst->send_sock->name.len,
327 333
 						pdst->send_sock->name.s, pdst->send_sock->address_str.len,
328 334
 						pdst->send_sock->address_str.s);