import pyloxi @ 56db3af912fd38fe3789e7629a823788b94f463d
diff --git a/src/python/loxi/of10/__init__.py b/src/python/loxi/of10/__init__.py
index 9b3bf53..6f2680d 100644
--- a/src/python/loxi/of10/__init__.py
+++ b/src/python/loxi/of10/__init__.py
@@ -1,17 +1,6 @@
-#
-# Copyright 2012, 2013, Big Switch Networks, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+# Copyright (c) 2011, 2012 Open Networking Foundation
+# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
 
 # Automatically generated by LOXI from template init.py
 # Do not modify
diff --git a/src/python/loxi/of10/action.py b/src/python/loxi/of10/action.py
index c6129a5..8fe2997 100644
--- a/src/python/loxi/of10/action.py
+++ b/src/python/loxi/of10/action.py
@@ -1,17 +1,6 @@
-#
-# Copyright 2012, 2013, Big Switch Networks, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+# Copyright (c) 2011, 2012 Open Networking Foundation
+# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
 
 # Automatically generated by LOXI from template action.py
 # Do not modify
@@ -19,22 +8,15 @@
 import struct
 import const
 import util
+import loxi.generic_util
 import loxi
 
-def unpack_list(buf):
-    if len(buf) % 8 != 0: raise loxi.ProtocolError("action list length not a multiple of 8")
-    actions = []
-    offset = 0
-    while offset < len(buf):
-        type, length = struct.unpack_from("!HH", buf, offset)
-        if length == 0: raise loxi.ProtocolError("action length is 0")
-        if length % 8 != 0: raise loxi.ProtocolError("action length not a multiple of 8")
-        if offset + length > len(buf): raise loxi.ProtocolError("action length overruns list length")
-        parser = parsers.get(type)
-        if not parser: raise loxi.ProtocolError("unknown action type %d" % type)
-        actions.append(parser(buffer(buf, offset, length)))
-        offset += length
-    return actions
+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(object):
     type = None # override in subclass
@@ -45,7 +27,7 @@
     experimenter = 0x5c16c7
     subtype = 1
 
-    def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None, pad=None):
+    def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None):
         if dest_port != None:
             self.dest_port = dest_port
         else:
@@ -58,10 +40,7 @@
             self.copy_stage = copy_stage
         else:
             self.copy_stage = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0]
+        return
 
     def pack(self):
         packed = []
@@ -72,7 +51,7 @@
         packed.append(struct.pack("!L", self.dest_port))
         packed.append(struct.pack("!L", self.vlan_tag))
         packed.append(struct.pack("!B", self.copy_stage))
-        packed.append(struct.pack("!3B", *self.pad))
+        packed.append('\x00' * 3)
         length = sum([len(x) for x in packed])
         packed[1] = struct.pack("!H", length)
         return ''.join(packed)
@@ -80,28 +59,28 @@
     @staticmethod
     def unpack(buf):
         obj = bsn_mirror()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 24: raise loxi.ProtocolError("bsn_mirror length is %d, should be 24" % _length)
-        experimenter = struct.unpack_from('!L', buf, 4)[0]
-        assert(experimenter == 0x5c16c7)
-        subtype = struct.unpack_from('!L', buf, 8)[0]
-        assert(subtype == 1)
-        obj.dest_port = struct.unpack_from('!L', buf, 12)[0]
-        obj.vlan_tag = struct.unpack_from('!L', buf, 16)[0]
-        obj.copy_stage = struct.unpack_from('!B', buf, 20)[0]
-        obj.pad = list(struct.unpack_from('!3B', buf, 21))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_VENDOR)
+        _len = reader.read('!H')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x5c16c7)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 1)
+        obj.dest_port = reader.read('!L')[0]
+        obj.vlan_tag = reader.read('!L')[0]
+        obj.copy_stage = reader.read('!B')[0]
+        reader.skip(3)
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
         if self.dest_port != other.dest_port: return False
         if self.vlan_tag != other.vlan_tag: return False
         if self.copy_stage != other.copy_stage: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -124,9 +103,6 @@
                 q.text(","); q.breakable()
                 q.text("copy_stage = ");
                 q.text("%#x" % self.copy_stage)
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
@@ -140,6 +116,7 @@
             self.dst = dst
         else:
             self.dst = 0
+        return
 
     def pack(self):
         packed = []
@@ -155,21 +132,22 @@
     @staticmethod
     def unpack(buf):
         obj = bsn_set_tunnel_dst()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 16: raise loxi.ProtocolError("bsn_set_tunnel_dst length is %d, should be 16" % _length)
-        experimenter = struct.unpack_from('!L', buf, 4)[0]
-        assert(experimenter == 0x5c16c7)
-        subtype = struct.unpack_from('!L', buf, 8)[0]
-        assert(subtype == 2)
-        obj.dst = struct.unpack_from('!L', buf, 12)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_VENDOR)
+        _len = reader.read('!H')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x5c16c7)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 2)
+        obj.dst = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
         if self.dst != other.dst: return False
         return True
 
@@ -193,26 +171,23 @@
 class enqueue(Action):
     type = const.OFPAT_ENQUEUE
 
-    def __init__(self, port=None, pad=None, queue_id=None):
+    def __init__(self, port=None, queue_id=None):
         if port != None:
             self.port = port
         else:
             self.port = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0,0,0,0]
         if queue_id != None:
             self.queue_id = queue_id
         else:
             self.queue_id = 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("!H", self.port))
-        packed.append(struct.pack("!6B", *self.pad))
+        packed.append('\x00' * 6)
         packed.append(struct.pack("!L", self.queue_id))
         length = sum([len(x) for x in packed])
         packed[1] = struct.pack("!H", length)
@@ -221,21 +196,21 @@
     @staticmethod
     def unpack(buf):
         obj = enqueue()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_ENQUEUE)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 16: raise loxi.ProtocolError("enqueue length is %d, should be 16" % _length)
-        obj.port = struct.unpack_from('!H', buf, 4)[0]
-        obj.pad = list(struct.unpack_from('!6B', buf, 6))
-        obj.queue_id = struct.unpack_from('!L', buf, 12)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_ENQUEUE)
+        _len = reader.read('!H')[0]
+        obj.port = reader.read('!H')[0]
+        reader.skip(6)
+        obj.queue_id = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
         if self.port != other.port: return False
-        if self.pad != other.pad: return False
         if self.queue_id != other.queue_id: return False
         return True
 
@@ -254,9 +229,6 @@
                 q.text("port = ");
                 q.text(util.pretty_port(self.port))
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
-                q.text(","); q.breakable()
                 q.text("queue_id = ");
                 q.text("%#x" % self.queue_id)
             q.breakable()
@@ -267,15 +239,8 @@
     experimenter = 0x2320
     subtype = 18
 
-    def __init__(self, pad=None, pad2=None):
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = 0
-        if pad2 != None:
-            self.pad2 = pad2
-        else:
-            self.pad2 = 0
+    def __init__(self):
+        return
 
     def pack(self):
         packed = []
@@ -283,8 +248,8 @@
         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("!H", self.pad))
-        packed.append(struct.pack("!L", self.pad2))
+        packed.append('\x00' * 2)
+        packed.append('\x00' * 4)
         length = sum([len(x) for x in packed])
         packed[1] = struct.pack("!H", length)
         return ''.join(packed)
@@ -292,24 +257,23 @@
     @staticmethod
     def unpack(buf):
         obj = nicira_dec_ttl()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 16: raise loxi.ProtocolError("nicira_dec_ttl length is %d, should be 16" % _length)
-        experimenter = struct.unpack_from('!L', buf, 4)[0]
-        assert(experimenter == 0x2320)
-        subtype = struct.unpack_from('!H', buf, 8)[0]
-        assert(subtype == 18)
-        obj.pad = struct.unpack_from('!H', buf, 10)[0]
-        obj.pad2 = struct.unpack_from('!L', buf, 12)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_VENDOR)
+        _len = reader.read('!H')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x2320)
+        _subtype = reader.read('!H')[0]
+        assert(_subtype == 18)
+        reader.skip(2)
+        reader.skip(4)
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
-        if self.pad != other.pad: return False
-        if self.pad2 != other.pad2: return False
         return True
 
     def __ne__(self, other):
@@ -324,11 +288,6 @@
         with q.group():
             with q.indent(2):
                 q.breakable()
-                q.text("pad = ");
-                q.text("%#x" % self.pad)
-                q.text(","); q.breakable()
-                q.text("pad2 = ");
-                q.text("%#x" % self.pad2)
             q.breakable()
         q.text('}')
 
@@ -344,6 +303,7 @@
             self.max_len = max_len
         else:
             self.max_len = 0
+        return
 
     def pack(self):
         packed = []
@@ -358,18 +318,19 @@
     @staticmethod
     def unpack(buf):
         obj = output()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_OUTPUT)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 8: raise loxi.ProtocolError("output length is %d, should be 8" % _length)
-        obj.port = struct.unpack_from('!H', buf, 4)[0]
-        obj.max_len = struct.unpack_from('!H', buf, 6)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_OUTPUT)
+        _len = reader.read('!H')[0]
+        obj.port = reader.read('!H')[0]
+        obj.max_len = reader.read('!H')[0]
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
         if self.port != other.port: return False
         if self.max_len != other.max_len: return False
         return True
@@ -397,22 +358,19 @@
 class set_dl_dst(Action):
     type = const.OFPAT_SET_DL_DST
 
-    def __init__(self, dl_addr=None, pad=None):
+    def __init__(self, dl_addr=None):
         if dl_addr != None:
             self.dl_addr = dl_addr
         else:
             self.dl_addr = [0,0,0,0,0,0]
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0,0,0,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("!6B", *self.dl_addr))
-        packed.append(struct.pack("!6B", *self.pad))
+        packed.append('\x00' * 6)
         length = sum([len(x) for x in packed])
         packed[1] = struct.pack("!H", length)
         return ''.join(packed)
@@ -420,20 +378,20 @@
     @staticmethod
     def unpack(buf):
         obj = set_dl_dst()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_SET_DL_DST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 16: raise loxi.ProtocolError("set_dl_dst length is %d, should be 16" % _length)
-        obj.dl_addr = list(struct.unpack_from('!6B', buf, 4))
-        obj.pad = list(struct.unpack_from('!6B', buf, 10))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_SET_DL_DST)
+        _len = reader.read('!H')[0]
+        obj.dl_addr = list(reader.read('!6B'))
+        reader.skip(6)
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
         if self.dl_addr != other.dl_addr: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -450,31 +408,25 @@
                 q.breakable()
                 q.text("dl_addr = ");
                 q.text(util.pretty_mac(self.dl_addr))
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
 class set_dl_src(Action):
     type = const.OFPAT_SET_DL_SRC
 
-    def __init__(self, dl_addr=None, pad=None):
+    def __init__(self, dl_addr=None):
         if dl_addr != None:
             self.dl_addr = dl_addr
         else:
             self.dl_addr = [0,0,0,0,0,0]
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0,0,0,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("!6B", *self.dl_addr))
-        packed.append(struct.pack("!6B", *self.pad))
+        packed.append('\x00' * 6)
         length = sum([len(x) for x in packed])
         packed[1] = struct.pack("!H", length)
         return ''.join(packed)
@@ -482,20 +434,20 @@
     @staticmethod
     def unpack(buf):
         obj = set_dl_src()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_SET_DL_SRC)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 16: raise loxi.ProtocolError("set_dl_src length is %d, should be 16" % _length)
-        obj.dl_addr = list(struct.unpack_from('!6B', buf, 4))
-        obj.pad = list(struct.unpack_from('!6B', buf, 10))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_SET_DL_SRC)
+        _len = reader.read('!H')[0]
+        obj.dl_addr = list(reader.read('!6B'))
+        reader.skip(6)
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
         if self.dl_addr != other.dl_addr: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -512,9 +464,6 @@
                 q.breakable()
                 q.text("dl_addr = ");
                 q.text(util.pretty_mac(self.dl_addr))
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
@@ -526,6 +475,7 @@
             self.nw_addr = nw_addr
         else:
             self.nw_addr = 0
+        return
 
     def pack(self):
         packed = []
@@ -539,17 +489,18 @@
     @staticmethod
     def unpack(buf):
         obj = set_nw_dst()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_SET_NW_DST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 8: raise loxi.ProtocolError("set_nw_dst length is %d, should be 8" % _length)
-        obj.nw_addr = struct.unpack_from('!L', buf, 4)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_SET_NW_DST)
+        _len = reader.read('!H')[0]
+        obj.nw_addr = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
         if self.nw_addr != other.nw_addr: return False
         return True
 
@@ -578,6 +529,7 @@
             self.nw_addr = nw_addr
         else:
             self.nw_addr = 0
+        return
 
     def pack(self):
         packed = []
@@ -591,17 +543,18 @@
     @staticmethod
     def unpack(buf):
         obj = set_nw_src()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_SET_NW_SRC)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 8: raise loxi.ProtocolError("set_nw_src length is %d, should be 8" % _length)
-        obj.nw_addr = struct.unpack_from('!L', buf, 4)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_SET_NW_SRC)
+        _len = reader.read('!H')[0]
+        obj.nw_addr = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
         if self.nw_addr != other.nw_addr: return False
         return True
 
@@ -625,22 +578,19 @@
 class set_nw_tos(Action):
     type = const.OFPAT_SET_NW_TOS
 
-    def __init__(self, nw_tos=None, pad=None):
+    def __init__(self, nw_tos=None):
         if nw_tos != None:
             self.nw_tos = nw_tos
         else:
             self.nw_tos = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,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("!B", self.nw_tos))
-        packed.append(struct.pack("!3B", *self.pad))
+        packed.append('\x00' * 3)
         length = sum([len(x) for x in packed])
         packed[1] = struct.pack("!H", length)
         return ''.join(packed)
@@ -648,20 +598,20 @@
     @staticmethod
     def unpack(buf):
         obj = set_nw_tos()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_SET_NW_TOS)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 8: raise loxi.ProtocolError("set_nw_tos length is %d, should be 8" % _length)
-        obj.nw_tos = struct.unpack_from('!B', buf, 4)[0]
-        obj.pad = list(struct.unpack_from('!3B', buf, 5))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_SET_NW_TOS)
+        _len = reader.read('!H')[0]
+        obj.nw_tos = reader.read('!B')[0]
+        reader.skip(3)
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
         if self.nw_tos != other.nw_tos: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -678,31 +628,25 @@
                 q.breakable()
                 q.text("nw_tos = ");
                 q.text("%#x" % self.nw_tos)
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
 class set_tp_dst(Action):
     type = const.OFPAT_SET_TP_DST
 
-    def __init__(self, tp_port=None, pad=None):
+    def __init__(self, tp_port=None):
         if tp_port != None:
             self.tp_port = tp_port
         else:
             self.tp_port = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,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("!H", self.tp_port))
-        packed.append(struct.pack("!2B", *self.pad))
+        packed.append('\x00' * 2)
         length = sum([len(x) for x in packed])
         packed[1] = struct.pack("!H", length)
         return ''.join(packed)
@@ -710,20 +654,20 @@
     @staticmethod
     def unpack(buf):
         obj = set_tp_dst()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_SET_TP_DST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 8: raise loxi.ProtocolError("set_tp_dst length is %d, should be 8" % _length)
-        obj.tp_port = struct.unpack_from('!H', buf, 4)[0]
-        obj.pad = list(struct.unpack_from('!2B', buf, 6))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_SET_TP_DST)
+        _len = reader.read('!H')[0]
+        obj.tp_port = reader.read('!H')[0]
+        reader.skip(2)
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
         if self.tp_port != other.tp_port: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -740,31 +684,25 @@
                 q.breakable()
                 q.text("tp_port = ");
                 q.text("%#x" % self.tp_port)
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
 class set_tp_src(Action):
     type = const.OFPAT_SET_TP_SRC
 
-    def __init__(self, tp_port=None, pad=None):
+    def __init__(self, tp_port=None):
         if tp_port != None:
             self.tp_port = tp_port
         else:
             self.tp_port = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,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("!H", self.tp_port))
-        packed.append(struct.pack("!2B", *self.pad))
+        packed.append('\x00' * 2)
         length = sum([len(x) for x in packed])
         packed[1] = struct.pack("!H", length)
         return ''.join(packed)
@@ -772,20 +710,20 @@
     @staticmethod
     def unpack(buf):
         obj = set_tp_src()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_SET_TP_SRC)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 8: raise loxi.ProtocolError("set_tp_src length is %d, should be 8" % _length)
-        obj.tp_port = struct.unpack_from('!H', buf, 4)[0]
-        obj.pad = list(struct.unpack_from('!2B', buf, 6))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_SET_TP_SRC)
+        _len = reader.read('!H')[0]
+        obj.tp_port = reader.read('!H')[0]
+        reader.skip(2)
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
         if self.tp_port != other.tp_port: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -802,31 +740,25 @@
                 q.breakable()
                 q.text("tp_port = ");
                 q.text("%#x" % self.tp_port)
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
 class set_vlan_pcp(Action):
     type = const.OFPAT_SET_VLAN_PCP
 
-    def __init__(self, vlan_pcp=None, pad=None):
+    def __init__(self, vlan_pcp=None):
         if vlan_pcp != None:
             self.vlan_pcp = vlan_pcp
         else:
             self.vlan_pcp = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,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("!B", self.vlan_pcp))
-        packed.append(struct.pack("!3B", *self.pad))
+        packed.append('\x00' * 3)
         length = sum([len(x) for x in packed])
         packed[1] = struct.pack("!H", length)
         return ''.join(packed)
@@ -834,20 +766,20 @@
     @staticmethod
     def unpack(buf):
         obj = set_vlan_pcp()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_SET_VLAN_PCP)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 8: raise loxi.ProtocolError("set_vlan_pcp length is %d, should be 8" % _length)
-        obj.vlan_pcp = struct.unpack_from('!B', buf, 4)[0]
-        obj.pad = list(struct.unpack_from('!3B', buf, 5))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_SET_VLAN_PCP)
+        _len = reader.read('!H')[0]
+        obj.vlan_pcp = reader.read('!B')[0]
+        reader.skip(3)
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
         if self.vlan_pcp != other.vlan_pcp: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -864,31 +796,25 @@
                 q.breakable()
                 q.text("vlan_pcp = ");
                 q.text("%#x" % self.vlan_pcp)
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
 class set_vlan_vid(Action):
     type = const.OFPAT_SET_VLAN_VID
 
-    def __init__(self, vlan_vid=None, pad=None):
+    def __init__(self, vlan_vid=None):
         if vlan_vid != None:
             self.vlan_vid = vlan_vid
         else:
             self.vlan_vid = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,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("!H", self.vlan_vid))
-        packed.append(struct.pack("!2B", *self.pad))
+        packed.append('\x00' * 2)
         length = sum([len(x) for x in packed])
         packed[1] = struct.pack("!H", length)
         return ''.join(packed)
@@ -896,20 +822,20 @@
     @staticmethod
     def unpack(buf):
         obj = set_vlan_vid()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_SET_VLAN_VID)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 8: raise loxi.ProtocolError("set_vlan_vid length is %d, should be 8" % _length)
-        obj.vlan_vid = struct.unpack_from('!H', buf, 4)[0]
-        obj.pad = list(struct.unpack_from('!2B', buf, 6))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_SET_VLAN_VID)
+        _len = reader.read('!H')[0]
+        obj.vlan_vid = reader.read('!H')[0]
+        reader.skip(2)
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
         if self.vlan_vid != other.vlan_vid: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -926,26 +852,20 @@
                 q.breakable()
                 q.text("vlan_vid = ");
                 q.text("%#x" % self.vlan_vid)
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
 class strip_vlan(Action):
     type = const.OFPAT_STRIP_VLAN
 
-    def __init__(self, pad=None):
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0,0]
+    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("!4B", *self.pad))
+        packed.append('\x00' * 4)
         length = sum([len(x) for x in packed])
         packed[1] = struct.pack("!H", length)
         return ''.join(packed)
@@ -953,18 +873,18 @@
     @staticmethod
     def unpack(buf):
         obj = strip_vlan()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPAT_STRIP_VLAN)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 8: raise loxi.ProtocolError("strip_vlan length is %d, should be 8" % _length)
-        obj.pad = list(struct.unpack_from('!4B', buf, 4))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPAT_STRIP_VLAN)
+        _len = reader.read('!H')[0]
+        reader.skip(4)
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.type != other.type: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -979,26 +899,22 @@
         with q.group():
             with q.indent(2):
                 q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
 
-def parse_vendor(buf):
-    if len(buf) < 16:
-        raise loxi.ProtocolError("experimenter action too short")
+def parse_vendor(reader):
 
-    experimenter, = struct.unpack_from("!L", buf, 4)
+    experimenter, = reader.peek("!4xL")
     if experimenter == 0x005c16c7: # Big Switch Networks
-        subtype, = struct.unpack_from("!L", buf, 8)
+        subtype, = reader.peek("!8xL")
     elif experimenter == 0x00002320: # Nicira
-        subtype, = struct.unpack_from("!H", buf, 8)
+        subtype, = reader.peek("!8xH")
     else:
         raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter)
 
     if subtype in experimenter_parsers[experimenter]:
-        return experimenter_parsers[experimenter][subtype](buf)
+        return experimenter_parsers[experimenter][subtype](reader)
     else:
         raise loxi.ProtocolError("unexpected BSN experimenter subtype %#x" % subtype)
 
diff --git a/src/python/loxi/of10/common.py b/src/python/loxi/of10/common.py
index 07c41d0..cfee494 100644
--- a/src/python/loxi/of10/common.py
+++ b/src/python/loxi/of10/common.py
@@ -1,17 +1,6 @@
-#
-# Copyright 2012, 2013, Big Switch Networks, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+# Copyright (c) 2011, 2012 Open Networking Foundation
+# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
 
 # Automatically generated by LOXI from template common.py
 # Do not modify
@@ -21,58 +10,59 @@
 import action
 import const
 import util
+import loxi.generic_util
+
 
 # HACK make this module visible as 'common' to simplify code generation
 common = sys.modules[__name__]
 
-def unpack_list_flow_stats_entry(buf):
-    entries = []
-    offset = 0
-    while offset < len(buf):
-        length, = struct.unpack_from("!H", buf, offset)
-        if length == 0: raise loxi.ProtocolError("entry length is 0")
-        if offset + length > len(buf): raise loxi.ProtocolError("entry length overruns list length")
-        entries.append(flow_stats_entry.unpack(buffer(buf, offset, length)))
-        offset += length
-    return entries
+def unpack_list_flow_stats_entry(reader):
+    return loxi.generic_util.unpack_list_lv16(reader, flow_stats_entry.unpack)
 
-def unpack_list_queue_prop(buf):
-    entries = []
-    offset = 0
-    while offset < len(buf):
-        type, length, = struct.unpack_from("!HH", buf, offset)
-        if length == 0: raise loxi.ProtocolError("entry length is 0")
-        if offset + length > len(buf): raise loxi.ProtocolError("entry length overruns list length")
-        if type == const.OFPQT_MIN_RATE:
-            entry = queue_prop_min_rate.unpack(buffer(buf, offset, length))
+def unpack_list_queue_prop(reader):
+    def deserializer(reader, typ):
+        if typ == const.OFPQT_MIN_RATE:
+            return queue_prop_min_rate.unpack(reader)
         else:
-            raise loxi.ProtocolError("unknown queue prop %d" % type)
-        entries.append(entry)
-        offset += length
-    return entries
+            raise loxi.ProtocolError("unknown queue prop %d" % typ)
+    return loxi.generic_util.unpack_list_tlv16(reader, deserializer)
 
-def unpack_list_packet_queue(buf):
-    entries = []
-    offset = 0
-    while offset < len(buf):
-        _, length, = struct.unpack_from("!LH", buf, offset)
-        if length == 0: raise loxi.ProtocolError("entry length is 0")
-        if offset + length > len(buf): raise loxi.ProtocolError("entry length overruns list length")
-        entries.append(packet_queue.unpack(buffer(buf, offset, length)))
-        offset += length
-    return entries
+def unpack_list_packet_queue(reader):
+    def wrapper(reader):
+        length, = reader.peek('!4xH')
+        return packet_queue.unpack(reader.slice(length))
+    return loxi.generic_util.unpack_list(reader, wrapper)
+
+def unpack_list_hello_elem(reader):
+    def deserializer(reader, typ):
+        if typ == const.OFPHET_VERSIONBITMAP:
+            return hello_elem_versionbitmap.unpack(reader)
+        else:
+            return None
+    return [x for x in loxi.generic_util.unpack_list_tlv16(reader, deserializer) if x != None]
+
+def unpack_list_bucket(reader):
+    return loxi.generic_util.unpack_list_lv16(reader, bucket.unpack)
+
+def unpack_list_group_desc_stats_entry(reader):
+    return loxi.generic_util.unpack_list_lv16(reader, group_desc_stats_entry.unpack)
+
+def unpack_list_group_stats_entry(reader):
+    return loxi.generic_util.unpack_list_lv16(reader, group_stats_entry.unpack)
+
+def unpack_list_meter_stats(reader):
+    def wrapper(reader):
+        length, = reader.peek('!4xH')
+        return meter_stats.unpack(reader.slice(length))
+    return loxi.generic_util.unpack_list(reader, wrapper)
 
 class bsn_interface(object):
 
-    def __init__(self, hw_addr=None, pad=None, name=None, ipv4_addr=None, ipv4_netmask=None):
+    def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
         if hw_addr != None:
             self.hw_addr = hw_addr
         else:
             self.hw_addr = [0,0,0,0,0,0]
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = 0
         if name != None:
             self.name = name
         else:
@@ -85,11 +75,12 @@
             self.ipv4_netmask = ipv4_netmask
         else:
             self.ipv4_netmask = 0
+        return
 
     def pack(self):
         packed = []
         packed.append(struct.pack("!6B", *self.hw_addr))
-        packed.append(struct.pack("!H", self.pad))
+        packed.append('\x00' * 2)
         packed.append(struct.pack("!16s", self.name))
         packed.append(struct.pack("!L", self.ipv4_addr))
         packed.append(struct.pack("!L", self.ipv4_netmask))
@@ -97,19 +88,21 @@
 
     @staticmethod
     def unpack(buf):
-        assert(len(buf) >= 32) # Should be verified by caller
         obj = bsn_interface()
-        obj.hw_addr = list(struct.unpack_from('!6B', buf, 0))
-        obj.pad = struct.unpack_from('!H', buf, 6)[0]
-        obj.name = str(buffer(buf, 8, 16)).rstrip("\x00")
-        obj.ipv4_addr = struct.unpack_from('!L', buf, 24)[0]
-        obj.ipv4_netmask = struct.unpack_from('!L', buf, 28)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        obj.hw_addr = list(reader.read('!6B'))
+        reader.skip(2)
+        obj.name = reader.read("!16s")[0].rstrip("\x00")
+        obj.ipv4_addr = reader.read('!L')[0]
+        obj.ipv4_netmask = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
         if self.hw_addr != other.hw_addr: return False
-        if self.pad != other.pad: return False
         if self.name != other.name: return False
         if self.ipv4_addr != other.ipv4_addr: return False
         if self.ipv4_netmask != other.ipv4_netmask: return False
@@ -130,9 +123,6 @@
                 q.text("hw_addr = ");
                 q.text(util.pretty_mac(self.hw_addr))
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.text("%#x" % self.pad)
-                q.text(","); q.breakable()
                 q.text("name = ");
                 q.pp(self.name)
                 q.text(","); q.breakable()
@@ -146,15 +136,11 @@
 
 class flow_stats_entry(object):
 
-    def __init__(self, table_id=None, pad=None, match=None, duration_sec=None, duration_nsec=None, priority=None, idle_timeout=None, hard_timeout=None, pad2=None, cookie=None, packet_count=None, byte_count=None, actions=None):
+    def __init__(self, table_id=None, match=None, duration_sec=None, duration_nsec=None, priority=None, idle_timeout=None, hard_timeout=None, cookie=None, packet_count=None, byte_count=None, actions=None):
         if table_id != None:
             self.table_id = table_id
         else:
             self.table_id = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = 0
         if match != None:
             self.match = match
         else:
@@ -179,10 +165,6 @@
             self.hard_timeout = hard_timeout
         else:
             self.hard_timeout = 0
-        if pad2 != None:
-            self.pad2 = pad2
-        else:
-            self.pad2 = [0,0,0,0,0,0]
         if cookie != None:
             self.cookie = cookie
         else:
@@ -199,19 +181,20 @@
             self.actions = actions
         else:
             self.actions = []
+        return
 
     def pack(self):
         packed = []
         packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
         packed.append(struct.pack("!B", self.table_id))
-        packed.append(struct.pack("!B", self.pad))
+        packed.append('\x00' * 1)
         packed.append(self.match.pack())
         packed.append(struct.pack("!L", self.duration_sec))
         packed.append(struct.pack("!L", self.duration_nsec))
         packed.append(struct.pack("!H", self.priority))
         packed.append(struct.pack("!H", self.idle_timeout))
         packed.append(struct.pack("!H", self.hard_timeout))
-        packed.append(struct.pack("!6B", *self.pad2))
+        packed.append('\x00' * 6)
         packed.append(struct.pack("!Q", self.cookie))
         packed.append(struct.pack("!Q", self.packet_count))
         packed.append(struct.pack("!Q", self.byte_count))
@@ -222,37 +205,36 @@
 
     @staticmethod
     def unpack(buf):
-        assert(len(buf) >= 88) # Should be verified by caller
         obj = flow_stats_entry()
-        _length = struct.unpack_from('!H', buf, 0)[0]
-        assert(_length == len(buf))
-        if _length < 88: raise loxi.ProtocolError("flow_stats_entry length is %d, should be at least 88" % _length)
-        obj.table_id = struct.unpack_from('!B', buf, 2)[0]
-        obj.pad = struct.unpack_from('!B', buf, 3)[0]
-        obj.match = common.match.unpack(buffer(buf, 4))
-        obj.duration_sec = struct.unpack_from('!L', buf, 44)[0]
-        obj.duration_nsec = struct.unpack_from('!L', buf, 48)[0]
-        obj.priority = struct.unpack_from('!H', buf, 52)[0]
-        obj.idle_timeout = struct.unpack_from('!H', buf, 54)[0]
-        obj.hard_timeout = struct.unpack_from('!H', buf, 56)[0]
-        obj.pad2 = list(struct.unpack_from('!6B', buf, 58))
-        obj.cookie = struct.unpack_from('!Q', buf, 64)[0]
-        obj.packet_count = struct.unpack_from('!Q', buf, 72)[0]
-        obj.byte_count = struct.unpack_from('!Q', buf, 80)[0]
-        obj.actions = action.unpack_list(buffer(buf, 88))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _length = reader.read('!H')[0]
+        obj.table_id = reader.read('!B')[0]
+        reader.skip(1)
+        obj.match = common.match.unpack(reader)
+        obj.duration_sec = reader.read('!L')[0]
+        obj.duration_nsec = reader.read('!L')[0]
+        obj.priority = reader.read('!H')[0]
+        obj.idle_timeout = reader.read('!H')[0]
+        obj.hard_timeout = reader.read('!H')[0]
+        reader.skip(6)
+        obj.cookie = reader.read('!Q')[0]
+        obj.packet_count = reader.read('!Q')[0]
+        obj.byte_count = reader.read('!Q')[0]
+        obj.actions = action.unpack_list(reader)
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
         if self.table_id != other.table_id: return False
-        if self.pad != other.pad: return False
         if self.match != other.match: return False
         if self.duration_sec != other.duration_sec: return False
         if self.duration_nsec != other.duration_nsec: return False
         if self.priority != other.priority: return False
         if self.idle_timeout != other.idle_timeout: return False
         if self.hard_timeout != other.hard_timeout: return False
-        if self.pad2 != other.pad2: return False
         if self.cookie != other.cookie: return False
         if self.packet_count != other.packet_count: return False
         if self.byte_count != other.byte_count: return False
@@ -274,9 +256,6 @@
                 q.text("table_id = ");
                 q.text("%#x" % self.table_id)
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.text("%#x" % self.pad)
-                q.text(","); q.breakable()
                 q.text("match = ");
                 q.pp(self.match)
                 q.text(","); q.breakable()
@@ -295,9 +274,6 @@
                 q.text("hard_timeout = ");
                 q.text("%#x" % self.hard_timeout)
                 q.text(","); q.breakable()
-                q.text("pad2 = ");
-                q.pp(self.pad2)
-                q.text(","); q.breakable()
                 q.text("cookie = ");
                 q.text("%#x" % self.cookie)
                 q.text(","); q.breakable()
@@ -314,7 +290,7 @@
 
 class match_v1(object):
 
-    def __init__(self, wildcards=None, in_port=None, eth_src=None, eth_dst=None, vlan_vid=None, vlan_pcp=None, pad1=None, eth_type=None, ip_dscp=None, ip_proto=None, pad2=None, ipv4_src=None, ipv4_dst=None, tcp_src=None, tcp_dst=None):
+    def __init__(self, wildcards=None, in_port=None, eth_src=None, eth_dst=None, vlan_vid=None, vlan_pcp=None, eth_type=None, ip_dscp=None, ip_proto=None, ipv4_src=None, ipv4_dst=None, tcp_src=None, tcp_dst=None):
         if wildcards != None:
             self.wildcards = wildcards
         else:
@@ -339,10 +315,6 @@
             self.vlan_pcp = vlan_pcp
         else:
             self.vlan_pcp = 0
-        if pad1 != None:
-            self.pad1 = pad1
-        else:
-            self.pad1 = 0
         if eth_type != None:
             self.eth_type = eth_type
         else:
@@ -355,10 +327,6 @@
             self.ip_proto = ip_proto
         else:
             self.ip_proto = 0
-        if pad2 != None:
-            self.pad2 = pad2
-        else:
-            self.pad2 = [0,0]
         if ipv4_src != None:
             self.ipv4_src = ipv4_src
         else:
@@ -375,6 +343,7 @@
             self.tcp_dst = tcp_dst
         else:
             self.tcp_dst = 0
+        return
 
     def pack(self):
         packed = []
@@ -384,11 +353,11 @@
         packed.append(struct.pack("!6B", *self.eth_dst))
         packed.append(struct.pack("!H", self.vlan_vid))
         packed.append(struct.pack("!B", self.vlan_pcp))
-        packed.append(struct.pack("!B", self.pad1))
+        packed.append('\x00' * 1)
         packed.append(struct.pack("!H", self.eth_type))
         packed.append(struct.pack("!B", self.ip_dscp))
         packed.append(struct.pack("!B", self.ip_proto))
-        packed.append(struct.pack("!2B", *self.pad2))
+        packed.append('\x00' * 2)
         packed.append(struct.pack("!L", self.ipv4_src))
         packed.append(struct.pack("!L", self.ipv4_dst))
         packed.append(struct.pack("!H", self.tcp_src))
@@ -397,23 +366,26 @@
 
     @staticmethod
     def unpack(buf):
