Optimize log output
This commit is contained in:
@@ -241,21 +241,31 @@ static void packet_handler(u_char *user, const struct pcap_pkthdr *h, const u_ch
|
||||
{
|
||||
struct runtime *rte = (struct runtime *)user;
|
||||
|
||||
char *ptr = (char *)calloc(1, h->caplen);
|
||||
if (ptr == NULL)
|
||||
{
|
||||
PRINT_RED("calloc() failed");
|
||||
return;
|
||||
}
|
||||
memcpy(ptr, bytes, h->caplen);
|
||||
|
||||
struct packet pkt;
|
||||
memset(&pkt, 0, sizeof(pkt));
|
||||
packet_parse(&pkt, (const char *)bytes, h->caplen);
|
||||
packet_parse(&pkt, (const char *)ptr, h->caplen);
|
||||
rte->pcap_count++;
|
||||
|
||||
if (rte->print_verbose)
|
||||
{
|
||||
PRINT_GREEN("frame=%lu len=%u", rte->pcap_count, h->caplen);
|
||||
packet_print(&pkt);
|
||||
packet_dump_hex(&pkt, STDOUT_FILENO);
|
||||
}
|
||||
|
||||
if (rte->tshark_format)
|
||||
{
|
||||
tshark_format(rte, &pkt);
|
||||
}
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
static void usage(char *cmd)
|
||||
|
||||
Reference in New Issue
Block a user