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

Python utils.hex_array函数代码示例

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

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



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

示例1: error_msg_handler

 def error_msg_handler(self, ev):
     """
     A switch has sent us an error event
     """
     msg = ev.msg
     datapath = msg.datapath
     dpid = datapath.id
     if msg.type == 0x03 and msg.code == 0x00:
         self.logger.error('event=OFPErrorMsg_received: dpid=%s '
                   'type=Flow_Table_Full(0x03) code=0x%02x message=%s',
                   dpid, msg.code, utils.hex_array(msg.data))
     else:
         self.logger.error('event=OFPErrorMsg_received: dpid=%s '
                   'type=0x%02x code=0x%02x message=%s',
                   dpid, msg.type, msg.code, utils.hex_array(msg.data))
开发者ID:haidlir,项目名称:nmeta,代码行数:15,代码来源:nmeta.py


示例2: error_msg_handler

 def error_msg_handler(self, ev):
     msg = ev.msg
     print "OFPErrorMsg received: type=0x%02x code=0x%02x 'message=%s'" % (
         msg.type,
         msg.code,
         utils.hex_array(msg.data),
     )
开发者ID:gord1306,项目名称:AOS_OF_Example,代码行数:7,代码来源:app_example.py


示例3: packet_in_handler

    def packet_in_handler(self, ev):
        msg = ev.msg
        dp = msg.datapath
        ofp = dp.ofproto

        if msg.reason == ofp.OFPR_NO_MATCH:
            reason = 'NO MATCH'
        elif msg.reason == ofp.OFPR_ACTION:
            reason = 'ACTION'
        elif msg.reason == ofp.OFPR_INVALID_TTL:
            reason = 'INVALID TTL'
        else:
            reason = 'unknown'

        self.logger.debug('OFPPacketIn received: '
                          'buffer_id=%x total_len=%d reason=%s '
                          'table_id=%d cookie=%d match=%s data=%s',
                          msg.buffer_id, msg.total_len, reason,
                          msg.table_id, msg.cookie, msg.match,
                          utils.hex_array(msg.data))

        pkt = packet.packet.Packet(array.array('B', ev.msg.data))
        for p in pkt.protocols:
            print(p)
            if p.protocol_name == 'ipv4':
                print(p.src)
开发者ID:wuyouke,项目名称:SDN-Route,代码行数:26,代码来源:dijkstra.py


示例4: test_hex_array_bytearray

 def test_hex_array_bytearray(self):
     """
     Test hex_array() with bytearray type.
     """
     expected_result = '0x01 0x02 0x03 0x04'
     data = bytearray(b'\x01\x02\x03\x04')
     eq_(expected_result, utils.hex_array(data))
开发者ID:5g-empower,项目名称:empower-ryu,代码行数:7,代码来源:test_utils.py


示例5: test_hex_array_string

 def test_hex_array_string(self):
     """
     Test hex_array() with str type.
     """
     expected_result = '0x01 0x02 0x03 0x04'
     data = b'\x01\x02\x03\x04'
     eq_(expected_result, utils.hex_array(data))
开发者ID:5g-empower,项目名称:empower-ryu,代码行数:7,代码来源:test_utils.py


示例6: openflow_error

 def openflow_error(self, ev):
     """
         Print Error Received. Useful for troubleshooting, specially with Brocade
     """
     msg = ev.msg
     print ('OFPErrorMsg received: type=0x%02x code=0x%02x message=%s' %
            (msg.type, msg.code, utils.hex_array(msg.data)))
开发者ID:ansp-2015,项目名称:SDNTrace,代码行数:7,代码来源:sdntrace.py


示例7: msg

