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):
|
def pp(value, bits=16):
|
||||||
if type(value) == type(''):
|
|
||||||
value, _ = unpack('<H', value)
|
|
||||||
hexfmt = '%%0%dx' % (bits / 4)
|
hexfmt = '%%0%dx' % (bits / 4)
|
||||||
return '%6d 0x%s %s' % (value, (hexfmt % value), bin(value, bits))
|
return '%6d 0x%s %s' % (value, (hexfmt % value), bin(value, bits))
|
||||||
|
|
||||||
|
|
21
ip.py
21
ip.py
|
@ -323,16 +323,16 @@ class Dispatch:
|
||||||
|
|
||||||
def _read(self, pc, filename, fd):
|
def _read(self, pc, filename, fd):
|
||||||
pos = fd.tell()
|
pos = fd.tell()
|
||||||
pkt = pc.read()
|
f = pc.read()
|
||||||
if pkt:
|
if f:
|
||||||
heapq.heappush(self.tops, (pkt, pc, filename, fd, pos))
|
heapq.heappush(self.tops, (f, pc, filename, fd, pos))
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
while self.tops:
|
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:
|
if not self.last:
|
||||||
self.last = (filename, pos)
|
self.last = (filename, pos)
|
||||||
frame = Frame(pkt)
|
frame = Frame(f)
|
||||||
if frame.protocol == TCP:
|
if frame.protocol == TCP:
|
||||||
# compute TCP session hash
|
# compute TCP session hash
|
||||||
tcp_sess = self.sessions.get(frame.hash)
|
tcp_sess = self.sessions.get(frame.hash)
|
||||||
|
@ -415,11 +415,12 @@ class Packet(UserDict.DictMixin):
|
||||||
self.opcode,
|
self.opcode,
|
||||||
self.opcode_desc)
|
self.opcode_desc)
|
||||||
if self.firstframe:
|
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.sport,
|
||||||
self.firstframe.dst_addr,
|
self.firstframe.dst_addr,
|
||||||
self.firstframe.dport,
|
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:
|
if self.parts:
|
||||||
dl = len(self.parts[-1])
|
dl = len(self.parts[-1])
|
||||||
|
|
Loading…
Reference in New Issue