vnet: store hw interface speed in kbps instead of using flags
[vpp.git] / src / vnet / unix / pcap.c
index 0832b16..3c9ce31 100644 (file)
@@ -110,9 +110,10 @@ 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));
+      clib_memset (&fh, 0, sizeof (fh));
       fh.magic = 0xa1b2c3d4;
       fh.major_version = 2;
       fh.minor_version = 4;
@@ -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: