diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-07-18 12:39:32 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-07-18 16:54:18 +0900 |
commit | 112c7e5496828095d300cb4421ce89d69216bc84 (patch) | |
tree | aa07d01145a7b386feca38462463275edb351000 | |
parent | 4c2de66d32d51faf313ea14f84ce89dcbdf2e164 (diff) |
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>
-rw-r--r-- | ryu/app/simple_switch.py | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/ryu/app/simple_switch.py b/ryu/app/simple_switch.py index 25227f21..7f0d6cdb 100644 --- a/ryu/app/simple_switch.py +++ b/ryu/app/simple_switch.py @@ -21,7 +21,7 @@ from ryu.controller import mac_to_port from ryu.controller import ofp_event from ryu.controller.handler import MAIN_DISPATCHER 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 @@ -36,6 +36,7 @@ LOG = logging.getLogger('ryu.app.simple_switch') class SimpleSwitch(app_manager.RyuApp): + OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION] _CONTEXTS = { 'mac2port': mac_to_port.MacToPortTable, } @@ -67,18 +68,25 @@ class SimpleSwitch(app_manager.RyuApp): actions = [datapath.ofproto_parser.OFPActionOutput(out_port)] if out_port != ofproto.OFPP_FLOOD: - rule = nx_match.ClsRule() - rule.set_in_port(msg.in_port) - rule.set_dl_dst(dst) - rule.set_dl_type(nx_match.ETH_TYPE_IP) - rule.set_nw_dscp(0) - datapath.send_flow_mod( - rule=rule, cookie=0, command=ofproto.OFPFC_ADD, - idle_timeout=0, hard_timeout=0, + wildcards = ofproto_v1_0.OFPFW_ALL + wildcards &= ~ofproto_v1_0.OFPFW_IN_PORT + wildcards &= ~ofproto_v1_0.OFPFW_DL_DST + + match = datapath.ofproto_parser.OFPMatch( + wildcards, msg.in_port, 0, dst, + 0, 0, 0, 0, 0, 0, 0, 0, 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, 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) def _port_status_handler(self, ev): |