simple_switch: specify OF1.0

simple_switch works with only OF1.0 and OF1.0 provides all
simple_switch needs. So specify OF1.0.

simple_switch doesn't need nxm so use OFPMatch and OFPFlowMod (and
avoid the helper functions).

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
FUJITA Tomonori 2012-07-18 12:39:32 +09:00
parent 4c2de66d32
commit 112c7e5496

View File

@ -21,7 +21,7 @@ from ryu.controller import mac_to_port
from ryu.controller import ofp_event from ryu.controller import ofp_event
from ryu.controller.handler import MAIN_DISPATCHER from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls from ryu.controller.handler import set_ev_cls
from ryu.ofproto import nx_match from ryu.ofproto import ofproto_v1_0
from ryu.lib.mac import haddr_to_str from ryu.lib.mac import haddr_to_str
@ -36,6 +36,7 @@ LOG = logging.getLogger('ryu.app.simple_switch')
class SimpleSwitch(app_manager.RyuApp): class SimpleSwitch(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION]
_CONTEXTS = { _CONTEXTS = {
'mac2port': mac_to_port.MacToPortTable, 'mac2port': mac_to_port.MacToPortTable,
} }
@ -67,18 +68,25 @@ class SimpleSwitch(app_manager.RyuApp):
actions = [datapath.ofproto_parser.OFPActionOutput(out_port)] actions = [datapath.ofproto_parser.OFPActionOutput(out_port)]
if out_port != ofproto.OFPP_FLOOD: if out_port != ofproto.OFPP_FLOOD:
rule = nx_match.ClsRule() wildcards = ofproto_v1_0.OFPFW_ALL
rule.set_in_port(msg.in_port) wildcards &= ~ofproto_v1_0.OFPFW_IN_PORT
rule.set_dl_dst(dst) wildcards &= ~ofproto_v1_0.OFPFW_DL_DST
rule.set_dl_type(nx_match.ETH_TYPE_IP)
rule.set_nw_dscp(0) match = datapath.ofproto_parser.OFPMatch(
datapath.send_flow_mod( wildcards, msg.in_port, 0, dst,
rule=rule, cookie=0, command=ofproto.OFPFC_ADD, 0, 0, 0, 0, 0, 0, 0, 0, 0)
idle_timeout=0, hard_timeout=0,
mod = datapath.ofproto_parser.OFPFlowMod(
datapath=datapath, match=match, cookie=0,
command=ofproto.OFPFC_ADD, idle_timeout=0, hard_timeout=0,
priority=ofproto.OFP_DEFAULT_PRIORITY, priority=ofproto.OFP_DEFAULT_PRIORITY,
flags=ofproto.OFPFF_SEND_FLOW_REM, actions=actions) flags=ofproto.OFPFF_SEND_FLOW_REM, actions=actions)
datapath.send_msg(mod)
datapath.send_packet_out(msg.buffer_id, msg.in_port, actions) out = datapath.ofproto_parser.OFPPacketOut(
datapath=datapath, buffer_id=msg.buffer_id, in_port=msg.in_port,
actions=actions)
datapath.send_msg(out)
@set_ev_cls(ofp_event.EventOFPPortStatus, MAIN_DISPATCHER) @set_ev_cls(ofp_event.EventOFPPortStatus, MAIN_DISPATCHER)
def _port_status_handler(self, ev): def _port_status_handler(self, ev):