Thanks a lot Brandon. I'll push to 0.6 shortly.
Hi,
Please disregard the previous attachment - what started out as a
bugreport became a patch, and I forgot to remove the pcap dump of the
offending packets.
Thanks,
-b
On Sun, Jan 24, 2010 at 4:15 AM, Brandon Heller <[email protected]
<mailto:[email protected]>> wrote:
Hi,
Parsing the first packet in an iperf TCP session produced the
following:
File "./nox/lib/packet/packet_base.py", line 114, in tostring
return ''.join((buf, self.next.tostring()))
File "./nox/lib/packet/packet_base.py", line 114, in tostring
return ''.join((buf, self.next.tostring()))
File "./nox/lib/packet/packet_base.py", line 109, in tostring
buf = self.hdr()
File "./nox/lib/packet/tcp.py", line 215, in hdr
packet += option.to_bytes()
File "./nox/lib/packet/tcp.py", line 70, in to_bytes
return struct.pack('!BBH',self.type,4,self.val)
File "/usr/lib/python2.5/struct.py", line 63, in pack
return o.pack(*args)
TypeError: unsupported operand type(s) for &: 'tuple' and 'long'
This first packet had an MSS TCP option set.
The error is caused when the packet is parsed: the single value in
the tuple returned by struct.unpack() on the MSS value was not
extracted, and caused an unsupported operand exception when
to_bytes was later called to write the packet out.
The fix is to append [0] to extract the first tuple value. I
didn't see any other options for which a single value was unpacked.
Patch:
diff --git a/src/nox/lib/packet/tcp.py b/src/nox/lib/packet/tcp.py
index 9842673..af1546e 100644
--- a/src/nox/lib/packet/tcp.py
+++ b/src/nox/lib/packet/tcp.py
@@ -150,7 +150,7 @@ class tcp(packet_base):
elif arr[i] == tcp_opt.MSS:
if arr[i+1] != 4:
raise Exception()
- val = struct.unpack('!H',arr[i+2:i+4])
+ val = struct.unpack('!H',arr[i+2:i+4])[0]
self.options.append(tcp_opt(tcp_opt.MSS,val))
elif arr[i] == tcp_opt.WSOPT:
if arr[i+1] != 3:
Please add this to NOX.
Thanks,
-b
------------------------------------------------------------------------
_______________________________________________
nox-dev mailing list
[email protected]
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org
_______________________________________________
nox-dev mailing list
[email protected]
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org