You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. use pcap.Writer to create a pcap
2. od -X <> | head shows big-endian pcap file.
What is the expected output? What do you see instead?
Expected a little endian pcap on x86 platforms.
What version of the product are you using? On what operating system?
dpkt 1.7, Linux (Ubuntu 10.04 x86), Mac OS X (Snow Leopard 10.6.4 x86)
Please provide any additional information below.
--- pcap.py 2009-11-06 22:28:26.000000000 +0000
+++ pcap-new.py 2010-09-09 13:07:09.000000000 +0100
@@ -70,7 +70,10 @@
"""Simple pcap dumpfile writer."""
def __init__(self, fileobj, snaplen=1500, linktype=DLT_EN10MB):
self.__f = fileobj
- fh = FileHdr(snaplen=snaplen, linktype=linktype)
+ if sys.byteorder == 'little':
+ fh = LEFileHdr(snaplen=snaplen, linktype=linktype)
+ else:
+ fh = FileHdr(snaplen=snaplen, linktype=linktype)
self.__f.write(str(fh))
def writepkt(self, pkt, ts=None):
@@ -78,7 +81,12 @@
ts = time.time()
s = str(pkt)
n = len(s)
- ph = PktHdr(tv_sec=int(ts),
+ if sys.byteorder == 'little':
+ ph = LEPktHdr(tv_sec=int(ts),
+ tv_usec=int((float(ts) - int(ts)) * 1000000.0),
+ caplen=n, len=n)
+ else:
+ ph = PktHdr(tv_sec=int(ts),
tv_usec=int((float(ts) - int(ts)) * 1000000.0),
caplen=n, len=n)
self.__f.write(str(ph))
Original issue reported on code.google.com by pete.sha...@gmail.com on 9 Sep 2010 at 12:10
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
pete.sha...@gmail.com
on 9 Sep 2010 at 12:10The text was updated successfully, but these errors were encountered: