示例#1
0
文件: test_ipv6.py 项目: qsdj/ryu
 def setUp_with_multi_headers(self):
     self.opt1_type = 5
     self.opt1_len = 2
     self.opt1_data = '\x00\x00'
     self.opt2_type = 1
     self.opt2_len = 0
     self.opt2_data = None
     self.options = [
         ipv6.option(self.opt1_type, self.opt1_len, self.opt1_data),
         ipv6.option(self.opt2_type, self.opt2_len, self.opt2_data),
     ]
     self.hop_opts_nxt = ipv6.auth.TYPE
     self.hop_opts_size = 0
     self.hop_opts = ipv6.hop_opts(self.hop_opts_nxt, self.hop_opts_size,
                                   self.options)
     self.auth_nxt = 6
     self.auth_size = 4
     self.auth_spi = 256
     self.auth_seq = 1
     self.auth_data = '\xa0\xe7\xf8\xab\xf9\x69\x1a\x8b\xf3\x9f\x7c\xae'
     self.auth = ipv6.auth(self.auth_nxt, self.auth_size, self.auth_spi,
                           self.auth_seq, self.auth_data)
     self.ext_hdrs = [self.hop_opts, self.auth]
     self.payload_length += len(self.hop_opts) + len(self.auth)
     self.nxt = ipv6.hop_opts.TYPE
     self.ip = ipv6.ipv6(self.version, self.traffic_class, self.flow_label,
                         self.payload_length, self.nxt, self.hop_limit,
                         self.src, self.dst, self.ext_hdrs)
     self.buf = struct.pack(ipv6.ipv6._PACK_STR, self.v_tc_flow,
                            self.payload_length, self.nxt, self.hop_limit,
                            addrconv.ipv6.text_to_bin(self.src),
                            addrconv.ipv6.text_to_bin(self.dst))
     self.buf += self.hop_opts.serialize()
     self.buf += self.auth.serialize()
示例#2
0
 def test_len_re(self):
     size = 5
     auth = ipv6.auth(
         0, size, 256, 1,
         b'\x21\xd3\xa9\x5c\x5f\xfd\x4d\x18\x46\x22\xb9\xf8\xf8\xf8\xf8\xf8'
     )
     eq_((size + 2) * 4, len(auth))
 def setUp(self):
     self.nxt = 0
     self.size = 4
     self.spi = 256
     self.seq = 1
     self.data = '\x21\xd3\xa9\x5c\x5f\xfd\x4d\x18\x46\x22\xb9\xf8'
     self.auth = ipv6.auth(
         self.nxt, self.size, self.spi, self.seq, self.data)
     self.form = '!BB2xII12s'
     self.buf = struct.pack(self.form, self.nxt, self.size, self.spi,
                            self.seq, self.data)
示例#4
0
文件: test_ipv6.py 项目: qsdj/ryu
 def setUp(self):
     self.nxt = 0
     self.size = 4
     self.spi = 256
     self.seq = 1
     self.data = '\x21\xd3\xa9\x5c\x5f\xfd\x4d\x18\x46\x22\xb9\xf8'
     self.auth = ipv6.auth(self.nxt, self.size, self.spi, self.seq,
                           self.data)
     self.form = '!BB2xII12s'
     self.buf = struct.pack(self.form, self.nxt, self.size, self.spi,
                            self.seq, self.data)
    def test_default_args(self):
        hdr = ipv6.auth()
        buf = hdr.serialize()
        LOG.info(repr(buf))
        res = struct.unpack_from(ipv6.auth._PACK_STR, str(buf))
        LOG.info(res)

        eq_(res[0], 6)
        eq_(res[1], 3)
        eq_(res[2], 0)
        eq_(res[3], 0)
        eq_(buf[ipv6.auth._MIN_LEN:], '\x00\x00\x00\x00')
示例#6
0
文件: test_ipv6.py 项目: qsdj/ryu
    def test_default_args(self):
        hdr = ipv6.auth()
        buf = hdr.serialize()
        LOG.info(repr(buf))
        res = struct.unpack_from(ipv6.auth._PACK_STR, str(buf))
        LOG.info(res)

        eq_(res[0], 6)
        eq_(res[1], 2)
        eq_(res[2], 0)
        eq_(res[3], 0)
        eq_(buf[ipv6.auth._MIN_LEN:], '\x00\x00\x00\x00')
