diff options
author | Yuichi Ito <ito.yuichi0@gmail.com> | 2013-12-12 13:56:32 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2013-12-12 18:58:34 +0900 |
commit | 31c0941fb8b734b47b948b8aa0346c0d6eb506e4 (patch) | |
tree | 4c4f7f446e5b1e66e67e6ec900765389fb4c759e | |
parent | f7118a89c1cf72d4144c71a6668d01869d2e6553 (diff) |
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>
-rw-r--r-- | ryu/lib/packet/ipv6.py | 4 | ||||
-rw-r--r-- | ryu/tests/unit/packet/test_ipv6.py | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/ryu/lib/packet/ipv6.py b/ryu/lib/packet/ipv6.py index 9f04da5f..59d7e18f 100644 --- a/ryu/lib/packet/ipv6.py +++ b/ryu/lib/packet/ipv6.py @@ -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 diff --git a/ryu/tests/unit/packet/test_ipv6.py b/ryu/tests/unit/packet/test_ipv6.py index 4e46d31d..a2a13433 100644 --- a/ryu/tests/unit/packet/test_ipv6.py +++ b/ryu/tests/unit/packet/test_ipv6.py @@ -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()) |