def msg(datapath, version, msg_type, msg_len, xid, buf):
    exp = None
    try:
        assert len(buf) >= msg_len
    except AssertionError as e:
        exp = e

    msg_parser = _MSG_PARSERS.get(version)
    if msg_parser is None:
        raise exception.OFPUnknownVersion(version=version)

    try:
        msg = msg_parser(datapath, version, msg_type, msg_len, xid, buf)
    except exception.OFPTruncatedMessage as e:
        raise e
    except:
        LOG.exception(
            'Encountered an error while parsing OpenFlow packet from switch. '
            'This implies the switch sent a malformed OpenFlow packet. '
            'version 0x%02x msg_type %d msg_len %d xid %d buf %s',
            version, msg_type, msg_len, xid, utils.hex_array(buf))
        msg = None
    if exp:
        raise exp
    return msg
开发者ID:Huangmachi,项目名称:ryu,代码行数:25,代码来源:ofproto_parser.py


示例8: test_hex_array_bytes

 def test_hex_array_bytes(self):
     """
     Test hex_array() with bytes type. (Python3 only)
     """
     if six.PY2:
         return
     expected_result = '0x01 0x02 0x03 0x04'
     data = bytes(b'\x01\x02\x03\x04')
     eq_(expected_result, utils.hex_array(data))
开发者ID:5g-empower,项目名称:empower-ryu,代码行数:9,代码来源:test_utils.py


示例9: error_msg_handler

 def error_msg_handler(self, ev):
     """
     A switch has sent us an error event
     """
     msg = ev.msg
     datapath = msg.datapath
     dpid = datapath.id
     self.logger.error('event=OFPErrorMsg_received: dpid=%s '
                   'type=%s code=%s message=%s',
                   dpid, msg.type, msg.code, utils.hex_array(msg.data))
     #*** Log human-friendly decodes for the error type and code:
     type1, type2, code1, code2 = of_error_decode.decode(msg.type, msg.code)
     self.logger.error('error_type=%s %s error_code=%s %s', type1, type2,
                             code1, code2)
开发者ID:mattjhayes,项目名称:nmeta2,代码行数:14,代码来源:nmeta2.py


示例10: msg

def msg(datapath, version, msg_type, msg_len, xid, buf):
    assert len(buf) >= msg_len

    msg_parser = _MSG_PARSERS.get(version)
    if msg_parser is None:
        raise exception.OFPUnknownVersion(version=version)

    try:
        return msg_parser(datapath, version, msg_type, msg_len, xid, buf)
    except:
        LOG.exception(
            'Encounter an error during parsing OpenFlow packet from switch.'
            'This implies switch sending a malformed OpenFlow packet.'
            'version 0x%02x msg_type %d msg_len %d xid %d buf %s',
            version, msg_type, msg_len, xid, utils.hex_array(buf))
        return None
开发者ID:ProyectoRRAP,项目名称:LiveCode,代码行数:16,代码来源:ofproto_parser.py


示例11: _badWeb_Potect

    def _badWeb_Potect(self, datapath, msg):
        print "in _badWeb_Potect"
        ofproto = datapath.ofproto
        parser = datapath.ofproto_parser
        pkt = packet.Packet(msg.data)
        hdata = utils.hex_array(msg.data)
        hdata = hdata.split(' ')
        hex_data = ''
        for hexdata in hdata:
            cc = hexdata.replace('0x', '')
            if len(cc) == 1:
                cc = '0%s' % cc
            hex_data = hex_data + cc
        # print "hex_data", hex_data
        # print 'pkt:', pkt

        hex_dnsdata = hex_data[84:]
        # print "dns hex data", hex_dnsdata
        dns_binary = binascii.unhexlify(hex_dnsdata)
        dns = DNSRecord.parse(dns_binary)
        # print 'dns:', dns
        dns
        web_name = dns.questions[0].get_qname().label
        web_name = ".".join(list(web_name))
        # print web_name

        try:
            conn = MySQLdb.connect(
                host='localhost', user='root', passwd='123456', db='web', port=3306)
            cur = conn.cursor()
            select = 'select * from WEB_lacklist where name="%s"' % web_name
            if(cur.execute(select)):
                print ' ilegal web  "%s", it`s dangerous! you  can`t to access it.' % web_name
                cur.close()
                conn.close()
                return
            else:
                print 'legal web "%s",you can access it.' % web_name
                cur.close()
                conn.close()
                self._forwarding(datapath, msg)
        except MySQLdb.Error, e:
            print "Mysql Error %d: %s" % (e.args[0], e.args[1])
开发者ID:ysywh,项目名称:match,代码行数:43,代码来源:badWeb_Protection.py


示例12: msg

def msg(datapath, version, msg_type, msg_len, xid, buf):
    assert len(buf) >= msg_len

    msg_parser = _MSG_PARSERS.get(version)
    if msg_parser is None:
        raise exception.OFPUnknownVersion(version=version)

    try:
        return msg_parser(datapath, version, msg_type, msg_len, xid, buf)
    except:
        LOG.exception(
            "Encountered an error while parsing OpenFlow packet from switch. "
            "This implies the switch sent a malformed OpenFlow packet. "
            "version 0x%02x msg_type %d msg_len %d xid %d buf %s",
            version,
            msg_type,
            msg_len,
            xid,
            utils.hex_array(buf),
        )
        return None
开发者ID:hisaharu,项目名称:ryu,代码行数:21,代码来源:ofproto_parser.py


示例13: error_msg_handler

 def error_msg_handler(self, ev):
   msg = ev.msg
   self.logger.error('OFPErrorMsg received: type=0x%02x code=0x%02x '
     'message=%s',
      msg.type, msg.code, utils.hex_array(msg.data)
    )
开发者ID:coscin,项目名称:coscin-app-ryu,代码行数:6,代码来源:coscin_app.py


示例14: error_msg_handler

 def error_msg_handler(self, ev):
     msg = ev.msg
     self.logger.debug('error msg ev %s type 0x%x code 0x%x %s',
                       msg, msg.type, msg.code, utils.hex_array(msg.data))
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:4,代码来源:ofp_handler.py


示例15: _error_handler

 def _error_handler(self,ev):
     msg = ev.msg
     print 'type=0x%02x code=0x%02x msg : %s'%(msg.type,msg.code,hex_array(msg.data))
开发者ID:onlysheep5200,项目名称:NetnsEx,代码行数:3,代码来源:control_plane.py


示例16: test_hex_array_invalid

 def test_hex_array_invalid(self):
     ''' Test conversion into array of hexes with invalid data type '''
     expected_result = None
     data = 1234
     eq_(expected_result, utils.hex_array(data))
开发者ID:John-Lin,项目名称:ryu,代码行数:5,代码来源:test_utils.py


示例17: test_hex_array_bytearray

 def test_hex_array_bytearray(self):
     ''' Test bytearray conversion into array of hexes '''
     expected_result = '0x1 0x2 0x3 0x4'
     data = bytearray(b'\01\02\03\04')
     eq_(expected_result, utils.hex_array(data))
开发者ID:John-Lin,项目名称:ryu,代码行数:5,代码来源:test_utils.py


示例18: test_hex_array_string

 def test_hex_array_string(self):
     ''' Test string conversion into array of hexes '''
     expected_result = '0x1 0x2 0x3 0x4'
     data = b'\01\02\03\04'
     eq_(expected_result, utils.hex_array(data))
开发者ID:John-Lin,项目名称:ryu,代码行数:5,代码来源:test_utils.py


示例19: echo_request_handler

 def echo_request_handler(self, event):
     self.logger.info('OFPEchoRequest received: data=%s', utils.hex_array(event.msg.data))
     datapath = event.msg.datapath
     data = event.msg.data
     self.send_echo_request(datapath, data)
开发者ID:Ahmed-Azri,项目名称:nesox,代码行数:5,代码来源:pingpong.py


示例20: OF_error_msg_handler

 def OF_error_msg_handler(self, event):
     msg = event.msg
     LOG.error(_LE('OFPErrorMsg received: type=0x%(type)02x '
                   'code=0x%(code)02x message=%(msg)s'),
               {'type': msg.type, 'code': msg.code,
                'msg': utils.hex_array(msg.data)})
开发者ID:paperandsoap,项目名称:dragonflow,代码行数:6,代码来源:ryu_base_app.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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