Added (optional) notifier for LRU add
This commit is contained in:
@@ -1017,6 +1017,11 @@ struct pcre_struct {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ndpi_stun_cache,
|
||||||
|
ndpi_hangout_cache
|
||||||
|
} ndpi_lru_cache_type;
|
||||||
|
|
||||||
struct ndpi_detection_module_struct {
|
struct ndpi_detection_module_struct {
|
||||||
NDPI_PROTOCOL_BITMASK detection_bitmask;
|
NDPI_PROTOCOL_BITMASK detection_bitmask;
|
||||||
NDPI_PROTOCOL_BITMASK generic_http_packet_bitmask;
|
NDPI_PROTOCOL_BITMASK generic_http_packet_bitmask;
|
||||||
@@ -1128,8 +1133,9 @@ struct ndpi_detection_module_struct {
|
|||||||
|
|
||||||
ndpi_proto_defaults_t proto_defaults[NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS];
|
ndpi_proto_defaults_t proto_defaults[NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS];
|
||||||
|
|
||||||
u_int8_t direction_detect_disable:1, /* disable internal detection of packet direction */
|
u_int8_t direction_detect_disable:1, /* disable internal detection of packet direction */ _pad:7;
|
||||||
_pad:7;
|
|
||||||
|
void (*ndpi_notify_lru_add_handler_ptr)(ndpi_lru_cache_type cache_type, u_int32_t proto, u_int32_t app_proto);
|
||||||
|
|
||||||
#ifdef CUSTOM_NDPI_PROTOCOLS
|
#ifdef CUSTOM_NDPI_PROTOCOLS
|
||||||
#include "../../../nDPI-custom/custom_ndpi_typedefs.h"
|
#include "../../../nDPI-custom/custom_ndpi_typedefs.h"
|
||||||
@@ -1547,5 +1553,4 @@ struct ndpi_bin {
|
|||||||
} u;
|
} u;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* __NDPI_TYPEDEFS_H__ */
|
#endif /* __NDPI_TYPEDEFS_H__ */
|
||||||
|
|||||||
@@ -1968,6 +1968,15 @@ static const char *categories[] = {
|
|||||||
|
|
||||||
/* ******************************************************************** */
|
/* ******************************************************************** */
|
||||||
|
|
||||||
|
#ifdef TEST_LRU_HANDLER
|
||||||
|
void test_lru_handler(ndpi_lru_cache_type cache_type, u_int32_t proto, u_int32_t app_proto) {
|
||||||
|
|
||||||
|
printf("[test_lru_handler] %u / %u / %u\n", cache_type, proto, app_proto);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ******************************************************************** */
|
||||||
|
|
||||||
struct ndpi_detection_module_struct *ndpi_init_detection_module(ndpi_init_prefs prefs) {
|
struct ndpi_detection_module_struct *ndpi_init_detection_module(ndpi_init_prefs prefs) {
|
||||||
struct ndpi_detection_module_struct *ndpi_str = ndpi_malloc(sizeof(struct ndpi_detection_module_struct));
|
struct ndpi_detection_module_struct *ndpi_str = ndpi_malloc(sizeof(struct ndpi_detection_module_struct));
|
||||||
int i;
|
int i;
|
||||||
@@ -1982,6 +1991,10 @@ struct ndpi_detection_module_struct *ndpi_init_detection_module(ndpi_init_prefs
|
|||||||
|
|
||||||
memset(ndpi_str, 0, sizeof(struct ndpi_detection_module_struct));
|
memset(ndpi_str, 0, sizeof(struct ndpi_detection_module_struct));
|
||||||
|
|
||||||
|
#ifdef TEST_LRU_HANDLER
|
||||||
|
ndpi_str->ndpi_notify_lru_add_handler_ptr = test_lru_handler;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||||
set_ndpi_debug_function(ndpi_str, (ndpi_debug_function_ptr) ndpi_debug_printf);
|
set_ndpi_debug_function(ndpi_str, (ndpi_debug_function_ptr) ndpi_debug_printf);
|
||||||
NDPI_BITMASK_RESET(ndpi_str->debug_bitmask);
|
NDPI_BITMASK_RESET(ndpi_str->debug_bitmask);
|
||||||
|
|||||||
@@ -108,6 +108,8 @@ void ndpi_search_hangout(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ndpi_lru_add_to_cache(ndpi_struct->stun_cache, key, NDPI_PROTOCOL_HANGOUT_DUO);
|
ndpi_lru_add_to_cache(ndpi_struct->stun_cache, key, NDPI_PROTOCOL_HANGOUT_DUO);
|
||||||
|
if(ndpi_struct->ndpi_notify_lru_add_handler_ptr)
|
||||||
|
ndpi_struct->ndpi_notify_lru_add_handler_ptr(ndpi_hangout_cache, key, NDPI_PROTOCOL_HANGOUT_DUO);
|
||||||
}
|
}
|
||||||
|
|
||||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_HANGOUT_DUO,
|
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_HANGOUT_DUO,
|
||||||
|
|||||||
@@ -88,7 +88,12 @@ void ndpi_int_stun_add_connection(struct ndpi_detection_module_struct *ndpi_stru
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ndpi_lru_add_to_cache(ndpi_struct->stun_cache, key, app_proto);
|
ndpi_lru_add_to_cache(ndpi_struct->stun_cache, key, app_proto);
|
||||||
|
if(ndpi_struct->ndpi_notify_lru_add_handler_ptr)
|
||||||
|
ndpi_struct->ndpi_notify_lru_add_handler_ptr(ndpi_stun_cache, key, app_proto);
|
||||||
|
|
||||||
ndpi_lru_add_to_cache(ndpi_struct->stun_cache, key_rev, app_proto);
|
ndpi_lru_add_to_cache(ndpi_struct->stun_cache, key_rev, app_proto);
|
||||||
|
if(ndpi_struct->ndpi_notify_lru_add_handler_ptr)
|
||||||
|
ndpi_struct->ndpi_notify_lru_add_handler_ptr(ndpi_stun_cache, key_rev, app_proto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user