summaryrefslogtreecommitdiff
path: root/src/osfp_score_db.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/osfp_score_db.c')
-rw-r--r--src/osfp_score_db.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/osfp_score_db.c b/src/osfp_score_db.c
index 00a15a3..3e3f97c 100644
--- a/src/osfp_score_db.c
+++ b/src/osfp_score_db.c
@@ -1,3 +1,8 @@
+#include <stdio.h>
+#include <sys/param.h>
+
+#include "cJSON.h"
+
#include "osfp_common.h"
#include "osfp.h"
@@ -301,7 +306,7 @@ int osfp_score_db_score(struct osfp_score_db *score_db, unsigned int flags, stru
continue;
}
- coefficient = OSFP_PERCENTILE / PERFECT_SCORE_EXPECTED_RATE * score_db->field_weight[i] / total_weight;
+ coefficient = fdb->coefficient;
for (j = 0; j < OSFP_OS_CLASS_MAX; j++) {
os_entry_count = score_db->os_entry_count[j];
@@ -510,10 +515,10 @@ struct osfp_score_db *osfp_score_db_create(void)
continue;
}
- score_db->field_weight[i] = osfp_fingerprint_get_field_importance(i);
+ db->weight = osfp_fingerprint_get_field_importance(i);
// tcp options ordered and tcp options overlap
if (i != OSFP_FIELD_TCP_OPTIONS_ORDERED) {
- score_db->total_weight += score_db->field_weight[i];
+ score_db->total_weight += db->weight;
}
db->type = osfp_fingerprint_get_field_type(i);
@@ -542,6 +547,11 @@ struct osfp_score_db *osfp_score_db_create(void)
}
}
+ for (i = 0; i < OSFP_FIELD_MAX; i++) {
+ db = &score_db->field_score_dbs[i];
+ db->coefficient = (OSFP_PERCENTILE / PERFECT_SCORE_EXPECTED_RATE) * ((float)db->weight / (float)score_db->total_weight);
+ }
+
return score_db;
exit:
if (score_db) {