-        assert(len(buf) >= 40) # Should be verified by caller
         obj = match_v1()
-        obj.wildcards = struct.unpack_from('!L', buf, 0)[0]
-        obj.in_port = struct.unpack_from('!H', buf, 4)[0]
-        obj.eth_src = list(struct.unpack_from('!6B', buf, 6))
-        obj.eth_dst = list(struct.unpack_from('!6B', buf, 12))
-        obj.vlan_vid = struct.unpack_from('!H', buf, 18)[0]
-        obj.vlan_pcp = struct.unpack_from('!B', buf, 20)[0]
-        obj.pad1 = struct.unpack_from('!B', buf, 21)[0]
-        obj.eth_type = struct.unpack_from('!H', buf, 22)[0]
-        obj.ip_dscp = struct.unpack_from('!B', buf, 24)[0]
-        obj.ip_proto = struct.unpack_from('!B', buf, 25)[0]
-        obj.pad2 = list(struct.unpack_from('!2B', buf, 26))
-        obj.ipv4_src = struct.unpack_from('!L', buf, 28)[0]
-        obj.ipv4_dst = struct.unpack_from('!L', buf, 32)[0]
-        obj.tcp_src = struct.unpack_from('!H', buf, 36)[0]
-        obj.tcp_dst = struct.unpack_from('!H', buf, 38)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        obj.wildcards = reader.read('!L')[0]
+        obj.in_port = reader.read('!H')[0]
+        obj.eth_src = list(reader.read('!6B'))
+        obj.eth_dst = list(reader.read('!6B'))
+        obj.vlan_vid = reader.read('!H')[0]
+        obj.vlan_pcp = reader.read('!B')[0]
+        reader.skip(1)
+        obj.eth_type = reader.read('!H')[0]
+        obj.ip_dscp = reader.read('!B')[0]
+        obj.ip_proto = reader.read('!B')[0]
+        reader.skip(2)
+        obj.ipv4_src = reader.read('!L')[0]
+        obj.ipv4_dst = reader.read('!L')[0]
+        obj.tcp_src = reader.read('!H')[0]
+        obj.tcp_dst = reader.read('!H')[0]
         return obj
 
     def __eq__(self, other):
@@ -424,11 +396,9 @@
         if self.eth_dst != other.eth_dst: return False
         if self.vlan_vid != other.vlan_vid: return False
         if self.vlan_pcp != other.vlan_pcp: return False
-        if self.pad1 != other.pad1: return False
         if self.eth_type != other.eth_type: return False
         if self.ip_dscp != other.ip_dscp: return False
         if self.ip_proto != other.ip_proto: return False
-        if self.pad2 != other.pad2: return False
         if self.ipv4_src != other.ipv4_src: return False
         if self.ipv4_dst != other.ipv4_dst: return False
         if self.tcp_src != other.tcp_src: return False
@@ -465,9 +435,6 @@
                 q.text("vlan_pcp = ");
                 q.text("%#x" % self.vlan_pcp)
                 q.text(","); q.breakable()
-                q.text("pad1 = ");
-                q.text("%#x" % self.pad1)
-                q.text(","); q.breakable()
                 q.text("eth_type = ");
                 q.text("%#x" % self.eth_type)
                 q.text(","); q.breakable()
@@ -477,9 +444,6 @@
                 q.text("ip_proto = ");
                 q.text("%#x" % self.ip_proto)
                 q.text(","); q.breakable()
-                q.text("pad2 = ");
-                q.pp(self.pad2)
-                q.text(","); q.breakable()
                 q.text("ipv4_src = ");
                 q.text(util.pretty_ipv4(self.ipv4_src))
                 q.text(","); q.breakable()
@@ -494,29 +458,24 @@
             q.breakable()
         q.text('}')
 
-match = match_v1
-
 class packet_queue(object):
 
-    def __init__(self, queue_id=None, pad=None, properties=None):
+    def __init__(self, queue_id=None, properties=None):
         if queue_id != None:
             self.queue_id = queue_id
         else:
             self.queue_id = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0]
         if properties != None:
             self.properties = properties
         else:
             self.properties = []
+        return
 
     def pack(self):
         packed = []
         packed.append(struct.pack("!L", self.queue_id))
         packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
-        packed.append(struct.pack("!2B", *self.pad))
+        packed.append('\x00' * 2)
         packed.append("".join([x.pack() for x in self.properties]))
         length = sum([len(x) for x in packed])
         packed[1] = struct.pack("!H", length)
@@ -524,20 +483,20 @@
 
     @staticmethod
     def unpack(buf):
-        assert(len(buf) >= 8) # Should be verified by caller
         obj = packet_queue()
-        obj.queue_id = struct.unpack_from('!L', buf, 0)[0]
-        _length = struct.unpack_from('!H', buf, 4)[0]
-        assert(_length == len(buf))
-        if _length < 8: raise loxi.ProtocolError("packet_queue length is %d, should be at least 8" % _length)
-        obj.pad = list(struct.unpack_from('!2B', buf, 6))
-        obj.properties = common.unpack_list_queue_prop(buffer(buf, 8))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        obj.queue_id = reader.read('!L')[0]
+        _len = reader.read('!H')[0]
+        reader.skip(2)
+        obj.properties = common.unpack_list_queue_prop(reader)
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
         if self.queue_id != other.queue_id: return False
-        if self.pad != other.pad: return False
         if self.properties != other.properties: return False
         return True
 
@@ -556,9 +515,6 @@
                 q.text("queue_id = ");
                 q.text("%#x" % self.queue_id)
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
-                q.text(","); q.breakable()
                 q.text("properties = ");
                 q.pp(self.properties)
             q.breakable()
@@ -603,6 +559,7 @@
             self.peer = peer
         else:
             self.peer = 0
+        return
 
     def pack(self):
         packed = []
@@ -619,17 +576,20 @@
 
     @staticmethod
     def unpack(buf):
-        assert(len(buf) >= 48) # Should be verified by caller
         obj = port_desc()
-        obj.port_no = struct.unpack_from('!H', buf, 0)[0]
-        obj.hw_addr = list(struct.unpack_from('!6B', buf, 2))
-        obj.name = str(buffer(buf, 8, 16)).rstrip("\x00")
-        obj.config = struct.unpack_from('!L', buf, 24)[0]
-        obj.state = struct.unpack_from('!L', buf, 28)[0]
-        obj.curr = struct.unpack_from('!L', buf, 32)[0]
-        obj.advertised = struct.unpack_from('!L', buf, 36)[0]
-        obj.supported = struct.unpack_from('!L', buf, 40)[0]
-        obj.peer = struct.unpack_from('!L', buf, 44)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        obj.port_no = reader.read('!H')[0]
+        obj.hw_addr = list(reader.read('!6B'))
+        obj.name = reader.read("!16s")[0].rstrip("\x00")
+        obj.config = reader.read('!L')[0]
+        obj.state = reader.read('!L')[0]
+        obj.curr = reader.read('!L')[0]
+        obj.advertised = reader.read('!L')[0]
+        obj.supported = reader.read('!L')[0]
+        obj.peer = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
@@ -688,15 +648,11 @@
 
 class port_stats_entry(object):
 
-    def __init__(self, port_no=None, pad=None, rx_packets=None, tx_packets=None, rx_bytes=None, tx_bytes=None, rx_dropped=None, tx_dropped=None, rx_errors=None, tx_errors=None, rx_frame_err=None, rx_over_err=None, rx_crc_err=None, collisions=None):
+    def __init__(self, port_no=None, rx_packets=None, tx_packets=None, rx_bytes=None, tx_bytes=None, rx_dropped=None, tx_dropped=None, rx_errors=None, tx_errors=None, rx_frame_err=None, rx_over_err=None, rx_crc_err=None, collisions=None):
         if port_no != None:
             self.port_no = port_no
         else:
             self.port_no = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0,0,0,0]
         if rx_packets != None:
             self.rx_packets = rx_packets
         else:
@@ -745,11 +701,12 @@
             self.collisions = collisions
         else:
             self.collisions = 0
+        return
 
     def pack(self):
         packed = []
         packed.append(struct.pack("!H", self.port_no))
-        packed.append(struct.pack("!6B", *self.pad))
+        packed.append('\x00' * 6)
         packed.append(struct.pack("!Q", self.rx_packets))
         packed.append(struct.pack("!Q", self.tx_packets))
         packed.append(struct.pack("!Q", self.rx_bytes))
@@ -766,28 +723,30 @@
 
     @staticmethod
     def unpack(buf):
-        assert(len(buf) >= 104) # Should be verified by caller
         obj = port_stats_entry()
-        obj.port_no = struct.unpack_from('!H', buf, 0)[0]
-        obj.pad = list(struct.unpack_from('!6B', buf, 2))
-        obj.rx_packets = struct.unpack_from('!Q', buf, 8)[0]
-        obj.tx_packets = struct.unpack_from('!Q', buf, 16)[0]
-        obj.rx_bytes = struct.unpack_from('!Q', buf, 24)[0]
-        obj.tx_bytes = struct.unpack_from('!Q', buf, 32)[0]
-        obj.rx_dropped = struct.unpack_from('!Q', buf, 40)[0]
-        obj.tx_dropped = struct.unpack_from('!Q', buf, 48)[0]
-        obj.rx_errors = struct.unpack_from('!Q', buf, 56)[0]
-        obj.tx_errors = struct.unpack_from('!Q', buf, 64)[0]
-        obj.rx_frame_err = struct.unpack_from('!Q', buf, 72)[0]
-        obj.rx_over_err = struct.unpack_from('!Q', buf, 80)[0]
-        obj.rx_crc_err = struct.unpack_from('!Q', buf, 88)[0]
-        obj.collisions = struct.unpack_from('!Q', buf, 96)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        obj.port_no = reader.read('!H')[0]
+        reader.skip(6)
+        obj.rx_packets = reader.read('!Q')[0]
+        obj.tx_packets = reader.read('!Q')[0]
+        obj.rx_bytes = reader.read('!Q')[0]
+        obj.tx_bytes = reader.read('!Q')[0]
+        obj.rx_dropped = reader.read('!Q')[0]
+        obj.tx_dropped = reader.read('!Q')[0]
+        obj.rx_errors = reader.read('!Q')[0]
+        obj.tx_errors = reader.read('!Q')[0]
+        obj.rx_frame_err = reader.read('!Q')[0]
+        obj.rx_over_err = reader.read('!Q')[0]
+        obj.rx_crc_err = reader.read('!Q')[0]
+        obj.collisions = reader.read('!Q')[0]
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
         if self.port_no != other.port_no: return False
-        if self.pad != other.pad: return False
         if self.rx_packets != other.rx_packets: return False
         if self.tx_packets != other.tx_packets: return False
         if self.rx_bytes != other.rx_bytes: return False
@@ -817,9 +776,6 @@
                 q.text("port_no = ");
                 q.text(util.pretty_port(self.port_no))
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
-                q.text(","); q.breakable()
                 q.text("rx_packets = ");
                 q.text("%#x" % self.rx_packets)
                 q.text(","); q.breakable()
@@ -861,50 +817,42 @@
 class queue_prop_min_rate(object):
     type = const.OFPQT_MIN_RATE
 
-    def __init__(self, pad=None, rate=None, pad2=None):
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0,0]
+    def __init__(self, rate=None):
         if rate != None:
             self.rate = rate
         else:
             self.rate = 0
-        if pad2 != None:
-            self.pad2 = pad2
-        else:
-            self.pad2 = [0,0,0,0,0,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("!4B", *self.pad))
+        packed.append('\x00' * 4)
         packed.append(struct.pack("!H", self.rate))
-        packed.append(struct.pack("!6B", *self.pad2))
+        packed.append('\x00' * 6)
         length = sum([len(x) for x in packed])
         packed[1] = struct.pack("!H", length)
         return ''.join(packed)
 
     @staticmethod
     def unpack(buf):
-        assert(len(buf) >= 16) # Should be verified by caller
         obj = queue_prop_min_rate()
-        type = struct.unpack_from('!H', buf, 0)[0]
-        assert(type == const.OFPQT_MIN_RATE)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 16: raise loxi.ProtocolError("queue_prop_min_rate length is %d, should be 16" % _length)
-        obj.pad = list(struct.unpack_from('!4B', buf, 4))
-        obj.rate = struct.unpack_from('!H', buf, 8)[0]
-        obj.pad2 = list(struct.unpack_from('!6B', buf, 10))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _type = reader.read('!H')[0]
+        assert(_type == const.OFPQT_MIN_RATE)
+        _len = reader.read('!H')[0]
+        reader.skip(4)
+        obj.rate = reader.read('!H')[0]
+        reader.skip(6)
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
-        if self.pad != other.pad: return False
         if self.rate != other.rate: return False
-        if self.pad2 != other.pad2: return False
         return True
 
     def __ne__(self, other):
@@ -919,28 +867,18 @@
         with q.group():
             with q.indent(2):
                 q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
-                q.text(","); q.breakable()
                 q.text("rate = ");
                 q.text("%#x" % self.rate)
-                q.text(","); q.breakable()
-                q.text("pad2 = ");
-                q.pp(self.pad2)
             q.breakable()
         q.text('}')
 
 class queue_stats_entry(object):
 
-    def __init__(self, port_no=None, pad=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None):
+    def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None):
         if port_no != None:
             self.port_no = port_no
         else:
             self.port_no = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0]
         if queue_id != None:
             self.queue_id = queue_id
         else:
@@ -957,11 +895,12 @@
             self.tx_errors = tx_errors
         else:
             self.tx_errors = 0
+        return
 
     def pack(self):
         packed = []
         packed.append(struct.pack("!H", self.port_no))
-        packed.append(struct.pack("!2B", *self.pad))
+        packed.append('\x00' * 2)
         packed.append(struct.pack("!L", self.queue_id))
         packed.append(struct.pack("!Q", self.tx_bytes))
         packed.append(struct.pack("!Q", self.tx_packets))
@@ -970,20 +909,22 @@
 
     @staticmethod
     def unpack(buf):
-        assert(len(buf) >= 32) # Should be verified by caller
         obj = queue_stats_entry()
-        obj.port_no = struct.unpack_from('!H', buf, 0)[0]
-        obj.pad = list(struct.unpack_from('!2B', buf, 2))
-        obj.queue_id = struct.unpack_from('!L', buf, 4)[0]
-        obj.tx_bytes = struct.unpack_from('!Q', buf, 8)[0]
-        obj.tx_packets = struct.unpack_from('!Q', buf, 16)[0]
-        obj.tx_errors = struct.unpack_from('!Q', buf, 24)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        obj.port_no = reader.read('!H')[0]
+        reader.skip(2)
+        obj.queue_id = reader.read('!L')[0]
+        obj.tx_bytes = reader.read('!Q')[0]
+        obj.tx_packets = reader.read('!Q')[0]
+        obj.tx_errors = reader.read('!Q')[0]
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
         if self.port_no != other.port_no: return False
-        if self.pad != other.pad: return False
         if self.queue_id != other.queue_id: return False
         if self.tx_bytes != other.tx_bytes: return False
         if self.tx_packets != other.tx_packets: return False
@@ -1005,9 +946,6 @@
                 q.text("port_no = ");
                 q.text(util.pretty_port(self.port_no))
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
-                q.text(","); q.breakable()
                 q.text("queue_id = ");
                 q.text("%#x" % self.queue_id)
                 q.text(","); q.breakable()
@@ -1024,15 +962,11 @@
 
 class table_stats_entry(object):
 
-    def __init__(self, table_id=None, pad=None, name=None, wildcards=None, max_entries=None, active_count=None, lookup_count=None, matched_count=None):
+    def __init__(self, table_id=None, name=None, wildcards=None, max_entries=None, active_count=None, lookup_count=None, matched_count=None):
         if table_id != None:
             self.table_id = table_id
         else:
             self.table_id = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0]
         if name != None:
             self.name = name
         else:
@@ -1057,11 +991,12 @@
             self.matched_count = matched_count
         else:
             self.matched_count = 0
+        return
 
     def pack(self):
         packed = []
         packed.append(struct.pack("!B", self.table_id))
-        packed.append(struct.pack("!3B", *self.pad))
+        packed.append('\x00' * 3)
         packed.append(struct.pack("!32s", self.name))
         packed.append(struct.pack("!L", self.wildcards))
         packed.append(struct.pack("!L", self.max_entries))
@@ -1072,22 +1007,24 @@
 
     @staticmethod
     def unpack(buf):
-        assert(len(buf) >= 64) # Should be verified by caller
         obj = table_stats_entry()
-        obj.table_id = struct.unpack_from('!B', buf, 0)[0]
-        obj.pad = list(struct.unpack_from('!3B', buf, 1))
-        obj.name = str(buffer(buf, 4, 32)).rstrip("\x00")
-        obj.wildcards = struct.unpack_from('!L', buf, 36)[0]
-        obj.max_entries = struct.unpack_from('!L', buf, 40)[0]
-        obj.active_count = struct.unpack_from('!L', buf, 44)[0]
-        obj.lookup_count = struct.unpack_from('!Q', buf, 48)[0]
-        obj.matched_count = struct.unpack_from('!Q', buf, 56)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        obj.table_id = reader.read('!B')[0]
+        reader.skip(3)
+        obj.name = reader.read("!32s")[0].rstrip("\x00")
+        obj.wildcards = reader.read('!L')[0]
+        obj.max_entries = reader.read('!L')[0]
+        obj.active_count = reader.read('!L')[0]
+        obj.lookup_count = reader.read('!Q')[0]
+        obj.matched_count = reader.read('!Q')[0]
         return obj
 
     def __eq__(self, other):
         if type(self) != type(other): return False
         if self.table_id != other.table_id: return False
