This is a second patch for the MeterMod messages to apply a Meter to a flow.
>From 9aab054fea03e94a5b8e64f345ab9cc26ba5e91b Mon Sep 17 00:00:00 2001 From: Aeschlimann Philipp <[email protected]> Date: Wed, 19 Jun 2013 11:19:07 +0200 Subject: [PATCH] Added InstructionMeter Signed-off-by: Philipp Aeschlimann <[email protected]> --- ryu/ofproto/ofproto_v1_3_parser.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ryu/ofproto/ofproto_v1_3_parser.py b/ryu/ofproto/ofproto_v1_3_parser.py index f8221f2..f4f32ac 100644 --- a/ryu/ofproto/ofproto_v1_3_parser.py +++ b/ryu/ofproto/ofproto_v1_3_parser.py @@ -1591,6 +1591,26 @@ class OFPInstructionActions(object): buf, offset, self.type, self.len) [email protected]_instruction_type([ofproto_v1_3.OFPIT_METER]) +class OFPInstructionMeter(object): + def __init__(self, meter_id): + super(OFPInstructionMeter, self).__init__() + self.type = ofproto_v1_3.OFPIT_METER + self.len = ofproto_v1_3.OFP_INSTRUCTION_METER_SIZE + self.meter_id = meter_id + + @classmethod + def parser(cls, buf, offset): + (type_, len_, table_id) = struct.unpack_from( + ofproto_v1_3.OFP_INSTRUCTION_METER_PACK_STR, + buf, offset) + return cls(meter_id) + + def serialize(self, buf, offset): + msg_pack_into(ofproto_v1_3.OFP_INSTRUCTION_METER_PACK_STR, + buf, offset, self.type, self.len, self.meter_id) + + class OFPActionHeader(object): def __init__(self, type_, len_): self.type = type_ -- 1.8.3.1 g *pae 2013/6/11 Philipp Aeschlimann <[email protected]>: > The pep8 errors are now fixed. The patch is also as file attached. > > From 9db85fdc939f3801a2d4d6769b2d6a5d4f789ac0 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 | 92 > ++++++++++++++++++++++++++++++++++++-- > 1 file changed, 88 insertions(+), 4 deletions(-) > > diff --git a/ryu/ofproto/ofproto_v1_3_parser.py > b/ryu/ofproto/ofproto_v1_3_parser.py > index 524994d..01b0e1a 100644 > --- a/ryu/ofproto/ofproto_v1_3_parser.py > +++ b/ryu/ofproto/ofproto_v1_3_parser.py > @@ -1949,6 +1949,26 @@ class OFPPortMod(MsgBase): > 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) > class OFPTableMod(MsgBase): > def __init__(self, datapath, table_id, config): > @@ -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,56 @@ 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 +2585,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 > > 2013/6/10 FUJITA Tomonori <[email protected]>: >> On Mon, 10 Jun 2013 09:55:25 +0200 >> Philipp Aeschlimann <[email protected]> wrote: >> >>> Sry for the late answer. Yeah, must be the mailer... I attached the >>> patch also as file. >>> >>> >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(-) >> >> Thanks. Now I can apply this however I got pep8 errors. Can you fix >> the following and resend it? >> >> Thanks! >> >> fujita@rose:~/git/ryu$ ./run_tests.sh -p >> Running pep8 ... >> ryu/ofproto/ofproto_v1_3_parser.py:1950:1: W293 blank line contains >> whitespace >> >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:1965:1: W293 blank line contains >> whitespace >> >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:2507:74: W291 trailing whitespace >> super(OFPMeterBandHeader, >> self).__init__(cls.cls_meter_band_type, >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:2518:80: E501 line too long (83 >> characters) >> >> ofproto_v1_3.OFP_METER_BAND_DROP_SIZE) >> >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:2524:1: W293 blank line contains >> whitespace >> >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:2526:78: W291 trailing whitespace >> msg_pack_into(ofproto_v1_3.OFP_METER_BAND_DROP_PACK_STR, buf, >> offset, >> >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:2531:80: E501 line too long (90 >> characters) >> >> ofproto_v1_3.OFP_METER_BAND_DSCP_REMARK_SIZE) >> >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:2538:1: W293 blank line contains >> whitespace >> >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:2540:77: W291 trailing whitespace >> msg_pack_into(ofproto_v1_3.OFP_METER_BAND_DSCP_REMARK_PACK_STR, >> buf, >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:2541:79: W291 trailing whitespace >> offset, self.type, self.len, self.rate, >> self.burst_size, >> >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:2543:1: W293 blank line contains >> whitespace >> >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:2548:80: E501 line too long (91 >> characters) >> >> ofproto_v1_3.OFP_METER_BAND_EXPERIMENTER_SIZE) >> >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:2555:1: W293 blank line contains >> whitespace >> >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:2557:78: W291 trailing whitespace >> msg_pack_into(ofproto_v1_3.OFP_METER_BAND_EXPERIMENTER_PACK_STR, >> buf, >> >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:2558:79: W291 trailing whitespace >> offset, self.type, self.len, self.rate, >> self.burst_size, >> >> ^ >> ryu/ofproto/ofproto_v1_3_parser.py:2560:1: W293 blank line contains >> whitespace >> >> ^ > > > > -- > ZHAW - Zurich University of Applied Sciences > Institute of Applied Information Technology InIT > InIT Cloud Computing Laboratory ICCLab > > Philipp Aeschlimann > Researcher > Obere Kirchgasse 2 > CH-8401 Winterthur > > Tel. +41 58 934 6964 (intern 6964) > mailto:[email protected] > www.zhaw.ch > www.cloudcomp.ch > > GPG IDKey: 647E122E > Fingerprint: 47B7 8D8A 98D1 E91D 4B7C E261 D88C BE9E 647E 122E
0001-Added-InstructionMeter.patch
Description: Binary data
------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev
_______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
