packet lib: ipv6: correct a default parameter of opt_header

the length of opt_header has to be a multiple of 8.

wrong:
    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   | nxt             | size          | (opt)type=1   | (opt)len=6  |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   | (opt)data='\x00\x00\x00\x00\x00\x00' (6 octet)                |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                                 |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

right:
    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   | nxt             | size          | (opt)type=1   | (opt)len=4  |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   | (opt)data='\x00\x00\x00\x00' (4 octet)                        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Yuichi Ito 2013-12-12 13:56:32 +09:00 committed by FUJITA Tomonori
parent f7118a89c1
commit 31c0941fb8
2 changed files with 4 additions and 4 deletions

View File

@ -203,8 +203,8 @@ class opt_header(header):
buf = struct.pack(self._PACK_STR, self.nxt, self.size)
buf = bytearray(buf)
if self.data is None:
self.data = [option(type_=1, len_=6,
data='\x00\x00\x00\x00\x00\x00')]
self.data = [option(type_=1, len_=4,
data='\x00\x00\x00\x00')]
for opt in self.data:
buf.extend(opt.serialize())
return buf

View File

@ -528,7 +528,7 @@ class Test_hop_opts(unittest.TestCase):
eq_(res[0], 6)
eq_(res[1], 0)
opt = ipv6.option(type_=1, len_=6, data='\x00\x00\x00\x00\x00\x00')
opt = ipv6.option(type_=1, len_=4, data='\x00\x00\x00\x00')
eq_(str(buf[2:]), opt.serialize())
@ -609,7 +609,7 @@ class Test_dst_opts(unittest.TestCase):
eq_(res[0], 6)
eq_(res[1], 0)
opt = ipv6.option(type_=1, len_=6, data='\x00\x00\x00\x00\x00\x00')
opt = ipv6.option(type_=1, len_=4, data='\x00\x00\x00\x00')
eq_(str(buf[2:]), opt.serialize())