diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2025-06-03 10:22:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-03 10:22:15 +0200 |
commit | ed210577101af311e70d6ddcde1b0282a76f6031 (patch) | |
tree | 2be00d2596b052ede26a9849a7c75c1828ca089c /example/reader_util.c | |
parent | 70a72f163800dd37dca1ec586ae0a58a6cef8206 (diff) |
First step into a dynamic number of protocols (#2857)
We want to get rid of the defines `NDPI_MAX_SUPPORTED_PROTOCOLS` and
`NDPI_MAX_NUM_CUSTOM_PROTOCOLS`.
You can use:
```
ndpi_get_num_protocols()
```
See #2136
Removed some unused functions from public API
Diffstat (limited to 'example/reader_util.c')
-rw-r--r-- | example/reader_util.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/example/reader_util.c b/example/reader_util.c index a71935da6..3c0819b7e 100644 --- a/example/reader_util.c +++ b/example/reader_util.c @@ -336,28 +336,6 @@ void ndpi_free_flow_info_half(struct ndpi_flow_info *flow) { /* ***************************************************** */ -static uint16_t ndpi_get_proto_id(struct ndpi_detection_module_struct *ndpi_mod, const char *name) { - 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 && - 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(proto_defaults[proto_id].protoName && - !strcasecmp(proto_defaults[proto_id].protoName,name)) - return proto_id; - } - return NDPI_PROTOCOL_UNKNOWN; -} - -/* ***************************************************** */ - static char _proto_delim[] = " \t,:;"; int parse_proto_name_list(char *str, NDPI_INTERNAL_PROTOCOL_BITMASK *bitmask, int inverted_logic) { char *n; @@ -393,7 +371,7 @@ int parse_proto_name_list(char *str, NDPI_INTERNAL_PROTOCOL_BITMASK *bitmask, in NDPI_INTERNAL_PROTOCOL_RESET(*bitmask); continue; } - proto = ndpi_get_proto_id(module, n); + proto = ndpi_get_proto_by_name(module, n); if(proto == NDPI_PROTOCOL_UNKNOWN && strcmp(n,"unknown") && strcmp(n,"0")) { LOG(NDPI_LOG_ERROR, "Invalid protocol %s\n", n); ndpi_exit_detection_module(module); @@ -625,6 +603,14 @@ void ndpi_workflow_free(struct ndpi_workflow * workflow) { ndpi_exit_detection_module(workflow->ndpi_struct); ndpi_free(workflow->ndpi_flows_root); + + ndpi_free(workflow->stats.protocol_counter); + ndpi_free(workflow->stats.protocol_counter_bytes); + ndpi_free(workflow->stats.protocol_flows); + ndpi_free(workflow->stats.fpc_protocol_counter); + ndpi_free(workflow->stats.fpc_protocol_counter_bytes); + ndpi_free(workflow->stats.fpc_protocol_flows); + ndpi_free(workflow); } |