diff --git a/src/python/loxi/of13/action.py b/src/python/loxi/of13/action.py
old mode 100644
new mode 100755
index 5065041..2018fb3
--- a/src/python/loxi/of13/action.py
+++ b/src/python/loxi/of13/action.py
@@ -125,7 +125,7 @@
         q.text('}')
 
 action.subtypes[65535] = experimenter
-
+"""
 class bsn(experimenter):
     subtypes = {}
 
@@ -435,6 +435,7 @@
         q.text('}')
 
 bsn.subtypes[2] = bsn_set_tunnel_dst
+"""
 
 class copy_ttl_in(action):
     type = 12
@@ -1282,4 +1283,823 @@
 
 action.subtypes[21] = set_queue
 
+OFDPA_EXPERIMETER =0x00001018
 
+class ofdpa(experimenter):
+    subtypes = {}
+
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+
+    def __init__(self, subtype=None):
+        if subtype != None:
+            self.subtype = subtype
+        else:
+            self.subtype = 0
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append('\x00' * 6)
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        #8 is offset, ref OFReader
+        subtype, = reader.peek('!H', 8)
+        subclass = ofdpa.subtypes.get(subtype)
+        if subclass:
+            return subclass.unpack(reader)
+
+        obj = ofdpa()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        obj.subtype = reader.read("!H")[0]
+        reader.skip(6)
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        if self.subtype != other.subtype: return False
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+            q.breakable()
+        q.text('}')
+
+experimenter.subtypes[OFDPA_EXPERIMETER] = ofdpa
+
+OFDPA_ACT_PUSH_L2_HEADER=1
+OFDPA_ACT_POP_L2_HEADER=2 
+OFDPA_ACT_PUSH_CW=3 
+OFDPA_ACT_POP_CW=4
+OFDPA_ACT_COPY_TC_IN=5
+OFDPA_ACT_COPY_TC_OUT=6
+OFDPA_ACT_SET_TC_FROM_TABLE=7
+OFDPA_ACT_SET_PCP_DFI_FROM_TABLE=9
+OFDPA_ACT_OAM_LM_RX_COUNT=10
+OFDPA_ACT_OAM_LM_TX_COUNT=11
+OFDPA_ACT_OAM_SET_COUNTER_FIELDS=12
+OFDPA_ACT_DEC_TTL_MTU=13
+OFDPA_ACT_CHECK_DROP_STATUS=14
+OFDPA_ACT_SET_QOS_FROM_TABLE=15
+
+
+class ofdpa_push_l2_header(ofdpa):
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+    subtype = OFDPA_ACT_PUSH_L2_HEADER
+
+    def __init__(self):
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append('\x00' * 6)
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        obj = ofdpa_push_l2_header()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        _subtype = reader.read("!H")[0]
+        assert(_subtype == OFDPA_ACT_PUSH_L2_HEADER)   
+        reader.skip(6)
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa_push_l2_header {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("ofdpa_push_l2_header");
+            q.breakable()
+        q.text('}')
+
+ofdpa.subtypes[OFDPA_ACT_PUSH_L2_HEADER] = ofdpa_push_l2_header
+
+class ofdpa_pop_l2_header(ofdpa):
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+    subtype = OFDPA_ACT_POP_L2_HEADER
+
+    def __init__(self):
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append('\x00' * 6)        
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        obj = ofdpa_pop_l2_header()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        _subtype = reader.read("!H")[0]
+        assert(_subtype == OFDPA_ACT_POP_L2_HEADER)          
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa_pop_l2_header {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("ofdpa_pop_l2_header");
+            q.breakable()
+        q.text('}')
+
+ofdpa.subtypes[OFDPA_ACT_POP_L2_HEADER] = ofdpa_pop_l2_header
+
+class ofdpa_push_cw(ofdpa):
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+    subtype = OFDPA_ACT_PUSH_CW
+
+    def __init__(self):
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append('\x00' * 6)        
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        obj = ofdpa_push_cw()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        _subtype = reader.read("!H")[0]
+        assert(_subtype == OFDPA_ACT_PUSH_CW)          
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa_push_cw {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("ofdpa_push_cw");
+            q.breakable()
+        q.text('}')
+
+ofdpa.subtypes[OFDPA_ACT_PUSH_CW] = ofdpa_push_cw
+
+class ofdpa_pop_cw(ofdpa):
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+    subtype = OFDPA_ACT_POP_CW
+
+    def __init__(self):
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append('\x00' * 6)        
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        obj = ofdpa_pop_cw()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        _subtype = reader.read("!H")[0]
+        assert(_subtype == OFDPA_ACT_POP_CW)          
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa_pop_cw {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("ofdpa_pop_cw");
+            q.breakable()
+        q.text('}')
+
+ofdpa.subtypes[OFDPA_ACT_POP_CW] = ofdpa_pop_cw
+
+class ofdpa_copy_tc_in(ofdpa):
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+    subtype = OFDPA_ACT_COPY_TC_IN
+
+    def __init__(self):
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append('\x00' * 6)        
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        obj = ofdpa_copy_tc_in()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        _subtype = reader.read("!H")[0]
+        assert(_subtype == OFDPA_ACT_COPY_TC_IN)  
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa_copy_tc_in {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("ofdpa_copy_tc_in");
+            q.breakable()
+        q.text('}')
+
+ofdpa.subtypes[OFDPA_ACT_COPY_TC_IN] = ofdpa_copy_tc_in
+
+class ofdpa_copy_tc_out(ofdpa):
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+    subtype = OFDPA_ACT_COPY_TC_OUT
+
+    def __init__(self):
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append('\x00' * 6)        
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        obj = ofdpa_copy_tc_out()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        _subtype = reader.read("!H")[0]
+        assert(_subtype == OFDPA_ACT_COPY_TC_OUT)        
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa_copy_tc_out {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("ofdpa_copy_tc_out");
+            q.breakable()
+        q.text('}')
+
+ofdpa.subtypes[OFDPA_ACT_COPY_TC_OUT] = ofdpa_copy_tc_out
+
+class ofdpa_dec_ttl_mtu(ofdpa):
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+    subtype = OFDPA_ACT_DEC_TTL_MTU
+
+    def __init__(self):
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append('\x00' * 6)        
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        obj = ofdpa_dec_ttl_mtu()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        _subtype = reader.read("!H")[0]
+        assert(_subtype == OFDPA_ACT_DEC_TTL_MTU)        
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa_dec_ttl_mtu {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("ofdpa_dec_ttl_mtu");
+            q.breakable()
+        q.text('}')
+
+ofdpa.subtypes[OFDPA_ACT_DEC_TTL_MTU] = ofdpa_dec_ttl_mtu
+
+class ofdpa_set_tc_from_table(ofdpa):
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+    subtype = OFDPA_ACT_SET_TC_FROM_TABLE
+
+    def __init__(self, qos_index=None):
+        if qos_index != None:
+            self.qos_index = qos_index
+        else:
+            self.qos_index = 0
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append(struct.pack("!B", self.qos_index))
+        packed.append('\x00' * 5)        
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        obj = ofdpa_set_tc_from_table()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        _subtype = reader.read("!H")[0]
+        assert(_subtype == OFDPA_ACT_SET_TC_FROM_TABLE)
+        obj.qos_index = reader.read("!B")[0]
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        if self.qos_index != other.qos_index: return False
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa_set_tc_from_table {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("ofdpa_set_tc_from_table");
+                q.pp(self.qos_index)
+            q.breakable()
+        q.text('}')
+
+ofdpa.subtypes[OFDPA_ACT_SET_TC_FROM_TABLE] = ofdpa_set_tc_from_table
+
+
+class ofdpa_set_pcp_dfi_from_table(ofdpa):
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+    subtype = OFDPA_ACT_SET_PCP_DFI_FROM_TABLE
+
+    def __init__(self, qos_index=None):
+        if qos_index != None:
+            self.qos_index = qos_index
+        else:
+            self.qos_index = 0
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append(struct.pack("!B", self.qos_index))
+        packed.append('\x00' * 5)         
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        obj = ofdpa_set_pcp_dfi_from_table()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        _subtype = reader.read("!H")[0]
+        assert(_subtype == OFDPA_ACT_SET_PCP_DFI_FROM_TABLE)
+        obj.qos_index = reader.read("!B")[0]
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        if self.qos_index != other.qos_index: return False
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa_set_pcp_dfi_from_table {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("ofdpa_set_pcp_dfi_from_table");
+                q.pp(self.qos_index)
+            q.breakable()
+        q.text('}')
+
+ofdpa.subtypes[OFDPA_ACT_SET_PCP_DFI_FROM_TABLE] = ofdpa_set_pcp_dfi_from_table
+
+
+class ofdpa_check_drop_status(ofdpa):
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+    subtype = OFDPA_ACT_CHECK_DROP_STATUS
+
+    def __init__(self, index, status_type):
+        self.index = index
+        self.status_type  = status_type
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append(struct.pack("!L", self.index))
+        packed.append(struct.pack("!B", self.status_type))  
+        packed.append('\x00' * 1)    
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        obj = ofdpa_check_drop_status()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        _subtype = reader.read("!H")[0]
+        assert(_subtype == OFDPA_ACT_CHECK_DROP_STATUS)
+        obj.status_type  = reader.read("!L")[0]
+        obj.index = reader.read("!B")[0]        
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        if self.index != other.index: return False
+        if self.status_type != other.status_type: return False        
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa_check_drop_status {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("ofdpa_check_drop_status = ");
+                q.pp(self.index)
+                q.pp(self.status_type)                
+            q.breakable()
+        q.text('}')
+
+ofdpa.subtypes[OFDPA_ACT_CHECK_DROP_STATUS] = ofdpa_check_drop_status
+
+
+class ofdpa_set_qos_from_table(ofdpa):
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+    subtype = OFDPA_ACT_SET_QOS_FROM_TABLE
+
+    def __init__(self, qos_index, mpls_tc):
+        self.qos_index = qos_index
+        self.mpls_tc  = mpls_tc
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append(struct.pack("!B", self.qos_index))
+        packed.append(struct.pack("!B", self.mpls_tc))   
+        packed.append('\x00' * 4)           
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        obj = ofdpa_check_drop_status()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        _subtype = reader.read("!H")[0]
+        assert(_subtype == OFDPA_ACT_SET_QOS_FROM_TABLE)
+        obj.qos_index = reader.read("!B")[0]
+        obj.mpls_tc  = reader.read("!B")[0]
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        if self.qos_index != other.qos_index: return False
+        if self.mpls_tc != other.mpls_tc: return False        
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa_set_qos_from_table {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("ofdpa_set_qos_from_table = ");
+                q.pp(self.qos_index)
+                q.pp(self.mpls_tc)                
+            q.breakable()
+        q.text('}')
+
+ofdpa.subtypes[OFDPA_ACT_SET_QOS_FROM_TABLE] = ofdpa_set_qos_from_table
+
+
+class ofdpa_oam_lm_tx_count(ofdpa):
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+    subtype = OFDPA_ACT_OAM_LM_TX_COUNT
+
+    def __init__(self, lmep_id, traffic_class):
+        self.lmep_id = lmep_id
+        self.traffic_class  = traffic_class
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append(struct.pack("!L", self.lmep_id))
+        packed.append(struct.pack("!B", self.traffic_class))   
+        packed.append('\x00' * 1)   
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        obj = ofdpa_check_drop_status()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        _subtype = reader.read("!H")[0]
+        assert(_subtype == OFDPA_ACT_OAM_LM_TX_COUNT)
+        obj.lmep_id = reader.read("!L")[0]
+        obj.traffic_class  = reader.read("!B")[0]
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        if self.lmep_id != other.lmep_id: return False
+        if self.traffic_class != other.traffic_class: return False        
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa_oam_lm_tx_count {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("ofdpa_oam_lm_tx_count = ");
+                q.pp(self.lmep_id)
+                q.pp(self.traffic_class)                
+            q.breakable()
+        q.text('}')
+
+ofdpa.subtypes[OFDPA_ACT_OAM_LM_TX_COUNT] = ofdpa_oam_lm_tx_count
+
+class ofdpa_oam_lm_rx_count(ofdpa):
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+    subtype = OFDPA_ACT_OAM_LM_RX_COUNT
+
+    def __init__(self, lmep_id, traffic_class):
+        self.lmep_id = lmep_id
+        self.traffic_class  = traffic_class
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append(struct.pack("!L", self.lmep_id))
+        packed.append(struct.pack("!B", self.traffic_class))  
+        packed.append('\x00' * 1)   
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        obj = ofdpa_check_drop_status()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        _subtype = reader.read("!H")[0]
+        assert(_subtype == OFDPA_ACT_OAM_LM_RX_COUNT)
+        obj.lmep_id = reader.read("!L")[0]
+        obj.traffic_class  = reader.read("!B")[0]
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        if self.lmep_id != other.lmep_id: return False
+        if self.traffic_class != other.traffic_class: return False        
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa_oam_lm_rx_count {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("ofdpa_oam_lm_rx_count = ");
+                q.pp(self.lmep_id)
+                q.pp(self.traffic_class)                
+            q.breakable()
+        q.text('}')
+
+ofdpa.subtypes[OFDPA_ACT_OAM_LM_RX_COUNT] = ofdpa_oam_lm_rx_count
+
+
+class ofdpa_oam_set_counter_field(ofdpa):
+    type = 65535
+    experimenter = OFDPA_EXPERIMETER
+    subtype = OFDPA_ACT_OAM_SET_COUNTER_FIELDS
+
+    def __init__(self, lmep_id, traffic_class):
+        self.lmep_id = lmep_id
+        self.traffic_class  = traffic_class
+        return
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!H", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!H", self.subtype))
+        packed.append(struct.pack("!L", self.lmep_id))
+        packed.append(struct.pack("!B", self.traffic_class))  
+        packed.append('\x00' * 1)   
+        length = sum([len(x) for x in packed])
+        packed[1] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(reader):
+        obj = ofdpa_check_drop_status()
+        _type = reader.read("!H")[0]
+        assert(_type == 65535)
+        _len = reader.read("!H")[0]
+        orig_reader = reader
+        reader = orig_reader.slice(_len, 4)
+        _experimenter = reader.read("!L")[0]
+        assert(_experimenter == OFDPA_EXPERIMETER)
+        _subtype = reader.read("!H")[0]
+        assert(_subtype == OFDPA_ACT_OAM_SET_COUNTER_FIELDS)
+        obj.lmep_id = reader.read("!L")[0]
+        obj.traffic_class  = reader.read("!B")[0]
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        if self.lmep_id != other.lmep_id: return False
+        if self.traffic_class != other.traffic_class: return False        
+        return True
+
+    def pretty_print(self, q):
+        q.text("ofdpa_oam_set_counter_field {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("ofdpa_oam_set_counter_field = ");
+                q.pp(self.lmep_id)
+                q.pp(self.traffic_class)                
+            q.breakable()
+        q.text('}')
+
+ofdpa.subtypes[OFDPA_ACT_OAM_SET_COUNTER_FIELDS] = ofdpa_oam_set_counter_field
\ No newline at end of file
