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

Python ofproto_parser.msg函数代码示例

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

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



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

示例1: test_check_msg_parser

    def test_check_msg_parser(self):
        (version,
         msg_type,
         msg_len,
         xid) = ofproto_parser.header(self.bufPacketIn)

        version = 0xff
        ofproto_parser.msg(self,
                           version,
                           msg_type,
                           msg_len,
                           xid,
                           self.bufPacketIn)
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:13,代码来源:test_ofproto_parser.py


示例2: SBP_handler

    def SBP_handler(self, ev):
        # Parser the msg and raise an event.
        # Handle event in service or app.
        msg = ev.msg
        domain = msg.domain
        data = msg.data

        if domain.sbp_proto_type == oxproto_v1_0.OXPS_OPENFLOW:
            buf = bytearray()
            required_len = ofproto_common.OFP_HEADER_SIZE

            if len(data) == 0:
                return
            buf += data
            while len(buf) >= required_len:
                (version, msg_type, msg_len, xid) = ofproto_parser.header(buf)
                self.logger.debug('ofp msg %s cls %s', msg, msg.__class__)
                required_len = msg_len
                if len(buf) < required_len:
                    break

                msg = ofproto_parser.msg(self.fake_datapath,
                                         version, msg_type, msg_len, xid, buf)
                if msg:
                    ev = oxp_event.sbp_to_oxp_msg_to_ev(msg)
                    ev.domain = domain
                    self.send_event_to_observers(ev, MAIN_DISPATCHER)

                buf = buf[required_len:]
                required_len = ofproto_common.OFP_HEADER_SIZE
开发者ID:Jasonlyt,项目名称:ryu,代码行数:30,代码来源:oxp_server_handler.py


示例3: _test_msg

    def _test_msg(self, name, wire_msg, json_str):
        json_dict = json.loads(json_str)
        # on-wire -> OFPxxx -> json
        (version, msg_type, msg_len, xid) = ofproto_parser.header(wire_msg)
        try:
            has_parser, has_serializer = implemented[version][msg_type]
        except KeyError:
            has_parser = True
            has_serializer = True

        dp = DummyDatapath(*self._ofp_versions[version])
        if has_parser:
            msg = ofproto_parser.msg(dp, version, msg_type, msg_len, xid,
                                     wire_msg)
            json_dict2 = self._msg_to_jsondict(msg)
            # XXXdebug code
            open(('/tmp/%s.json' % name), 'wb').write(json.dumps(json_dict2))
            eq_(json_dict, json_dict2)

        # json -> OFPxxx -> json
        msg2 = self._jsondict_to_msg(dp, json_dict)
        if has_serializer:
            msg2.serialize()
            eq_(self._msg_to_jsondict(msg2), json_dict)
            eq_(wire_msg, msg2.buf)
开发者ID:rnudechu,项目名称:ryu,代码行数:25,代码来源:test_parser.py


示例4: blocking_read_sdn_message

    def blocking_read_sdn_message(self,block_read_written=False):
        '''
        @returns an SDN message
        '''
        reader_method = self._sdn_socket.blocking_read
        if block_read_written:
            reader_method = self._sdn_socket.blocking_read_written
        
        # first read openflow header
        msg_buffer = reader_method(OFP_HEADER_SIZE)
        while len(msg_buffer) != OFP_HEADER_SIZE:
            diff = OFP_HEADER_SIZE - len(msg_buffer)
            msg_buffer.extend(reader_method(diff))

        # based on size of openflow header, decide how much more to
        # read
        (version, msg_type, msg_len, xid) = ofproto_parser.header(msg_buffer)

        while len(msg_buffer) != msg_len:
            diff = msg_len - len(msg_buffer)
            msg_buffer.extend(reader_method(diff))
        
        msg = ofproto_parser.msg(
            _OF_1_0_DATAPATH, version, msg_type, msg_len,
            xid, str(msg_buffer))

        msg.original_buffer = msg_buffer
        return msg
开发者ID:bmistree,项目名称:sdn_fuzz,代码行数:28,代码来源:sdn_message_reader.py