-        if self.pad != other.pad: return False
         if self.name != other.name: return False
         if self.wildcards != other.wildcards: return False
         if self.max_entries != other.max_entries: return False
@@ -1111,9 +1048,6 @@
                 q.text("table_id = ");
                 q.text("%#x" % self.table_id)
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
-                q.text(","); q.breakable()
                 q.text("name = ");
                 q.pp(self.name)
                 q.text(","); q.breakable()
@@ -1134,3 +1068,5 @@
             q.breakable()
         q.text('}')
 
+
+match = match_v1
diff --git a/src/python/loxi/of10/const.py b/src/python/loxi/of10/const.py
index e269071..3b9a177 100644
--- a/src/python/loxi/of10/const.py
+++ b/src/python/loxi/of10/const.py
@@ -1,17 +1,6 @@
-#
-# Copyright 2012, 2013, Big Switch Networks, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+# Copyright (c) 2011, 2012 Open Networking Foundation
+# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
 
 # Automatically generated by LOXI from template const.py
 # Do not modify
@@ -24,18 +13,18 @@
 OFP_MAX_PORT_NAME_LEN = 16
 OFP_MAX_TABLE_NAME_LEN = 32
 SERIAL_NUM_LEN = 32
-OFPFW_ICMP_TYPE = (1 << 6)
-OFPFW_ICMP_CODE = (1 << 7)
+OFPFW_ICMP_TYPE = 64
 OFP_DEFAULT_MISS_SEND_LEN = 128
+OFPFW_ICMP_CODE = 128
 DESC_STR_LEN = 256
-OFP_DL_TYPE_NOT_ETH_TYPE = 0x05ff
-OFP_DL_TYPE_ETH2_CUTOFF = 0x0600
+OFP_DL_TYPE_NOT_ETH_TYPE = 1535
+OFP_DL_TYPE_ETH2_CUTOFF = 1536
 OFP_TCP_PORT = 6633
 OFP_SSL_PORT = 6633
-OFP_DEFAULT_PRIORITY = 0x8000
-OFPQ_MIN_RATE_UNCFG = 0xffff
-OFP_VLAN_NONE = 0xffff
-OFPQ_ALL = 0xffffffff
+OFP_DEFAULT_PRIORITY = 32768
+OFP_VLAN_NONE = 65535
+OFPQ_MIN_RATE_UNCFG = 65535
+OFPQ_ALL = 4294967295
 
 # Identifiers from group ofp_action_type
 OFPAT_OUTPUT = 0
@@ -50,7 +39,7 @@
 OFPAT_SET_TP_SRC = 9
 OFPAT_SET_TP_DST = 10
 OFPAT_ENQUEUE = 11
-OFPAT_VENDOR = 0xffff
+OFPAT_VENDOR = 65535
 
 ofp_action_type_map = {
     0: 'OFPAT_OUTPUT',
@@ -65,7 +54,7 @@
     9: 'OFPAT_SET_TP_SRC',
     10: 'OFPAT_SET_TP_DST',
     11: 'OFPAT_ENQUEUE',
-    0xffff: 'OFPAT_VENDOR',
+    65535: 'OFPAT_VENDOR',
 }
 
 # Identifiers from group ofp_bad_action_code
@@ -115,24 +104,24 @@
 }
 
 # Identifiers from group ofp_capabilities
-OFPC_FLOW_STATS = 1 << 0
-OFPC_TABLE_STATS = 1 << 1
-OFPC_PORT_STATS = 1 << 2
-OFPC_STP = 1 << 3
-OFPC_RESERVED = 1 << 4
-OFPC_IP_REASM = 1 << 5
-OFPC_QUEUE_STATS = 1 << 6
-OFPC_ARP_MATCH_IP = 1 << 7
+OFPC_FLOW_STATS = 1
+OFPC_TABLE_STATS = 2
+OFPC_PORT_STATS = 4
+OFPC_STP = 8
+OFPC_RESERVED = 16
+OFPC_IP_REASM = 32
+OFPC_QUEUE_STATS = 64
+OFPC_ARP_MATCH_IP = 128
 
 ofp_capabilities_map = {
-    1 << 0: 'OFPC_FLOW_STATS',
-    1 << 1: 'OFPC_TABLE_STATS',
-    1 << 2: 'OFPC_PORT_STATS',
-    1 << 3: 'OFPC_STP',
-    1 << 4: 'OFPC_RESERVED',
-    1 << 5: 'OFPC_IP_REASM',
-    1 << 6: 'OFPC_QUEUE_STATS',
-    1 << 7: 'OFPC_ARP_MATCH_IP',
+    1: 'OFPC_FLOW_STATS',
+    2: 'OFPC_TABLE_STATS',
+    4: 'OFPC_PORT_STATS',
+    8: 'OFPC_STP',
+    16: 'OFPC_RESERVED',
+    32: 'OFPC_IP_REASM',
+    64: 'OFPC_QUEUE_STATS',
+    128: 'OFPC_ARP_MATCH_IP',
 }
 
 # Identifiers from group ofp_config_flags
@@ -198,14 +187,14 @@
 }
 
 # Identifiers from group ofp_flow_mod_flags
-OFPFF_SEND_FLOW_REM = 1 << 0
-OFPFF_CHECK_OVERLAP = 1 << 1
-OFPFF_EMERG = 1 << 2
+OFPFF_SEND_FLOW_REM = 1
+OFPFF_CHECK_OVERLAP = 2
+OFPFF_EMERG = 4
 
 ofp_flow_mod_flags_map = {
-    1 << 0: 'OFPFF_SEND_FLOW_REM',
-    1 << 1: 'OFPFF_CHECK_OVERLAP',
-    1 << 2: 'OFPFF_EMERG',
+    1: 'OFPFF_SEND_FLOW_REM',
+    2: 'OFPFF_CHECK_OVERLAP',
+    4: 'OFPFF_EMERG',
 }
 
 # Identifiers from group ofp_flow_removed_reason
@@ -220,37 +209,37 @@
 }
 
 # Identifiers from group ofp_flow_wildcards
-OFPFW_IN_PORT = 1 << 0
-OFPFW_DL_VLAN = 1 << 1
-OFPFW_DL_SRC = 1 << 2
+OFPFW_IN_PORT = 1
+OFPFW_DL_VLAN = 2
+OFPFW_DL_SRC = 4
 OFPFW_NW_DST_BITS = 6
 OFPFW_NW_SRC_BITS = 6
 OFPFW_NW_SRC_SHIFT = 8
-OFPFW_DL_DST = 1 << 3
+OFPFW_DL_DST = 8
 OFPFW_NW_DST_SHIFT = 14
-OFPFW_DL_TYPE = 1 << 4
-OFPFW_NW_PROTO = 1 << 5
-OFPFW_TP_SRC = 1 << 6
-OFPFW_TP_DST = 1 << 7
-OFPFW_NW_SRC_ALL = 32 << (8)
-OFPFW_NW_SRC_MASK = ((1 << (6)) - 1) << (8)
-OFPFW_NW_DST_ALL = 32 << (14)
-OFPFW_NW_DST_MASK = ((1 << (6)) - 1) << (14)
-OFPFW_DL_VLAN_PCP = 1 << 20
-OFPFW_NW_TOS = 1 << 21
-OFPFW_ALL = ((1 << 22) - 1)
+OFPFW_DL_TYPE = 16
+OFPFW_NW_PROTO = 32
+OFPFW_TP_SRC = 64
+OFPFW_TP_DST = 128
+OFPFW_NW_SRC_ALL = 8192
+OFPFW_NW_SRC_MASK = 16128
+OFPFW_NW_DST_ALL = 524288
+OFPFW_NW_DST_MASK = 1032192
+OFPFW_DL_VLAN_PCP = 1048576
+OFPFW_NW_TOS = 2097152
+OFPFW_ALL = 4194303
 
 ofp_flow_wildcards_map = {
-    1 << 0: 'OFPFW_IN_PORT',
-    1 << 1: 'OFPFW_DL_VLAN',
-    1 << 2: 'OFPFW_DL_SRC',
-    1 << 3: 'OFPFW_DL_DST',
-    1 << 4: 'OFPFW_DL_TYPE',
-    1 << 5: 'OFPFW_NW_PROTO',
-    1 << 6: 'OFPFW_TP_SRC',
-    1 << 7: 'OFPFW_TP_DST',
-    1 << 20: 'OFPFW_DL_VLAN_PCP',
-    1 << 21: 'OFPFW_NW_TOS',
+    1: 'OFPFW_IN_PORT',
+    2: 'OFPFW_DL_VLAN',
+    4: 'OFPFW_DL_SRC',
+    8: 'OFPFW_DL_DST',
+    16: 'OFPFW_DL_TYPE',
+    32: 'OFPFW_NW_PROTO',
+    64: 'OFPFW_TP_SRC',
+    128: 'OFPFW_TP_DST',
+    1048576: 'OFPFW_DL_VLAN_PCP',
+    2097152: 'OFPFW_NW_TOS',
 }
 
 # Identifiers from group ofp_hello_failed_code
@@ -262,6 +251,17 @@
     1: 'OFPHFC_EPERM',
 }
 
+# Identifiers from group ofp_nicira_controller_role
+NX_ROLE_OTHER = 0
+NX_ROLE_MASTER = 1
+NX_ROLE_SLAVE = 2
+
+ofp_nicira_controller_role_map = {
+    0: 'NX_ROLE_OTHER',
+    1: 'NX_ROLE_MASTER',
+    2: 'NX_ROLE_SLAVE',
+}
+
 # Identifiers from group ofp_packet_in_reason
 OFPR_NO_MATCH = 0
 OFPR_ACTION = 1
@@ -295,51 +295,51 @@
 }
 
 # Identifiers from group ofp_port_config
-OFPPC_PORT_DOWN = 1 << 0
-OFPPC_NO_STP = 1 << 1
-OFPPC_NO_RECV = 1 << 2
-OFPPC_NO_RECV_STP = 1 << 3
-OFPPC_NO_FLOOD = 1 << 4
-OFPPC_NO_FWD = 1 << 5
-OFPPC_NO_PACKET_IN = 1 << 6
+OFPPC_PORT_DOWN = 1
+OFPPC_NO_STP = 2
+OFPPC_NO_RECV = 4
+OFPPC_NO_RECV_STP = 8
+OFPPC_NO_FLOOD = 16
+OFPPC_NO_FWD = 32
+OFPPC_NO_PACKET_IN = 64
 
 ofp_port_config_map = {
-    1 << 0: 'OFPPC_PORT_DOWN',
-    1 << 1: 'OFPPC_NO_STP',
-    1 << 2: 'OFPPC_NO_RECV',
-    1 << 3: 'OFPPC_NO_RECV_STP',
-    1 << 4: 'OFPPC_NO_FLOOD',
-    1 << 5: 'OFPPC_NO_FWD',
-    1 << 6: 'OFPPC_NO_PACKET_IN',
+    1: 'OFPPC_PORT_DOWN',
+    2: 'OFPPC_NO_STP',
+    4: 'OFPPC_NO_RECV',
+    8: 'OFPPC_NO_RECV_STP',
+    16: 'OFPPC_NO_FLOOD',
+    32: 'OFPPC_NO_FWD',
+    64: 'OFPPC_NO_PACKET_IN',
 }
 
 # Identifiers from group ofp_port_features
-OFPPF_10MB_HD = 1 << 0
-OFPPF_10MB_FD = 1 << 1
-OFPPF_100MB_HD = 1 << 2
-OFPPF_100MB_FD = 1 << 3
-OFPPF_1GB_HD = 1 << 4
-OFPPF_1GB_FD = 1 << 5
-OFPPF_10GB_FD = 1 << 6
-OFPPF_COPPER = 1 << 7
-OFPPF_FIBER = 1 << 8
-OFPPF_AUTONEG = 1 << 9
-OFPPF_PAUSE = 1 << 10
-OFPPF_PAUSE_ASYM = 1 << 11
+OFPPF_10MB_HD = 1
+OFPPF_10MB_FD = 2
+OFPPF_100MB_HD = 4
+OFPPF_100MB_FD = 8
+OFPPF_1GB_HD = 16
+OFPPF_1GB_FD = 32
+OFPPF_10GB_FD = 64
+OFPPF_COPPER = 128
+OFPPF_FIBER = 256
+OFPPF_AUTONEG = 512
+OFPPF_PAUSE = 1024
+OFPPF_PAUSE_ASYM = 2048
 
 ofp_port_features_map = {
-    1 << 0: 'OFPPF_10MB_HD',
-    1 << 1: 'OFPPF_10MB_FD',
-    1 << 2: 'OFPPF_100MB_HD',
-    1 << 3: 'OFPPF_100MB_FD',
-    1 << 4: 'OFPPF_1GB_HD',
-    1 << 5: 'OFPPF_1GB_FD',
-    1 << 6: 'OFPPF_10GB_FD',
-    1 << 7: 'OFPPF_COPPER',
-    1 << 8: 'OFPPF_FIBER',
-    1 << 9: 'OFPPF_AUTONEG',
-    1 << 10: 'OFPPF_PAUSE',
-    1 << 11: 'OFPPF_PAUSE_ASYM',
+    1: 'OFPPF_10MB_HD',
+    2: 'OFPPF_10MB_FD',
+    4: 'OFPPF_100MB_HD',
+    8: 'OFPPF_100MB_FD',
+    16: 'OFPPF_1GB_HD',
+    32: 'OFPPF_1GB_FD',
+    64: 'OFPPF_10GB_FD',
+    128: 'OFPPF_COPPER',
+    256: 'OFPPF_FIBER',
+    512: 'OFPPF_AUTONEG',
+    1024: 'OFPPF_PAUSE',
+    2048: 'OFPPF_PAUSE_ASYM',
 }
 
 # Identifiers from group ofp_port_mod_failed_code
@@ -363,20 +363,20 @@
 }
 
 # Identifiers from group ofp_port_state
-OFPPS_STP_LISTEN = 0 << 8
-OFPPS_LINK_DOWN = 1 << 0
-OFPPS_STP_LEARN = 1 << 8
-OFPPS_STP_FORWARD = 2 << 8
-OFPPS_STP_BLOCK = 3 << 8
-OFPPS_STP_MASK = 3 << 8
+OFPPS_STP_LISTEN = 0
+OFPPS_LINK_DOWN = 1
+OFPPS_STP_LEARN = 256
+OFPPS_STP_FORWARD = 512
+OFPPS_STP_BLOCK = 768
+OFPPS_STP_MASK = 768
 
 ofp_port_state_map = {
-    0 << 8: 'OFPPS_STP_LISTEN',
-    1 << 0: 'OFPPS_LINK_DOWN',
-    1 << 8: 'OFPPS_STP_LEARN',
-    2 << 8: 'OFPPS_STP_FORWARD',
-    3 << 8: 'OFPPS_STP_BLOCK',
-    3 << 8: 'OFPPS_STP_MASK',
+    0: 'OFPPS_STP_LISTEN',
+    1: 'OFPPS_LINK_DOWN',
+    256: 'OFPPS_STP_LEARN',
+    512: 'OFPPS_STP_FORWARD',
+    768: 'OFPPS_STP_BLOCK',
+    768: 'OFPPS_STP_MASK',
 }
 
 # Identifiers from group ofp_queue_op_failed_code
@@ -400,10 +400,10 @@
 }
 
 # Identifiers from group ofp_stats_reply_flags
-OFPSF_REPLY_MORE = 1 << 0
+OFPSF_REPLY_MORE = 1
 
 ofp_stats_reply_flags_map = {
-    1 << 0: 'OFPSF_REPLY_MORE',
+    1: 'OFPSF_REPLY_MORE',
 }
 
 # Identifiers from group ofp_stats_types
@@ -413,7 +413,7 @@
 OFPST_TABLE = 3
 OFPST_PORT = 4
 OFPST_QUEUE = 5
-OFPST_VENDOR = 0xffff
+OFPST_VENDOR = 65535
 
 ofp_stats_types_map = {
     0: 'OFPST_DESC',
@@ -422,7 +422,7 @@
     3: 'OFPST_TABLE',
     4: 'OFPST_PORT',
     5: 'OFPST_QUEUE',
-    0xffff: 'OFPST_VENDOR',
+    65535: 'OFPST_VENDOR',
 }
 
 # Identifiers from group ofp_type
diff --git a/src/python/loxi/of10/message.py b/src/python/loxi/of10/message.py
index d80dac3..f12fe1d 100644
--- a/src/python/loxi/of10/message.py
+++ b/src/python/loxi/of10/message.py
@@ -1,17 +1,6 @@
-#
-# Copyright 2012, 2013, Big Switch Networks, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+# Copyright (c) 2011, 2012 Open Networking Foundation
+# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
 
 # Automatically generated by LOXI from template message.py
 # Do not modify
@@ -22,6 +11,7 @@
 import common
 import action # for unpack_list
 import util
+import loxi.generic_util
 
 class Message(object):
     version = const.OFP_VERSION
@@ -33,7 +23,7 @@
     type = const.OFPT_STATS_REPLY
     stats_type = const.OFPST_AGGREGATE
 
-    def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None, pad=None):
+    def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None):
         self.xid = xid
         if flags != None:
             self.flags = flags
@@ -51,10 +41,6 @@
             self.flow_count = flow_count
         else:
             self.flow_count = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0,0]
 
     def pack(self):
         packed = []
@@ -67,7 +53,7 @@
         packed.append(struct.pack("!Q", self.packet_count))
         packed.append(struct.pack("!Q", self.byte_count))
         packed.append(struct.pack("!L", self.flow_count))
