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

Python pack_utils.msg_pack_into函数代码示例

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

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



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

示例1: serialize_body

 def serialize_body(self):
     data = bytearray()
     msg_pack_into(self._fmt_str, data, 0,
                   self.clause,
                   self.n_clauses,
                   self.id)
     return data
开发者ID:dx-entity,项目名称:env_controller,代码行数:7,代码来源:nx_actions.py


示例2: _make_exp_hdr

def _make_exp_hdr(oxx, mod, n):
    exp_hdr = bytearray()
    try:
        get_desc = getattr(mod, '_' + oxx + '_field_desc')
        desc = get_desc(n)
    except KeyError:
        return n, exp_hdr
    if desc._class == OFPXXC_EXPERIMENTER:
        (exp_id, exp_type) = n
        assert desc.experimenter_id == exp_id
        oxx_type = getattr(desc, oxx + '_type')
        if hasattr(desc, 'exp_type'):  # XXX
            # XXX
            # This block implements EXT-256 style experimenter OXM.
            assert desc.exp_type == 2560
            exp_hdr_pack_str = '!IH'  # experimenter_id, exp_type
            msg_pack_into(exp_hdr_pack_str, exp_hdr, 0,
                          desc.experimenter_id, desc.exp_type)
        else:
            assert oxx_type == exp_type
            exp_hdr_pack_str = '!I'  # experimenter_id
            msg_pack_into(exp_hdr_pack_str, exp_hdr, 0,
                          desc.experimenter_id)
        assert len(exp_hdr) == struct.calcsize(exp_hdr_pack_str)
        n = oxx_type
        assert (n >> 7) == OFPXXC_EXPERIMENTER
    return n, exp_hdr
开发者ID:gdesta,项目名称:ryu,代码行数:27,代码来源:oxx_fields.py


示例3: serialize

    def serialize(self, payload=None, prev=None):
        present = 0
        hdr = bytearray()
        optional = bytearray()

        if self.checksum is not None:
            present |= GRE_CHECKSUM_FLG

            # For purposes of computing the checksum,
            # the value of the checksum field is zero.
            # Also, because Reserved1 is always 0x00 of 2 bytes,
            # Set in conjunction with checksum.
            optional += b'\x00' * self._CHECKSUM_LEN

        if self._key is not None:
            present |= GRE_KEY_FLG
            optional += struct.pack(self._KEY_PACK_STR, self._key)

        if self.seq_number is not None:
            present |= GRE_SEQUENCE_NUM_FLG
            optional += struct.pack(self._SEQNUM_PACK_STR, self.seq_number)

        msg_pack_into(self._PACK_STR, hdr, 0, present, self.version,
                      self.protocol)

        hdr += optional

        if self.checksum:
            self.checksum = packet_utils.checksum(hdr)
            struct.pack_into(self._CHECKSUM_PACK_STR, hdr, self._MIN_LEN,
                             self.checksum)

        return hdr
开发者ID:5g-empower,项目名称:empower-ryu,代码行数:33,代码来源:gre.py


示例4: _serialize_body

 def _serialize_body(self):
     self.serialize_req_header()
     offset = ofproto.OFP_HEADER_SIZE + EVT_HEADER_SIZE + EVT_REQUEST_HEADER_SIZE
     msg_pack_into(EVT_PORT_TIMER_REQUEST_PACK_STR, self.buf, offset,
         self.port_no,self.event_conditions,
         self.interval_sec,self.interval_msec,
         self.threshold_tx_packets,self.threshold_tx_bytes,
         self.threshold_rx_packets,self.threshold_rx_bytes)
开发者ID:BenjaminUJun,项目名称:ryu-event,代码行数:8,代码来源:event_message_ofp10.py


示例5: _serialize_subfield

 def _serialize_subfield(subfield):
     (field, ofs) = subfield
     buf = bytearray()
     n = ofp.oxm_from_user_header(field)
     ofp.oxm_serialize_header(n, buf, 0)
     assert len(buf) == 4  # only 4-bytes NXM/OXM are defined
     msg_pack_into('!H', buf, 4, ofs)
     return buf
开发者ID:AndrewArcher,项目名称:ryu,代码行数:8,代码来源:nx_actions.py


示例6: _serialize

def _serialize(mod, num, value, mask, buf, offset):
    num, exp_hdr = _make_exp_hdr(mod, num)
    exp_hdr_len = len(exp_hdr)
    value_len = len(value)
    pack_str = "!I%ds%ds" % (exp_hdr_len, value_len,)
    msg_pack_into(pack_str, buf, offset,
                  (num << 9) | (0 << 8) | (exp_hdr_len + value_len),
                  bytes(exp_hdr), value)
    return struct.calcsize(pack_str)
开发者ID:jalilm,项目名称:ryu,代码行数:9,代码来源:oxs_fields.py


示例7: _serialize_header

def _serialize_header(mod, n, buf, offset):
    try:
        desc = mod._oxm_field_desc(n)
        value_len = desc.type.size
    except KeyError:
        value_len = 0
    n, exp_hdr = _make_exp_hdr(mod, n)
    exp_hdr_len = len(exp_hdr)
    pack_str = "!I%ds" % (exp_hdr_len,)
    msg_pack_into(pack_str, buf, offset, (n << 9) | (0 << 8) | (exp_hdr_len + value_len), bytes(exp_hdr))
    return struct.calcsize(pack_str)
开发者ID:hyqdvd,项目名称:ryuCode,代码行数:11,代码来源:oxm_fields.py


示例8: _serialize_body

 def _serialize_body(self):
     self.serialize_req_header()
     offset = EVT_REQUEST_HEADER_SIZE
     msg_pack_into(OFP13_FLOW_REQUEST_PACK_STR,self.data,offset,
         self.event_conditions,self.interval_sec,self.interval_msec,
         self.threshold_new_match_packets,self.threshold_new_match_bytes,
         self.threshold_total_match_packets,self.threshold_total_match_bytes,
         self.table_id,self.out_port,self.out_group,self.flow_cookie,self.cookie_mask
         )
     offset += 72
     
     self.match.serialize(self.data,offset)
     ofproto_parser.OFPExperimenter._serialize_body(self)
开发者ID:BenjaminUJun,项目名称:ryu-event,代码行数:13,代码来源:event_message_ofp13.py


示例9: serialize

 def serialize(self, buf, offset):
     data = self.serialize_body()
     payload_offset = (
         ofp.OFP_ACTION_EXPERIMENTER_HEADER_SIZE +
         struct.calcsize(NXAction._fmt_str)
     )
     self.len = utils.round_up(payload_offset + len(data), 8)
     super(NXAction, self).serialize(buf, offset)
     msg_pack_into(NXAction._fmt_str,
                   buf,
                   offset + ofp.OFP_ACTION_EXPERIMENTER_HEADER_SIZE,
                   self.subtype)
     buf += data
开发者ID:dx-entity,项目名称:env_controller,代码行数:13,代码来源:nx_actions.py


示例10: serialize

 def serialize(self, buf, offset):
     data = bytearray()
     msg_pack_into(NXActionResubmitTable._fmt_str, data, 0,
                   self.in_port,
                   self.table_id)
     payload_offset = (
         ofp.OFP_ACTION_EXPERIMENTER_HEADER_SIZE +
         struct.calcsize(NXAction._fmt_str)
     )
     self.len = utils.round_up(payload_offset + len(data), 8)
     super(NXActionResubmitTable, self).serialize(buf, offset)
     msg_pack_into('!%ds' % len(data), buf, offset + payload_offset,
                   bytes(data))
开发者ID:AndrewArcher,项目名称:ryu,代码行数:13,代码来源:nx_actions.py


示例11: _serialize

def _serialize(mod, n, value, mask, buf, offset):
    n, exp_hdr = _make_exp_hdr(mod, n)
    exp_hdr_len = len(exp_hdr)
    value_len = len(value)
    if mask:
        assert value_len == len(mask)
        pack_str = "!I%ds%ds%ds" % (exp_hdr_len, value_len, len(mask))
        msg_pack_into(
            pack_str, buf, offset, (n << 9) | (1 << 8) | (exp_hdr_len + value_len * 2), bytes(exp_hdr), value, mask
        )
    else:
        pack_str = "!I%ds%ds" % (exp_hdr_len, value_len)
        msg_pack_into(pack_str, buf, offset, (n << 9) | (0 << 8) | (exp_hdr_len + value_len), bytes(exp_hdr), value)
    return struct.calcsize(pack_str)
开发者ID:hyqdvd,项目名称:ryuCode,代码行数:14,代码来源:oxm_fields.py


示例12: OFPExpStateStatsMultipartRequest

def OFPExpStateStatsMultipartRequest(datapath, flags=0, table_id=ofproto.OFPTT_ALL, state=None, match=None):
    get_from_state = 1
    if state is None:
        get_from_state = 0
        state = 0
        
    if match is None:
        match = ofproto_parser.OFPMatch()

    data=bytearray()
    msg_pack_into(osproto.OFP_STATE_STATS_REQUEST_0_PACK_STR, data, 0, table_id, get_from_state, state)
    
    offset=osproto.OFP_STATE_STATS_REQUEST_0_SIZE
    match.serialize(data, offset)

    exp_type=osproto.OFPMP_EXP_STATE_STATS
    return ofproto_parser.OFPExperimenterStatsRequest(datapath=datapath, flags=flags, experimenter=0xBEBABEBA, exp_type=exp_type, data=data)
开发者ID:uiuc-srg,项目名称:ryu,代码行数:17,代码来源:openstate_v1_0_parser.py


示例13: _make_exp_hdr

def _make_exp_hdr(mod, num):
    exp_hdr = bytearray()
    try:
        desc = mod._oxs_field_desc(num)
    except KeyError:
        return num, exp_hdr
    if isinstance(desc, Experimenter):  # XXX
        (exp_id, exp_type) = num
        assert desc.experimenter_id == exp_id
        assert desc.oxs_type == exp_type
        exp_hdr_pack_str = '!I'  # experimenter_id
        msg_pack_into(exp_hdr_pack_str, exp_hdr, 0,
                      desc.experimenter_id)
        assert len(exp_hdr) == struct.calcsize(exp_hdr_pack_str)
        num = desc.oxs_type
        assert (num >> 7) == OFPXSC_EXPERIMENTER
    return num, exp_hdr
开发者ID:jalilm,项目名称:ryu,代码行数:17,代码来源:oxs_fields.py


示例14: serialize

        def serialize(self, buf, offset):
            hdr_data = bytearray()
            n = ofp.oxm_from_user_header(self.dst)
            ofp.oxm_serialize_header(n, hdr_data, 0)
            (dst_num,) = struct.unpack_from('!I', six.binary_type(hdr_data), 0)

            ofs_nbits = (self.ofs << 6) + self.nbits - 1
            data = bytearray()
            msg_pack_into(NXActionRegLoad._fmt_str, data, 0,
                          ofs_nbits, dst_num, self.value)
            payload_offset = (
                ofp.OFP_ACTION_EXPERIMENTER_HEADER_SIZE +
                struct.calcsize(NXAction._fmt_str)
            )
            self.len = utils.round_up(payload_offset + len(data), 8)
            super(NXActionRegLoad, self).serialize(buf, offset)
            msg_pack_into('!%ds' % len(data), buf, offset + payload_offset,
                          bytes(data))
开发者ID:Aries-Sushi,项目名称:ryu,代码行数:18,代码来源:nx_actions.py


示例15: _test_msg_pack_into

    def _test_msg_pack_into(self, offset_type='e'):
        fmt = '!HH'
        len_ = struct.calcsize(fmt)
        buf = bytearray(len_)
        offset = len_
        arg1 = 1
        arg2 = 2

        if offset_type == 'l':
            offset += 1
        elif offset_type == 'g':
            offset -= 1

        pack_utils.msg_pack_into(fmt, buf, offset, arg1, arg2)

        check_offset = len(buf) - len_
        res = struct.unpack_from(fmt, six.binary_type(buf), check_offset)

        eq_(arg1, res[0])
        eq_(arg2, res[1])

        return True
开发者ID:5g-empower,项目名称:empower-ryu,代码行数:22,代码来源:test_pack_utils.py


示例16: _make_exp_hdr

def _make_exp_hdr(mod, n):
    exp_hdr = bytearray()
    try:
        desc = mod._oxm_field_desc(n)
    except KeyError:
        return n, exp_hdr
    if isinstance(desc, _Experimenter):  # XXX
        (exp_id, exp_type) = n
        assert desc.experimenter_id == exp_id
        if isinstance(desc, OldONFExperimenter):  # XXX
            # XXX
            # This block implements EXT-256 style experimenter OXM.
            exp_hdr_pack_str = "!IH"  # experimenter_id, exp_type
            msg_pack_into(exp_hdr_pack_str, exp_hdr, 0, desc.experimenter_id, desc.exp_type)
        else:
            assert desc.oxm_type == exp_type
            exp_hdr_pack_str = "!I"  # experimenter_id
            msg_pack_into(exp_hdr_pack_str, exp_hdr, 0, desc.experimenter_id)
        assert len(exp_hdr) == struct.calcsize(exp_hdr_pack_str)
        n = desc.oxm_type
        assert (n >> 7) == OFPXMC_EXPERIMENTER
    return n, exp_hdr
开发者ID:hyqdvd,项目名称:ryuCode,代码行数:22,代码来源:oxm_fields.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python arp.arp函数代码示例发布时间:2022-05-27
下一篇:
Python ofctl_utils.send_stats_request函数代码示例发布时间: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