Browse code

siptrace: skip non-sip traffic for db storage using core callbacks

Daniel-Constantin Mierla authored on 02/05/2020 13:02:55
Showing 1 changed files
... ...
@@ -2077,6 +2077,24 @@ int siptrace_net_data_recv(sr_event_param_t *evp)
2077 2077
 			goto afterdb;
2078 2078
 		}
2079 2079
 
2080
+		if(tmsg.first_line.type==SIP_REQUEST) {
2081
+			if(!IS_SIP(&tmsg)) {
2082
+				LM_DBG("non sip request message\n");
2083
+				free_sip_msg(&tmsg);
2084
+				goto afterdb;
2085
+			}
2086
+		} else if(tmsg.first_line.type==SIP_REPLY) {
2087
+			if(!IS_SIP_REPLY(&tmsg)) {
2088
+				LM_DBG("non sip reply message\n");
2089
+				free_sip_msg(&tmsg);
2090
+				goto afterdb;
2091
+			}
2092
+		} else {
2093
+			LM_DBG("unknown sip message type %d\n", tmsg.first_line.type);
2094
+			free_sip_msg(&tmsg);
2095
+			goto afterdb;
2096
+		}
2097
+
2080 2098
 		if(sip_trace_msg_attrs(&tmsg, &sto) < 0) {
2081 2099
 			free_sip_msg(&tmsg);
2082 2100
 			goto afterdb;
... ...
@@ -2179,6 +2197,24 @@ int siptrace_net_data_send(sr_event_param_t *evp)
2179 2197
 			goto afterdb;
2180 2198
 		}
2181 2199
 
2200
+		if(tmsg.first_line.type==SIP_REQUEST) {
2201
+			if(!IS_SIP(&tmsg)) {
2202
+				LM_DBG("non sip request message\n");
2203
+				free_sip_msg(&tmsg);
2204
+				goto afterdb;
2205
+			}
2206
+		} else if(tmsg.first_line.type==SIP_REPLY) {
2207
+			if(!IS_SIP_REPLY(&tmsg)) {
2208
+				LM_DBG("non sip reply message\n");
2209
+				free_sip_msg(&tmsg);
2210
+				goto afterdb;
2211
+			}
2212
+		} else {
2213
+			LM_DBG("unknown sip message type %d\n", tmsg.first_line.type);
2214
+			free_sip_msg(&tmsg);
2215
+			goto afterdb;
2216
+		}
2217
+
2182 2218
 		if(sip_trace_msg_attrs(&tmsg, &sto) < 0) {
2183 2219
 			free_sip_msg(&tmsg);
2184 2220
 			goto afterdb;