-        packed.append(struct.pack("!4B", *self.pad))
+        packed.append('\x00' * 4)
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
         return ''.join(packed)
@@ -76,21 +62,23 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = aggregate_stats_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_STATS_REPLY)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 36: raise loxi.ProtocolError("aggregate_stats_reply length is %d, should be 36" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        stats_type = struct.unpack_from('!H', buf, 8)[0]
-        assert(stats_type == const.OFPST_AGGREGATE)
-        obj.flags = struct.unpack_from('!H', buf, 10)[0]
-        obj.packet_count = struct.unpack_from('!Q', buf, 12)[0]
-        obj.byte_count = struct.unpack_from('!Q', buf, 20)[0]
-        obj.flow_count = struct.unpack_from('!L', buf, 28)[0]
-        obj.pad = list(struct.unpack_from('!4B', buf, 32))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_STATS_REPLY)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _stats_type = reader.read('!H')[0]
+        assert(_stats_type == const.OFPST_AGGREGATE)
+        obj.flags = reader.read('!H')[0]
+        obj.packet_count = reader.read('!Q')[0]
+        obj.byte_count = reader.read('!Q')[0]
+        obj.flow_count = reader.read('!L')[0]
+        reader.skip(4)
         return obj
 
     def __eq__(self, other):
@@ -102,7 +90,6 @@
         if self.packet_count != other.packet_count: return False
         if self.byte_count != other.byte_count: return False
         if self.flow_count != other.flow_count: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -137,9 +124,6 @@
                 q.text(","); q.breakable()
                 q.text("flow_count = ");
                 q.text("%#x" % self.flow_count)
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
@@ -148,7 +132,7 @@
     type = const.OFPT_STATS_REQUEST
     stats_type = const.OFPST_AGGREGATE
 
-    def __init__(self, xid=None, flags=None, match=None, table_id=None, pad=None, out_port=None):
+    def __init__(self, xid=None, flags=None, match=None, table_id=None, out_port=None):
         self.xid = xid
         if flags != None:
             self.flags = flags
@@ -162,10 +146,6 @@
             self.table_id = table_id
         else:
             self.table_id = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = 0
         if out_port != None:
             self.out_port = out_port
         else:
@@ -181,7 +161,7 @@
         packed.append(struct.pack("!H", self.flags))
         packed.append(self.match.pack())
         packed.append(struct.pack("!B", self.table_id))
-        packed.append(struct.pack("!B", self.pad))
+        packed.append('\x00' * 1)
         packed.append(struct.pack("!H", self.out_port))
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
@@ -191,21 +171,23 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = aggregate_stats_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_STATS_REQUEST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 56: raise loxi.ProtocolError("aggregate_stats_request length is %d, should be 56" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        stats_type = struct.unpack_from('!H', buf, 8)[0]
-        assert(stats_type == const.OFPST_AGGREGATE)
-        obj.flags = struct.unpack_from('!H', buf, 10)[0]
-        obj.match = common.match.unpack(buffer(buf, 12))
-        obj.table_id = struct.unpack_from('!B', buf, 52)[0]
-        obj.pad = struct.unpack_from('!B', buf, 53)[0]
-        obj.out_port = struct.unpack_from('!H', buf, 54)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_STATS_REQUEST)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _stats_type = reader.read('!H')[0]
+        assert(_stats_type == const.OFPST_AGGREGATE)
+        obj.flags = reader.read('!H')[0]
+        obj.match = common.match.unpack(reader)
+        obj.table_id = reader.read('!B')[0]
+        reader.skip(1)
+        obj.out_port = reader.read('!H')[0]
         return obj
 
     def __eq__(self, other):
@@ -216,7 +198,6 @@
         if self.flags != other.flags: return False
         if self.match != other.match: return False
         if self.table_id != other.table_id: return False
-        if self.pad != other.pad: return False
         if self.out_port != other.out_port: return False
         return True
 
@@ -250,9 +231,6 @@
                 q.text("table_id = ");
                 q.text("%#x" % self.table_id)
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.text("%#x" % self.pad)
-                q.text(","); q.breakable()
                 q.text("out_port = ");
                 q.text(util.pretty_port(self.out_port))
             q.breakable()
@@ -279,14 +257,16 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = barrier_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_BARRIER_REPLY)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 8: raise loxi.ProtocolError("barrier_reply length is %d, should be 8" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_BARRIER_REPLY)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
@@ -340,14 +320,16 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = barrier_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_BARRIER_REQUEST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 8: raise loxi.ProtocolError("barrier_request length is %d, should be 8" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_BARRIER_REQUEST)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
@@ -410,19 +392,21 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = bsn_get_interfaces_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 16: raise loxi.ProtocolError("bsn_get_interfaces_reply length is %d, should be at least 16" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        experimenter = struct.unpack_from('!L', buf, 8)[0]
-        assert(experimenter == 0x5c16c7)
-        subtype = struct.unpack_from('!L', buf, 12)[0]
-        assert(subtype == 10)
-        obj.interfaces = util.unpack_array(common.bsn_interface.unpack, 32, buffer(buf, 16))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_VENDOR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x5c16c7)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 10)
+        obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack)
         return obj
 
     def __eq__(self, other):
@@ -484,18 +468,20 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = bsn_get_interfaces_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 16: raise loxi.ProtocolError("bsn_get_interfaces_request length is %d, should be 16" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        experimenter = struct.unpack_from('!L', buf, 8)[0]
-        assert(experimenter == 0x5c16c7)
-        subtype = struct.unpack_from('!L', buf, 12)[0]
-        assert(subtype == 9)
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_VENDOR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x5c16c7)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 9)
         return obj
 
     def __eq__(self, other):
@@ -534,16 +520,12 @@
     experimenter = 0x5c16c7
     subtype = 2
 
-    def __init__(self, xid=None, index=None, pad=None, mask=None):
+    def __init__(self, xid=None, index=None, mask=None):
         self.xid = xid
         if index != None:
             self.index = index
         else:
             self.index = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0]
         if mask != None:
             self.mask = mask
         else:
@@ -558,7 +540,7 @@
         packed.append(struct.pack("!L", self.experimenter))
         packed.append(struct.pack("!L", self.subtype))
         packed.append(struct.pack("!B", self.index))
-        packed.append(struct.pack("!3B", *self.pad))
+        packed.append('\x00' * 3)
         packed.append(struct.pack("!L", self.mask))
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
@@ -568,21 +550,23 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = bsn_get_ip_mask_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 24: raise loxi.ProtocolError("bsn_get_ip_mask_reply length is %d, should be 24" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        experimenter = struct.unpack_from('!L', buf, 8)[0]
-        assert(experimenter == 0x5c16c7)
-        subtype = struct.unpack_from('!L', buf, 12)[0]
-        assert(subtype == 2)
-        obj.index = struct.unpack_from('!B', buf, 16)[0]
-        obj.pad = list(struct.unpack_from('!3B', buf, 17))
-        obj.mask = struct.unpack_from('!L', buf, 20)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_VENDOR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x5c16c7)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 2)
+        obj.index = reader.read('!B')[0]
+        reader.skip(3)
+        obj.mask = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
@@ -591,7 +575,6 @@
         if self.type != other.type: return False
         if self.xid != other.xid: return False
         if self.index != other.index: return False
-        if self.pad != other.pad: return False
         if self.mask != other.mask: return False
         return True
 
@@ -619,9 +602,6 @@
                 q.text("index = ");
                 q.text("%#x" % self.index)
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
-                q.text(","); q.breakable()
                 q.text("mask = ");
                 q.text("%#x" % self.mask)
             q.breakable()
@@ -633,16 +613,12 @@
     experimenter = 0x5c16c7
     subtype = 1
 
-    def __init__(self, xid=None, index=None, pad=None):
+    def __init__(self, xid=None, index=None):
         self.xid = xid
         if index != None:
             self.index = index
         else:
             self.index = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0,0,0,0,0]
 
     def pack(self):
         packed = []
@@ -653,7 +629,7 @@
         packed.append(struct.pack("!L", self.experimenter))
         packed.append(struct.pack("!L", self.subtype))
         packed.append(struct.pack("!B", self.index))
-        packed.append(struct.pack("!7B", *self.pad))
+        packed.append('\x00' * 7)
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
         return ''.join(packed)
@@ -662,20 +638,22 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = bsn_get_ip_mask_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 24: raise loxi.ProtocolError("bsn_get_ip_mask_request length is %d, should be 24" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        experimenter = struct.unpack_from('!L', buf, 8)[0]
-        assert(experimenter == 0x5c16c7)
-        subtype = struct.unpack_from('!L', buf, 12)[0]
-        assert(subtype == 1)
-        obj.index = struct.unpack_from('!B', buf, 16)[0]
-        obj.pad = list(struct.unpack_from('!7B', buf, 17))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_VENDOR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x5c16c7)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 1)
+        obj.index = reader.read('!B')[0]
+        reader.skip(7)
         return obj
 
     def __eq__(self, other):
@@ -684,7 +662,6 @@
         if self.type != other.type: return False
         if self.xid != other.xid: return False
         if self.index != other.index: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -710,9 +687,6 @@
                 q.text(","); q.breakable()
                 q.text("index = ");
                 q.text("%#x" % self.index)
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
@@ -722,16 +696,12 @@
     experimenter = 0x5c16c7
     subtype = 5
 
-    def __init__(self, xid=None, report_mirror_ports=None, pad=None):
+    def __init__(self, xid=None, report_mirror_ports=None):
         self.xid = xid
         if report_mirror_ports != None:
             self.report_mirror_ports = report_mirror_ports
         else:
             self.report_mirror_ports = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0]
 
     def pack(self):
         packed = []
@@ -742,7 +712,7 @@
         packed.append(struct.pack("!L", self.experimenter))
         packed.append(struct.pack("!L", self.subtype))
         packed.append(struct.pack("!B", self.report_mirror_ports))
-        packed.append(struct.pack("!3B", *self.pad))
+        packed.append('\x00' * 3)
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
         return ''.join(packed)
@@ -751,20 +721,22 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = bsn_get_mirroring_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 20: raise loxi.ProtocolError("bsn_get_mirroring_reply length is %d, should be 20" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        experimenter = struct.unpack_from('!L', buf, 8)[0]
-        assert(experimenter == 0x5c16c7)
-        subtype = struct.unpack_from('!L', buf, 12)[0]
-        assert(subtype == 5)
-        obj.report_mirror_ports = struct.unpack_from('!B', buf, 16)[0]
-        obj.pad = list(struct.unpack_from('!3B', buf, 17))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_VENDOR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x5c16c7)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 5)
+        obj.report_mirror_ports = reader.read('!B')[0]
+        reader.skip(3)
         return obj
 
     def __eq__(self, other):
@@ -773,7 +745,6 @@
         if self.type != other.type: return False
         if self.xid != other.xid: return False
         if self.report_mirror_ports != other.report_mirror_ports: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -799,9 +770,6 @@
                 q.text(","); q.breakable()
                 q.text("report_mirror_ports = ");
                 q.text("%#x" % self.report_mirror_ports)
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
@@ -811,16 +779,12 @@
     experimenter = 0x5c16c7
     subtype = 4
 
-    def __init__(self, xid=None, report_mirror_ports=None, pad=None):
+    def __init__(self, xid=None, report_mirror_ports=None):
         self.xid = xid
         if report_mirror_ports != None:
             self.report_mirror_ports = report_mirror_ports
         else:
             self.report_mirror_ports = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0]
 
     def pack(self):
         packed = []
@@ -831,7 +795,7 @@
         packed.append(struct.pack("!L", self.experimenter))
         packed.append(struct.pack("!L", self.subtype))
         packed.append(struct.pack("!B", self.report_mirror_ports))
-        packed.append(struct.pack("!3B", *self.pad))
+        packed.append('\x00' * 3)
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
         return ''.join(packed)
@@ -840,20 +804,22 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = bsn_get_mirroring_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 20: raise loxi.ProtocolError("bsn_get_mirroring_request length is %d, should be 20" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        experimenter = struct.unpack_from('!L', buf, 8)[0]
-        assert(experimenter == 0x5c16c7)
-        subtype = struct.unpack_from('!L', buf, 12)[0]
-        assert(subtype == 4)
-        obj.report_mirror_ports = struct.unpack_from('!B', buf, 16)[0]
-        obj.pad = list(struct.unpack_from('!3B', buf, 17))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_VENDOR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x5c16c7)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 4)
+        obj.report_mirror_ports = reader.read('!B')[0]
+        reader.skip(3)
         return obj
 
     def __eq__(self, other):
@@ -862,7 +828,6 @@
         if self.type != other.type: return False
         if self.xid != other.xid: return False
         if self.report_mirror_ports != other.report_mirror_ports: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -888,9 +853,6 @@
                 q.text(","); q.breakable()
                 q.text("report_mirror_ports = ");
                 q.text("%#x" % self.report_mirror_ports)
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
@@ -900,16 +862,12 @@
     experimenter = 0x5c16c7
     subtype = 0
 
-    def __init__(self, xid=None, index=None, pad=None, mask=None):
+    def __init__(self, xid=None, index=None, mask=None):
         self.xid = xid
         if index != None:
             self.index = index
         else:
             self.index = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0]
         if mask != None:
             self.mask = mask
         else:
@@ -924,7 +882,7 @@
         packed.append(struct.pack("!L", self.experimenter))
         packed.append(struct.pack("!L", self.subtype))
         packed.append(struct.pack("!B", self.index))
-        packed.append(struct.pack("!3B", *self.pad))
+        packed.append('\x00' * 3)
         packed.append(struct.pack("!L", self.mask))
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
@@ -934,21 +892,23 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = bsn_set_ip_mask()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 24: raise loxi.ProtocolError("bsn_set_ip_mask length is %d, should be 24" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        experimenter = struct.unpack_from('!L', buf, 8)[0]
-        assert(experimenter == 0x5c16c7)
-        subtype = struct.unpack_from('!L', buf, 12)[0]
-        assert(subtype == 0)
-        obj.index = struct.unpack_from('!B', buf, 16)[0]
-        obj.pad = list(struct.unpack_from('!3B', buf, 17))
-        obj.mask = struct.unpack_from('!L', buf, 20)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_VENDOR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x5c16c7)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 0)
+        obj.index = reader.read('!B')[0]
+        reader.skip(3)
+        obj.mask = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
@@ -957,7 +917,6 @@
         if self.type != other.type: return False
         if self.xid != other.xid: return False
         if self.index != other.index: return False
-        if self.pad != other.pad: return False
         if self.mask != other.mask: return False
         return True
 
@@ -985,9 +944,6 @@
                 q.text("index = ");
                 q.text("%#x" % self.index)
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
-                q.text(","); q.breakable()
                 q.text("mask = ");
                 q.text("%#x" % self.mask)
             q.breakable()
@@ -999,16 +955,12 @@
     experimenter = 0x5c16c7
     subtype = 3
 
-    def __init__(self, xid=None, report_mirror_ports=None, pad=None):
+    def __init__(self, xid=None, report_mirror_ports=None):
         self.xid = xid
         if report_mirror_ports != None:
             self.report_mirror_ports = report_mirror_ports
         else:
             self.report_mirror_ports = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0]
 
     def pack(self):
         packed = []
@@ -1019,7 +971,7 @@
         packed.append(struct.pack("!L", self.experimenter))
         packed.append(struct.pack("!L", self.subtype))
         packed.append(struct.pack("!B", self.report_mirror_ports))
-        packed.append(struct.pack("!3B", *self.pad))
+        packed.append('\x00' * 3)
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
         return ''.join(packed)
@@ -1028,20 +980,22 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = bsn_set_mirroring()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 20: raise loxi.ProtocolError("bsn_set_mirroring length is %d, should be 20" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        experimenter = struct.unpack_from('!L', buf, 8)[0]
-        assert(experimenter == 0x5c16c7)
-        subtype = struct.unpack_from('!L', buf, 12)[0]
-        assert(subtype == 3)
-        obj.report_mirror_ports = struct.unpack_from('!B', buf, 16)[0]
-        obj.pad = list(struct.unpack_from('!3B', buf, 17))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_VENDOR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x5c16c7)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 3)
+        obj.report_mirror_ports = reader.read('!B')[0]
+        reader.skip(3)
         return obj
 
     def __eq__(self, other):
@@ -1050,7 +1004,6 @@
         if self.type != other.type: return False
         if self.xid != other.xid: return False
         if self.report_mirror_ports != other.report_mirror_ports: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -1076,9 +1029,129 @@
                 q.text(","); q.breakable()
                 q.text("report_mirror_ports = ");
                 q.text("%#x" % self.report_mirror_ports)
