v0.0.5
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user