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]>
--- 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)
+ 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