diff options
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r-- | example/ndpiReader.c | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 3753bff12..fef71d38c 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -143,9 +143,6 @@ int enable_malloc_bins = 0; int max_malloc_bins = 14; int malloc_size_stats = 0; -static int lru_cache_sizes[NDPI_LRUCACHE_MAX]; -static int lru_cache_ttls[NDPI_LRUCACHE_MAX]; - struct flow_info { struct ndpi_flow_info *flow; u_int16_t thread_id; @@ -607,16 +604,12 @@ static void help(u_int long_help) { " -A | Dump internal statistics (LRU caches / Patricia trees / Ahocarasick automas / ...\n" " -M | Memory allocation stats on data-path (only by the library). It works only on single-thread configuration\n" " -Z proto:value | Set this value of aggressiveness for this protocol (0 to disable it). This flag can be used multiple times\n" - " --lru-cache-size=NAME:size | Specify the size for this LRU cache (0 to disable it). This flag can be used multiple times\n" - " --lru-cache-ttl=NAME:size | Specify the TTL [in seconds] for this LRU cache (0 to disable it). This flag can be used multiple times\n" " --cfg=proto,param,value | Configure the specific attribute of this protocol\n" , human_readeable_string_len, min_pattern_len, max_pattern_len, max_num_packets_per_flow, max_packet_payload_dissection, max_num_reported_top_payloads, max_num_tcp_dissected_pkts, max_num_udp_dissected_pkts); - printf("\nLRU Cache names: ookla, bittorrent, zoom, stun, tls_cert, mining, msteams, stun_zoom\n"); - NDPI_PROTOCOL_BITMASK all; struct ndpi_detection_module_struct *ndpi_info_mod = ndpi_init_detection_module(init_prefs); NDPI_BITMASK_SET_ALL(all); @@ -663,9 +656,6 @@ static void help(u_int long_help) { } -#define OPTLONG_VALUE_LRU_CACHE_SIZE 1000 -#define OPTLONG_VALUE_LRU_CACHE_TTL 1001 - #define OPTLONG_VALUE_CFG 3000 static struct option longopts[] = { @@ -709,9 +699,6 @@ static struct option longopts[] = { { "result-path", required_argument, NULL, 'w'}, { "quiet", no_argument, NULL, 'q'}, - { "lru-cache-size", required_argument, NULL, OPTLONG_VALUE_LRU_CACHE_SIZE}, - { "lru-cache-ttl", required_argument, NULL, OPTLONG_VALUE_LRU_CACHE_TTL}, - { "cfg", required_argument, NULL, OPTLONG_VALUE_CFG}, {0, 0, 0, 0} @@ -903,52 +890,6 @@ void printCSVHeader() { fprintf(csv_fp, "\n"); } -static int cache_idx_from_name(const char *name) -{ - if(strcmp(name, "ookla") == 0) - return NDPI_LRUCACHE_OOKLA; - if(strcmp(name, "bittorrent") == 0) - return NDPI_LRUCACHE_BITTORRENT; - if(strcmp(name, "zoom") == 0) - return NDPI_LRUCACHE_ZOOM; - if(strcmp(name, "stun") == 0) - return NDPI_LRUCACHE_STUN; - if(strcmp(name, "tls_cert") == 0) - return NDPI_LRUCACHE_TLS_CERT; - if(strcmp(name, "mining") == 0) - return NDPI_LRUCACHE_MINING; - if(strcmp(name, "msteams") == 0) - return NDPI_LRUCACHE_MSTEAMS; - if(strcmp(name, "stun_zoom") == 0) - return NDPI_LRUCACHE_STUN_ZOOM; - return -1; -} - -static int parse_cache_param(char *param, int *cache_idx, int *param_value) -{ - char *saveptr, *tmp_str, *cache_str, *param_str; - int idx; - - tmp_str = ndpi_strdup(param); - if(tmp_str) { - cache_str = strtok_r(tmp_str, ":", &saveptr); - if(cache_str) { - param_str = strtok_r(NULL, ":", &saveptr); - if(param_str) { - idx = cache_idx_from_name(cache_str); - if(idx >= 0) { - *cache_idx = idx; - *param_value = atoi(param_str); - ndpi_free(tmp_str); - return 0; - } - } - } - } - ndpi_free(tmp_str); - return -1; -} - static int parse_two_unsigned_integer(char *param, u_int32_t *num1, u_int32_t *num2) { char *saveptr, *tmp_str, *num1_str, *num2_str; @@ -1049,7 +990,6 @@ static void parseOptions(int argc, char **argv) { u_int num_cores = sysconf(_SC_NPROCESSORS_ONLN); #endif #endif - int cache_idx, cache_size, cache_ttl; char *s1, *s2, *s3; #ifdef USE_DPDK @@ -1066,11 +1006,6 @@ static void parseOptions(int argc, char **argv) { for(i = 0; i < NDPI_MAX_SUPPORTED_PROTOCOLS; i++) aggressiveness[i] = -1; /* Use the default value */ - for(i = 0; i < NDPI_LRUCACHE_MAX; i++) { - lru_cache_sizes[i] = -1; /* Use the default value */ - lru_cache_ttls[i] = -1; /* Use the default value */ - } - while((opt = getopt_long(argc, argv, "a:Ab:B:e:Ec:C:dDFf:g:G:i:Ij:k:K:S:hHp:pP:l:r:Rs:tu:v:V:n:rp:x:X:w:Z:q0123:456:7:89:m:MT:U:", longopts, &option_idx)) != EOF) { @@ -1378,22 +1313,6 @@ static void parseOptions(int argc, char **argv) { max_num_udp_dissected_pkts = atoi(optarg); break; - case OPTLONG_VALUE_LRU_CACHE_SIZE: - if(parse_cache_param(optarg, &cache_idx, &cache_size) == -1) { - printf("Invalid parameter [%s]\n", optarg); - exit(1); - } - lru_cache_sizes[cache_idx] = cache_size; - break; - - case OPTLONG_VALUE_LRU_CACHE_TTL: - if(parse_cache_param(optarg, &cache_idx, &cache_ttl) == -1) { - printf("Invalid parameter [%s]\n", optarg); - exit(1); - } - lru_cache_ttls[cache_idx] = cache_ttl; - break; - case OPTLONG_VALUE_CFG: if(parse_three_strings(optarg, &s1, &s2, &s3) == -1 || reader_add_cfg(s1, s2, s3, 0) == -1) { @@ -2903,20 +2822,6 @@ static void setupDetection(u_int16_t thread_id, pcap_t * pcap_handle) { if(_protoFilePath != NULL) ndpi_load_protocols_file(ndpi_thread_info[thread_id].workflow->ndpi_struct, _protoFilePath); - /* Enable/disable/configure LRU caches size here */ - for(i = 0; i < NDPI_LRUCACHE_MAX; i++) { - if(lru_cache_sizes[i] != -1) - ndpi_set_lru_cache_size(ndpi_thread_info[thread_id].workflow->ndpi_struct, - i, lru_cache_sizes[i]); - } - - /* Enable/disable LRU caches TTL here */ - for(i = 0; i < NDPI_LRUCACHE_MAX; i++) { - if(lru_cache_ttls[i] != -1) - ndpi_set_lru_cache_ttl(ndpi_thread_info[thread_id].workflow->ndpi_struct, - i, lru_cache_ttls[i]); - } - /* Set aggressiveness here */ for(i = 0; i < NDPI_MAX_SUPPORTED_PROTOCOLS; i++) { if(aggressiveness[i] != -1) |