Added support for roaring bitmap v3 (#2355)
* Integrated RoaringBitmap v3 * Renamed ndpi_bitmap64 ro ndpi_bitmap64_fuse * Fixes to ndpi_bitmap for new roaring library * Fixes for bitmap serialization * Fixed format * Warning fix * Conversion fix * Warning fix * Added check for roaring v3 support * Updated file name * Updated path * Uses clang-9 (instead of clang-7) for builds * Fixed fuzz_ds_bitmap64_fuse * Fixes nDPI printf handling * Disabled printf * Yet another printf fix * Cleaup * Fx for compiling on older platforms * Fixes for old compilers * Initialization changes * Added compiler check * Fixes for old compilers * Inline function is not static inline * Added missing include
This commit is contained in:
+12
-14
@@ -2012,18 +2012,16 @@ extern "C" {
|
||||
*/
|
||||
|
||||
ndpi_bitmap* ndpi_bitmap_alloc(void);
|
||||
ndpi_bitmap* ndpi_bitmap_alloc_size(u_int32_t size);
|
||||
void ndpi_bitmap_free(ndpi_bitmap* b);
|
||||
ndpi_bitmap* ndpi_bitmap_copy(ndpi_bitmap* b);
|
||||
u_int64_t ndpi_bitmap_cardinality(ndpi_bitmap* b);
|
||||
bool ndpi_bitmap_is_empty(ndpi_bitmap* b);
|
||||
void ndpi_bitmap_set(ndpi_bitmap* b, u_int32_t value);
|
||||
void ndpi_bitmap_unset(ndpi_bitmap* b, u_int32_t value);
|
||||
bool ndpi_bitmap_isset(ndpi_bitmap* b, u_int32_t value);
|
||||
void ndpi_bitmap_clear(ndpi_bitmap* b);
|
||||
void ndpi_bitmap_set(ndpi_bitmap* b, u_int64_t value);
|
||||
void ndpi_bitmap_unset(ndpi_bitmap* b, u_int64_t value);
|
||||
bool ndpi_bitmap_isset(ndpi_bitmap* b, u_int64_t value);
|
||||
|
||||
size_t ndpi_bitmap_serialize(ndpi_bitmap* b, char **buf);
|
||||
ndpi_bitmap* ndpi_bitmap_deserialize(char *buf);
|
||||
ndpi_bitmap* ndpi_bitmap_deserialize(char *buf, size_t buf_len);
|
||||
|
||||
void ndpi_bitmap_and(ndpi_bitmap* a, ndpi_bitmap* b_and);
|
||||
ndpi_bitmap* ndpi_bitmap_and_alloc(ndpi_bitmap* a, ndpi_bitmap* b_and);
|
||||
@@ -2035,7 +2033,7 @@ extern "C" {
|
||||
|
||||
ndpi_bitmap_iterator* ndpi_bitmap_iterator_alloc(ndpi_bitmap* b);
|
||||
void ndpi_bitmap_iterator_free(ndpi_bitmap* b);
|
||||
bool ndpi_bitmap_iterator_next(ndpi_bitmap_iterator* i, u_int32_t *value);
|
||||
bool ndpi_bitmap_iterator_next(ndpi_bitmap_iterator* i, u_int64_t *value);
|
||||
|
||||
/* ******************************* */
|
||||
|
||||
@@ -2045,16 +2043,16 @@ extern "C" {
|
||||
|
||||
This is
|
||||
- a probabilistic datastructure !!! (i.e. be prepared to false positives)
|
||||
- immutable (i.e. adding keys after a search (i.e. ndpi_bitmap64_isset)
|
||||
- immutable (i.e. adding keys after a search (i.e. ndpi_bitmap64_fuse_isset)
|
||||
is not allowed
|
||||
*/
|
||||
|
||||
ndpi_bitmap64* ndpi_bitmap64_alloc(void);
|
||||
bool ndpi_bitmap64_set(ndpi_bitmap64 *b, u_int64_t value);
|
||||
bool ndpi_bitmap64_compress(ndpi_bitmap64 *b);
|
||||
bool ndpi_bitmap64_isset(ndpi_bitmap64 *b, u_int64_t value);
|
||||
void ndpi_bitmap64_free(ndpi_bitmap64 *b);
|
||||
u_int32_t ndpi_bitmap64_size(ndpi_bitmap64 *b);
|
||||
ndpi_bitmap64_fuse* ndpi_bitmap64_fuse_alloc(void);
|
||||
bool ndpi_bitmap64_fuse_set(ndpi_bitmap64_fuse *b, u_int64_t value);
|
||||
bool ndpi_bitmap64_fuse_compress(ndpi_bitmap64_fuse *b);
|
||||
bool ndpi_bitmap64_fuse_isset(ndpi_bitmap64_fuse *b, u_int64_t value);
|
||||
void ndpi_bitmap64_fuse_free(ndpi_bitmap64_fuse *b);
|
||||
u_int32_t ndpi_bitmap64_fuse_size(ndpi_bitmap64_fuse *b);
|
||||
|
||||
/* ******************************* */
|
||||
|
||||
|
||||
@@ -176,6 +176,7 @@
|
||||
#define get_u_int32_t(X,O) (*(u_int32_t *)((&(((u_int8_t *)X)[O]))))
|
||||
#if defined(__arm__)
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
static inline uint64_t get_u_int64_t(const uint8_t* X, int O)
|
||||
{
|
||||
uint64_t tmp;
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* ndpi_replace_printf.h
|
||||
*
|
||||
* Copyright (C) 2023 - ntop.org and contributors
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
// This file may be included in every *.c file that uses printf(...) except for ndpi_main.c !
|
||||
|
||||
#include "ndpi_config.h"
|
||||
|
||||
#ifndef NDPI_CFFI_PREPROCESSING
|
||||
|
||||
#undef printf
|
||||
#undef fprintf
|
||||
|
||||
#include "ndpi_typedefs.h"
|
||||
|
||||
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||
|
||||
#define printf(...) ndpi_debug_printf(0, NULL, NDPI_LOG_DEBUG_EXTRA, __FILE__, __func__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#ifdef NDPI_REPLACE_FPRINTF
|
||||
#define fprintf(stream, ...) ndpi_debug_printf(0, NULL, NDPI_LOG_ERROR, __FILE__, __func__, __LINE__, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define printf(...) do {} while(0);
|
||||
|
||||
#ifdef NDPI_REPLACE_FPRINTF
|
||||
#define fprintf(stream, ...) do {} while(0);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
void ndpi_debug_printf(unsigned int proto, struct ndpi_detection_module_struct *ndpi_str, ndpi_log_level_t log_level,
|
||||
const char *file_name, const char *func_name, int line_number, const char *format, ...);
|
||||
|
||||
#endif
|
||||
@@ -1141,6 +1141,7 @@ typedef struct ndpi_proto {
|
||||
|
||||
typedef void ndpi_bitmap;
|
||||
typedef void ndpi_bitmap64;
|
||||
typedef void ndpi_bitmap64_fuse; /* probabilistic */
|
||||
typedef void ndpi_bitmap_iterator;
|
||||
typedef void ndpi_filter;
|
||||
|
||||
@@ -1155,7 +1156,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
struct {
|
||||
u_int16_t class_id;
|
||||
ndpi_bitmap64 *domains;
|
||||
ndpi_bitmap64_fuse *domains;
|
||||
} classes[MAX_NUM_NDPI_DOMAIN_CLASSIFICATIONS];
|
||||
} ndpi_domain_classify;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user