mirror of https://github.com/dirtbags/netarch.git
A few trivial cosmetic changes
This commit is contained in:
parent
5fd76ede00
commit
237fe5910d
|
@ -207,8 +207,6 @@ def unhex(s):
|
|||
|
||||
|
||||
def pp(value, bits=16):
|
||||
if type(value) == type(''):
|
||||
value, _ = unpack('<H', value)
|
||||
hexfmt = '%%0%dx' % (bits / 4)
|
||||
return '%6d 0x%s %s' % (value, (hexfmt % value), bin(value, bits))
|
||||
|
||||
|
|
15
ip.py
15
ip.py
|
@ -323,16 +323,16 @@ class Dispatch:
|
|||
|
||||
def _read(self, pc, filename, fd):
|
||||
pos = fd.tell()
|
||||
pkt = pc.read()
|
||||
if pkt:
|
||||
heapq.heappush(self.tops, (pkt, pc, filename, fd, pos))
|
||||
f = pc.read()
|
||||
if f:
|
||||
heapq.heappush(self.tops, (f, pc, filename, fd, pos))
|
||||
|
||||
def __iter__(self):
|
||||
while self.tops:
|
||||
pkt, pc, filename, fd, pos = heapq.heappop(self.tops)
|
||||
f, pc, filename, fd, pos = heapq.heappop(self.tops)
|
||||
if not self.last:
|
||||
self.last = (filename, pos)
|
||||
frame = Frame(pkt)
|
||||
frame = Frame(f)
|
||||
if frame.protocol == TCP:
|
||||
# compute TCP session hash
|
||||
tcp_sess = self.sessions.get(frame.hash)
|
||||
|
@ -415,11 +415,12 @@ class Packet(UserDict.DictMixin):
|
|||
self.opcode,
|
||||
self.opcode_desc)
|
||||
if self.firstframe:
|
||||
print ' %s:%d -> %s:%d (%s)' % (self.firstframe.src_addr,
|
||||
print ' %s:%d -> %s:%d (%s.%06dZ)' % (self.firstframe.src_addr,
|
||||
self.firstframe.sport,
|
||||
self.firstframe.dst_addr,
|
||||
self.firstframe.dport,
|
||||
time.ctime(self.firstframe.time))
|
||||
time.strftime('%Y-%m-%dT%T', time.gmtime(self.firstframe.time)),
|
||||
self.firstframe.time_usec)
|
||||
|
||||
if self.parts:
|
||||
dl = len(self.parts[-1])
|
||||
|
|
Loading…
Reference in New Issue