diff options
author | Vitaly Lavrov <vel21ripn@gmail.com> | 2021-06-15 09:28:09 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-15 11:28:09 +0200 |
commit | be808c30f3f4582009df4c5efccd4f3bb0c6ef1d (patch) | |
tree | f16d861560fecd97d23e5de1826d8fdc9bcd0049 /src/include | |
parent | 09293fabd9dcb92812641788509a1a766e9320f8 (diff) |
Code review. (#1205)
The common actions required to call the ac_automata_search() function
have been moved to the ndpi_match_string_common function. This made it
possible to simplify the ndpi_match_string, ndpi_match_string_protocol_id,
ndpi_match_string_value, ndpi_match_custom_category, ndpi_match_string_subprotocol,
ndpi_match_bigram, ndpi_match_trigram functions.
Using u_int16_t type for protocol identifiers when working with the
ahocorasick library (changes src/include/ndpi_api.h.in and src/include/ndpi_typedefs.h).
Reworked "finalization" of all AC_AUTOMATA_t structures.
Changing the order of fields in the ndpi_call_function_struct structure
reduces the size of the ndpi_detection_module_struct structure by 10 kB (for x86_64).
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/ndpi_api.h.in | 2 | ||||
-rw-r--r-- | src/include/ndpi_typedefs.h | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/include/ndpi_api.h.in b/src/include/ndpi_api.h.in index f2da3b186..d2c1b62bf 100644 --- a/src/include/ndpi_api.h.in +++ b/src/include/ndpi_api.h.in @@ -106,7 +106,7 @@ extern "C" { via ndpi_add_string_value_to_automa() */ int ndpi_match_string_value(void *_automa, char *string_to_match, - u_int match_len, u_int32_t *num); + u_int match_len, u_int16_t *num); /** * nDPI personal allocation and free functions diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h index 4656b4af2..4fee4e4d4 100644 --- a/src/include/ndpi_typedefs.h +++ b/src/include/ndpi_typedefs.h @@ -923,11 +923,11 @@ struct ndpi_detection_module_struct; struct ndpi_flow_struct; struct ndpi_call_function_struct { - u_int16_t ndpi_protocol_id; NDPI_PROTOCOL_BITMASK detection_bitmask; NDPI_PROTOCOL_BITMASK excluded_protocol_bitmask; - NDPI_SELECTION_BITMASK_PROTOCOL_SIZE ndpi_selection_bitmask; void (*func) (struct ndpi_detection_module_struct *, struct ndpi_flow_struct *flow); + NDPI_SELECTION_BITMASK_PROTOCOL_SIZE ndpi_selection_bitmask; + u_int16_t ndpi_protocol_id; u_int8_t detection_feature; }; @@ -1056,7 +1056,6 @@ typedef struct ndpi_default_ports_tree_node { typedef struct _ndpi_automa { void *ac_automa; /* Real type is AC_AUTOMATA_t */ - u_int8_t ac_automa_finalized; } ndpi_automa; typedef struct ndpi_proto { @@ -1149,6 +1148,7 @@ struct ndpi_detection_module_struct { u_int ndpi_num_supported_protocols; u_int ndpi_num_custom_protocols; + int ac_automa_finalized; /* HTTP/DNS/HTTPS/QUIC host matching */ ndpi_automa host_automa, /* Used for DNS/HTTPS */ content_automa, /* Used for HTTP subprotocol_detection */ @@ -1526,7 +1526,7 @@ typedef enum } ndpi_prefs; typedef struct { - int protocol_id; + u_int16_t protocol_id; ndpi_protocol_category_t protocol_category; ndpi_protocol_breed_t protocol_breed; } ndpi_protocol_match_result; |