diff options
| author | liuwentan <[email protected]> | 2023-02-20 10:57:40 +0800 |
|---|---|---|
| committer | liuwentan <[email protected]> | 2023-02-20 10:57:40 +0800 |
| commit | bbed56db80cbdc994a3f9a937cdf62e3316e6008 (patch) | |
| tree | 2e465495f6be580352b43a06186d23fc666c82c9 /scanner | |
| parent | be5d1577331dcd35f4930edaf6f0df9931ee08ff (diff) | |
compile table support conjunction, ip_plugin support cidr
Diffstat (limited to 'scanner')
| -rw-r--r-- | scanner/bool_matcher.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/scanner/bool_matcher.h b/scanner/bool_matcher.h new file mode 100644 index 0000000..3b86e5f --- /dev/null +++ b/scanner/bool_matcher.h @@ -0,0 +1,66 @@ +/* + * + * Copyright (c) 2018 + * String Algorithms Research Group + * Institute of Information Engineering, Chinese Academy of Sciences (IIE-CAS) + * National Engineering Laboratory for Information Security Technologies (NELIST) + * All rights reserved + * + * Written by: LIU YANBING ([email protected]) + * Last modification: 2021-06-12 + * + * This code is the exclusive and proprietary property of IIE-CAS and NELIST. + * Usage for direct or indirect commercial advantage is not allowed without + * written permission from the authors. + * + */ + +#ifndef INCLUDE_BOOL_MATCHER_H +#define INCLUDE_BOOL_MATCHER_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include <stddef.h> + +#define MAX_ITEMS_PER_BOOL_EXPR 8 + + /* not_flag=0表示布尔项item_id必须出现;not_flag=1表示布尔项item_id不能出现 */ + struct bool_item + { + unsigned long long item_id; + unsigned char not_flag; + }; + + /* At least one item's not_flag should be 0. */ + struct bool_expr + { + unsigned long long expr_id; + void *user_tag; + size_t item_num; + struct bool_item items[MAX_ITEMS_PER_BOOL_EXPR]; + }; + + struct bool_expr_match + { + unsigned long long expr_id; + void *user_tag; + }; + + struct bool_matcher; + + struct bool_matcher *bool_matcher_new(struct bool_expr *exprs, size_t expr_num, size_t *mem_size); + + /* Returned results are sorted by expr_id in descending order. */ + // Input item_ids MUST be ASCENDING order and NO duplication. + int bool_matcher_match(struct bool_matcher *matcher, unsigned long long *item_ids, size_t item_num, struct bool_expr_match *results, size_t n_result); + + void bool_matcher_free(struct bool_matcher *matcher); + +#ifdef __cplusplus +} +#endif + +#endif |
