diff options
author | Kei Ohmura <ohmura.kei@gmail.com> | 2013-07-24 08:19:20 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2013-07-24 08:36:20 +0900 |
commit | bdde02b61b0595eef9d108e67b845200827bb026 (patch) | |
tree | d9fa9feed073903184d9ae9e3f5ea56d8e16df11 | |
parent | afefe3c3cd8fe1130c3cb617ff811b557538cb62 (diff) |
ryu/app/ofctl_rest: add of1.3 support
This patch allows users to manually insert flows into switches via OpenFlow1.3
in the following way:
curl -d '{"dpid":"1", "priority":"32768",\
"actions":[{"type":"SET_FIELD","field":"vlan_vid","value":10},\
{"type":"OUTPUT","port":2},\
{"type":"GOTO_TABLE","table_id":3}],\
"match":{"in_port":1}}' http://127.0.0.1:8080/stats/flowentry/add
Signed-off-by: OHMURA Kei <ohmura.kei@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/app/ofctl_rest.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/ryu/app/ofctl_rest.py b/ryu/app/ofctl_rest.py index 5a5223ac..4e3e46f4 100644 --- a/ryu/app/ofctl_rest.py +++ b/ryu/app/ofctl_rest.py @@ -24,7 +24,9 @@ from ryu.controller import dpset from ryu.controller.handler import MAIN_DISPATCHER from ryu.controller.handler import set_ev_cls from ryu.ofproto import ofproto_v1_0 +from ryu.ofproto import ofproto_v1_3 from ryu.lib import ofctl_v1_0 +from ryu.lib import ofctl_v1_3 from ryu.app.wsgi import ControllerBase, WSGIApplication @@ -94,6 +96,8 @@ class StatsController(ControllerBase): if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION: flows = ofctl_v1_0.get_flow_stats(dp, self.waiters) + if dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION: + flows = ofctl_v1_3.get_flow_stats(dp, self.waiters) else: LOG.debug('Unsupported OF protocol') return Response(status=501) @@ -138,6 +142,8 @@ class StatsController(ControllerBase): if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION: ofctl_v1_0.mod_flow_entry(dp, flow, cmd) + if dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION: + ofctl_v1_3.mod_flow_entry(dp, flow, cmd) else: LOG.debug('Unsupported OF protocol') return Response(status=501) @@ -159,7 +165,8 @@ class StatsController(ControllerBase): class RestStatsApi(app_manager.RyuApp): - OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION] + OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION, + ofproto_v1_3.OFP_VERSION] _CONTEXTS = { 'dpset': dpset.DPSet, 'wsgi': WSGIApplication @@ -218,7 +225,13 @@ class RestStatsApi(app_manager.RyuApp): lock, msgs = self.waiters[dp.id][msg.xid] msgs.append(msg) - if msg.flags & dp.ofproto.OFPSF_REPLY_MORE: + flags = 0 + if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION: + flags = dp.ofproto.OFPSF_REPLY_MORE + elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION: + flags = dp.ofproto.OFPMPF_REPLY_MORE + + if msg.flags & flags: return del self.waiters[dp.id][msg.xid] lock.set() |