This commit is contained in:
zhuzhenjun
2023-10-09 15:23:31 +08:00
parent 1a559eba99
commit 56e3dec5f0
29 changed files with 433055 additions and 184 deletions

View File

@@ -442,21 +442,27 @@ void example_detect(struct osfp_db *osfp_db, Packet *p)
int ret;
char str_buf[1024];
//unsigned char *iph = (unsigned char *)(p->iph != NULL ? (void *)p->iph : (void *)p->ip6h);
struct iphdr *iph;
struct ipv6hdr *ip6h;
struct tcphdr *tcph;
unsigned int tcph_len;
struct osfp_result *result;
unsigned int os_class_flags = OSFP_OS_CLASS_FLAG_WINDOWS | OSFP_OS_CLASS_FLAG_LINUX | OSFP_OS_CLASS_FLAG_MAC_OS;
struct osfp_result *result = NULL;
printf("Example ipv4 header detect: --------------------------\n");
if (p->iph == NULL) {
goto exit;
}
iph = (struct iphdr *)p->iph;
ip6h = (struct ipv6hdr *)p->ip6h;
tcph = (struct tcphdr *)p->tcph;
tcph_len = tcph->doff << 2;
result = osfp_ipv4_identify(osfp_db, p->iph, tcph, tcph_len);
if (iph) {
result = osfp_ipv4_identify(osfp_db, iph, tcph, tcph_len);
} else if (ip6h) {
result = osfp_ipv6_identify(osfp_db, ip6h, tcph, tcph_len);
} else {
goto exit;
}
if (result == NULL) {
printf("osfp header match failed, erro: %s\n", "?");
goto exit;
@@ -468,9 +474,10 @@ void example_detect(struct osfp_db *osfp_db, Packet *p)
printf("Details:\n");
printf("%s\n", osfp_result_score_detail_export(result));
osfp_result_free(result);
exit:
if (result) {
osfp_result_free(result);
}
return;
}