diff options
author | Luca Deri <deri@ntop.org> | 2018-05-14 22:58:14 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2018-05-14 22:58:14 +0200 |
commit | 66b759ca690425aa94b88b05f5a23818dce0b4be (patch) | |
tree | ad4dd7439df3ed96057e9d9e1c7d36c036a4535d /example | |
parent | 529492e81fa9866f0b4cd22227eb6a499ac5da68 (diff) |
Hidden ndpi_detection_module_struct definition
Diffstat (limited to 'example')
-rw-r--r-- | example/ndpiReader.c | 16 | ||||
-rw-r--r-- | example/ndpi_util.c | 12 |
2 files changed, 17 insertions, 11 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 2aa08feba..c3b49aa41 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -378,29 +378,31 @@ int cmpFlows(const void *_a, const void *_b) { void extcap_config() { int i, argidx = 0; struct ndpi_proto_sorter *protos; - + u_int ndpi_num_supported_protocols = ndpi_get_ndpi_num_supported_protocols(ndpi_info_mod); + ndpi_proto_defaults_t *proto_defaults = ndpi_get_proto_defaults(ndpi_info_mod); + /* -i <interface> */ printf("arg {number=%d}{call=-i}{display=Capture Interface}{type=string}" "{tooltip=The interface name}\n", argidx++); printf("arg {number=%d}{call=-i}{display=Pcap File to Analyze}{type=fileselect}" "{tooltip=The pcap file to analyze (if the interface is unspecified)}\n", argidx++); - protos = (struct ndpi_proto_sorter*)malloc(sizeof(struct ndpi_proto_sorter) * ndpi_info_mod->ndpi_num_supported_protocols); + protos = (struct ndpi_proto_sorter*)malloc(sizeof(struct ndpi_proto_sorter) * ndpi_num_supported_protocols); if(!protos) exit(0); - for(i=0; i<(int) ndpi_info_mod->ndpi_num_supported_protocols; i++) { + for(i=0; i<(int) ndpi_num_supported_protocols; i++) { protos[i].id = i; - snprintf(protos[i].name, sizeof(protos[i].name), "%s", ndpi_info_mod->proto_defaults[i].protoName); + snprintf(protos[i].name, sizeof(protos[i].name), "%s", proto_defaults[i].protoName); } - qsort(protos, ndpi_info_mod->ndpi_num_supported_protocols, sizeof(struct ndpi_proto_sorter), cmpProto); + qsort(protos, ndpi_num_supported_protocols, sizeof(struct ndpi_proto_sorter), cmpProto); printf("arg {number=%d}{call=-9}{display=nDPI Protocol Filter}{type=selector}" "{tooltip=nDPI Protocol to be filtered}\n", argidx); printf("value {arg=%d}{value=%d}{display=%s}\n", argidx, -1, "All Protocols (no nDPI filtering)"); - for(i=0; i<(int)ndpi_info_mod->ndpi_num_supported_protocols; i++) + for(i=0; i<(int)ndpi_num_supported_protocols; i++) printf("value {arg=%d}{value=%d}{display=%s (%d)}\n", argidx, protos[i].id, protos[i].name, protos[i].id); @@ -1933,7 +1935,7 @@ static void printResults(u_int64_t tot_usec) { if(!quiet_mode) { printf("\nnDPI Memory statistics:\n"); - printf("\tnDPI Memory (once): %-13s\n", formatBytes(sizeof(struct ndpi_detection_module_struct), buf, sizeof(buf))); + printf("\tnDPI Memory (once): %-13s\n", formatBytes(ndpi_get_ndpi_detection_module_size(), buf, sizeof(buf))); printf("\tFlow Memory (per flow): %-13s\n", formatBytes(sizeof(struct ndpi_flow_struct), buf, sizeof(buf))); printf("\tActual Memory: %-13s\n", formatBytes(current_ndpi_memory, buf, sizeof(buf))); printf("\tPeak Memory: %-13s\n", formatBytes(max_ndpi_memory, buf, sizeof(buf))); diff --git a/example/ndpi_util.c b/example/ndpi_util.c index d83f1fdca..9695558ae 100644 --- a/example/ndpi_util.c +++ b/example/ndpi_util.c @@ -113,14 +113,17 @@ static uint16_t ndpi_get_proto_id(struct ndpi_detection_module_struct *ndpi_mod, uint16_t proto_id; char *e; unsigned long p = strtol(name,&e,0); + ndpi_proto_defaults_t *proto_defaults = ndpi_get_proto_defaults(ndpi_mod); + if(e && !*e) { if(p < NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS && - ndpi_mod->proto_defaults[p].protoName) return (uint16_t)p; + proto_defaults[p].protoName) return (uint16_t)p; return NDPI_PROTOCOL_UNKNOWN; } + for(proto_id=NDPI_PROTOCOL_UNKNOWN; proto_id < NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS; proto_id++) { - if(ndpi_mod->proto_defaults[proto_id].protoName && - !strcasecmp(ndpi_mod->proto_defaults[proto_id].protoName,name)) + if(proto_defaults[proto_id].protoName && + !strcasecmp(proto_defaults[proto_id].protoName,name)) return proto_id; } return NDPI_PROTOCOL_UNKNOWN; @@ -181,7 +184,8 @@ struct ndpi_workflow* ndpi_workflow_init(const struct ndpi_workflow_prefs * pref NDPI_LOG(0, NULL, NDPI_LOG_ERROR, "global structure initialization failed\n"); exit(-1); } - module->ndpi_log_level = nDPI_LogLevel; + + ndpi_set_log_level(module, nDPI_LogLevel); if(_debug_protocols != NULL && ! _debug_protocols_ok) { if(parse_debug_proto(module,_debug_protocols)) |