Browse code

siptrace: fallback to udp if send sock is not set

Daniel-Constantin Mierla authored on 09/04/2021 14:37:30
Showing 1 changed files
... ...
@@ -2211,6 +2211,7 @@ int siptrace_net_data_sent(sr_event_param_t *evp)
2211 2211
 	dest_info_t new_dst;
2212 2212
 	siptrace_data_t sto;
2213 2213
 	sip_msg_t tmsg;
2214
+	int proto;
2214 2215
 
2215 2216
 	if(evp->data == 0)
2216 2217
 		return -1;
... ...
@@ -2238,6 +2239,7 @@ int siptrace_net_data_sent(sr_event_param_t *evp)
2238 2239
 		LM_WARN("no sending socket found\n");
2239 2240
 		strcpy(sto.fromip_buff, SIPTRACE_ANYADDR);
2240 2241
 		sto.fromip.len = SIPTRACE_ANYADDR_LEN;
2242
+		proto = PROTO_UDP;
2241 2243
 	} else {
2242 2244
 		if(new_dst.send_sock->sock_str.len>=SIPTRACE_ADDR_MAX-1) {
2243 2245
 			LM_ERR("socket string is too large: %d\n",
... ...
@@ -2247,11 +2249,12 @@ int siptrace_net_data_sent(sr_event_param_t *evp)
2247 2249
 		strncpy(sto.fromip_buff, new_dst.send_sock->sock_str.s,
2248 2250
 				new_dst.send_sock->sock_str.len);
2249 2251
 		sto.fromip.len = new_dst.send_sock->sock_str.len;
2252
+		proto = new_dst.send_sock->proto;
2250 2253
 	}
2251 2254
 	sto.fromip.s = sto.fromip_buff;
2252 2255
 
2253 2256
 	sto.toip.len = snprintf(sto.toip_buff, SIPTRACE_ADDR_MAX, "%s:%s:%d",
2254
-			siptrace_proto_name(new_dst.send_sock->proto),
2257
+			siptrace_proto_name(proto),
2255 2258
 			suip2a(&new_dst.to, sizeof(new_dst.to)),
2256 2259
 			(int)su_getport(&new_dst.to));
2257 2260
 	if(sto.toip.len<0 || sto.toip.len>=SIPTRACE_ADDR_MAX) {