Code cleanup for improving readability
This commit is contained in:
@@ -31,7 +31,7 @@
|
|||||||
#define __NDPI_PROTOCOLS_DEFAULT_H__
|
#define __NDPI_PROTOCOLS_DEFAULT_H__
|
||||||
|
|
||||||
#define NDPI_DETECTION_SUPPORT_IPV6
|
#define NDPI_DETECTION_SUPPORT_IPV6
|
||||||
#define NDPI_PROTOCOL_HISTORY_SIZE 3
|
#define NDPI_PROTOCOL_HISTORY_SIZE 2
|
||||||
|
|
||||||
#define NDPI_PROTOCOL_UNKNOWN 0
|
#define NDPI_PROTOCOL_UNKNOWN 0
|
||||||
|
|
||||||
|
|||||||
@@ -471,16 +471,10 @@ typedef struct ndpi_packet_struct {
|
|||||||
* used for the main loop */
|
* used for the main loop */
|
||||||
/* u_int16_t real_protocol_read_only; */
|
/* u_int16_t real_protocol_read_only; */
|
||||||
|
|
||||||
#if NDPI_PROTOCOL_HISTORY_SIZE > 1
|
|
||||||
# if NDPI_PROTOCOL_HISTORY_SIZE > 5
|
|
||||||
# error protocol stack size not supported
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
__attribute__ ((__packed__))
|
__attribute__ ((__packed__))
|
||||||
#endif
|
#endif
|
||||||
u_int16_t protocol_stack_info;
|
u_int16_t protocol_stack_info;
|
||||||
#endif
|
|
||||||
|
|
||||||
struct ndpi_int_one_line_struct line[NDPI_MAX_PARSE_LINES_PER_PACKET];
|
struct ndpi_int_one_line_struct line[NDPI_MAX_PARSE_LINES_PER_PACKET];
|
||||||
struct ndpi_int_one_line_struct host_line;
|
struct ndpi_int_one_line_struct host_line;
|
||||||
@@ -668,16 +662,10 @@ typedef struct ndpi_detection_module_struct {
|
|||||||
|
|
||||||
typedef struct ndpi_flow_struct {
|
typedef struct ndpi_flow_struct {
|
||||||
u_int16_t detected_protocol_stack[NDPI_PROTOCOL_HISTORY_SIZE];
|
u_int16_t detected_protocol_stack[NDPI_PROTOCOL_HISTORY_SIZE];
|
||||||
#if NDPI_PROTOCOL_HISTORY_SIZE > 1
|
|
||||||
# if NDPI_PROTOCOL_HISTORY_SIZE > 5
|
|
||||||
# error protocol stack size not supported
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
__attribute__ ((__packed__))
|
__attribute__ ((__packed__))
|
||||||
#endif
|
#endif
|
||||||
u_int16_t protocol_stack_info;
|
u_int16_t protocol_stack_info;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* init parameter, internal used to set up timestamp,... */
|
/* init parameter, internal used to set up timestamp,... */
|
||||||
u_int16_t guessed_protocol_id;
|
u_int16_t guessed_protocol_id;
|
||||||
|
|||||||
+22
-290
@@ -3828,9 +3828,7 @@ void ndpi_apply_flow_protocol_to_packet(struct ndpi_flow_struct *flow,
|
|||||||
{
|
{
|
||||||
memcpy(&packet->detected_protocol_stack[0],
|
memcpy(&packet->detected_protocol_stack[0],
|
||||||
&flow->detected_protocol_stack[0], sizeof(packet->detected_protocol_stack));
|
&flow->detected_protocol_stack[0], sizeof(packet->detected_protocol_stack));
|
||||||
#if NDPI_PROTOCOL_HISTORY_SIZE > 1
|
|
||||||
memcpy(&packet->protocol_stack_info, &flow->protocol_stack_info, sizeof(packet->protocol_stack_info));
|
memcpy(&packet->protocol_stack_info, &flow->protocol_stack_info, sizeof(packet->protocol_stack_info));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ndpi_init_packet_header(struct ndpi_detection_module_struct *ndpi_struct,
|
static int ndpi_init_packet_header(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
@@ -4883,295 +4881,43 @@ u_int8_t ndpi_detection_get_l4(const u_int8_t * l3, u_int16_t l3_len, const u_in
|
|||||||
|
|
||||||
void ndpi_set_detected_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
void ndpi_set_detected_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
struct ndpi_flow_struct *flow,
|
struct ndpi_flow_struct *flow,
|
||||||
u_int16_t detected_protocol/* , ndpi_protocol_type_t protocol_type */)
|
u_int16_t detected_protocol)
|
||||||
{
|
{
|
||||||
struct ndpi_id_struct *src = flow->src;
|
struct ndpi_id_struct *src = flow->src;
|
||||||
struct ndpi_id_struct *dst = flow->dst;
|
struct ndpi_id_struct *dst = flow->dst;
|
||||||
|
|
||||||
ndpi_int_change_protocol(ndpi_struct, flow, detected_protocol);
|
ndpi_int_change_protocol(ndpi_struct, flow, detected_protocol);
|
||||||
|
|
||||||
if(src != NULL) {
|
if(src != NULL)
|
||||||
NDPI_ADD_PROTOCOL_TO_BITMASK(src->detected_protocol_bitmask, detected_protocol);
|
NDPI_ADD_PROTOCOL_TO_BITMASK(src->detected_protocol_bitmask, detected_protocol);
|
||||||
}
|
|
||||||
if(dst != NULL) {
|
if(dst != NULL)
|
||||||
NDPI_ADD_PROTOCOL_TO_BITMASK(dst->detected_protocol_bitmask, detected_protocol);
|
NDPI_ADD_PROTOCOL_TO_BITMASK(dst->detected_protocol_bitmask, detected_protocol);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ndpi_int_change_flow_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
void ndpi_int_change_flow_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
struct ndpi_flow_struct *flow,
|
struct ndpi_flow_struct *flow,
|
||||||
u_int16_t detected_protocol/* , ndpi_protocol_type_t protocol_type */)
|
u_int16_t detected_protocol) {
|
||||||
{
|
if(!flow) return;
|
||||||
/* #if NDPI_PROTOCOL_HISTORY_SIZE > 1 */
|
|
||||||
/* u_int8_t a; */
|
|
||||||
/* u_int8_t stack_size; */
|
|
||||||
/* u_int8_t new_is_real = 0; */
|
|
||||||
/* u_int16_t preserve_bitmask; */
|
|
||||||
/* #endif */
|
|
||||||
|
|
||||||
if(!flow)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* #if NDPI_PROTOCOL_HISTORY_SIZE > 1 */
|
|
||||||
/* stack_size = flow->protocol_stack_info.current_stack_size_minus_one + 1; */
|
|
||||||
|
|
||||||
/* here are the rules for stack manipulations:
|
|
||||||
* 1.if the new protocol is a real protocol, insert it at the position
|
|
||||||
* of the top-most real protocol or below the last non-unknown correlated
|
|
||||||
* protocol.
|
|
||||||
* 2.if the new protocol is not real, put it on top of stack but if there is
|
|
||||||
* a real protocol in the stack, make sure at least one real protocol remains
|
|
||||||
* in the stack
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* if(protocol_type == NDPI_CORRELATED_PROTOCOL) { */
|
|
||||||
/* u_int16_t saved_real_protocol = NDPI_PROTOCOL_UNKNOWN; */
|
|
||||||
|
|
||||||
/* if(stack_size == NDPI_PROTOCOL_HISTORY_SIZE) { */
|
|
||||||
/* /\* check whether we will lost real protocol information due to shifting *\/ */
|
|
||||||
/* u_int16_t real_protocol = flow->protocol_stack_info.entry_is_real_protocol; */
|
|
||||||
|
|
||||||
/* for (a = 0; a < stack_size; a++) { */
|
|
||||||
/* if(real_protocol & 1) */
|
|
||||||
/* break; */
|
|
||||||
/* real_protocol >>= 1; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* if(a == (stack_size - 1)) { */
|
|
||||||
/* /\* oh, only one real protocol at the end, store it and insert it later *\/ */
|
|
||||||
/* saved_real_protocol = flow->detected_protocol_stack[stack_size - 1]; */
|
|
||||||
/* } */
|
|
||||||
/* } else { */
|
|
||||||
/* flow->protocol_stack_info.current_stack_size_minus_one++; */
|
|
||||||
/* stack_size++; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* /\* now shift and insert *\/ */
|
|
||||||
/* for (a = stack_size - 1; a > 0; a--) { */
|
|
||||||
/* flow->detected_protocol_stack[a] = flow->detected_protocol_stack[a - 1]; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* flow->protocol_stack_info.entry_is_real_protocol <<= 1; */
|
|
||||||
|
|
||||||
/* /\* now set the new protocol *\/ */
|
|
||||||
|
|
||||||
/* flow->detected_protocol_stack[0] = detected_protocol; */
|
|
||||||
|
|
||||||
/* /\* restore real protocol *\/ */
|
|
||||||
/* if(saved_real_protocol != NDPI_PROTOCOL_UNKNOWN) { */
|
|
||||||
/* flow->detected_protocol_stack[stack_size - 1] = saved_real_protocol; */
|
|
||||||
/* flow->protocol_stack_info.entry_is_real_protocol |= 1 << (stack_size - 1); */
|
|
||||||
/* } */
|
|
||||||
/* /\* done *\/ */
|
|
||||||
/* } else { */
|
|
||||||
/* u_int8_t insert_at = 0; */
|
|
||||||
|
|
||||||
/* if(!(flow->protocol_stack_info.entry_is_real_protocol & 1)) { */
|
|
||||||
/* u_int16_t real_protocol = flow->protocol_stack_info.entry_is_real_protocol; */
|
|
||||||
|
|
||||||
/* for (a = 0; a < stack_size; a++) { */
|
|
||||||
/* if(real_protocol & 1) */
|
|
||||||
/* break; */
|
|
||||||
/* real_protocol >>= 1; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* insert_at = a; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* if(insert_at >= stack_size) { */
|
|
||||||
/* /\* no real protocol found, insert it at the bottom *\/ */
|
|
||||||
|
|
||||||
/* insert_at = stack_size - 1; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* if(stack_size < NDPI_PROTOCOL_HISTORY_SIZE) { */
|
|
||||||
/* flow->protocol_stack_info.current_stack_size_minus_one++; */
|
|
||||||
/* stack_size++; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* /\* first shift all stacks *\/ */
|
|
||||||
/* for (a = stack_size - 1; a > insert_at; a--) { */
|
|
||||||
/* flow->detected_protocol_stack[a] = flow->detected_protocol_stack[a - 1]; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* preserve_bitmask = (1 << insert_at) - 1; */
|
|
||||||
|
|
||||||
/* new_is_real = (flow->protocol_stack_info.entry_is_real_protocol & (~preserve_bitmask)) << 1; */
|
|
||||||
/* new_is_real |= flow->protocol_stack_info.entry_is_real_protocol & preserve_bitmask; */
|
|
||||||
|
|
||||||
/* flow->protocol_stack_info.entry_is_real_protocol = new_is_real; */
|
|
||||||
|
|
||||||
/* /\* now set the new protocol *\/ */
|
|
||||||
|
|
||||||
/* flow->detected_protocol_stack[insert_at] = detected_protocol; */
|
|
||||||
|
|
||||||
/* /\* and finally update the additional stack information *\/ */
|
|
||||||
|
|
||||||
/* flow->protocol_stack_info.entry_is_real_protocol |= 1 << insert_at; */
|
|
||||||
/* } */
|
|
||||||
/* #else */
|
|
||||||
flow->detected_protocol_stack[0] = detected_protocol;
|
flow->detected_protocol_stack[0] = detected_protocol;
|
||||||
/* flow->detected_subprotocol_stack[0] = detected_subprotocol; */
|
|
||||||
/* #endif */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ndpi_int_change_packet_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
void ndpi_int_change_packet_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
struct ndpi_flow_struct *flow,
|
struct ndpi_flow_struct *flow,
|
||||||
u_int16_t detected_protocol/* , ndpi_protocol_type_t protocol_type */)
|
u_int16_t detected_protocol) {
|
||||||
{
|
|
||||||
struct ndpi_packet_struct *packet = &flow->packet;
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
/* NOTE: everything below is identically to change_flow_protocol
|
/* NOTE: everything below is identically to change_flow_protocol
|
||||||
* except flow->packet If you want to change something here,
|
* except flow->packet If you want to change something here,
|
||||||
* don't! Change it for the flow function and apply it here
|
* don't! Change it for the flow function and apply it here
|
||||||
* as well */
|
* as well */
|
||||||
/* #if NDPI_PROTOCOL_HISTORY_SIZE > 1 */
|
|
||||||
/* u_int8_t a; */
|
|
||||||
/* u_int8_t stack_size; */
|
|
||||||
/* u_int16_t new_is_real = 0; */
|
|
||||||
/* u_int16_t preserve_bitmask; */
|
|
||||||
/* #endif */
|
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* #if NDPI_PROTOCOL_HISTORY_SIZE > 1 */
|
|
||||||
/* stack_size = packet->protocol_stack_info.current_stack_size_minus_one + 1; */
|
|
||||||
|
|
||||||
/* here are the rules for stack manipulations:
|
|
||||||
* 1.if the new protocol is a real protocol, insert it at the position
|
|
||||||
* of the top-most real protocol or below the last non-unknown correlated
|
|
||||||
* protocol.
|
|
||||||
* 2.if the new protocol is not real, put it on top of stack but if there is
|
|
||||||
* a real protocol in the stack, make sure at least one real protocol remains
|
|
||||||
* in the stack
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* if(protocol_type == NDPI_CORRELATED_PROTOCOL) { */
|
|
||||||
/* u_int16_t saved_real_protocol = NDPI_PROTOCOL_UNKNOWN; */
|
|
||||||
|
|
||||||
/* if(stack_size == NDPI_PROTOCOL_HISTORY_SIZE) { */
|
|
||||||
/* /\* check whether we will lost real protocol information due to shifting *\/ */
|
|
||||||
/* u_int16_t real_protocol = packet->protocol_stack_info.entry_is_real_protocol; */
|
|
||||||
|
|
||||||
/* for (a = 0; a < stack_size; a++) { */
|
|
||||||
/* if(real_protocol & 1) */
|
|
||||||
/* break; */
|
|
||||||
/* real_protocol >>= 1; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* if(a == (stack_size - 1)) { */
|
|
||||||
/* /\* oh, only one real protocol at the end, store it and insert it later *\/ */
|
|
||||||
/* saved_real_protocol = packet->detected_protocol_stack[stack_size - 1]; */
|
|
||||||
/* } */
|
|
||||||
/* } else { */
|
|
||||||
/* packet->protocol_stack_info.current_stack_size_minus_one++; */
|
|
||||||
/* stack_size++; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* /\* now shift and insert *\/ */
|
|
||||||
/* for (a = stack_size - 1; a > 0; a--) { */
|
|
||||||
/* packet->detected_protocol_stack[a] = packet->detected_protocol_stack[a - 1]; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* packet->protocol_stack_info.entry_is_real_protocol <<= 1; */
|
|
||||||
|
|
||||||
/* /\* now set the new protocol *\/ */
|
|
||||||
|
|
||||||
/* packet->detected_protocol_stack[0] = detected_protocol; */
|
|
||||||
|
|
||||||
/* /\* restore real protocol *\/ */
|
|
||||||
/* if(saved_real_protocol != NDPI_PROTOCOL_UNKNOWN) { */
|
|
||||||
/* packet->detected_protocol_stack[stack_size - 1] = saved_real_protocol; */
|
|
||||||
/* packet->protocol_stack_info.entry_is_real_protocol |= 1 << (stack_size - 1); */
|
|
||||||
/* } */
|
|
||||||
/* /\* done *\/ */
|
|
||||||
/* } else { */
|
|
||||||
/* u_int8_t insert_at = 0; */
|
|
||||||
|
|
||||||
/* if(!(packet->protocol_stack_info.entry_is_real_protocol & 1)) { */
|
|
||||||
/* u_int16_t real_protocol = packet->protocol_stack_info.entry_is_real_protocol; */
|
|
||||||
|
|
||||||
/* for (a = 0; a < stack_size; a++) { */
|
|
||||||
/* if(real_protocol & 1) */
|
|
||||||
/* break; */
|
|
||||||
/* real_protocol >>= 1; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* insert_at = a; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* if(insert_at >= stack_size) { */
|
|
||||||
/* /\* no real protocol found, insert it at the first unknown protocol *\/ */
|
|
||||||
|
|
||||||
/* insert_at = stack_size - 1; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* if(stack_size < NDPI_PROTOCOL_HISTORY_SIZE) { */
|
|
||||||
/* packet->protocol_stack_info.current_stack_size_minus_one++; */
|
|
||||||
/* stack_size++; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* /\* first shift all stacks *\/ */
|
|
||||||
/* for (a = stack_size - 1; a > insert_at; a--) { */
|
|
||||||
/* packet->detected_protocol_stack[a] = packet->detected_protocol_stack[a - 1]; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* preserve_bitmask = (1 << insert_at) - 1; */
|
|
||||||
|
|
||||||
/* new_is_real = (packet->protocol_stack_info.entry_is_real_protocol & (~preserve_bitmask)) << 1; */
|
|
||||||
/* new_is_real |= packet->protocol_stack_info.entry_is_real_protocol & preserve_bitmask; */
|
|
||||||
|
|
||||||
/* packet->protocol_stack_info.entry_is_real_protocol = (u_int8_t)new_is_real; */
|
|
||||||
|
|
||||||
/* /\* now set the new protocol *\/ */
|
|
||||||
|
|
||||||
/* packet->detected_protocol_stack[insert_at] = detected_protocol; */
|
|
||||||
|
|
||||||
/* /\* and finally update the additional stack information *\/ */
|
|
||||||
|
|
||||||
/* packet->protocol_stack_info.entry_is_real_protocol |= 1 << insert_at; */
|
|
||||||
/* } */
|
|
||||||
/* #else */
|
|
||||||
packet->detected_protocol_stack[0] = detected_protocol;
|
packet->detected_protocol_stack[0] = detected_protocol;
|
||||||
/* packet->detected_subprotocol_stack[0] = detected_subprotocol; */
|
|
||||||
/* #endif */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* this function returns the real protocol of the flow. Actually it
|
|
||||||
* accesses the packet stack since this is what leaves the library but
|
|
||||||
* it could also use the flow stack.
|
|
||||||
*/
|
|
||||||
/* u_int16_t ndpi_detection_get_real_protocol_of_flow(struct ndpi_detection_module_struct * ndpi_struct, */
|
|
||||||
/* struct ndpi_flow_struct *flow) */
|
|
||||||
/* { */
|
|
||||||
/* struct ndpi_packet_struct *packet = &flow->packet; */
|
|
||||||
/* #if NDPI_PROTOCOL_HISTORY_SIZE > 1 */
|
|
||||||
/* u_int8_t a; */
|
|
||||||
/* u_int8_t stack_size; */
|
|
||||||
/* u_int16_t real_protocol; */
|
|
||||||
/* #endif */
|
|
||||||
|
|
||||||
/* if(!packet) */
|
|
||||||
/* return NDPI_PROTOCOL_UNKNOWN; */
|
|
||||||
|
|
||||||
/* #if NDPI_PROTOCOL_HISTORY_SIZE > 1 */
|
|
||||||
/* stack_size = packet->protocol_stack_info.current_stack_size_minus_one + 1; */
|
|
||||||
/* real_protocol = packet->protocol_stack_info.entry_is_real_protocol; */
|
|
||||||
|
|
||||||
/* for (a = 0; a < stack_size; a++) { */
|
|
||||||
/* if(real_protocol & 1) */
|
|
||||||
/* return packet->detected_protocol_stack[a]; */
|
|
||||||
/* real_protocol >>= 1; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* return NDPI_PROTOCOL_UNKNOWN; */
|
|
||||||
/* #else */
|
|
||||||
/* return packet->detected_protocol_stack[0]; */
|
|
||||||
/* #endif */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* this function checks whether a protocol can be found in the
|
* this function checks whether a protocol can be found in the
|
||||||
* history. Actually it accesses the packet stack since this is what
|
* history. Actually it accesses the packet stack since this is what
|
||||||
@@ -5179,22 +4925,14 @@ void ndpi_int_change_packet_protocol(struct ndpi_detection_module_struct *ndpi_s
|
|||||||
*/
|
*/
|
||||||
u_int8_t ndpi_detection_flow_protocol_history_contains_protocol(struct ndpi_detection_module_struct * ndpi_struct,
|
u_int8_t ndpi_detection_flow_protocol_history_contains_protocol(struct ndpi_detection_module_struct * ndpi_struct,
|
||||||
struct ndpi_flow_struct *flow,
|
struct ndpi_flow_struct *flow,
|
||||||
u_int16_t protocol_id)
|
u_int16_t protocol_id) {
|
||||||
{
|
|
||||||
u_int8_t a;
|
u_int8_t a;
|
||||||
u_int8_t stack_size;
|
|
||||||
struct ndpi_packet_struct *packet = &flow->packet;
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* #if NDPI_PROTOCOL_HISTORY_SIZE > 1 */
|
for(a = 0; a < NDPI_PROTOCOL_HISTORY_SIZE; a++) {
|
||||||
/* stack_size = packet->protocol_stack_info.current_stack_size_minus_one + 1; */
|
|
||||||
/* #else */
|
|
||||||
stack_size = 1; /* DA SISTEMARE */
|
|
||||||
/* #endif */
|
|
||||||
|
|
||||||
for (a = 0; a < stack_size; a++) {
|
|
||||||
if(packet->detected_protocol_stack[a] == protocol_id)
|
if(packet->detected_protocol_stack[a] == protocol_id)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -5210,7 +4948,7 @@ u_int8_t ndpi_detection_flow_protocol_history_contains_protocol(struct ndpi_dete
|
|||||||
*/
|
*/
|
||||||
void ndpi_set_detected_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
void ndpi_set_detected_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
struct ndpi_flow_struct *flow,
|
struct ndpi_flow_struct *flow,
|
||||||
u_int16_t detected_protocol/* , ndpi_protocol_type_t protocol_type */);
|
u_int16_t detected_protocol);
|
||||||
|
|
||||||
/* generic function for changing the flow protocol
|
/* generic function for changing the flow protocol
|
||||||
*
|
*
|
||||||
@@ -5219,7 +4957,7 @@ void ndpi_set_detected_protocol(struct ndpi_detection_module_struct *ndpi_struct
|
|||||||
*/
|
*/
|
||||||
void ndpi_int_change_flow_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
void ndpi_int_change_flow_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
struct ndpi_flow_struct *flow,
|
struct ndpi_flow_struct *flow,
|
||||||
u_int16_t detected_protocol/* , ndpi_protocol_type_t protocol_type */);
|
u_int16_t detected_protocol);
|
||||||
|
|
||||||
/* generic function for changing the packetprotocol
|
/* generic function for changing the packetprotocol
|
||||||
*
|
*
|
||||||
@@ -5228,7 +4966,7 @@ void ndpi_int_change_flow_protocol(struct ndpi_detection_module_struct *ndpi_str
|
|||||||
*/
|
*/
|
||||||
void ndpi_int_change_packet_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
void ndpi_int_change_packet_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
struct ndpi_flow_struct *flow,
|
struct ndpi_flow_struct *flow,
|
||||||
u_int16_t detected_protocol/* , ndpi_protocol_type_t protocol_type */);
|
u_int16_t detected_protocol);
|
||||||
|
|
||||||
/* generic function for changing the protocol
|
/* generic function for changing the protocol
|
||||||
*
|
*
|
||||||
@@ -5238,8 +4976,7 @@ void ndpi_int_change_packet_protocol(struct ndpi_detection_module_struct *ndpi_s
|
|||||||
*/
|
*/
|
||||||
void ndpi_int_change_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
void ndpi_int_change_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
struct ndpi_flow_struct *flow,
|
struct ndpi_flow_struct *flow,
|
||||||
u_int16_t detected_protocol/* , */
|
u_int16_t detected_protocol)
|
||||||
/* ndpi_protocol_type_t protocol_type */)
|
|
||||||
{
|
{
|
||||||
ndpi_int_change_flow_protocol(ndpi_struct, flow, detected_protocol);
|
ndpi_int_change_flow_protocol(ndpi_struct, flow, detected_protocol);
|
||||||
ndpi_int_change_packet_protocol(ndpi_struct, flow, detected_protocol);
|
ndpi_int_change_packet_protocol(ndpi_struct, flow, detected_protocol);
|
||||||
@@ -5248,28 +4985,23 @@ void ndpi_int_change_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
|
|
||||||
/* turns a packet back to unknown */
|
/* turns a packet back to unknown */
|
||||||
void ndpi_int_reset_packet_protocol(struct ndpi_packet_struct *packet) {
|
void ndpi_int_reset_packet_protocol(struct ndpi_packet_struct *packet) {
|
||||||
packet->detected_protocol_stack[0] = NDPI_PROTOCOL_UNKNOWN;
|
int a;
|
||||||
|
|
||||||
/* #if NDPI_PROTOCOL_HISTORY_SIZE > 1 */
|
for(a = 0; a < NDPI_PROTOCOL_HISTORY_SIZE; a++)
|
||||||
/* packet->protocol_stack_info.current_stack_size_minus_one = 0; */
|
packet->detected_protocol_stack[a] = NDPI_PROTOCOL_UNKNOWN;
|
||||||
/* packet->protocol_stack_info.entry_is_real_protocol = 0; */
|
|
||||||
/* #endif */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ndpi_int_reset_protocol(struct ndpi_flow_struct *flow)
|
void ndpi_int_reset_protocol(struct ndpi_flow_struct *flow) {
|
||||||
{
|
|
||||||
if(flow) {
|
if(flow) {
|
||||||
flow->detected_protocol_stack[0] = NDPI_PROTOCOL_UNKNOWN;
|
int a;
|
||||||
|
|
||||||
/* #if NDPI_PROTOCOL_HISTORY_SIZE > 1 */
|
for(a = 0; a < NDPI_PROTOCOL_HISTORY_SIZE; a++) {
|
||||||
/* flow->protocol_stack_info.current_stack_size_minus_one = 0; */
|
flow->detected_protocol_stack[a] = NDPI_PROTOCOL_UNKNOWN;
|
||||||
/* flow->protocol_stack_info.entry_is_real_protocol = 0; */
|
}
|
||||||
/* #endif */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NDPI_PROTOCOL_IP_clear(ndpi_ip_addr_t * ip)
|
void NDPI_PROTOCOL_IP_clear(ndpi_ip_addr_t * ip) {
|
||||||
{
|
|
||||||
memset(ip, 0, sizeof(ndpi_ip_addr_t));
|
memset(ip, 0, sizeof(ndpi_ip_addr_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user