2013/6/5 Isaku Yamahata <[email protected]>: > Looks good. Thank you for quick respin. > Can you please send the patch to ryu-devel? > > thanks, >
I missed the answer-all-button...zzz > > For consistency and OF-wire stringify, please use cls_meter_band_xxx. > i.e. > cls.cls_meter_band_type = type_ > cls.cls_meter_band_len = len_ Sure, thanks, here we go... >From dbf8d01d8ec5f43bdf0a31815c377f1073b248d1 Mon Sep 17 00:00:00 2001 From: Aeschlimann Philipp <[email protected]> Date: Wed, 5 Jun 2013 15:16:35 +0200 Subject: [PATCH] Send MeterMod messages Signed-off-by: Philipp Aeschlimann <[email protected]> --- ryu/ofproto/ofproto_v1_3_parser.py | 89 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 4 deletions(-) diff --git a/ryu/ofproto/ofproto_v1_3_parser.py b/ryu/ofproto/ofproto_v1_3_parser.py index 524994d..e1aa836 100644 --- a/ryu/ofproto/ofproto_v1_3_parser.py +++ b/ryu/ofproto/ofproto_v1_3_parser.py @@ -1947,6 +1947,26 @@ class OFPPortMod(MsgBase): ofproto_v1_3.OFP_HEADER_SIZE, self.port_no, self.hw_addr, self.config, self.mask, self.advertise) + + +@_set_msg_type(ofproto_v1_3.OFPT_METER_MOD) +class OFPMeterMod(MsgBase): + def __init__(self, datapath, command, flags, meter_id, bands): + super(OFPMeterMod, self).__init__(datapath) + self.command = command + self.flags = flags + self.meter_id = meter_id + self.bands = bands + + def _serialize_body(self): + msg_pack_into(ofproto_v1_3.OFP_METER_MOD_PACK_STR, self.buf, + ofproto_v1_3.OFP_HEADER_SIZE, + self.command, self.flags, self.meter_id) + + offset = ofproto_v1_3.OFP_METER_MOD_SIZE + for b in self.bands: + b.serialize(self.buf, offset) + offset += b.len @_set_msg_type(ofproto_v1_3.OFPT_TABLE_MOD) @@ -2467,12 +2487,25 @@ class OFPMeterStatsReply(OFPMultipartReply): super(OFPMeterStatsReply, self).__init__(datapath) -class OFPMeterBandHeader(object): - def __init__(self, type_, len_, rate, burst_size): +class OFPMeterBand(object): + def __init__(self, type_, len_): self.type = type_ self.len = len_ - self.rate = rate - self.burst_size = burst_size + + +class OFPMeterBandHeader(OFPMeterBand): + @staticmethod + def register_meter_band_type(type_, len_): + def _register_meter_band_type(cls): + cls.cls_meter_band_type = type_ + cls.cls_meter_band_len = len_ + return cls + return _register_meter_band_type + + def __init__(self): + cls = self.__class__ + super(OFPMeterBandHeader, self).__init__(cls.cls_meter_band_type, + cls.cls_meter_band_len) @classmethod def parser(cls, buf, offset): @@ -2481,6 +2514,53 @@ class OFPMeterBandHeader(object): return cls(*band_header) [email protected]_meter_band_type(ofproto_v1_3.OFPMBT_DROP, + ofproto_v1_3.OFP_METER_BAND_DROP_SIZE) +class OFPMeterBandDrop(OFPMeterBandHeader): + def __init__(self, rate, burst_size): + super(OFPMeterBandDrop, self).__init__() + self.rate = rate + self.burst_size = burst_size + + def serialize(self, buf, offset): + msg_pack_into(ofproto_v1_3.OFP_METER_BAND_DROP_PACK_STR, buf, offset, + self.type, self.len, self.rate, self.burst_size) + + [email protected]_meter_band_type(ofproto_v1_3.OFPMBT_DSCP_REMARK, + ofproto_v1_3.OFP_METER_BAND_DSCP_REMARK_SIZE) +class OFPMeterBandDscpRemark(OFPMeterBandHeader): + def __init__(self, rate, burst_size, prec_level): + super(OFPMeterBandDscpRemark, self).__init__() + self.rate = rate + self.burst_size = burst_size + self.prec_level = prec_level + + def serialize(self, buf, offset): + msg_pack_into(ofproto_v1_3.OFP_METER_BAND_DSCP_REMARK_PACK_STR, buf, + offset, self.type, self.len, self.rate, self.burst_size, + self.prec_level) + + # TODO: Add parser method here + + [email protected]_meter_band_type(ofproto_v1_3.OFPMBT_EXPERIMENTER, + ofproto_v1_3.OFP_METER_BAND_EXPERIMENTER_SIZE) +class OFPMeterBandExperimenter(OFPMeterBandHeader): + def __init__(self, rate, burst_size, experimenter): + super(OFPMeterBandDscpRemark, self).__init__() + self.rate = rate + self.burst_size = burst_size + self.experimenter = experimenter + + def serialize(self, buf, offset): + msg_pack_into(ofproto_v1_3.OFP_METER_BAND_EXPERIMENTER_PACK_STR, buf, + offset, self.type, self.len, self.rate, self.burst_size, + self.experimenter) + + # TODO: Add parser method here + + class OFPMeterConfigStats(object): def __init__(self): super(OFPMeterConfigStats, self).__init__() @@ -2502,6 +2582,7 @@ class OFPMeterConfigStats(object): length = ofproto_v1_3.OFP_METER_CONFIG_SIZE while length < meter_config.length: band_header = OFPMeterBandHeader.parser(buf, offset) + #TODO: Parse all types of MeterBands, not only common header meter_config.bands.append(band_header) offset += band_header.len length += band_header.len -- 1.8.3 g *pae ------------------------------------------------------------------------------ How ServiceNow helps IT people transform IT departments: 1. A cloud service to automate IT design, transition and operations 2. Dashboards that offer high-level views of enterprise services 3. A single system of record for all IT processes http://p.sf.net/sfu/servicenow-d2d-j _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
