A (tiny) effort to reduce memory usage per flow (#1304)

Follow-up of 22241a1d
Only trivial changes:
* remove completely unused fields
* remove fields only written (but never read)
* CSGO protocol only handles UDP traffic
This commit is contained in:
Ivan Nardi
2021-09-18 09:29:45 +02:00
committed by GitHub
parent 4539e96ce2
commit 227e586e63
10 changed files with 25 additions and 243 deletions
+14 -14
View File
@@ -38,18 +38,18 @@ void ndpi_search_csgo(struct ndpi_detection_module_struct* ndpi_struct, struct n
uint32_t w = htonl(get_u_int32_t(packet->payload, 0));
NDPI_LOG_DBG2(ndpi_struct, "CSGO: word %08x\n", w);
if(!flow->csgo_state && packet->payload_packet_len == 23 && w == 0xfffffffful) {
if(!flow->l4.udp.csgo_state && packet->payload_packet_len == 23 && w == 0xfffffffful) {
if(!memcmp(packet->payload + 5, "connect0x", 9)) {
flow->csgo_state++;
memcpy(flow->csgo_strid, packet->payload + 5, 18);
flow->l4.udp.csgo_state++;
memcpy(flow->l4.udp.csgo_strid, packet->payload + 5, 18);
NDPI_LOG_DBG2(ndpi_struct, "Found csgo connect0x\n");
return;
}
}
if(flow->csgo_state == 1 && packet->payload_packet_len >= 42 && w == 0xfffffffful) {
if(!memcmp(packet->payload + 24, flow->csgo_strid, 18)) {
flow->csgo_state++;
if(flow->l4.udp.csgo_state == 1 && packet->payload_packet_len >= 42 && w == 0xfffffffful) {
if(!memcmp(packet->payload + 24, flow->l4.udp.csgo_strid, 18)) {
flow->l4.udp.csgo_state++;
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
NDPI_LOG_INFO( ndpi_struct, "found csgo connect0x reply\n");
return;
@@ -77,32 +77,32 @@ void ndpi_search_csgo(struct ndpi_detection_module_struct* ndpi_struct, struct n
}
}
if(flow->csgo_s2 < 3 && (w & 0xffff0000ul) == 0x0d1d0000) {
if(flow->l4.udp.csgo_s2 < 3 && (w & 0xffff0000ul) == 0x0d1d0000) {
uint32_t w2 = get_u_int32_t(packet->payload, 2);
if(packet->payload_packet_len == 13) {
if(!flow->csgo_s2) {
flow->csgo_id2 = w2;
flow->csgo_s2 = 1;
if(!flow->l4.udp.csgo_s2) {
flow->l4.udp.csgo_id2 = w2;
flow->l4.udp.csgo_s2 = 1;
NDPI_LOG_DBG2( ndpi_struct, "Found csgo udp 0d1d step1\n");
return;
}
if(flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
if(flow->l4.udp.csgo_s2 == 1 && flow->l4.udp.csgo_id2 == w2) {
NDPI_LOG_DBG2( ndpi_struct, "Found csgo udp 0d1d step1 DUP\n");
return;
}
flow->csgo_s2 = 3;
flow->l4.udp.csgo_s2 = 3;
return;
}
if(packet->payload_packet_len == 15) {
if(flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
if(flow->l4.udp.csgo_s2 == 1 && flow->l4.udp.csgo_id2 == w2) {
NDPI_LOG_INFO( ndpi_struct, "found csgo udp 0d1d\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
}
}
flow->csgo_s2 = 3;
flow->l4.udp.csgo_s2 = 3;
}
if(packet->payload_packet_len >= 140 && (w == 0x02124c6c || w == 0x02125c6c) &&
-4
View File
@@ -39,11 +39,7 @@
static void ndpi_int_direct_download_link_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, NDPI_PROTOCOL_UNKNOWN);
flow->l4.tcp.ddlink_server_direction = packet->packet_direction;
}
-1
View File
@@ -554,7 +554,6 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
flow->extra_packets_func = NULL; /* We're good now */
if(len > 0) ndpi_check_dga_name(ndpi_struct, flow, (char*)flow->host_server_name, 1);
flow->server_id = flow->dst;
if(packet->forwarded_line.ptr) {
len = ndpi_min(packet->forwarded_line.len, sizeof(flow->protos.http.nat_ip)-1);
-16
View File
@@ -42,9 +42,6 @@ void ndpi_search_rtsp_tcp_udp(struct ndpi_detection_module_struct
{
struct ndpi_packet_struct *packet = &flow->packet;
struct ndpi_id_struct *src = flow->src;
struct ndpi_id_struct *dst = flow->dst;
NDPI_LOG_DBG(ndpi_struct, "search RTSP\n");
if (packet->parsed_lines == 0)
@@ -84,20 +81,7 @@ void ndpi_search_rtsp_tcp_udp(struct ndpi_detection_module_struct
if((memcmp(packet->payload, "RTSP/1.0 ", 9) == 0)
|| (strstr(buf, "rtsp://") != NULL)) {
NDPI_LOG_DBG2(ndpi_struct, "found RTSP/1.0 \n");
if (dst != NULL) {
NDPI_LOG_DBG2(ndpi_struct, "found dst\n");
ndpi_packet_src_ip_get(packet, &dst->rtsp_ip_address);
dst->rtsp_timer = packet->current_time_ms;
dst->rtsp_ts_set = 1;
}
if (src != NULL) {
NDPI_LOG_DBG2(ndpi_struct, "found src\n");
ndpi_packet_dst_ip_get(packet, &src->rtsp_ip_address);
src->rtsp_timer = packet->current_time_ms;
src->rtsp_ts_set = 1;
}
NDPI_LOG_INFO(ndpi_struct, "found RTSP\n");
flow->rtsp_control_flow = 1;
ndpi_int_rtsp_add_connection(ndpi_struct, flow);
return;
}
-2
View File
@@ -47,8 +47,6 @@ void ndpi_search_whois_das(struct ndpi_detection_module_struct *ndpi_struct, str
flow->host_server_name[i] = '\0';
flow->server_id = ((sport == 43) || (sport == 4343)) ? flow->src : flow->dst;
NDPI_LOG_INFO(ndpi_struct, "[WHOIS/DAS] %s\n", flow->host_server_name);
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_WHOIS_DAS, NDPI_PROTOCOL_UNKNOWN);
return;