diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2025-06-09 09:00:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-09 09:00:17 +0200 |
commit | cbd7136b3480774a10f18744d33d3694ffee221b (patch) | |
tree | a9981734e85c500ab4605e913cd6ee8b8197492d /src/include/ndpi_api.h | |
parent | 75395cb264f9bfd38d27ac0ba506acc9eab22e34 (diff) |
Remove `NDPI_PROTOCOL_BITMASK`; add a new generic bitmask data structure (#2871)
The main difference is that the memory is allocated at runtime
Typical usercase:
```
struct ndpi_bitmask b;
ndpi_bitmask_alloc(&b, ndpi_get_num_internal_protocols());
ndpi_bitmask_set(&b, $BIT);
ndpi_bitmask_is_set(&b, $BIT);
[...]
ndpi_bitmask_dealloc(&b);
```
See #2136
Diffstat (limited to 'src/include/ndpi_api.h')
-rw-r--r-- | src/include/ndpi_api.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/include/ndpi_api.h b/src/include/ndpi_api.h index 78ac1d605..e8b1b06b5 100644 --- a/src/include/ndpi_api.h +++ b/src/include/ndpi_api.h @@ -212,7 +212,7 @@ extern "C" { * */ struct ndpi_detection_module_struct *ndpi_init_detection_module_ext(struct ndpi_global_context *g_ctx, - const NDPI_INTERNAL_PROTOCOL_BITMASK *detection_bitmask); + const struct ndpi_bitmask *detection_bitmask); /** * Completes the initialization (2nd step) @@ -880,6 +880,14 @@ extern "C" { u_int ndpi_get_num_protocols(struct ndpi_detection_module_struct *ndpi_mod); /** + * Get the number of the internal protocols. + * + * @return the number of protocols + * + */ + u_int ndpi_get_num_internal_protocols(void); + + /** * Get the nDPI version release * * @return the NDPI_GIT_RELEASE @@ -2433,6 +2441,16 @@ extern "C" { */ int ndpi_memcasecmp(const void *s1, const void *s2, size_t n); + + int ndpi_bitmask_alloc(struct ndpi_bitmask *b, u_int16_t max_bits); + void ndpi_bitmask_dealloc(struct ndpi_bitmask *b); + void ndpi_bitmask_set(struct ndpi_bitmask *b, u_int16_t bit); + void ndpi_bitmask_clear(struct ndpi_bitmask *b, u_int16_t bit); + int ndpi_bitmask_is_set(const struct ndpi_bitmask *b, u_int16_t bit); + void ndpi_bitmask_set_all(struct ndpi_bitmask *b); + void ndpi_bitmask_reset(struct ndpi_bitmask *b); + struct ndpi_bitmask *ndpi_bitmask_clone(const struct ndpi_bitmask *b); + #ifdef __cplusplus } #endif |