From: Sylvain Rodon <s...@nexatech.fr>

Timestamp is always set in PCAP header, whether it reads a file or
listen on an interface. This information can be important for some
applications and it cannot be obtained otherwise (especially when
reading a PCAP file). Timestamp here is the number of microseconds
since epoch.

Signed-off-by: Sylvain Rodon <s...@nexatech.fr>
---
 drivers/net/pcap/rte_eth_pcap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 95d4b5b..3e80f0c 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -265,6 +265,9 @@ struct pmd_devargs_all {
                }
 
                mbuf->pkt_len = (uint16_t)header.caplen;
+               mbuf->timestamp = (uint64_t)header.ts.tv_sec * 1000000
+                                         + header.ts.tv_usec;
+               mbuf->ol_flags |= PKT_RX_TIMESTAMP;
                mbuf->port = pcap_q->port_id;
                bufs[num_rx] = mbuf;
                num_rx++;
-- 
1.9.1

Reply via email to