mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 13:56:09 +02:00
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>
This commit is contained in:
parent
afefe3c3cd
commit
bdde02b61b
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user