Keep separating public and private API (#2157)

See: b08c787fe
This commit is contained in:
Ivan Nardi
2023-11-29 17:13:00 +01:00
committed by GitHub
parent ac90b1f009
commit 3b35cb37d9
19 changed files with 360 additions and 484 deletions
+4 -4
View File
@@ -108,14 +108,14 @@ u_int32_t make_bittorrent_host_key(struct ndpi_flow_struct *flow, int client, in
/* network byte order */
if(flow->is_ipv6) {
if(client)
key = ndpi_ip_port_hash_funct(ndpi_quick_hash(flow->c_address.v6, 16), htons(ntohs(flow->c_port) + offset));
key = ip_port_hash_funct(ndpi_quick_hash(flow->c_address.v6, 16), htons(ntohs(flow->c_port) + offset));
else
key = ndpi_ip_port_hash_funct(ndpi_quick_hash(flow->s_address.v6, 16), flow->s_port);
key = ip_port_hash_funct(ndpi_quick_hash(flow->s_address.v6, 16), flow->s_port);
} else {
if(client)
key = ndpi_ip_port_hash_funct(flow->c_address.v4, htons(ntohs(flow->c_port) + offset));
key = ip_port_hash_funct(flow->c_address.v4, htons(ntohs(flow->c_port) + offset));
else
key = ndpi_ip_port_hash_funct(flow->s_address.v4, flow->s_port);
key = ip_port_hash_funct(flow->s_address.v4, flow->s_port);
}
return key;
+1 -1
View File
@@ -60,7 +60,7 @@ static void ndpi_set_binary_application_transfer(struct ndpi_detection_module_st
/*
Check known exceptions
*/
if(ndpi_ends_with(ndpi_struct, (char*)flow->host_server_name, ".windowsupdate.com"))
if(ends_with(ndpi_struct, (char*)flow->host_server_name, ".windowsupdate.com"))
;
else
ndpi_set_risk(ndpi_struct, flow, NDPI_BINARY_APPLICATION_TRANSFER, msg);
+3 -3
View File
@@ -45,9 +45,9 @@ static int krb_decode_asn1_length(struct ndpi_detection_module_struct *ndpi_stru
int64_t length;
u_int16_t value_len;
length = ndpi_asn1_ber_decode_length(&packet->payload[*kasn1_offset],
packet->payload_packet_len - *kasn1_offset,
&value_len);
length = asn1_ber_decode_length(&packet->payload[*kasn1_offset],
packet->payload_packet_len - *kasn1_offset,
&value_len);
if (length == -1 ||
packet->payload_packet_len < *kasn1_offset + value_len + length)
+1 -1
View File
@@ -47,7 +47,7 @@ static void ndpi_search_ldap(struct ndpi_detection_module_struct *ndpi_struct, s
if(packet->payload_packet_len > 1 &&
packet->payload[0] == 0x30) {
length = ndpi_asn1_ber_decode_length(&packet->payload[1], packet->payload_packet_len - 1, &length_len);
length = asn1_ber_decode_length(&packet->payload[1], packet->payload_packet_len - 1, &length_len);
NDPI_LOG_DBG(ndpi_struct, "length %d (%d bytes)\n", length, length_len);
if(length > 0 &&
packet->payload_packet_len > 1 + length_len + 1 &&
+3 -3
View File
@@ -72,7 +72,7 @@ static void ndpi_search_snmp(struct ndpi_detection_module_struct *ndpi_struct,
u_int16_t len_length = 0, offset;
int64_t len;
len = ndpi_asn1_ber_decode_length(&packet->payload[1], packet->payload_packet_len - 1, &len_length);
len = asn1_ber_decode_length(&packet->payload[1], packet->payload_packet_len - 1, &len_length);
if(len > 2 &&
1 + len_length + len == packet->payload_packet_len &&
@@ -106,10 +106,10 @@ static void ndpi_search_snmp(struct ndpi_detection_module_struct *ndpi_struct,
if(snmp_primitive == 2 /* Get Response */ &&
snmp_primitive_offset + 1 < packet->payload_packet_len) {
offset = snmp_primitive_offset + 1;
ndpi_asn1_ber_decode_length(&packet->payload[offset], packet->payload_packet_len - offset, &len_length);
asn1_ber_decode_length(&packet->payload[offset], packet->payload_packet_len - offset, &len_length);
offset += len_length + 1;
if(offset < packet->payload_packet_len) {
len = ndpi_asn1_ber_decode_length(&packet->payload[offset], packet->payload_packet_len - offset, &len_length);
len = asn1_ber_decode_length(&packet->payload[offset], packet->payload_packet_len - offset, &len_length);
u_int8_t error_status_offset = offset + len_length + len + 2;
+5 -5
View File
@@ -35,11 +35,11 @@ static u_int8_t sc2_match_logon_ip(struct ndpi_packet_struct* packet)
u_int32_t source_ip = ntohl(packet->iph->saddr);
u_int32_t dest_ip = ntohl(packet->iph->daddr);
return (ndpi_ips_match(source_ip, dest_ip, 0xD5F87F82, 32) // EU 213.248.127.130
|| ndpi_ips_match(source_ip, dest_ip, 0x0C81CE82, 32) // US 12.129.206.130
|| ndpi_ips_match(source_ip, dest_ip, 0x79FEC882, 32) // KR 121.254.200.130
|| ndpi_ips_match(source_ip, dest_ip, 0xCA09424C, 32) // SG 202.9.66.76
|| ndpi_ips_match(source_ip, dest_ip, 0x0C81ECFE, 32)); // BETA 12.129.236.254
return (ips_match(source_ip, dest_ip, 0xD5F87F82, 32) // EU 213.248.127.130
|| ips_match(source_ip, dest_ip, 0x0C81CE82, 32) // US 12.129.206.130
|| ips_match(source_ip, dest_ip, 0x79FEC882, 32) // KR 121.254.200.130
|| ips_match(source_ip, dest_ip, 0xCA09424C, 32) // SG 202.9.66.76
|| ips_match(source_ip, dest_ip, 0x0C81ECFE, 32)); // BETA 12.129.236.254
}
/*
+2 -2
View File
@@ -408,8 +408,8 @@ static int stun_search_again(struct ndpi_detection_module_struct *ndpi_struct,
first_dtls_pkt = 1;
/* TODO: right way? It is a bit scary... do we need to reset something else too? */
ndpi_reset_detected_protocol(ndpi_struct, flow);
ndpi_int_change_category(ndpi_struct, flow, NDPI_PROTOCOL_CATEGORY_UNSPECIFIED);
reset_detected_protocol(ndpi_struct, flow);
change_category(ndpi_struct, flow, NDPI_PROTOCOL_CATEGORY_UNSPECIFIED);
/* Give room for DTLS handshake, where we might have
retransmissions and fragments */