Browse code

siptrace: fallback to udp if send sock is not set

(cherry picked from commit a5f8810223021939b12eb0d04fc625f8d36980f7)

Daniel-Constantin Mierla authored on 09/04/2021 14:37:30
Showing 1 changed files
... ...
@@ -2150,6 +2150,7 @@ int siptrace_net_data_sent(sr_event_param_t *evp)
2150 2150
 	dest_info_t new_dst;
2151 2151
 	siptrace_data_t sto;
2152 2152
 	sip_msg_t tmsg;
2153
+	int proto;
2153 2154
 
2154 2155
 	if(evp->data == 0)
2155 2156
 		return -1;
... ...
@@ -2177,6 +2178,7 @@ int siptrace_net_data_sent(sr_event_param_t *evp)
2177 2178
 		LM_WARN("no sending socket found\n");
2178 2179
 		strcpy(sto.fromip_buff, SIPTRACE_ANYADDR);
2179 2180
 		sto.fromip.len = SIPTRACE_ANYADDR_LEN;
2181
+		proto = PROTO_UDP;
2180 2182
 	} else {
2181 2183
 		if(new_dst.send_sock->sock_str.len>=SIPTRACE_ADDR_MAX-1) {
2182 2184
 			LM_ERR("socket string is too large: %d\n",
... ...
@@ -2186,11 +2188,12 @@ int siptrace_net_data_sent(sr_event_param_t *evp)
2186 2188
 		strncpy(sto.fromip_buff, new_dst.send_sock->sock_str.s,
2187 2189
 				new_dst.send_sock->sock_str.len);
2188 2190
 		sto.fromip.len = new_dst.send_sock->sock_str.len;
2191
+		proto = new_dst.send_sock->proto;
2189 2192
 	}
2190 2193
 	sto.fromip.s = sto.fromip_buff;
2191 2194
 
2192 2195
 	sto.toip.len = snprintf(sto.toip_buff, SIPTRACE_ADDR_MAX, "%s:%s:%d",
2193
-			siptrace_proto_name(new_dst.send_sock->proto),
2196
+			siptrace_proto_name(proto),
2194 2197
 			suip2a(&new_dst.to, sizeof(new_dst.to)),
2195 2198
 			(int)su_getport(&new_dst.to));
2196 2199
 	if(sto.toip.len<0 || sto.toip.len>=SIPTRACE_ADDR_MAX) {