Added ndpi_init_detection_module() API preferences
This commit is contained in:
@@ -4169,7 +4169,7 @@ int orginal_main(int argc, char **argv) {
|
||||
analyzeUnitTest();
|
||||
|
||||
gettimeofday(&startup_time, NULL);
|
||||
ndpi_info_mod = ndpi_init_detection_module();
|
||||
ndpi_info_mod = ndpi_init_detection_module(0 /* Don't skip tor hosts */);
|
||||
|
||||
if(ndpi_info_mod == NULL) return -1;
|
||||
|
||||
|
||||
@@ -413,7 +413,7 @@ struct ndpi_workflow* ndpi_workflow_init(const struct ndpi_workflow_prefs * pref
|
||||
set_ndpi_flow_malloc(NULL), set_ndpi_flow_free(NULL);
|
||||
|
||||
/* TODO: just needed here to init ndpi malloc wrapper */
|
||||
module = ndpi_init_detection_module();
|
||||
module = ndpi_init_detection_module(ndpi_no_prefs);
|
||||
|
||||
if(module == NULL) {
|
||||
NDPI_LOG(0, NULL, NDPI_LOG_ERROR, "global structure initialization failed\n");
|
||||
|
||||
@@ -142,10 +142,11 @@ extern "C" {
|
||||
* hosts and do other things. As soon as you are ready to use
|
||||
* it do not forget to call first ndpi_finalize_initalization()
|
||||
*
|
||||
* @par prefs = load preferences
|
||||
* @return the initialized detection module
|
||||
*
|
||||
*/
|
||||
struct ndpi_detection_module_struct *ndpi_init_detection_module(void);
|
||||
struct ndpi_detection_module_struct *ndpi_init_detection_module(ndpi_init_prefs prefs);
|
||||
|
||||
/**
|
||||
* Completes the initialization (2nd step)
|
||||
|
||||
@@ -1379,6 +1379,14 @@ typedef struct {
|
||||
u_int8_t value;
|
||||
} ndpi_network;
|
||||
|
||||
typedef u_int32_t ndpi_init_prefs;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ndpi_no_prefs = 0,
|
||||
ndpi_dont_load_tor_hosts,
|
||||
} ndpi_prefs;
|
||||
|
||||
typedef struct {
|
||||
int protocol_id;
|
||||
ndpi_protocol_category_t protocol_category;
|
||||
|
||||
+9
-3
@@ -1946,13 +1946,17 @@ static patricia_node_t* add_to_ptree(patricia_tree_t *tree, int family,
|
||||
/* ******************************************* */
|
||||
|
||||
static void ndpi_init_ptree_ipv4(struct ndpi_detection_module_struct *ndpi_str,
|
||||
void *ptree, ndpi_network host_list[]) {
|
||||
void *ptree, ndpi_network host_list[],
|
||||
u_int8_t skip_tor_hosts) {
|
||||
int i;
|
||||
|
||||
for(i=0; host_list[i].network != 0x0; i++) {
|
||||
struct in_addr pin;
|
||||
patricia_node_t *node;
|
||||
|
||||
if(skip_tor_hosts && (host_list[i].value == NDPI_PROTOCOL_TOR))
|
||||
continue;
|
||||
|
||||
pin.s_addr = htonl(host_list[i].network);
|
||||
if((node = add_to_ptree(ptree, AF_INET,
|
||||
&pin, host_list[i].cidr /* bits */)) != NULL)
|
||||
@@ -2135,7 +2139,7 @@ static const char* categories[] = {
|
||||
|
||||
/* ******************************************************************** */
|
||||
|
||||
struct ndpi_detection_module_struct *ndpi_init_detection_module(void) {
|
||||
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));
|
||||
int i;
|
||||
|
||||
@@ -2153,7 +2157,9 @@ struct ndpi_detection_module_struct *ndpi_init_detection_module(void) {
|
||||
#endif /* NDPI_ENABLE_DEBUG_MESSAGES */
|
||||
|
||||
if((ndpi_str->protocols_ptree = ndpi_New_Patricia(32 /* IPv4 */)) != NULL)
|
||||
ndpi_init_ptree_ipv4(ndpi_str, ndpi_str->protocols_ptree, host_protocol_list);
|
||||
ndpi_init_ptree_ipv4(ndpi_str, ndpi_str->protocols_ptree,
|
||||
host_protocol_list,
|
||||
prefs & ndpi_dont_load_tor_hosts);
|
||||
|
||||
NDPI_BITMASK_RESET(ndpi_str->detection_bitmask);
|
||||
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||
|
||||
Reference in New Issue
Block a user