diff options
author | Yuichi Ito <ito.yuichi0@gmail.com> | 2013-11-12 14:33:01 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2013-11-12 17:58:36 +0900 |
commit | a8750a2abe7bd2b09ee68ffe7c31c836344e9687 (patch) | |
tree | fb8c2a79aedb242d1452864b4598d00281ade378 | |
parent | 723961fb3aa925b501a8f85527e53cf7140152c3 (diff) |
packet lib: ipv6: change some default parameters
nxt : IPPROTO_NONE(0x3b) -> IPPROTO_TCP(0x06)
hop_limit : 0 -> 255
it is more useful and common.
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 | 10 | ||||
-rw-r--r-- | ryu/tests/unit/packet/test_ipv6.py | 14 | ||||
-rw-r--r-- | ryu/tests/unit/packet/test_packet.py | 26 |
3 files changed, 25 insertions, 25 deletions
diff --git a/ryu/lib/packet/ipv6.py b/ryu/lib/packet/ipv6.py index b0207c2e..f5ee038e 100644 --- a/ryu/lib/packet/ipv6.py +++ b/ryu/lib/packet/ipv6.py @@ -69,7 +69,7 @@ class ipv6(packet_base.PacketBase): return _register_header_type def __init__(self, version=6, traffic_class=0, flow_label=0, - payload_length=0, nxt=inet.IPPROTO_NONE, hop_limit=0, + payload_length=0, nxt=inet.IPPROTO_TCP, hop_limit=255, src='::', dst='::', ext_hdrs=None): super(ipv6, self).__init__() self.version = version @@ -235,7 +235,7 @@ class hop_opts(opt_header): """ TYPE = inet.IPPROTO_HOPOPTS - def __init__(self, nxt=inet.IPPROTO_NONE, size=0, data=None): + def __init__(self, nxt=inet.IPPROTO_TCP, size=0, data=None): super(hop_opts, self).__init__(nxt, size, data) @@ -262,7 +262,7 @@ class dst_opts(opt_header): """ TYPE = inet.IPPROTO_DSTOPTS - def __init__(self, nxt=inet.IPPROTO_NONE, size=0, data=None): + def __init__(self, nxt=inet.IPPROTO_TCP, size=0, data=None): super(dst_opts, self).__init__(nxt, size, data) @@ -354,7 +354,7 @@ class fragment(header): _PACK_STR = '!BxHI' _MIN_LEN = struct.calcsize(_PACK_STR) - def __init__(self, nxt=inet.IPPROTO_NONE, offset=0, more=0, id_=0): + def __init__(self, nxt=inet.IPPROTO_TCP, offset=0, more=0, id_=0): super(fragment, self).__init__(nxt) self.offset = offset self.more = more @@ -404,7 +404,7 @@ class auth(header): _PACK_STR = '!BB2xII' _MIN_LEN = struct.calcsize(_PACK_STR) - def __init__(self, nxt=inet.IPPROTO_NONE, size=3, spi=0, seq=0, + def __init__(self, nxt=inet.IPPROTO_TCP, size=3, spi=0, seq=0, data='\x00\x00\x00\x00'): super(auth, self).__init__(nxt) assert data is not None diff --git a/ryu/tests/unit/packet/test_ipv6.py b/ryu/tests/unit/packet/test_ipv6.py index e701234e..bf4184df 100644 --- a/ryu/tests/unit/packet/test_ipv6.py +++ b/ryu/tests/unit/packet/test_ipv6.py @@ -403,8 +403,8 @@ class Test_ipv6(unittest.TestCase): eq_(res[0], 6 << 28) eq_(res[1], 0) - eq_(res[2], 59) - eq_(res[3], 0) + eq_(res[2], 6) + eq_(res[3], 255) eq_(res[4], addrconv.ipv6.text_to_bin('::')) eq_(res[5], addrconv.ipv6.text_to_bin('::')) @@ -420,7 +420,7 @@ class Test_ipv6(unittest.TestCase): eq_(res[0], 6 << 28) eq_(res[1], 8) eq_(res[2], 0) - eq_(res[3], 0) + eq_(res[3], 255) eq_(res[4], addrconv.ipv6.text_to_bin('::')) eq_(res[5], addrconv.ipv6.text_to_bin('::')) eq_(res[6], '\x3a\x00\x05\x02\x00\x00\x01\x00') @@ -501,7 +501,7 @@ class Test_hop_opts(unittest.TestCase): buf = hdr.serialize() res = struct.unpack('!BB', str(buf[:2])) - eq_(res[0], 59) + eq_(res[0], 6) eq_(res[1], 0) opt = ipv6.option(type_=1, len_=6, data='\x00\x00\x00\x00\x00\x00') eq_(str(buf[2:]), opt.serialize()) @@ -582,7 +582,7 @@ class Test_dst_opts(unittest.TestCase): buf = hdr.serialize() res = struct.unpack('!BB', str(buf[:2])) - eq_(res[0], 59) + eq_(res[0], 6) eq_(res[1], 0) opt = ipv6.option(type_=1, len_=6, data='\x00\x00\x00\x00\x00\x00') eq_(str(buf[2:]), opt.serialize()) @@ -713,7 +713,7 @@ class Test_fragment(unittest.TestCase): buf = hdr.serialize() res = struct.unpack_from(ipv6.fragment._PACK_STR, buf) - eq_(res[0], 59) + eq_(res[0], 6) eq_(res[1], 0) eq_(res[2], 0) @@ -770,7 +770,7 @@ class Test_auth(unittest.TestCase): res = struct.unpack_from(ipv6.auth._PACK_STR, str(buf)) LOG.info(res) - eq_(res[0], 59) + eq_(res[0], 6) eq_(res[1], 3) eq_(res[2], 0) eq_(res[3], 0) diff --git a/ryu/tests/unit/packet/test_packet.py b/ryu/tests/unit/packet/test_packet.py index aebf3bf3..a9797774 100644 --- a/ryu/tests/unit/packet/test_packet.py +++ b/ryu/tests/unit/packet/test_packet.py @@ -872,7 +872,7 @@ class TestPacket(unittest.TestCase): ip_buf = '\x60\x00\x00\x00' \ + '\x00\x00' \ + '\x11' \ - + '\x00' \ + + '\xff' \ + '\x00\x00' \ + ipaddr \ + ipaddr @@ -905,7 +905,7 @@ class TestPacket(unittest.TestCase): eq_(0, p_ipv6.flow_label) eq_(len(u_buf) + len(self.payload), p_ipv6.payload_length) eq_(inet.IPPROTO_UDP, p_ipv6.nxt) - eq_(0, p_ipv6.hop_limit) + eq_(255, p_ipv6.hop_limit) eq_('::', p_ipv6.src) eq_('::', p_ipv6.dst) @@ -940,7 +940,7 @@ class TestPacket(unittest.TestCase): 'flow_label': 0, 'payload_length': len(u_buf) + len(self.payload), 'nxt': inet.IPPROTO_UDP, - 'hop_limit': 0, + 'hop_limit': 255, 'src': '::', 'dst': '::', 'ext_hdrs': []} @@ -976,7 +976,7 @@ class TestPacket(unittest.TestCase): def test_ipv6_tcp(self): # build packet e = ethernet.ethernet(ethertype=ether.ETH_TYPE_IPV6) - ip = ipv6.ipv6(nxt=inet.IPPROTO_TCP) + ip = ipv6.ipv6() t = tcp.tcp(option='\x01\x02') p = e/ip/t/self.payload @@ -993,7 +993,7 @@ class TestPacket(unittest.TestCase): ip_buf = '\x60\x00\x00\x00' \ + '\x00\x00' \ + '\x06' \ - + '\x00' \ + + '\xff' \ + '\x00\x00' \ + ipaddr \ + ipaddr @@ -1032,7 +1032,7 @@ class TestPacket(unittest.TestCase): eq_(0, p_ipv6.flow_label) eq_(len(t_buf) + len(self.payload), p_ipv6.payload_length) eq_(inet.IPPROTO_TCP, p_ipv6.nxt) - eq_(0, p_ipv6.hop_limit) + eq_(255, p_ipv6.hop_limit) eq_('::', p_ipv6.src) eq_('::', p_ipv6.dst) @@ -1072,7 +1072,7 @@ class TestPacket(unittest.TestCase): 'flow_label': 0, 'payload_length': len(t_buf) + len(self.payload), 'nxt': inet.IPPROTO_TCP, - 'hop_limit': 0, + 'hop_limit': 255, 'src': '::', 'dst': '::', 'ext_hdrs': []} @@ -1131,7 +1131,7 @@ class TestPacket(unittest.TestCase): ip_buf = '\x60\x00\x00\x00' \ + '\x00\x00' \ + '\x84' \ - + '\x00' \ + + '\xff' \ + '\x00\x00' \ + ipaddr \ + ipaddr @@ -1172,7 +1172,7 @@ class TestPacket(unittest.TestCase): eq_(0, p_ipv6.flow_label) eq_(len(s_buf), p_ipv6.payload_length) eq_(inet.IPPROTO_SCTP, p_ipv6.nxt) - eq_(0, p_ipv6.hop_limit) + eq_(255, p_ipv6.hop_limit) eq_('::', p_ipv6.src) eq_('::', p_ipv6.dst) @@ -1208,7 +1208,7 @@ class TestPacket(unittest.TestCase): 'flow_label': 0, 'payload_length': len(s_buf), 'nxt': inet.IPPROTO_SCTP, - 'hop_limit': 0, + 'hop_limit': 255, 'src': '::', 'dst': '::', 'ext_hdrs': []} @@ -1274,7 +1274,7 @@ class TestPacket(unittest.TestCase): ip_buf = '\x60\x00\x00\x00' \ + '\x00\x00' \ + '\x3a' \ - + '\x00' \ + + '\xff' \ + '\x00\x00' \ + ipaddr \ + ipaddr @@ -1306,7 +1306,7 @@ class TestPacket(unittest.TestCase): eq_(0, p_ipv6.flow_label) eq_(len(ic_buf), p_ipv6.payload_length) eq_(inet.IPPROTO_ICMPV6, p_ipv6.nxt) - eq_(0, p_ipv6.hop_limit) + eq_(255, p_ipv6.hop_limit) eq_('::', p_ipv6.src) eq_('::', p_ipv6.dst) @@ -1335,7 +1335,7 @@ class TestPacket(unittest.TestCase): 'flow_label': 0, 'payload_length': len(ic_buf), 'nxt': inet.IPPROTO_ICMPV6, - 'hop_limit': 0, + 'hop_limit': 255, 'src': '::', 'dst': '::', 'ext_hdrs': []} |