Skip to content

Commit

Permalink
Fix ryu adapter for OpenFlow1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hsiaohsuan1l1l authored and waynelkh committed Jun 28, 2016
1 parent f4dcaeb commit 7fc101f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions adapter/ryu/omniui/omniui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 7fc101f

Please sign in to comment.