diff options
author | Simon Horman <horms@verge.net.au> | 2014-03-11 10:41:59 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-03-16 21:42:05 +0900 |
commit | 3df9da512d622acf1d26352b281e4d60167132a7 (patch) | |
tree | 1a4277fcf41ac943cbb757607aabe06db62081ee | |
parent | fbd51b60f7310426619f5cf78cd92d5812778917 (diff) |
of14: Add flow monitor request support
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/ofproto/ofproto_v1_4.py | 7 | ||||
-rw-r--r-- | ryu/ofproto/ofproto_v1_4_parser.py | 82 |
2 files changed, 88 insertions, 1 deletions
diff --git a/ryu/ofproto/ofproto_v1_4.py b/ryu/ofproto/ofproto_v1_4.py index 0d8efb63..5f83e074 100644 --- a/ryu/ofproto/ofproto_v1_4.py +++ b/ryu/ofproto/ofproto_v1_4.py @@ -1259,7 +1259,12 @@ OFP_QUEUE_STATS_SIZE = 48 assert calcsize(OFP_QUEUE_STATS_PACK_STR) == OFP_QUEUE_STATS_SIZE # struct ofp_flow_monitor_request -OFP_FLOW_MONITOR_REQUEST_PACK_STR = '!IIIHBB' + _OFP_MATCH_PACK_STR +_OFP_FLOW_MONITOR_REQUEST_0_PACK_STR = 'IIIHBB' +OFP_FLOW_MONITOR_REQUEST_0_PACK_STR = ('!' + + _OFP_FLOW_MONITOR_REQUEST_0_PACK_STR) +OFP_FLOW_MONITOR_REQUEST_0_SIZE = 16 +OFP_FLOW_MONITOR_REQUEST_PACK_STR = (OFP_FLOW_MONITOR_REQUEST_0_PACK_STR + + _OFP_MATCH_PACK_STR) OFP_FLOW_MONITOR_REQUEST_SIZE = 24 assert (calcsize(OFP_FLOW_MONITOR_REQUEST_PACK_STR) == OFP_FLOW_MONITOR_REQUEST_SIZE) diff --git a/ryu/ofproto/ofproto_v1_4_parser.py b/ryu/ofproto/ofproto_v1_4_parser.py index 21f5fe60..7cc78e75 100644 --- a/ryu/ofproto/ofproto_v1_4_parser.py +++ b/ryu/ofproto/ofproto_v1_4_parser.py @@ -3516,6 +3516,88 @@ class OFPFlowUpdatePaused(OFPFlowUpdateHeader): return cls(length, event) +class OFPFlowMonitorRequestBase(OFPMultipartRequest): + def __init__(self, datapath, flags, monitor_id, out_port, out_group, + monitor_flags, table_id, command, match): + super(OFPFlowMonitorRequestBase, self).__init__(datapath, flags) + self.monitor_id = monitor_id + self.out_port = out_port + self.out_group = out_group + self.monitor_flags = monitor_flags + self.table_id = table_id + self.command = command + self.match = match + + def _serialize_stats_body(self): + offset = ofproto.OFP_MULTIPART_REQUEST_SIZE + msg_pack_into(ofproto.OFP_FLOW_MONITOR_REQUEST_0_PACK_STR, self.buf, + offset, self.monitor_id, self.out_port, self.out_group, + self.monitor_flags, self.table_id, self.command) + + offset += ofproto.OFP_FLOW_MONITOR_REQUEST_0_SIZE + self.match.serialize(self.buf, offset) + + +@_set_stats_type(ofproto.OFPMP_FLOW_MONITOR, OFPFlowUpdateHeader) +@_set_msg_type(ofproto.OFPT_MULTIPART_REQUEST) +class OFPFlowMonitorRequest(OFPFlowMonitorRequestBase): + """ + Flow monitor request message + + The controller uses this message to query flow monitors. + + ================ ====================================================== + Attribute Description + ================ ====================================================== + flags Zero or ``OFPMPF_REQ_MORE`` + monitor_id Controller-assigned ID for this monitor + out_port Require matching entries to include this as an output + port + out_group Require matching entries to include this as an output + group + monitor_flags Bitmap of the following flags. + OFPFMF_INITIAL + OFPFMF_ADD + OFPFMF_REMOVED + OFPFMF_MODIFY + OFPFMF_INSTRUCTIONS + OFPFMF_NO_ABBREV + OFPFMF_ONLY_OWN + table_id ID of table to monitor + command One of the following values. + OFPFMC_ADD + OFPFMC_MODIFY + OFPFMC_DELETE + match Instance of ``OFPMatch`` + ================ ====================================================== + + Example:: + + def send_flow_stats_request(self, datapath): + ofp = datapath.ofproto + ofp_parser = datapath.ofproto_parser + + monitor_flags = [ofp.OFPFMF_INITIAL, ofp.OFPFMF_ONLY_OWN] + match = ofp_parser.OFPMatch(in_port=1) + req = ofp_parser.OFPFlowMonitorRequest(datapath, 0, 10000, + ofp.OFPP_ANY, ofp.OFPG_ANY, + monitor_flags, + ofp.OFPTT_ALL, + ofp.OFPFMC_ADD, match) + datapath.send_msg(req) + """ + def __init__(self, datapath, flags=0, monitor_id=0, + out_port=ofproto.OFPP_ANY, out_group=ofproto.OFPG_ANY, + monitor_flags=0, table_id=ofproto.OFPTT_ALL, + command=ofproto.OFPFMC_ADD, match=None, type_=None): + if match is None: + match = OFPMatch() + super(OFPFlowMonitorRequest, self).__init__(datapath, flags, + monitor_id, out_port, + out_group, monitor_flags, + table_id, command, match) + + class OFPExperimenterMultipart(ofproto_parser.namedtuple( 'OFPExperimenterMultipart', ('experimenter', 'exp_type', 'data'))): |