Clean up dpdk plugin rx/tx pcap tracing
[vpp.git] / src / vnet / unix / pcap.c
index 0832b16..e91b879 100644 (file)
@@ -110,6 +110,7 @@ pcap_write (pcap_main_t * pm)
       pm->flags |= PCAP_MAIN_INIT_DONE;
       pm->n_packets_captured = 0;
       pm->n_pcap_data_written = 0;
+      clib_spinlock_init (&pm->lock);
 
       /* Write file header. */
       memset (&fh, 0, sizeof (fh));
@@ -216,6 +217,9 @@ pcap_read (pcap_main_t * pm)
   while ((n = read (fd, &ph, sizeof (ph))) != 0)
     {
       u8 *data;
+      u64 timestamp;
+      u32 timestamp_sec;
+      u32 timestamp_usec;
 
       if (need_swap)
        {
@@ -242,7 +246,11 @@ pcap_read (pcap_main_t * pm)
            clib_max (pm->max_packet_bytes, ph.n_bytes_in_packet);
        }
 
+      timestamp_sec = ph.time_in_sec;
+      timestamp_usec = ph.time_in_usec;
+      timestamp = ((u64) timestamp_sec) * 1000000 + (u64) timestamp_usec;
       vec_add1 (pm->packets_read, data);
+      vec_add1 (pm->timestamps, timestamp);
     }
 
 done: