update pyloxi to 026ff024585f1588a7f11fa4c1a9a48d44dc098d
diff --git a/src/python/loxi/of12/action.py b/src/python/loxi/of12/action.py
index 141d118..7a93a43 100644
--- a/src/python/loxi/of12/action.py
+++ b/src/python/loxi/of12/action.py
@@ -3,28 +3,61 @@
# 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 action.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 util
import loxi.generic_util
-import loxi
-import oxm # for unpack
-def unpack_list(reader):
- def deserializer(reader, typ):
- parser = parsers.get(typ)
- if not parser: raise loxi.ProtocolError("unknown action type %d" % typ)
- return parser(reader)
- return loxi.generic_util.unpack_list_tlv16(reader, deserializer)
+class action(loxi.OFObject):
+ subtypes = {}
-class Action(object):
- type = None # override in subclass
- pass
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!H', 0)
+ try:
+ subclass = action.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown action subtype %#x" % subtype)
+ return subclass.unpack(reader)
-class bsn_mirror(Action):
+
+class experimenter(action):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!L', 4)
+ try:
+ subclass = experimenter.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown experimenter action subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+action.subtypes[65535] = experimenter
+
+class bsn(experimenter):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!L', 8)
+ try:
+ subclass = bsn.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown bsn experimenter action subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+experimenter.subtypes[6035143] = bsn
+
+class bsn_mirror(bsn):
type = 65535
experimenter = 6035143
subtype = 1
@@ -59,15 +92,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = bsn_mirror()
- 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))
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
_subtype = reader.read("!L")[0]
@@ -85,13 +116,6 @@
if self.copy_stage != other.copy_stage: 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("bsn_mirror {")
with q.group():
@@ -108,7 +132,9 @@
q.breakable()
q.text('}')
-class bsn_set_tunnel_dst(Action):
+bsn.subtypes[1] = bsn_mirror
+
+class bsn_set_tunnel_dst(bsn):
type = 65535
experimenter = 6035143
subtype = 2
@@ -132,15 +158,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = bsn_set_tunnel_dst()
- 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))
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
_subtype = reader.read("!L")[0]
@@ -153,13 +177,6 @@
if self.dst != other.dst: 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("bsn_set_tunnel_dst {")
with q.group():
@@ -170,7 +187,9 @@
q.breakable()
q.text('}')
-class copy_ttl_in(Action):
+bsn.subtypes[2] = bsn_set_tunnel_dst
+
+class copy_ttl_in(action):
type = 12
def __init__(self):
@@ -186,15 +205,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = copy_ttl_in()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 12)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
return obj
@@ -202,13 +219,6 @@
if type(self) != type(other): 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("copy_ttl_in {")
with q.group():
@@ -217,7 +227,9 @@
q.breakable()
q.text('}')
-class copy_ttl_out(Action):
+action.subtypes[12] = copy_ttl_in
+
+class copy_ttl_out(action):
type = 11
def __init__(self):
@@ -233,15 +245,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = copy_ttl_out()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 11)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
return obj
@@ -249,13 +259,6 @@
if type(self) != type(other): 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("copy_ttl_out {")
with q.group():
@@ -264,7 +267,9 @@
q.breakable()
q.text('}')
-class dec_mpls_ttl(Action):
+action.subtypes[11] = copy_ttl_out
+
+class dec_mpls_ttl(action):
type = 16
def __init__(self):
@@ -280,15 +285,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = dec_mpls_ttl()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 16)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
return obj
@@ -296,13 +299,6 @@
if type(self) != type(other): 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("dec_mpls_ttl {")
with q.group():
@@ -311,7 +307,9 @@
q.breakable()
q.text('}')
-class dec_nw_ttl(Action):
+action.subtypes[16] = dec_mpls_ttl
+
+class dec_nw_ttl(action):
type = 24
def __init__(self):
@@ -327,15 +325,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = dec_nw_ttl()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 24)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
return obj
@@ -343,13 +339,6 @@
if type(self) != type(other): 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("dec_nw_ttl {")
with q.group():
@@ -358,7 +347,9 @@
q.breakable()
q.text('}')
-class group(Action):
+action.subtypes[24] = dec_nw_ttl
+
+class group(action):
type = 22
def __init__(self, group_id=None):
@@ -378,15 +369,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = group()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 22)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.group_id = reader.read("!L")[0]
return obj
@@ -395,13 +384,6 @@
if self.group_id != other.group_id: 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("group {")
with q.group():
@@ -412,7 +394,23 @@
q.breakable()
q.text('}')
-class nicira_dec_ttl(Action):
+action.subtypes[22] = group
+
+class nicira(experimenter):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!H', 8)
+ try:
+ subclass = nicira.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown nicira experimenter action subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+experimenter.subtypes[8992] = nicira
+
+class nicira_dec_ttl(nicira):
type = 65535
experimenter = 8992
subtype = 18
@@ -433,15 +431,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = nicira_dec_ttl()
- 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))
_experimenter = reader.read("!L")[0]
assert(_experimenter == 8992)
_subtype = reader.read("!H")[0]
@@ -454,13 +450,6 @@
if type(self) != type(other): 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("nicira_dec_ttl {")
with q.group():
@@ -469,7 +458,9 @@
q.breakable()
q.text('}')
-class output(Action):
+nicira.subtypes[18] = nicira_dec_ttl
+
+class output(action):
type = 0
def __init__(self, port=None, max_len=None):
@@ -495,15 +486,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = output()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 0)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.port = util.unpack_port_no(reader)
obj.max_len = reader.read("!H")[0]
reader.skip(6)
@@ -515,13 +504,6 @@
if self.max_len != other.max_len: 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("output {")
with q.group():
@@ -535,7 +517,9 @@
q.breakable()
q.text('}')
-class pop_mpls(Action):
+action.subtypes[0] = output
+
+class pop_mpls(action):
type = 20
def __init__(self, ethertype=None):
@@ -556,15 +540,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = pop_mpls()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 20)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.ethertype = reader.read("!H")[0]
reader.skip(2)
return obj
@@ -574,13 +556,6 @@
if self.ethertype != other.ethertype: 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("pop_mpls {")
with q.group():
@@ -591,7 +566,9 @@
q.breakable()
q.text('}')
-class pop_vlan(Action):
+action.subtypes[20] = pop_mpls
+
+class pop_vlan(action):
type = 18
def __init__(self):
@@ -607,15 +584,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = pop_vlan()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 18)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
return obj
@@ -623,13 +598,6 @@
if type(self) != type(other): 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("pop_vlan {")
with q.group():
@@ -638,7 +606,9 @@
q.breakable()
q.text('}')
-class push_mpls(Action):
+action.subtypes[18] = pop_vlan
+
+class push_mpls(action):
type = 19
def __init__(self, ethertype=None):
@@ -659,15 +629,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = push_mpls()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 19)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.ethertype = reader.read("!H")[0]
reader.skip(2)
return obj
@@ -677,13 +645,6 @@
if self.ethertype != other.ethertype: 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("push_mpls {")
with q.group():
@@ -694,7 +655,9 @@
q.breakable()
q.text('}')
-class push_vlan(Action):
+action.subtypes[19] = push_mpls
+
+class push_vlan(action):
type = 17
def __init__(self, ethertype=None):
@@ -715,15 +678,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = push_vlan()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 17)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.ethertype = reader.read("!H")[0]
reader.skip(2)
return obj
@@ -733,13 +694,6 @@
if self.ethertype != other.ethertype: 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("push_vlan {")
with q.group():
@@ -750,7 +704,9 @@
q.breakable()
q.text('}')
-class set_field(Action):
+action.subtypes[17] = push_vlan
+
+class set_field(action):
type = 25
def __init__(self, field=None):
@@ -772,17 +728,14 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_field()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 25)
_len = reader.read("!H")[0]
- obj.field = oxm.unpack(reader)
- reader.skip_align()
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
+ obj.field = oxm.oxm.unpack(reader)
return obj
def __eq__(self, other):
@@ -790,13 +743,6 @@
if self.field != other.field: 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("set_field {")
with q.group():
@@ -807,7 +753,9 @@
q.breakable()
q.text('}')
-class set_mpls_ttl(Action):
+action.subtypes[25] = set_field
+
+class set_mpls_ttl(action):
type = 15
def __init__(self, mpls_ttl=None):
@@ -828,15 +776,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_mpls_ttl()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 15)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.mpls_ttl = reader.read("!B")[0]
reader.skip(3)
return obj
@@ -846,13 +792,6 @@
if self.mpls_ttl != other.mpls_ttl: 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("set_mpls_ttl {")
with q.group():
@@ -863,7 +802,9 @@
q.breakable()
q.text('}')
-class set_nw_ttl(Action):
+action.subtypes[15] = set_mpls_ttl
+
+class set_nw_ttl(action):
type = 23
def __init__(self, nw_ttl=None):
@@ -884,15 +825,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_nw_ttl()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 23)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.nw_ttl = reader.read("!B")[0]
reader.skip(3)
return obj
@@ -902,13 +841,6 @@
if self.nw_ttl != other.nw_ttl: 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("set_nw_ttl {")
with q.group():
@@ -919,7 +851,9 @@
q.breakable()
q.text('}')
-class set_queue(Action):
+action.subtypes[23] = set_nw_ttl
+
+class set_queue(action):
type = 21
def __init__(self, queue_id=None):
@@ -939,15 +873,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_queue()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 21)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.queue_id = reader.read("!L")[0]
return obj
@@ -956,13 +888,6 @@
if self.queue_id != other.queue_id: 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("set_queue {")
with q.group():
@@ -973,45 +898,6 @@
q.breakable()
q.text('}')
+action.subtypes[21] = set_queue
-def parse_experimenter(reader):
- experimenter, = reader.peek("!4xL")
- if experimenter == 0x005c16c7: # Big Switch Networks
- subtype, = reader.peek("!8xL")
- elif experimenter == 0x00002320: # Nicira
- subtype, = reader.peek("!8xH")
- else:
- raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter)
- if subtype in experimenter_parsers[experimenter]:
- return experimenter_parsers[experimenter][subtype](reader)
- else:
- raise loxi.ProtocolError("unexpected BSN experimenter subtype %#x" % subtype)
-
-parsers = {
- const.OFPAT_OUTPUT : output.unpack,
- const.OFPAT_COPY_TTL_OUT : copy_ttl_out.unpack,
- const.OFPAT_COPY_TTL_IN : copy_ttl_in.unpack,
- const.OFPAT_SET_MPLS_TTL : set_mpls_ttl.unpack,
- const.OFPAT_DEC_MPLS_TTL : dec_mpls_ttl.unpack,
- const.OFPAT_PUSH_VLAN : push_vlan.unpack,
- const.OFPAT_POP_VLAN : pop_vlan.unpack,
- const.OFPAT_PUSH_MPLS : push_mpls.unpack,
- const.OFPAT_POP_MPLS : pop_mpls.unpack,
- const.OFPAT_SET_QUEUE : set_queue.unpack,
- const.OFPAT_GROUP : group.unpack,
- const.OFPAT_SET_NW_TTL : set_nw_ttl.unpack,
- const.OFPAT_DEC_NW_TTL : dec_nw_ttl.unpack,
- const.OFPAT_SET_FIELD : set_field.unpack,
- const.OFPAT_EXPERIMENTER : parse_experimenter,
-}
-
-experimenter_parsers = {
- 8992 : {
- 18: nicira_dec_ttl.unpack,
- },
- 6035143 : {
- 1: bsn_mirror.unpack,
- 2: bsn_set_tunnel_dst.unpack,
- },
-}