def packet_in_handler(self, ev): ryu_packet = RyuPacket(ev, self.logger) self.logger.info("packet in %s %s %s %s", ryu_packet.get_dpid(), ryu_packet.get_mac_src(), ryu_packet.get_mac_dst(), ryu_packet.get_in_port()) ryu_packet.flood() return
def packet_in_handler(self, ev): ryu_packet = RyuPacket(ev, self.logger) self.mac_to_port.setdefault(ryu_packet.get_dpid(), {}) self.logger.info("packet in %s %s %s %s", ryu_packet.get_dpid(), ryu_packet.get_mac_src(), ryu_packet.get_mac_dst(), ryu_packet.get_in_port()) if ryu_packet.is_arp_request(): self.logger.info("Is ARP: %s", ryu_packet.is_arp_request()) self.ip_to_mac[ ryu_packet.get_arp_ip_src()] = ryu_packet.get_mac_src() self.silent_arp(ryu_packet) return # Learn a path by incoming packet self.mac_to_port[ryu_packet.get_dpid()][ ryu_packet.get_mac_src()] = ryu_packet.get_in_port() if ryu_packet.get_mac_dst() in self.mac_to_port[ryu_packet.get_dpid()]: out_port = self.mac_to_port[ryu_packet.get_dpid()][ ryu_packet.get_mac_dst()] ryu_packet.send_packet(out_port) else: ryu_packet.flood() return RyuFlow(ev, self.logger).add_flow( ryu_packet.get_datapath(), ryu_packet.get_datapath().ofproto_parser.OFPMatch( in_port=ryu_packet.get_in_port(), eth_dst=ryu_packet.get_mac_dst()), [ ryu_packet.get_datapath().ofproto_parser.OFPActionOutput( out_port) ], 0, 0)
def packet_in_handler(self, ev): ryu_packet = RyuPacket(ev, self.logger) self.mac_to_port.setdefault(ryu_packet.get_dpid(), {}) self.logger.info("packet in %s %s %s %s", ryu_packet.get_dpid(), ryu_packet.get_mac_src(), ryu_packet.get_mac_dst(), ryu_packet.get_in_port()) if ryu_packet.is_arp_request(): self.logger.info("Is ARP: %s", ryu_packet.is_arp_request()) self.ip_to_mac[ryu_packet.get_arp_ip_src()] = ryu_packet.get_mac_src() self.silent_arp(ryu_packet) return # Learn a path by incoming packet self.mac_to_port[ryu_packet.get_dpid()][ryu_packet.get_mac_src()] = ryu_packet.get_in_port() if ryu_packet.get_mac_dst() in self.mac_to_port[ryu_packet.get_dpid()]: out_port = self.mac_to_port[ryu_packet.get_dpid()][ryu_packet.get_mac_dst()] ryu_packet.send_packet(out_port) else: ryu_packet.flood() return RyuFlow(ev, self.logger).add_flow( ryu_packet.get_datapath(), ryu_packet.get_datapath().ofproto_parser.OFPMatch(in_port=ryu_packet.get_in_port(), eth_dst=ryu_packet.get_mac_dst()), [ryu_packet.get_datapath().ofproto_parser.OFPActionOutput(out_port)], 0, 0)