From 7fc101fc58183833d48543c2e67a207a50b03e3d Mon Sep 17 00:00:00 2001 From: HsiaoHsuan Date: Sat, 14 May 2016 05:43:03 -0700 Subject: [PATCH] Fix ryu adapter for OpenFlow1.0 --- adapter/ryu/omniui/omniui.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/adapter/ryu/omniui/omniui.py b/adapter/ryu/omniui/omniui.py index 9d0edd7..d8fb345 100644 --- a/adapter/ryu/omniui/omniui.py +++ b/adapter/ryu/omniui/omniui.py @@ -23,6 +23,7 @@ from operator import attrgetter from ryu.ofproto.ether import ETH_TYPE_LLDP, ETH_TYPE_IPV6 from ryu.lib import hub +from ryu.lib.mac import haddr_to_bin from ryu.lib.packet import * from ryu.topology import event, switches @@ -100,6 +101,14 @@ def switch_features_handler(self, ev): ofproto.OFPCML_NO_BUFFER)] self.add_flow(datapath, 0, match, actions) + def add_flow10(self, datapath, priority, match, actions): + ofproto = datapath.ofproto + parser = datapath.ofproto_parser + + mod = parser.OFPFlowMod(datapath=datapath, match=match, cookie=0, command=ofproto.OFPFC_ADD, idle_timeout=0, + hard_timeout=0, priority=priority, flags=ofproto.OFPFF_SEND_FLOW_REM, actions=actions) + datapath.send_msg(mod) + def add_flow(self, datapath, priority, match, actions): ofproto = datapath.ofproto parser = datapath.ofproto_parser @@ -447,8 +456,12 @@ def packet_in_handler(self, ev): # install a flow to avoid packet_in next time if out_port != ofproto.OFPP_FLOOD: - match = parser.OFPMatch(in_port=in_port, eth_dst=dst, eth_src=src) - self.add_flow(datapath, 1, match, actions) + if ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION: + match = parser.OFPMatch(in_port=in_port, dl_dst=haddr_to_bin(dst)) + self.add_flow10(datapath, 1, match, actions) + else: + match = parser.OFPMatch(in_port=in_port, eth_dst=dst, eth_src=src) + self.add_flow(datapath, 1, match, actions) data = None if msg.buffer_id == ofproto.OFP_NO_BUFFER: