add support for retrieving pcap packet timestamps

This commit is contained in:
luwenpeng
2024-08-23 16:04:07 +08:00
parent 6808e6ba29
commit 2634d70108
6 changed files with 31 additions and 8 deletions

View File

@@ -40,6 +40,7 @@ struct pcap_pkt
{
char *data;
int len;
struct timeval ts;
};
/******************************************************************************
@@ -142,6 +143,7 @@ static void pcap_pkt_handler(u_char *user, const struct pcap_pkthdr *h, const u_
}
pcap_pkt->data = (char *)pcap_pkt + sizeof(struct pcap_pkt);
pcap_pkt->len = h->caplen;
pcap_pkt->ts = h->ts;
memcpy((char *)pcap_pkt->data, bytes, h->caplen);
// calculate packet hash
@@ -386,6 +388,7 @@ uint16_t dumpfile_io_ingress(struct dumpfile_io *handle, uint16_t thr_idx, struc
memset(&pkt->meta, 0, sizeof(pkt->meta));
packet_set_origin_ctx(pkt, pcap_pkt);
packet_set_action(pkt, PACKET_ACTION_FORWARD);
packet_set_timeval(pkt, &pcap_pkt->ts);
nr_parsed++;
}
}