本文整理汇总了Python中ryu.lib.packet.packet.Packet.next方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.next方法的具体用法?Python Packet.next怎么用?Python Packet.next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ryu.lib.packet.packet.Packet
的用法示例。
在下文中一共展示了Packet.next方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _packet_in_handler
# 需要导入模块: from ryu.lib.packet.packet import Packet [as 别名]
# 或者: from ryu.lib.packet.packet.Packet import next [as 别名]
def _packet_in_handler(self, ev):
"""Handle packet_in events."""
if not self.link_discovery:
return
msg = ev.msg
in_port = msg.match['in_port']
packet = Packet(msg.data)
efm = packet.next()
if efm.ethertype == ether.ETH_TYPE_ARP:
self.send_event_to_observers(event.EventArpReceived(ev))
try:
src_dpid, src_port_no = LLDPPacket.lldp_parse(msg.data)
except LLDPPacket.LLDPUnknownFormat as e:
# This handler can receive all the packtes which can be
# not-LLDP packet. Ignore it silently
return
else:
dst_dpid = msg.datapath.id
dst_port_no = in_port
src = self._get_port(src_dpid, src_port_no)
if not src or src.dpid == dst_dpid:
return
dst = self._get_port(dst_dpid, dst_port_no)
if not dst:
return
old_peer = self.links.get_peer(src)
#LOG.debug("Packet-In")
#LOG.debug(" src=%s", src)
#LOG.debug(" dst=%s", dst)
#LOG.debug(" old_peer=%s", old_peer)
if old_peer and old_peer != dst:
old_link = Link(src, old_peer)
self.send_event_to_observers(event.EventLinkDelete(old_link))
link = Link(src, dst)
if not link in self.links:
self.send_event_to_observers(event.EventLinkAdd(link))
if not self.links.update_link(src, dst):
# reverse link is not detected yet.
# So schedule the check early because it's very likely it's up
try:
self.ports.lldp_received(dst)
except KeyError as e:
# There are races between EventOFPPacketIn and
# EventDPPortAdd. So packet-in event can happend before
# port add event. In that case key error can happend.
# LOG.debug('lldp_received: KeyError %s', e)
pass
else:
self.ports.move_front(dst)
self.lldp_event.set()
示例2: arp_received_handler
# 需要导入模块: from ryu.lib.packet.packet import Packet [as 别名]
# 或者: from ryu.lib.packet.packet.Packet import next [as 别名]
def arp_received_handler(self, ev):
msg = ev.ev.msg
datapath = msg.datapath
in_port = msg.match['in_port']
packet = Packet(msg.data)
packet.next()
arppkt = packet.next()
if arppkt.opcode == arp.ARP_REQUEST:
self.broadcast_to_end_nodes(msg)
try:
src_port, dst_port = db.handle_arp_packet(arppkt, datapath.id, in_port)
self.process_end_hw_addr_flows(src_port)
self.process_end_hw_addr_flows(dst_port)
if src_port[0] != dst_port[0]:
self.process_route(src_port, dst_port, True)
self.process_route(dst_port, src_port, True)
if arppkt.opcode == arp.ARP_REPLY:
target_switch = self.switches[dst_port[0]].switch
self.arp_packet_out(target_switch.dp, dst_port[1], msg.data)
except db.ArpTableNotFoundException:
pass