• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python ipv6.option函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中ryu.lib.packet.ipv6.option函数的典型用法代码示例。如果您正苦于以下问题:Python option函数的具体用法?Python option怎么用?Python option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了option函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_default_args

    def test_default_args(self):
        ip = ipv6.ipv6()
        buf = ip.serialize(bytearray(), None)
        res = struct.unpack(ipv6.ipv6._PACK_STR, str(buf))

        eq_(res[0], 6 << 28)
        eq_(res[1], 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('::'))

        # with extension header
        ip = ipv6.ipv6(
            nxt=0, ext_hdrs=[
                ipv6.hop_opts(58, 0, [
                    ipv6.option(5, 2, '\x00\x00'),
                    ipv6.option(1, 0, None)])])
        buf = ip.serialize(bytearray(), None)
        res = struct.unpack(ipv6.ipv6._PACK_STR + '8s', str(buf))

        eq_(res[0], 6 << 28)
        eq_(res[1], 8)
        eq_(res[2], 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')
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:28,代码来源:test_ipv6.py


示例2: setUp_with_dst_opts

 def setUp_with_dst_opts(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.dst_opts_nxt = 6
     self.dst_opts_size = 0
     self.dst_opts = ipv6.dst_opts(
         self.dst_opts_nxt, self.dst_opts_size, self.options)
     self.ext_hdrs = [self.dst_opts]
     self.payload_length += len(self.dst_opts)
     self.nxt = ipv6.dst_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.dst_opts.serialize()
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:28,代码来源:test_ipv6.py


示例3: create_packet

    def create_packet(self, src, dst, srcip, dstip, mld):
        self.logger.debug("")
        # ETHER
        eth = ethernet.ethernet(
#            ethertype=ether.ETH_TYPE_8021Q, dst=dst, src=src)
            ethertype=ether.ETH_TYPE_IPV6, dst=dst, src=src)
# TODO
        """
        # VLAN
        vln = vlan.vlan(vid=100, ethertype=ether.ETH_TYPE_IPV6)
        """
        # IPV6 with Hop-By-Hop
        ext_headers = [ipv6.hop_opts(nxt=inet.IPPROTO_ICMPV6,
                    data=[ipv6.option(type_=5, len_=2, data="\x00\x00"),
                          ipv6.option(type_=1, len_=0)])]
        ip6 = ipv6.ipv6(src=srcip, dst=dstip, hop_limit=1,
                        nxt=inet.IPPROTO_HOPOPTS, ext_hdrs=ext_headers)

        # MLDV2
        if type(mld) == icmpv6.mldv2_query:
            icmp6 = icmpv6_extend(
                type_=icmpv6.MLD_LISTENER_QUERY, data=mld)

        elif type(mld) == icmpv6.mldv2_report:
            icmp6 = icmpv6_extend(
                type_=icmpv6.MLDV2_LISTENER_REPORT, data=mld)

        # ether - vlan - ipv6 - icmpv6 ( - mldv2 )
#        sendpkt = eth / vln / ip6 / icmp6
        sendpkt = eth / ip6 / icmp6
        sendpkt.serialize()
        self.logger.debug("created packet(ryu) : %s", str(sendpkt))

        return sendpkt
开发者ID:t-koshiba,项目名称:trial,代码行数:34,代码来源:mld_process.py


示例4: create_packet

    def create_packet(self, vid, mld):
        self.logger.debug("")

        # VLAN
        vln = vlan.vlan(vid=vid, ethertype=ether.ETH_TYPE_IPV6)

        # Hop-By-Hop
        ext_headers = [ipv6.hop_opts(nxt=inet.IPPROTO_ICMPV6, data=[
            ipv6.option(type_=5, len_=2, data="\x00\x00"),
            ipv6.option(type_=1, len_=0)])]

        # MLDV2_Query
        if type(mld) == icmpv6.mldv2_query:
            eth_dst = self.QUERY_DST
            ip_dst = self.QUERY_DST_IP
            if mld.address != "::":
                ip_str = netaddr.ip.IPAddress(mld.address).\
                    format(netaddr.ipv6_verbose())
                eth_dst = "33:33:" + ip_str[30:32] + ":" + \
                    ip_str[32:34] + ":" + ip_str[35:37] + ":" + ip_str[37:39]
                ip_dst = mld.address

            # ETHER
            eth = ethernet.ethernet(
                ethertype=ether.ETH_TYPE_8021Q,
                src=self.ifinfo[self.IF_KEY_MAC], dst=eth_dst)

            # IPV6 with ExtensionHeader
            ip6 = ipv6.ipv6(
                src=self.ifinfo[self.IF_KEY_IP6], dst=ip_dst,
                hop_limit=1, nxt=inet.IPPROTO_HOPOPTS, ext_hdrs=ext_headers)

            # MLD Query
            icmp6 = icmpv6_extend(
                type_=icmpv6.MLD_LISTENER_QUERY, data=mld)

        # MLDV2_Report
        elif type(mld) == icmpv6.mldv2_report:
            # ETHER
            eth = ethernet.ethernet(
                ethertype=ether.ETH_TYPE_8021Q,
                src=self.ifinfo[self.IF_KEY_MAC], dst=self.REPORT_DST)

            # IPV6 with ExtensionHeader
            ip6 = ipv6.ipv6(
                src=self.ifinfo[self.IF_KEY_IP6], dst=self.REPORT_DST_IP,
                hop_limit=1, nxt=inet.IPPROTO_HOPOPTS, ext_hdrs=ext_headers)

            # MLD Report
            icmp6 = icmpv6_extend(
                type_=icmpv6.MLDV2_LISTENER_REPORT, data=mld)

        # ether - vlan - ipv6 - icmpv6 ( - mldv2 )
        sendpkt = eth / vln / ip6 / icmp6
        sendpkt.serialize()
        self.logger.debug("created packet(ryu) : %s", str(sendpkt))

        return sendpkt
开发者ID:ntts-clo,项目名称:mld-ryu,代码行数:58,代码来源:mld_process.py


示例5: setUp

 def setUp(self):
     self.type_ = 1
     self.len_ = 0
     self.data = None
     self.opt = ipv6.option(self.type_, self.len_, self.data)
     self.form = '!BB'
     self.buf = struct.pack(self.form, self.type_, self.len_)
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:7,代码来源:test_ipv6.py


示例6: test_default_args

    def test_default_args(self):
        hdr = ipv6.hop_opts()
        buf = hdr.serialize()
        res = struct.unpack('!BB', six.binary_type(buf[:2]))

        eq_(res[0], 6)
        eq_(res[1], 0)
        opt = ipv6.option(type_=1, len_=4, data=b'\x00\x00\x00\x00')
        eq_(six.binary_type(buf[2:]), opt.serialize())
开发者ID:Aries-Sushi,项目名称:ryu,代码行数:9,代码来源:test_ipv6.py


示例7: test_create_packet

    def test_create_packet(self):
        addressinfo = ["00:11:22:33:44:55", "66:55:44:33:22:11",
                       "1111::2222", "9999::8888"]
        
        eth = ethernet.ethernet(
            ethertype=ether.ETH_TYPE_IPV6, 
            src=addressinfo[0], dst=addressinfo[1])

        ext_headers = [ipv6.hop_opts(nxt=inet.IPPROTO_ICMPV6,
                    data=[ipv6.option(type_=5, len_=2, data="\x00\x00"),
                          ipv6.option(type_=1, len_=0)])]
        ip6 = ipv6.ipv6(src=addressinfo[2], dst=addressinfo[3],
                        hop_limit=1, nxt=inet.IPPROTO_HOPOPTS,
                        ext_hdrs=ext_headers)

        mld = icmpv6.mldv2_query(address="1234::6789", 
                                 srcs=["9876::4321"])

        icmp6 = icmpv6_extend(
                type_=icmpv6.MLD_LISTENER_QUERY, data=mld)

        expect = eth / ip6 / icmp6
        expect.serialize()
        
        actual = self.mld_proc.create_packet(addressinfo, mld)
        
        exp_eth = expect.get_protocols(ethernet.ethernet)
        exp_ip6 = expect.get_protocols(ipv6.ipv6)
        exp_extend = exp_ip6[0]
        exp_icmp6 = expect.get_protocols(icmpv6.icmpv6)
        exp_mld = exp_icmp6[0].data
        
        act_eth = actual.get_protocols(ethernet.ethernet)
        act_ip6 = actual.get_protocols(ipv6.ipv6)
        act_extend = act_ip6[0].ext_hdrs
        act_icmp6 = actual.get_protocols(icmpv6.icmpv6)
        act_mld = act_icmp6[0].data

        # TODO 確認方法
        eq_(expect.data, actual.data)
        """
开发者ID:t-koshiba,项目名称:trial,代码行数:41,代码来源:test_mld_process.py


示例8: setUp_with_multi_headers

 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()
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:37,代码来源:test_ipv6.py



注:本文中的ryu.lib.packet.ipv6.option函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python lldp.lldp函数代码示例发布时间:2022-05-27
下一篇:
Python ipv6.ipv6函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap