update pyloxi to 026ff024585f1588a7f11fa4c1a9a48d44dc098d
diff --git a/src/python/loxi/of13/meter_band.py b/src/python/loxi/of13/meter_band.py
index 5573beb..9c7a23f 100644
--- a/src/python/loxi/of13/meter_band.py
+++ b/src/python/loxi/of13/meter_band.py
@@ -3,27 +3,36 @@
# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
# See the file LICENSE.pyloxi which should have been included in the source distribution
-# Automatically generated by LOXI from template meter_band.py
+# Automatically generated by LOXI from template module.py
# Do not modify
import struct
+import loxi
import const
+import common
+import action
+import instruction
+import oxm
+import action_id
+import instruction_id
+import meter_band
import util
import loxi.generic_util
-import loxi
-def unpack_list(reader):
- def deserializer(reader, typ):
- parser = parsers.get(typ)
- if not parser: raise loxi.ProtocolError("unknown meter band type %d" % typ)
- return parser(reader)
- return loxi.generic_util.unpack_list_tlv16(reader, deserializer)
+class meter_band(loxi.OFObject):
+ subtypes = {}
-class MeterBand(object):
- type = None # override in subclass
- pass
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!H', 0)
+ try:
+ subclass = meter_band.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown meter_band subtype %#x" % subtype)
+ return subclass.unpack(reader)
-class drop(MeterBand):
+
+class drop(meter_band):
type = 1
def __init__(self, rate=None, burst_size=None):
@@ -49,15 +58,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = drop()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 1)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.rate = reader.read("!L")[0]
obj.burst_size = reader.read("!L")[0]
reader.skip(4)
@@ -69,13 +76,6 @@
if self.burst_size != other.burst_size: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("drop {")
with q.group():
@@ -89,7 +89,9 @@
q.breakable()
q.text('}')
-class dscp_remark(MeterBand):
+meter_band.subtypes[1] = drop
+
+class dscp_remark(meter_band):
type = 2
def __init__(self, rate=None, burst_size=None, prec_level=None):
@@ -120,15 +122,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = dscp_remark()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 2)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.rate = reader.read("!L")[0]
obj.burst_size = reader.read("!L")[0]
obj.prec_level = reader.read("!B")[0]
@@ -142,13 +142,6 @@
if self.prec_level != other.prec_level: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("dscp_remark {")
with q.group():
@@ -165,7 +158,9 @@
q.breakable()
q.text('}')
-class experimenter(MeterBand):
+meter_band.subtypes[2] = dscp_remark
+
+class experimenter(meter_band):
type = 65535
def __init__(self, rate=None, burst_size=None, experimenter=None):
@@ -195,15 +190,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = experimenter()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 65535)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.rate = reader.read("!L")[0]
obj.burst_size = reader.read("!L")[0]
obj.experimenter = reader.read("!L")[0]
@@ -216,13 +209,6 @@
if self.experimenter != other.experimenter: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("experimenter {")
with q.group():
@@ -239,9 +225,6 @@
q.breakable()
q.text('}')
+meter_band.subtypes[65535] = experimenter
-parsers = {
- const.OFPMBT_DROP : drop.unpack,
- const.OFPMBT_DSCP_REMARK : dscp_remark.unpack,
- const.OFPMBT_EXPERIMENTER : experimenter.unpack,
-}
+