示例5: _recv_loop

    def _recv_loop(self):
        buf = bytearray()
        required_len = ofproto_common.OFP_HEADER_SIZE

        count = 0
        while self.is_active:
            ret = self.socket.recv(required_len)
            if len(ret) == 0:
                self.is_active = False
                break
            buf += ret
            while len(buf) >= required_len:
                (version, msg_type, msg_len, xid) = ofproto_parser.header(buf)
                required_len = msg_len
                if len(buf) < required_len:
                    break

                msg = ofproto_parser.msg(self,
                                         version, msg_type, msg_len, xid, buf)
                # LOG.debug('queue msg %s cls %s', msg, msg.__class__)
                if msg:
                    self.principal_connection.receive_principal_message(msg)

                buf = buf[required_len:]
                required_len = ofproto_common.OFP_HEADER_SIZE

                # We need to schedule other greenlets. Otherwise, ryu
                # can't accept new switches or handle the existing
                # switches. The limit is arbitrary. We need the better
                # approach in the future.
                count += 1
                if count > 2048:
                    count = 0
                    hub.sleep(0)
开发者ID:bmistree,项目名称:pluribus,代码行数:34,代码来源:principal_datapath.py


示例6: handle_event

    def handle_event(self, header, msg):
        #required_len = self.ofp.OFP_HEADER_SIZE
        ret = bytearray(msg)
        (version, msg_type, msg_len, xid) = ofproto_parser.header(ret)
        self.netide_xid = header[NetIDEOps.NetIDE_header['XID']]
        msg = ofproto_parser.msg(self, version, msg_type, msg_len, xid, ret)

        if msg:
            ev = ofp_event.ofp_msg_to_ev(msg)
            event_observers = self.ofp_brick.get_observers(ev,self.state)
            module_id = header[NetIDEOps.NetIDE_header['MOD_ID']]
            for key, value in self.channel.running_modules.iteritems():
                if value == module_id and key in event_observers:
                    module_brick = ryu.base.app_manager.lookup_service_brick(key)
                    module_brick_handlers = module_brick.get_handlers(ev)
                    for handler in module_brick_handlers:
                        handler(ev)
                    break

            # Sending the FENCE message to the Core only if self.netide_xid is not 0
            if self.netide_xid is not 0:
                msg_to_send = NetIDEOps.netIDE_encode('NETIDE_FENCE', self.netide_xid, module_id, 0, "")
                self.channel.socket.send(msg_to_send)

            dispatchers = lambda x: x.callers[ev.__class__].dispatchers
            handlers = [handler for handler in
                        self.ofp_brick.get_handlers(ev) if
                        self.state in dispatchers(handler)]

            for handler in handlers:
                handler(ev)

            # Resetting netide_xid to zero
            self.netide_xid = 0
开发者ID:fp7-netide,项目名称:Engine,代码行数:34,代码来源:ryu-backend.py


示例7: SBP_handler

    def SBP_handler(self, ev):
        # parser the msg and handle the SBP message.
        # raise the event.
        # finish it in service or app.
        msg = ev.msg
        domain = msg.domain
        data = msg.data

        if CONF.sbp_proto_type == oxproto_v1_0.OXPS_OPENFLOW:
            buf = bytearray()
            required_len = ofproto_common.OFP_HEADER_SIZE

            if len(data) == 0:
                return
            buf += data
            while len(buf) >= required_len:
                (version, msg_type, msg_len, xid) = ofproto_parser.header(buf)

                required_len = msg_len
                if len(buf) < required_len:
                    break

                msg = ofproto_parser.msg(self.network_aware.fake_datapath,
                                         version, msg_type, msg_len, xid, buf)
                if msg:
                    ev = oxp_event.sbp_to_oxp_msg_to_ev(msg)
                    ev.domain = domain
                    self.send_event_to_observers(ev, MAIN_DISPATCHER)

                buf = buf[required_len:]
                required_len = ofproto_common.OFP_HEADER_SIZE
开发者ID:Jasonlyt,项目名称:ryu,代码行数:31,代码来源:oxp_client_handler.py


示例8: _on_message

 def _on_message(self, data):
     (version, msg_type, msg_len, xid) = ofproto_parser.header(self._msg_header)
     assert len(data) == msg_len - ofproto_common.OFP_HEADER_SIZE
     msg = ofproto_parser.msg(self, version, msg_type, msg_len, xid, self._msg_header+data)
     logging.getLogger("openflow").debug("RECV %s %s" % (self.address, msg))
     self.dispatch(msg)
     if not self.stream.closed():
         self.stream.read_bytes(ofproto_common.OFP_HEADER_SIZE, stack_context.wrap(self._on_header))
开发者ID:hkwi,项目名称:hkwi_seeds,代码行数:8,代码来源:ryu_tornado.py


示例9: _recv_loop

    def _recv_loop(self):
        buf = bytearray()
        required_len = ofproto_common.OFP_HEADER_SIZE

        count = 0
        while self.state != DEAD_DISPATCHER:
            ret = ""

            try:
                ret = self.socket.recv(required_len)
            except SocketTimeout:
                continue
            except ssl.SSLError:
                # eventlet throws SSLError (which is a subclass of IOError)
                # on SSL socket read timeout; re-try the loop in this case.
                continue
            except (EOFError, IOError):
                break

            if len(ret) == 0:
                break

            buf += ret
            while len(buf) >= required_len:
                (version, msg_type, msg_len, xid) = ofproto_parser.header(buf)
                required_len = msg_len
                if len(buf) < required_len:
                    break

                msg = ofproto_parser.msg(
                    self, version, msg_type, msg_len, xid, buf[:msg_len])
                # LOG.debug('queue msg %s cls %s', msg, msg.__class__)
                if msg:
                    ev = ofp_event.ofp_msg_to_ev(msg)
                    self.ofp_brick.send_event_to_observers(ev, self.state)

                    dispatchers = lambda x: x.callers[ev.__class__].dispatchers
                    handlers = [handler for handler in
                                self.ofp_brick.get_handlers(ev) if
                                self.state in dispatchers(handler)]
                    for handler in handlers:
                        handler(ev)

                buf = buf[required_len:]
                required_len = ofproto_common.OFP_HEADER_SIZE

                # We need to schedule other greenlets. Otherwise, ryu
                # can't accept new switches or handle the existing
                # switches. The limit is arbitrary. We need the better
                # approach in the future.
                count += 1
                if count > 2048:
                    count = 0
                    hub.sleep(0)
开发者ID:KooDongSoo,项目名称:ryu,代码行数:54,代码来源:controller.py


示例10: _recv_loop

    def _recv_loop(self):
        buf = bytearray()
        required_len = ofproto_common.OFP_HEADER_SIZE

        count = 0
        while True:
            ret = ""

            try:
                ret = self.socket.recv(required_len)
            except:
                # Hit socket timeout; decide what to do.
                if self.close_requested:
                    pass
                else:
                    continue

            if (len(ret) == 0) or (self.close_requested):
                self.socket.close()
                break

            buf += ret
            while len(buf) >= required_len:
                (version, msg_type, msg_len, xid) = ofproto_parser.header(buf)
                required_len = msg_len
                if len(buf) < required_len:
                    break

                msg = ofproto_parser.msg(
                    self, version, msg_type, msg_len, xid, buf[:msg_len])
                # LOG.debug('queue msg %s cls %s', msg, msg.__class__)
                if msg:
                    ev = ofp_event.ofp_msg_to_ev(msg)
                    self.ofp_brick.send_event_to_observers(ev, self.state)

                    dispatchers = lambda x: x.callers[ev.__class__].dispatchers
                    handlers = [handler for handler in
                                self.ofp_brick.get_handlers(ev) if
                                self.state in dispatchers(handler)]
                    for handler in handlers:
                        handler(ev)

                buf = buf[required_len:]
                required_len = ofproto_common.OFP_HEADER_SIZE

                # We need to schedule other greenlets. Otherwise, ryu
                # can't accept new switches or handle the existing
                # switches. The limit is arbitrary. We need the better
                # approach in the future.
                count += 1
                if count > 2048:
                    count = 0
                    hub.sleep(0)
开发者ID:alexgpg,项目名称:ryu,代码行数:53,代码来源:controller.py


示例11: error_msg_handler

 def error_msg_handler(self, ev):
     err_msg = ev.msg
     #self.logger.info('OFPErrorMsg received: type=0x%02x code=0x%02x message=%s', msg.type, msg.code, utils.hex_array(msg.data))
     if err_msg.type == ofproto_v1_3.OFPET_FLOW_MOD_FAILED and err_msg.code == ofproto_v1_3.OFPFMFC_TABLE_FULL:
         print 'caputred full table error message'
         self.rand_remove(err_msg.datapath)
         #parser = err_msg.datapath.ofproto_parser
         (version,msg_type,msg_len,xid)= ofproto_parser.header(err_msg.data)
         print 'version %s, msg_type %s, msg_len %s, xid %s, len %s' % (version, msg_type, msg_len, xid, len(err_msg.data))
         msg = ofproto_parser.msg(err_msg.datapath, version,msg_type,msg_len,xid,err_msg.data)
         #controller will assign a new xid
         msg.xid=None
         error_msg.datapath.send_msg(msg)
开发者ID:JunanDang,项目名称:CAB_SDN_HELPER,代码行数:13,代码来源:table_overflow.py


示例12: testPacketIn

    def testPacketIn(self):
        (version,
         msg_type,
         msg_len,
         xid) = ofproto_parser.header(self.bufPacketIn)

        msg = ofproto_parser.msg(self,
                                 version,
                                 msg_type,
                                 msg_len,
                                 xid,
                                 self.bufPacketIn)
        LOG.debug(msg)
        ok_(isinstance(msg, ofproto_v1_0_parser.OFPPacketIn))
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:14,代码来源:test_ofproto_parser.py


示例13: recv_ofp

    def recv_ofp(self):
        logging.debug("%s", binascii.hexlify(self.data))

        self.recv(ofproto_common.OFP_HEADER_SIZE)
        version, msg_type, msg_len, xid = ofproto_parser.header(self.data)

        self.recv(msg_len)

        msg = ofproto_parser.msg(self,
                                 version, msg_type, msg_len, xid, self.data[:msg_len])

        self.data = self.data[msg_len:]

        return msg
开发者ID:1514louluo,项目名称:lagopus,代码行数:14,代码来源:ofp_datapath.py


示例14: _test_msg

    def _test_msg(self, name, wire_msg, json_str):
        json_dict = json.loads(json_str)
        # on-wire -> OFPxxx -> json
        (version, msg_type, msg_len, xid) = ofproto_parser.header(wire_msg)
        try:
            has_parser, has_serializer = implemented[version][msg_type]
        except KeyError:
            has_parser = True
            has_serializer = True

        dp = DummyDatapath(*self._ofp_versions[version])
        if has_parser:
            msg = ofproto_parser.msg(dp, version, msg_type, msg_len, xid,
                                     wire_msg)
            json_dict2 = self._msg_to_jsondict(msg)
            # XXXdebug code
            open(('/tmp/%s.json' % name), 'wb').write(json.dumps(json_dict2))
            eq_(json_dict, json_dict2)

        # json -> OFPxxx -> json
        msg2 = self._jsondict_to_msg(dp, json_dict)
        if has_serializer:
            msg2.serialize()
            eq_(self._msg_to_jsondict(msg2), json_dict)
            eq_(wire_msg, msg2.buf)

            # check if "len" "length" fields can be omitted

            def _remove(d, names):
                f = lambda x: _remove(x, names)
                if isinstance(d, list):
                    return map(f, d)
                if isinstance(d, dict):
                    d2 = {}
                    for k, v in d.iteritems():
                        if k in names:
                            continue
                        d2[k] = f(v)
                    return d2
                return d

            json_dict3 = _remove(json_dict, ['len', 'length'])
            msg3 = self._jsondict_to_msg(dp, json_dict3)
            msg3.serialize()
            eq_(wire_msg, msg3.buf)

            msg2.serialize()
            eq_(wire_msg, msg2.buf)
开发者ID:aryantaheri,项目名称:ryu,代码行数:48,代码来源:test_parser.py


示例15: testFeaturesReply

    def testFeaturesReply(self):
        (version,
         msg_type,
         msg_len,
         xid) = ofproto_parser.header(self.bufFeaturesReply)

        msg = ofproto_parser.msg(self,
                                 version,
                                 msg_type,
                                 msg_len,
                                 xid,
                                 self.bufFeaturesReply)
        LOG.debug(msg)

        ok_(isinstance(msg, ofproto_v1_0_parser.OFPSwitchFeatures))
        LOG.debug(msg.ports[65534])
        ok_(isinstance(msg.ports[1], ofproto_v1_0_parser.OFPPhyPort))
        ok_(isinstance(msg.ports[2], ofproto_v1_0_parser.OFPPhyPort))
        ok_(isinstance(msg.ports[65534], ofproto_v1_0_parser.OFPPhyPort))
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:19,代码来源:test_ofproto_parser.py


示例16: handle_event

    def handle_event(self, header, msg, of_proto):
        #required_len = self.ofp.OFP_HEADER_SIZE
        ret = bytearray(msg)
        (version, msg_type, msg_len, xid) = ofproto_parser.header(ret)
        self.netide_xid = header[NetIDEOps.NetIDE_header['XID']]
        msg = ofproto_parser.msg(self, version, msg_type, msg_len, xid, ret)

        if msg:
            ev = ofp_event.ofp_msg_to_ev(msg)
            event_observers = self.ofp_brick.get_observers(ev,self.state)
            module_id = header[NetIDEOps.NetIDE_header['MOD_ID']]
            for key, value in self.channel.running_modules.iteritems():
                if value == module_id and key in event_observers:
                    module_brick = ryu.base.app_manager.lookup_service_brick(key)
                    module_brick_handlers = module_brick.get_handlers(ev)
                    for handler in module_brick_handlers:
                        handler(ev)
                    break

            # Sending the FENCE message to the Core only if self.netide_xid is not 0
            if self.netide_xid is not 0:
                msg_to_send = NetIDEOps.netIDE_encode('NETIDE_FENCE', self.netide_xid, module_id, 0, "")
                self.channel.socket.send(msg_to_send)

            dispatchers = lambda x: x.callers[ev.__class__].dispatchers
            handlers = [handler for handler in
                        self.ofp_brick.get_handlers(ev) if
                        self.state in dispatchers(handler)]

            for handler in handlers:
                # we record that we received a feature reply from that specific device
                if msg_type == of_proto.OFPT_FEATURES_REPLY:
                    self.datapath_init[msg.datapath.id] = True

                # we do not allow multipart messages until the feature_reply has been received (needed for OF1.3 or higher)
                if of_proto.OFP_VERSION >= 0x04:
                    if msg_type == of_proto.OFPT_MULTIPART_REPLY and msg.datapath.id not in self.datapath_init:
                        break

                handler(ev)

            # Resetting netide_xid to zero
            self.netide_xid = 0
开发者ID:fp7-netide,项目名称:Engine,代码行数:43,代码来源:ryu-backend.py


示例17: _recv_loop

    def _recv_loop(self):
        buf = bytearray()
        required_len = ofproto_common.OFP_HEADER_SIZE

        count = 0
        while self.is_active:
            ret = self.socket.recv(required_len)
            if len(ret) == 0:
                self.is_active = False
                break
            buf += ret
            while len(buf) >= required_len:
                (version, msg_type, msg_len, xid) = ofproto_parser.header(buf)
                required_len = msg_len
                if len(buf) < required_len:
                    break

                msg = ofproto_parser.msg(self,
                                         version, msg_type, msg_len, xid, buf)
                #LOG.debug('queue msg %s cls %s', msg, msg.__class__)
                if msg:
                    ev = ofp_event.ofp_msg_to_ev(msg)
                    self.ofp_brick.send_event_to_observers(ev, self.state)

                    handlers = [handler for handler in
                                self.ofp_brick.get_handlers(ev) if
                                self.state in handler.dispatchers]
                    for handler in handlers:
                        handler(ev)

                buf = buf[required_len:]
                required_len = ofproto_common.OFP_HEADER_SIZE

                # We need to schedule other greenlets. Otherwise, ryu
                # can't accept new switches or handle the existing
                # switches. The limit is arbitrary. We need the better
                # approach in the future.
                count += 1
                if count > 2048:
                    count = 0
                    hub.sleep(0)
开发者ID:xbee,项目名称:ryu,代码行数:41,代码来源:controller.py


示例18: _recv_loop

    def _recv_loop(self):
        buf = bytearray()
        required_len = ofproto.OFP_HEADER_SIZE

        while self.is_active:
            ret = self.socket.recv(ofproto.OFP_MSG_SIZE_MAX)
            if len(ret) == 0:
                self.is_active = False
                break
            buf += ret
            while len(buf) >= required_len:
                (version, msg_type, msg_len, xid) = ofproto_parser.header(buf)
                required_len = msg_len
                if len(buf) < required_len:
                    break

                msg = ofproto_parser.msg(self,
                                         version, msg_type, msg_len, xid, buf)
                #LOG.debug('queue msg %s cls %s', msg, msg.__class__)
                self.recv_q.put(msg)

                buf = buf[required_len:]
                required_len = ofproto.OFP_HEADER_SIZE
开发者ID:yamahata,项目名称:ryu,代码行数:23,代码来源:controller.py


示例19: packet_in_handler

 def packet_in_handler(self,msg): 
     version = ofproto.OFP_VERSION
     msg_type = ofproto.OFPT_PACKET_IN
     msg_len = ofproto.OFP_PACKET_IN_SIZE
     in_port = msg['inport']
     buf = self.packet_to_network(msg)
     buf_len = len(buf)
     zfill = '\x00' * 1    
     
     # TODO: buffer_id is set to -1 since is not provided by the shim client
     data =  self.to_hex_string(version,1) \
             + self.to_hex_string(msg_type,1) \
             + self.to_hex_string(msg_len,2) \
             + self.to_hex_string(0,4) \
             + self.to_hex_string(0xFFFFFFFF,4) \
             + self.to_hex_string(msg_len + buf_len,2) \
             + self.to_hex_string(in_port,2) \
             + self.to_hex_string(ofproto.OFPR_NO_MATCH,1) \
             + zfill \
             + buf
     
     packet_in = ofproto_parser.msg(self, version, msg_type, msg_len, 0, data)
     print "Backend. Datapath: " , self.id, " packet_in:", packet_in
     self.register_event(packet_in)
开发者ID:luciappardo,项目名称:ProyectoNet,代码行数:24,代码来源:backend.py


示例20: _test_msg

    def _test_msg(self, name, wire_msg, json_str):
        def bytes_eq(buf1, buf2):
            if buf1 != buf2:
                msg = 'EOF in either data'
                for i in range(0, min(len(buf1), len(buf2))):
                    c1 = six.indexbytes(six.binary_type(buf1), i)
                    c2 = six.indexbytes(six.binary_type(buf2), i)
                    if c1 != c2:
                        msg = 'differs at chr %d, %d != %d' % (i, c1, c2)
                        break
                assert buf1 == buf2, "%r != %r, %s" % (buf1, buf2, msg)

        json_dict = json.loads(json_str)
        # on-wire -> OFPxxx -> json
        (version, msg_type, msg_len, xid) = ofproto_parser.header(wire_msg)
        try:
            has_parser, has_serializer = implemented[version][msg_type]
        except KeyError:
            has_parser = True
            has_serializer = True

        dp = ofproto_protocol.ProtocolDesc(version=version)
        if has_parser:
            msg = ofproto_parser.msg(dp, version, msg_type, msg_len, xid,
                                     wire_msg)
            json_dict2 = self._msg_to_jsondict(msg)
            # XXXdebug code
            open(('/tmp/%s.json' % name), 'w').write(json.dumps(json_dict2))
            eq_(json_dict, json_dict2)

        # json -> OFPxxx -> json
        xid = json_dict[list(json_dict.keys())[0]].pop('xid', None)
        msg2 = self._jsondict_to_msg(dp, json_dict)
        msg2.set_xid(xid)
        if has_serializer:
            msg2.serialize()
            eq_(self._msg_to_jsondict(msg2), json_dict)
            bytes_eq(wire_msg, msg2.buf)

            # check if "len" "length" fields can be omitted

            def _remove(d, names):
                f = lambda x: _remove(x, names)
                if isinstance(d, list):
                    return list(map(f, d))
                if isinstance(d, dict):
                    d2 = {}
                    for k, v in d.items():
                        if k in names:
                            continue
                        d2[k] = f(v)
                    return d2
                return d

            json_dict3 = _remove(json_dict, ['len', 'length'])
            msg3 = self._jsondict_to_msg(dp, json_dict3)
            msg3.set_xid(xid)
            msg3.serialize()
            bytes_eq(wire_msg, msg3.buf)

            msg2.serialize()
            bytes_eq(wire_msg, msg2.buf)
开发者ID:AsmaSwapna,项目名称:ryu,代码行数:62,代码来源:test_parser.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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