+            q.breakable()
+        q.text('}')
+
+class bsn_set_pktin_suppression(Message):
+    version = const.OFP_VERSION
+    type = const.OFPT_VENDOR
+    experimenter = 0x5c16c7
+    subtype = 11
+
+    def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None):
+        self.xid = xid
+        if enabled != None:
+            self.enabled = enabled
+        else:
+            self.enabled = 0
+        if idle_timeout != None:
+            self.idle_timeout = idle_timeout
+        else:
+            self.idle_timeout = 0
+        if hard_timeout != None:
+            self.hard_timeout = hard_timeout
+        else:
+            self.hard_timeout = 0
+        if priority != None:
+            self.priority = priority
+        else:
+            self.priority = 0
+        if cookie != None:
+            self.cookie = cookie
+        else:
+            self.cookie = 0
+
+    def pack(self):
+        packed = []
+        packed.append(struct.pack("!B", self.version))
+        packed.append(struct.pack("!B", self.type))
+        packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+        packed.append(struct.pack("!L", self.xid))
+        packed.append(struct.pack("!L", self.experimenter))
+        packed.append(struct.pack("!L", self.subtype))
+        packed.append(struct.pack("!B", self.enabled))
+        packed.append('\x00' * 1)
+        packed.append(struct.pack("!H", self.idle_timeout))
+        packed.append(struct.pack("!H", self.hard_timeout))
+        packed.append(struct.pack("!H", self.priority))
+        packed.append(struct.pack("!Q", self.cookie))
+        length = sum([len(x) for x in packed])
+        packed[2] = struct.pack("!H", length)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(buf):
+        if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+        obj = bsn_set_pktin_suppression()
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_VENDOR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x5c16c7)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 11)
+        obj.enabled = reader.read('!B')[0]
+        reader.skip(1)
+        obj.idle_timeout = reader.read('!H')[0]
+        obj.hard_timeout = reader.read('!H')[0]
+        obj.priority = reader.read('!H')[0]
+        obj.cookie = reader.read('!Q')[0]
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+        if self.version != other.version: return False
+        if self.type != other.type: return False
+        if self.xid != other.xid: return False
+        if self.enabled != other.enabled: return False
+        if self.idle_timeout != other.idle_timeout: return False
+        if self.hard_timeout != other.hard_timeout: return False
+        if self.priority != other.priority: return False
+        if self.cookie != other.cookie: return False
+        return True
+
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
+    def __str__(self):
+        return self.show()
+
+    def show(self):
+        import loxi.pp
+        return loxi.pp.pp(self)
+
+    def pretty_print(self, q):
+        q.text("bsn_set_pktin_suppression {")
+        with q.group():
+            with q.indent(2):
+                q.breakable()
+                q.text("xid = ");
+                if self.xid != None:
+                    q.text("%#x" % self.xid)
+                else:
+                    q.text('None')
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
+                q.text("enabled = ");
+                q.text("%#x" % self.enabled)
+                q.text(","); q.breakable()
+                q.text("idle_timeout = ");
+                q.text("%#x" % self.idle_timeout)
+                q.text(","); q.breakable()
+                q.text("hard_timeout = ");
+                q.text("%#x" % self.hard_timeout)
+                q.text(","); q.breakable()
+                q.text("priority = ");
+                q.text("%#x" % self.priority)
+                q.text(","); q.breakable()
+                q.text("cookie = ");
+                q.text("%#x" % self.cookie)
             q.breakable()
         q.text('}')
 
@@ -1117,20 +1190,22 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = bsn_shell_command()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 20: raise loxi.ProtocolError("bsn_shell_command length is %d, should be at least 20" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        experimenter = struct.unpack_from('!L', buf, 8)[0]
-        assert(experimenter == 0x5c16c7)
-        subtype = struct.unpack_from('!L', buf, 12)[0]
-        assert(subtype == 6)
-        obj.service = struct.unpack_from('!L', buf, 16)[0]
-        obj.data = buf[20:]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_VENDOR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x5c16c7)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 6)
+        obj.service = reader.read('!L')[0]
+        obj.data = str(reader.read_all())
         return obj
 
     def __eq__(self, other):
@@ -1201,19 +1276,21 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = bsn_shell_output()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 16: raise loxi.ProtocolError("bsn_shell_output length is %d, should be at least 16" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        experimenter = struct.unpack_from('!L', buf, 8)[0]
-        assert(experimenter == 0x5c16c7)
-        subtype = struct.unpack_from('!L', buf, 12)[0]
-        assert(subtype == 7)
-        obj.data = buf[16:]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_VENDOR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x5c16c7)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 7)
+        obj.data = str(reader.read_all())
         return obj
 
     def __eq__(self, other):
@@ -1280,19 +1357,21 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = bsn_shell_status()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 20: raise loxi.ProtocolError("bsn_shell_status length is %d, should be 20" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        experimenter = struct.unpack_from('!L', buf, 8)[0]
-        assert(experimenter == 0x5c16c7)
-        subtype = struct.unpack_from('!L', buf, 12)[0]
-        assert(subtype == 8)
-        obj.status = struct.unpack_from('!L', buf, 16)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_VENDOR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x5c16c7)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 8)
+        obj.status = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
@@ -1382,22 +1461,24 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = desc_stats_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_STATS_REPLY)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 1068: raise loxi.ProtocolError("desc_stats_reply length is %d, should be 1068" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        stats_type = struct.unpack_from('!H', buf, 8)[0]
-        assert(stats_type == const.OFPST_DESC)
-        obj.flags = struct.unpack_from('!H', buf, 10)[0]
-        obj.mfr_desc = str(buffer(buf, 12, 256)).rstrip("\x00")
-        obj.hw_desc = str(buffer(buf, 268, 256)).rstrip("\x00")
-        obj.sw_desc = str(buffer(buf, 524, 256)).rstrip("\x00")
-        obj.serial_num = str(buffer(buf, 780, 32)).rstrip("\x00")
-        obj.dp_desc = str(buffer(buf, 812, 256)).rstrip("\x00")
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_STATS_REPLY)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _stats_type = reader.read('!H')[0]
+        assert(_stats_type == const.OFPST_DESC)
+        obj.flags = reader.read('!H')[0]
+        obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00")
+        obj.hw_desc = reader.read("!256s")[0].rstrip("\x00")
+        obj.sw_desc = reader.read("!256s")[0].rstrip("\x00")
+        obj.serial_num = reader.read("!32s")[0].rstrip("\x00")
+        obj.dp_desc = reader.read("!256s")[0].rstrip("\x00")
         return obj
 
     def __eq__(self, other):
@@ -1482,17 +1563,19 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = desc_stats_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_STATS_REQUEST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 12: raise loxi.ProtocolError("desc_stats_request length is %d, should be 12" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        stats_type = struct.unpack_from('!H', buf, 8)[0]
-        assert(stats_type == const.OFPST_DESC)
-        obj.flags = struct.unpack_from('!H', buf, 10)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_STATS_REQUEST)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _stats_type = reader.read('!H')[0]
+        assert(_stats_type == const.OFPST_DESC)
+        obj.flags = reader.read('!H')[0]
         return obj
 
     def __eq__(self, other):
@@ -1555,15 +1638,17 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = echo_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_ECHO_REPLY)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 8: raise loxi.ProtocolError("echo_reply length is %d, should be at least 8" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.data = buf[8:]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_ECHO_REPLY)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.data = str(reader.read_all())
         return obj
 
     def __eq__(self, other):
@@ -1626,15 +1711,17 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = echo_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_ECHO_REQUEST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 8: raise loxi.ProtocolError("echo_request length is %d, should be at least 8" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.data = buf[8:]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_ECHO_REQUEST)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.data = str(reader.read_all())
         return obj
 
     def __eq__(self, other):
@@ -1707,17 +1794,19 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = error_msg()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_ERROR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 12: raise loxi.ProtocolError("error_msg length is %d, should be at least 12" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.err_type = struct.unpack_from('!H', buf, 8)[0]
-        obj.code = struct.unpack_from('!H', buf, 10)[0]
-        obj.data = buf[12:]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_ERROR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.err_type = reader.read('!H')[0]
+        obj.code = reader.read('!H')[0]
+        obj.data = str(reader.read_all())
         return obj
 
     def __eq__(self, other):
@@ -1800,19 +1889,21 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = experimenter_stats_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_STATS_REPLY)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 16: raise loxi.ProtocolError("experimenter_stats_reply length is %d, should be at least 16" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        stats_type = struct.unpack_from('!H', buf, 8)[0]
-        assert(stats_type == const.OFPST_VENDOR)
-        obj.flags = struct.unpack_from('!H', buf, 10)[0]
-        obj.experimenter = struct.unpack_from('!L', buf, 12)[0]
-        obj.data = buf[16:]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_STATS_REPLY)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _stats_type = reader.read('!H')[0]
+        assert(_stats_type == const.OFPST_VENDOR)
+        obj.flags = reader.read('!H')[0]
+        obj.experimenter = reader.read('!L')[0]
+        obj.data = str(reader.read_all())
         return obj
 
     def __eq__(self, other):
@@ -1895,19 +1986,21 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = experimenter_stats_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_STATS_REQUEST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 16: raise loxi.ProtocolError("experimenter_stats_request length is %d, should be at least 16" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        stats_type = struct.unpack_from('!H', buf, 8)[0]
-        assert(stats_type == const.OFPST_VENDOR)
-        obj.flags = struct.unpack_from('!H', buf, 10)[0]
-        obj.experimenter = struct.unpack_from('!L', buf, 12)[0]
-        obj.data = buf[16:]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_STATS_REQUEST)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _stats_type = reader.read('!H')[0]
+        assert(_stats_type == const.OFPST_VENDOR)
+        obj.flags = reader.read('!H')[0]
+        obj.experimenter = reader.read('!L')[0]
+        obj.data = str(reader.read_all())
         return obj
 
     def __eq__(self, other):
@@ -1956,7 +2049,7 @@
     version = const.OFP_VERSION
     type = const.OFPT_FEATURES_REPLY
 
-    def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, pad=None, capabilities=None, actions=None, ports=None):
+    def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, capabilities=None, actions=None, ports=None):
         self.xid = xid
         if datapath_id != None:
             self.datapath_id = datapath_id
@@ -1970,10 +2063,6 @@
             self.n_tables = n_tables
         else:
             self.n_tables = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0]
         if capabilities != None:
             self.capabilities = capabilities
         else:
@@ -1996,7 +2085,7 @@
         packed.append(struct.pack("!Q", self.datapath_id))
         packed.append(struct.pack("!L", self.n_buffers))
         packed.append(struct.pack("!B", self.n_tables))
-        packed.append(struct.pack("!3B", *self.pad))
+        packed.append('\x00' * 3)
         packed.append(struct.pack("!L", self.capabilities))
         packed.append(struct.pack("!L", self.actions))
         packed.append("".join([x.pack() for x in self.ports]))
@@ -2008,21 +2097,23 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = features_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_FEATURES_REPLY)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 32: raise loxi.ProtocolError("features_reply length is %d, should be at least 32" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.datapath_id = struct.unpack_from('!Q', buf, 8)[0]
-        obj.n_buffers = struct.unpack_from('!L', buf, 16)[0]
-        obj.n_tables = struct.unpack_from('!B', buf, 20)[0]
-        obj.pad = list(struct.unpack_from('!3B', buf, 21))
-        obj.capabilities = struct.unpack_from('!L', buf, 24)[0]
-        obj.actions = struct.unpack_from('!L', buf, 28)[0]
-        obj.ports = util.unpack_array(common.port_desc.unpack, 48, buffer(buf, 32))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_FEATURES_REPLY)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.datapath_id = reader.read('!Q')[0]
+        obj.n_buffers = reader.read('!L')[0]
+        obj.n_tables = reader.read('!B')[0]
+        reader.skip(3)
+        obj.capabilities = reader.read('!L')[0]
+        obj.actions = reader.read('!L')[0]
+        obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack)
         return obj
 
     def __eq__(self, other):
@@ -2033,7 +2124,6 @@
         if self.datapath_id != other.datapath_id: return False
         if self.n_buffers != other.n_buffers: return False
         if self.n_tables != other.n_tables: return False
-        if self.pad != other.pad: return False
         if self.capabilities != other.capabilities: return False
         if self.actions != other.actions: return False
         if self.ports != other.ports: return False
@@ -2069,9 +2159,6 @@
                 q.text("n_tables = ");
                 q.text("%#x" % self.n_tables)
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
-                q.text(","); q.breakable()
                 q.text("capabilities = ");
                 q.text("%#x" % self.capabilities)
                 q.text(","); q.breakable()
@@ -2104,14 +2191,16 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = features_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_FEATURES_REQUEST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 8: raise loxi.ProtocolError("features_request length is %d, should be 8" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_FEATURES_REQUEST)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
@@ -2212,25 +2301,27 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = flow_add()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_FLOW_MOD)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 72: raise loxi.ProtocolError("flow_add length is %d, should be at least 72" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.match = common.match.unpack(buffer(buf, 8))
-        obj.cookie = struct.unpack_from('!Q', buf, 48)[0]
-        _command = struct.unpack_from('!H', buf, 56)[0]
-        assert(_command == const.OFPFC_ADD)
-        obj.idle_timeout = struct.unpack_from('!H', buf, 58)[0]
-        obj.hard_timeout = struct.unpack_from('!H', buf, 60)[0]
-        obj.priority = struct.unpack_from('!H', buf, 62)[0]
-        obj.buffer_id = struct.unpack_from('!L', buf, 64)[0]
-        obj.out_port = struct.unpack_from('!H', buf, 68)[0]
-        obj.flags = struct.unpack_from('!H', buf, 70)[0]
-        obj.actions = action.unpack_list(buffer(buf, 72))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_FLOW_MOD)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.match = common.match.unpack(reader)
+        obj.cookie = reader.read('!Q')[0]
+        __command = reader.read('!H')[0]
+        assert(__command == const.OFPFC_ADD)
+        obj.idle_timeout = reader.read('!H')[0]
+        obj.hard_timeout = reader.read('!H')[0]
+        obj.priority = reader.read('!H')[0]
+        obj.buffer_id = reader.read('!L')[0]
+        obj.out_port = reader.read('!H')[0]
+        obj.flags = reader.read('!H')[0]
+        obj.actions = action.unpack_list(reader)
         return obj
 
     def __eq__(self, other):
@@ -2367,25 +2458,27 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = flow_delete()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_FLOW_MOD)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 72: raise loxi.ProtocolError("flow_delete length is %d, should be at least 72" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.match = common.match.unpack(buffer(buf, 8))
-        obj.cookie = struct.unpack_from('!Q', buf, 48)[0]
-        _command = struct.unpack_from('!H', buf, 56)[0]
-        assert(_command == const.OFPFC_DELETE)
-        obj.idle_timeout = struct.unpack_from('!H', buf, 58)[0]
-        obj.hard_timeout = struct.unpack_from('!H', buf, 60)[0]
-        obj.priority = struct.unpack_from('!H', buf, 62)[0]
-        obj.buffer_id = struct.unpack_from('!L', buf, 64)[0]
-        obj.out_port = struct.unpack_from('!H', buf, 68)[0]
-        obj.flags = struct.unpack_from('!H', buf, 70)[0]
-        obj.actions = action.unpack_list(buffer(buf, 72))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_FLOW_MOD)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.match = common.match.unpack(reader)
+        obj.cookie = reader.read('!Q')[0]
+        __command = reader.read('!H')[0]
+        assert(__command == const.OFPFC_DELETE)
+        obj.idle_timeout = reader.read('!H')[0]
+        obj.hard_timeout = reader.read('!H')[0]
+        obj.priority = reader.read('!H')[0]
+        obj.buffer_id = reader.read('!L')[0]
+        obj.out_port = reader.read('!H')[0]
+        obj.flags = reader.read('!H')[0]
+        obj.actions = action.unpack_list(reader)
         return obj
 
     def __eq__(self, other):
@@ -2522,25 +2615,27 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = flow_delete_strict()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_FLOW_MOD)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 72: raise loxi.ProtocolError("flow_delete_strict length is %d, should be at least 72" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.match = common.match.unpack(buffer(buf, 8))
-        obj.cookie = struct.unpack_from('!Q', buf, 48)[0]
-        _command = struct.unpack_from('!H', buf, 56)[0]
-        assert(_command == const.OFPFC_DELETE_STRICT)
-        obj.idle_timeout = struct.unpack_from('!H', buf, 58)[0]
-        obj.hard_timeout = struct.unpack_from('!H', buf, 60)[0]
-        obj.priority = struct.unpack_from('!H', buf, 62)[0]
-        obj.buffer_id = struct.unpack_from('!L', buf, 64)[0]
-        obj.out_port = struct.unpack_from('!H', buf, 68)[0]
-        obj.flags = struct.unpack_from('!H', buf, 70)[0]
-        obj.actions = action.unpack_list(buffer(buf, 72))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_FLOW_MOD)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.match = common.match.unpack(reader)
+        obj.cookie = reader.read('!Q')[0]
+        __command = reader.read('!H')[0]
+        assert(__command == const.OFPFC_DELETE_STRICT)
+        obj.idle_timeout = reader.read('!H')[0]
+        obj.hard_timeout = reader.read('!H')[0]
+        obj.priority = reader.read('!H')[0]
+        obj.buffer_id = reader.read('!L')[0]
+        obj.out_port = reader.read('!H')[0]
+        obj.flags = reader.read('!H')[0]
+        obj.actions = action.unpack_list(reader)
         return obj
 
     def __eq__(self, other):
@@ -2677,25 +2772,27 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = flow_modify()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_FLOW_MOD)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 72: raise loxi.ProtocolError("flow_modify length is %d, should be at least 72" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.match = common.match.unpack(buffer(buf, 8))
-        obj.cookie = struct.unpack_from('!Q', buf, 48)[0]
-        _command = struct.unpack_from('!H', buf, 56)[0]
-        assert(_command == const.OFPFC_MODIFY)
-        obj.idle_timeout = struct.unpack_from('!H', buf, 58)[0]
-        obj.hard_timeout = struct.unpack_from('!H', buf, 60)[0]
-        obj.priority = struct.unpack_from('!H', buf, 62)[0]
-        obj.buffer_id = struct.unpack_from('!L', buf, 64)[0]
-        obj.out_port = struct.unpack_from('!H', buf, 68)[0]
-        obj.flags = struct.unpack_from('!H', buf, 70)[0]
-        obj.actions = action.unpack_list(buffer(buf, 72))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_FLOW_MOD)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.match = common.match.unpack(reader)
+        obj.cookie = reader.read('!Q')[0]
+        __command = reader.read('!H')[0]
+        assert(__command == const.OFPFC_MODIFY)
+        obj.idle_timeout = reader.read('!H')[0]
+        obj.hard_timeout = reader.read('!H')[0]
+        obj.priority = reader.read('!H')[0]
+        obj.buffer_id = reader.read('!L')[0]
+        obj.out_port = reader.read('!H')[0]
+        obj.flags = reader.read('!H')[0]
+        obj.actions = action.unpack_list(reader)
         return obj
 
     def __eq__(self, other):
@@ -2832,25 +2929,27 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = flow_modify_strict()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_FLOW_MOD)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 72: raise loxi.ProtocolError("flow_modify_strict length is %d, should be at least 72" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.match = common.match.unpack(buffer(buf, 8))
-        obj.cookie = struct.unpack_from('!Q', buf, 48)[0]
-        _command = struct.unpack_from('!H', buf, 56)[0]
-        assert(_command == const.OFPFC_MODIFY_STRICT)
-        obj.idle_timeout = struct.unpack_from('!H', buf, 58)[0]
-        obj.hard_timeout = struct.unpack_from('!H', buf, 60)[0]
-        obj.priority = struct.unpack_from('!H', buf, 62)[0]
-        obj.buffer_id = struct.unpack_from('!L', buf, 64)[0]
-        obj.out_port = struct.unpack_from('!H', buf, 68)[0]
-        obj.flags = struct.unpack_from('!H', buf, 70)[0]
-        obj.actions = action.unpack_list(buffer(buf, 72))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_FLOW_MOD)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.match = common.match.unpack(reader)
+        obj.cookie = reader.read('!Q')[0]
+        __command = reader.read('!H')[0]
+        assert(__command == const.OFPFC_MODIFY_STRICT)
+        obj.idle_timeout = reader.read('!H')[0]
+        obj.hard_timeout = reader.read('!H')[0]
+        obj.priority = reader.read('!H')[0]
+        obj.buffer_id = reader.read('!L')[0]
+        obj.out_port = reader.read('!H')[0]
+        obj.flags = reader.read('!H')[0]
+        obj.actions = action.unpack_list(reader)
         return obj
 
     def __eq__(self, other):
@@ -2923,7 +3022,7 @@
     version = const.OFP_VERSION
     type = const.OFPT_FLOW_REMOVED
 
-    def __init__(self, xid=None, match=None, cookie=None, priority=None, reason=None, pad=None, duration_sec=None, duration_nsec=None, idle_timeout=None, pad2=None, packet_count=None, byte_count=None):
+    def __init__(self, xid=None, match=None, cookie=None, priority=None, reason=None, duration_sec=None, duration_nsec=None, idle_timeout=None, packet_count=None, byte_count=None):
         self.xid = xid
         if match != None:
             self.match = match
@@ -2941,10 +3040,6 @@
             self.reason = reason
         else:
             self.reason = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = 0
         if duration_sec != None:
             self.duration_sec = duration_sec
         else:
@@ -2957,10 +3052,6 @@
             self.idle_timeout = idle_timeout
         else:
             self.idle_timeout = 0
-        if pad2 != None:
-            self.pad2 = pad2
-        else:
-            self.pad2 = [0,0]
         if packet_count != None:
             self.packet_count = packet_count
         else:
@@ -2980,11 +3071,11 @@
         packed.append(struct.pack("!Q", self.cookie))
         packed.append(struct.pack("!H", self.priority))
         packed.append(struct.pack("!B", self.reason))
-        packed.append(struct.pack("!B", self.pad))
+        packed.append('\x00' * 1)
         packed.append(struct.pack("!L", self.duration_sec))
         packed.append(struct.pack("!L", self.duration_nsec))
         packed.append(struct.pack("!H", self.idle_timeout))
-        packed.append(struct.pack("!2B", *self.pad2))
+        packed.append('\x00' * 2)
         packed.append(struct.pack("!Q", self.packet_count))
         packed.append(struct.pack("!Q", self.byte_count))
         length = sum([len(x) for x in packed])
@@ -2995,25 +3086,27 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = flow_removed()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_FLOW_REMOVED)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 88: raise loxi.ProtocolError("flow_removed length is %d, should be 88" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.match = common.match.unpack(buffer(buf, 8))
-        obj.cookie = struct.unpack_from('!Q', buf, 48)[0]
-        obj.priority = struct.unpack_from('!H', buf, 56)[0]
-        obj.reason = struct.unpack_from('!B', buf, 58)[0]
-        obj.pad = struct.unpack_from('!B', buf, 59)[0]
-        obj.duration_sec = struct.unpack_from('!L', buf, 60)[0]
-        obj.duration_nsec = struct.unpack_from('!L', buf, 64)[0]
-        obj.idle_timeout = struct.unpack_from('!H', buf, 68)[0]
-        obj.pad2 = list(struct.unpack_from('!2B', buf, 70))
-        obj.packet_count = struct.unpack_from('!Q', buf, 72)[0]
-        obj.byte_count = struct.unpack_from('!Q', buf, 80)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_FLOW_REMOVED)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.match = common.match.unpack(reader)
+        obj.cookie = reader.read('!Q')[0]
+        obj.priority = reader.read('!H')[0]
+        obj.reason = reader.read('!B')[0]
+        reader.skip(1)
+        obj.duration_sec = reader.read('!L')[0]
+        obj.duration_nsec = reader.read('!L')[0]
+        obj.idle_timeout = reader.read('!H')[0]
+        reader.skip(2)
+        obj.packet_count = reader.read('!Q')[0]
+        obj.byte_count = reader.read('!Q')[0]
         return obj
 
     def __eq__(self, other):
@@ -3025,11 +3118,9 @@
         if self.cookie != other.cookie: return False
         if self.priority != other.priority: return False
         if self.reason != other.reason: return False
-        if self.pad != other.pad: return False
         if self.duration_sec != other.duration_sec: return False
         if self.duration_nsec != other.duration_nsec: return False
         if self.idle_timeout != other.idle_timeout: return False
-        if self.pad2 != other.pad2: return False
         if self.packet_count != other.packet_count: return False
         if self.byte_count != other.byte_count: return False
         return True
@@ -3067,9 +3158,6 @@
                 q.text("reason = ");
                 q.text("%#x" % self.reason)
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.text("%#x" % self.pad)
-                q.text(","); q.breakable()
                 q.text("duration_sec = ");
                 q.text("%#x" % self.duration_sec)
                 q.text(","); q.breakable()
@@ -3079,9 +3167,6 @@
                 q.text("idle_timeout = ");
                 q.text("%#x" % self.idle_timeout)
                 q.text(","); q.breakable()
-                q.text("pad2 = ");
-                q.pp(self.pad2)
-                q.text(","); q.breakable()
                 q.text("packet_count = ");
                 q.text("%#x" % self.packet_count)
                 q.text(","); q.breakable()
@@ -3123,18 +3208,20 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = flow_stats_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_STATS_REPLY)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 12: raise loxi.ProtocolError("flow_stats_reply length is %d, should be at least 12" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        stats_type = struct.unpack_from('!H', buf, 8)[0]
-        assert(stats_type == const.OFPST_FLOW)
-        obj.flags = struct.unpack_from('!H', buf, 10)[0]
-        obj.entries = common.unpack_list_flow_stats_entry(buffer(buf, 12))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_STATS_REPLY)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _stats_type = reader.read('!H')[0]
+        assert(_stats_type == const.OFPST_FLOW)
+        obj.flags = reader.read('!H')[0]
+        obj.entries = common.unpack_list_flow_stats_entry(reader)
         return obj
 
     def __eq__(self, other):
@@ -3180,7 +3267,7 @@
     type = const.OFPT_STATS_REQUEST
     stats_type = const.OFPST_FLOW
 
-    def __init__(self, xid=None, flags=None, match=None, table_id=None, pad=None, out_port=None):
+    def __init__(self, xid=None, flags=None, match=None, table_id=None, out_port=None):
         self.xid = xid
         if flags != None:
             self.flags = flags
@@ -3194,10 +3281,6 @@
             self.table_id = table_id
         else:
             self.table_id = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = 0
         if out_port != None:
             self.out_port = out_port
         else:
@@ -3213,7 +3296,7 @@
         packed.append(struct.pack("!H", self.flags))
         packed.append(self.match.pack())
         packed.append(struct.pack("!B", self.table_id))
-        packed.append(struct.pack("!B", self.pad))
+        packed.append('\x00' * 1)
         packed.append(struct.pack("!H", self.out_port))
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
@@ -3223,21 +3306,23 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = flow_stats_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_STATS_REQUEST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 56: raise loxi.ProtocolError("flow_stats_request length is %d, should be 56" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        stats_type = struct.unpack_from('!H', buf, 8)[0]
-        assert(stats_type == const.OFPST_FLOW)
-        obj.flags = struct.unpack_from('!H', buf, 10)[0]
-        obj.match = common.match.unpack(buffer(buf, 12))
-        obj.table_id = struct.unpack_from('!B', buf, 52)[0]
-        obj.pad = struct.unpack_from('!B', buf, 53)[0]
-        obj.out_port = struct.unpack_from('!H', buf, 54)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_STATS_REQUEST)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _stats_type = reader.read('!H')[0]
+        assert(_stats_type == const.OFPST_FLOW)
+        obj.flags = reader.read('!H')[0]
+        obj.match = common.match.unpack(reader)
+        obj.table_id = reader.read('!B')[0]
+        reader.skip(1)
+        obj.out_port = reader.read('!H')[0]
         return obj
 
     def __eq__(self, other):
@@ -3248,7 +3333,6 @@
         if self.flags != other.flags: return False
         if self.match != other.match: return False
         if self.table_id != other.table_id: return False
-        if self.pad != other.pad: return False
         if self.out_port != other.out_port: return False
         return True
 
@@ -3282,9 +3366,6 @@
                 q.text("table_id = ");
                 q.text("%#x" % self.table_id)
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.text("%#x" % self.pad)
-                q.text(","); q.breakable()
                 q.text("out_port = ");
                 q.text(util.pretty_port(self.out_port))
             q.breakable()
@@ -3321,16 +3402,18 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = get_config_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_GET_CONFIG_REPLY)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 12: raise loxi.ProtocolError("get_config_reply length is %d, should be 12" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.flags = struct.unpack_from('!H', buf, 8)[0]
-        obj.miss_send_len = struct.unpack_from('!H', buf, 10)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_GET_CONFIG_REPLY)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.flags = reader.read('!H')[0]
+        obj.miss_send_len = reader.read('!H')[0]
         return obj
 
     def __eq__(self, other):
@@ -3392,14 +3475,16 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = get_config_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_GET_CONFIG_REQUEST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 8: raise loxi.ProtocolError("get_config_request length is %d, should be 8" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_GET_CONFIG_REQUEST)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
@@ -3453,14 +3538,16 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = hello()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_HELLO)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 8: raise loxi.ProtocolError("hello length is %d, should be 8" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_HELLO)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
@@ -3523,19 +3610,21 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = nicira_controller_role_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 20: raise loxi.ProtocolError("nicira_controller_role_reply length is %d, should be 20" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        experimenter = struct.unpack_from('!L', buf, 8)[0]
-        assert(experimenter == 0x2320)
-        subtype = struct.unpack_from('!L', buf, 12)[0]
-        assert(subtype == 11)
-        obj.role = struct.unpack_from('!L', buf, 16)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_VENDOR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x2320)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 11)
+        obj.role = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
@@ -3602,19 +3691,21 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = nicira_controller_role_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_VENDOR)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 20: raise loxi.ProtocolError("nicira_controller_role_request length is %d, should be 20" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        experimenter = struct.unpack_from('!L', buf, 8)[0]
-        assert(experimenter == 0x2320)
-        subtype = struct.unpack_from('!L', buf, 12)[0]
-        assert(subtype == 10)
-        obj.role = struct.unpack_from('!L', buf, 16)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_VENDOR)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _experimenter = reader.read('!L')[0]
+        assert(_experimenter == 0x2320)
+        _subtype = reader.read('!L')[0]
+        assert(_subtype == 10)
+        obj.role = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
@@ -3655,7 +3746,7 @@
     version = const.OFP_VERSION
     type = const.OFPT_PACKET_IN
 
-    def __init__(self, xid=None, buffer_id=None, total_len=None, in_port=None, reason=None, pad=None, data=None):
+    def __init__(self, xid=None, buffer_id=None, total_len=None, in_port=None, reason=None, data=None):
         self.xid = xid
         if buffer_id != None:
             self.buffer_id = buffer_id
@@ -3673,10 +3764,6 @@
             self.reason = reason
         else:
             self.reason = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = 0
         if data != None:
             self.data = data
         else:
@@ -3692,7 +3779,7 @@
         packed.append(struct.pack("!H", self.total_len))
         packed.append(struct.pack("!H", self.in_port))
         packed.append(struct.pack("!B", self.reason))
-        packed.append(struct.pack("!B", self.pad))
+        packed.append('\x00' * 1)
         packed.append(self.data)
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
@@ -3702,20 +3789,22 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = packet_in()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_PACKET_IN)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 18: raise loxi.ProtocolError("packet_in length is %d, should be at least 18" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.buffer_id = struct.unpack_from('!L', buf, 8)[0]
-        obj.total_len = struct.unpack_from('!H', buf, 12)[0]
-        obj.in_port = struct.unpack_from('!H', buf, 14)[0]
-        obj.reason = struct.unpack_from('!B', buf, 16)[0]
-        obj.pad = struct.unpack_from('!B', buf, 17)[0]
-        obj.data = buf[18:]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_PACKET_IN)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.buffer_id = reader.read('!L')[0]
+        obj.total_len = reader.read('!H')[0]
+        obj.in_port = reader.read('!H')[0]
+        obj.reason = reader.read('!B')[0]
+        reader.skip(1)
+        obj.data = str(reader.read_all())
         return obj
 
     def __eq__(self, other):
@@ -3727,7 +3816,6 @@
         if self.total_len != other.total_len: return False
         if self.in_port != other.in_port: return False
         if self.reason != other.reason: return False
-        if self.pad != other.pad: return False
         if self.data != other.data: return False
         return True
 
@@ -3764,9 +3852,6 @@
                 q.text("reason = ");
                 q.text("%#x" % self.reason)
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.text("%#x" % self.pad)
-                q.text(","); q.breakable()
                 q.text("data = ");
                 q.pp(self.data)
             q.breakable()
@@ -3799,13 +3884,13 @@
         packed = []
         packed.append(struct.pack("!B", self.version))
         packed.append(struct.pack("!B", self.type))
-        packed.append(struct.pack("!H", 0)) # placeholder for length at index 3
+        packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
         packed.append(struct.pack("!L", self.xid))
         packed.append(struct.pack("!L", self.buffer_id))
         packed.append(struct.pack("!H", self.in_port))
-        packed_actions = "".join([x.pack() for x in self.actions])
-        packed.append(struct.pack("!H", len(packed_actions)))
-        packed.append(packed_actions)
+        packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6
+        packed.append("".join([x.pack() for x in self.actions]))
+        packed[6] = struct.pack("!H", len(packed[-1]))
         packed.append(self.data)
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
@@ -3815,19 +3900,21 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = packet_out()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_PACKET_OUT)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 16: raise loxi.ProtocolError("packet_out length is %d, should be at least 16" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.buffer_id = struct.unpack_from('!L', buf, 8)[0]
-        obj.in_port = struct.unpack_from('!H', buf, 12)[0]
-        actions_len = struct.unpack_from('!H', buf, 14)[0]
-        obj.actions = action.unpack_list(buffer(buf, 16, actions_len))
-        obj.data = str(buffer(buf, 16+actions_len))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_PACKET_OUT)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.buffer_id = reader.read('!L')[0]
+        obj.in_port = reader.read('!H')[0]
+        _actions_len = reader.read('!H')[0]
+        obj.actions = action.unpack_list(reader.slice(_actions_len))
+        obj.data = str(reader.read_all())
         return obj
 
     def __eq__(self, other):
@@ -3880,7 +3967,7 @@
     version = const.OFP_VERSION
     type = const.OFPT_PORT_MOD
 
-    def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None, pad=None):
+    def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None):
         self.xid = xid
         if port_no != None:
             self.port_no = port_no
@@ -3902,10 +3989,6 @@
             self.advertise = advertise
         else:
             self.advertise = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0,0]
 
     def pack(self):
         packed = []
@@ -3918,7 +4001,7 @@
         packed.append(struct.pack("!L", self.config))
         packed.append(struct.pack("!L", self.mask))
         packed.append(struct.pack("!L", self.advertise))
-        packed.append(struct.pack("!4B", *self.pad))
+        packed.append('\x00' * 4)
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
         return ''.join(packed)
@@ -3927,20 +4010,22 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = port_mod()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_PORT_MOD)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 32: raise loxi.ProtocolError("port_mod length is %d, should be 32" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.port_no = struct.unpack_from('!H', buf, 8)[0]
-        obj.hw_addr = list(struct.unpack_from('!6B', buf, 10))
-        obj.config = struct.unpack_from('!L', buf, 16)[0]
-        obj.mask = struct.unpack_from('!L', buf, 20)[0]
-        obj.advertise = struct.unpack_from('!L', buf, 24)[0]
-        obj.pad = list(struct.unpack_from('!4B', buf, 28))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_PORT_MOD)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.port_no = reader.read('!H')[0]
+        obj.hw_addr = list(reader.read('!6B'))
+        obj.config = reader.read('!L')[0]
+        obj.mask = reader.read('!L')[0]
+        obj.advertise = reader.read('!L')[0]
+        reader.skip(4)
         return obj
 
     def __eq__(self, other):
@@ -3953,7 +4038,6 @@
         if self.config != other.config: return False
         if self.mask != other.mask: return False
         if self.advertise != other.advertise: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -3991,9 +4075,6 @@
                 q.text(","); q.breakable()
                 q.text("advertise = ");
                 q.text("%#x" % self.advertise)
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
@@ -4030,18 +4111,20 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = port_stats_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_STATS_REPLY)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 12: raise loxi.ProtocolError("port_stats_reply length is %d, should be at least 12" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        stats_type = struct.unpack_from('!H', buf, 8)[0]
-        assert(stats_type == const.OFPST_PORT)
-        obj.flags = struct.unpack_from('!H', buf, 10)[0]
-        obj.entries = util.unpack_array(common.port_stats_entry.unpack, 104, buffer(buf, 12))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_STATS_REPLY)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _stats_type = reader.read('!H')[0]
+        assert(_stats_type == const.OFPST_PORT)
+        obj.flags = reader.read('!H')[0]
+        obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack)
         return obj
 
     def __eq__(self, other):
@@ -4087,7 +4170,7 @@
     type = const.OFPT_STATS_REQUEST
     stats_type = const.OFPST_PORT
 
-    def __init__(self, xid=None, flags=None, port_no=None, pad=None):
+    def __init__(self, xid=None, flags=None, port_no=None):
         self.xid = xid
         if flags != None:
             self.flags = flags
@@ -4097,10 +4180,6 @@
             self.port_no = port_no
         else:
             self.port_no = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0,0,0,0]
 
     def pack(self):
         packed = []
@@ -4111,7 +4190,7 @@
         packed.append(struct.pack("!H", self.stats_type))
         packed.append(struct.pack("!H", self.flags))
         packed.append(struct.pack("!H", self.port_no))
-        packed.append(struct.pack("!6B", *self.pad))
+        packed.append('\x00' * 6)
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
         return ''.join(packed)
@@ -4120,19 +4199,21 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = port_stats_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_STATS_REQUEST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 20: raise loxi.ProtocolError("port_stats_request length is %d, should be 20" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        stats_type = struct.unpack_from('!H', buf, 8)[0]
-        assert(stats_type == const.OFPST_PORT)
-        obj.flags = struct.unpack_from('!H', buf, 10)[0]
-        obj.port_no = struct.unpack_from('!H', buf, 12)[0]
-        obj.pad = list(struct.unpack_from('!6B', buf, 14))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_STATS_REQUEST)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _stats_type = reader.read('!H')[0]
+        assert(_stats_type == const.OFPST_PORT)
+        obj.flags = reader.read('!H')[0]
+        obj.port_no = reader.read('!H')[0]
+        reader.skip(6)
         return obj
 
     def __eq__(self, other):
@@ -4142,7 +4223,6 @@
         if self.xid != other.xid: return False
         if self.flags != other.flags: return False
         if self.port_no != other.port_no: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -4171,9 +4251,6 @@
                 q.text(","); q.breakable()
                 q.text("port_no = ");
                 q.text(util.pretty_port(self.port_no))
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
@@ -4181,16 +4258,12 @@
     version = const.OFP_VERSION
     type = const.OFPT_PORT_STATUS
 
-    def __init__(self, xid=None, reason=None, pad=None, desc=None):
+    def __init__(self, xid=None, reason=None, desc=None):
         self.xid = xid
         if reason != None:
             self.reason = reason
         else:
             self.reason = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0,0,0,0,0]
         if desc != None:
             self.desc = desc
         else:
@@ -4203,7 +4276,7 @@
         packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
         packed.append(struct.pack("!L", self.xid))
         packed.append(struct.pack("!B", self.reason))
-        packed.append(struct.pack("!7B", *self.pad))
+        packed.append('\x00' * 7)
         packed.append(self.desc.pack())
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
@@ -4213,17 +4286,19 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = port_status()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_PORT_STATUS)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 64: raise loxi.ProtocolError("port_status length is %d, should be 64" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.reason = struct.unpack_from('!B', buf, 8)[0]
-        obj.pad = list(struct.unpack_from('!7B', buf, 9))
-        obj.desc = common.port_desc.unpack(buffer(buf, 16))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_PORT_STATUS)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.reason = reader.read('!B')[0]
+        reader.skip(7)
+        obj.desc = common.port_desc.unpack(reader)
         return obj
 
     def __eq__(self, other):
@@ -4232,7 +4307,6 @@
         if self.type != other.type: return False
         if self.xid != other.xid: return False
         if self.reason != other.reason: return False
-        if self.pad != other.pad: return False
         if self.desc != other.desc: return False
         return True
 
@@ -4260,9 +4334,6 @@
                 q.text("reason = ");
                 q.text("%#x" % self.reason)
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
-                q.text(","); q.breakable()
                 q.text("desc = ");
                 q.pp(self.desc)
             q.breakable()
@@ -4272,16 +4343,12 @@
     version = const.OFP_VERSION
     type = const.OFPT_QUEUE_GET_CONFIG_REPLY
 
-    def __init__(self, xid=None, port=None, pad=None, queues=None):
+    def __init__(self, xid=None, port=None, queues=None):
         self.xid = xid
         if port != None:
             self.port = port
         else:
             self.port = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0,0,0,0]
         if queues != None:
             self.queues = queues
         else:
@@ -4294,7 +4361,7 @@
         packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
         packed.append(struct.pack("!L", self.xid))
         packed.append(struct.pack("!H", self.port))
-        packed.append(struct.pack("!6B", *self.pad))
+        packed.append('\x00' * 6)
         packed.append("".join([x.pack() for x in self.queues]))
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
@@ -4304,17 +4371,19 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = queue_get_config_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_QUEUE_GET_CONFIG_REPLY)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 16: raise loxi.ProtocolError("queue_get_config_reply length is %d, should be at least 16" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.port = struct.unpack_from('!H', buf, 8)[0]
-        obj.pad = list(struct.unpack_from('!6B', buf, 10))
-        obj.queues = common.unpack_list_packet_queue(buffer(buf, 16))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_QUEUE_GET_CONFIG_REPLY)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.port = reader.read('!H')[0]
+        reader.skip(6)
+        obj.queues = common.unpack_list_packet_queue(reader)
         return obj
 
     def __eq__(self, other):
@@ -4323,7 +4392,6 @@
         if self.type != other.type: return False
         if self.xid != other.xid: return False
         if self.port != other.port: return False
-        if self.pad != other.pad: return False
         if self.queues != other.queues: return False
         return True
 
@@ -4351,9 +4419,6 @@
                 q.text("port = ");
                 q.text(util.pretty_port(self.port))
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
-                q.text(","); q.breakable()
                 q.text("queues = ");
                 q.pp(self.queues)
             q.breakable()
@@ -4363,16 +4428,12 @@
     version = const.OFP_VERSION
     type = const.OFPT_QUEUE_GET_CONFIG_REQUEST
 
-    def __init__(self, xid=None, port=None, pad=None):
+    def __init__(self, xid=None, port=None):
         self.xid = xid
         if port != None:
             self.port = port
         else:
             self.port = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0]
 
     def pack(self):
         packed = []
@@ -4381,7 +4442,7 @@
         packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
         packed.append(struct.pack("!L", self.xid))
         packed.append(struct.pack("!H", self.port))
-        packed.append(struct.pack("!2B", *self.pad))
+        packed.append('\x00' * 2)
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
         return ''.join(packed)
@@ -4390,16 +4451,18 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = queue_get_config_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_QUEUE_GET_CONFIG_REQUEST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 12: raise loxi.ProtocolError("queue_get_config_request length is %d, should be 12" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.port = struct.unpack_from('!H', buf, 8)[0]
-        obj.pad = list(struct.unpack_from('!2B', buf, 10))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_QUEUE_GET_CONFIG_REQUEST)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.port = reader.read('!H')[0]
+        reader.skip(2)
         return obj
 
     def __eq__(self, other):
@@ -4408,7 +4471,6 @@
         if self.type != other.type: return False
         if self.xid != other.xid: return False
         if self.port != other.port: return False
-        if self.pad != other.pad: return False
         return True
 
     def __ne__(self, other):
@@ -4434,9 +4496,6 @@
                 q.text(","); q.breakable()
                 q.text("port = ");
                 q.text(util.pretty_port(self.port))
-                q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
             q.breakable()
         q.text('}')
 
@@ -4473,18 +4532,20 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = queue_stats_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_STATS_REPLY)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 12: raise loxi.ProtocolError("queue_stats_reply length is %d, should be at least 12" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        stats_type = struct.unpack_from('!H', buf, 8)[0]
-        assert(stats_type == const.OFPST_QUEUE)
-        obj.flags = struct.unpack_from('!H', buf, 10)[0]
-        obj.entries = util.unpack_array(common.queue_stats_entry.unpack, 32, buffer(buf, 12))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_STATS_REPLY)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _stats_type = reader.read('!H')[0]
+        assert(_stats_type == const.OFPST_QUEUE)
+        obj.flags = reader.read('!H')[0]
+        obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack)
         return obj
 
     def __eq__(self, other):
@@ -4530,7 +4591,7 @@
     type = const.OFPT_STATS_REQUEST
     stats_type = const.OFPST_QUEUE
 
-    def __init__(self, xid=None, flags=None, port_no=None, pad=None, queue_id=None):
+    def __init__(self, xid=None, flags=None, port_no=None, queue_id=None):
         self.xid = xid
         if flags != None:
             self.flags = flags
@@ -4540,10 +4601,6 @@
             self.port_no = port_no
         else:
             self.port_no = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0]
         if queue_id != None:
             self.queue_id = queue_id
         else:
@@ -4558,7 +4615,7 @@
         packed.append(struct.pack("!H", self.stats_type))
         packed.append(struct.pack("!H", self.flags))
         packed.append(struct.pack("!H", self.port_no))
-        packed.append(struct.pack("!2B", *self.pad))
+        packed.append('\x00' * 2)
         packed.append(struct.pack("!L", self.queue_id))
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
@@ -4568,20 +4625,22 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = queue_stats_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_STATS_REQUEST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 20: raise loxi.ProtocolError("queue_stats_request length is %d, should be 20" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        stats_type = struct.unpack_from('!H', buf, 8)[0]
-        assert(stats_type == const.OFPST_QUEUE)
-        obj.flags = struct.unpack_from('!H', buf, 10)[0]
-        obj.port_no = struct.unpack_from('!H', buf, 12)[0]
-        obj.pad = list(struct.unpack_from('!2B', buf, 14))
-        obj.queue_id = struct.unpack_from('!L', buf, 16)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_STATS_REQUEST)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _stats_type = reader.read('!H')[0]
+        assert(_stats_type == const.OFPST_QUEUE)
+        obj.flags = reader.read('!H')[0]
+        obj.port_no = reader.read('!H')[0]
+        reader.skip(2)
+        obj.queue_id = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
@@ -4591,7 +4650,6 @@
         if self.xid != other.xid: return False
         if self.flags != other.flags: return False
         if self.port_no != other.port_no: return False
-        if self.pad != other.pad: return False
         if self.queue_id != other.queue_id: return False
         return True
 
@@ -4622,9 +4680,6 @@
                 q.text("port_no = ");
                 q.text(util.pretty_port(self.port_no))
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
-                q.text(","); q.breakable()
                 q.text("queue_id = ");
                 q.text("%#x" % self.queue_id)
             q.breakable()
@@ -4661,16 +4716,18 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = set_config()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_SET_CONFIG)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 12: raise loxi.ProtocolError("set_config length is %d, should be 12" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.flags = struct.unpack_from('!H', buf, 8)[0]
-        obj.miss_send_len = struct.unpack_from('!H', buf, 10)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_SET_CONFIG)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.flags = reader.read('!H')[0]
+        obj.miss_send_len = reader.read('!H')[0]
         return obj
 
     def __eq__(self, other):
@@ -4715,16 +4772,12 @@
     version = const.OFP_VERSION
     type = 22
 
-    def __init__(self, xid=None, table_id=None, pad=None, config=None):
+    def __init__(self, xid=None, table_id=None, config=None):
         self.xid = xid
         if table_id != None:
             self.table_id = table_id
         else:
             self.table_id = 0
-        if pad != None:
-            self.pad = pad
-        else:
-            self.pad = [0,0,0]
         if config != None:
             self.config = config
         else:
@@ -4737,7 +4790,7 @@
         packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
         packed.append(struct.pack("!L", self.xid))
         packed.append(struct.pack("!B", self.table_id))
-        packed.append(struct.pack("!3B", *self.pad))
+        packed.append('\x00' * 3)
         packed.append(struct.pack("!L", self.config))
         length = sum([len(x) for x in packed])
         packed[2] = struct.pack("!H", length)
@@ -4747,17 +4800,19 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = table_mod()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == 22)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 16: raise loxi.ProtocolError("table_mod length is %d, should be 16" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        obj.table_id = struct.unpack_from('!B', buf, 8)[0]
-        obj.pad = list(struct.unpack_from('!3B', buf, 9))
-        obj.config = struct.unpack_from('!L', buf, 12)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == 22)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        obj.table_id = reader.read('!B')[0]
+        reader.skip(3)
+        obj.config = reader.read('!L')[0]
         return obj
 
     def __eq__(self, other):
@@ -4766,7 +4821,6 @@
         if self.type != other.type: return False
         if self.xid != other.xid: return False
         if self.table_id != other.table_id: return False
-        if self.pad != other.pad: return False
         if self.config != other.config: return False
         return True
 
@@ -4794,9 +4848,6 @@
                 q.text("table_id = ");
                 q.text("%#x" % self.table_id)
                 q.text(","); q.breakable()
-                q.text("pad = ");
-                q.pp(self.pad)
-                q.text(","); q.breakable()
                 q.text("config = ");
                 q.text("%#x" % self.config)
             q.breakable()
@@ -4835,18 +4886,20 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = table_stats_reply()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_STATS_REPLY)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length < 12: raise loxi.ProtocolError("table_stats_reply length is %d, should be at least 12" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        stats_type = struct.unpack_from('!H', buf, 8)[0]
-        assert(stats_type == const.OFPST_TABLE)
-        obj.flags = struct.unpack_from('!H', buf, 10)[0]
-        obj.entries = util.unpack_array(common.table_stats_entry.unpack, 64, buffer(buf, 12))
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_STATS_REPLY)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _stats_type = reader.read('!H')[0]
+        assert(_stats_type == const.OFPST_TABLE)
+        obj.flags = reader.read('!H')[0]
+        obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack)
         return obj
 
     def __eq__(self, other):
@@ -4915,17 +4968,19 @@
     def unpack(buf):
         if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
         obj = table_stats_request()
-        version = struct.unpack_from('!B', buf, 0)[0]
-        assert(version == const.OFP_VERSION)
-        type = struct.unpack_from('!B', buf, 1)[0]
-        assert(type == const.OFPT_STATS_REQUEST)
-        _length = struct.unpack_from('!H', buf, 2)[0]
-        assert(_length == len(buf))
-        if _length != 12: raise loxi.ProtocolError("table_stats_request length is %d, should be 12" % _length)
-        obj.xid = struct.unpack_from('!L', buf, 4)[0]
-        stats_type = struct.unpack_from('!H', buf, 8)[0]
-        assert(stats_type == const.OFPST_TABLE)
-        obj.flags = struct.unpack_from('!H', buf, 10)[0]
+        if type(buf) == loxi.generic_util.OFReader:
+            reader = buf
+        else:
+            reader = loxi.generic_util.OFReader(buf)
+        _version = reader.read('!B')[0]
+        assert(_version == const.OFP_VERSION)
+        _type = reader.read('!B')[0]
+        assert(_type == const.OFPT_STATS_REQUEST)
+        _length = reader.read('!H')[0]
+        obj.xid = reader.read('!L')[0]
+        _stats_type = reader.read('!H')[0]
+        assert(_stats_type == const.OFPST_TABLE)
+        obj.flags = reader.read('!H')[0]
         return obj
 
     def __eq__(self, other):
@@ -5091,6 +5146,7 @@
         4: bsn_get_mirroring_request.unpack,
         0: bsn_set_ip_mask.unpack,
         3: bsn_set_mirroring.unpack,
+        11: bsn_set_pktin_suppression.unpack,
         6: bsn_shell_command.unpack,
         7: bsn_shell_output.unpack,
         8: bsn_shell_status.unpack,
diff --git a/src/python/loxi/of10/util.py b/src/python/loxi/of10/util.py
index 713d5cb..45aa2d0 100644
--- a/src/python/loxi/of10/util.py
+++ b/src/python/loxi/of10/util.py
@@ -1,32 +1,13 @@
-#
-# Copyright 2012, 2013, Big Switch Networks, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+# Copyright (c) 2011, 2012 Open Networking Foundation
+# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
 
 # Automatically generated by LOXI from template util.py
 # Do not modify
 
 import loxi
 import const
-
-def unpack_array(deserializer, element_size, buf):
-    """
-    Deserialize an array of fixed length elements.
-    The deserializer function should take a buffer and return the new object.
-    """
-    if len(buf) % element_size != 0: raise loxi.ProtocolError("invalid array length")
-    n = len(buf) / element_size
-    return [deserializer(buffer(buf, i*element_size, element_size)) for i in range(n)]
+import struct
 
 def pretty_mac(mac):
     return ':'.join(["%02x" % x for x in mac])