重构代码目录,改用cmake编译。
This commit is contained in:
@@ -1226,20 +1226,20 @@ int Maat_scan_proto_addr(Maat_feather_t feather,int table_id
|
||||
switch(addr->addrtype)
|
||||
{
|
||||
case ADDR_TYPE_IPV4:
|
||||
ip_scan_data.ipv4_data.saddr=ntohl(addr->paddr.v4->saddr);
|
||||
ip_scan_data.ipv4_data.daddr=ntohl(addr->paddr.v4->daddr);
|
||||
ip_scan_data.ipv4_data.sport=ntohs(addr->paddr.v4->source);
|
||||
ip_scan_data.ipv4_data.dport=ntohs(addr->paddr.v4->dest);
|
||||
ip_scan_data.ipv4_data.saddr=ntohl(addr->v4->saddr);
|
||||
ip_scan_data.ipv4_data.daddr=ntohl(addr->v4->daddr);
|
||||
ip_scan_data.ipv4_data.sport=ntohs(addr->v4->source);
|
||||
ip_scan_data.ipv4_data.dport=ntohs(addr->v4->dest);
|
||||
ip_scan_data.ipv4_data.proto=proto;
|
||||
break;
|
||||
case ADDR_TYPE_IPV6:
|
||||
ip_scan_data.rule_type=RULETYPE_IPv6;
|
||||
memcpy(ip_scan_data.ipv6_data.saddr,addr->paddr.v6->saddr,sizeof(ip_scan_data.ipv6_data.saddr));
|
||||
memcpy(ip_scan_data.ipv6_data.saddr,addr->v6->saddr,sizeof(ip_scan_data.ipv6_data.saddr));
|
||||
ipv6_ntoh(ip_scan_data.ipv6_data.saddr);
|
||||
memcpy(ip_scan_data.ipv6_data.daddr,addr->paddr.v6->daddr,sizeof(ip_scan_data.ipv6_data.daddr));
|
||||
memcpy(ip_scan_data.ipv6_data.daddr,addr->v6->daddr,sizeof(ip_scan_data.ipv6_data.daddr));
|
||||
ipv6_ntoh(ip_scan_data.ipv6_data.daddr);
|
||||
ip_scan_data.ipv6_data.sport=ntohs(addr->paddr.v6->source);
|
||||
ip_scan_data.ipv6_data.dport=ntohs(addr->paddr.v6->dest);
|
||||
ip_scan_data.ipv6_data.sport=ntohs(addr->v6->source);
|
||||
ip_scan_data.ipv6_data.dport=ntohs(addr->v6->dest);
|
||||
ip_scan_data.ipv6_data.proto=proto;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -1,513 +0,0 @@
|
||||
#ifndef H_MAAT_RULE_INTERNAL_H_INCLUDE
|
||||
#define H_MAAT_RULE_INTERNAL_H_INCLUDE
|
||||
|
||||
#include "Maat_rule.h"
|
||||
#include "Maat_command.h"
|
||||
|
||||
#include <MESA/MESA_htable.h>
|
||||
#include <MESA/MESA_list_queue.h>
|
||||
#include <MESA/field_stat2.h>
|
||||
#include "dynamic_array.h"
|
||||
#include "UniversalBoolMatch.h"
|
||||
#include "rulescan.h"
|
||||
#include "hiredis.h"
|
||||
|
||||
#include "stream_fuzzy_hash.h"
|
||||
#include "gram_index_engine.h"
|
||||
#include "aligment_int64.h"
|
||||
#include <pthread.h>
|
||||
#include <iconv.h>
|
||||
|
||||
extern const char *maat_module;
|
||||
|
||||
|
||||
#if(__GNUC__ * 100 + __GNUC_MINOR__ * 10 + __GNUC_PATCHLEVEL__ >= 411)
|
||||
#define atomic_inc(x) __sync_add_and_fetch((x),1)
|
||||
#define atomic_dec(x) __sync_sub_and_fetch((x),1)
|
||||
#define atomic_add(x,y) __sync_add_and_fetch((x),(y))
|
||||
#define atomic_sub(x,y) __sync_sub_and_fetch((x),(y))
|
||||
typedef int atomic_t;
|
||||
#define ATOMIC_INIT(i) { (i) }
|
||||
#define atomic_read(x) __sync_add_and_fetch((x),0)
|
||||
#define atomic_set(x,y) __sync_lock_test_and_set((x),y)
|
||||
#else
|
||||
#include <alsa/iatomic.h>
|
||||
#endif
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#define MAX_TABLE_NUM 256
|
||||
#define MAX_CONJUNCTION_TABLE_NUM 8
|
||||
#define MAX_CHARSET_NUM 16
|
||||
#define MAX_TABLE_NAME_LEN 256
|
||||
#define MAX_TABLE_LINE_SIZE (1024*16)
|
||||
#define MAX_EXPR_KEYLEN 1024
|
||||
#define MAX_DISTRICT_LEN 64
|
||||
#define MAX_PLUGING_NUM 32
|
||||
|
||||
#define MAX_SCANNER_HIT_NUM 64
|
||||
|
||||
#define MAX_GROUP_CACHE 128
|
||||
|
||||
#define MAX_FAILED_NUM 128
|
||||
|
||||
#define MAX_MAAT_STAT_NUM 64
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
||||
#endif
|
||||
|
||||
#ifndef container_of
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
#endif
|
||||
|
||||
typedef void* rule_scanner_t;
|
||||
enum MAAT_TABLE_TYPE
|
||||
{
|
||||
TABLE_TYPE_EXPR=0,
|
||||
TABLE_TYPE_IP,
|
||||
TABLE_TYPE_INTERVAL,
|
||||
TABLE_TYPE_DIGEST,
|
||||
TABLE_TYPE_EXPR_PLUS,
|
||||
TABLE_TYPE_SIMILARITY,
|
||||
TABLE_TYPE_GROUP,
|
||||
TABLE_TYPE_COMPILE,
|
||||
TABLE_TYPE_PLUGIN
|
||||
|
||||
};
|
||||
|
||||
struct db_str_rule_t
|
||||
{
|
||||
int region_id;
|
||||
int group_id;
|
||||
char keywords[MAX_EXPR_KEYLEN];
|
||||
char district[MAX_DISTRICT_LEN];
|
||||
enum MAAT_EXPR_TYPE expr_type;
|
||||
enum MAAT_MATCH_METHOD match_method;
|
||||
int is_hexbin;
|
||||
int is_case_sensitive;
|
||||
int is_valid;
|
||||
|
||||
};
|
||||
struct db_ip_rule_t
|
||||
{
|
||||
int region_id;
|
||||
int group_id;
|
||||
int addr_type;
|
||||
union
|
||||
{
|
||||
//ip address use network order
|
||||
//port use host order
|
||||
ipv4_rule_t ipv4_rule;
|
||||
ipv6_rule_t ipv6_rule;
|
||||
};
|
||||
int is_valid;
|
||||
};
|
||||
struct db_intval_rule_t
|
||||
{
|
||||
int region_id;
|
||||
int group_id;
|
||||
interval_rule_t intval;
|
||||
int is_valid;
|
||||
};
|
||||
struct db_digest_rule_t
|
||||
{
|
||||
int region_id;
|
||||
int group_id;
|
||||
unsigned long long orgin_len;
|
||||
char* digest_string;
|
||||
short confidence_degree;
|
||||
int is_valid;
|
||||
};
|
||||
struct _head_Maat_rule_t
|
||||
{
|
||||
int config_id;
|
||||
int service_id;
|
||||
char do_log;
|
||||
char do_blacklist;
|
||||
char action;
|
||||
char resevered;
|
||||
int serv_def_len;
|
||||
};
|
||||
struct db_compile_rule_t
|
||||
{
|
||||
struct _head_Maat_rule_t m_rule_head;// fix len of Maat_rule_t
|
||||
char* service_defined;
|
||||
long long effective_range;
|
||||
int is_valid;
|
||||
int declare_grp_num;
|
||||
};
|
||||
struct db_group_rule_t
|
||||
{
|
||||
int group_id;
|
||||
int compile_id;
|
||||
int is_valid;
|
||||
};
|
||||
struct op_expr_t
|
||||
{
|
||||
boolean_expr_t* p_expr;
|
||||
scan_rule_t* p_rules[MAAT_MAX_EXPR_ITEM_NUM];
|
||||
int convert_failed;
|
||||
int no_effect_convert_cnt;
|
||||
int table_id;
|
||||
int rule_type;
|
||||
};
|
||||
|
||||
struct _Maat_region_inner_t
|
||||
{
|
||||
int region_id;
|
||||
int district_id;
|
||||
int table_id;
|
||||
int expr_id_cnt;
|
||||
int expr_id_lb;
|
||||
int expr_id_ub;
|
||||
enum MAAT_TABLE_TYPE table_type;
|
||||
};
|
||||
struct _Maat_group_inner_t
|
||||
{
|
||||
int group_id;
|
||||
int table_id;
|
||||
int region_boundary;
|
||||
int region_cnt;
|
||||
int ref_cnt;
|
||||
char* group_name;
|
||||
dynamic_array_t *regions;
|
||||
void* compile_shortcut;
|
||||
pthread_mutex_t mutex;
|
||||
};
|
||||
struct _Maat_compile_inner_t
|
||||
{
|
||||
struct db_compile_rule_t *db_c_rule;
|
||||
dynamic_array_t *groups;
|
||||
int compile_id;//equal to db_c_rule->m_rule.config_id
|
||||
int table_id;
|
||||
int group_boundary;
|
||||
int group_cnt;
|
||||
pthread_rwlock_t rwlock;//reading compile rule is safe in update thread, rwlock lock called when delete or scan thread read
|
||||
};
|
||||
struct _compile_result_t
|
||||
{
|
||||
int compile_id;
|
||||
universal_bool_expr_t group_set;
|
||||
};
|
||||
struct _callback_plugin
|
||||
{
|
||||
Maat_start_callback_t *start;
|
||||
Maat_update_callback_t *update;
|
||||
Maat_finish_callback_t *finish;
|
||||
void* u_para;
|
||||
};
|
||||
|
||||
struct _plugin_table_info
|
||||
{
|
||||
int cb_plug_cnt;
|
||||
struct _callback_plugin cb_plug[MAX_PLUGING_NUM];
|
||||
dynamic_array_t *cache_lines;
|
||||
int cache_line_num;
|
||||
int acc_line_num;
|
||||
int update_type;
|
||||
long cache_size;
|
||||
};
|
||||
struct _region_stat_t
|
||||
{
|
||||
int cfg_num;
|
||||
union
|
||||
{
|
||||
int expr_rule_cnt; //expr_type=0,1,3
|
||||
int ipv4_rule_cnt;
|
||||
};
|
||||
union
|
||||
{
|
||||
int regex_rule_cnt; //expr_type=2
|
||||
int ipv6_rule_cnt;
|
||||
};
|
||||
};
|
||||
#define USER_REGION_ENCODE_NONE 0
|
||||
#define USER_REGION_ENCODE_ESCAPE 1
|
||||
#define USER_REGION_ENCODE_BASE64 2
|
||||
|
||||
struct _Maat_table_info_t
|
||||
{
|
||||
unsigned short table_id;
|
||||
unsigned short conj_cnt;
|
||||
unsigned short updating_name;
|
||||
char table_name[MAX_CONJUNCTION_TABLE_NUM][MAX_TABLE_NAME_LEN];
|
||||
enum MAAT_TABLE_TYPE table_type;
|
||||
enum MAAT_CHARSET src_charset;
|
||||
enum MAAT_CHARSET dst_charset[MAX_CHARSET_NUM];
|
||||
int src_charset_in_dst;
|
||||
int do_charset_merge;
|
||||
int cfg_num;
|
||||
int cross_cache_size;
|
||||
int quick_expr_switch;
|
||||
union
|
||||
{
|
||||
int expr_rule_cnt; //expr_type=0,1,3
|
||||
int ipv4_rule_cnt;
|
||||
};
|
||||
union
|
||||
{
|
||||
int regex_rule_cnt; //expr_type=2
|
||||
int ipv6_rule_cnt;
|
||||
};
|
||||
struct _plugin_table_info *cb_info;
|
||||
int valid_flag_column; //for plugin table
|
||||
int rule_tag_column; //for plugin table;
|
||||
int user_region_encoding; //for compile table, USER_REGION_ENCODE_xx
|
||||
//for stat>>>>>>>>
|
||||
unsigned long long udpate_err_cnt;
|
||||
unsigned long long unmatch_tag_cnt;
|
||||
unsigned long long iconv_err_cnt;
|
||||
int stat_line_id;
|
||||
mcore_long_t scan_cnt;
|
||||
mcore_long_t scan_cpu_time; //nano
|
||||
mcore_long_t input_bytes;
|
||||
mcore_long_t stream_num;
|
||||
mcore_long_t hit_cnt;
|
||||
};
|
||||
|
||||
struct _INNER_scan_status_t
|
||||
{
|
||||
int cur_hit_cnt;
|
||||
int hit_group_cnt;
|
||||
int hit_group_size;
|
||||
unsigned int cur_hit_id[MAX_SCANNER_HIT_NUM];
|
||||
unsigned int *hitted_group_id;
|
||||
};
|
||||
struct _OUTER_scan_status_t
|
||||
{
|
||||
struct _Maat_feather_t* feather;
|
||||
unsigned short thread_num;
|
||||
unsigned char is_set_district;
|
||||
unsigned char is_last_region;
|
||||
int district_id;
|
||||
struct _INNER_scan_status_t* inner;
|
||||
};
|
||||
enum maat_garbage_type
|
||||
{
|
||||
GARBAGE_SCANNER=0,
|
||||
GARBAGE_GROUP_RULE,
|
||||
GARBAGE_COMPILE_RULE,
|
||||
GARBAGE_BOOL_MATCHER,
|
||||
GARBAGE_MAP_STR2INT
|
||||
};
|
||||
struct iconv_handle_t
|
||||
{
|
||||
int is_initialized;
|
||||
iconv_t cd;
|
||||
};
|
||||
struct _stream_para_t
|
||||
{
|
||||
struct _Maat_feather_t* feather;
|
||||
int version;
|
||||
int thread_num;
|
||||
int max_cross_size;
|
||||
int caching_size;
|
||||
unsigned short table_id;
|
||||
char do_merge;
|
||||
char do_expr:4;
|
||||
char do_regex:4;
|
||||
char* last_cache;
|
||||
char* scan_buff;
|
||||
void* rs_stream_para;
|
||||
long process_offset;
|
||||
unsigned long long total_len;
|
||||
sfh_instance_t *fuzzy_hash_handle;
|
||||
pthread_mutex_t fuzzy_mutex;
|
||||
unsigned char query_point[8];
|
||||
};
|
||||
struct GIE_aux_t
|
||||
{
|
||||
enum MAAT_TABLE_TYPE table_type;
|
||||
GIE_handle_t* gie_handle;
|
||||
MESA_lqueue_head update_q;
|
||||
};
|
||||
struct rule_tag
|
||||
{
|
||||
char* tag_name;
|
||||
char* tag_val;
|
||||
};
|
||||
struct _Maat_scanner_t
|
||||
{
|
||||
long long version;
|
||||
time_t last_update_time;
|
||||
long long *ref_cnt; //optimized for cache_alignment 64
|
||||
rule_scanner_t region;
|
||||
long gie_total_q_size;
|
||||
struct GIE_aux_t gie_aux[MAX_TABLE_NUM];
|
||||
MESA_htable_handle region_hash;
|
||||
MESA_htable_handle group_hash;
|
||||
MESA_htable_handle compile_hash;
|
||||
MESA_htable_handle district_map;
|
||||
MESA_htable_handle tmp_district_map;
|
||||
unsigned int district_num;
|
||||
unsigned int cfg_num;
|
||||
unsigned int exprid_generator;
|
||||
unsigned int dedup_expr_num;
|
||||
MESA_lqueue_head region_update_q;
|
||||
void * expr_compiler;
|
||||
scan_result_t *region_rslt_buff;
|
||||
MESA_lqueue_head tomb_ref;//reference of feather->garbage_q
|
||||
struct _region_stat_t region_counter[MAX_TABLE_NUM];
|
||||
int max_thread_num;
|
||||
iconv_t iconv_handle[MAX_CHARSET_NUM][MAX_CHARSET_NUM];//iconv_handle[to][from]
|
||||
};
|
||||
struct _Maat_feather_t
|
||||
{
|
||||
struct _Maat_scanner_t *scanner;
|
||||
struct _Maat_scanner_t *update_tmp_scanner;
|
||||
MESA_lqueue_head garbage_q;
|
||||
int table_cnt;
|
||||
int DEFERRED_LOAD_ON;
|
||||
int GROUP_MODE_ON;
|
||||
int REDIS_MODE_ON;
|
||||
int still_working;
|
||||
int scan_interval_ms;
|
||||
int effect_interval_ms;
|
||||
int cumulative_update_off;
|
||||
int stat_on;
|
||||
int perf_on;
|
||||
struct _Maat_table_info_t *p_table_info[MAX_TABLE_NUM];
|
||||
MESA_htable_handle map_tablename2id;
|
||||
void* logger;
|
||||
long long maat_version;
|
||||
long long last_full_version;
|
||||
int scan_thread_num;
|
||||
int rule_scan_type;
|
||||
char inc_dir[MAX_TABLE_NAME_LEN];
|
||||
char full_dir[MAX_TABLE_NAME_LEN];
|
||||
char stat_file[MAX_TABLE_NAME_LEN];
|
||||
char instance_name[MAX_TABLE_NAME_LEN];
|
||||
char table_info_fn[MAX_TABLE_NAME_LEN];
|
||||
char compile_tn[MAX_TABLE_NAME_LEN];
|
||||
char group_tn[MAX_TABLE_NAME_LEN];
|
||||
pthread_mutex_t backgroud_update_mutex;
|
||||
unsigned char decrypt_key[MAX_TABLE_NAME_LEN];
|
||||
|
||||
char redis_ip[MAX_TABLE_NAME_LEN];
|
||||
int redis_port;
|
||||
int redis_index;
|
||||
int AUTO_NUMBERING_ON;
|
||||
struct timeval connect_timeout;
|
||||
redisContext *redis_read_ctx;
|
||||
redisContext *redis_write_ctx; // not thread safe.
|
||||
int on_redis_writing;
|
||||
int cmd_q_cnt;
|
||||
struct _Maat_cmd_inner_t* cmd_qhead, *cmd_qtail;
|
||||
pthread_mutex_t redis_write_lock; //protect redis_write_ctx
|
||||
long long base_rgn_seq,base_grp_seq,server_time;
|
||||
long long load_version_from;
|
||||
|
||||
struct rule_tag *accept_tags;
|
||||
int n_tags;
|
||||
//internal states
|
||||
long long new_version;
|
||||
int active_plugin_table_num;
|
||||
int is_last_plugin_table_updating;
|
||||
|
||||
//for stat>>>>
|
||||
int backgroud_update_enabled;
|
||||
screen_stat_handle_t stat_handle;
|
||||
int total_stat_id;
|
||||
int fs_status_id[MAX_MAAT_STAT_NUM];
|
||||
int fs_column_id[MAX_MAAT_STAT_NUM];
|
||||
mcore_long_t outer_mid_cnt;
|
||||
mcore_long_t inner_mid_cnt;
|
||||
mcore_long_t hit_cnt;
|
||||
mcore_long_t thread_call_cnt;//size indicate by scan_thread_num,
|
||||
mcore_long_t orphan_group_saving;
|
||||
mcore_long_t last_region_saving;
|
||||
long long total_scan_bytes;
|
||||
long long total_scan_cnt;
|
||||
long long update_err_cnt;//sum of the same name variable in each table
|
||||
long long iconv_err_cnt;//sum of the same name variable in each table
|
||||
long long scan_err_cnt;
|
||||
long long zombie_rs_stream;
|
||||
long long postpone_q_size;
|
||||
long long compile_rule_num;
|
||||
long long cmd_acc_num;
|
||||
long long line_cmd_acc_num;
|
||||
};
|
||||
struct _maat_garbage_t
|
||||
{
|
||||
enum maat_garbage_type type;
|
||||
time_t create_time;
|
||||
int ok_times;
|
||||
union
|
||||
{
|
||||
struct _Maat_scanner_t* scanner;
|
||||
struct _Maat_group_inner_t* group_rule;
|
||||
struct _Maat_compile_inner_t* compile_rule;
|
||||
void* bool_matcher;
|
||||
void * raw;
|
||||
MESA_htable_handle str2int_map;
|
||||
};
|
||||
};
|
||||
struct serial_rule_t //rm= Redis Maat
|
||||
{
|
||||
enum MAAT_OPERATION op;//0: delete, 1: add.
|
||||
int rule_id;
|
||||
int label_id;
|
||||
long long timeout; // absolute unix time.
|
||||
char table_name[256];
|
||||
char* table_line;
|
||||
};
|
||||
int parse_accept_tag(const char* value, struct rule_tag** result, void* logger);
|
||||
void garbage_bagging(enum maat_garbage_type type,void *p,MESA_lqueue_head garbage_q);
|
||||
void garbage_bury(MESA_lqueue_head garbage_q,void *logger);
|
||||
void make_group_set(const struct _Maat_compile_inner_t* compile_rule,universal_bool_expr_t* a_set);
|
||||
int read_table_info(struct _Maat_table_info_t** p_table_info,int num,const char* table_info_path,int max_thread_num,void* logger);
|
||||
void maat_start_cb(long long new_version,int update_type,void*u_para);
|
||||
int maat_update_cb(const char* table_name,const char* line,void *u_para);
|
||||
void maat_finish_cb(void* u_para);
|
||||
void *thread_rule_monitor(void *arg);
|
||||
unsigned int make_sub_type(unsigned short table_id,enum MAAT_CHARSET charset,int do_charset_merge);
|
||||
inline void ipv6_ntoh(unsigned int *v6_addr)
|
||||
{
|
||||
unsigned int i=0;
|
||||
for(i=0;i<4;i++)
|
||||
{
|
||||
v6_addr[i]=ntohl(v6_addr[i]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
void * HASH_fetch_by_id(MESA_htable_handle hash,int id);
|
||||
int HASH_add_by_id(MESA_htable_handle hash,int id,void*data);
|
||||
int HASH_delete_by_id(MESA_htable_handle hash,int id);
|
||||
void maat_read_full_config(_Maat_feather_t* _feather);
|
||||
void maat_stat_init(struct _Maat_feather_t* feather);
|
||||
void maat_stat_table(struct _Maat_table_info_t* p_table,int scan_len,struct timespec* start, struct timespec* end,int thread_num);
|
||||
void maat_stat_output(struct _Maat_feather_t* feather);
|
||||
char* _maat_strdup(const char* s);
|
||||
char* str_unescape(char* s);
|
||||
redisReply *_wrap_redisCommand(redisContext *c, const char *format, ...);
|
||||
int get_rm_key_list(redisContext *c, long long instance_version, long long desired_version, long long* new_version, struct serial_rule_t** list,int *update_type, void* logger, int cumulative_off);
|
||||
int get_maat_redis_value(redisContext *c,struct serial_rule_t* rule_list,int rule_num,void* logger,int print_process);
|
||||
void set_serial_rule(struct serial_rule_t* rule,enum MAAT_OPERATION op,int rule_id,int label_id,const char* table_name,const char* line, long long timeout);
|
||||
void empty_serial_rules(struct serial_rule_t* rule);
|
||||
int exec_serial_rule(redisContext* ctx,struct serial_rule_t* s_rule,int serial_rule_num, long long server_time, void* logger);
|
||||
long long redis_server_time(redisContext* ctx);
|
||||
|
||||
void redis_monitor_traverse(long long version,redisContext *c,
|
||||
void (*start)(long long,int ,void*),//vesion,CM_UPDATE_TYPE_*,u_para
|
||||
int (*update)(const char* ,const char*,void* ),//table name ,line ,u_para
|
||||
void (*finish)(void*),//u_para
|
||||
void* u_para,
|
||||
const unsigned char* dec_key,
|
||||
_Maat_feather_t* feather);
|
||||
|
||||
const char* module_name_str(const char*name);
|
||||
#define maat_module (module_name_str("MAAT_Frame"))
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
#opt: OPTFLAGS = -O2
|
||||
#export OPTFLAGS
|
||||
|
||||
CC = gcc
|
||||
CCC = g++
|
||||
CFLAGS = -Wall -g -fPIC
|
||||
#GCOV_FLAGS = -fprofile-arcs -ftest-coverage
|
||||
CFLAGS += $(OPTFLAGS)
|
||||
#CFLAGS += $(GCOV_FLAGS)
|
||||
LDDICTATOR = -Wl,-wrap,malloc -Wl,-wrap,calloc -Wl,-wrap,free -Wl,-wrap,realloc
|
||||
LDFLAGS += -lMESA_handle_logger -lMESA_htable -lpthread -lrt -lm -lrulescan -lpcre -lMESA_field_stat2 -lcrypto -lhiredis_vip
|
||||
#LDFLAGS += $(LDDICTATOR)
|
||||
LDFLAGS += $(GCOV_FLAGS)
|
||||
H_DIR =-I../inc_internal -I../../inc -I/opt/MESA/include/
|
||||
LIBMAAT = libmaatframe.a
|
||||
LIBMAAT_SO = libmaatframe.so
|
||||
|
||||
OBJS=config_monitor.o Maat_rule.o Maat_api.o Maat_command.o Maat_stat.o UniversalBoolMatch.o dynamic_array.o\
|
||||
cJSON.o json2iris.o map_str2int.o interval_index.o gram_index_engine.o stream_fuzzy_hash.o rbtree.o
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) -I. $(H_DIR) $<
|
||||
|
||||
.cpp.o:
|
||||
$(CCC) -c $(CFLAGS) -I. $(H_DIR) $<
|
||||
|
||||
all: $(LIBMAAT) $(LIBMAAT_SO)
|
||||
|
||||
$(LIBMAAT_SO): $(OBJS)
|
||||
$(CCC) -o $(LIBMAAT_SO) -shared $(OBJS) $(LDFLAGS)
|
||||
cp $(LIBMAAT_SO) ../../lib/
|
||||
$(LIBMAAT): $(OBJS)
|
||||
echo making dynamic lib ...
|
||||
ar cqs $(LIBMAAT) $(OBJS)
|
||||
cp $(LIBMAAT) ../../lib/
|
||||
|
||||
clean:
|
||||
rm -rf *.o *.gcov *.gcno $(LIBMAAT) *~
|
||||
|
||||
opt:
|
||||
$(MAKE) all
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2014
|
||||
* 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 (liuyanbing@iie.ac.cn)
|
||||
* Last modification: 2014-12-09
|
||||
*
|
||||
* 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 H_UNIVERSAL_BOOL_MATCH_H
|
||||
#define H_UNIVERSAL_BOOL_MATCH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define MAX_ITEMS_PER_BOOL_EXPR 8
|
||||
|
||||
typedef struct _universal_bool_expr_t
|
||||
{
|
||||
void * bool_expr_id;
|
||||
unsigned int bool_item_num;
|
||||
unsigned int bool_item_ids[MAX_ITEMS_PER_BOOL_EXPR];
|
||||
}universal_bool_expr_t;
|
||||
|
||||
/*ע<>⣺<EFBFBD><E2A3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ûύ<C3BB><E1BDBB>bool_exprs<72><73>Ԫ<EFBFBD>ص<EFBFBD>λ<EFBFBD><CEBB>*/
|
||||
void * boolexpr_initialize(universal_bool_expr_t * bool_exprs, unsigned int bool_expr_num, unsigned int max_thread_num, unsigned int * mem_size);
|
||||
|
||||
int boolexpr_match(void * instance, unsigned int thread_id, unsigned int * item_ids, unsigned int item_num, void ** result, unsigned int size);
|
||||
|
||||
void boolexpr_destroy(void * instance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
#ifndef H_ALIGMENT_INT64_H_INCLUDE
|
||||
#define H_ALIGMENT_INT64_H_INCLUDE
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define CPU_CACHE_ALIGMENT 64
|
||||
typedef long long* mcore_long_t;
|
||||
|
||||
inline long long *aligment_int64_array_alloc(int size)
|
||||
{
|
||||
long long *ret=NULL;
|
||||
ret=(long long*)calloc(CPU_CACHE_ALIGMENT,size);
|
||||
return ret;
|
||||
}
|
||||
inline long long aligment_int64_array_sum(mcore_long_t array,int size)
|
||||
{
|
||||
long long sum=0;
|
||||
int offset=0,i=0;
|
||||
for(i=0;i<size;i++)
|
||||
{
|
||||
offset=(CPU_CACHE_ALIGMENT/sizeof(long long))*i;
|
||||
sum+=array[offset];
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
inline long long aligment_int64_array_add(mcore_long_t array,int offset,long long op_val)
|
||||
{
|
||||
int idx=(CPU_CACHE_ALIGMENT/sizeof(long long))*offset;
|
||||
array[idx]+=op_val;
|
||||
return array[idx];
|
||||
}
|
||||
inline long long aligment_int64_array_cnt(mcore_long_t array,int size)
|
||||
{
|
||||
int offset=0,i=0;
|
||||
int cnt=0;
|
||||
for(i=0;i<size;i++)
|
||||
{
|
||||
offset=(CPU_CACHE_ALIGMENT/sizeof(long long))*i;
|
||||
if(array[offset]>0)
|
||||
{
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
inline void aligment_int64_array_free(mcore_long_t array)
|
||||
{
|
||||
free(array);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2009 Dave Gamble
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE EXPR_TYPE_AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef cJSON__h
|
||||
#define cJSON__h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* cJSON Types: */
|
||||
#define cJSON_False 0
|
||||
#define cJSON_True 1
|
||||
#define cJSON_NULL 2
|
||||
#define cJSON_Number 3
|
||||
#define cJSON_String 4
|
||||
#define cJSON_Array 5
|
||||
#define cJSON_Object 6
|
||||
|
||||
#define cJSON_IsReference 256
|
||||
|
||||
/* The cJSON structure: */
|
||||
typedef struct cJSON {
|
||||
struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||
struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||
|
||||
int type; /* The type of the item, as above. */
|
||||
|
||||
char *valuestring; /* The item's string, if type==cJSON_String */
|
||||
int valueint; /* The item's number, if type==cJSON_Number */
|
||||
double valuedouble; /* The item's number, if type==cJSON_Number */
|
||||
|
||||
char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||
} cJSON;
|
||||
|
||||
typedef struct cJSON_Hooks {
|
||||
void *(*malloc_fn)(size_t sz);
|
||||
void (*free_fn)(void *ptr);
|
||||
} cJSON_Hooks;
|
||||
|
||||
/* Supply malloc, realloc and free functions to cJSON */
|
||||
extern void cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||
|
||||
|
||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
|
||||
extern cJSON *cJSON_Parse(const char *value);
|
||||
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
|
||||
extern char *cJSON_Print(cJSON *item);
|
||||
/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
|
||||
extern char *cJSON_PrintUnformatted(cJSON *item);
|
||||
/* Delete a cJSON entity and all subentities. */
|
||||
extern void cJSON_Delete(cJSON *c);
|
||||
|
||||
/* Returns the number of items in an array (or object). */
|
||||
extern int cJSON_GetArraySize(cJSON *array);
|
||||
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
|
||||
extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
|
||||
/* Get item "string" from object. Case insensitive. */
|
||||
extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
|
||||
|
||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||
extern const char *cJSON_GetErrorPtr(void);
|
||||
|
||||
/* These calls create a cJSON item of the appropriate type. */
|
||||
extern cJSON *cJSON_CreateNull(void);
|
||||
extern cJSON *cJSON_CreateTrue(void);
|
||||
extern cJSON *cJSON_CreateFalse(void);
|
||||
extern cJSON *cJSON_CreateBool(int b);
|
||||
extern cJSON *cJSON_CreateNumber(double num);
|
||||
extern cJSON *cJSON_CreateString(const char *string);
|
||||
extern cJSON *cJSON_CreateArray(void);
|
||||
extern cJSON *cJSON_CreateObject(void);
|
||||
|
||||
/* These utilities create an Array of count items. */
|
||||
extern cJSON *cJSON_CreateIntArray(const int *numbers,int count);
|
||||
extern cJSON *cJSON_CreateFloatArray(const float *numbers,int count);
|
||||
extern cJSON *cJSON_CreateDoubleArray(const double *numbers,int count);
|
||||
extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
|
||||
|
||||
/* Append item to the specified array/object. */
|
||||
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
|
||||
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||
extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
|
||||
|
||||
/* Remove/Detatch items from Arrays/Objects. */
|
||||
extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
|
||||
extern void cJSON_DeleteItemFromArray(cJSON *array,int which);
|
||||
extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
|
||||
extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string);
|
||||
|
||||
/* Update array items. */
|
||||
extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
|
||||
extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
||||
|
||||
/* Duplicate a cJSON item */
|
||||
extern cJSON *cJSON_Duplicate(cJSON *item,int recurse);
|
||||
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||
need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||
The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||
|
||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||
extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated);
|
||||
|
||||
extern void cJSON_Minify(char *json);
|
||||
|
||||
/* Macros for creating things quickly. */
|
||||
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
|
||||
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
|
||||
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
|
||||
#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
|
||||
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
|
||||
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
|
||||
|
||||
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||
#define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef __CONFIG_MONITOR_H_INCLUDE_
|
||||
#define __CONFIG_MONITOR_H_INCLUDE_
|
||||
|
||||
#define CM_UPDATE_TYPE_FULL 1
|
||||
#define CM_UPDATE_TYPE_INC 2
|
||||
|
||||
void config_monitor_traverse(long long version,const char*idx_dir,
|
||||
void (*start)(long long, int, void*),//vesion,CM_UPDATE_TYPE_*,u_para
|
||||
int (*update)(const char*, const char*, void*),//table name ,line ,u_para
|
||||
void (*finish)(void*),//u_para
|
||||
void* u_para,
|
||||
const unsigned char* dec_key,
|
||||
void* logger);
|
||||
#endif
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#ifndef _DYNAMIC_ARRAY_H_INCLUDE_
|
||||
#define _DYNAMIC_ARRAY_H_INCLUDE_
|
||||
struct dynamic_array_t
|
||||
{
|
||||
void ** array;
|
||||
int size;
|
||||
int enlarge_step;
|
||||
};
|
||||
struct dynamic_array_t* dynamic_array_create(int size,int step);
|
||||
void dynamic_array_destroy(struct dynamic_array_t* d_array,void (* free_data)(void *));
|
||||
void* dynamic_array_read(struct dynamic_array_t* d_array,int i);
|
||||
void dynamic_array_write(struct dynamic_array_t* d_array,int i,void* data);
|
||||
#endif //_DYNAMIC_ARRAY_H_INCLUDE_
|
||||
@@ -1,313 +0,0 @@
|
||||
/************************************************************************
|
||||
* InterVal Index interface
|
||||
* NOTE that:
|
||||
* (1) There are no overlapping intervals in InterVal Index;
|
||||
* (2) Each interval is closed;
|
||||
* (3) The interval supports rollback.
|
||||
*
|
||||
* author: zhengchao@iie.ac.cn tangqi@iie.ac.cn
|
||||
* last modify time: 2015-12-04
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef _INTERVAL_INDEX_H_
|
||||
#define _INTERVAL_INDEX_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
|
||||
#define SIZE_8
|
||||
|
||||
#ifdef SIZE_8
|
||||
typedef unsigned long long OFFSET_TYPE;
|
||||
typedef signed long long S_OFFSET_TYPE;
|
||||
#else
|
||||
typedef unsigned int OFFSET_TYPE;
|
||||
typedef signed int S_OFFSET_TYPE;
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct{
|
||||
}IVI_t;
|
||||
|
||||
|
||||
/**
|
||||
* structure of segment
|
||||
**/
|
||||
typedef struct __IVI_seg_t{
|
||||
OFFSET_TYPE left;
|
||||
OFFSET_TYPE right;
|
||||
void * data;
|
||||
}IVI_seg_t;
|
||||
|
||||
|
||||
typedef void IVI_callback_t(IVI_seg_t * seg, void * usr_para);
|
||||
|
||||
/**
|
||||
* Deal with rollback
|
||||
* Refering to the approach of Linux's kernel to solute tcp seq rollback
|
||||
**/
|
||||
static inline int before(OFFSET_TYPE off1, OFFSET_TYPE off2)
|
||||
{
|
||||
return (S_OFFSET_TYPE)(off1 - off2) < 0;
|
||||
}
|
||||
#define after(off2, off1) before(off1, off2)
|
||||
|
||||
static inline int continuous(OFFSET_TYPE prev, OFFSET_TYPE next)
|
||||
{
|
||||
return ((next - prev) == 1);
|
||||
}
|
||||
|
||||
|
||||
IVI_seg_t * IVI_first_seg(IVI_t * handler);
|
||||
IVI_seg_t * IVI_last_seg(IVI_t * handler);
|
||||
IVI_seg_t * IVI_prev_seg(IVI_seg_t * seg);
|
||||
IVI_seg_t * IVI_next_seg(IVI_seg_t * seg);
|
||||
IVI_seg_t * IVI_prev_continuous_seg(IVI_seg_t * seg);
|
||||
IVI_seg_t * IVI_next_continuous_seg(IVI_seg_t * seg);
|
||||
|
||||
|
||||
/**
|
||||
* Relation of two segments
|
||||
**/
|
||||
typedef enum __Relation_t{
|
||||
LEFT_NO_OVERLAP = 1, // |___A___|
|
||||
// |___B___|
|
||||
|
||||
LEFT_OVERLAP, // |___A___|
|
||||
// |___B___|
|
||||
|
||||
CONTAINED, // |___A___|
|
||||
// |_____B_____|
|
||||
|
||||
CONTAIN, // |_____A_____|
|
||||
// |___B___|
|
||||
|
||||
RIGHT_OVERLAP, // |___A___|
|
||||
// |___B___|
|
||||
|
||||
RIGHT_NO_OVERLAP, // |___A___|
|
||||
// |___B___|
|
||||
|
||||
ERROR
|
||||
}Relation_t;
|
||||
|
||||
|
||||
/**
|
||||
* Name:
|
||||
* IVI_relative_position
|
||||
* Description:
|
||||
* Get relative position of given two interval segments
|
||||
* Params:
|
||||
* seg1: Subject of relation
|
||||
* seg2: Object of relation
|
||||
* Relation:
|
||||
* On success, return the relation of two segments with enum;
|
||||
* Else, return ERROR in enum;
|
||||
**/
|
||||
Relation_t IVI_relative_position(IVI_seg_t * seg1, IVI_seg_t * seg2);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Name:
|
||||
* IVI_create
|
||||
* Description:
|
||||
* Create an InterVal Index
|
||||
* Params:
|
||||
* void
|
||||
* Return:
|
||||
* Return a handler of this InterVal Index
|
||||
**/
|
||||
IVI_t * IVI_create(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Name:
|
||||
* IVI_destroy
|
||||
* Description:
|
||||
* Destroy a given InterVal Index's handler
|
||||
* Params:
|
||||
* handler: The InterVal Index you want to destroy
|
||||
* cb: Callback function for user to free data in segement
|
||||
* usr_para: User parameter
|
||||
* Return:
|
||||
* void
|
||||
**/
|
||||
void IVI_destroy(IVI_t * handler, IVI_callback_t cb, void * usr_para);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Name:
|
||||
* IVI_seg_malloc
|
||||
* Description:
|
||||
* Malloc a segment with given parameters
|
||||
* Params:
|
||||
* left: Left point of segment
|
||||
* right: Right point of segment
|
||||
* data: User data
|
||||
* Return:
|
||||
* Return a pointer of segment structure.
|
||||
**/
|
||||
IVI_seg_t * IVI_seg_malloc(OFFSET_TYPE left, OFFSET_TYPE right, void * data);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Name:
|
||||
* IVI_seg_free
|
||||
* Description:
|
||||
* Free the memory of given segment
|
||||
* Params:
|
||||
* seg: The segment that you want to free
|
||||
* cb: Callback function for user to free *data in seg
|
||||
* usr_para: User parameter for cb
|
||||
* Return:
|
||||
* void
|
||||
**/
|
||||
void IVI_seg_free(IVI_seg_t * seg, IVI_callback_t cb, void * usr_para);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Name:
|
||||
* IVI_insert
|
||||
* Description:
|
||||
* Insert a segment to an InterVal Index handler,and the segment
|
||||
* MUST not be overlapped with others in handler.
|
||||
* Params:
|
||||
* handler: The handler of InterVal Index created by IVI_create
|
||||
* seg: A segment that user wants to add. It MUST be created
|
||||
* by IVI_seg_malloc.
|
||||
* Return:
|
||||
* On success, 0 is returned;
|
||||
* Else when overlapp occures or error occures, -1 is returned.
|
||||
**/
|
||||
int IVI_insert(IVI_t * handler, IVI_seg_t * seg);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Name:
|
||||
* IVI_remove
|
||||
* Description:
|
||||
* Remove a given segment from given InterVal Index handler.
|
||||
* Params:
|
||||
* handler: The handler of InterVal Index created by IVI_create
|
||||
* seg: A segment that user wants to delete. It MUST be created
|
||||
* by IVI_seg_malloc.
|
||||
* Return:
|
||||
* On success, 0 is returned;
|
||||
* Else when overlapp occures, -1 is returned.
|
||||
**/
|
||||
int IVI_remove(IVI_t * handler, IVI_seg_t * seg);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Name:
|
||||
* IVI_query
|
||||
* Description:
|
||||
* Query from given InterVal Index and get the number of segments
|
||||
* which are overlapped with given interval, and store those segments
|
||||
* in the last parameter.
|
||||
* Params:
|
||||
* handler: The handler of interval index created by IVI_create
|
||||
* left: Left point of given interval
|
||||
* right: Right point of given interval
|
||||
* segs: An address of a segment pointer array to store those segments which
|
||||
* are overlapped with given interval. NOTE that user should not malloc
|
||||
* the array, and segs need to be freed by user. The element of *segs
|
||||
* MUST not be freed by user.
|
||||
* Return:
|
||||
* Return the number of segments which are overlapped with given interval
|
||||
**/
|
||||
int IVI_query(IVI_t * handler, OFFSET_TYPE left, OFFSET_TYPE right, IVI_seg_t *** segs);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Name:
|
||||
* IVI_query_continuous
|
||||
* Description:
|
||||
* Query from interval index handler and get the number of continous segments
|
||||
* which are overlapped with given interval.
|
||||
* Params:
|
||||
* handler: The handler of InterVal Index created by IVI_create.
|
||||
* left: Left point of given interval
|
||||
* right: Right point of given interval
|
||||
* segs: An address of a segment pointer array to store those segments which
|
||||
* are overlapped with given interval. NOTE that user should not malloc
|
||||
* the array, and segs need to be freed by user. The element of *segs
|
||||
* MUST not be freed by user.
|
||||
* Return:
|
||||
* Return the number of continous segments which are overlapped with given interval
|
||||
**/
|
||||
int IVI_query_continuous(IVI_t * handler, OFFSET_TYPE left, OFFSET_TYPE right, IVI_seg_t *** segs);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Name:
|
||||
* IVI_seg_cnt
|
||||
* Description:
|
||||
* Get the count of segments in given interval index handler
|
||||
* Params:
|
||||
* handler: The handler of InterVal Index created by IVI_create.
|
||||
* Return:
|
||||
* Return the count of segments in given interval index handler
|
||||
**/
|
||||
int IVI_seg_cnt(IVI_t * handler);
|
||||
|
||||
|
||||
/**
|
||||
* Name:
|
||||
* IVI_seg_len
|
||||
* Description:
|
||||
* Get the length of whole segments in given interval index handler
|
||||
* Params:
|
||||
* handler: The handler of InterVal Index created by IVI_create.
|
||||
* Return:
|
||||
* Return the length of whole segments in given interval index handler
|
||||
**/
|
||||
OFFSET_TYPE IVI_seg_length(IVI_t * handler);
|
||||
|
||||
|
||||
/**
|
||||
* Name:
|
||||
* IVI_mem_occupy
|
||||
* Description:
|
||||
* Get the memory occupy of given interval index handler
|
||||
* Params:
|
||||
* handler: The handler of InterVal Index created by IVI_create.
|
||||
* Return:
|
||||
* Return the memory occupy of given interval index handler
|
||||
**/
|
||||
unsigned long long IVI_mem_occupy(IVI_t * handler);
|
||||
|
||||
|
||||
/**
|
||||
* Name:
|
||||
* IVI_traverse
|
||||
* Description:
|
||||
* Traverse given InterVal Index and execute given callback function
|
||||
* one time for each seg in InterVal Index.
|
||||
* Params:
|
||||
* handler: The handler of InterVal Index created by IVI_create.
|
||||
* IVI_callback_t: Callback function for user to define.
|
||||
* usr_para: Parameter user want to pass to callback function.
|
||||
* Return:
|
||||
* void
|
||||
**/
|
||||
void IVI_traverse(IVI_t * handler, IVI_callback_t cb, void * usr_para);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _INTERVAL_INDEX_H_ */
|
||||
@@ -1,6 +0,0 @@
|
||||
#ifndef H_MAAT_JSON2IRIS_H_INCLUDE
|
||||
#define H_MAAT_JSON2IRIS_H_INCLUDE
|
||||
int json2iris(const char* json_file,const char*compile_tn,const char* group_tn,redisContext *redis_write_ctx,char* iris_dir_buf,int buf_len,void* logger);
|
||||
int set_file_rulenum(const char* path,int rulenum,void* logger);
|
||||
#endif
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef __MAP_STR2INT_H_INCLUDE_
|
||||
#define __MAP_STR2INT_H_INCLUDE_
|
||||
#include <MESA/MESA_htable.h>
|
||||
MESA_htable_handle map_create(void);
|
||||
void map_destroy(MESA_htable_handle p);
|
||||
int map_register(MESA_htable_handle handle,const char* string,int value);
|
||||
int map_str2int(MESA_htable_handle handle,const char* string,int* value);
|
||||
int map_unNullstr2int(MESA_htable_handle handle,const char* string,int size,int* value);
|
||||
MESA_htable_handle map_duplicate(MESA_htable_handle origin_map);
|
||||
#endif
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
Red Black Trees
|
||||
(C) 1999 Andrea Arcangeli <andrea@suse.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
linux/include/linux/rbtree.h
|
||||
|
||||
To use rbtrees you'll have to implement your own insert and search cores.
|
||||
This will avoid us to use callbacks and to drop drammatically performances.
|
||||
I know it's not the cleaner way, but in C (not in C++) to get
|
||||
performances and genericity...
|
||||
|
||||
See Documentation/rbtree.txt for documentation and samples.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_RBTREE_H
|
||||
#define _LINUX_RBTREE_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
struct rb_node {
|
||||
unsigned long __rb_parent_color;
|
||||
struct rb_node *rb_right;
|
||||
struct rb_node *rb_left;
|
||||
} __attribute__((aligned(sizeof(long))));
|
||||
/* The alignment might seem pointless, but allegedly CRIS needs it */
|
||||
|
||||
struct rb_root {
|
||||
struct rb_node *rb_node;
|
||||
};
|
||||
|
||||
|
||||
#define rb_parent(r) ((struct rb_node *)((r)->__rb_parent_color & ~3))
|
||||
|
||||
#define RB_ROOT (struct rb_root) { NULL, }
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
||||
#endif
|
||||
|
||||
#ifndef container_of
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type, member) );})
|
||||
#endif
|
||||
|
||||
#define rb_entry(ptr, type, member) container_of(ptr, type, member)
|
||||
|
||||
#define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL)
|
||||
|
||||
/* 'empty' nodes are nodes that are known not to be inserted in an rbtree */
|
||||
#define RB_EMPTY_NODE(node) \
|
||||
((node)->__rb_parent_color == (unsigned long)(node))
|
||||
#define RB_CLEAR_NODE(node) \
|
||||
((node)->__rb_parent_color = (unsigned long)(node))
|
||||
|
||||
|
||||
extern void rb_insert_color(struct rb_node *, struct rb_root *);
|
||||
extern void rb_erase(struct rb_node *, struct rb_root *);
|
||||
|
||||
|
||||
/* Find logical next and previous nodes in a tree */
|
||||
extern struct rb_node *rb_next(const struct rb_node *);
|
||||
extern struct rb_node *rb_prev(const struct rb_node *);
|
||||
extern struct rb_node *rb_first(const struct rb_root *);
|
||||
extern struct rb_node *rb_last(const struct rb_root *);
|
||||
|
||||
/* Postorder iteration - always visit the parent after its children */
|
||||
extern struct rb_node *rb_first_postorder(const struct rb_root *);
|
||||
extern struct rb_node *rb_next_postorder(const struct rb_node *);
|
||||
|
||||
/* Fast replacement of a single node without remove/rebalance/add/rebalance */
|
||||
extern void rb_replace_node(struct rb_node *victim, struct rb_node *new,
|
||||
struct rb_root *root);
|
||||
|
||||
static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
|
||||
struct rb_node ** rb_link)
|
||||
{
|
||||
node->__rb_parent_color = (unsigned long)parent;
|
||||
node->rb_left = node->rb_right = NULL;
|
||||
|
||||
*rb_link = node;
|
||||
}
|
||||
|
||||
#define rb_entry_safe(ptr, type, member) \
|
||||
({ typeof(ptr) ____ptr = (ptr); \
|
||||
____ptr ? rb_entry(____ptr, type, member) : NULL; \
|
||||
})
|
||||
|
||||
/**
|
||||
* rbtree_postorder_for_each_entry_safe - iterate over rb_root in post order of
|
||||
* given type safe against removal of rb_node entry
|
||||
*
|
||||
* @pos: the 'type *' to use as a loop cursor.
|
||||
* @n: another 'type *' to use as temporary storage
|
||||
* @root: 'rb_root *' of the rbtree.
|
||||
* @field: the name of the rb_node field within 'type'.
|
||||
*/
|
||||
#define rbtree_postorder_for_each_entry_safe(pos, n, root, field) \
|
||||
for (pos = rb_entry_safe(rb_first_postorder(root), typeof(*pos), field); \
|
||||
pos && ({ n = rb_entry_safe(rb_next_postorder(&pos->field), \
|
||||
typeof(*pos), field); 1; }); \
|
||||
pos = n)
|
||||
|
||||
#endif /* _LINUX_RBTREE_H */
|
||||
@@ -1,241 +0,0 @@
|
||||
/*
|
||||
Red Black Trees
|
||||
(C) 1999 Andrea Arcangeli <andrea@suse.de>
|
||||
(C) 2002 David Woodhouse <dwmw2@infradead.org>
|
||||
(C) 2012 Michel Lespinasse <walken@google.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
linux/include/linux/rbtree_augmented.h
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_RBTREE_AUGMENTED_H
|
||||
#define _LINUX_RBTREE_AUGMENTED_H
|
||||
|
||||
#include "rbtree.h"
|
||||
|
||||
/*
|
||||
* Please note - only struct rb_augment_callbacks and the prototypes for
|
||||
* rb_insert_augmented() and rb_erase_augmented() are intended to be public.
|
||||
* The rest are implementation details you are not expected to depend on.
|
||||
*
|
||||
* See Documentation/rbtree.txt for documentation and samples.
|
||||
*/
|
||||
|
||||
struct rb_augment_callbacks {
|
||||
void (*propagate)(struct rb_node *node, struct rb_node *stop);
|
||||
void (*copy)(struct rb_node *old, struct rb_node *new);
|
||||
void (*rotate)(struct rb_node *old, struct rb_node *new);
|
||||
};
|
||||
|
||||
extern void __rb_insert_augmented(struct rb_node *node, struct rb_root *root,
|
||||
void (*augment_rotate)(struct rb_node *old, struct rb_node *new));
|
||||
/*
|
||||
* Fixup the rbtree and update the augmented information when rebalancing.
|
||||
*
|
||||
* On insertion, the user must update the augmented information on the path
|
||||
* leading to the inserted node, then call rb_link_node() as usual and
|
||||
* rb_augment_inserted() instead of the usual rb_insert_color() call.
|
||||
* If rb_augment_inserted() rebalances the rbtree, it will callback into
|
||||
* a user provided function to update the augmented information on the
|
||||
* affected subtrees.
|
||||
*/
|
||||
static inline void
|
||||
rb_insert_augmented(struct rb_node *node, struct rb_root *root,
|
||||
const struct rb_augment_callbacks *augment)
|
||||
{
|
||||
__rb_insert_augmented(node, root, augment->rotate);
|
||||
}
|
||||
|
||||
#define RB_DECLARE_CALLBACKS(rbstatic, rbname, rbstruct, rbfield, \
|
||||
rbtype, rbaugmented, rbcompute) \
|
||||
static inline void \
|
||||
rbname ## _propagate(struct rb_node *rb, struct rb_node *stop) \
|
||||
{ \
|
||||
while (rb != stop) { \
|
||||
rbstruct *node = rb_entry(rb, rbstruct, rbfield); \
|
||||
rbtype augmented = rbcompute(node); \
|
||||
if (node->rbaugmented == augmented) \
|
||||
break; \
|
||||
node->rbaugmented = augmented; \
|
||||
rb = rb_parent(&node->rbfield); \
|
||||
} \
|
||||
} \
|
||||
static inline void \
|
||||
rbname ## _copy(struct rb_node *rb_old, struct rb_node *rb_new) \
|
||||
{ \
|
||||
rbstruct *old = rb_entry(rb_old, rbstruct, rbfield); \
|
||||
rbstruct *new = rb_entry(rb_new, rbstruct, rbfield); \
|
||||
new->rbaugmented = old->rbaugmented; \
|
||||
} \
|
||||
static void \
|
||||
rbname ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new) \
|
||||
{ \
|
||||
rbstruct *old = rb_entry(rb_old, rbstruct, rbfield); \
|
||||
rbstruct *new = rb_entry(rb_new, rbstruct, rbfield); \
|
||||
new->rbaugmented = old->rbaugmented; \
|
||||
old->rbaugmented = rbcompute(old); \
|
||||
} \
|
||||
rbstatic const struct rb_augment_callbacks rbname = { \
|
||||
rbname ## _propagate, rbname ## _copy, rbname ## _rotate \
|
||||
};
|
||||
|
||||
|
||||
#define RB_RED 0
|
||||
#define RB_BLACK 1
|
||||
|
||||
#define __rb_parent(pc) ((struct rb_node *)(pc & ~3))
|
||||
|
||||
#define __rb_color(pc) ((pc) & 1)
|
||||
#define __rb_is_black(pc) __rb_color(pc)
|
||||
#define __rb_is_red(pc) (!__rb_color(pc))
|
||||
#define rb_color(rb) __rb_color((rb)->__rb_parent_color)
|
||||
#define rb_is_red(rb) __rb_is_red((rb)->__rb_parent_color)
|
||||
#define rb_is_black(rb) __rb_is_black((rb)->__rb_parent_color)
|
||||
|
||||
static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p)
|
||||
{
|
||||
rb->__rb_parent_color = rb_color(rb) | (unsigned long)p;
|
||||
}
|
||||
|
||||
static inline void rb_set_parent_color(struct rb_node *rb,
|
||||
struct rb_node *p, int color)
|
||||
{
|
||||
rb->__rb_parent_color = (unsigned long)p | color;
|
||||
}
|
||||
|
||||
static inline void
|
||||
__rb_change_child(struct rb_node *old, struct rb_node *new,
|
||||
struct rb_node *parent, struct rb_root *root)
|
||||
{
|
||||
if (parent) {
|
||||
if (parent->rb_left == old)
|
||||
parent->rb_left = new;
|
||||
else
|
||||
parent->rb_right = new;
|
||||
} else
|
||||
root->rb_node = new;
|
||||
}
|
||||
|
||||
extern void __rb_erase_color(struct rb_node *parent, struct rb_root *root,
|
||||
void (*augment_rotate)(struct rb_node *old, struct rb_node *new));
|
||||
|
||||
static __always_inline struct rb_node *
|
||||
__rb_erase_augmented(struct rb_node *node, struct rb_root *root,
|
||||
const struct rb_augment_callbacks *augment)
|
||||
{
|
||||
struct rb_node *child = node->rb_right, *tmp = node->rb_left;
|
||||
struct rb_node *parent, *rebalance;
|
||||
unsigned long pc;
|
||||
|
||||
if (!tmp) {
|
||||
/*
|
||||
* Case 1: node to erase has no more than 1 child (easy!)
|
||||
*
|
||||
* Note that if there is one child it must be red due to 5)
|
||||
* and node must be black due to 4). We adjust colors locally
|
||||
* so as to bypass __rb_erase_color() later on.
|
||||
*/
|
||||
pc = node->__rb_parent_color;
|
||||
parent = __rb_parent(pc);
|
||||
__rb_change_child(node, child, parent, root);
|
||||
if (child) {
|
||||
child->__rb_parent_color = pc;
|
||||
rebalance = NULL;
|
||||
} else
|
||||
rebalance = __rb_is_black(pc) ? parent : NULL;
|
||||
tmp = parent;
|
||||
} else if (!child) {
|
||||
/* Still case 1, but this time the child is node->rb_left */
|
||||
tmp->__rb_parent_color = pc = node->__rb_parent_color;
|
||||
parent = __rb_parent(pc);
|
||||
__rb_change_child(node, tmp, parent, root);
|
||||
rebalance = NULL;
|
||||
tmp = parent;
|
||||
} else {
|
||||
struct rb_node *successor = child, *child2;
|
||||
tmp = child->rb_left;
|
||||
if (!tmp) {
|
||||
/*
|
||||
* Case 2: node's successor is its right child
|
||||
*
|
||||
* (n) (s)
|
||||
* / \ / \
|
||||
* (x) (s) -> (x) (c)
|
||||
* \
|
||||
* (c)
|
||||
*/
|
||||
parent = successor;
|
||||
child2 = successor->rb_right;
|
||||
augment->copy(node, successor);
|
||||
} else {
|
||||
/*
|
||||
* Case 3: node's successor is leftmost under
|
||||
* node's right child subtree
|
||||
*
|
||||
* (n) (s)
|
||||
* / \ / \
|
||||
* (x) (y) -> (x) (y)
|
||||
* / /
|
||||
* (p) (p)
|
||||
* / /
|
||||
* (s) (c)
|
||||
* \
|
||||
* (c)
|
||||
*/
|
||||
do {
|
||||
parent = successor;
|
||||
successor = tmp;
|
||||
tmp = tmp->rb_left;
|
||||
} while (tmp);
|
||||
parent->rb_left = child2 = successor->rb_right;
|
||||
successor->rb_right = child;
|
||||
rb_set_parent(child, successor);
|
||||
augment->copy(node, successor);
|
||||
augment->propagate(parent, successor);
|
||||
}
|
||||
|
||||
successor->rb_left = tmp = node->rb_left;
|
||||
rb_set_parent(tmp, successor);
|
||||
|
||||
pc = node->__rb_parent_color;
|
||||
tmp = __rb_parent(pc);
|
||||
__rb_change_child(node, successor, tmp, root);
|
||||
if (child2) {
|
||||
successor->__rb_parent_color = pc;
|
||||
rb_set_parent_color(child2, parent, RB_BLACK);
|
||||
rebalance = NULL;
|
||||
} else {
|
||||
unsigned long pc2 = successor->__rb_parent_color;
|
||||
successor->__rb_parent_color = pc;
|
||||
rebalance = __rb_is_black(pc2) ? parent : NULL;
|
||||
}
|
||||
tmp = successor;
|
||||
}
|
||||
|
||||
augment->propagate(tmp, NULL);
|
||||
return rebalance;
|
||||
}
|
||||
|
||||
static __always_inline void
|
||||
rb_erase_augmented(struct rb_node *node, struct rb_root *root,
|
||||
const struct rb_augment_callbacks *augment)
|
||||
{
|
||||
struct rb_node *rebalance = __rb_erase_augmented(node, root, augment);
|
||||
if (rebalance)
|
||||
__rb_erase_color(rebalance, root, augment->rotate);
|
||||
}
|
||||
|
||||
#endif /* _LINUX_RBTREE_AUGMENTED_H */
|
||||
@@ -1,108 +0,0 @@
|
||||
#include "zt_hash.h"
|
||||
#include "interval_index.h"
|
||||
#include "stream_fuzzy_hash.h"
|
||||
|
||||
#ifndef __SFH_INTERNAL_H_INCLUDE_
|
||||
#define __SFH_INTERNAL_H_INCLUDE_
|
||||
|
||||
#define ROLLING_WINDOW 7
|
||||
#define BLOCKSIZE_MIN 3
|
||||
#define HASH_PRIME 0x01000193
|
||||
#define HASH_INIT 0x28021967
|
||||
#define CALCULATE 0
|
||||
#define MODIFY 1
|
||||
#define EXPECT_SIGNATURE_LEN 64
|
||||
#define MEMORY_OCCUPY 3
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef container_of
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
#endif
|
||||
|
||||
#define DEBUG (0)
|
||||
|
||||
//int count = 0;
|
||||
struct roll_state_t
|
||||
{
|
||||
unsigned char window[ROLLING_WINDOW];
|
||||
unsigned char pad[1];
|
||||
unsigned int h1, h2, h3;
|
||||
unsigned int n;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char mbuf[ROLLING_WINDOW-1];
|
||||
char pad[8-ROLLING_WINDOW+1];
|
||||
int slice_num;
|
||||
unsigned int msize;
|
||||
|
||||
struct zt_state_t p_state; //partial strong hash value
|
||||
struct zt_state_t s_state; //strong hash state
|
||||
struct roll_state_t r_state;
|
||||
|
||||
unsigned long long left_offset;
|
||||
unsigned long long right_offset;
|
||||
|
||||
unsigned int * r_array; //array to store rolling hash value
|
||||
unsigned int r_cnt;
|
||||
unsigned int r_size;
|
||||
struct zt_state_t * s_array; //array to store strong(Tillichi-Zemor) hash value
|
||||
unsigned int s_cnt; //always point to the next available position
|
||||
unsigned int s_size;
|
||||
}sfh_seg_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned long long orilen;
|
||||
IVI_t * ivi; //ÿһ<C3BF><D2BB>handle<6C><65><EFBFBD>汣<EFBFBD><E6B1A3>һ<EFBFBD><D2BB>IVIָ<49>룬һ<EBA3AC><D2BB>IVI<56><49><EFBFBD>汣<EFBFBD><E6B1A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ƭ
|
||||
unsigned long long effective_length;
|
||||
unsigned long long blocksize;
|
||||
unsigned long long fuzzy_node_memory;
|
||||
unsigned long long IVI_memory;
|
||||
unsigned long long length_increase;
|
||||
int s_state_cnt;
|
||||
unsigned int sim_tuned_rs_cnt;//rolling state count after a tune simulation
|
||||
int do_tune;
|
||||
}fuzzy_handle_inner_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char * hash_b1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>char<61><72><EFBFBD><EFBFBD>
|
||||
char * hash_b2;
|
||||
unsigned int size_b1,size_b2;
|
||||
unsigned int offset_b1,offset_b2; //<2F><><EFBFBD>鳤<EFBFBD><E9B3A4>
|
||||
unsigned long long first_ZTH_offset;
|
||||
unsigned long long last_ZTH_offset;
|
||||
char last_char_b1, last_char_b2;
|
||||
unsigned long long b1,b2;
|
||||
}sfh_output_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned long long first_ZTH_offset;
|
||||
unsigned long long last_ZTH_offset;
|
||||
unsigned long long hash_length;
|
||||
}final_length;
|
||||
|
||||
int destroy_sfh_seg(sfh_seg_t*p);
|
||||
unsigned long long get_blocksize(unsigned long long orilen);
|
||||
int sfh_merge_seg(fuzzy_handle_inner_t * _handle,sfh_seg_t * seg, sfh_seg_t * next_seg, unsigned long long blocksize);
|
||||
int sfh_update_seg(fuzzy_handle_inner_t * _handle,sfh_seg_t * p, const char * data, unsigned long data_size, unsigned long long blocksize);
|
||||
unsigned int segment_overlap(fuzzy_handle_inner_t * handle, unsigned int size, unsigned long long offset, const char * data);
|
||||
void sfh_tune_callback(IVI_seg_t * seg, void * user_para);
|
||||
void sfh_output_callback(IVI_seg_t * seg, void * user_para);
|
||||
void fuzzy_hash_length(IVI_seg_t * seg, void * user_para);
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <sfh_internal.h>
|
||||
#include "sfh_internal.h"
|
||||
#include "stream_fuzzy_hash.h"
|
||||
#include "interval_index.h"
|
||||
//#define DEBUG_PRINT
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user