packet lib: tcp: fix default arguments

Reported-by: Arne Goetje <arne_goetje@accton.com>
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Minoru TAKAHASHI 2014-07-30 14:32:16 +09:00 committed by FUJITA Tomonori
parent 8c6185b4d9
commit 27c0cd5b11
3 changed files with 12 additions and 12 deletions

View File

@ -48,7 +48,7 @@ class tcp(packet_base.PacketBase):
_PACK_STR = '!HHIIBBHHH'
_MIN_LEN = struct.calcsize(_PACK_STR)
def __init__(self, src_port=0, dst_port=0, seq=0, ack=0, offset=0,
def __init__(self, src_port=1, dst_port=1, seq=0, ack=0, offset=0,
bits=0, window_size=0, csum=0, urgent=0, option=None):
super(tcp, self).__init__()
self.src_port = src_port

View File

@ -1038,8 +1038,8 @@ class TestPacket(unittest.TestCase):
# tcp
ok_(p_tcp)
eq_(0, p_tcp.src_port)
eq_(0, p_tcp.dst_port)
eq_(1, p_tcp.src_port)
eq_(1, p_tcp.dst_port)
eq_(0, p_tcp.seq)
eq_(0, p_tcp.ack)
eq_(6, p_tcp.offset)
@ -1052,7 +1052,7 @@ class TestPacket(unittest.TestCase):
ph = struct.pack('!16s16sI3xB', ipaddr, ipaddr,
len(t_buf) + len(self.payload), 6)
t = ph + t + self.payload
eq_(packet_utils.checksum(t), 0x60)
eq_(packet_utils.checksum(t), 0x62)
# payload
ok_('payload' in protocols)
@ -1081,8 +1081,8 @@ class TestPacket(unittest.TestCase):
if k in ipv6_values])
ipv6_str = '%s(%s)' % (ipv6.ipv6.__name__, _ipv6_str)
tcp_values = {'src_port': 0,
'dst_port': 0,
tcp_values = {'src_port': 1,
'dst_port': 1,
'seq': 0,
'ack': 0,
'offset': 6,

View File

@ -145,8 +145,8 @@ class Test_tcp(unittest.TestCase):
buf = t.serialize(bytearray(), prev)
res = struct.unpack(tcp._PACK_STR, buf)
eq_(res[0], 0)
eq_(res[1], 0)
eq_(res[0], 1)
eq_(res[1], 1)
eq_(res[2], 0)
eq_(res[3], 0)
eq_(res[4], 5 << 4)
@ -159,8 +159,8 @@ class Test_tcp(unittest.TestCase):
buf = t.serialize(bytearray(), prev)
res = struct.unpack(tcp._PACK_STR + '4s', buf)
eq_(res[0], 0)
eq_(res[1], 0)
eq_(res[0], 1)
eq_(res[1], 1)
eq_(res[2], 0)
eq_(res[3], 0)
eq_(res[4], 6 << 4)
@ -174,8 +174,8 @@ class Test_tcp(unittest.TestCase):
buf = t.serialize(bytearray(), prev)
res = struct.unpack(tcp._PACK_STR + '8s', buf)
eq_(res[0], 0)
eq_(res[1], 0)
eq_(res[0], 1)
eq_(res[1], 1)
eq_(res[2], 0)
eq_(res[3], 0)
eq_(res[4], 7 << 4)