From 112d3cc880ff761bf4cc80ad363446649c8ea815 Mon Sep 17 00:00:00 2001 From: pi-rho Date: Fri, 1 Feb 2013 17:18:54 -0600 Subject: [PATCH] Frame::ipid needs to be 2 bytes; Session::open_out should care about binary --- netarch/ip.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/netarch/ip.py b/netarch/ip.py index 28be66d..6357977 100644 --- a/netarch/ip.py +++ b/netarch/ip.py @@ -195,7 +195,7 @@ class TCP_Recreate(object): if cli: sip, sport = self.src dip, dport = self.dst - ipid = self.sid + ipid = (self.sid & 0xffff) self.sid += 1 seq = self.sseq self.sseq += len(payload) @@ -205,7 +205,7 @@ class TCP_Recreate(object): else: sip, sport = self.dst dip, dport = self.src - ipid = self.did + ipid = (self.did & 0xffff) self.did += 1 seq = self.dseq self.dseq += len(payload) @@ -749,7 +749,7 @@ class Session(object): return - def open_out(self, fn): + def open_out(self, fn, text=True): frame = self.firstframe fn = '%d-%s~%d-%s~%d---%s' % (frame.time, frame.src_addr, frame.sport, @@ -758,7 +758,7 @@ class Session(object): fullfn = os.path.join(self.basename, fn) fullfn2 = os.path.join(self.basename2, fn) print ' writing %s' % (fn,) - fd = file(fullfn, 'w') + fd = file(fullfn, 'w' if text else 'wb') try: os.unlink(fullfn2) except OSError: