diff options
author | Simon Horman <horms@verge.net.au> | 2014-01-29 12:06:24 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-01-29 12:43:55 +0900 |
commit | c6bea4f0289fe12f4610a221c1bc2fdf975a9290 (patch) | |
tree | 8434511e4b1d2279f7bb3d9f314d0316952d5ddb | |
parent | 9d87fc08d9e7954198d69f04101172309d026328 (diff) |
Add OF1.4 meter features stats request and reply message 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_parser.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/ryu/ofproto/ofproto_v1_4_parser.py b/ryu/ofproto/ofproto_v1_4_parser.py index 1b4e4e2f..3f73f8a3 100644 --- a/ryu/ofproto/ofproto_v1_4_parser.py +++ b/ryu/ofproto/ofproto_v1_4_parser.py @@ -2344,6 +2344,79 @@ class OFPMeterConfigStatsReply(OFPMultipartReply): super(OFPMeterConfigStatsReply, self).__init__(datapath, **kwargs) +class OFPMeterFeaturesStats(ofproto_parser.namedtuple('OFPMeterFeaturesStats', + ('max_meter', 'band_types', 'capabilities', + 'max_band', 'max_color'))): + @classmethod + def parser(cls, buf, offset): + meter_features = struct.unpack_from( + ofproto.OFP_METER_FEATURES_PACK_STR, buf, offset) + stats = cls(*meter_features) + stats.length = ofproto.OFP_METER_FEATURES_SIZE + return stats + + +@_set_stats_type(ofproto.OFPMP_METER_FEATURES, OFPMeterFeaturesStats) +@_set_msg_type(ofproto.OFPT_MULTIPART_REQUEST) +class OFPMeterFeaturesStatsRequest(OFPMultipartRequest): + """ + Meter features statistics request message + + The controller uses this message to query the set of features of the + metering subsystem. + + ================ ====================================================== + Attribute Description + ================ ====================================================== + flags Zero or ``OFPMPF_REQ_MORE`` + ================ ====================================================== + + Example:: + + def send_meter_features_stats_request(self, datapath): + ofp_parser = datapath.ofproto_parser + + req = ofp_parser.OFPMeterFeaturesStatsRequest(datapath, 0) + datapath.send_msg(req) + """ + def __init__(self, datapath, flags, type_=None): + super(OFPMeterFeaturesStatsRequest, self).__init__(datapath, flags) + + +@OFPMultipartReply.register_stats_type() +@_set_stats_type(ofproto.OFPMP_METER_FEATURES, OFPMeterFeaturesStats) +@_set_msg_type(ofproto.OFPT_MULTIPART_REPLY) +class OFPMeterFeaturesStatsReply(OFPMultipartReply): + """ + Meter features statistics reply message + + The switch responds with this message to a meter features statistics + request. + + ================ ====================================================== + Attribute Description + ================ ====================================================== + body List of ``OFPMeterFeaturesStats`` instance + ================ ====================================================== + + Example:: + + @set_ev_cls(ofp_event.EventOFPMeterFeaturesStatsReply, MAIN_DISPATCHER) + def meter_features_stats_reply_handler(self, ev): + features = [] + for stat in ev.msg.body: + features.append('max_meter=%d band_types=0x%08x ' + 'capabilities=0x%08x max_band=%d ' + 'max_color=%d' % + (stat.max_meter, stat.band_types, + stat.capabilities, stat.max_band, + stat.max_color)) + self.logger.debug('MeterFeaturesStats: %s', configs) + """ + def __init__(self, datapath, type_=None, **kwargs): + super(OFPMeterFeaturesStatsReply, self).__init__(datapath, **kwargs) + + class OFPMeterBand(StringifyMixin): def __init__(self, type_, len_): super(OFPMeterBand, self).__init__() |