示例#7
0
文件: test_ipv6.py 项目: qsdj/ryu
 def setUp_with_auth(self):
     self.auth_nxt = 6
     self.auth_size = 4
     self.auth_spi = 256
     self.auth_seq = 1
     self.auth_data = '\xa0\xe7\xf8\xab\xf9\x69\x1a\x8b\xf3\x9f\x7c\xae'
     self.auth = ipv6.auth(self.auth_nxt, self.auth_size, self.auth_spi,
                           self.auth_seq, self.auth_data)
     self.ext_hdrs = [self.auth]
     self.payload_length += len(self.auth)
     self.nxt = ipv6.auth.TYPE
     self.ip = ipv6.ipv6(self.version, self.traffic_class, self.flow_label,
                         self.payload_length, self.nxt, self.hop_limit,
                         self.src, self.dst, self.ext_hdrs)
     self.buf = struct.pack(ipv6.ipv6._PACK_STR, self.v_tc_flow,
                            self.payload_length, self.nxt, self.hop_limit,
                            addrconv.ipv6.text_to_bin(self.src),
                            addrconv.ipv6.text_to_bin(self.dst))
     self.buf += self.auth.serialize()
 def setUp_with_auth(self):
     self.auth_nxt = 6
     self.auth_size = 4
     self.auth_spi = 256
     self.auth_seq = 1
     self.auth_data = '\xa0\xe7\xf8\xab\xf9\x69\x1a\x8b\xf3\x9f\x7c\xae'
     self.auth = ipv6.auth(
         self.auth_nxt, self.auth_size, self.auth_spi, self.auth_seq,
         self.auth_data)
     self.ext_hdrs = [self.auth]
     self.payload_length += len(self.auth)
     self.nxt = ipv6.auth.TYPE
     self.ip = ipv6.ipv6(
         self.version, self.traffic_class, self.flow_label,
         self.payload_length, self.nxt, self.hop_limit, self.src,
         self.dst, self.ext_hdrs)
     self.buf = struct.pack(
         ipv6.ipv6._PACK_STR, self.v_tc_flow,
         self.payload_length, self.nxt, self.hop_limit,
         addrconv.ipv6.text_to_bin(self.src),
         addrconv.ipv6.text_to_bin(self.dst))
     self.buf += self.auth.serialize()
 def setUp_with_multi_headers(self):
     self.opt1_type = 5
     self.opt1_len = 2
     self.opt1_data = '\x00\x00'
     self.opt2_type = 1
     self.opt2_len = 0
     self.opt2_data = None
     self.options = [
         ipv6.option(self.opt1_type, self.opt1_len, self.opt1_data),
         ipv6.option(self.opt2_type, self.opt2_len, self.opt2_data),
     ]
     self.hop_opts_nxt = ipv6.auth.TYPE
     self.hop_opts_size = 0
     self.hop_opts = ipv6.hop_opts(
         self.hop_opts_nxt, self.hop_opts_size, self.options)
     self.auth_nxt = 6
     self.auth_size = 4
     self.auth_spi = 256
     self.auth_seq = 1
     self.auth_data = '\xa0\xe7\xf8\xab\xf9\x69\x1a\x8b\xf3\x9f\x7c\xae'
     self.auth = ipv6.auth(
         self.auth_nxt, self.auth_size, self.auth_spi, self.auth_seq,
         self.auth_data)
     self.ext_hdrs = [self.hop_opts, self.auth]
     self.payload_length += len(self.hop_opts) + len(self.auth)
     self.nxt = ipv6.hop_opts.TYPE
     self.ip = ipv6.ipv6(
         self.version, self.traffic_class, self.flow_label,
         self.payload_length, self.nxt, self.hop_limit, self.src,
         self.dst, self.ext_hdrs)
     self.buf = struct.pack(
         ipv6.ipv6._PACK_STR, self.v_tc_flow,
         self.payload_length, self.nxt, self.hop_limit,
         addrconv.ipv6.text_to_bin(self.src),
         addrconv.ipv6.text_to_bin(self.dst))
     self.buf += self.hop_opts.serialize()
     self.buf += self.auth.serialize()
示例#10
0
文件: test_ipv6.py 项目: AkiraSuu/ryu
 def test_len_re(self):
     size = 5
     auth = ipv6.auth(
         0, size, 256, 1,
         '\x21\xd3\xa9\x5c\x5f\xfd\x4d\x18\x46\x22\xb9\xf8\xf8\xf8\xf8\xf8')
     eq_((size + 2) * 4, len(auth))