2023-09-27 11:45:26 +08:00
|
|
|
#ifndef __OSFP_SCORE_DB_H__
|
|
|
|
|
#define __OSFP_SCORE_DB_H__
|
|
|
|
|
|
2023-10-13 14:08:55 +08:00
|
|
|
#include "osfp.h"
|
2023-09-27 11:45:26 +08:00
|
|
|
#include "osfp_fingerprint.h"
|
2023-10-10 17:14:34 +08:00
|
|
|
#include "osfp_common.h"
|
2023-09-27 11:45:26 +08:00
|
|
|
|
2023-09-27 15:43:32 +08:00
|
|
|
struct osfp_os_class_score {
|
|
|
|
|
unsigned int scores[OSFP_OS_CLASS_MAX];
|
|
|
|
|
};
|
|
|
|
|
|
2023-09-27 11:45:26 +08:00
|
|
|
struct osfp_field_score_db {
|
|
|
|
|
unsigned int enabled;
|
|
|
|
|
unsigned int type;
|
|
|
|
|
unsigned int entry_count;
|
|
|
|
|
|
|
|
|
|
void *data;
|
|
|
|
|
|
|
|
|
|
void *(*create)(void);
|
|
|
|
|
void (*destroy)(void *);
|
|
|
|
|
int (*add)(void *data, struct osfp_os_class_score *, void *, unsigned int);
|
|
|
|
|
struct osfp_os_class_score *(*match)(void *, void *, unsigned int);
|
|
|
|
|
};
|
|
|
|
|
|
2023-10-23 09:54:02 +08:00
|
|
|
struct osfp_prefilter_hash_element {
|
|
|
|
|
struct osfp_fingerprint *fp;
|
|
|
|
|
char *fp_json;
|
|
|
|
|
unsigned int os_class;
|
|
|
|
|
UT_hash_handle hh;
|
|
|
|
|
};
|
|
|
|
|
|
2023-09-27 11:45:26 +08:00
|
|
|
struct osfp_score_db {
|
|
|
|
|
unsigned int entry_count;
|
2023-10-23 09:54:02 +08:00
|
|
|
|
|
|
|
|
struct osfp_prefilter_hash_element *prefilter_head;
|
|
|
|
|
|
2023-09-27 11:45:26 +08:00
|
|
|
unsigned int perfect_score;
|
|
|
|
|
unsigned int os_class_entry_count[OSFP_OS_CLASS_MAX];
|
|
|
|
|
struct osfp_field_score_db field_score_dbs[OSFP_FIELD_MAX];
|
|
|
|
|
};
|
|
|
|
|
|
2023-10-09 15:23:31 +08:00
|
|
|
char *osfp_score_db_read_file(char *fp_file);
|
2023-09-27 11:45:26 +08:00
|
|
|
void osfp_score_db_debug_print(struct osfp_score_db *score_db);
|
|
|
|
|
|
|
|
|
|
int osfp_score_db_load(struct osfp_score_db *score_db, char *fp_file);
|
2023-10-23 09:54:02 +08:00
|
|
|
int osfp_score_db_prefilter(struct osfp_score_db *score_db, struct osfp_fingerprint *fp, struct osfp_os_class_score *result_score);
|
2023-09-27 11:45:26 +08:00
|
|
|
int osfp_score_db_score(struct osfp_score_db *score_db, unsigned int flags, struct osfp_fingerprint *fp, struct osfp_os_class_score *result_score);
|
|
|
|
|
|
|
|
|
|
struct osfp_score_db *osfp_score_db_create(void);
|
|
|
|
|
void osfp_score_db_destroy(struct osfp_score_db *score_db);
|
|
|
|
|
|
2023-10-09 15:23:31 +08:00
|
|
|
int test_osfp_score_db(void);
|
|
|
|
|
|
2023-09-27 11:45:26 +08:00
|
|
|
#endif
|