On Sun, Jun 23, 2013 at 08:43:21PM -0300, Raphael Vicente Rosa wrote:
> I think it's fixed and done like OFPAction.
> Raphael
>
>
> --- ofproto_v1_3_parser.py.orig 2013-06-17 11:47:53.338664755 -0300
> +++ ofproto_v1_3_parser.py 2013-06-23 20:18:15.577834191 -0300
> @@ -1590,6 +1590,24 @@ class OFPInstructionActions(object):
> msg_pack_into(ofproto_v1_3.OFP_INSTRUCTION_ACTIONS_PACK_STR,
> 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_, meter_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_):
> @@ -2468,19 +2486,122 @@ class OFPMeterStatsReply(OFPMultipartRep
>
>
> class OFPMeterBandHeader(object):
> - def __init__(self, type_, len_, rate, burst_size):
> + def __init__(self, type_, len_, rate_, burst_size_):
> + super(OFPMeterBandHeader, self).__init__()
> self.type = type_
> self.len = len_
> - self.rate = rate
> - self.burst_size = burst_size
> + self.rate = rate_
> + self.burst_size = burst_size_
> +
> + def _serialize_stats_body(self, buf, offset):
> + pass
> +
> + def serialize(self, buf, offset):
> + self._serialize_stats_body(buf, offset)
> +
> +
> +class OFPMeterBand(OFPMeterBandHeader):
These methods can be merged into OFPMeterBandHeader.
> + _METER_TYPES = {}
> +
> + @staticmethod
> + def register_meter_type(type_, len_):
> + def _register_meter_type(cls):
> + cls.cls_meter_type = type_
> + cls.cls_meter_len = len_
> + OFPMeterBand._METER_TYPES[cls.cls_meter_type] = cls
> + return cls
> + return _register_meter_type
> +
> + def __init__(self):
def __init__(self, rate, burst_size):?
> + cls = self.__class__
> + super(OFPMeterBand, self).__init__(cls.cls_action_type,
> + cls.cls_action_len,
> + cls.cls_action_rate,
rate?
> + cls.cls_action_burst_size)
burst_size?
thanks,
>
> @classmethod
> def parser(cls, buf, offset):
> - band_header = struct.unpack_from(
> + type_, len_, rate_, burst_size_ = struct.unpack_from(
> ofproto_v1_3.OFP_METER_BAND_HEADER_PACK_STR, buf, offset)
> - return cls(*band_header)
> + cls_ = cls._METER_TYPES.get(type_)
> + assert cls_ is not None
> + return cls_.parser(buf, offset)
> +
> [email protected]_meter_type(ofproto_v1_3.OFPMBT_DROP,
> + ofproto_v1_3.OFP_METER_BAND_DROP_SIZE)
> +class OFPMeterBandDrop(OFPMeterBandHeader):
> + def __init__(self, type_, len_, rate, burst_size):
> + super(OFPMeterBandDrop, self).__init__(ofproto_v1_3.OFPMBT_DROP,
> ofproto_v1_3.OFP_METER_BAND_DROP_SIZE,
> + rate, burst_size)
> +
> + @classmethod
> + def parser(cls, buf, offset):
> + type_, len_, rate_, burst_size_ = struct.unpack_from(
> + ofproto_v1_3.OFP_METER_BAND_DROP_PACK_STR, buf, offset)
> + return cls(type_, len_, rate_, burst_size_)
> +
> +
> + def _serialize_stats_body(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_type(ofproto_v1_3.OFPMBT_DSCP_REMARK,
> + ofproto_v1_3.OFP_METER_BAND_DSCP_REMARK_SIZE)
> +class OFPMeterBandDscpRemark(OFPMeterBandHeader):
> + def __init__(self, type_, len_, rate, burst_size, prec_level):
> + self.prec_level = prec_level
> + super(OFPMeterBandDscpRemark, self).__init__
> (ofproto_v1_3.OFPMBT_DSCP_REMARK,
> ofproto_v1_3.OFP_METER_BAND_DSCP_REMARK_SIZE,
> + rate, burst_size)
> +
> + @classmethod
> + def parser(cls, buf, offset):
> + type_, len_, rate_, burst_size_ = struct.unpack_from(
> + ofproto_v1_3.OFP_METER_BAND_DSCP_REMARK_PACK_STR, buf, offset)
> + return cls(type_, len_, rate_, burst_size_)
>
>
> + def _serialize_stats_body(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)
> +
> [email protected]_meter_type(ofproto_v1_3.OFPMBT_EXPERIMENTER,
> +
> ofproto_v1_3.OFP_METER_BAND_EXPERIMENTER_SIZE)
> +class OFPMeterBandExperimenter(OFPMeterBandHeader):
> + def __init__(self, type_, len_, rate, burst_size, experimenter):
> + self.experimenter = experimenter
> + super(OFPMeterBandExperimenter, self).__init__
> (ofproto_v1_3.OFPMBT_EXPERIMENTER,
> ofproto_v1_3.OFP_METER_BAND_EXPERIMENTER_SIZE,
> + rate, burst_size)
> +
> + @classmethod
> + def parser(cls, buf, offset):
> + type_, len_, rate_, burst_size_ = struct.unpack_from(
> + ofproto_v1_3.OFP_METER_BAND_EXPERIMENTER_PACK_STR, buf, offset)
> + return cls(type_, len_, rate_, burst_size_)
> +
> + def _serialize_stats_body(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)
> +
> +
> +@_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
> +
> class OFPMeterConfigStats(object):
> def __init__(self):
> super(OFPMeterConfigStats, self).__init__()
> @@ -2853,4 +2974,3 @@ class OFPSetAsync(MsgBase):
> self.packet_in_mask[0], self.packet_in_mask[1],
> self.port_status_mask[0], self.port_status_mask[1],
> self.flow_removed_mask[0], self.flow_removed_mask[1])
> -
>
>
>
> On Mon, Jun 17, 2013 at 6:54 PM, FUJITA Tomonori
> <[email protected]
> > wrote:
>
> On Mon, 17 Jun 2013 12:03:42 -0300
> Raphael Vicente Rosa <[email protected]> wrote:
>
> > Patch description:
> > - OFPInstructionMeter class coded;
> > - OFPMeterBandHeader class verified and coded;
> > - OFPMeterBandDrop class coded;
> > - OFPMeterBandDscpRemark class coded;
> > - OFPMeterBandExperimenter class coded;
> > - OFPMeterMod class coded.
> >
> > All classes were tested using ofsoftswitch13.
> >
> > Signed-off-by: Raphael Vicente Rosa <[email protected]>
>
> Thanks, but the patch is corrupted. Can you check the mailer
> configuration?
>
>
> > --- ofproto_v1_3_parser.py.orig 2013-06-17 11:47:53.338664755 -0300
> > +++ ofproto_v1_3_parser.py 2013-06-17 11:45:16.077884945 -0300
> > @@ -1590,6 +1590,24 @@ class OFPInstructionActions(object):
> > msg_pack_into(ofproto_v1_3.OFP_INSTRUCTION_ACTIONS_PACK_STR,
> > 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_, meter_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_):
> > @@ -2469,6 +2487,7 @@ class OFPMeterStatsReply(OFPMultipartRep
> >
> > class OFPMeterBandHeader(object):
> > def __init__(self, type_, len_, rate, burst_size):
> > + super(OFPMeterBandHeader, self).__init__()
> > self.type = type_
> > self.len = len_
> > self.rate = rate
> > @@ -2480,6 +2499,63 @@ class OFPMeterBandHeader(object):
> > ofproto_v1_3.OFP_METER_BAND_HEADER_PACK_STR, buf, offset)
> > return cls(*band_header)
>
> Can you implement like what we did with OFPAciton?
>
> > + def _serialize_stats_body(self, buf, offset):
> > + pass
> > +
> > + def serialize(self, buf, offset):
> > + self._serialize_stats_body(buf, offset)
> > +
> > +
> > +class OFPMeterBandDrop(OFPMeterBandHeader):
> > + def __init__(self, type_, len_, rate, burst_size):
> > + super(OFPMeterBandDrop,
> self).__init__(ofproto_v1_3.OFPMBT_DROP,
> > ofproto_v1_3.OFP_METER_BAND_DROP_SIZE,
> > + rate, burst_size)
> > +
> > + def _serialize_stats_body(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)
> > +
> > +
> > +class OFPMeterBandDscpRemark(OFPMeterBandHeader):
> > + def __init__(self, type_, len_, rate, burst_size, prec_level):
> > + self.prec_level = prec_level
> > + super(OFPMeterBandDscpRemark,
> > self).__init__(ofproto_v1_3.OFPMBT_DSCP_REMARK,
> > ofproto_v1_3.OFP_METER_BAND_DSCP_REMARK_SIZE,
> > + rate, burst_size)
> > +
> > + def _serialize_stats_body(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)
> > +
> > +
> > +class OFPMeterBandExperimenter(OFPMeterBandHeader):
> > + def __init__(self, type_, len_, rate, burst_size, experimenter):
> > + self.experimenter = experimenter
> > + super(OFPMeterBandExperimenter,
> > self).__init__(ofproto_v1_3.OFPMBT_EXPERIMENTER,
> > ofproto_v1_3.OFP_METER_BAND_EXPERIMENTER_SIZE,
> > + rate,
> burst_size)
> > +
> > + def _serialize_stats_body(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)
> > +
> > +
> > +@_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
> >
> > class OFPMeterConfigStats(object):
> > def __init__(self):
> > @@ -2853,4 +2929,3 @@ class OFPSetAsync(MsgBase):
> > self.packet_in_mask[0], self.packet_in_mask[1],
> > self.port_status_mask[0], self.port_status_mask
> [1],
> > self.flow_removed_mask[0], self.flow_removed_mask
> [1])
> > -
>
>
> ------------------------------------------------------------------------------
> 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
--
yamahata
------------------------------------------------------------------------------
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