profile: init profile stats
This commit is contained in:
24
src/osfp.c
24
src/osfp.c
@@ -94,6 +94,10 @@ char *osfp_result_score_detail_export(struct osfp_result *result)
|
||||
cJSON *array;
|
||||
cJSON *os_score;
|
||||
|
||||
osfp_profile_cycle(c1);
|
||||
osfp_profile_cycle(c2);
|
||||
osfp_profile_get_cycle(c1);
|
||||
|
||||
if (result == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
@@ -139,6 +143,10 @@ exit:
|
||||
if (root) {
|
||||
cJSON_Delete(root);
|
||||
}
|
||||
if (result_str) {
|
||||
osfp_profile_get_cycle(c2);
|
||||
osfp_profile_counter_update(&osfp_profile_result_export, c2 - c1);
|
||||
}
|
||||
return result_str;
|
||||
}
|
||||
|
||||
@@ -159,21 +167,33 @@ struct osfp_result *osfp_ipv4_identify(struct osfp_db *db, struct iphdr* l3_hdr,
|
||||
struct osfp_os_class_score os_class_score;
|
||||
struct osfp_result *result;
|
||||
|
||||
osfp_profile_cycle(c1);
|
||||
osfp_profile_cycle(c2);
|
||||
|
||||
if (db == NULL || l3_hdr == NULL || l4_hdr == NULL || l4_hdr == 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
osfp_profile_get_cycle(c1);
|
||||
ret = osfp_fingerprinting((unsigned char *)l3_hdr, (unsigned char *)l4_hdr, (unsigned int)l4_hdr_len, &fp, 4);
|
||||
osfp_profile_get_cycle(c2);
|
||||
osfp_profile_counter_update(&osfp_profile_fingerprinting, c2 - c1);
|
||||
if (ret != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
osfp_profile_get_cycle(c1);
|
||||
ret = osfp_score_db_score(db->score_db, 0, &fp, &os_class_score);
|
||||
osfp_profile_get_cycle(c2);
|
||||
osfp_profile_counter_update(&osfp_profile_score, c2 - c1);
|
||||
if (ret != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
osfp_profile_get_cycle(c1);
|
||||
result = osfp_result_build(&os_class_score);
|
||||
osfp_profile_get_cycle(c2);
|
||||
osfp_profile_counter_update(&osfp_profile_result_build, c2 - c1);
|
||||
if (result == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
@@ -190,7 +210,7 @@ struct osfp_result *osfp_ipv6_identify(struct osfp_db *db, struct ip6_hdr* l3_hd
|
||||
struct osfp_os_class_score os_class_score;
|
||||
struct osfp_result *result;
|
||||
|
||||
if (db == NULL || l3_hdr == NULL || l4_hdr == NULL) {
|
||||
if (db == NULL || l3_hdr == NULL || l4_hdr == NULL || l4_hdr_len == 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@@ -225,7 +245,7 @@ struct osfp_result *osfp_json_identify(struct osfp_db *db, const char *json_str)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ret = osfp_fingerprint_from_json(&fp, json_str);
|
||||
ret = osfp_fingerprint_from_json(&fp, (char *)json_str);
|
||||
if (ret != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user