Remove some unused fields (#1393)
This commit is contained in:
@@ -687,14 +687,10 @@ struct ndpi_packet_struct {
|
||||
uint8_t http_num_headers; /* number of found (valid) header lines in HTTP request or response */
|
||||
|
||||
uint16_t l3_packet_len;
|
||||
uint16_t l4_packet_len;
|
||||
uint16_t payload_packet_len;
|
||||
uint16_t actual_payload_len;
|
||||
uint16_t num_retried_bytes;
|
||||
uint16_t parsed_lines;
|
||||
uint16_t empty_line_position;
|
||||
uint8_t tcp_retransmission;
|
||||
uint8_t l4_protocol;
|
||||
|
||||
uint8_t packet_lines_parsed_complete:1,
|
||||
packet_direction:1, empty_line_position_set:1, http_check_content:1, pad:4;
|
||||
|
||||
@@ -635,14 +635,10 @@ class NDPIPacketStruct(Structure):
|
||||
('http_response', NDPIIntOneLineStruct),
|
||||
('http_num_headers', c_uint8),
|
||||
('l3_packet_len', c_uint16),
|
||||
('l4_packet_len', c_uint16),
|
||||
('payload_packet_len', c_uint16),
|
||||
('actual_payload_len', c_uint16),
|
||||
('num_retried_bytes', c_uint16),
|
||||
('parsed_lines', c_uint16),
|
||||
('empty_line_position', c_uint16),
|
||||
('tcp_retransmission', c_uint8),
|
||||
('l4_protocol', c_uint8),
|
||||
('packet_lines_parsed_complete', c_uint8, 1),
|
||||
('packet_direction', c_uint8, 1),
|
||||
('empty_line_position_set', c_uint8, 1),
|
||||
|
||||
@@ -494,15 +494,6 @@ typedef struct message {
|
||||
u_int32_t next_seq[2]; /* Directions */
|
||||
} message_t;
|
||||
|
||||
/* NDPI_PROTOCOL_BITTORRENT */
|
||||
typedef struct spinlock {
|
||||
volatile int val;
|
||||
} spinlock_t;
|
||||
|
||||
typedef struct atomic {
|
||||
volatile int counter;
|
||||
} atomic_t;
|
||||
|
||||
/* NDPI_PROTOCOL_TINC */
|
||||
#define TINC_CACHE_MAX_SIZE 10
|
||||
|
||||
@@ -826,14 +817,10 @@ struct ndpi_packet_struct {
|
||||
u_int8_t http_num_headers; /* number of found (valid) header lines in HTTP request or response */
|
||||
|
||||
u_int16_t l3_packet_len;
|
||||
u_int16_t l4_packet_len;
|
||||
u_int16_t payload_packet_len;
|
||||
u_int16_t actual_payload_len;
|
||||
u_int16_t num_retried_bytes;
|
||||
u_int16_t parsed_lines;
|
||||
u_int16_t empty_line_position;
|
||||
u_int8_t tcp_retransmission;
|
||||
u_int8_t l4_protocol;
|
||||
|
||||
u_int8_t packet_lines_parsed_complete:1,
|
||||
packet_direction:1, empty_line_position_set:1, http_check_content:1, pad:4;
|
||||
|
||||
+10
-27
@@ -4377,7 +4377,7 @@ static int ndpi_init_packet(struct ndpi_detection_module_struct *ndpi_str,
|
||||
struct ndpi_packet_struct *packet = &ndpi_str->packet;
|
||||
const struct ndpi_iphdr *decaps_iph = NULL;
|
||||
u_int16_t l3len;
|
||||
u_int16_t l4len;
|
||||
u_int16_t l4len, l4_packet_len;
|
||||
const u_int8_t *l4ptr;
|
||||
u_int8_t l4protocol;
|
||||
u_int8_t l4_result;
|
||||
@@ -4396,7 +4396,6 @@ static int ndpi_init_packet(struct ndpi_detection_module_struct *ndpi_str,
|
||||
/* reset payload_packet_len, will be set if ipv4 tcp or udp */
|
||||
packet->payload = NULL;
|
||||
packet->payload_packet_len = 0;
|
||||
packet->l4_packet_len = 0;
|
||||
packet->l3_packet_len = packetlen;
|
||||
|
||||
packet->tcp = NULL, packet->udp = NULL;
|
||||
@@ -4441,17 +4440,15 @@ static int ndpi_init_packet(struct ndpi_detection_module_struct *ndpi_str,
|
||||
return(1);
|
||||
}
|
||||
|
||||
packet->l4_protocol = l4protocol;
|
||||
packet->l4_packet_len = l4len;
|
||||
l4_packet_len = l4len;
|
||||
flow->l4_proto = l4protocol;
|
||||
|
||||
/* TCP / UDP detection */
|
||||
if(l4protocol == IPPROTO_TCP && packet->l4_packet_len >= 20 /* min size of tcp */) {
|
||||
if(l4protocol == IPPROTO_TCP && l4_packet_len >= 20 /* min size of tcp */) {
|
||||
/* tcp */
|
||||
packet->tcp = (struct ndpi_tcphdr *) l4ptr;
|
||||
if(packet->l4_packet_len >= packet->tcp->doff * 4) {
|
||||
packet->payload_packet_len = packet->l4_packet_len - packet->tcp->doff * 4;
|
||||
packet->actual_payload_len = packet->payload_packet_len;
|
||||
if(l4_packet_len >= packet->tcp->doff * 4) {
|
||||
packet->payload_packet_len = l4_packet_len - packet->tcp->doff * 4;
|
||||
packet->payload = ((u_int8_t *) packet->tcp) + (packet->tcp->doff * 4);
|
||||
|
||||
/* check for new tcp syn packets, here
|
||||
@@ -4493,14 +4490,14 @@ static int ndpi_init_packet(struct ndpi_detection_module_struct *ndpi_str,
|
||||
/* tcp header not complete */
|
||||
packet->tcp = NULL;
|
||||
}
|
||||
} else if(l4protocol == IPPROTO_UDP && packet->l4_packet_len >= 8 /* size of udp */) {
|
||||
} else if(l4protocol == IPPROTO_UDP && l4_packet_len >= 8 /* size of udp */) {
|
||||
packet->udp = (struct ndpi_udphdr *) l4ptr;
|
||||
packet->payload_packet_len = packet->l4_packet_len - 8;
|
||||
packet->payload_packet_len = l4_packet_len - 8;
|
||||
packet->payload = ((u_int8_t *) packet->udp) + 8;
|
||||
} else if((l4protocol == IPPROTO_ICMP && packet->l4_packet_len >= sizeof(struct ndpi_icmphdr))
|
||||
|| (l4protocol == IPPROTO_ICMPV6 && packet->l4_packet_len >= sizeof(struct ndpi_icmp6hdr))) {
|
||||
} else if((l4protocol == IPPROTO_ICMP && l4_packet_len >= sizeof(struct ndpi_icmphdr))
|
||||
|| (l4protocol == IPPROTO_ICMPV6 && l4_packet_len >= sizeof(struct ndpi_icmp6hdr))) {
|
||||
packet->payload = ((u_int8_t *) l4ptr);
|
||||
packet->payload_packet_len = packet->l4_packet_len;
|
||||
packet->payload_packet_len = l4_packet_len;
|
||||
} else {
|
||||
packet->generic_l4_ptr = l4ptr;
|
||||
}
|
||||
@@ -4550,8 +4547,6 @@ void ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
||||
}
|
||||
|
||||
if(tcph != NULL) {
|
||||
/* reset retried bytes here before setting it */
|
||||
packet->num_retried_bytes = 0;
|
||||
|
||||
flow->sport = tcph->source, flow->dport = tcph->dest; /* (*#*) */
|
||||
|
||||
@@ -4601,23 +4596,11 @@ void ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
||||
/* CHECK IF PARTIAL RETRY IS HAPPENING */
|
||||
if((flow->next_tcp_seq_nr[packet->packet_direction] - ntohl(tcph->seq) <
|
||||
packet->payload_packet_len)) {
|
||||
/* num_retried_bytes actual_payload_len hold info about the partial retry
|
||||
analyzer which require this info can make use of this info
|
||||
Other analyzer can use packet->payload_packet_len */
|
||||
packet->num_retried_bytes =
|
||||
(u_int16_t)(flow->next_tcp_seq_nr[packet->packet_direction] - ntohl(tcph->seq));
|
||||
packet->actual_payload_len = packet->payload_packet_len - packet->num_retried_bytes;
|
||||
|
||||
if(flow->num_processed_pkts > 1) /* See also (***) above */
|
||||
flow->next_tcp_seq_nr[packet->packet_direction] = ntohl(tcph->seq) + packet->payload_packet_len;
|
||||
}
|
||||
}
|
||||
|
||||
/* normal path
|
||||
actual_payload_len is initialized to payload_packet_len during tcp header parsing itself.
|
||||
It will be changed only in case of retransmission */
|
||||
else {
|
||||
packet->num_retried_bytes = 0;
|
||||
flow->next_tcp_seq_nr[packet->packet_direction] = ntohl(tcph->seq) + packet->payload_packet_len;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ void ndpi_search_in_non_tcp_udp(struct ndpi_detection_module_struct
|
||||
return;
|
||||
}
|
||||
|
||||
switch (packet->l4_protocol) {
|
||||
switch (flow->l4_proto) {
|
||||
case NDPI_IPSEC_PROTOCOL_ESP:
|
||||
case NDPI_IPSEC_PROTOCOL_AH:
|
||||
set_protocol_and_bmask(NDPI_PROTOCOL_IP_IPSEC);
|
||||
|
||||
@@ -204,13 +204,13 @@ void ndpi_search_someip (struct ndpi_detection_module_struct *ndpi_struct,
|
||||
//Filtering by port.
|
||||
//This check is NOT a 100% thing - these ports are mentioned in the documentation but the documentation also states they haven't been approved by IANA yet, and that the user is free to use different ports.
|
||||
//This is is PURELY for demo purposes and the rest of the check must be filled in later on!
|
||||
if (packet->l4_protocol == IPPROTO_UDP){
|
||||
if (flow->l4_proto == IPPROTO_UDP){
|
||||
if ((packet->udp->dest == ntohs(PORT_DEFAULT_CLIENT)) || (packet->udp->dest == ntohs(PORT_DEFAULT_SERVER)) || (packet->udp->dest == ntohs(PORT_DEFAULT_SD))) {
|
||||
ndpi_int_someip_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (packet->l4_protocol == IPPROTO_TCP){
|
||||
if (flow->l4_proto == IPPROTO_TCP){
|
||||
if ((packet->tcp->dest == ntohs(PORT_DEFAULT_CLIENT)) || (packet->tcp->dest == ntohs(PORT_DEFAULT_SERVER))) {
|
||||
ndpi_int_someip_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user