[ovs-dev] [PATCH v2 1/2] ovs-pcap: Support nanosecond resolution pcap files.

Mark Michelson mmichels at redhat.com
Fri Oct 5 16:52:39 UTC 2018


pcap files with nanosecond resolution use a different magic number in
the pcap header than those with microsecond resolution.

Signed-off-by: Mark Michelson <mmichels at redhat.com>
---
 utilities/ovs-pcap.in | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/utilities/ovs-pcap.in b/utilities/ovs-pcap.in
index fc1532110..7bebc0795 100755
--- a/utilities/ovs-pcap.in
+++ b/utilities/ovs-pcap.in
@@ -34,13 +34,14 @@ class PcapReader(object):
             raise PcapException("end of file reading pcap header")
         magic, version, thiszone, sigfigs, snaplen, network = \
             struct.unpack(">6I", header)
-        if magic == 0xa1b2c3d4:
+        if magic == 0xa1b2c3d4 or magic == 0xa1b23c4d:
             self.header_format = ">4I"
-        elif magic == 0xd4c3b2a1:
+        elif magic == 0xd4c3b2a1 or magic == 0x4d3cb2a1:
             self.header_format = "<4I"
         else:
             raise PcapException("bad magic %u reading pcap file "
-                        "(expected 0xa1b2c3d4 or 0xd4c3b2a1)" % magic)
+                        "(expected 0xa1b2c3d4, 0xa1b23c4d, 0x4d3cb2a1 or "
+                        "0xd4c3b2a1)" % magic)
 
     def read(self):
         header = self.file.read(16)
-- 
2.14.4



More information about the dev mailing list