Initial import

LoxiGen is the work of several developers, not just myself.
diff --git a/c_gen/Makefile.local b/c_gen/Makefile.local
new file mode 100644
index 0000000..fb544d5
--- /dev/null
+++ b/c_gen/Makefile.local
@@ -0,0 +1,91 @@
+# Copyright 2013, Big Switch Networks, Inc.
+#
+# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+# the following special exception:
+#
+# LOXI Exception
+#
+# As a special exception to the terms of the EPL, you may distribute libraries
+# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+# that copyright and licensing notices generated by LoxiGen are not altered or removed
+# from the LoxiGen Libraries and the notice provided below is (i) included in
+# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+# documentation for the LoxiGen Libraries, if distributed in binary form.
+#
+# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+#
+# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+# a copy of the EPL at:
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# 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
+# EPL for the specific language governing permissions and limitations
+# under the EPL.
+
+# Makefile to test LOCI generated files locally
+# Assumes code is in BigCode layout
+# Normally the loci and locitest code is put into a directory 'local' with
+# this make file copied to its top level.
+
+LOCI_SOURCES:=$(wildcard Modules/loci/module/src/*.c)
+LOCI_OBJECTS:=$(LOCI_SOURCES:.c=.o)
+LOCI_HEADERS:=$(wildcard Modules/loci/module/inc/loci/*.h)
+LOCI_HEADERS+=$(wildcard Modules/loci/module/src/*.h)
+
+LOCITEST_SOURCES:=$(wildcard Modules/locitest/module/src/*.c)
+LOCITEST_OBJECTS:=$(LOCITEST_SOURCES:.c=.o)
+LOCITEST_HEADERS:=$(wildcard Modules/locitest/module/inc/locitest/*.h)
+LOCITEST_HEADERS+=$(wildcard Modules/locitests/module/src/*.h)
+
+LOCITEST_MAIN:=Modules/locitest/utest/main.c
+
+ALL_SOURCES:=${LOCITEST_SOURCES} ${LOCI_SOURCES}
+ALL_OBJECTS:=$(ALL_SOURCES:.c=.o)
+ALL_HEADERS:=${LOCITEST_HEADERS} ${LOCI_HEADERS}
+
+CFLAGS:=-Wall -g -I Modules/loci/module/inc -I Modules/locitest/module/inc -O0
+
+all: test
+
+test: locitest
+	./locitest
+
+%.o: %.c ${ALL_HEADERS}
+	gcc -c ${CFLAGS} $< -o $@
+
+%.E: %.c ${ALL_HEADERS}
+	gcc -E ${CFLAGS} $< -o $@
+
+libloci.a: ${LOCI_OBJECTS}
+	ar rcu libloci.a ${LOCI_OBJECTS}
+	ranlib libloci.a
+
+liblocitest.a: ${LOCITEST_OBJECTS}
+	ar rcu liblocitest.a ${LOCITEST_OBJECTS}
+	ranlib liblocitest.a
+
+# Test executable
+locitest: ${LOCITEST_MAIN} libloci.a liblocitest.a
+	gcc $< ${CFLAGS} -l locitest -l loci -L . -o $@
+
+show:
+	@echo ALL_SOURCES ${ALL_SOURCES}
+	@echo ALL_OBJECTS ${ALL_OBJECTS}
+	@echo ALL_HEADERS ${ALL_HEADERS}
+
+help:
+	@echo "Run loci unit tests locally"
+
+clean:
+	find . -name '*.o' | xargs rm -f
+	find . -name '*.E' | xargs rm -f
+	rm -f libloci.a liblocitest.a locitest
+
+# TBD
+doc: ${ALL_HEADERS}
+	doxygen Doxyfile
+
+.PHONY: all test lib clean show doc
diff --git a/c_gen/__init__.py b/c_gen/__init__.py
new file mode 100644
index 0000000..5e4e379
--- /dev/null
+++ b/c_gen/__init__.py
@@ -0,0 +1,26 @@
+# Copyright 2013, Big Switch Networks, Inc.
+#
+# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+# the following special exception:
+#
+# LOXI Exception
+#
+# As a special exception to the terms of the EPL, you may distribute libraries
+# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+# that copyright and licensing notices generated by LoxiGen are not altered or removed
+# from the LoxiGen Libraries and the notice provided below is (i) included in
+# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+# documentation for the LoxiGen Libraries, if distributed in binary form.
+#
+# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+#
+# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+# a copy of the EPL at:
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# 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
+# EPL for the specific language governing permissions and limitations
+# under the EPL.
diff --git a/c_gen/c_code_gen.py b/c_gen/c_code_gen.py
new file mode 100644
index 0000000..0a10715
--- /dev/null
+++ b/c_gen/c_code_gen.py
@@ -0,0 +1,3616 @@
+# Copyright 2013, Big Switch Networks, Inc.
+#
+# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+# the following special exception:
+#
+# LOXI Exception
+#
+# As a special exception to the terms of the EPL, you may distribute libraries
+# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+# that copyright and licensing notices generated by LoxiGen are not altered or removed
+# from the LoxiGen Libraries and the notice provided below is (i) included in
+# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+# documentation for the LoxiGen Libraries, if distributed in binary form.
+#
+# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+#
+# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+# a copy of the EPL at:
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# 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
+# EPL for the specific language governing permissions and limitations
+# under the EPL.
+
+"""
+@file code_gen.py
+Code generation functions for LOCI
+"""
+
+import sys
+import of_g
+import c_match
+from generic_utils import *
+import c_gen.c_type_maps as c_type_maps
+import loxi_front_end.type_maps as type_maps
+import loxi_front_end.flags as flags
+import loxi_utils.loxi_utils as loxi_utils
+import loxi_front_end.identifiers as identifiers
+
+# 'property' is for queues. Could be trouble
+
+
+################################################################
+#
+# Misc helper functions
+#
+################################################################
+
+def h_file_to_define(name):
+    """
+    Convert a .h file name to the define used for the header
+    """
+    h_name = name[:-2].upper()
+    h_name = "_" + h_name + "_H_"
+    return h_name
+
+def enum_name(cls):
+    """
+    Return the name used for an enum identifier for the given class
+    @param cls The class name
+    """
+    return loxi_utils.enum_name(cls)
+
+def member_returns_val(cls, m_name):
+    """
+    Should get accessor return a value rather than void
+    @param cls The class name
+    @param m_name The member name
+    @return True if of_g config and the specific member allow a 
+    return value.  Otherwise False
+    """
+    m_type = of_g.unified[cls]["union"][m_name]["m_type"]
+    return (config_check("get_returns") =="value" and 
+            m_type in of_g.of_scalar_types)
+
+# TODO serialize match outside accessor?
+def accessor_return_type(a_type, m_type):
+    if loxi_utils.accessor_returns_error(a_type, m_type):
+        return "int WARN_UNUSED_RESULT"
+    else:
+        return "void"
+
+def accessor_return_success(a_type, m_type):
+    if loxi_utils.accessor_returns_error(a_type, m_type):
+        return "OF_ERROR_NONE"
+    else:
+        return ""
+
+################################################################
+#
+# Per-file generators, mapped to jump table below
+#
+################################################################
+
+def base_h_gen(out, name):
+    """
+    Generate code for base header file
+    @param out The file handle to write to
+    @param name The name of the file
+    """
+    common_top_matter(out, name)
+    base_h_content(out)
+    gen_object_enum(out)
+    out.write("""
+/****************************************************************
+ *
+ * Experimenter IDs
+ *
+ ****************************************************************/
+
+""")
+    for name, val in of_g.experimenter_name_to_id.items():
+        out.write("#define OF_EXPERIMENTER_ID_%s 0x%08x\n" %
+                  (name.upper(), val))
+
+    out.write("""
+/****************************************************************
+ *
+ * OpenFlow Match version specific and generic defines
+ *
+ ****************************************************************/
+""")
+    c_match.gen_v4_match_compat(out)
+    c_match.gen_match_macros(out)
+    c_match.gen_oxm_defines(out)
+    out.write("\n#endif /* Base header file */\n")
+
+def identifiers_gen(out, filename):
+    """
+    Generate the macros for LOCI identifiers
+    @param out The file handle to write to
+    @param filename The name of the file
+    """
+    common_top_matter(out, filename)
+    out.write("""
+/**
+ * For each identifier from an OpenFlow header file, a Loxi version
+ * of the identifier is generated.  For example, ofp_port_flood becomes
+ * OF_PORT_DEST_FLOOD.  Loxi provides the following macros related to 
+ * OpenFlow identifiers (using OF_IDENT_ as an example below):
+ *     OF_IDENT_BY_VERSION(version) Get the value for the specific version
+ *     OF_IDENT_SUPPORTED(version) Boolean: Is OF_IDENT defined for version
+ *     OF_IDENT The common value across all versions if defined
+ *     OF_IDENT_GENERIC A unique value across all OF identifiers
+ *
+ * For identifiers marked as flags, the following are also defined
+ *     OF_IDENT_SET(flags, version)
+ *     OF_IDENT_CLEAR(flags, version)
+ *     OF_IDENT_TEST(flags, version)
+ *
+ * Notes:
+ *
+ *     OF_IDENT_BY_VERSION(version) returns an undefined value
+ * if the passed version does not define OF_IDENT.  It does not generate an
+ * error, nor record anything to the log file.  If the value is the same
+ * across all defined versions, the version is ignored.
+ *
+ *     OF_IDENT is only defined if the value is the same across all
+ * target LOXI versions FOR WHICH IT IS DEFINED.  No error checking is
+ * done.  This allows code to be written without requiring the version
+ * to be known or referenced when it doesn't matter.  It does mean
+ * that when porting to a new version of OpenFlow, compile errors may
+ * occur.  However, this is an indication that the existing code must
+ * be updated to account for a change in the semantics with the newly
+ * supported OpenFlow version.
+ *
+ * @fixme Currently we do not handle multi-bit flags or field values; for
+ * example, OF_TABLE_CONFIG_TABLE_MISS_CONTROLLER is the meaning for
+ * a zero value in the bits indicated by OF_TABLE_CONFIG_TABLE_MISS_MASK.
+ *
+ * @fixme Need to decide (or make a code gen option) on the requirement
+ * for defining OF_IDENT:  Is it that all target versions define it and
+ * the agree?  Or only that the versions which define it agree?
+ */
+""")
+
+    # Build value-by-version parameters and c_code
+    if len(of_g.target_version_list) > 1: # Supporting more than one version
+        vbv_params = []
+        vbv_code = ""
+        first = True
+        for version in of_g.target_version_list:
+            vbv_params.append("value_%s" % of_g.short_version_names[version])
+            if not first:
+                vbv_code += "\\\n     "
+            else:
+                first = False
+            last_value = "value_%s" % of_g.short_version_names[version]
+            vbv_code += "((version) == %s) ? (%s) : " % \
+                (of_g.of_version_wire2name[version], last_value)
+        # @todo Using last value, can optimize out last ?
+        vbv_code += "(%s)" % last_value
+
+    out.write("""
+/**
+ * @brief True for the special case of all versions supported
+ */
+#define OF_IDENT_IN_ALL_VERSIONS 1 /* Indicates identifier in all versions */
+
+/**
+ * @brief General macro to map version to value where values given as params
+ *
+ * If unknown version is passed, use the latest version's value
+ */
+#define OF_VALUE_BY_VERSION(version, %s) \\
+    (%s)
+
+/**
+ * @brief Generic set a flag
+ */
+#define OF_FLAG_SET(flags, mask) (flags) = (flags) | (mask)
+
+/**
+ * @brief Generic test if a flag is set
+ */
+#define OF_FLAG_CLEAR(flags, mask) (flags) = (flags) & ~(mask)
+
+/**
+ * @brief Generic test if a flag is set
+ */
+#define OF_FLAG_TEST(flags, mask) ((flags) & (mask) ? 1 : 0)
+
+/**
+ * @brief Set a flag where the value is an enum indication of bit shift
+ */
+#define OF_FLAG_ENUM_SET(flags, e_val) OF_FLAG_SET(flags, 1 << (e_val))
+
+/**
+ * @brief Clear a flag where the value is an enum indication of bit shift
+ */
+#define OF_FLAG_ENUM_CLEAR(flags, e_val) OF_FLAG_CLEAR(flags, 1 << (e_val))
+
+/**
+ * @brief Test a flag where the value is an enum indication of bit shift
+ */
+#define OF_FLAG_ENUM_TEST(flags, e_val) OF_FLAG_TEST(flags, 1 << (e_val))
+""" % (", ".join(vbv_params), vbv_code))
+
+    # For each group of identifiers, bunch ident defns
+    count = 1
+    keys = of_g.identifiers_by_group.keys()
+    keys.sort()
+    for group in keys:
+        idents = of_g.identifiers_by_group[group]
+        idents.sort()
+        out.write("""
+/****************************************************************
+ * Identifiers from %s 
+ *****************************************************************/
+""" % group)
+        for ident in idents:
+            info = of_g.identifiers[ident]
+
+            keys = info["values_by_version"].keys()
+            keys.sort()
+
+            out.write("""
+/*
+ * Defines for %(ident)s
+ * Original name %(ofp_name)s
+ */
+""" % dict(ident=ident, ofp_name=info["ofp_name"]))
+
+            # Generate supported versions macro
+            if len(keys) == len(of_g.target_version_list): # Defined for all
+                out.write("""\
+#define %(ident)s_SUPPORTED(version) OF_IDENT_IN_ALL_VERSIONS
+""" % dict(ident=ident))
+            else: # Undefined for some version
+                sup_list = []
+                for version in keys:
+                    sup_list.append("((version) == %s)" %
+                                    of_g.of_version_wire2name[version])
+                out.write("""\
+#define %(ident)s_SUPPORTED(version)      \\
+    (%(sup_str)s)
+""" % dict(ident=ident, sup_str=" || \\\n     ".join(sup_list)))
+
+            # Generate value macro
+            if identifiers.defined_versions_agree(of_g.identifiers,
+                                                  of_g.target_version_list,
+                                                  ident):
+                out.write("""\
+#define %(ident)s (%(value)s)
+#define %(ident)s_BY_VERSION(version) (%(value)s)
+""" % dict(ident=ident,value=info["common_value"]))
+            else: # Values differ between versions
+                # Generate version check and value by version
+                val_list = []
+                # Order of params matters
+                for version in of_g.target_version_list:
+                    if version in info["values_by_version"]:
+                        value = info["values_by_version"][version]
+                    else:
+                        value = identifiers.UNDEFINED_IDENT_VALUE
+                    val_list.append("%s" % value)
+                out.write("""\
+#define %(ident)s_BY_VERSION(version)     \\
+    OF_VALUE_BY_VERSION(version, %(val_str)s)
+""" % dict(ident=ident, val_str=", ".join(val_list)))
+            if flags.ident_is_flag(ident):
+                log("Treating %s as a flag" % ident)
+                out.write("""
+#define %(ident)s_SET(flags, version)     \\
+    OF_FLAG_SET(flags, %(ident)s_BY_VERSION(version))
+#define %(ident)s_TEST(flags, version)    \\
+    OF_FLAG_TEST(flags, %(ident)s_BY_VERSION(version))
+#define %(ident)s_CLEAR(flags, version)   \\
+    OF_FLAG_CLEAR(flags, %(ident)s_BY_VERSION(version))
+""" % dict(ident=ident))
+
+            out.write("#define %(ident)s_GENERIC %(count)d\n"
+                      % dict(ident=ident, count=count))
+            count += 1 # This count should probably be promoted higher
+
+    log("Generated %d identifiers" % (count - 1))
+    out.write("\n#endif /* Loci identifiers header file */\n")
+
+def base_h_external(out, filename):
+    """
+    Copy contents of external file to base header
+
+    The contents of the filename are copied literally into the
+    out file handler.  This allows openflow common defines to
+    be entered into the LoxiGen code base.  The content of this
+    code must depend only on standard C headers.
+    """
+    infile = open(filename, "r")
+    contents = infile.read()
+    out.write(contents)
+    infile.close()
+
+def match_h_gen(out, name):
+    """
+    Generate code for
+    @param out The file handle to write to
+    @param name The name of the file
+    """
+    c_match.match_h_top_matter(out, name)
+    c_match.gen_incompat_members(out)
+    c_match.gen_match_struct(out)
+    c_match.gen_match_comp(out)
+#    c_match.gen_match_accessors(out)
+    out.write("\n#endif /* Match header file */\n")
+
+def top_h_gen(out, name):
+    """
+    Generate code for
+    @param out The file handle to write to
+    @param name The name of the file
+    """
+    external_h_top_matter(out, name)
+    out.write("""
+
+typedef enum loci_log_level {
+    LOCI_LOG_LEVEL_TRACE,
+    LOCI_LOG_LEVEL_VERBOSE,
+    LOCI_LOG_LEVEL_INFO,
+    LOCI_LOG_LEVEL_WARN,
+    LOCI_LOG_LEVEL_ERROR,
+    LOCI_LOG_LEVEL_MSG
+} loci_log_level_t;
+
+/**
+ * @brief Output a log message.
+ * @param level The log level.
+ * @param fname The function name.
+ * @param file The file name.
+ * @param line The line number.
+ * @param format The message format string.
+ */
+typedef int (*loci_logger_f)(loci_log_level_t level,
+                             const char *fname, const char *file, int line,
+                             const char *format, ...);
+
+/*
+ * This variable should be set by the user of the library to redirect logs to
+ * their log infrastructure. The default drops all logs.
+ */
+extern loci_logger_f loci_logger;
+
+/**
+ * Map a generic object to the underlying wire buffer
+ *
+ * Treat as private
+ */
+#define OF_OBJECT_TO_MESSAGE(obj) \\
+    ((of_message_t)(WBUF_BUF((obj)->wire_object.wbuf)))
+
+/**
+ * Macro for the fixed length part of an object
+ *
+ * @param obj The object whose extended length is being calculated
+ * @returns length in bytes of non-variable part of the object
+ */
+#define OF_OBJECT_FIXED_LENGTH(obj) \\
+    (of_object_fixed_len[(obj)->version][(obj)->object_id])
+
+/**
+ * Return the length of the object beyond its fixed length
+ *
+ * @param obj The object whose extended length is being calculated
+ * @returns length in bytes of non-variable part of the object
+ *
+ * Most variable length fields are alone at the end of a structure.
+ * Their length is a simple calculation, just the total length of
+ * the parent minus the length of the non-variable part of the
+ * parent's class type.
+ */
+
+#define OF_OBJECT_VARIABLE_LENGTH(obj) \\
+    ((obj)->length - OF_OBJECT_FIXED_LENGTH(obj))
+
+/* FIXME: Where do these go? */
+/* Low level maps btwn wire version + type and object ids */
+extern int of_message_is_stats_request(int type, int w_ver);
+extern int of_message_is_stats_reply(int type, int w_ver);
+extern int of_message_stats_reply_to_object_id(int stats_type, int w_ver);
+extern int of_message_stats_request_to_object_id(int stats_type, int w_ver);
+extern int of_message_type_to_object_id(int type, int w_ver);
+
+extern int of_wire_buffer_of_match_get(of_object_t *obj, int offset,
+                                    of_match_t *match);
+extern int of_wire_buffer_of_match_set(of_object_t *obj, int offset,
+                                    of_match_t *match, int cur_len);
+extern void of_extension_object_id_set(of_object_t *obj, of_object_id_t id);
+""")
+
+    # gen_base_types(out)
+
+    gen_struct_typedefs(out)
+    gen_acc_pointer_typedefs(out)
+    gen_new_function_declarations(out)
+    if config_check("gen_unified_fns"):
+        gen_accessor_declarations(out)
+
+    gen_common_struct_definitions(out)
+    gen_flow_add_setup_function_declarations(out)
+    if config_check("gen_fn_ptrs"): # Otherwise, all classes are from generic cls
+        gen_struct_definitions(out)
+    gen_generic_union(out)
+    gen_generics(out)
+    gen_top_static_functions(out)
+    out.write("""
+/****************************************************************
+ *
+ * Declarations of maps between on-the-wire type values and LOCI identifiers
+ *
+ ****************************************************************/
+""")
+    c_type_maps.gen_type_maps_header(out)
+    c_type_maps.gen_type_data_header(out)
+    c_match.gen_declarations(out)
+    # @fixme Move debug stuff to own fn
+    out.write("""
+/**
+ * Macro to check consistency of length for top level objects
+ *
+ * If the object has no parent then its length should match the
+ * underlying wire buffer's current bytes.
+ */
+#define OF_LENGTH_CHECK_ASSERT(obj) \\
+    ASSERT(((obj)->parent != NULL) || \\
+     ((obj)->wire_object.wbuf == NULL) || \\
+     (WBUF_CURRENT_BYTES((obj)->wire_object.wbuf) == (obj)->length))
+
+#define OF_DEBUG_DUMP
+#if defined(OF_DEBUG_DUMP)
+extern void dump_match(of_match_t *match);
+#endif /* OF_DEBUG_DUMP */
+""")
+
+    out.write("\n#endif /* Top header file */\n")
+
+def match_c_gen(out, name):
+    """
+    Generate code for
+    @param out The file handle to write to
+    @param name The name of the file
+    """
+    c_match.match_c_top_matter(out, name)
+    c_match.gen_match_conversions(out)
+    c_match.gen_serialize(out)
+    c_match.gen_deserialize(out)
+
+def gen_len_offset_macros(out):
+    """
+    Special case length and offset calculations put directly into
+    loci.c as they are private.
+    """
+
+    out.write("""
+/****************************************************************
+ * Special case macros for calculating variable lengths and offsets
+ ****************************************************************/
+
+/**
+ * Get a u16 directly from an offset in an object's wire buffer
+ * @param obj An of_object_t object
+ * @param offset Base offset of the uint16 relative to the object
+ *
+ */
+
+static inline int
+of_object_u16_get(of_object_t *obj, int offset) {
+    uint16_t val16;
+
+    of_wire_buffer_u16_get(obj->wire_object.wbuf,
+        obj->wire_object.obj_offset + offset, &val16);
+
+    return (int)val16;
+}
+
+/**
+ * Set a u16 directly at an offset in an object's wire buffer
+ * @param obj An of_object_t object
+ * @param offset Base offset of the uint16 relative to the object
+ * @param val The value to store
+ *
+ */
+
+static inline void
+of_object_u16_set(of_object_t *obj, int offset, int value) {
+    uint16_t val16;
+
+    val16 = (uint16_t)value;
+    of_wire_buffer_u16_set(obj->wire_object.wbuf,
+        obj->wire_object.obj_offset + offset, val16);
+}
+
+/**
+ * Get length of an object with a TLV header with uint16_t
+ * @param obj An object with a match member
+ * @param offset The wire offset of the start of the object
+ *
+ * The length field follows the type field.
+ */
+
+#define _TLV16_LEN(obj, offset) \\
+    (of_object_u16_get((of_object_t *)(obj), (offset) + 2))
+
+/**
+ * Get length of an object that is the "rest" of the object
+ * @param obj An object with a match member
+ * @param offset The wire offset of the start of the object
+ *
+ */
+
+#define _END_LEN(obj, offset) ((obj)->length - (offset))
+
+/**
+ * Get length of the action list object in a packet_out object
+ * @param obj An object of type of_packet_out
+ *
+ * The length field is just before the end of the fixed length
+ * part of the object in all versions.
+ */
+
+#define _PACKET_OUT_ACTION_LEN(obj) \\
+    (of_object_u16_get((of_object_t *)(obj), \\
+     of_object_fixed_len[(obj)->version][OF_PACKET_OUT] - 2))
+
+/**
+ * Set length of the action list object in a packet_out object
+ * @param obj An object of type of_packet_out
+ *
+ * The length field is just before the end of the fixed length
+ * part of the object in all versions.
+ */
+
+#define _PACKET_OUT_ACTION_LEN_SET(obj, len) \\
+    (of_object_u16_set((of_object_t *)(obj), \\
+     of_object_fixed_len[(obj)->version][OF_PACKET_OUT] - 2, len))
+
+/*
+ * Match structs in 1.2 come at the end of the fixed length part
+ * of structures.  They add 8 bytes to the minimal length of the
+ * message, but are also variable length.  This means that the 
+ * type/length offsets are 8 bytes back from the end of the fixed 
+ * length part of the object.  The right way to handle this is to 
+ * expose the offset of the match member more explicitly.  For now, 
+ * we make the calculation as described here.
+ */
+
+/* 1.2 min length of match is 8 bytes */
+#define _MATCH_MIN_LENGTH_V3 8
+
+/**
+ * The offset of a 1.2 match object relative to fixed length of obj
+ */
+#define _MATCH_OFFSET_V3(fixed_obj_len) \\
+    ((fixed_obj_len) - _MATCH_MIN_LENGTH_V3)
+
+/**
+ * The "extra" length beyond the minimal 8 bytes of a match struct
+ * in an object
+ */
+#define _MATCH_EXTRA_LENGTH_V3(obj, fixed_obj_len) \\
+    (OF_MATCH_BYTES(_TLV16_LEN(obj, _MATCH_OFFSET_V3(fixed_obj_len))) - \\
+     _MATCH_MIN_LENGTH_V3)
+
+/**
+ * The offset of an object following a match object for 1.2
+ */
+#define _OFFSET_FOLLOWING_MATCH_V3(obj, fixed_obj_len) \\
+    ((fixed_obj_len) + _MATCH_EXTRA_LENGTH_V3(obj, fixed_obj_len))
+
+/**
+ * Get length of a match object from its wire representation
+ * @param obj An object with a match member
+ * @param match_offset The wire offset of the match object.
+ *
+ * See above; for 1.2, 
+ * The match length is raw bytes but the actual space it takes
+ * up is padded for alignment to 64-bits
+ */
+#define _WIRE_MATCH_LEN(obj, match_offset) \\
+    (((obj)->version == OF_VERSION_1_0) ? %(match1)d : \\
+     (((obj)->version == OF_VERSION_1_1) ? %(match2)d : \\
+      _TLV16_LEN(obj, match_offset)))
+
+#define _WIRE_LEN_MIN 4
+
+/*
+ * Wrapper function for match len.  There are cases where the wire buffer
+ * has not been set with the proper minimum length.  In this case, the
+ * wire match len is interpretted as its minimum length, 4 bytes.
+ */
+
+static inline int
+wire_match_len(of_object_t *obj, int match_offset) {
+    int len;
+
+    len = _WIRE_MATCH_LEN(obj, match_offset);
+
+    return (len == 0) ? _WIRE_LEN_MIN : len;
+}
+
+#define _WIRE_MATCH_PADDED_LEN(obj, match_offset) \\
+    OF_MATCH_BYTES(wire_match_len((of_object_t *)(obj), (match_offset)))
+
+/**
+ * Macro to calculate variable offset of instructions member in flow mod
+ * @param obj An object of some type of flow modify/add/delete
+ *
+ * Get length of preceding match object and add to fixed length
+ * Applies only to version 1.2
+ */
+
+#define _FLOW_MOD_INSTRUCTIONS_OFFSET(obj) \\
+    _OFFSET_FOLLOWING_MATCH_V3(obj, %(flow_mod)d)
+
+/* The different flavors of flow mod all use the above */
+#define _FLOW_ADD_INSTRUCTIONS_OFFSET(obj) \\
+    _FLOW_MOD_INSTRUCTIONS_OFFSET(obj)
+#define _FLOW_MODIFY_INSTRUCTIONS_OFFSET(obj) \\
+    _FLOW_MOD_INSTRUCTIONS_OFFSET(obj)
+#define _FLOW_MODIFY_STRICT_INSTRUCTIONS_OFFSET(obj) \\
+    _FLOW_MOD_INSTRUCTIONS_OFFSET(obj)
+#define _FLOW_DELETE_INSTRUCTIONS_OFFSET(obj) \\
+    _FLOW_MOD_INSTRUCTIONS_OFFSET(obj)
+#define _FLOW_DELETE_STRICT_INSTRUCTIONS_OFFSET(obj) \\
+    _FLOW_MOD_INSTRUCTIONS_OFFSET(obj)
+
+/**
+ * Macro to calculate variable offset of instructions member in flow stats
+ * @param obj An object of type of_flow_mod_t
+ *
+ * Get length of preceding match object and add to fixed length
+ * Applies only to version 1.2 and 1.3
+ */
+
+#define _FLOW_STATS_ENTRY_INSTRUCTIONS_OFFSET(obj) \\
+    _OFFSET_FOLLOWING_MATCH_V3(obj, %(flow_stats)d)
+
+/**
+ * Macro to calculate variable offset of data (packet) member in packet_in
+ * @param obj An object of type of_packet_in_t
+ *
+ * Get length of preceding match object and add to fixed length
+ * Applies only to version 1.2 and 1.3
+ */
+
+#define _PACKET_IN_DATA_OFFSET(obj) \\
+    _OFFSET_FOLLOWING_MATCH_V3((obj), (obj)->version == OF_VERSION_1_2 ? \
+%(packet_in)d : %(packet_in_1_3)d)
+
+/**
+ * Macro to calculate variable offset of data (packet) member in packet_out
+ * @param obj An object of type of_packet_out_t
+ *
+ * Find the length in the actions_len variable and add to the fixed len
+ * Applies only to version 1.2 and 1.3
+ */
+
+#define _PACKET_OUT_DATA_OFFSET(obj) (_PACKET_OUT_ACTION_LEN(obj) + \\
+     of_object_fixed_len[(obj)->version][OF_PACKET_OUT])
+
+/**
+ * Macro to map port numbers that changed across versions
+ * @param port The port_no_t variable holding the value
+ * @param ver The OpenFlow version from which the value was extracted
+ */
+#define OF_PORT_NO_VALUE_CHECK(port, ver) \\
+    if (((ver) == OF_VERSION_1_0) && ((port) > 0xff00)) (port) += 0xffff0000
+
+""" % dict(flow_mod=of_g.base_length[("of_flow_modify",of_g.VERSION_1_2)],
+           packet_in=of_g.base_length[("of_packet_in",of_g.VERSION_1_2)],
+           packet_in_1_3=of_g.base_length[("of_packet_in",of_g.VERSION_1_3)],
+           flow_stats=of_g.base_length[("of_flow_stats_entry",
+                                        of_g.VERSION_1_2)],
+           match1=of_g.base_length[("of_match_v1",of_g.VERSION_1_0)],
+           match2=of_g.base_length[("of_match_v2",of_g.VERSION_1_1)]))
+
+def gen_obj_id_macros(out):
+    """
+    Flow modify (add, delete) messages (and maybe others) use ID checks allowing
+    inheritance to use common accessor functions.
+    """
+    out.write("""
+/**
+ * Macro to detect if an object ID falls in the "flow mod" family of objects
+ * This includes add, modify, modify_strict, delete and delete_strict
+ */
+#define IS_FLOW_MOD_SUBTYPE(object_id)                 \\
+    (((object_id) == OF_FLOW_MODIFY) ||                \\
+     ((object_id) == OF_FLOW_MODIFY_STRICT) ||         \\
+     ((object_id) == OF_FLOW_DELETE) ||                \\
+     ((object_id) == OF_FLOW_DELETE_STRICT) ||         \\
+     ((object_id) == OF_FLOW_ADD))
+""")
+
+
+def top_c_gen(out, name):
+    """
+    Generate code for
+    @param out The file handle to write to
+    @param name The name of the file
+    """
+    common_top_matter(out, name)
+    # Generic C code that needs to go into loci.c can go here.
+    out.write("""
+/****************************************************************
+ *
+ * This file is divided into the following sections.
+ *
+ * Instantiate strings such as object names
+ * Special case macros for low level object access
+ * Per-class, per-member accessor definitions
+ * Per-class new/init function definitions
+ * Per-class new/init pointer instantiations
+ * Instantiate "set map" for pointer set fns
+ *
+ ****************************************************************/
+
+#include <loci/loci.h>
+#include <loci/of_object.h>
+#include "loci_log.h"
+
+""")
+    gen_object_enum_str(out)
+    gen_len_offset_macros(out)
+    gen_obj_id_macros(out)
+    if config_check("gen_unified_fns"):
+        gen_accessor_definitions(out)
+    gen_new_function_definitions(out)
+    gen_init_map(out)
+    out.write("\n/* This code should be broken out to a different file */\n")
+    gen_setup_from_add_fns(out)
+
+def type_data_c_gen(out, name):
+    common_top_matter(out, name)
+    c_type_maps.gen_type_maps(out)
+    c_type_maps.gen_length_array(out)
+
+################################################################
+# Top Matter
+################################################################
+
+def common_top_matter(out, name):
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""\
+/****************************************************************
+ * File: %s
+ *
+ * DO NOT EDIT
+ *
+ * This file is automatically generated
+ *
+ ****************************************************************/
+
+""" % name)
+
+    if name[-2:] == ".h":
+        out.write("""
+#if !defined(%(h)s)
+#define %(h)s
+
+""" % dict(h=h_file_to_define(name)))
+
+def base_h_content(out):
+    """
+    Generate base header file content
+
+    @param out The output file object
+    """
+
+    # @fixme Supported version should be generated based on input to LoxiGen
+
+    out.write("""
+/*
+ * Base OpenFlow definitions.  These depend only on standard C headers
+ */
+#include <string.h>
+#include <stdint.h>
+
+/* g++ requires this to pick up PRI, etc.
+ * See  http://gcc.gnu.org/ml/gcc-help/2006-10/msg00223.html
+ */
+#if !defined(__STDC_FORMAT_MACROS)
+#define __STDC_FORMAT_MACROS
+#endif
+#include <inttypes.h>
+
+#include <stdlib.h>
+#include <assert.h>
+#include <loci/loci_idents.h>
+
+/**
+ * Macro to enable debugging for LOCI.
+ *
+ * This enables debug output to stdout.
+ */
+#define OF_DEBUG_ENABLE
+
+#if defined(OF_DEBUG_ENABLE)
+#include <stdio.h> /* Currently for debugging */
+#define FIXME(str) do {                 \\
+        fprintf(stderr, "%s\\n", str);  \\
+        exit(1);                        \\
+    } while (0)
+#define debug printf
+#else
+#define FIXME(str)
+#define debug(str, ...)
+#endif /* OF_DEBUG_ENABLE */
+
+/**
+ * The type of a function used by the LOCI dump/show functions to
+ * output text. Essentially the same signature as fprintf. May
+ * be called many times per invocation of e.g. of_object_show().
+ */
+typedef int (*loci_writer_f)(void *cookie, const char *fmt, ...);
+
+/**
+ * Check if a version is supported
+ */
+#define OF_VERSION_OKAY(v) ((v) >= OF_VERSION_1_0 && (v) <= OF_VERSION_1_3)
+
+""")
+    gen_version_enum(out)
+    out.write("\n")
+
+    # for c_name in of_g.ofp_constants:
+    #     val = str(of_g.ofp_constants[c_name])
+    #     out.write("#define %s %s\n" % (c_name, val))
+    # out.write("\n")
+
+    out.write("""
+typedef enum of_error_codes_e {
+    OF_ERROR_NONE        = 0,
+    OF_ERROR_RESOURCE    = -1,    /* Could not allocate space */
+    OF_ERROR_PARAM       = -2,    /* Bad parameter */
+    OF_ERROR_VERSION     = -3,    /* Version not supported */
+    OF_ERROR_RANGE       = -4,    /* End of list indication */
+    OF_ERROR_COMPAT      = -5,    /* Incompatible assignment */
+    OF_ERROR_PARSE       = -6,    /* Error in parsing data */
+    OF_ERROR_INIT        = -7,    /* Uninitialized data */
+    OF_ERROR_UNKNOWN     = -8     /* Unknown error */
+} of_error_codes_t;
+
+#define OF_ERROR_STRINGS "none", \\
+    "resource", \\
+    "parameter", \\
+    "version", \\
+    "range", \\
+    "incompatible", \\
+    "parse", \\
+    "init", \\
+    "unknown"
+
+extern const char *of_error_strings[];
+
+/* #define ASSERT(val) assert(val) */
+#define FORCE_FAULT *(volatile int *)0 = 1
+#define ASSERT(val) if (!(val)) \\
+    fprintf(stderr, "\\nASSERT %s. %s:%d\\n", #val, __FILE__, __LINE__), \\
+    FORCE_FAULT
+
+/*
+ * Some LOCI object accessors can fail, and it's easy to forget to check.
+ * On certain compilers we can trigger a warning if the error code
+ * is ignored.
+ */
+#ifndef DISABLE_WARN_UNUSED_RESULT
+#ifdef __GNUC__
+#define WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
+#else
+#define WARN_UNUSED_RESULT
+#endif
+#else
+#define WARN_UNUSED_RESULT
+#endif
+
+typedef union of_generic_u of_generic_t;
+typedef struct of_object_s of_object_t;
+
+/* Define ipv4 address as uint32 */
+typedef uint32_t of_ipv4_t;
+
+/* Table ID is the OF standard uint8 */
+typedef uint8_t of_table_id_t;
+
+#define OF_MAC_ADDR_BYTES 6
+typedef struct of_mac_addr_s {
+   uint8_t addr[OF_MAC_ADDR_BYTES];
+} of_mac_addr_t;
+
+#define OF_IPV6_BYTES 16
+typedef struct of_ipv6_s {
+   uint8_t addr[OF_IPV6_BYTES];
+} of_ipv6_t;
+
+extern const of_mac_addr_t of_mac_addr_all_ones;
+extern const of_mac_addr_t of_mac_addr_all_zeros;
+
+extern const of_ipv6_t of_ipv6_all_ones;
+extern const of_ipv6_t of_ipv6_all_zeros;
+
+/**
+ * Generic zero and all-ones values of size 16 bytes.
+ *
+ * IPv6 is longest data type we worry about for comparisons
+ */
+#define of_all_zero_value of_ipv6_all_zeros
+#define of_all_ones_value of_ipv6_all_ones
+
+/**
+ * Non-zero/all ones check for arbitrary type of size <= 16 bytes
+ */
+#define OF_VARIABLE_IS_NON_ZERO(_ptr) \\
+    (MEMCMP(&of_all_zero_value, (_ptr), sizeof(*(_ptr))))
+#define OF_VARIABLE_IS_ALL_ONES(_ptr) \\
+    (!MEMCMP(&of_all_ones_value, (_ptr), sizeof(*(_ptr))))
+
+/* The octets object is a struct holding pointer and length */
+typedef struct of_octets_s {
+    uint8_t *data;
+    int bytes;
+} of_octets_t;
+
+/* Macro to convert an octet object to a pointer; currently trivial */
+#define OF_OCTETS_POINTER_GET(octet_ptr) ((octet_ptr)->data)
+#define OF_OCTETS_POINTER_SET(octet_ptr, ptr) (octet_ptr)->data = (ptr)
+#define OF_OCTETS_BYTES_GET(octet_ptr) ((octet_ptr)->bytes)
+#define OF_OCTETS_BYTES_SET(octet_ptr, bytes) (octet_ptr)->bytes = (bytes)
+
+/* Currently these are categorized as scalars */
+typedef char of_port_name_t[OF_MAX_PORT_NAME_LEN];
+typedef char of_table_name_t[OF_MAX_TABLE_NAME_LEN];
+typedef char of_desc_str_t[OF_DESC_STR_LEN];
+typedef char of_serial_num_t[OF_SERIAL_NUM_LEN];
+
+/* These are types which change across versions.  */
+typedef uint32_t of_port_no_t;
+typedef uint16_t of_fm_cmd_t;
+typedef uint64_t of_wc_bmap_t;
+typedef uint64_t of_match_bmap_t;
+
+#define MEMMOVE(dest, src, bytes) memmove(dest, src, bytes)
+#define MEMSET(dest, val, bytes) memset(dest, val, bytes)
+#define MEMCPY(dest, src, bytes) memcpy(dest, src, bytes)
+#define MEMCMP(a, b, bytes) memcmp(a, b, bytes)
+#define MALLOC(bytes) malloc(bytes)
+#define FREE(ptr) free(ptr)
+
+/** Try an operation and return on failure. */
+#define OF_TRY(op) do {                                                      \\
+        int _rv;                                                             \\
+        if ((_rv = (op)) < 0) {                                              \\
+            LOCI_LOG_ERROR("ERROR %d at %s:%d\\n", _rv, __FILE__, __LINE__); \\
+            return _rv;                                                      \\
+        }                                                                    \\
+    } while (0)
+
+/* The extent of an OF match object is determined by its length field, but
+ * aligned to 8 bytes
+ */
+
+#define OF_MATCH_BYTES(length) (((length) + 7) & 0xfff8)
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define U16_NTOH(val) (val)
+#define U32_NTOH(val) (val)
+#define U64_NTOH(val) (val)
+#define IPV6_NTOH(dst, src) /* NOTE different syntax; currently no-op */
+#define U16_HTON(val) (val)
+#define U32_HTON(val) (val)
+#define U64_HTON(val) (val)
+#define IPV6_HTON(dst, src) /* NOTE different syntax; currently no-op */
+#else /* Little Endian */
+#define U16_NTOH(val) (((val) >> 8) | ((val) << 8))
+#define U32_NTOH(val) ((((val) & 0xff000000) >> 24) |                   \\
+                       (((val) & 0x00ff0000) >>  8) |                   \\
+                       (((val) & 0x0000ff00) <<  8) |                   \\
+                       (((val) & 0x000000ff) << 24))
+#define U64_NTOH(val) ((((val) & 0xff00000000000000LL) >> 56) |         \\
+                       (((val) & 0x00ff000000000000LL) >> 40) |         \\
+                       (((val) & 0x0000ff0000000000LL) >> 24) |         \\
+                       (((val) & 0x000000ff00000000LL) >>  8) |         \\
+                       (((val) & 0x00000000ff000000LL) <<  8) |         \\
+                       (((val) & 0x0000000000ff0000LL) << 24) |         \\
+                       (((val) & 0x000000000000ff00LL) << 40) |         \\
+                       (((val) & 0x00000000000000ffLL) << 56))
+#define IPV6_NTOH(dst, src) /* NOTE different syntax; currently no-op */
+#define U16_HTON(val) U16_NTOH(val)
+#define U32_HTON(val) U32_NTOH(val)
+#define U64_HTON(val) U64_NTOH(val)
+#define IPV6_HTON(dst, src) /* NOTE different syntax; currently no-op */
+#endif
+
+/****************************************************************
+ *
+ * The following are internal definitions used by the automatically
+ * generated code.  Users should not reference these definitions
+ * as they may change between versions of this code
+ *
+ ****************************************************************/
+
+#define OF_MESSAGE_IN_MATCH_POINTER(obj)                            \\
+    (WIRE_BUF_POINTER(&((obj)->wire_buffer), OF_MESSAGE_IN_MATCH_OFFSET))
+#define OF_MESSAGE_IN_MATCH_LEN(ptr) BUF_U16_GET(&ptr[2])
+#define OF_MESSAGE_IN_DATA_OFFSET(obj) \\
+    (FIXED_LEN + OF_MESSAGE_IN_MATCH_LEN(OF_MESSAGE_IN_MATCH_POINTER(obj)) + 2)
+
+#define OF_MESSAGE_OUT_DATA_OFFSET(obj) \\
+    (FIXED_LEN + of_message_out_actions_len_get(obj))
+
+""")
+
+def external_h_top_matter(out, name):
+    """
+    Generate top matter for external header file
+
+    @param name The name of the output file
+    @param out The output file object
+    """
+    common_top_matter(out, name)
+    out.write("""
+#include <loci/loci_base.h>
+#include <loci/of_message.h>
+#include <loci/of_match.h>
+#include <loci/of_object.h>
+#include <loci/of_wire_buf.h>
+
+/****************************************************************
+ *
+ * This file is divided into the following sections.
+ *
+ * A few object specific macros
+ * Class typedefs (no struct definitions)
+ * Per-data type accessor function typedefs
+ * Per-class new/delete function typedefs
+ * Per-class static delete functions
+ * Per-class, per-member accessor declarations
+ * Per-class structure definitions
+ * Generic union (inheritance) definitions
+ * Pointer set function declarations
+ * Some special case macros
+ *
+ ****************************************************************/
+""")
+
+def gen_top_static_functions(out):
+    out.write("""
+
+#define _MAX_PARENT_ITERATIONS 4
+/**
+ * Iteratively update parent lengths thru hierarchy
+ * @param obj The object whose length is being updated
+ * @param delta The difference between the current and new lengths
+ *
+ * Note that this includes updating the object itself.  It will
+ * iterate thru parents.
+ *
+ * Assumes delta > 0.
+ */
+static inline void
+of_object_parent_length_update(of_object_t *obj, int delta)
+{
+    int count = 0;
+    of_wire_buffer_t *wbuf;  /* For debug asserts only */
+
+    while (obj != NULL) {
+        ASSERT(count++ < _MAX_PARENT_ITERATIONS);
+        obj->length += delta;
+        if (obj->wire_length_set != NULL) {
+            obj->wire_length_set(obj, obj->length);
+        }
+        wbuf = obj->wire_object.wbuf;
+
+        /* Asserts for wire length checking */
+        ASSERT(obj->length + obj->wire_object.obj_offset <=
+               WBUF_CURRENT_BYTES(wbuf));
+        if (obj->parent == NULL) {
+            ASSERT(obj->length + obj->wire_object.obj_offset ==
+                   WBUF_CURRENT_BYTES(wbuf));
+        }
+
+        obj = obj->parent;
+    }
+}
+""")
+
+################################################################
+#
+################################################################
+
+def gen_version_enum(out):
+    """
+    Generate the enumerated type for versions in LoxiGen
+    @param out The file object to which to write the decs
+
+    This just uses the wire versions for now
+    """
+    out.write("""
+/**
+ * Enumeration of OpenFlow versions
+ *
+ * The wire protocol numbers are currently used for values of the corresponding
+ * version identifiers.
+ */
+typedef enum of_version_e {
+    OF_VERSION_UNKNOWN = 0,
+""")
+
+    is_first = True
+    max = 0
+    for v in of_g.wire_ver_map:
+        if is_first:
+            is_first = False
+        else:
+            out.write(",\n")
+        if v > max:
+            max = v
+        out.write("    %s = %d" % (of_g.wire_ver_map[v], v))
+
+    out.write("""
+} of_version_t;
+
+/**
+ * @brief Use this when declaring arrays indexed by wire version
+ */
+#define OF_VERSION_ARRAY_MAX %d
+""" % (max + 1))
+    
+def gen_object_enum(out):
+    """
+    Generate the enumerated type for object identification in LoxiGen
+    @param out The file object to which to write the decs
+    """
+    out.write("""
+
+/**
+ * Enumeration of OpenFlow objects
+ *
+ * We enumerate the OpenFlow objects used internally.  Note that some
+ * message types are determined both by an outer type (message type like
+ * stats_request) and an inner type (port stats).  These are different
+ * messages in ofC.
+ *
+ * These values are for internal use only.  They will change with
+ * different versions of ofC.
+ */
+
+typedef enum of_object_id_e {
+    /* Root object type */
+    OF_OBJECT_INVALID = -1, /* "invalid" return value for mappings */
+    OF_OBJECT = 0, /* Generic, untyped object */
+
+    /* OpenFlow message objects */
+""")
+    last = 0
+    msg_count = 0
+    for cls in of_g.ordered_messages:
+        out.write("    %s = %d,\n" % (enum_name(cls),
+                                   of_g.unified[cls]["object_id"]))
+        msg_count = of_g.unified[cls]["object_id"] + 1
+
+    out.write("\n    /* Non-message objects */\n")
+    for cls in of_g.ordered_non_messages:
+        out.write("    %s = %d,\n" % (enum_name(cls),
+                                   of_g.unified[cls]["object_id"]))
+        last = of_g.unified[cls]["object_id"]
+    out.write("\n    /* List objects */\n")
+    for cls in of_g.ordered_list_objects:
+        out.write("    %s = %d,\n" % (enum_name(cls),
+                                   of_g.unified[cls]["object_id"]))
+        last = of_g.unified[cls]["object_id"]
+
+    out.write("\n    /* Generic stats request/reply types; pseudo objects */\n")
+    for cls in of_g.ordered_pseudo_objects:
+        out.write("    %s = %d,\n" % (enum_name(cls),
+                                   of_g.unified[cls]["object_id"]))
+        last = of_g.unified[cls]["object_id"]
+
+    out.write("""
+    OF_OBJECT_COUNT = %d
+} of_object_id_t;
+
+extern const char *of_object_id_str[];
+
+#define OF_MESSAGE_OBJECT_COUNT %d
+""" % ((last + 1), msg_count))
+
+    # Generate object type range checking for inheritance classes
+
+    # @fixme These should be determined algorithmicly
+    out.write("""
+/*
+ * Macros to check if an object ID is within an inheritance class range
+ */
+""")
+    # Alphabetical order for 'last'
+    last_ids = dict(of_action="OF_ACTION_STRIP_VLAN",
+                    of_oxm="OF_OXM_VLAN_VID_MASKED",
+                    of_instruction="OF_INSTRUCTION_WRITE_METADATA",
+                    of_queue_prop="OF_QUEUE_PROP_MIN_RATE",
+                    of_table_feature_prop="OF_TABLE_FEATURE_PROP_WRITE_SETFIELD_MISS",
+                    # @FIXME add meter_band ?
+                    )
+    for cls, last in last_ids.items():
+        out.write("""
+#define %(enum)s_FIRST_ID      (%(enum)s + 1)
+#define %(enum)s_LAST_ID       %(last)s
+#define %(enum)s_VALID_ID(id) \\
+    ((id) >= %(enum)s_FIRST_ID && \\
+     (id) <= %(enum)s_LAST_ID)
+""" % dict(enum=enum_name(cls), last=last))
+    out.write("""
+/**
+ * Function to check a wire ID
+ * @param object_id The ID to check
+ * @param base_object_id The inheritance parent, if applicable
+ * @returns boolean: If base_object_id is an inheritance class, check if
+ * object_id is valid as a subclass.  Otherwise return 1.
+ *
+ * Note: Could check that object_id == base_object_id in the
+ * second case.
+ */
+static inline int
+of_wire_id_valid(int object_id, int base_object_id) {
+    switch (base_object_id) {
+    case OF_ACTION:
+        return OF_ACTION_VALID_ID(object_id);
+    case OF_OXM:
+        return OF_OXM_VALID_ID(object_id);
+    case OF_QUEUE_PROP:
+        return OF_QUEUE_PROP_VALID_ID(object_id);
+    case OF_TABLE_FEATURE_PROP:
+        return OF_TABLE_FEATURE_PROP_VALID_ID(object_id);
+    case OF_INSTRUCTION:
+        return OF_INSTRUCTION_VALID_ID(object_id);
+    default:
+        break;
+    }
+    return 1;
+}
+""")
+
+def gen_object_enum_str(out):
+    out.write("\nconst char *of_object_id_str[] = {\n")
+    out.write("    \"of_object\",\n")
+    for cls in of_g.ordered_messages:
+        out.write("    \"%s\",\n" % cls)
+    out.write("\n    /* Non-message objects */\n")
+    for cls in of_g.ordered_non_messages:
+        out.write("    \"%s\",\n" % cls)
+    out.write("\n    /* List objects */\n")
+    for cls in of_g.ordered_list_objects:
+        out.write("    \"%s\",\n" % cls)
+    out.write("\n    /* Generic stats request/reply types; pseudo objects */\n")
+    for cls in of_g.ordered_pseudo_objects:
+        out.write("    \"%s\",\n" % cls)
+    out.write("\n    \"of_unknown_object\"\n};\n")
+
+    # We'll do version strings while we're at it
+    out.write("""
+ const char *of_version_str[] = {
+    "Unknown OpenFlow Version",
+    "OpenFlow-1.0",
+    "OpenFlow-1.1",
+    "OpenFlow-1.2"
+};
+
+const of_mac_addr_t of_mac_addr_all_ones = {
+    {
+        0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+    }
+};
+/* Just to be explicit; static duration vars are init'd to 0 */
+const of_mac_addr_t of_mac_addr_all_zeros = {
+    {
+        0, 0, 0, 0, 0, 0
+    }
+};
+
+const of_ipv6_t of_ipv6_all_ones = {
+    {
+        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+    }
+};
+/* Just to be explicit; static duration vars are init'd to 0 */
+const of_ipv6_t of_ipv6_all_zeros = {
+    {
+        0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0
+    }
+};
+
+/** @var of_error_strings
+ * The error string map; use abs value to index
+ */
+const char *of_error_strings[] = { OF_ERROR_STRINGS };
+""")
+
+################################################################
+#
+# Internal Utility Functions
+#
+################################################################
+
+
+def acc_name(cls, m_name):
+    """
+    Generate the root name of an accessor function for typedef
+    @param cls The class name
+    @param m_name The member name
+    """
+    (m_type, get_rv) = get_acc_rv(cls, m_name)
+    return "%s_%s" % (cls, m_type)
+
+def get_acc_rv(cls, m_name):
+    """
+    Determine the data type and return type for a get accessor.
+
+    The return type may be "void" or it may be the accessor type
+    depending on the system configuration and on the data type.
+
+    @param cls The class name
+    @param m_name The member name
+    @return A pair (m_type, rv) where m_type is the unified type of the
+    member and rv is the get_accessor return type
+    """
+    member = of_g.unified[cls]["union"][m_name]
+    m_type = member["m_type"]
+    rv = "int"
+    if member_returns_val(cls, m_name):
+        rv = m_type
+    if m_type[-2:] == "_t":
+        m_type = m_type[:-2]
+
+    return (m_type, rv)
+
+def param_list(cls, m_name, a_type):
+    """
+    Generate the parameter list (no parens) for an a_type accessor
+    @param cls The class name
+    @param m_name The member name
+    @param a_type One of "set" or "get" or TBD
+    """
+    member = of_g.unified[cls]["union"][m_name]
+    m_type = member["m_type"]
+    params = ["%s_t *obj" % cls]
+    if a_type == "set":
+        if loxi_utils.type_is_scalar(m_type):
+            params.append("%s %s" % (m_type, m_name))
+        else:
+            params.append("%s *%s" % (m_type, m_name))
+    elif a_type in ["get", "bind"]:
+        params.append("%s *%s" % (m_type, m_name))
+    else:
+        debug("Class %s, name %s Bad param list a_type: %s" %
+            (cls, m_name, a_type))
+        sys.exit(1)
+    return params
+
+def typed_function_base(cls, m_name):
+    """
+    Generate the core name for accessors based on the type
+    @param cls The class name
+    @param m_name The member name
+    """
+    (m_type, get_rv) = get_acc_rv(cls, m_name)
+    return "%s_%s" % (cls, m_type)
+
+def member_function_base(cls, m_name):
+    """
+    Generate the core name for accessors based on the member name
+    @param cls The class name
+    @param m_name The member name
+    """
+    return "%s_%s" % (cls, m_name)
+
+def field_ver_get(cls, m_name):
+    """
+    Generate a dict, indexed by wire version, giving a pair (type, offset)
+
+    @param cls The class name
+    @param m_name The name of the class member
+
+    If offset is not known for m_name, the type
+    A dict is used for more convenient indexing.
+    """
+    result = {}
+
+    for ver in of_g.unified[cls]:
+        if type(ver) == type(0): # It's a version
+            if "use_version" in of_g.unified[cls][ver]: # deref version ref
+                ref_ver = of_g.unified[cls][ver]["use_version"]
+                members = of_g.unified[cls][ref_ver]["members"]
+            else:
+                members = of_g.unified[cls][ver]["members"]
+            idx = loxi_utils.member_to_index(m_name, members)
+            if (idx < 0):
+                continue # Member not in this version
+            m_type = members[idx]["m_type"]
+            offset = members[idx]["offset"]
+
+            # If m_type is mixed, get wire version type from global data
+            if m_type in of_g.of_mixed_types and \
+                    ver in of_g.of_mixed_types[m_type]:
+                m_type = of_g.of_mixed_types[m_type][ver]
+
+            # add version to result list
+            result[ver] = (m_type, offset)
+
+    return result
+
+def v3_match_offset_get(cls):
+    """
+    Return the offset of an OF 1.2 match in an object if it has such; 
+    otherwise return -1
+    """
+    result = field_ver_get(cls, "match")
+    if of_g.VERSION_1_2 in result:
+        if result[of_g.VERSION_1_2][0] == "of_match_v3_t":
+            return result[of_g.VERSION_1_2][1]
+    return -1
+
+################################################################
+#
+# OpenFlow Object Definitions
+#
+################################################################
+
+
+def gen_of_object_defs(out):
+    """
+    Generate low level of_object core operations
+    @param out The file for output, already open
+    """
+
+def gen_generics(out):
+    for (cls, subclasses) in type_maps.inheritance_map.items():
+        out.write("""
+/**
+ * Inheritance super class for %(cls)s
+ *
+ * This class is the union of %(cls)s classes.  You can refer
+ * to it untyped by refering to the member 'header' whose structure
+ * is common across all sub-classes.
+ */
+
+union %(cls)s_u {
+    %(cls)s_header_t header; /* Generic instance */
+""" % dict(cls=cls))
+        for subcls in sorted(subclasses):
+            out.write("    %s_%s_t %s;\n" % (cls, subcls, subcls))
+        out.write("};\n")
+
+def gen_struct_typedefs(out):
+    """
+    Generate typedefs for all struct objects
+    @param out The file for output, already open
+    """
+
+    out.write("\n/* LOCI inheritance parent typedefs */\n")
+    for cls in type_maps.inheritance_map:
+        out.write("typedef union %(cls)s_u %(cls)s_t;\n" % dict(cls=cls))
+    out.write("\n/* LOCI object typedefs */\n")
+    for cls in of_g.standard_class_order:
+        if cls in type_maps.inheritance_map:
+            continue
+        if config_check("gen_fn_ptrs"):
+            out.write("typedef struct %(cls)s_s %(cls)s_t;\n" % dict(cls=cls))
+        else:
+            template = "typedef of_object_t %(cls)s_t;\n"
+            out.write(template % dict(cls=cls))
+
+    out.write("""
+/****************************************************************
+ *
+ * Additional of_object defines
+ * These are needed for some static inline ops, so we put them here.
+ *
+ ****************************************************************/
+
+/* Delete an OpenFlow object without reference to its type */
+extern void of_object_delete(of_object_t *obj);
+
+""")
+
+def gen_generic_union(out):
+    """
+    Generate the generic union object composing all LOCI objects
+
+    @param out The file to which to write the decs
+    """
+    out.write("""
+/**
+ * The common LOCI object is a union of all possible objects.
+ */
+union of_generic_u {
+    of_object_t object;  /* Common base class with fundamental accessors */
+
+    /* Message objects */
+""")
+    for cls in of_g.ordered_messages:
+        out.write("    %s_t %s;\n" % (cls, cls))
+    out.write("\n    /* Non-message composite objects */\n")
+    for cls in of_g.ordered_non_messages:
+        if cls in type_maps.inheritance_map:
+            continue
+        out.write("    %s_t %s;\n" % (cls, cls))
+    out.write("\n    /* List objects */\n")
+    for cls in of_g.ordered_list_objects:
+        out.write("    %s_t %s;\n" % (cls, cls))
+    out.write("};\n")
+
+def gen_common_struct_definitions(out):
+    out.write("""
+/****************************************************************
+ *
+ * Unified structure definitions
+ *
+ ****************************************************************/
+
+struct of_object_s {
+    /* Common members */
+%(common)s
+};
+""" % dict(common=of_g.base_object_members))
+
+def gen_flow_add_setup_function_declarations(out):
+    """
+    Add the declarations for functions that can be initialized
+    by a flow add.  These are defined external to LOXI.
+    """
+
+    out.write("""
+/****************************************************************
+ * Functions for objects that can be initialized by a flow add message.
+ * These are defined in a non-autogenerated file
+ ****************************************************************/
+
+/**
+ * @brief Set up a flow removed message from the original add
+ * @param obj The flow removed message being updated
+ * @param flow_add The flow_add message to use
+ *
+ * Initialize the following fields of obj to be identical
+ * to what was originally on the wire from the flow_add object:
+ *     match
+ *     cookie
+ *     priority
+ *     idle_timeout
+ *     hard_timeout
+ *
+ */
+
+extern int
+of_flow_removed_setup_from_flow_add(of_flow_removed_t *obj,
+                                    of_flow_add_t *flow_add);
+
+
+/**
+ * @brief Set up the packet in match structure from the original add
+ * @param obj The packet in message being updated
+ * @param flow_add The flow_add message to use
+ * @returns Indigo error code.  Does not return a version error if
+ * the version does not require initializing obj.
+ *
+ * Initialize the match member of obj to be identical to what was originally
+ * on the wire from the flow_add object.  If applicable, the table ID is also
+ * initialized from the flow_add object.
+ *
+ * This API applies to 1.2 and later only.
+ */
+
+extern int
+of_packet_in_setup_from_flow_add(of_packet_in_t *obj,
+                                 of_flow_add_t *flow_add);
+
+
+/**
+ * @brief Set up the flow stats entry from the original add
+ * @param obj The packet in message being updated
+ * @param flow_add The flow_add message to use
+ * @param effects Optional actions or instructions; see below.
+ *
+ * Initialize the following fields of obj to be identical
+ * to what was originally on the wire from the flow_add object:
+ *     match
+ *     actions/instructions (effects)
+ *     cookie
+ *     priority
+ *     idle_timeout
+ *     hard_timeout
+ *
+ * Note that the actions/instructions of a flow may be modified by a 
+ * subsequent flow modify message.  To facilitate implementations,
+ * the "effects" parameter is provided.  If effects is NULL, the
+ * actions/instructions are taken from the flow_add message.
+ * Otherwise, effects is coerced to the proper type (actions or
+ * instructions) and used to init obj.
+ */
+
+extern int
+of_flow_stats_entry_setup_from_flow_add(of_flow_stats_entry_t *obj,
+                                        of_flow_add_t *flow_add,
+                                        of_object_t *effects);
+""")
+
+def gen_struct_definitions(out):
+    """
+    Generate the declaration of all of_ C structures
+
+    @param out The file to which to write the decs
+    """
+
+    # This should only get called if gen_fn_ptr is true in code_gen_config
+    if not config_check("gen_fn_ptrs"):
+        debug("Error: gen_struct_defs called, but no fn ptrs set")
+        return
+
+    for cls in of_g.standard_class_order:
+        if cls in type_maps.inheritance_map:
+            continue # These are generated elsewhere
+        note = ""
+        if loxi_utils.class_is_message(cls):
+            note = " /* Class is message */"
+        out.write("struct %s_s {%s\n" % (cls, note))
+        out.write("""    /* Common members */
+%s
+    /* Class specific members */
+""" % of_g.base_object_members)
+        if loxi_utils.class_is_list(cls):
+            out.write("""
+    %(cls)s_first_f first;
+    %(cls)s_next_f next;
+    %(cls)s_append_bind_f append_bind;
+    %(cls)s_append_f append;
+};
+
+""" % {"cls": cls})
+            continue   # All done with list object
+
+        # Else, not a list instance; add accessors for all data members
+        for m_name in of_g.ordered_members[cls]:
+            if m_name in of_g.skip_members:
+                # These members (length, etc) are handled internally
+                continue
+            f_name = acc_name(cls, m_name)
+            out.write("    %s_get_f %s;\n" % (f_name, m_name + "_get"))
+            out.write("    %s_set_f %s;\n" % (f_name, m_name + "_set"))
+        out.write("};\n\n")
+
+
+################################################################
+#
+# List accessor code generation
+#
+# Currently these all implement copy on read semantics
+#
+################################################################
+
+def init_call(e_type, obj, ver, length, cw):
+    """
+    Generate the init call given the strings for params
+    """
+    hdr = "" # If inheritance type, coerce to hdr object
+    obj_name = obj
+    if e_type in type_maps.inheritance_map:
+        hdr = "_header"
+        obj_name = "(%s_header_t *)" % e_type + obj
+
+    return """\
+%(e_type)s%(hdr)s_init(%(obj_name)s,
+            %(ver)s, %(length)s, %(cw)s)\
+""" % dict(e_type=e_type, hdr=hdr, obj_name=obj_name, ver=ver,
+           length=length, cw=cw)
+
+def gen_list_first(out, cls, e_type):
+    """
+    Generate the body of a list_first operation
+    @param cls The class name for which code is being generated
+    @param e_type The element type of the list
+    @param out The file to which to write
+    """
+    i_call = init_call(e_type, "obj", "list->version", "0", "1")
+    if e_type in type_maps.inheritance_map:
+        len_str = "obj->header.length"
+    else:
+        len_str = "obj->length"
+
+    out.write("""
+/**
+ * Associate an iterator with a list
+ * @param list The list to iterate over
+ * @param obj The list entry iteration pointer
+ * @return OF_ERROR_RANGE if the list is empty (end of list)
+ *
+ * The obj instance is completely initialized.  The caller is responsible
+ * for cleaning up any wire buffers associated with obj before this call
+ */
+
+int
+%(cls)s_first(%(cls)s_t *list,
+    %(e_type)s_t *obj)
+{
+    int rv;
+
+    %(i_call)s;
+    if ((rv = of_list_first((of_object_t *)list, (of_object_t *)obj)) < 0) {
+        return rv;
+    }
+""" % dict(cls=cls, e_type=e_type, i_call=i_call))
+
+    # Special case flow_stats_entry lists
+
+    out.write("""
+    of_object_wire_init((of_object_t *) obj, %(u_type)s,
+                        list->length);
+    if (%(len_str)s == 0) {
+        return OF_ERROR_PARSE;
+    }
+
+    return rv;
+}
+""" % dict(cls=cls, e_type=e_type, u_type=enum_name(e_type), len_str=len_str))
+
+
+def gen_bind(out, cls, m_name, m_type):
+    """
+    Generate the body of a bind function
+    @param out The file to which to write
+    @param cls The class name for which code is being generated
+    @param m_name The name of the data member
+    @param m_type The type of the data member
+    """
+
+    bparams = ",\n    ".join(param_list(cls, m_name, "bind"))
+
+    i_call = init_call(e_type, "child", "parent->version", "0", "1")
+
+    out.write("""
+/**
+ * Bind the child object to the parent object for read processing
+ * @param parent The parent object
+ * @param child The child object
+ *
+ * The child obj instance is completely initialized.
+ */
+
+int
+%(cls)s_%(m_name)_bind(%(cls)s_t *parent,
+    %(e_type)s_t *child)
+{
+    int rv;
+
+    %(i_call)s;
+
+    /* Derive offset and length of child in parent */
+    OF_TRY(of_object_child_attach(parent, child, 
+    if ((rv = of_list_first((of_object_t *)list, (of_object_t *)obj)) < 0) {
+        return rv;
+    }
+""" % dict(cls=cls, e_type=e_type, i_call=i_call))
+
+    # Special case flow_stats_entry lists
+
+    out.write("""
+    rv = of_object_wire_init((of_object_t *) obj, %(u_type)s,
+                               list->length);
+    if ((rv == OF_ERROR_NONE) && (%(len_str)s == 0)) {
+        return OF_ERROR_PARSE;
+    }
+
+    return rv;
+}
+""" % dict(cls=cls, e_type=e_type, u_type=enum_name(e_type), len_str=len_str))
+
+
+def gen_list_next(out, cls, e_type):
+    """
+    Generate the body of a list_next operation
+    @param cls The class name for which code is being generated
+    @param e_type The element type of the list
+    @param out The file to which to write
+    """
+
+    if e_type in type_maps.inheritance_map:
+        len_str = "obj->header.length"
+    else:
+        len_str = "obj->length"
+        
+    out.write("""
+/**
+ * Advance an iterator to the next element in a list
+ * @param list The list being iterated
+ * @param obj The list entry iteration pointer
+ * @return OF_ERROR_RANGE if already at the last entry on the list
+ *
+ */
+
+int
+%(cls)s_next(%(cls)s_t *list,
+    %(e_type)s_t *obj)
+{
+    int rv;
+
+    if ((rv = of_list_next((of_object_t *)list, (of_object_t *)obj)) < 0) {
+        return rv;
+    }
+
+    rv = of_object_wire_init((of_object_t *) obj, %(u_type)s,
+        list->length);
+
+    if ((rv == OF_ERROR_NONE) && (%(len_str)s == 0)) {
+        return OF_ERROR_PARSE;
+    }
+
+    return rv;
+}
+""" % dict(cls=cls, e_type=e_type, u_type=enum_name(e_type), len_str=len_str))
+
+def gen_list_append(out, cls, e_type):
+    """
+    Generate the body of a list append functions
+    @param cls The class name for which code is being generated
+    @param e_type The element type of the list
+    @param out The file to which to write
+    """
+
+    out.write("""
+/**
+ * Set up to append an object of type %(e_type)s to an %(cls)s.
+ * @param list The list that is prepared for append
+ * @param obj Pointer to object to hold data to append
+ *
+ * The obj instance is completely initialized.  The caller is responsible
+ * for cleaning up any wire buffers associated with obj before this call.
+ *
+ * See the generic documentation for of_list_append_bind.
+ */
+
+int
+%(cls)s_append_bind(%(cls)s_t *list,
+    %(e_type)s_t *obj)
+{
+    return of_list_append_bind((of_object_t *)list, (of_object_t *)obj);
+}
+
+/**
+ * Append an item to a %(cls)s list.
+ *
+ * This copies data from item and leaves item untouched.
+ *
+ * See the generic documentation for of_list_append.
+ */
+
+int
+%(cls)s_append(%(cls)s_t *list,
+    %(e_type)s_t *item)
+{
+    return of_list_append((of_object_t *)list, (of_object_t *)item);
+}
+
+""" % dict(cls=cls, e_type=e_type))
+
+def gen_list_accessors(out, cls):
+    e_type = loxi_utils.list_to_entry_type(cls)
+    gen_list_first(out, cls, e_type)
+    gen_list_next(out, cls, e_type)
+    gen_list_append(out, cls, e_type)
+
+################################################################
+#
+# Accessor Functions
+#
+################################################################
+
+    
+def gen_accessor_declarations(out):
+    """
+    Generate the declaration of each version independent accessor
+
+    @param out The file to which to write the decs
+    """
+
+    out.write("""
+/****************************************************************
+ *
+ * Unified, per-member accessor function declarations
+ *
+ ****************************************************************/
+""")
+    for cls in of_g.standard_class_order:
+        if cls in type_maps.inheritance_map:
+            continue
+        out.write("\n/* Unified accessor functions for %s */\n" % cls)
+        for m_name in of_g.ordered_members[cls]:
+            if m_name in of_g.skip_members:
+                continue
+            m_type = loxi_utils.member_base_type(cls, m_name)
+            base_name = "%s_%s" % (cls, m_name)
+            gparams = ",\n    ".join(param_list(cls, m_name, "get"))
+            get_ret_type = accessor_return_type("get", m_type)
+            sparams = ",\n    ".join(param_list(cls, m_name, "set"))
+            set_ret_type = accessor_return_type("set", m_type)
+            bparams = ",\n    ".join(param_list(cls, m_name, "bind"))
+            bind_ret_type = accessor_return_type("bind", m_type)
+
+            if loxi_utils.type_is_of_object(m_type):
+                # Generate bind accessors, but not get accessor
+                out.write("""
+extern %(set_ret_type)s %(base_name)s_set(
+    %(sparams)s);
+extern %(bind_ret_type)s %(base_name)s_bind(
+    %(bparams)s);
+extern %(m_type)s *%(cls)s_%(m_name)s_get(
+    %(cls)s_t *obj);
+""" % dict(base_name=base_name, sparams=sparams, bparams=bparams,
+           m_name=m_name, m_type=m_type, cls=cls,
+           set_ret_type=set_ret_type, bind_ret_type=bind_ret_type))
+            else:
+                out.write("""
+extern %(set_ret_type)s %(base_name)s_set(
+    %(sparams)s);
+extern %(get_ret_type)s %(base_name)s_get(
+    %(gparams)s);
+""" % dict(base_name=base_name, gparams=gparams, sparams=sparams,
+           get_ret_type=get_ret_type, set_ret_type=set_ret_type))
+            
+        if loxi_utils.class_is_list(cls):
+            e_type = loxi_utils.list_to_entry_type(cls)
+            out.write("""
+extern int %(cls)s_first(
+    %(cls)s_t *list, %(e_type)s_t *obj);
+extern int %(cls)s_next(
+    %(cls)s_t *list, %(e_type)s_t *obj);
+extern int %(cls)s_append_bind(
+    %(cls)s_t *list, %(e_type)s_t *obj);
+extern int %(cls)s_append(
+    %(cls)s_t *list, %(e_type)s_t *obj);
+
+/**
+ * Iteration macro for list of type %(cls)s
+ * @param list Pointer to the list being iterated over of
+ * type %(cls)s
+ * @param elt Pointer to an element of type %(e_type)s
+ * @param rv On exiting the loop will have the value OF_ERROR_RANGE.
+ */
+#define %(u_cls)s_ITER(list, elt, rv)  \\
+    for ((rv) = %(cls)s_first((list), (elt));   \\
+         (rv) == OF_ERROR_NONE;   \\
+         (rv) = %(cls)s_next((list), (elt)))
+""" % dict(u_cls=cls.upper(), cls=cls, e_type=e_type))
+
+
+def wire_accessor(m_type, a_type):
+    """
+    Returns the name of the a_type accessor for low level wire buff offset
+    @param m_type The member type
+    @param a_type The accessor type (set or get)
+    """
+    # Strip off _t if present
+    if m_type in of_g.of_base_types:
+        m_type = of_g.of_base_types[m_type]["short_name"]
+    if m_type in of_g.of_mixed_types:
+        m_type = of_g.of_mixed_types[m_type]["short_name"]
+    if m_type[-2:] == "_t":
+        m_type = m_type[:-2]
+    if m_type == "octets":
+        m_type = "octets_data"
+    return "of_wire_buffer_%s_%s" % (m_type, a_type)
+
+def get_len_macro(cls, m_type, version):
+    """
+    Get the length macro for m_type in cls
+    """
+    if m_type.find("of_match") == 0:
+        return "_WIRE_MATCH_PADDED_LEN(obj, offset)"
+    if m_type.find("of_list_oxm") == 0:
+        return "wire_match_len(obj, 0) - 4"
+    if loxi_utils.class_is_tlv16(m_type):
+        return "_TLV16_LEN(obj, offset)"
+    if cls == "of_packet_out" and m_type == "of_list_action_t":
+        return "_PACKET_OUT_ACTION_LEN(obj)"
+    # Default is everything to the end of the object
+    return "_END_LEN(obj, offset)"
+
+def gen_accessor_offsets(out, cls, m_name, version, a_type, m_type, offset):
+    """
+    Generate the sub-object offset and length calculations for accessors
+    @param out File being written
+    @param m_name Name of member
+    @param version Wire version being processed
+    @param a_type The accessor type (set or get)
+    @param m_type The original member type
+    @param offset The offset of the object or -1 if not fixed
+    """
+    # determine offset
+    o_str = "%d" % offset  # Default is fixed length
+    if offset == -1:
+        # There are currently 4 special cases for this
+        # In general, get offset and length of predecessor
+        if (loxi_utils.cls_is_flow_mod(cls) and m_name == "instructions"):
+            pass
+        elif (cls == "of_flow_stats_entry" and m_name == "instructions"):
+            pass
+        elif (cls == "of_packet_in" and m_name == "data"):
+            pass
+        elif (cls == "of_packet_out" and m_name == "data"):
+            pass
+        else:
+            debug("Error: Unknown member with offset == -1")
+            debug("  cls %s, m_name %s, version %d" % (cls, m_name, version))
+            sys.exit(1)
+        o_str = "_%s_%s_OFFSET(obj)" % (cls.upper()[3:], m_name.upper())
+
+    out.write("""\
+        offset = %s;
+""" % o_str);
+
+    # This could be moved to main body but for version check
+    if not loxi_utils.type_is_scalar(m_type):
+        if loxi_utils.class_is_var_len(m_type[:-2], version) or \
+                m_type == "of_match_t":
+            len_macro = get_len_macro(cls, m_type, version)
+        else:
+            len_macro = "%d" % of_g.base_length[(m_type[:-2], version)]
+        out.write("        cur_len = %s;\n" % len_macro)
+    out.write("        break;\n")
+
+def length_of(m_type, version):
+    """
+    Return the length of a type based on the version
+    """
+    if m_type in of_g.of_mixed_types:
+        m_type = of_g.of_mixed_types[m_type][version]
+    if m_type in of_g.of_base_types:
+        return of_g.of_base_types[m_type]["bytes"]
+    if (m_type[:-2], version) in of_g.base_length:
+        return of_g.base_length[(m_type[:-2], version)]
+    print "Unknown length request", m_type, version
+    sys.exit(1)
+        
+
+def gen_get_accessor_body(out, cls, m_type, m_name):
+    """
+    Generate the common operations for a get accessor
+    """
+    if loxi_utils.type_is_scalar(m_type):
+        ver = ""      # See if version required for scalar update
+        if m_type in of_g.of_mixed_types:
+            ver = "ver, "
+        out.write("""\
+    %(wa)s(%(ver)swbuf, abs_offset, %(m_name)s);
+""" % dict(wa=wire_accessor(m_type, "get"), ver=ver, m_name=m_name))
+
+        if m_type == "of_port_no_t":
+           out.write("    OF_PORT_NO_VALUE_CHECK(*%s, ver);\n" % m_name)
+    elif m_type == "of_octets_t":
+        out.write("""\
+    ASSERT(cur_len + abs_offset <= WBUF_CURRENT_BYTES(wbuf));
+    %(m_name)s->bytes = cur_len;
+    %(m_name)s->data = OF_WIRE_BUFFER_INDEX(wbuf, abs_offset);
+""" % dict(m_name=m_name))
+    elif m_type == "of_match_t":
+        out.write("""
+    ASSERT(cur_len + abs_offset <= WBUF_CURRENT_BYTES(wbuf));
+    match_octets.bytes = cur_len;
+    match_octets.data = OF_OBJECT_BUFFER_INDEX(obj, offset);
+    OF_TRY(of_match_deserialize(ver, %(m_name)s, &match_octets));
+""" % dict(m_name=m_name))
+    else:
+        out.write("""
+    /* Initialize child */
+    %(m_type)s_init(%(m_name)s, obj->version, 0, 1);
+    /* Attach to parent */
+    %(m_name)s->parent = (of_object_t *)obj;
+    %(m_name)s->wire_object.wbuf = obj->wire_object.wbuf;
+    %(m_name)s->wire_object.obj_offset = abs_offset;
+    %(m_name)s->wire_object.owned = 0;
+    %(m_name)s->length = cur_len;
+""" % dict(m_type=m_type[:-2], m_name=m_name))
+
+
+def gen_set_accessor_body(out, cls, m_type, m_name):
+    """
+    Generate the contents of a set accessor
+    """
+    if loxi_utils.type_is_scalar(m_type) or m_type == "of_octets_t":
+        ver = "" # See if version required for scalar update
+        if m_type in of_g.of_mixed_types:
+            ver = "ver, "
+        cur_len = "" # See if version required for scalar update
+        if m_type == "of_octets_t":
+            cur_len = ", cur_len"
+            out.write("""\
+    new_len = %(m_name)s->bytes;
+    of_wire_buffer_grow(wbuf, abs_offset + (new_len - cur_len));
+""" % dict(m_name=m_name))
+        out.write("""\
+    %(wa)s(%(ver)swbuf, abs_offset, %(m_name)s%(cur_len)s);
+""" % dict(wa=wire_accessor(m_type, "set"), ver=ver, cur_len=cur_len,
+           m_name=m_name))
+
+    elif m_type == "of_match_t":
+        out.write("""
+    /* Match object */
+    OF_TRY(of_match_serialize(ver, %(m_name)s, &match_octets));
+    new_len = match_octets.bytes;
+    of_wire_buffer_replace_data(wbuf, abs_offset, cur_len,
+        match_octets.data, new_len);
+    /* Free match serialized octets */
+    FREE(match_octets.data);
+""" % dict(m_name=m_name))
+
+    else:  # Other object type
+        out.write("\n    /* LOCI object type */")
+        # Need to special case OXM list
+        out.write("""
+    new_len = %(m_name)s->length;
+    /* If underlying buffer already shared; nothing to do */
+    if (obj->wire_object.wbuf == %(m_name)s->wire_object.wbuf) {
+        of_wire_buffer_grow(wbuf, abs_offset + new_len);
+        /* Verify that the offsets are correct */
+        ASSERT(abs_offset == OF_OBJECT_ABSOLUTE_OFFSET(%(m_name)s, 0));
+        /* ASSERT(new_len == cur_len); */ /* fixme: may fail for OXM lists */
+        return %(ret_success)s;
+    }
+
+    /* Otherwise, replace existing object in data buffer */
+    of_wire_buffer_replace_data(wbuf, abs_offset, cur_len,
+        OF_OBJECT_BUFFER_INDEX(%(m_name)s, 0), new_len);
+""" % dict(m_name=m_name, ret_success=accessor_return_success("set", m_type)))
+
+    if not loxi_utils.type_is_scalar(m_type):
+        if cls == "of_packet_out" and m_type == "of_list_action_t":
+            out.write("""
+    /* Special case for setting action lengths */
+    _PACKET_OUT_ACTION_LEN_SET(obj, %(m_name)s->length);
+""" % dict(m_name=m_name))
+        elif m_type not in ["of_match_t", "of_octets_t"]:
+            out.write("""
+    /* @fixme Shouldn't this precede copying value's data to buffer? */
+    if (%(m_name)s->wire_length_set != NULL) {
+        %(m_name)s->wire_length_set((of_object_t *)%(m_name)s, %(m_name)s->length);
+    }
+""" % dict(m_name=m_name))
+        out.write("""
+    /* Not scalar, update lengths if needed */
+    delta = new_len - cur_len;
+    if (delta != 0) {
+        /* Update parent(s) */
+        of_object_parent_length_update((of_object_t *)obj, delta);
+    }
+""")
+
+def obj_assert_check(cls):
+    """
+    The body of the assert check for an accessor
+    We allow all versions of add/delete/modify to use the same accessors
+    """
+    if cls in ["of_flow_modify", "of_flow_modify_strict",
+               "of_flow_delete", "of_flow_delete_strict",
+               "of_flow_add"]:
+        return "IS_FLOW_MOD_SUBTYPE(obj->object_id)"
+    else:
+        return "obj->object_id == %s" % cls.upper()
+
+def gen_of_object_get(out, cls, m_name, m_type):
+    sub_cls = m_type[:-2]
+    out.write("""
+/**
+ * Create a copy of %(m_name)s into a new variable of type %(m_type)s from 
+ * a %(cls)s instance.
+ *
+ * @param obj Pointer to the source of type %(cls)s_t
+ * @returns A pointer to a new instance of type %(m_type)s whose contents
+ * match that of %(m_name)s from source
+ * @returns NULL if an error occurs
+ */
+%(m_type)s *
+%(cls)s_%(m_name)s_get(%(cls)s_t *obj) {
+    %(m_type)s _%(m_name)s;
+    %(m_type)s *_%(m_name)s_ptr;
+
+    %(cls)s_%(m_name)s_bind(obj, &_%(m_name)s);
+    _%(m_name)s_ptr = (%(m_type)s *)of_object_dup(&_%(m_name)s);
+    return _%(m_name)s_ptr;
+}
+""" % dict(m_name=m_name, m_type=m_type, cls=cls, sub_cls=sub_cls))
+
+def gen_unified_acc_body(out, cls, m_name, ver_type_map, a_type, m_type):
+    """
+    Generate the body of a set or get accessor function
+
+    @param out The file to which to write the decs
+    @param cls The class name
+    @param m_name The member name
+    @param ver_type_map Maps (type, offset) pairs to a list of versions
+    @param a_type The accessor type, set or get
+    @param m_type The original member type
+
+    The type values in ver_type_map are now ignored as we've pushed down
+    the type munging to the lower level.
+
+    This is unified because the version switch case processing is the
+    same for both set and get
+    """
+    out.write("""{
+    of_wire_buffer_t *wbuf;
+    int offset = 0; /* Offset of value relative to the start obj */
+    int abs_offset; /* Offset of value relative to start of wbuf */
+    of_version_t ver;
+""")
+
+    if not loxi_utils.type_is_scalar(m_type):
+        out.write("""\
+    int cur_len = 0; /* Current length of object data */
+""")
+        if a_type == "set":
+            out.write("""\
+    int new_len, delta; /* For set, need new length and delta */
+""")
+
+    # For match, need octet string for set/get
+    if m_type == "of_match_t":
+        out.write("""\
+    of_octets_t match_octets; /* Serialized string for match */
+""")
+
+    out.write("""
+    ASSERT(%(assert_str)s);
+    ver = obj->version;
+    wbuf = OF_OBJECT_TO_WBUF(obj);
+    ASSERT(wbuf != NULL);
+
+    /* By version, determine offset and current length (where needed) */
+    switch (ver) {
+""" % dict(assert_str=obj_assert_check(cls)))
+
+    for first in sorted(ver_type_map):
+        (prev_t, prev_o) = ver_type_map[first]
+        prev_len = length_of(prev_t, first)
+        prev = first
+        out.write("    case %s:\n" % of_g.wire_ver_map[first])
+        break
+
+    for next in sorted(ver_type_map):
+        if next == first:
+            continue
+
+        (t, o) = ver_type_map[next]
+        cur_len = length_of(t, next)
+        if o == prev_o and cur_len == prev_len:
+            out.write("    case %s:\n" % of_g.wire_ver_map[next])
+            continue
+        gen_accessor_offsets(out, cls, m_name, prev, a_type, m_type, prev_o)
+        out.write("    case %s:\n" % of_g.wire_ver_map[next])
+        (prev_t, prev_o, prev_len, prev) = (t, o, cur_len, next)
+
+    gen_accessor_offsets(out, cls, m_name, next, a_type, m_type, prev_o)
+    out.write("""\
+    default:
+        ASSERT(0);
+    }
+
+    abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset);
+    ASSERT(abs_offset >= 0);
+""")
+    if not loxi_utils.type_is_scalar(m_type):
+        out.write("    ASSERT(cur_len >= 0 && cur_len < 64 * 1024);\n")
+
+    # Now generate the common accessor code
+    if a_type in ["get", "bind"]:
+        gen_get_accessor_body(out, cls, m_type, m_name)
+    else:
+        gen_set_accessor_body(out, cls, m_type, m_name)
+
+    out.write("""
+    OF_LENGTH_CHECK_ASSERT(obj);
+
+    return %s;
+}
+""" % accessor_return_success(a_type, m_type))
+
+def gen_of_obj_bind(out, cls, m_name, m_type, ver_type_map):
+    """
+    For generating the bind call for OF sub-objects
+    """
+
+    params = ",\n    ".join(param_list(cls, m_name, "bind"))
+    out.write("""
+/**
+ * Bind an object of type %(m_type)s to the parent of type %(cls)s for
+ * member %(m_name)s
+ * @param obj Pointer to an object of type %(cls)s.
+ * @param %(m_name)s Pointer to the child object of type
+ * %(m_type)s to be filled out.
+ * \ingroup %(cls)s
+ *
+ * The parameter %(m_name)s is filled out to point to the same underlying
+ * wire buffer as its parent.
+ *
+ */
+""" % dict(m_name=m_name, cls=cls, m_type=m_type))
+
+    ret_type = accessor_return_type("bind", m_type)
+    out.write("%s\n%s_%s_bind(\n    %s)\n" % (ret_type, cls, m_name, params))
+    gen_unified_acc_body(out, cls, m_name, ver_type_map, "bind", m_type)
+
+def gen_get_accessor(out, cls, m_name, m_type, ver_type_map):
+    """
+    For generating the get call for non- OF sub-objects
+    """
+    params = ",\n    ".join(param_list(cls, m_name, "get"))
+    out.write("""
+/**
+ * Get %(m_name)s from an object of type %(cls)s.
+ * @param obj Pointer to an object of type %(cls)s.
+ * @param %(m_name)s Pointer to the child object of type
+ * %(m_type)s to be filled out.
+ *
+ */
+""" % dict(m_name=m_name, cls=cls, m_type=m_type))
+
+    ret_type =  accessor_return_type("get", m_type)
+    out.write("%s\n%s_%s_get(\n    %s)\n" % (ret_type, cls, m_name, params))
+    gen_unified_acc_body(out, cls, m_name, ver_type_map, "get", m_type)
+
+def gen_accessor_definitions(out):
+    """
+    Generate the body of each version independent accessor
+
+    @param out The file to which to write the decs
+    """
+
+    out.write("""
+/****************************************************************
+ *
+ * Unified accessor function definitions
+ *
+ ****************************************************************/
+""")
+    for cls in of_g.standard_class_order:
+        if cls in type_maps.inheritance_map:
+            continue
+        out.write("\n/* Unified accessor functions for %s */\n" % cls)
+        if loxi_utils.class_is_list(cls):
+            gen_list_accessors(out, cls)
+            continue
+        out.write("/** \\ingroup %s \n * @{ */\n" % cls)
+        for m_name in of_g.ordered_members[cls]:
+            if m_name in of_g.skip_members:
+                continue
+            m_type = loxi_utils.member_base_type(cls, m_name)
+            ver_type_map = field_ver_get(cls, m_name)
+
+            # Generate get/bind pending on member type
+            # FIXME:  Does this do the right thing for match?
+            if loxi_utils.type_is_of_object(m_type):
+                gen_of_obj_bind(out, cls, m_name, m_type, ver_type_map)
+                gen_of_object_get(out, cls, m_name, m_type)
+            else:
+                gen_get_accessor(out, cls, m_name, m_type, ver_type_map)
+
+            # Now generate set accessor for all objects
+            params = ",\n    ".join(param_list(cls, m_name, "set"))
+            out.write("""
+/**
+ * Set %(m_name)s in an object of type %(cls)s.
+ * @param obj Pointer to an object of type %(cls)s.
+""" % dict(m_name=m_name, cls=cls, m_type=m_type))
+            if loxi_utils.type_is_scalar(m_type) or m_type == "of_octets_t":
+                out.write("""\
+ * @param %(m_name)s The value to write into the object
+ */
+""" % dict(m_name=m_name, cls=cls, m_type=m_type))
+            else:
+                out.write("""\
+ * @param %(m_name)s Pointer to the child of type %(m_type)s.
+ *
+ * If the child's wire buffer is the same as the parent's, then
+ * nothing is done as the changes have already been registered in the
+ * parent.  Otherwise, the data in the child's wire buffer is inserted
+ * into the parent's and the appropriate lengths are updated.
+ */
+""" % dict(m_name=m_name, cls=cls, m_type=m_type))
+            ret_type = accessor_return_type("set", m_type)
+            out.write("%s\n%s_%s_set(\n    %s)\n" % (ret_type, cls, m_name, params))
+            gen_unified_acc_body(out, cls, m_name, ver_type_map, "set", m_type)
+
+        out.write("\n/** @} */\n")
+
+def gen_acc_pointer_typedefs(out):
+    """
+    Generate the function pointer typedefs for in-struct accessors
+    @param out The file to which to write the typedefs
+    """
+
+    out.write("""
+/****************************************************************
+ *
+ * Accessor function pointer typedefs
+ *
+ ****************************************************************/
+
+/*
+ * Generic accessors:
+ *
+ * Many objects have a length represented in the wire buffer
+ * wire_length_get and wire_length_set access these values directly on the
+ * wire.
+ *
+ * Many objects have a length represented in the wire buffer
+ * wire_length_get and wire_length_set access these values directly on the
+ * wire.
+ *
+ * FIXME: TBD if wire_length_set and wire_type_set are required.
+ */
+typedef void (*of_wire_length_get_f)(of_object_t *obj, int *bytes);
+typedef void (*of_wire_length_set_f)(of_object_t *obj, int bytes);
+typedef void (*of_wire_type_get_f)(of_object_t *obj, of_object_id_t *id);
+typedef void (*of_wire_type_set_f)(of_object_t *obj, of_object_id_t id);
+""")
+    # If not using function pointers in classes, don't gen typedefs below
+    if not config_check("gen_fn_ptrs"):
+        return
+
+    # For each class, for each type it uses, generate a typedef
+    for cls in of_g.standard_class_order:
+        if cls in type_maps.inheritance_map:
+            continue
+        out.write("\n/* Accessor function pointer typedefs for %s */\n" % cls)
+        types_done = list()
+        for m_name in of_g.ordered_members[cls]:
+            (m_type, get_rv) = get_acc_rv(cls, m_name)
+            if (m_type, get_rv) in types_done:
+                continue
+            types_done.append((m_type, get_rv))
+            fn = "%s_%s" % (cls, m_type)
+            params = ", ".join(param_list(cls, m_name, "get"))
+            out.write("typedef int (*%s_get_f)(\n    %s);\n" %
+                      (fn, params))
+
+            params = ", ".join(param_list(cls, m_name, "set"))
+            out.write("typedef int (*%s_set_f)(\n    %s);\n" %
+                      (fn, params))
+        if loxi_utils.class_is_list(cls):
+            obj_type = loxi_utils.list_to_entry_type(cls)
+            out.write("""typedef int (*%(cls)s_first_f)(
+    %(cls)s_t *list,
+    %(obj_type)s_t *obj);
+typedef int (*%(cls)s_next_f)(
+    %(cls)s_t *list,
+    %(obj_type)s_t *obj);
+typedef int (*%(cls)s_append_bind_f)(
+    %(cls)s_t *list,
+    %(obj_type)s_t *obj);
+typedef int (*%(cls)s_append_f)(
+    %(cls)s_t *list,
+    %(obj_type)s_t *obj);
+""" % {"cls":cls, "obj_type":obj_type})
+
+#             out.write("""
+# typedef int (*%(cls)s_get_f)(
+#     %(cls)s_t *list,
+#     %(obj_type)s_t *obj, int index);
+# typedef int (*%(cls)s_set_f)(
+#     %(cls)s_t *list,
+#     %(obj_type)s_t *obj, int index);
+# typedef int (*%(cls)s_append_f)(
+#     %(cls)s_t *list,
+#     %(obj_type)s_t *obj, int index);
+# typedef int (*%(cls)s_insert_f)(
+#     %(cls)s_t *list,
+#     %(obj_type)s_t *obj, int index);
+# typedef int (*%(cls)s_remove_f)(
+#     %(cls)s_t *list,
+#     int index);
+# """ % {"cls":cls, "obj_type":obj_type})
+
+################################################################
+#
+# New/Delete Function Definitions
+#
+################################################################
+
+
+################################################################
+# First, some utility functions for new/delete
+################################################################
+
+def del_function_proto(cls):
+    """
+    Return the prototype for the delete operator for the given class
+    @param cls The class name
+    """
+    fn = "void\n"
+    return fn
+
+
+def instantiate_fn_ptrs(cls, ilvl, out):
+    """
+    Generate the C code to instantiate function pointers for a class
+    @param cls The class name
+    @param ilvl The base indentation level
+    @param out The file to which to write the functions
+    """
+    for m_name in of_g.ordered_members[cls]:
+        if m_name in of_g.skip_members:
+            continue
+        out.write(" " * ilvl + "obj->%s_get = %s_%s_get;\n" %
+                  (m_name, cls, m_name))
+        out.write(" " * ilvl + "obj->%s_set = %s_%s_set;\n" %
+                  (m_name, cls, m_name))
+
+################################################################
+# Routines to generate the body of new/delete functions
+################################################################
+
+def gen_init_fn_body(cls, out):
+    """
+    Generate function body for init function
+    @param cls The class name for the function
+    @param out The file to which to write
+    """
+    if cls in type_maps.inheritance_map:
+        param = "obj_p"
+    else:
+        param = "obj"
+
+    out.write("""
+/**
+ * Initialize an object of type %(cls)s.
+ *
+ * @param obj Pointer to the object to initialize
+ * @param version The wire version to use for the object
+ * @param bytes How many bytes in the object
+ * @param clean_wire Boolean: If true, clear the wire object control struct
+ *
+ * If bytes < 0, then the default fixed length is used for the object
+ *
+ * This is a "coerce" function that sets up the pointers for the
+ * accessors properly.  
+ *
+ * If anything other than 0 is passed in for the buffer size, the underlying
+ * wire buffer will have 'grow' called.
+ */
+
+void
+%(cls)s_init(%(cls)s_t *%(param)s,
+    of_version_t version, int bytes, int clean_wire)
+{
+""" % dict(cls=cls, param=param))
+
+    # Use an extra pointer to deal with inheritance classes
+    if cls in type_maps.inheritance_map:
+        out.write("""\
+    %s_header_t *obj;
+
+    obj = &obj_p->header;  /* Need instantiable subclass */
+""" % cls)
+
+    out.write("""
+    ASSERT(of_object_fixed_len[version][%(enum)s] >= 0);
+    if (clean_wire) {
+        MEMSET(obj, 0, sizeof(*obj));
+    }
+    if (bytes < 0) {
+        bytes = of_object_fixed_len[version][%(enum)s];
+    }
+    obj->version = version;
+    obj->length = bytes;
+    obj->object_id = %(enum)s;
+""" % dict(cls=cls, enum=enum_name(cls)))
+    gen_coerce_ops(out, cls)
+
+    out.write("""
+    /* Grow the wire buffer */
+    if (obj->wire_object.wbuf != NULL) {
+        int tot_bytes;
+
+        tot_bytes = bytes + obj->wire_object.obj_offset;
+        of_wire_buffer_grow(obj->wire_object.wbuf, tot_bytes);
+    }
+}
+
+""")
+
+## @fixme This should also be updated once there is a map from
+# class instance to wire length/type accessors
+def gen_wire_push_fn(cls, out):
+    """
+    Generate the calls to push values into the wire buffer
+    """
+    if type_maps.class_is_virtual(cls):
+        print "Push fn gen called for virtual class " + cls
+        return
+
+    out.write("""
+/**
+ * Helper function to push values into the wire buffer
+ */
+static inline int
+%(cls)s_push_wire_values(%(cls)s_t *obj)
+{
+""" % dict(cls=cls))
+
+    if loxi_utils.class_is_message(cls):
+        out.write("""
+    /* Message obj; push version, length and type to wire */
+    of_message_t msg;
+
+    if ((msg = OF_OBJECT_TO_MESSAGE(obj)) != NULL) {
+        of_message_version_set(msg, obj->version);
+        of_message_length_set(msg, obj->length);
+        OF_TRY(of_wire_message_object_id_set(OF_OBJECT_TO_WBUF(obj),
+                 %(name)s));
+    }
+""" % dict(name = enum_name(cls)))
+ 
+        for version in of_g.of_version_range:
+            if type_maps.class_is_extension(cls, version):
+                exp_name = type_maps.extension_to_experimenter_macro_name(cls)
+                subtype = type_maps.extension_message_to_subtype(cls, version)
+                if subtype is None or exp_name is None:
+                    print "Error in mapping extension message"
+                    print cls, version
+                    sys.exit(1)
+                out.write("""
+    if (obj->version == %(version)s) {
+        of_message_experimenter_id_set(OF_OBJECT_TO_MESSAGE(obj),
+                                       %(exp_name)s);
+        of_message_experimenter_subtype_set(OF_OBJECT_TO_MESSAGE(obj),
+                                            %(subtype)s);
+    }
+""" % dict(exp_name=exp_name, version=of_g.wire_ver_map[version],
+           subtype=str(subtype)))
+           
+    else: # Not a message
+        if loxi_utils.class_is_tlv16(cls):
+            out.write("""
+    /* TLV obj; set length and type */
+    of_tlv16_wire_length_set((of_object_t *)obj, obj->length);
+    of_tlv16_wire_object_id_set((of_object_t *)obj,
+           %(enum)s);
+""" % dict(enum=enum_name(cls)))
+            # Some tlv16 types may be extensions requiring more work
+            if cls in ["of_action_bsn_mirror", "of_action_id_bsn_mirror",
+                       "of_action_bsn_set_tunnel_dst", "of_action_id_bsn_set_tunnel_dst",
+                       "of_action_nicira_dec_ttl", "of_action_id_nicira_dec_ttl"]:
+                out.write("""
+    /* Extended TLV obj; Call specific accessor */
+    of_extension_object_id_set(obj, %(enum)s);
+""" % dict(cls=cls, enum=enum_name(cls)))
+                
+
+        if loxi_utils.class_is_oxm(cls):
+            out.write("""\
+    /* OXM obj; set length and type */
+    of_oxm_wire_length_set((of_object_t *)obj, obj->length);
+    of_oxm_wire_object_id_set((of_object_t *)obj, %(enum)s);
+""" % dict(enum=enum_name(cls)))
+        if loxi_utils.class_is_u16_len(cls) or cls == "of_packet_queue":
+            out.write("""
+    obj->wire_length_set((of_object_t *)obj, obj->length);
+""")
+
+        if cls == "of_meter_stats":
+            out.write("""
+    of_meter_stats_wire_length_set((of_object_t *)obj, obj->length);
+""" % dict(enum=enum_name(cls)))
+
+    out.write("""
+    return OF_ERROR_NONE;
+}
+""")
+
+def gen_new_fn_body(cls, out):
+    """
+    Generate function body for new function
+    @param cls The class name for the function
+    @param out The file to which to write
+    """
+
+    out.write("""
+/**
+ * \\defgroup %(cls)s %(cls)s
+ */
+""" % dict(cls=cls))
+
+    if not type_maps.class_is_virtual(cls):
+        gen_wire_push_fn(cls, out)
+
+    out.write("""
+/**
+ * Create a new %(cls)s object
+ *
+ * @param version The wire version to use for the object
+ * @return Pointer to the newly create object or NULL on error
+ *
+ * Initializes the new object with it's default fixed length associating
+ * a new underlying wire buffer.
+ *
+ * Use new_from_message to bind an existing message to a message object,
+ * or a _get function for non-message objects.
+ *
+ * \\ingroup %(cls)s
+ */
+
+%(cls)s_t *
+%(cls)s_new_(of_version_t version)
+{
+    %(cls)s_t *obj;
+    int bytes;
+
+    bytes = of_object_fixed_len[version][%(enum)s];
+
+    /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */
+    if ((obj = (%(cls)s_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
+        return NULL;
+    }
+
+    %(cls)s_init(obj, version, bytes, 0);
+""" % dict(cls=cls, enum=enum_name(cls)))
+    if not type_maps.class_is_virtual(cls):
+        out.write("""
+    if (%(cls)s_push_wire_values(obj) < 0) {
+        FREE(obj);
+        return NULL;
+    }
+""" % dict(cls=cls))
+
+    match_offset = v3_match_offset_get(cls)
+    if match_offset >= 0:
+        # Init length field for match object
+        out.write("""
+    /* Initialize match TLV for 1.2 */
+    /* FIXME: Check 1.3 below */
+    if ((version == OF_VERSION_1_2) || (version == OF_VERSION_1_3)) {
+        of_object_u16_set((of_object_t *)obj, %(match_offset)d + 2, 4);
+    }
+""" % dict(match_offset=match_offset))
+    out.write("""
+    return obj;
+}
+
+#if defined(OF_OBJECT_TRACKING)
+
+/*
+ * Tracking objects.  Call the new function and then record location
+ */
+
+%(cls)s_t *
+%(cls)s_new_tracking(of_version_t version,
+     const char *file, int line)
+{
+    %(cls)s_t *obj;
+
+    obj = %(cls)s_new_(version);
+    of_object_track((of_object_t *)obj, file, line);
+
+    return obj;
+}
+#endif
+""" % dict(cls=cls))
+
+
+def gen_from_message_fn_body(cls, out):
+    """
+    Generate function body for from_message function
+    @param cls The class name for the function
+    @param out The file to which to write
+    """
+    out.write("""
+/**
+ * Create a new %(cls)s object and bind it to an existing message
+ *
+ * @param msg The message to bind the new object to
+ * @return Pointer to the newly create object or NULL on error
+ *
+ * \ingroup %(cls)s
+ */
+
+%(cls)s_t *
+%(cls)s_new_from_message_(of_message_t msg)
+{
+    %(cls)s_t *obj = NULL;
+    of_version_t version;
+    int length;
+
+    if (msg == NULL) return NULL;
+
+    version = of_message_version_get(msg);
+    if (!OF_VERSION_OKAY(version)) return NULL;
+
+    length = of_message_length_get(msg);
+
+    if ((obj = (%(cls)s_t *)of_object_new(-1)) == NULL) {
+        return NULL;
+    }
+
+    %(cls)s_init(obj, version, 0, 0);
+
+    if ((of_object_buffer_bind((of_object_t *)obj, OF_MESSAGE_TO_BUFFER(msg),
+                               length, OF_MESSAGE_FREE_FUNCTION)) < 0) {
+       FREE(obj);
+       return NULL;
+    }
+    obj->length = length;
+    obj->version = version;
+
+    return obj;
+}
+
+#if defined(OF_OBJECT_TRACKING)
+
+/*
+ * Tracking objects.  Call the new function and then record location
+ */
+
+%(cls)s_t *
+%(cls)s_new_from_message_tracking(of_message_t msg,
+    const char *file, int line)
+{
+    %(cls)s_t *obj;
+
+    obj = %(cls)s_new_from_message_(msg);
+    of_object_track((of_object_t *)obj, file, line);
+
+    return obj;
+}
+#endif
+""" % dict(cls=cls))
+
+
+################################################################
+# Now the top level generator functions
+################################################################
+
+def gen_new_function_declarations(out):
+    """
+    Gerenate the header file declarations for new operators for all classes
+    @param out The file to which to write the decs
+    """
+
+    out.write("""
+/****************************************************************
+ *
+ * New operator declarations
+ *
+ * _new: Create a new object for writing; includes init
+ * _new_from_message: Create a new instance of the object and bind the
+ *    message data to the object
+ * _init: Initialize and optionally allocate buffer space for an
+ *    automatic instance
+ *
+ * _new and _from_message require a delete operation to be called
+ * on the object.
+ *
+ ****************************************************************/
+""")
+    out.write("""
+/*
+ * If object tracking is enabled, map "new" and "new from msg"
+ * calls to tracking versions; otherwise, directly to internal
+ * versions of fns which have the same name but end in _.
+ */
+
+#if defined(OF_OBJECT_TRACKING)
+""")
+    for cls in of_g.standard_class_order:
+        out.write("""
+extern %(cls)s_t *
+    %(cls)s_new_tracking(of_version_t version,
+        const char *file, int line);
+#define %(cls)s_new(version) \\
+    %(cls)s_new_tracking(version, \\
+        __FILE__, __LINE__)
+""" % dict(cls=cls))
+        if loxi_utils.class_is_message(cls):
+            out.write("""extern %(cls)s_t *
+    %(cls)s_new_from_message_tracking(of_message_t msg,
+        const char *file, int line);
+#define %(cls)s_new_from_message(msg) \\
+    %(cls)s_new_from_message_tracking(msg, \\
+        __FILE__, __LINE__)
+""" % dict(cls=cls))
+
+    out.write("""
+#else /* No object tracking */
+""")
+    for cls in of_g.standard_class_order:
+        out.write("""
+#define %(cls)s_new(version) \\
+    %(cls)s_new_(version)
+""" % dict(cls=cls))
+        if loxi_utils.class_is_message(cls):
+            out.write("""#define %(cls)s_new_from_message(msg) \\
+    %(cls)s_new_from_message_(msg)
+""" % dict(cls=cls))
+
+    out.write("""
+#endif /* Object tracking */
+""")
+
+    for cls in of_g.standard_class_order:
+        out.write("""
+extern %(cls)s_t *
+    %(cls)s_new_(of_version_t version);
+""" % dict(cls=cls))
+        if loxi_utils.class_is_message(cls):
+            out.write("""extern %(cls)s_t *
+    %(cls)s_new_from_message_(of_message_t msg);
+""" % dict(cls=cls))
+        out.write("""extern void %(cls)s_init(
+    %(cls)s_t *obj, of_version_t version, int bytes, int clean_wire);
+""" % dict(cls=cls))
+
+    out.write("""
+/****************************************************************
+ *
+ * Delete operator static inline definitions.
+ * These are here for type checking purposes only
+ *
+ ****************************************************************/
+""")
+    for cls in of_g.standard_class_order:
+#        if cls in type_maps.inheritance_map:
+#            continue
+        out.write("""
+/**
+ * Delete an object of type %(cls)s_t
+ * @param obj An instance of type %(cls)s_t
+ *
+ * \ingroup %(cls)s
+ */
+static inline void
+%(cls)s_delete(%(cls)s_t *obj) {
+    of_object_delete((of_object_t *)(obj));
+}
+""" % dict(cls=cls))
+
+    out.write("""
+typedef void (*of_object_init_f)(of_object_t *obj, of_version_t version,
+    int bytes, int clean_wire);
+extern of_object_init_f of_object_init_map[];
+""")
+
+    out.write("""
+/****************************************************************
+ *
+ * Function pointer initialization functions
+ * These are part of the "coerce" type casting for objects
+ *
+ ****************************************************************/
+""")
+
+#
+# @fixme Not clear that these should all be set for virtual fns
+#
+# @fixme Clean up.  should have a (language specific) map from class
+# to length and type get/set functions
+#
+
+def gen_coerce_ops(out, cls):
+    out.write("""
+    /* Set up the object's function pointers */
+""")
+
+    if loxi_utils.class_is_message(cls):
+        out.write("""
+    obj->wire_length_get = of_object_message_wire_length_get;
+    obj->wire_length_set = of_object_message_wire_length_set;
+""")
+    else:
+        if loxi_utils.class_is_tlv16(cls):
+            if not (cls in type_maps.inheritance_map): # Don't set for super
+                out.write("""
+    obj->wire_length_set = of_tlv16_wire_length_set;
+    obj->wire_type_set = of_tlv16_wire_object_id_set;\
+""")
+            out.write("""
+    obj->wire_length_get = of_tlv16_wire_length_get;
+""")
+            if loxi_utils.class_is_action(cls):
+                out.write("""
+    obj->wire_type_get = of_action_wire_object_id_get;
+""")
+            if loxi_utils.class_is_action_id(cls):
+                out.write("""
+    obj->wire_type_get = of_action_id_wire_object_id_get;
+""")
+            if loxi_utils.class_is_instruction(cls):
+                out.write("""
+    obj->wire_type_get = of_instruction_wire_object_id_get;
+""")
+            if loxi_utils.class_is_queue_prop(cls):
+                    out.write("""
+    obj->wire_type_get = of_queue_prop_wire_object_id_get;
+""")
+            if loxi_utils.class_is_table_feature_prop(cls):
+                    out.write("""
+    obj->wire_type_get = of_table_feature_prop_wire_object_id_get;
+""")
+            if loxi_utils.class_is_meter_band(cls):
+                    out.write("""
+    obj->wire_type_get = of_meter_band_wire_object_id_get;
+""")
+            if loxi_utils.class_is_hello_elem(cls):
+                    out.write("""
+    obj->wire_type_get = of_hello_elem_wire_object_id_get;
+""")
+        if loxi_utils.class_is_oxm(cls):
+            out.write("""
+    obj->wire_length_get = of_oxm_wire_length_get;
+    obj->wire_length_set = of_oxm_wire_length_set;
+    obj->wire_type_get = of_oxm_wire_object_id_get;
+    obj->wire_type_set = of_oxm_wire_object_id_set;
+""")
+        if loxi_utils.class_is_u16_len(cls):
+            out.write("""
+    obj->wire_length_get = of_u16_len_wire_length_get;
+    obj->wire_length_set = of_u16_len_wire_length_set;
+""")
+        if cls == "of_packet_queue":
+            out.write("""
+    obj->wire_length_get = of_packet_queue_wire_length_get;
+    obj->wire_length_set = of_packet_queue_wire_length_set;
+""")
+#        if cls == "of_list_meter_band_stats":
+#            out.write("""
+#    obj->wire_length_get = of_list_meter_band_stats_wire_length_get;
+#""")
+        if cls == "of_meter_stats":
+            out.write("""
+    obj->wire_length_get = of_meter_stats_wire_length_get;
+    obj->wire_length_set = of_meter_stats_wire_length_set;
+""")
+
+    if config_check("gen_fn_ptrs"):
+        if loxi_utils.class_is_list(cls):
+            out.write("""
+    obj->first = %(cls)s_first;
+    obj->next = %(cls)s_next;
+    obj->append = %(cls)s_append;
+    obj->append_bind = %(cls)s_append_bind;
+""" % dict(cls=cls))
+        else:
+            instantiate_fn_ptrs(cls, 4, out)
+
+def gen_new_function_definitions(out):
+    """
+    Generate the new operator for all classes
+
+    @param out The file to which to write the functions
+    """
+
+    out.write("\n/* New operators for each message class */\n")
+    for cls in of_g.standard_class_order:
+        out.write("\n/* New operators for %s */\n" % cls)
+        gen_new_fn_body(cls, out)
+        gen_init_fn_body(cls, out)
+        if loxi_utils.class_is_message(cls):
+            gen_from_message_fn_body(cls, out)
+
+def gen_init_map(out):
+    """
+    Generate map from object ID to type coerce function
+    """
+    out.write("""
+/**
+ * Map from object ID to type coerce function
+ */
+of_object_init_f of_object_init_map[] = {
+    (of_object_init_f)NULL,
+""")
+    count = 1
+    for i, cls in enumerate(of_g.standard_class_order):
+        if count != of_g.unified[cls]["object_id"]:
+            print "Error in class mapping: object IDs not sequential"
+            print cls, count, of_g.unified[cls]["object_id"]
+            sys.exit(1)
+        s = "(of_object_init_f)%s_init" % cls
+        if cls in type_maps.inheritance_map:
+            s = "(of_object_init_f)%s_header_init" % cls
+        if i < len(of_g.standard_class_order) - 1:
+            s += ","
+        out.write("    %-65s /* %d */\n" % (s, count))
+        count += 1
+    out.write("};\n")
+
+"""
+Document generation functions
+
+The main reason this is here is to generate documentation per
+accessor that indicates the versions that support the interface.
+"""
+
+
+def gen_accessor_doc(out, name):
+    """
+    Generate documentation for each accessor function that indicates
+    the versions supporting the accessor.
+    """
+
+    common_top_matter(out, name)
+
+    out.write("/* DOCUMENTATION ONLY */\n")
+
+    for cls in of_g.standard_class_order:
+        if cls in type_maps.inheritance_map:
+            pass # Check this
+
+        out.write("""
+/**
+ * Structure for %(cls)s object.  Get/set 
+ * accessors available in all versions unless noted otherwise
+ *
+""" % dict(cls=cls))
+        if loxi_utils.class_is_list(cls):
+            out.write("""\
+ * @param first Function of type %(cls)s_first_f.
+ * Setup a TBD class object to the first entry in the list
+ * @param next Function of type %(cls)s_next_f.
+ * Advance a TBD class object to the next entry in the list
+ * @param append_bind Function of type %(cls)s_append_bind_f
+ * Setup a TBD class object for append to the end of the current list
+ * @param append  Function of type @ref %(cls)s_append_f.
+ * Copy an item to the end of a list
+""" % dict(cls=cls))
+
+        for m_name in of_g.ordered_members[cls]:
+            if m_name in of_g.skip_members:
+                continue
+            ver_type_map = field_ver_get(cls, m_name)
+            (m_type, get_rv) = get_acc_rv(cls, m_name)
+            if len(ver_type_map) == 3:
+                # ver_string = "Available in all versions"
+                ver_string = ""
+            else:
+                ver_string = "("
+                for ver in sorted(ver_type_map):
+                    ver_string += " " + of_g.short_version_names[ver]
+                ver_string += ")."
+
+            f_name = acc_name(cls, m_name)
+            out.write("""\
+ * @param %(m_name)s_get/set %(ver_string)s
+ *   Accessors for %(m_name)s, a variable of type %(m_type)s.  Functions
+ *   are of type %(f_name)s_get_f and _set_f.
+ *
+""" % dict(f_name=f_name, m_name=m_name, ver_string=ver_string, m_type=m_type))
+
+        out.write("""\
+ */
+typedef struct %(cls)s_s %(cls)s_t;
+""" % dict(cls=cls))
+
+    out.write("#endif /* _LOCI_DOC_H_ */\n")
+
+################################################################
+#
+# For fun, here are some unified, traditional C structure representation
+#
+################################################################
+
+def gen_cof_to_wire(out):
+    pass
+
+def gen_wire_to_cof(out):
+    pass
+
+def gen_cof_instance(out, cls):
+    out.write("struct c%s_s {\n" % cls)
+    for m in of_g.ordered_members[cls]:
+        if m in of_g.skip_members:
+            continue
+        entry = of_g.unified[cls]["union"][m]
+        cof_type = type_to_cof_type(entry["m_type"])
+        out.write("    %-20s %s;\n" % (cof_type, m))
+    out.write("};\n\n");
+
+def gen_cof_structs(out):
+    """
+    Generate non-version specific (common) representation of structures
+
+    @param out The file to which to write the functions
+    """
+
+    out.write("\n/* Common, unified OpenFlow structure representations */\n")
+    for cls in of_g.standard_class_order:
+        if cls in type_maps.inheritance_map:
+            continue
+        gen_cof_instance(out, cls)
+
+################################################################
+#
+# Generate code samples for applications.
+#
+################################################################
+
+def gen_code_samples(out, name):
+    out.write("""
+#if 0 /* Do not compile in */
+/**
+ * @file %(name)s
+ *
+ * These are code samples for inclusion in other components
+ */
+
+""" % dict(name=name))
+
+    gen_jump_table_template(out)
+    # These are messages that a switch might expect.
+    msg_list = ["of_echo_request",
+                "of_hello",
+                "of_packet_in",
+                "of_packet_out",
+                "of_port_mod",
+                "of_port_stats_request",
+                "of_queue_get_config_request",
+                "of_queue_stats_request",
+                "of_flow_add",
+                "of_flow_modify",
+                "of_flow_modify_strict",
+                "of_flow_delete",
+                "of_flow_delete_strict",
+                "of_get_config_request",
+                "of_flow_stats_request",
+                "of_barrier_request",
+                "of_echo_reply",
+                "of_aggregate_stats_request",
+                "of_desc_stats_request",
+                "of_table_stats_request",
+                "of_features_request",
+                "of_table_mod",
+                "of_set_config",
+                "of_experimenter",
+                "of_experimenter_stats_request",
+                "of_group_desc_stats_request",
+                "of_group_features_stats_request",
+                "of_role_request"]
+
+    gen_message_handler_templates(out, msgs=msg_list)
+
+    out.write("""
+#endif
+""")
+
+def gen_jump_table_template(out=sys.stdout, all_unhandled=True,
+                            cxn_type="ls_cxn_handle_t", 
+                            unhandled="unhandled_message"):
+    """
+    Generate a template for a jump table.
+    @param out The file to which to write the functions
+    """
+    out.write("""
+/*
+ * Simple jump table definition for message handling
+ */
+typedef int (*msg_handler_f)(%(cxn_type)s cxn, of_object_t *obj);
+typedef msg_handler_f msg_jump_table_t[OF_MESSAGE_OBJECT_COUNT];
+
+/* Jump table template for message objects */
+extern msg_jump_table_t jump_table;
+
+/* C-code template */
+msg_jump_table_t jump_table = {
+    %(unhandled)s, /* OF_OBJECT; place holder for generic object  */
+""" % dict(unhandled=unhandled, cxn_type=cxn_type))
+    count = 0
+    fn_name = unhandled
+    for cls in of_g.ordered_messages:
+        comma = ","
+        count += 1
+        if count == len(of_g.ordered_messages):
+            comma = " "
+        if not all_unhandled:
+            fn_name = "%s_handler" % cls[3:]
+        out.write("    %s%s /* %s */\n" % (fn_name, comma, enum_name(cls)))
+            
+    out.write("};\n")
+
+def gen_message_switch_stmt_tmeplate(out=sys.stdout, all_unhandled=True,
+                                     cxn_type="ls_cxn_handle_t", 
+                                     unhandled="unhandled_message"):
+    out.write("""
+/*
+ * Simple switch statement for message handling
+ */
+
+    switch (obj->object_id):
+""")
+    fn_name = unhandled
+    for cls in of_g.ordered_messages:
+        if not all_unhandled:
+            fn_name = "%s_handler" % cls[3:]
+        out.write("""
+    case %(enum)s:
+        rv = %(fn_name)s(cxn, obj);
+        break;
+""" % dict(fn_name=fn_name, cls=cls, enum=enum_name(cls)))
+    out.write("""
+    default:
+        rv = LS_ERROR_PARAM;
+        break;
+    }
+
+    TRACE("Handled msg %p with rv %d (%s)", obj, rv, ls_error_strings[rv]);
+
+    return rv;
+""")
+
+
+def gen_message_handler_templates(out=sys.stdout, cxn_type="ls_cxn_handle_t",
+                                  unhandled="unhandled_message", msgs=None):
+    gen_jump_table_template(out, False, cxn_type)
+    out.write("""
+/**
+ * Function for unhandled message
+ */
+static int
+unhandled_message(%(cxn_type)s cxn, of_object_t *obj)
+{
+    (void)cxn;
+    (void)obj;
+    TRACE("Unhandled message %%p.  Object id %%d", obj, obj->object_id);
+
+    return LS_ERROR_UNAVAIL;
+}
+""" % dict(unhandled=unhandled, cxn_type=cxn_type))
+
+    if not msgs:
+        msgs = of_g.ordered_messages
+    for cls in msgs:
+        out.write("""
+/**
+ * Handle a %(s_cls)s message
+ * @param cxn Connection handler for the owning connection
+ * @param _obj Generic type object for the message to be coerced
+ * @returns Error code
+ */
+
+static int
+%(s_cls)s_handler(%(cxn_type)s cxn, of_object_t *_obj)
+{
+    %(cls)s_t *obj;
+
+    TRACE("Handling %(cls)s message: %%p.", obj);
+    obj = (%(cls)s_t *)_obj;
+
+    /* Handle object of type %(cls)s_t */
+
+    return LS_ERROR_NONE;
+}
+""" % dict(s_cls=cls[3:], cls=cls, cxn_type=cxn_type))
+    gen_message_switch_stmt_tmeplate(out, False, cxn_type)
+
+def gen_setup_from_add_fns(out):
+    """
+    Generate functions that setup up objects based on an add
+
+    Okay, this is getting out of hand.  We need to refactor the code
+    so that this can be done without so much pain.
+    """
+    out.write("""
+
+/* Flow stats entry setup for all versions */
+
+static int
+flow_stats_entry_setup_from_flow_add_common(of_flow_stats_entry_t *obj,
+                                            of_flow_add_t *flow_add,
+                                            of_object_t *effects,
+                                            int entry_match_offset,
+                                            int add_match_offset)
+{
+    of_list_action_t actions;
+    int entry_len, add_len;
+    of_wire_buffer_t *wbuf;
+    int abs_offset;
+    int delta;
+    uint16_t val16;
+    uint64_t cookie;
+    of_octets_t match_octets;
+
+    /* Effects may come from different places */
+    if (effects != NULL) {
+        OF_TRY(of_flow_stats_entry_actions_set(obj,
+               (of_list_action_t *)effects));
+    } else {
+        of_flow_add_actions_bind(flow_add, &actions);
+        OF_TRY(of_flow_stats_entry_actions_set(obj, &actions));
+    }
+
+    /* Transfer the match underlying object from add to stats entry */
+    wbuf = OF_OBJECT_TO_WBUF(obj);
+    entry_len = _WIRE_MATCH_PADDED_LEN(obj, entry_match_offset);
+    add_len = _WIRE_MATCH_PADDED_LEN(flow_add, add_match_offset);
+
+    match_octets.bytes = add_len;
+    match_octets.data = OF_OBJECT_BUFFER_INDEX(flow_add, add_match_offset);
+
+    /* Copy data into flow entry */
+    abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, entry_match_offset);
+    of_wire_buffer_replace_data(wbuf, abs_offset, entry_len,
+                                match_octets.data, add_len);
+
+    /* Not scalar, update lengths if needed */
+    delta = add_len - entry_len;
+    if (delta != 0) {
+        /* Update parent(s) */
+        of_object_parent_length_update((of_object_t *)obj, delta);
+    }
+
+    of_flow_add_cookie_get(flow_add, &cookie);
+    of_flow_stats_entry_cookie_set(obj, cookie);
+
+    of_flow_add_priority_get(flow_add, &val16);
+    of_flow_stats_entry_priority_set(obj, val16);
+
+    of_flow_add_idle_timeout_get(flow_add, &val16);
+    of_flow_stats_entry_idle_timeout_set(obj, val16);
+
+    of_flow_add_hard_timeout_get(flow_add, &val16);
+    of_flow_stats_entry_hard_timeout_set(obj, val16);
+
+    return OF_ERROR_NONE;
+}
+
+/* Flow removed setup for all versions */
+
+static int
+flow_removed_setup_from_flow_add_common(of_flow_removed_t *obj,
+                                        of_flow_add_t *flow_add,
+                                        int removed_match_offset,
+                                        int add_match_offset)
+{
+    int add_len, removed_len;
+    of_wire_buffer_t *wbuf;
+    int abs_offset;
+    int delta;
+    uint16_t val16;
+    uint64_t cookie;
+    of_octets_t match_octets;
+
+    /* Transfer the match underlying object from add to removed obj */
+    wbuf = OF_OBJECT_TO_WBUF(obj);
+    removed_len = _WIRE_MATCH_PADDED_LEN(obj, removed_match_offset);
+    add_len = _WIRE_MATCH_PADDED_LEN(flow_add, add_match_offset);
+
+    match_octets.bytes = add_len;
+    match_octets.data = OF_OBJECT_BUFFER_INDEX(flow_add, add_match_offset);
+
+    /* Copy data into flow removed */
+    abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, removed_match_offset);
+    of_wire_buffer_replace_data(wbuf, abs_offset, removed_len,
+                                match_octets.data, add_len);
+
+    /* Not scalar, update lengths if needed */
+    delta = add_len - removed_len;
+    if (delta != 0) {
+        /* Update parent(s) */
+        of_object_parent_length_update((of_object_t *)obj, delta);
+    }
+
+    of_flow_add_cookie_get(flow_add, &cookie);
+    of_flow_removed_cookie_set(obj, cookie);
+
+    of_flow_add_priority_get(flow_add, &val16);
+    of_flow_removed_priority_set(obj, val16);
+
+    of_flow_add_idle_timeout_get(flow_add, &val16);
+    of_flow_removed_idle_timeout_set(obj, val16);
+ 
+    if (obj->version >= OF_VERSION_1_2) {
+        of_flow_add_hard_timeout_get(flow_add, &val16);
+        of_flow_removed_hard_timeout_set(obj, val16);
+    }
+
+    return OF_ERROR_NONE;
+}
+
+/* Set up a flow removed message from the original add */
+
+int
+of_flow_removed_setup_from_flow_add(of_flow_removed_t *obj,
+                                    of_flow_add_t *flow_add)
+{
+    switch (obj->version) {
+    case OF_VERSION_1_0:
+        return flow_removed_setup_from_flow_add_common(obj, flow_add, 
+                                                       8, 8);
+        break;
+    case OF_VERSION_1_1:
+    case OF_VERSION_1_2:
+    case OF_VERSION_1_3:
+        return flow_removed_setup_from_flow_add_common(obj, flow_add, 
+                                                       48, 48);
+        break;
+    default:
+        return OF_ERROR_VERSION;
+        break;
+    }
+
+    return OF_ERROR_NONE;
+}
+
+
+/* Set up a packet in message from the original add */
+
+int
+of_packet_in_setup_from_flow_add(of_packet_in_t *obj,
+                                 of_flow_add_t *flow_add)
+{
+    int add_len, pkt_in_len;
+    of_wire_buffer_t *wbuf;
+    int abs_offset;
+    int delta;
+    const int pkt_in_match_offset = 16;
+    const int add_match_offset = 48;
+    of_octets_t match_octets;
+
+    if (obj->version < OF_VERSION_1_2) {
+        /* Nothing to be done before OF 1.2 */
+        return OF_ERROR_NONE;
+    }
+
+    /* Transfer match struct from flow add to packet in object */
+    wbuf = OF_OBJECT_TO_WBUF(obj);
+    pkt_in_len = _WIRE_MATCH_PADDED_LEN(obj, pkt_in_match_offset);
+    add_len = _WIRE_MATCH_PADDED_LEN(flow_add, add_match_offset);
+
+    match_octets.bytes = add_len;
+    match_octets.data = OF_OBJECT_BUFFER_INDEX(flow_add, add_match_offset);
+
+    /* Copy data into pkt_in msg */
+    abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, pkt_in_match_offset);
+    of_wire_buffer_replace_data(wbuf, abs_offset, pkt_in_len,
+                                match_octets.data, add_len);
+
+    /* Not scalar, update lengths if needed */
+    delta = add_len - pkt_in_len;
+    if (delta != 0) {
+        /* Update parent(s) */
+        of_object_parent_length_update((of_object_t *)obj, delta);
+    }
+
+    return OF_ERROR_NONE;
+}
+
+/* Set up a stats entry from the original add */
+
+int
+of_flow_stats_entry_setup_from_flow_add(of_flow_stats_entry_t *obj,
+                                        of_flow_add_t *flow_add,
+                                        of_object_t *effects)
+{
+    switch (obj->version) {
+    case OF_VERSION_1_0:
+        return flow_stats_entry_setup_from_flow_add_common(obj, flow_add,
+                                                           effects, 4, 8);
+        break;
+    case OF_VERSION_1_1:
+    case OF_VERSION_1_2:
+    case OF_VERSION_1_3:
+        return flow_stats_entry_setup_from_flow_add_common(obj, flow_add, 
+                                                           effects, 48, 48);
+        break;
+    default:
+        return OF_ERROR_VERSION;
+    }
+
+    return OF_ERROR_NONE;
+}
+""")
diff --git a/c_gen/c_dump_gen.py b/c_gen/c_dump_gen.py
new file mode 100644
index 0000000..dbf1e7a
--- /dev/null
+++ b/c_gen/c_dump_gen.py
@@ -0,0 +1,270 @@
+# Copyright 2013, Big Switch Networks, Inc.
+#
+# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+# the following special exception:
+#
+# LOXI Exception
+#
+# As a special exception to the terms of the EPL, you may distribute libraries
+# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+# that copyright and licensing notices generated by LoxiGen are not altered or removed
+# from the LoxiGen Libraries and the notice provided below is (i) included in
+# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+# documentation for the LoxiGen Libraries, if distributed in binary form.
+#
+# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+#
+# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+# a copy of the EPL at:
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# 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
+# EPL for the specific language governing permissions and limitations
+# under the EPL.
+
+"""
+@brief Dump function generation
+
+Generates dump function files.
+
+"""
+
+import sys
+import of_g
+import loxi_front_end.match as match
+import loxi_front_end.flags as flags
+from generic_utils import *
+import loxi_front_end.type_maps as type_maps
+import loxi_utils.loxi_utils as loxi_utils
+import loxi_front_end.identifiers as identifiers
+from c_test_gen import var_name_map
+
+def gen_obj_dump_h(out, name):
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""
+/**
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ *
+ * Header file for object dumping. 
+ */
+
+/**
+ * Dump  object declarations
+ *
+ * Routines that emit a dump of each object.
+ *
+ */
+
+#if !defined(_LOCI_OBJ_DUMP_H_)
+#define _LOCI_OBJ_DUMP_H_
+
+#include <loci/loci.h>
+#include <stdio.h>
+
+/* g++ requires this to pick up PRI, etc.
+ * See  http://gcc.gnu.org/ml/gcc-help/2006-10/msg00223.html
+ */
+#if !defined(__STDC_FORMAT_MACROS)
+#define __STDC_FORMAT_MACROS
+#endif
+#include <inttypes.h>
+
+
+/**
+ * Dump any OF object. 
+ */
+int of_object_dump(loci_writer_f writer, void* cookie, of_object_t* obj); 
+
+
+
+
+
+
+""")
+
+    type_to_emitter = dict(
+
+        )
+    for version in of_g.of_version_range:
+        for cls in of_g.standard_class_order:
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            if cls in type_maps.inheritance_map:
+                continue
+            out.write("""\
+int %(cls)s_%(ver_name)s_dump(loci_writer_f writer, void* cookie, %(cls)s_t *obj);
+""" % dict(cls=cls, ver_name=loxi_utils.version_to_name(version)))
+
+    out.write("""
+#endif /* _LOCI_OBJ_DUMP_H_ */
+""")
+
+def gen_obj_dump_c(out, name):
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""
+/**
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ *
+ * Source file for object dumping. 
+ * 
+ */
+
+#define DISABLE_WARN_UNUSED_RESULT
+#include <loci/loci.h>
+#include <loci/loci_dump.h>
+#include <loci/loci_obj_dump.h>
+
+static int
+unknown_dump(loci_writer_f writer, void* cookie, of_object_t *obj)
+{
+    return writer(cookie, "Unable to print object of type %d, version %d\\n", 
+                         obj->object_id, obj->version);
+}    
+""")
+
+    for version in of_g.of_version_range:
+        ver_name = loxi_utils.version_to_name(version)
+        for cls in of_g.standard_class_order:
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            if cls in type_maps.inheritance_map:
+                continue
+            out.write("""
+int
+%(cls)s_%(ver_name)s_dump(loci_writer_f writer, void* cookie, %(cls)s_t *obj)
+{
+    int out = 0;
+""" % dict(cls=cls, ver_name=ver_name))
+
+            members, member_types = loxi_utils.all_member_types_get(cls, version)
+            for m_type in member_types:
+                if loxi_utils.type_is_scalar(m_type) or m_type in \
+                        ["of_match_t", "of_octets_t"]:
+                    # Declare instance of these
+                    out.write("    %s %s;\n" % (m_type, var_name_map(m_type)))
+                else:
+                    out.write("""
+    %(m_type)s %(v_name)s;
+"""  % dict(m_type=m_type, v_name=var_name_map(m_type)))
+                    if loxi_utils.class_is_list(m_type):
+                        base_type = loxi_utils.list_to_entry_type(m_type)
+                        out.write("    %s elt;\n    int rv;\n" % base_type)
+            out.write("""
+    out += writer(cookie, "Object of type %(cls)s\\n");
+""" % dict(cls=cls))
+            for member in members:
+                m_type = member["m_type"]
+                m_name = member["name"]
+                emitter = "LOCI_DUMP_" + loxi_utils.type_to_short_name(m_type)
+                if loxi_utils.skip_member_name(m_name):
+                    continue
+                if (loxi_utils.type_is_scalar(m_type) or
+                    m_type in ["of_match_t", "of_octets_t"]):
+                    out.write("""
+    %(cls)s_%(m_name)s_get(obj, &%(v_name)s);
+    out += writer(cookie, "  %(m_name)s (%(m_type)s):  ");
+    out += %(emitter)s(writer, cookie, %(v_name)s);
+    out += writer(cookie, "\\n");
+""" % dict(cls=cls, m_name=m_name, m_type=m_type,
+           v_name=var_name_map(m_type), emitter=emitter))
+                elif loxi_utils.class_is_list(m_type):
+                    sub_cls = m_type[:-2] # Trim _t
+                    elt_type = loxi_utils.list_to_entry_type(m_type)
+                    out.write("""
+    out += writer(cookie, "List of %(elt_type)s\\n");
+    %(cls)s_%(m_name)s_bind(obj, &%(v_name)s);
+    %(u_type)s_ITER(&%(v_name)s, &elt, rv) {
+        of_object_dump(writer, cookie, (of_object_t *)&elt);
+    }
+""" % dict(sub_cls=sub_cls, u_type=sub_cls.upper(), v_name=var_name_map(m_type),
+           elt_type=elt_type, cls=cls, m_name=m_name, m_type=m_type))
+                else:
+                    sub_cls = m_type[:-2] # Trim _t
+                    out.write("""
+    %(cls)s_%(m_name)s_bind(obj, &%(v_name)s);
+    out += %(sub_cls)s_%(ver_name)s_dump(writer, cookie, &%(v_name)s);
+""" % dict(cls=cls, sub_cls=sub_cls, m_name=m_name, 
+           v_name=var_name_map(m_type), ver_name=ver_name))
+
+            out.write("""
+    return out;
+}
+""")
+    out.write("""
+/**
+ * Log a match entry
+ */
+int
+loci_dump_match(loci_writer_f writer, void* cookie, of_match_t *match)
+{
+    int out = 0;
+
+    out += writer(cookie, "Match obj, version %d.\\n", match->version);
+""")
+
+    for key, entry in match.of_match_members.items():
+        m_type = entry["m_type"]
+        emitter = "LOCI_DUMP_" + loxi_utils.type_to_short_name(m_type)
+        out.write("""
+    if (OF_MATCH_MASK_%(ku)s_ACTIVE_TEST(match)) {
+        out += writer(cookie, "  %(key)s (%(m_type)s) active: Value ");
+        out += %(emitter)s(writer, cookie, match->fields.%(key)s);
+        out += writer(cookie, "\\n    Mask ");
+        out += %(emitter)s(writer, cookie, match->masks.%(key)s);
+        out += writer(cookie, "\\n");
+    }
+""" % dict(key=key, ku=key.upper(), emitter=emitter, m_type=m_type))
+
+    out.write("""
+    return out;
+}
+""")
+
+    # Generate big table indexed by version and object
+    for version in of_g.of_version_range:
+        out.write("""
+static loci_obj_dump_f dump_funs_v%(version)s[OF_OBJECT_COUNT] = {
+""" % dict(version=version))
+        out.write("    unknown_dump, /* of_object, not a valid specific type */\n")
+        for j, cls in enumerate(of_g.all_class_order):
+            comma = ""
+            if j < len(of_g.all_class_order) - 1: # Avoid ultimate comma
+                comma = ","
+
+            if (not loxi_utils.class_in_version(cls, version) or 
+                    cls in type_maps.inheritance_map):
+                out.write("    unknown_dump%s\n" % comma);
+            else:
+                out.write("    %s_%s_dump%s\n" % 
+                          (cls, loxi_utils.version_to_name(version), comma))
+        out.write("};\n\n")
+
+    out.write("""
+static loci_obj_dump_f *dump_funs[5] = {
+    NULL,
+    dump_funs_v1,
+    dump_funs_v2,
+    dump_funs_v3,
+    dump_funs_v4
+};
+
+int
+of_object_dump(loci_writer_f writer, void* cookie, of_object_t *obj)
+{
+    if ((obj->object_id > 0) && (obj->object_id < OF_OBJECT_COUNT)) {
+        if (((obj)->version > 0) && ((obj)->version <= OF_VERSION_1_2)) {
+            /* @fixme VERSION */
+            return dump_funs[obj->version][obj->object_id](writer, cookie, (of_object_t *)obj);
+        } else {
+            return writer(cookie, "Bad version %d\\n", obj->version);
+        }
+    }
+    return writer(cookie, "Bad object id %d\\n", obj->object_id);
+}
+""")
+
diff --git a/c_gen/c_match.py b/c_gen/c_match.py
new file mode 100644
index 0000000..1b5be1e
--- /dev/null
+++ b/c_gen/c_match.py
@@ -0,0 +1,1317 @@
+# Copyright 2013, Big Switch Networks, Inc.
+#
+# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+# the following special exception:
+#
+# LOXI Exception
+#
+# As a special exception to the terms of the EPL, you may distribute libraries
+# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+# that copyright and licensing notices generated by LoxiGen are not altered or removed
+# from the LoxiGen Libraries and the notice provided below is (i) included in
+# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+# documentation for the LoxiGen Libraries, if distributed in binary form.
+#
+# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+#
+# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+# a copy of the EPL at:
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# 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
+# EPL for the specific language governing permissions and limitations
+# under the EPL.
+
+# @brief Generate wire to generic match conversion functions
+#
+# @fixme This has lots of C specific code that should be moved into c_gen
+
+# of_match_to_wire_match(match, wire_match)
+# of_wire_match_to_match(wire_match, match)
+#    Version is taken from the source in each case
+#
+# name
+# type
+# conditions
+# v3 ident
+# takes mask
+
+import sys
+import of_g
+import loxi_front_end.oxm as oxm
+import loxi_front_end.match as match
+import c_code_gen
+
+def match_c_top_matter(out, name):
+    """
+    Generate top matter for match C file
+
+    @param name The name of the output file
+    @param out The output file object
+    """
+    c_code_gen.common_top_matter(out, name)
+    out.write("#include \"loci_log.h\"\n")
+    out.write("#include <loci/loci.h>\n")
+
+def match_h_top_matter(out, name):
+    """
+    Generate top matter for the C file
+
+    @param name The name of the output file
+    @param ih_name The name of the internal header file
+    @param out The output file object
+    """
+    c_code_gen.common_top_matter(out, name)
+    out.write("""
+#include <loci/loci_base.h>
+""")
+
+def gen_declarations(out):
+    out.write("""
+/*
+ * Match serialize/deserialize declarations
+ * Wire match conversion function declarations
+ */
+extern int of_match_serialize(of_version_t version, of_match_t *match,
+                              of_octets_t *octets);
+extern int of_match_deserialize(of_version_t version, of_match_t *match,
+                                of_octets_t *octets);
+extern int of_match_v1_to_match(of_match_v1_t *src, of_match_t *dst);
+extern int of_match_v2_to_match(of_match_v2_t *src, of_match_t *dst);
+extern int of_match_v3_to_match(of_match_v3_t *src, of_match_t *dst);
+extern int of_match_to_wire_match_v1(of_match_t *src, of_match_v1_t *dst);
+extern int of_match_to_wire_match_v2(of_match_t *src, of_match_v2_t *dst);
+extern int of_match_to_wire_match_v3(of_match_t *src, of_match_v3_t *dst);
+""")
+
+def gen_v4_match_compat(out):
+    """
+    Code for coercing version 1.3 matches to 1.2 matches
+
+    @FIXME This is a stopgap and needs to get cleaned up.
+    """
+    out.write("""
+/**
+ * Definitions to coerce v4 match (version 1.3) to v3 matches
+ * (version 1.2).
+ * @FIXME This is a stopgap and needs to get cleaned up.
+ */
+#define of_match_v4_t of_match_v3_t
+#define of_match_v4_init of_match_v3_init
+#define of_match_v4_new of_match_v3_new
+#define of_match_v4_to_match of_match_v3_to_match
+#define of_match_to_wire_match_v4 of_match_to_wire_match_v3
+#define of_match_v4_delete of_match_v3_delete
+""")
+
+def gen_match_macros(out):
+    out.write("""
+
+/**
+ * Definitions for wildcard macros for OF_VERSION_1_0
+ */
+
+""")
+    for key in match.of_v1_keys:
+        entry = match.of_match_members[key]
+        if "v1_wc_shift" in entry:
+            if key in ["ipv4_src", "ipv4_dst"]:
+                out.write("""
+#define OF_MATCH_V1_WC_%(ku)s_SHIFT %(val)d
+#define OF_MATCH_V1_WC_%(ku)s_MASK (0x3f << %(val)d)
+#define OF_MATCH_V1_WC_%(ku)s_CLEAR(wc) ((wc) &= ~(0x3f << %(val)d))
+#define OF_MATCH_V1_WC_%(ku)s_SET(wc, value) do {   \\
+        OF_MATCH_V1_WC_%(ku)s_CLEAR(wc); \\
+        ((wc) |= (((value) & 0x3f) << %(val)d)); \\
+    } while (0)
+#define OF_MATCH_V1_WC_%(ku)s_TEST(wc) ((wc) & (0x3f << %(val)d))
+#define OF_MATCH_V1_WC_%(ku)s_GET(wc) (((wc) >> %(val)d) & 0x3f)
+""" % dict(ku=key.upper(), val=entry["v1_wc_shift"]))
+            else:
+                out.write("""
+#define OF_MATCH_V1_WC_%(ku)s_SHIFT %(val)d
+#define OF_MATCH_V1_WC_%(ku)s_MASK (1 << %(val)d)
+#define OF_MATCH_V1_WC_%(ku)s_SET(wc) ((wc) |= (1 << %(val)d))
+#define OF_MATCH_V1_WC_%(ku)s_CLEAR(wc) ((wc) &= ~(1 << %(val)d))
+#define OF_MATCH_V1_WC_%(ku)s_TEST(wc) ((wc) & (1 << %(val)d))
+""" % dict(ku=key.upper(), val=entry["v1_wc_shift"]))
+
+    out.write("""
+
+/**
+ * Definitions for wildcard macros for OF_VERSION_1_1
+ */
+""")
+
+    for key in sorted(match.of_v2_keys):
+        entry = match.of_match_members[key]
+        if "v2_wc_shift" in entry:
+            out.write("""
+#define OF_MATCH_V2_WC_%(ku)s_SHIFT %(val)d
+#define OF_MATCH_V2_WC_%(ku)s_MASK (1 << %(val)d)
+#define OF_MATCH_V2_WC_%(ku)s_SET(wc) ((wc) |= (1 << %(val)d))
+#define OF_MATCH_V2_WC_%(ku)s_CLEAR(wc) ((wc) &= ~(1 << %(val)d))
+#define OF_MATCH_V2_WC_%(ku)s_TEST(wc) ((wc) & (1 << %(val)d))
+""" % dict(ku=key.upper(), val=entry["v2_wc_shift"]))
+
+
+def gen_match_struct(out=sys.stdout):
+    out.write("/* Unified, flat OpenFlow match structure based on OF 1.2 */\n")
+    out.write("typedef struct of_match_fields_s {\n")
+    out.write("    /* Version 1.2 is used for field names */\n")
+    for name in match.match_keys_sorted:
+        entry = match.of_match_members[name]
+        out.write("    %-20s %s;\n" % (entry["m_type"], entry["name"]))
+    out.write("""
+} of_match_fields_t;
+
+/**
+ * @brief The LOCI match structure.
+ */
+
+typedef struct of_match_s {
+    of_version_t version;
+    of_match_fields_t fields;
+    of_match_fields_t masks;
+} of_match_t;
+
+/**
+ * IP Mask map.  IP maks wildcards from OF 1.0 are interpretted as
+ * indices into the map below.
+ *
+ * of_ip_mask_map: Array mapping index to mask
+ * of_ip_mask_use_map: Boolean indication set when map is initialized
+ * of_ip_mask_map_init: Initialize to default values; set "use map".
+ */
+#define OF_IP_MASK_MAP_COUNT 64
+extern uint32_t of_ip_mask_map[OF_IP_MASK_MAP_COUNT];
+extern int of_ip_mask_map_init_done;
+
+#define OF_IP_MASK_INIT_CHECK \
+    if (!of_ip_mask_map_init_done) of_ip_mask_map_init()
+
+/**
+ * Initialize map
+ */
+extern void of_ip_mask_map_init(void);
+
+extern int of_ip_mask_map_set(int index, uint32_t mask);
+extern int of_ip_mask_map_get(int index, uint32_t *mask);
+
+/**
+ * @brief Map from mask to index
+ */
+
+extern int of_ip_mask_to_index(uint32_t mask);
+
+/**
+ * @brief Map from index to mask
+ */
+
+extern uint32_t of_ip_index_to_mask(int index);
+
+/**
+ * The signalling of an untagged packet varies by OF version.
+ * Use this macro to set the field value.
+ */
+#define OF_MATCH_UNTAGGED_VLAN_ID(version) \\
+    ((version) == OF_VERSION_1_0 ? 0xffff : \\
+     ((version) == OF_VERSION_1_1 ? 0xffff : 0))
+
+/**
+ * Version 1.1 had the notion of "any" vlan but must be set
+ */
+#define OF_MATCH_VLAN_TAG_PRESENT_ANY_ID(version) \\
+    ((version) == OF_VERSION_1_0 ? 0 /* @fixme */  : \\
+     ((version) == OF_VERSION_1_1 ? 0xfffe : 0x1000))
+""")
+
+def gen_oxm_defines(out):
+    """
+    Generate verbatim definitions for OXM
+    """
+    out.write("""
+
+/* These are from the OpenFlow 1.2 header file */
+
+/* OXM index values for bitmaps and parsing */
+enum of_oxm_index_e {
+    OF_OXM_INDEX_IN_PORT        = 0,  /* Switch input port. */
+    OF_OXM_INDEX_IN_PHY_PORT    = 1,  /* Switch physical input port. */
+    OF_OXM_INDEX_METADATA       = 2,  /* Metadata passed between tables. */
+    OF_OXM_INDEX_ETH_DST        = 3,  /* Ethernet destination address. */
+    OF_OXM_INDEX_ETH_SRC        = 4,  /* Ethernet source address. */
+    OF_OXM_INDEX_ETH_TYPE       = 5,  /* Ethernet frame type. */
+    OF_OXM_INDEX_VLAN_VID       = 6,  /* VLAN id. */
+    OF_OXM_INDEX_VLAN_PCP       = 7,  /* VLAN priority. */
+    OF_OXM_INDEX_IP_DSCP        = 8,  /* IP DSCP (6 bits in ToS field). */
+    OF_OXM_INDEX_IP_ECN         = 9,  /* IP ECN (2 bits in ToS field). */
+    OF_OXM_INDEX_IP_PROTO       = 10, /* IP protocol. */
+    OF_OXM_INDEX_IPV4_SRC       = 11, /* IPv4 source address. */
+    OF_OXM_INDEX_IPV4_DST       = 12, /* IPv4 destination address. */
+    OF_OXM_INDEX_TCP_SRC        = 13, /* TCP source port. */
+    OF_OXM_INDEX_TCP_DST        = 14, /* TCP destination port. */
+    OF_OXM_INDEX_UDP_SRC        = 15, /* UDP source port. */
+    OF_OXM_INDEX_UDP_DST        = 16, /* UDP destination port. */
+    OF_OXM_INDEX_SCTP_SRC       = 17, /* SCTP source port. */
+    OF_OXM_INDEX_SCTP_DST       = 18, /* SCTP destination port. */
+    OF_OXM_INDEX_ICMPV4_TYPE    = 19, /* ICMP type. */
+    OF_OXM_INDEX_ICMPV4_CODE    = 20, /* ICMP code. */
+    OF_OXM_INDEX_ARP_OP         = 21, /* ARP opcode. */
+    OF_OXM_INDEX_ARP_SPA        = 22, /* ARP source IPv4 address. */
+    OF_OXM_INDEX_ARP_TPA        = 23, /* ARP target IPv4 address. */
+    OF_OXM_INDEX_ARP_SHA        = 24, /* ARP source hardware address. */
+    OF_OXM_INDEX_ARP_THA        = 25, /* ARP target hardware address. */
+    OF_OXM_INDEX_IPV6_SRC       = 26, /* IPv6 source address. */
+    OF_OXM_INDEX_IPV6_DST       = 27, /* IPv6 destination address. */
+    OF_OXM_INDEX_IPV6_FLABEL    = 28, /* IPv6 Flow Label */
+    OF_OXM_INDEX_ICMPV6_TYPE    = 29, /* ICMPv6 type. */
+    OF_OXM_INDEX_ICMPV6_CODE    = 30, /* ICMPv6 code. */
+    OF_OXM_INDEX_IPV6_ND_TARGET = 31, /* Target address for ND. */
+    OF_OXM_INDEX_IPV6_ND_SLL    = 32, /* Source link-layer for ND. */
+    OF_OXM_INDEX_IPV6_ND_TLL    = 33, /* Target link-layer for ND. */
+    OF_OXM_INDEX_MPLS_LABEL     = 34, /* MPLS label. */
+    OF_OXM_INDEX_MPLS_TC        = 35, /* MPLS TC. */
+};
+
+#define OF_OXM_BIT(index) (((uint64_t) 1) << (index))
+
+/*
+ * The generic match structure uses the OXM bit indices for it's
+ * bitmasks for active and masked values
+ */
+""")
+    for key, entry in match.of_match_members.items():
+        out.write("""
+/* Mask/value check/set macros for %(key)s */
+
+/**
+ * Set the mask for an exact match of %(key)s
+ */
+#define OF_MATCH_MASK_%(ku)s_EXACT_SET(_match)   \\
+    MEMSET(&(_match)->masks.%(key)s, 0xff, \\
+        sizeof(((_match)->masks).%(key)s))
+
+/**
+ * Clear the mask for %(key)s making that field inactive for the match
+ */
+#define OF_MATCH_MASK_%(ku)s_CLEAR(_match) \\
+    MEMSET(&(_match)->masks.%(key)s, 0, \\
+        sizeof(((_match)->masks).%(key)s))
+
+/**
+ * Test whether the match is exact for %(key)s
+ */
+#define OF_MATCH_MASK_%(ku)s_EXACT_TEST(_match) \\
+    OF_VARIABLE_IS_ALL_ONES(&(((_match)->masks).%(key)s))
+
+/**
+ * Test whether key %(key)s is being checked in the match
+ */
+#define OF_MATCH_MASK_%(ku)s_ACTIVE_TEST(_match) \\
+    OF_VARIABLE_IS_NON_ZERO(&(((_match)->masks).%(key)s))
+
+""" % dict(key=key, bit=match.oxm_index(key), ku=key.upper()))
+
+def gen_incompat_members(out=sys.stdout):
+    """
+    Generate a macro that lists all the unified fields which are
+    incompatible with v1 matches
+    """
+    out.write("""
+/* Identify bits in unified match that are incompatible with V1, V2 matches */
+#define OF_MATCH_V1_INCOMPAT ( (uint64_t)0 """)
+    for key in match.of_match_members:
+        if key in match.of_v1_keys:
+            continue
+        out.write("\\\n    | ((uint64_t)1 << %s)" % match.oxm_index(key))
+    out.write(")\n\n")
+
+    out.write("#define OF_MATCH_V2_INCOMPAT ( (uint64_t)0 ")
+    for key in match.of_match_members:
+        if key in match.of_v2_keys:
+            continue
+        out.write("\\\n    | ((uint64_t)1 << %s)" % match.oxm_index(key))
+    out.write(""")
+
+/* Indexed by version number */
+extern uint64_t of_match_incompat[4];
+""")
+
+
+# # FIXME:  Make these version specific
+# def name_to_index(a, name, key="name"):
+#     """
+#     Given an array, a, with each entry a dict, and a name,
+#     find the entry with key matching name and return the index
+#     """
+#     count = 0
+#     for e in a:
+#         if e[key] == name:
+#             return count
+#         count += 1
+#     return -1
+
+def gen_wc_convert_literal(out):
+    """
+    A bunch of literal C code that's associated with match conversions
+    @param out The output file handle
+    """
+    out.write("""
+
+/* Some internal macros and utility functions */
+
+/* For counting bits in a uint32 */
+#define _VAL_AND_5s(v)  ((v) & 0x55555555)
+#define _VAL_EVERY_OTHER(v)  (_VAL_AND_5s(v) + _VAL_AND_5s(v >> 1))
+#define _VAL_AND_3s(v)  ((v) & 0x33333333)
+#define _VAL_PAIRS(v)  (_VAL_AND_3s(v) + _VAL_AND_3s(v >> 2))
+#define _VAL_QUADS(v)  (((val) + ((val) >> 4)) & 0x0F0F0F0F)
+#define _VAL_BYTES(v)  ((val) + ((val) >> 8))
+
+/**
+ * Counts the number of bits set in an integer
+ */
+static inline int
+_COUNT_BITS(unsigned int val)
+{
+    val = _VAL_EVERY_OTHER(val);
+    val = _VAL_PAIRS(val);
+    val = _VAL_QUADS(val);
+    val = _VAL_BYTES(val);
+
+    return (val & 0XFF) + ((val >> 16) & 0xFF);
+}
+
+/* Indexed by version number */
+uint64_t of_match_incompat[4] = {
+    -1,
+    OF_MATCH_V1_INCOMPAT,
+    OF_MATCH_V2_INCOMPAT,
+    0
+};
+
+""")
+
+
+def gen_unified_match_to_v1(out):
+    """
+    Generate C code to convert a unified match structure to a V1 match struct
+    @param out The output file handle
+    """
+
+    out.write("""
+/**
+ * Check if match is compatible with OF 1.0
+ * @param match The match being checked
+ */
+static inline int
+of_match_v1_compat_check(of_match_t *match)
+{
+""")
+    for key in match.of_match_members:
+        if key in match.of_v1_keys:
+            continue
+        out.write("""
+    if (OF_MATCH_MASK_%(ku)s_ACTIVE_TEST(match)) {
+        return 0;
+    }
+""" % dict(ku=key.upper()))
+
+    out.write("""
+    return 1;
+}
+""")
+
+    out.write("""
+/**
+ * Convert a generic match object to an OF_VERSION_1_0 object
+ * @param src Pointer to the generic match object source
+ * @param dst Pointer to the OF 1.0 wire structure
+ *
+ * The wire structure is initialized by this function if it doesn't
+ * not have the proper object ID.
+ */
+
+int
+of_match_to_wire_match_v1(of_match_t *src, of_match_v1_t *dst)
+{
+    of_wc_bmap_t wildcards = 0;
+    int ip_mask_index;
+
+    if ((src == NULL) || (dst == NULL)) {
+        return OF_ERROR_PARAM;
+    }
+    if (!of_match_v1_compat_check(src)) {
+        return OF_ERROR_COMPAT;
+    }
+    if (dst->object_id != OF_MATCH_V1) {
+        of_match_v1_init(dst, OF_VERSION_1_0, 0, 0);
+    }
+""")
+    for key in sorted(match.of_v1_keys):
+        if key in ["ipv4_src", "ipv4_dst"]: # Special cases for masks here
+            out.write("""
+    if (OF_MATCH_MASK_%(ku)s_ACTIVE_TEST(src)) {
+        ip_mask_index = of_ip_mask_to_index(src->masks.%(key)s);
+        of_match_v1_%(key)s_set(dst, src->fields.%(key)s);
+    } else { /* Wildcarded, look for 0 mask */
+        ip_mask_index = of_ip_mask_to_index(0);
+    }
+    OF_MATCH_V1_WC_%(ku)s_SET(wildcards, ip_mask_index);
+""" % dict(key=key, ku=key.upper()))
+        else:
+            out.write("""
+    if (OF_MATCH_MASK_%(ku)s_ACTIVE_TEST(src)) {
+        of_match_v1_%(key)s_set(dst, src->fields.%(key)s);
+    } else {
+        OF_MATCH_V1_WC_%(ku)s_SET(wildcards);
+    }
+""" % dict(key=key, ku=key.upper()))
+
+    out.write("""
+    of_match_v1_wildcards_set(dst, wildcards);
+
+    return OF_ERROR_NONE;
+}
+""")
+
+def all_ones_mask(d_type):
+    if d_type == "of_mac_addr_t":
+        return "of_mac_addr_all_ones"
+    else:
+        return "((%s) -1)" % d_type
+
+def gen_unified_match_to_v2(out):
+    """
+    Generate C code to convert a unified match structure to a V2 match struct
+    @param out The output file handle
+    """
+
+    out.write("""
+/**
+ * Check if match is compatible with OF 1.0
+ * @param match The match being checked
+ */
+static inline int
+of_match_v2_compat_check(of_match_t *match)
+{
+""")
+    for key in match.of_match_members:
+        if key in match.of_v2_keys:
+            continue
+        out.write("""
+    if (OF_MATCH_MASK_%(ku)s_ACTIVE_TEST(match)) {
+        return 0;
+    }
+""" % dict(ku=key.upper()))
+
+    out.write("""
+    return 1;
+}
+""")
+
+    out.write("""
+/**
+ * Convert a generic match object to an OF_VERSION_1_1 object
+ * @param src Pointer to the generic match object source
+ * @param dst Pointer to the OF 1.1 wire structure
+ *
+ * The wire structure is initialized by this function.
+ */
+
+int
+of_match_to_wire_match_v2(of_match_t *src, of_match_v2_t *dst)
+{
+    of_wc_bmap_t wildcards = 0;
+
+    if ((src == NULL) || (dst == NULL)) {
+        return OF_ERROR_PARAM;
+    }
+    if (!of_match_v2_compat_check(src)) {
+        return OF_ERROR_COMPAT;
+    }
+    if (dst->object_id != OF_MATCH_V2) {
+        of_match_v2_init(dst, OF_VERSION_1_1, 0, 0);
+    }
+""")
+    for key in match.of_v2_keys:
+        if key in match.of_v2_full_mask:
+            ones_mask = all_ones_mask(match.of_match_members[key]["m_type"])
+            out.write("""
+    if (OF_MATCH_MASK_%(ku)s_ACTIVE_TEST(src)) {
+        if (!OF_MATCH_MASK_%(ku)s_EXACT_TEST(src)) {
+            of_match_v2_%(key)s_mask_set(dst,
+                src->masks.%(key)s);
+        } else { /* Exact match; use all ones mask */
+            of_match_v2_%(key)s_mask_set(dst,
+                %(ones_mask)s);
+        }
+        of_match_v2_%(key)s_set(dst, src->fields.%(key)s);
+    }
+
+""" % dict(key=key, ku=key.upper(), ones_mask=ones_mask))
+        else:
+            out.write("""
+    if (!OF_MATCH_MASK_%(ku)s_EXACT_TEST(src)) {
+        return OF_ERROR_COMPAT;
+    }
+    if (OF_MATCH_MASK_%(ku)s_ACTIVE_TEST(src)) {
+        of_match_v2_%(key)s_set(dst, src->fields.%(key)s);
+    } else {
+        OF_MATCH_V2_WC_%(ku)s_SET(wildcards);
+    }
+""" % dict(key=key, ku=key.upper(),
+           wc_bit="OF_MATCH_WC_V2_%s" % key.upper()))
+
+    out.write("""
+    of_match_v2_wildcards_set(dst, wildcards);
+
+    return OF_ERROR_NONE;
+}
+""")
+
+def gen_unified_match_to_v3(out):
+    """
+    Generate C code to convert a unified match structure to a V3 match
+
+    This is much easier as the unified struct is based on V3
+    @param out The output file handle
+    """
+    out.write("""
+static int
+populate_oxm_list(of_match_t *src, of_list_oxm_t *oxm_list)
+{
+    of_oxm_t oxm_entry;
+
+    /* For each active member, add an OXM entry to the list */
+""")
+    # @fixme Would like to generate the list in some reasonable order
+    for key, entry in match.of_match_members.items():
+        out.write("""\
+    if (OF_MATCH_MASK_%(ku)s_ACTIVE_TEST(src)) {
+        if (!OF_MATCH_MASK_%(ku)s_EXACT_TEST(src)) {
+            of_oxm_%(key)s_masked_t *elt;
+            elt = &oxm_entry.%(key)s_masked;
+
+            of_oxm_%(key)s_masked_init(elt,
+                src->version, -1, 1);
+            of_list_oxm_append_bind(oxm_list, &oxm_entry);
+            of_oxm_%(key)s_masked_value_set(elt, 
+                   src->fields.%(key)s);
+            of_oxm_%(key)s_masked_value_mask_set(elt, 
+                   src->masks.%(key)s);
+        } else {  /* Active, but not masked */
+            of_oxm_%(key)s_t *elt;
+            elt = &oxm_entry.%(key)s;
+            of_oxm_%(key)s_init(elt,
+                src->version, -1, 1);
+            of_list_oxm_append_bind(oxm_list, &oxm_entry);
+            of_oxm_%(key)s_value_set(elt, src->fields.%(key)s);
+        }
+    }
+""" % dict(key=key, ku=key.upper()))
+    out.write("""
+    return OF_ERROR_NONE;
+}
+
+/**
+ * Convert a generic match object to an OF_VERSION_1_2 object
+ * @param src Pointer to the generic match object source
+ * @param dst Pointer to the OF 1.2 wire structure
+ *
+ * The wire structure is initialized by this function if the object
+ * id is not correct in the object
+ */
+
+int
+of_match_to_wire_match_v3(of_match_t *src, of_match_v3_t *dst)
+{
+    int rv = OF_ERROR_NONE;
+    of_list_oxm_t *oxm_list;
+
+    if ((src == NULL) || (dst == NULL)) {
+        return OF_ERROR_PARAM;
+    }
+    if (dst->object_id != OF_MATCH_V3) {
+        of_match_v3_init(dst, src->version, 0, 0);
+    }
+    if ((oxm_list = of_list_oxm_new(src->version)) == NULL) {
+        return OF_ERROR_RESOURCE;
+    }
+
+    rv = populate_oxm_list(src, oxm_list);
+
+    if (rv == OF_ERROR_NONE) {
+        rv = of_match_v3_oxm_list_set(dst, oxm_list);
+    }
+
+    of_list_oxm_delete(oxm_list);
+
+    return rv;
+}
+""")
+
+def gen_v1_to_unified_match(out):
+    """
+    Generate the code that maps a v1 wire format match object
+    to a unified match object
+    """
+    # for each v1 member, if not in wildcards
+    # translate to unified.  Treat nw_src/dst specially
+    out.write("""
+
+/**
+ * Convert an OF_VERSION_1_0 object to a generic match object
+ * @param src Pointer to the OF 1.0 wire structure source
+ * @param dst Pointer to the generic match object destination
+ *
+ * The wire structure is initialized by this function.
+ */
+
+int
+of_match_v1_to_match(of_match_v1_t *src, of_match_t *dst)
+{
+    of_wc_bmap_t wc;
+    int count;
+
+    MEMSET(dst, 0, sizeof(*dst));
+    dst->version = src->version;
+
+    of_match_v1_wildcards_get(src, &wc);
+""")
+    # Deal with nw fields first
+    out.write("""
+    /* Handle L3 src and dst wildcarding first */
+    /* @fixme Check mask values are properly treated for ipv4 src/dst */
+    if ((count = OF_MATCH_V1_WC_IPV4_DST_GET(wc)) < 32) {
+        of_match_v1_ipv4_dst_get(src, &dst->fields.ipv4_dst);
+        if (count > 0) { /* Not exact match */
+            dst->masks.ipv4_dst = ~(((uint32_t)1 << count) - 1);
+        } else {
+            OF_MATCH_MASK_IPV4_DST_EXACT_SET(dst);
+        }
+    }
+""")
+    for key in sorted(match.of_v1_keys):
+        if key in ["ipv4_src", "ipv4_dst"]: # Special cases for masks here
+            out.write("""
+    count = OF_MATCH_V1_WC_%(ku)s_GET(wc);
+    dst->masks.%(key)s = of_ip_index_to_mask(count);
+    /* @todo Review if we should only get the addr when masks.%(key)s != 0 */
+    of_match_v1_%(key)s_get(src, &dst->fields.%(key)s);
+""" % dict(ku=key.upper(), key=key))
+        else:
+            out.write("""
+    if (!(OF_MATCH_V1_WC_%(ku)s_TEST(wc))) {
+        of_match_v1_%(key)s_get(src, &dst->fields.%(key)s);
+        OF_MATCH_MASK_%(ku)s_EXACT_SET(dst);
+    }
+""" % dict(ku=key.upper(), key=key))
+
+    out.write("""
+    return OF_ERROR_NONE;
+}
+""")
+
+def gen_v2_to_unified_match(out):
+    """
+    Generate the code that maps a v2 wire format match object
+    to a unified match object
+    """
+    out.write("""
+int
+of_match_v2_to_match(of_match_v2_t *src, of_match_t *dst)
+{
+    of_wc_bmap_t wc;
+
+    MEMSET(dst, 0, sizeof(*dst));
+    dst->version = src->version;
+
+    of_match_v2_wildcards_get(src, &wc);
+""")
+    for key in match.of_v2_keys:
+        if key in match.of_v2_full_mask:
+            out.write("""
+    of_match_v2_%(key)s_mask_get(src, &dst->masks.%(key)s);
+    if (OF_VARIABLE_IS_NON_ZERO(&dst->masks.%(key)s)) { /* Matching something */
+        of_match_v2_%(key)s_get(src, &dst->fields.%(key)s);
+    }
+""" % dict(ku=key.upper(), key=key))
+        else:
+            out.write("""
+    if (!(OF_MATCH_V2_WC_%(ku)s_TEST(wc))) {
+        of_match_v2_%(key)s_get(src, &dst->fields.%(key)s);
+        OF_MATCH_MASK_%(ku)s_EXACT_SET(dst);
+    }
+""" % dict(ku=key.upper(), key=key))
+
+    out.write("""
+    return OF_ERROR_NONE;
+}
+""")
+
+
+def gen_v3_to_unified_match(out):
+    """
+    Generate the code that maps a v3 wire format match object
+    to a unified match object
+    """
+    # Iterate thru the OXM list members
+    out.write("""
+int
+of_match_v3_to_match(of_match_v3_t *src, of_match_t *dst)
+{
+    int rv;
+    of_list_oxm_t oxm_list;
+    of_oxm_t oxm_entry;
+""")
+#    for key in match.of_match_members:
+#        out.write("    of_oxm_%s_t *%s;\n" % (key, key))
+#        out.write("    of_oxm_%s_masked_t *%s_masked;\n" % (key, key))
+
+    out.write("""
+    MEMSET(dst, 0, sizeof(*dst));
+    dst->version = src->version;
+
+    of_match_v3_oxm_list_bind(src, &oxm_list);
+    rv = of_list_oxm_first(&oxm_list, &oxm_entry);
+
+    while (rv == OF_ERROR_NONE) {
+        switch (oxm_entry.header.object_id) { /* What kind of entry is this */
+""")
+    for key in match.of_match_members:
+        out.write("""
+        case OF_OXM_%(ku)s_MASKED:
+            of_oxm_%(key)s_masked_value_mask_get(
+                &oxm_entry.%(key)s_masked,
+                &dst->masks.%(key)s);
+            of_oxm_%(key)s_masked_value_get(
+                &oxm_entry.%(key)s,
+                &dst->fields.%(key)s);
+            break;
+        case OF_OXM_%(ku)s:
+            OF_MATCH_MASK_%(ku)s_EXACT_SET(dst);
+            of_oxm_%(key)s_value_get(
+                &oxm_entry.%(key)s,
+                &dst->fields.%(key)s);
+            break;
+""" % (dict(ku=key.upper(), key=key)))
+
+    out.write("""
+        default:
+             /* @fixme Add debug statement */
+             return OF_ERROR_PARSE;
+        } /* end switch */
+        rv = of_list_oxm_next(&oxm_list, &oxm_entry);
+    } /* end OXM iteration */
+
+    return OF_ERROR_NONE;
+}
+""")
+
+def gen_serialize(out):
+    out.write("""
+/**
+ * Serialize a match structure according to the version passed
+ * @param version The version to use for serialization protocol
+ * @param match Pointer to the structure to serialize
+ * @param octets Pointer to an octets object to fill out
+ *
+ * A buffer is allocated using normal internal ALLOC/FREE semantics
+ * and pointed to by the octets object.  The length of the resulting
+ * serialization is in octets->bytes.
+ *
+ * For 1.2 matches, returns the padded serialized structure
+ *
+ * Note that FREE must be called on octets->data when processing of
+ * the object is complete.
+ */
+
+int
+of_match_serialize(of_version_t version, of_match_t *match, of_octets_t *octets)
+{
+    int rv;
+
+    switch (version) {
+""")
+    for version in of_g.of_version_range:
+        out.write("""
+    case %(ver_name)s:
+        {
+            of_match_v%(version)s_t *wire_match;
+            wire_match = of_match_v%(version)s_new(version);
+            if (wire_match == NULL) {
+                return OF_ERROR_RESOURCE;
+            }
+            if ((rv = of_match_to_wire_match_v%(version)s(match, wire_match)) < 0) {
+                of_match_v%(version)s_delete(wire_match);
+                return rv;
+            }
+            octets->bytes = OF_MATCH_BYTES(wire_match->length);
+            of_object_wire_buffer_steal((of_object_t *)wire_match,
+                                        &octets->data);
+            of_match_v%(version)s_delete(wire_match);
+        }
+        break;
+""" % dict(version=version, ver_name=of_g.of_version_wire2name[version]))
+    out.write("""
+    default:
+        return OF_ERROR_COMPAT;
+    }
+
+    return OF_ERROR_NONE;
+}
+""")
+
+
+def gen_deserialize(out):
+    out.write("""
+/**
+ * Deserialize a match structure according to the version passed
+ * @param version The version to use for deserialization protocol
+ * @param match Pointer to the structure to fill out
+ * @param octets Pointer to an octets object holding serial buffer
+ *
+ * Normally the octets object will point to a part of a wire buffer.
+ */
+
+int
+of_match_deserialize(of_version_t version, of_match_t *match,
+                     of_octets_t *octets)
+{
+    if (octets->bytes == 0) { /* No match specified means all wildcards */
+        MEMSET(match, 0, sizeof(*match));
+        match->version = version;
+
+        return OF_ERROR_NONE;
+    }
+
+    switch (version) {
+""")
+    for version in of_g.of_version_range:
+        out.write("""
+    case %(ver_name)s:
+        { /* FIXME: check init bytes */
+            uint8_t *tmp;
+            of_match_v%(version)d_t wire_match;
+            of_match_v%(version)d_init(&wire_match,
+                   %(ver_name)s, -1, 1);
+            of_object_buffer_bind((of_object_t *)&wire_match, 
+                octets->data, octets->bytes, NULL);
+            OF_TRY(of_match_v%(version)d_to_match(&wire_match, match));
+
+            /* Free the wire buffer control block without freeing
+             * octets->bytes. */
+            of_wire_buffer_steal(wire_match.wire_object.wbuf, &tmp);
+        }
+        break;
+""" % dict(version=version, ver_name=of_g.of_version_wire2name[version]))
+
+    out.write("""
+    default:
+        return OF_ERROR_COMPAT;
+    }
+
+    return OF_ERROR_NONE;
+}
+""")
+
+def gen_match_comp(out=sys.stdout):
+    """
+    Generate match comparison functions
+    """
+    out.write("""
+/**
+ * Determine "more specific" relationship between mac addrs
+ * @return true if v1 is equal to or more specific than v2
+ *
+ * @todo Could be optimized
+ *
+ * Check: Every bit in v2 is set in v1; v1 may have add'l bits set.
+ * That is, return false if there is a bit set in v2 and not in v1.
+ */
+
+static inline int
+of_more_specific_ipv6(of_ipv6_t *v1, of_ipv6_t *v2) {
+    int idx;
+
+    for (idx = 0; idx < OF_IPV6_BYTES; idx++) {
+        /* If there's a bit set in v2 that is clear in v1, return false */
+        if (~v1->addr[idx] & v2->addr[idx]) {
+            return 0;
+        }
+    }
+
+    return 1;
+}
+
+/**
+ * Boolean test if two values agree when restricted to a mask
+ */
+
+static inline int
+of_restricted_match_ipv6(of_ipv6_t *v1, of_ipv6_t *v2, of_ipv6_t *mask) {
+    int idx;
+
+    for (idx = 0; idx < OF_IPV6_BYTES; idx++) {
+        if ((v1->addr[idx] & mask->addr[idx]) != 
+               (v2->addr[idx] & mask->addr[idx])) {
+            return 0;
+        }
+    }
+
+    return 1;
+}
+
+/**
+ * Boolean test if two values "overlap" (agree on common masks)
+ */
+
+static inline int
+of_overlap_ipv6(of_ipv6_t *v1, of_ipv6_t *v2,
+                         of_ipv6_t *m1, of_ipv6_t *m2) {
+    int idx;
+
+    for (idx = 0; idx < OF_IPV6_BYTES; idx++) {
+        if (((v1->addr[idx] & m1->addr[idx]) & m2->addr[idx]) != 
+               ((v2->addr[idx] & m1->addr[idx]) & m2->addr[idx])) {
+            return 0;
+        }
+    }
+
+    return 1;
+}
+
+#define OF_MORE_SPECIFIC_IPV6(v1, v2) of_more_specific_ipv6((v1), (v2))
+
+#define OF_RESTRICTED_MATCH_IPV6(v1, v2, mask) \\
+    of_restricted_match_ipv6((v1), (v2), (mask))
+
+#define OF_OVERLAP_IPV6(v1, v2, m1, m2) of_overlap_ipv6((v1), (v2), (m1), (m2))
+
+/**
+ * Determine "more specific" relationship between mac addrs
+ * @return true if v1 is equal to or more specific than v2
+ *
+ * @todo Could be optimized
+ *
+ * Check: Every bit in v2 is set in v1; v1 may have add'l bits set.
+ * That is, return false if there is a bit set in v2 and not in v1.
+ */
+static inline int
+of_more_specific_mac_addr(of_mac_addr_t *v1, of_mac_addr_t *v2) {
+    int idx;
+
+    for (idx = 0; idx < OF_MAC_ADDR_BYTES; idx++) {
+        /* If there's a bit set in v2 that is clear in v1, return false */
+        if (~v1->addr[idx] & v2->addr[idx]) {
+            return 0;
+        }
+    }
+
+    return 1;
+}
+
+/**
+ * Boolean test if two values agree when restricted to a mask
+ */
+static inline int
+of_restricted_match_mac_addr(of_mac_addr_t *v1, of_mac_addr_t *v2, 
+                             of_mac_addr_t *mask) {
+    int idx;
+
+    for (idx = 0; idx < OF_MAC_ADDR_BYTES; idx++) {
+        if ((v1->addr[idx] & mask->addr[idx]) != 
+               (v2->addr[idx] & mask->addr[idx])) {
+            return 0;
+        }
+    }
+
+    return 1;
+}
+
+/**
+ * Boolean test if two values "overlap" (agree on common masks)
+ */
+
+static inline int
+of_overlap_mac_addr(of_mac_addr_t *v1, of_mac_addr_t *v2,
+                         of_mac_addr_t *m1, of_mac_addr_t *m2) {
+    int idx;
+
+    for (idx = 0; idx < OF_MAC_ADDR_BYTES; idx++) {
+        if (((v1->addr[idx] & m1->addr[idx]) & m2->addr[idx]) != 
+               ((v2->addr[idx] & m1->addr[idx]) & m2->addr[idx])) {
+            return 0;
+        }
+    }
+
+    return 1;
+}
+
+#define OF_MORE_SPECIFIC_MAC_ADDR(v1, v2) of_more_specific_mac_addr((v1), (v2))
+
+#define OF_RESTRICTED_MATCH_MAC_ADDR(v1, v2, mask) \\
+    of_restricted_match_mac_addr((v1), (v2), (mask))
+
+#define OF_OVERLAP_MAC_ADDR(v1, v2, m1, m2) \\
+    of_overlap_mac_addr((v1), (v2), (m1), (m2))
+
+/**
+ * More-specific-than macro for integer types; see above
+ * @return true if v1 is equal to or more specific than v2
+ *
+ * If there is a bit that is set in v2 and not in v1, return false.
+ */
+#define OF_MORE_SPECIFIC_INT(v1, v2) (!(~(v1) & (v2)))
+
+/**
+ * Boolean test if two values agree when restricted to a mask
+ */
+#define OF_RESTRICTED_MATCH_INT(v1, v2, mask) \\
+   (((v1) & (mask)) == ((v2) & (mask)))
+
+
+#define OF_OVERLAP_INT(v1, v2, m1, m2) \\
+    ((((v1) & (m1)) & (m2)) == (((v2) & (m1)) & (m2)))
+""")
+
+    out.write("""
+/**
+ * Compare two match structures for exact equality
+ *
+ * We just do memcmp assuming structs were memset to 0 on init
+ */
+static inline int
+of_match_eq(of_match_t *match1, of_match_t *match2)
+{
+    return (MEMCMP(match1, match2, sizeof(of_match_t)) == 0);
+}
+
+/**
+ * Is the entry match more specific than (or equal to) the query match?
+ * @param entry Match expected to be more specific (subset of query)
+ * @param query Match expected to be less specific (superset of entry)
+ * @returns Boolean, see below
+ *
+ * The assumption is that a query is being done for a non-strict
+ * match against an entry in a table.  The result is true if the
+ * entry match indicates a more specific (but compatible) flow space
+ * specification than that in the query match.  This means that the
+ * values agree between the two where they overlap, and that each mask
+ * for the entry is more specific than that of the query.
+ *
+ * The query has the less specific mask (fewer mask bits) so it is
+ * used for the mask when checking values.
+ */
+
+static inline int
+of_match_more_specific(of_match_t *entry, of_match_t *query)
+{
+    of_match_fields_t *q_m, *e_m;  /* Short hand for masks, fields */
+    of_match_fields_t *q_f, *e_f;
+
+    q_m = &query->masks;
+    e_m = &entry->masks;
+    q_f = &query->fields;
+    e_f = &entry->fields;
+""")
+    for key, entry in match.of_match_members.items():
+        q_m = "&q_m->%s" % key
+        e_m = "&e_m->%s" % key
+        q_f = "&q_f->%s" % key
+        e_f = "&e_f->%s" % key
+        if entry["m_type"] == "of_ipv6_t":
+            comp = "OF_MORE_SPECIFIC_IPV6"
+            match_type = "OF_RESTRICTED_MATCH_IPV6"
+        elif entry["m_type"] == "of_mac_addr_t":
+            comp = "OF_MORE_SPECIFIC_MAC_ADDR"
+            match_type = "OF_RESTRICTED_MATCH_MAC_ADDR"
+        else: # Integer
+            comp = "OF_MORE_SPECIFIC_INT"
+            match_type = "OF_RESTRICTED_MATCH_INT"
+            q_m = "q_m->%s" % key
+            e_m = "e_m->%s" % key
+            q_f = "q_f->%s" % key
+            e_f = "e_f->%s" % key
+        out.write("""
+    /* Mask and values for %(key)s */
+    if (!%(comp)s(%(e_m)s, %(q_m)s)) {
+        return 0;
+    }
+    if (!%(match_type)s(%(e_f)s, %(q_f)s,
+            %(q_m)s)) {
+        return 0;
+    }
+""" % dict(match_type=match_type, comp=comp, q_f=q_f, e_f=e_f, 
+           q_m=q_m, e_m=e_m, key=key))
+
+    out.write("""
+    return 1;
+}
+""")
+
+    out.write("""
+
+/**
+ * Do two entries overlap?
+ * @param match1 One match struct
+ * @param match2 Another match struct
+ * @returns Boolean: true if there is a packet that would match both
+ *
+ */
+
+static inline int
+of_match_overlap(of_match_t *match1, of_match_t *match2)
+{
+    of_match_fields_t *m1, *m2;  /* Short hand for masks, fields */
+    of_match_fields_t *f1, *f2;
+
+    m1 = &match1->masks;
+    m2 = &match2->masks;
+    f1 = &match1->fields;
+    f2 = &match2->fields;
+""")
+    for key, entry in match.of_match_members.items():
+        m1 = "&m1->%s" % key
+        m2 = "&m2->%s" % key
+        f1 = "&f1->%s" % key
+        f2 = "&f2->%s" % key
+        if entry["m_type"] == "of_ipv6_t":
+            check = "OF_OVERLAP_IPV6"
+        elif entry["m_type"] == "of_mac_addr_t":
+            check = "OF_OVERLAP_MAC_ADDR"
+        else: # Integer
+            check = "OF_OVERLAP_INT"
+            m1 = "m1->%s" % key
+            m2 = "m2->%s" % key
+            f1 = "f1->%s" % key
+            f2 = "f2->%s" % key
+        out.write("""
+    /* Check overlap for %(key)s */
+    if (!%(check)s(%(f1)s, %(f2)s, 
+        %(m2)s, %(m1)s)) {
+        return 0; /* This field differentiates; all done */
+    }
+""" % dict(check=check, f1=f1, f2=f2, m1=m1, m2=m2, key=key))
+
+    out.write("""
+    return 1; /* No field differentiates matches */
+}
+""")
+
+def gen_match_conversions(out=sys.stdout):
+    match.match_sanity_check()
+    gen_wc_convert_literal(out)
+    out.write("""
+/**
+ * IP Mask map.  IP maks wildcards from OF 1.0 are interpretted as
+ * indices into the map below.
+ */
+
+int of_ip_mask_map_init_done = 0;
+uint32_t of_ip_mask_map[OF_IP_MASK_MAP_COUNT];
+void
+of_ip_mask_map_init(void)
+{
+    int idx;
+
+    MEMSET(of_ip_mask_map, 0, sizeof(of_ip_mask_map));
+    for (idx = 0; idx < 32; idx++) {
+        of_ip_mask_map[idx] = ~((1U << idx) - 1);
+    }
+
+    of_ip_mask_map_init_done = 1;
+}
+
+/**
+ * @brief Set non-default IP mask for given index
+ */
+int
+of_ip_mask_map_set(int index, uint32_t mask)
+{
+    OF_IP_MASK_INIT_CHECK;
+
+    if ((index < 0) || (index >= OF_IP_MASK_MAP_COUNT)) {
+        return OF_ERROR_RANGE;
+    }
+    of_ip_mask_map[index] = mask;
+
+    return OF_ERROR_NONE;
+}
+
+/**
+ * @brief Get a non-default IP mask for given index
+ */
+int
+of_ip_mask_map_get(int index, uint32_t *mask)
+{
+    OF_IP_MASK_INIT_CHECK;
+
+    if ((mask == NULL) || (index < 0) || (index >= OF_IP_MASK_MAP_COUNT)) {
+        return OF_ERROR_RANGE;
+    }
+    *mask = of_ip_mask_map[index];
+
+    return OF_ERROR_NONE;
+}
+
+/**
+ * @brief Return the index (used as the WC field in 1.0 match) given the mask
+ */
+
+int
+of_ip_mask_to_index(uint32_t mask)
+{
+    int idx;
+
+    OF_IP_MASK_INIT_CHECK;
+
+    /* Handle most common cases directly */
+    if ((mask == 0) && (of_ip_mask_map[63] == 0)) {
+        return 63;
+    }
+    if ((mask == 0xffffffff) && (of_ip_mask_map[0] == 0xffffffff)) {
+        return 0;
+    }
+
+    for (idx = 0; idx < OF_IP_MASK_MAP_COUNT; idx++) {
+        if (mask == of_ip_mask_map[idx]) {
+            return idx;
+        }
+    }
+
+    LOCI_LOG_INFO("OF 1.0: Could not map IP addr mask 0x%x", mask);
+    return 0x3f;
+}
+
+/**
+ * @brief Return the mask for the given index
+ */
+
+uint32_t
+of_ip_index_to_mask(int index)
+{
+    OF_IP_MASK_INIT_CHECK;
+
+    if (index >= OF_IP_MASK_MAP_COUNT) {
+        LOCI_LOG_INFO("IP index to map: bad index %d", index);
+        return 0;
+    }
+
+    return of_ip_mask_map[index];
+}
+
+""")
+
+    gen_unified_match_to_v1(out)
+    gen_unified_match_to_v2(out)
+    gen_unified_match_to_v3(out)
+    gen_v1_to_unified_match(out)
+    gen_v2_to_unified_match(out)
+    gen_v3_to_unified_match(out)
+    return
diff --git a/c_gen/c_show_gen.py b/c_gen/c_show_gen.py
new file mode 100644
index 0000000..5dab038
--- /dev/null
+++ b/c_gen/c_show_gen.py
@@ -0,0 +1,268 @@
+# Copyright 2013, Big Switch Networks, Inc.
+#
+# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+# the following special exception:
+#
+# LOXI Exception
+#
+# As a special exception to the terms of the EPL, you may distribute libraries
+# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+# that copyright and licensing notices generated by LoxiGen are not altered or removed
+# from the LoxiGen Libraries and the notice provided below is (i) included in
+# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+# documentation for the LoxiGen Libraries, if distributed in binary form.
+#
+# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+#
+# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+# a copy of the EPL at:
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# 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
+# EPL for the specific language governing permissions and limitations
+# under the EPL.
+
+"""
+@brief Show function generation
+
+Generates show function files.
+
+"""
+
+import sys
+import of_g
+import loxi_front_end.match as match
+import loxi_front_end.flags as flags
+from generic_utils import *
+import loxi_front_end.type_maps as type_maps
+import loxi_utils.loxi_utils as loxi_utils
+import loxi_front_end.identifiers as identifiers
+from c_test_gen import var_name_map
+
+def gen_obj_show_h(out, name):
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""
+/**
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ *
+ * Header file for object showing. 
+ */
+
+/**
+ * Show  object declarations
+ *
+ * Routines that emit a human-readable dump of each object.
+ *
+ */
+
+#if !defined(_LOCI_OBJ_SHOW_H_)
+#define _LOCI_OBJ_SHOW_H_
+
+#include <loci/loci.h>
+#include <stdio.h>
+
+/* g++ requires this to pick up PRI, etc.
+ * See  http://gcc.gnu.org/ml/gcc-help/2006-10/msg00223.html
+ */
+#if !defined(__STDC_FORMAT_MACROS)
+#define __STDC_FORMAT_MACROS
+#endif
+#include <inttypes.h>
+
+
+/**
+ * Show any OF object. 
+ */
+int of_object_show(loci_writer_f writer, void* cookie, of_object_t* obj); 
+
+
+
+
+
+
+""")
+
+    type_to_emitter = dict(
+
+        )
+    for version in of_g.of_version_range:
+        for cls in of_g.standard_class_order:
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            if cls in type_maps.inheritance_map:
+                continue
+            out.write("""\
+int %(cls)s_%(ver_name)s_show(loci_writer_f writer, void* cookie, %(cls)s_t *obj);
+""" % dict(cls=cls, ver_name=loxi_utils.version_to_name(version)))
+
+    out.write("""
+#endif /* _LOCI_OBJ_SHOW_H_ */
+""")
+
+def gen_obj_show_c(out, name):
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""
+/**
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ *
+ * Source file for object showing. 
+ * 
+ */
+
+#define DISABLE_WARN_UNUSED_RESULT
+#include <loci/loci.h>
+#include <loci/loci_show.h>
+#include <loci/loci_obj_show.h>
+
+static int
+unknown_show(loci_writer_f writer, void* cookie, of_object_t *obj)
+{
+    return writer(cookie, "Unable to print object of type %d, version %d\\n", 
+                         obj->object_id, obj->version);
+}    
+""")
+
+    for version in of_g.of_version_range:
+        ver_name = loxi_utils.version_to_name(version)
+        for cls in of_g.standard_class_order:
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            if cls in type_maps.inheritance_map:
+                continue
+            out.write("""
+int
+%(cls)s_%(ver_name)s_show(loci_writer_f writer, void* cookie, %(cls)s_t *obj)
+{
+    int out = 0;
+""" % dict(cls=cls, ver_name=ver_name))
+
+            members, member_types = loxi_utils.all_member_types_get(cls, version)
+            for m_type in member_types:
+                if loxi_utils.type_is_scalar(m_type) or m_type in \
+                        ["of_match_t", "of_octets_t"]:
+                    # Declare instance of these
+                    out.write("    %s %s;\n" % (m_type, var_name_map(m_type)))
+                else:
+                    out.write("""
+    %(m_type)s %(v_name)s;
+"""  % dict(m_type=m_type, v_name=var_name_map(m_type)))
+                    if loxi_utils.class_is_list(m_type):
+                        base_type = loxi_utils.list_to_entry_type(m_type)
+                        out.write("    %s elt;\n    int rv;\n" % base_type)
+            for member in members:
+                m_type = member["m_type"]
+                m_name = member["name"]
+                #emitter = "LOCI_SHOW_" + loxi_utils.type_to_short_name(m_type)
+                emitter = "LOCI_SHOW_" + loxi_utils.type_to_short_name(m_type) + "_" + m_name; 
+                if loxi_utils.skip_member_name(m_name):
+                    continue
+                if (loxi_utils.type_is_scalar(m_type) or
+                    m_type in ["of_match_t", "of_octets_t"]):
+                    out.write("""
+    %(cls)s_%(m_name)s_get(obj, &%(v_name)s);
+    out += writer(cookie, "%(m_name)s=");
+    out += %(emitter)s(writer, cookie, %(v_name)s);
+    out += writer(cookie, " "); 
+""" % dict(cls=cls, m_name=m_name, m_type=m_type,
+           v_name=var_name_map(m_type), emitter=emitter))
+                elif loxi_utils.class_is_list(m_type):
+                    sub_cls = m_type[:-2] # Trim _t
+                    elt_type = loxi_utils.list_to_entry_type(m_type)
+                    out.write("""
+    out += writer(cookie, "%(elt_type)s={ ");
+    %(cls)s_%(m_name)s_bind(obj, &%(v_name)s);
+    %(u_type)s_ITER(&%(v_name)s, &elt, rv) {
+        of_object_show(writer, cookie, (of_object_t *)&elt);
+    }
+    out += writer(cookie, "} "); 
+""" % dict(sub_cls=sub_cls, u_type=sub_cls.upper(), v_name=var_name_map(m_type),
+           elt_type=elt_type, cls=cls, m_name=m_name, m_type=m_type))
+                else:
+                    sub_cls = m_type[:-2] # Trim _t
+                    out.write("""
+    %(cls)s_%(m_name)s_bind(obj, &%(v_name)s);
+    out += %(sub_cls)s_%(ver_name)s_show(writer, cookie, &%(v_name)s);
+""" % dict(cls=cls, sub_cls=sub_cls, m_name=m_name, 
+           v_name=var_name_map(m_type), ver_name=ver_name))
+
+            out.write("""
+    return out;
+}
+""")
+    out.write("""
+/**
+ * Log a match entry
+ */
+int
+loci_show_match(loci_writer_f writer, void* cookie, of_match_t *match)
+{
+    int out = 0;
+""")
+
+    for key, entry in match.of_match_members.items():
+        m_type = entry["m_type"]
+        #emitter = "LOCI_SHOW_" + loxi_utils.type_to_short_name(m_type)
+        emitter = "LOCI_SHOW_" + loxi_utils.type_to_short_name(m_type) + "_" + key; 
+        out.write("""
+    if (OF_MATCH_MASK_%(ku)s_ACTIVE_TEST(match)) {
+        out += writer(cookie, "%(key)s active="); 
+        out += %(emitter)s(writer, cookie, match->fields.%(key)s);
+        out += writer(cookie, "/"); 
+        out += %(emitter)s(writer, cookie, match->masks.%(key)s);
+        out += writer(cookie, " ");
+    }
+""" % dict(key=key, ku=key.upper(), emitter=emitter, m_type=m_type))
+
+    out.write("""
+    return out;
+}
+""")
+
+    # Generate big table indexed by version and object
+    for version in of_g.of_version_range:
+        out.write("""
+static loci_obj_show_f show_funs_v%(version)s[OF_OBJECT_COUNT] = {
+""" % dict(version=version))
+        out.write("    unknown_show, /* of_object, not a valid specific type */\n")
+        for j, cls in enumerate(of_g.all_class_order):
+            comma = ""
+            if j < len(of_g.all_class_order) - 1: # Avoid ultimate comma
+                comma = ","
+
+            if (not loxi_utils.class_in_version(cls, version) or 
+                    cls in type_maps.inheritance_map):
+                out.write("    unknown_show%s\n" % comma);
+            else:
+                out.write("    %s_%s_show%s\n" % 
+                          (cls, loxi_utils.version_to_name(version), comma))
+        out.write("};\n\n")
+
+    out.write("""
+static loci_obj_show_f *show_funs[5] = {
+    NULL,
+    show_funs_v1,
+    show_funs_v2,
+    show_funs_v3,
+    show_funs_v4
+};
+
+int
+of_object_show(loci_writer_f writer, void* cookie, of_object_t *obj)
+{
+    if ((obj->object_id > 0) && (obj->object_id < OF_OBJECT_COUNT)) {
+        if (((obj)->version > 0) && ((obj)->version <= OF_VERSION_1_2)) {
+            /* @fixme VERSION */
+            return show_funs[obj->version][obj->object_id](writer, cookie, (of_object_t *)obj);
+        } else {
+            return writer(cookie, "Bad version %d\\n", obj->version);
+        }
+    }
+    return writer(cookie, "Bad object id %d\\n", obj->object_id);
+}
+""")
+
diff --git a/c_gen/c_test_gen.py b/c_gen/c_test_gen.py
new file mode 100644
index 0000000..97cc78d
--- /dev/null
+++ b/c_gen/c_test_gen.py
@@ -0,0 +1,1964 @@
+# Copyright 2013, Big Switch Networks, Inc.
+#
+# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+# the following special exception:
+#
+# LOXI Exception
+#
+# As a special exception to the terms of the EPL, you may distribute libraries
+# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+# that copyright and licensing notices generated by LoxiGen are not altered or removed
+# from the LoxiGen Libraries and the notice provided below is (i) included in
+# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+# documentation for the LoxiGen Libraries, if distributed in binary form.
+#
+# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+#
+# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+# a copy of the EPL at:
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# 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
+# EPL for the specific language governing permissions and limitations
+# under the EPL.
+
+"""
+@brief Test case generation functions
+
+@fixme Update the following
+The following components are generated.
+
+test_common.[ch]:  A collection of common code for tests.  Currently
+this includes the ability to set the scalar members of an object with
+incrementing values and then similarly verify those values
+
+test_scalar_acc.c: Instantiate each type of object, then set and get
+scalar values in the objects.
+
+test_list.c: Instantiate each type of list, add an element of each
+type the list supports, setting scalar values of the elements.
+
+test_match.c: Various tests for match objects
+
+test_msg.c: Instantiate top level messages
+
+These will move towards unified tests that do the following:
+
+Create or init an object.
+Populate the object with incrementing values.
+Possibly transform the object in some way (e.g., run the underlying
+wire buffer through a parse routine).
+Verify that the members all have the appropriate value
+
+Through out, checking the consistency of memory and memory operations
+is done with mcheck (not supported on Mac OS X).
+
+"""
+
+import sys
+import of_g
+import loxi_front_end.match as match
+import loxi_front_end.flags as flags
+from generic_utils import *
+import loxi_front_end.type_maps as type_maps
+import loxi_utils.loxi_utils as loxi_utils
+import loxi_front_end.identifiers as identifiers
+
+def var_name_map(m_type):
+    """
+    Map a type to a generic variable name for the type.
+    @param m_type The data type
+
+    Used mostly in test code generation, but also for the dup functions.
+    """
+    _var_name_map= dict(
+        uint8_t="val8",
+        uint16_t="val16",
+        uint32_t="val32",
+        uint64_t="val64",
+        of_port_no_t="port_no",
+        of_fm_cmd_t="fm_cmd",
+        of_wc_bmap_t="wc_bmap",
+        of_match_bmap_t = "match_bmap",
+        of_port_name_t="port_name", 
+        of_table_name_t="table_name",
+        of_desc_str_t="desc_str",
+        of_serial_num_t="ser_num", 
+        of_mac_addr_t="mac_addr", 
+        of_ipv6_t="ipv6",
+        # Non-scalars; more TBD
+        of_octets_t="octets",
+        of_meter_features_t="features",
+        of_match_t="match")
+
+    if m_type.find("of_list_") == 0:
+        return "list"
+    if m_type in of_g.of_mixed_types:
+        return of_g.of_mixed_types[m_type]["short_name"]
+    return _var_name_map[m_type]
+
+integer_types = ["uint8_t", "uint16_t", "uint32_t", "uint64_t",
+                 "of_port_no_t", "of_fm_cmd_t", "of_wc_bmap_t",
+                 "of_match_bmap_t"]
+string_types = [ "of_port_name_t", "of_table_name_t",
+                "of_desc_str_t", "of_serial_num_t", "of_mac_addr_t", 
+                "of_ipv6_t"]
+
+scalar_types = integer_types[:]
+scalar_types.extend(string_types)
+
+def ignore_member(cls, version, m_name, m_type):
+    """
+    Filter out names or types that either don't have accessors
+    or those that should not be messed with
+    or whose types we're not ready to deal with yet.
+    """
+    # This will probably need more granularity as more extensions are added
+    if (type_maps.class_is_extension(cls, version) and (
+            m_name == "experimenter" or
+            m_name == "subtype")):
+        return True
+    return loxi_utils.skip_member_name(m_name) or m_type not in scalar_types
+
+def gen_fill_string(out):
+    out.write("""
+
+/**
+ * The increment to use on values inside a string
+ */
+#define OF_TEST_STR_INCR 3
+
+/**
+ * Fill in a buffer with incrementing values starting
+ * at the given offset with the given value
+ * @param buf The buffer to fill
+ * @param value The value to use for data
+ * @param len The number of bytes to fill
+ */
+
+void
+of_test_str_fill(uint8_t *buf, int value, int len)
+{
+    int i;
+
+    for (i = 0; i < len; i++) {
+        *buf = value;
+        value += OF_TEST_STR_INCR;
+        buf++;
+    }
+}
+
+/**
+ * Given a buffer, verify that it's filled as above
+ * @param buf The buffer to check
+ * @param value The value to use for data
+ * @param len The number of bytes to fill
+ * @return Boolean True on equality (success)
+ */
+
+int
+of_test_str_check(uint8_t *buf, int value, int len)
+{
+    int i;
+    uint8_t val8;
+
+    val8 = value;
+
+    for (i = 0; i < len; i++) {
+        if (*buf != val8) {
+            return 0;
+        }
+        val8 += OF_TEST_STR_INCR;
+        buf++;
+    }
+
+    return 1;
+}
+
+/**
+ * Global that determines how octets should be populated
+ * -1 means use value % MAX (below) to determine length
+ * 0, 1, ... means used that fixed length
+ *
+ * Note: Was 16K, but that made objects too big.  May add flexibility
+ * to call populate with a max parameter for length
+ */
+int octets_pop_style = -1;
+#define OCTETS_MAX_VALUE (128) /* 16K was too big */
+#define OCTETS_MULTIPLIER 6367 /* A prime */
+
+int
+of_octets_populate(of_octets_t *octets, int value)
+{
+    if (octets_pop_style < 0) {
+        octets->bytes = (value * OCTETS_MULTIPLIER) % OCTETS_MAX_VALUE;
+    } else {
+        octets->bytes = octets_pop_style;
+    }
+
+    if (octets->bytes != 0) {
+        if ((octets->data = (uint8_t *)MALLOC(octets->bytes)) == NULL) {
+            return 0;
+        }
+        of_test_str_fill(octets->data, value, octets->bytes);
+        value += 1;
+    }
+
+    return value;
+}
+
+int
+of_octets_check(of_octets_t *octets, int value)
+{
+    int len;
+
+    if (octets_pop_style < 0) {
+        len =  (value * OCTETS_MULTIPLIER) % OCTETS_MAX_VALUE;
+        TEST_ASSERT(octets->bytes == len);
+    } else {
+        TEST_ASSERT(octets->bytes == octets_pop_style);
+    }
+
+    if (octets->bytes != 0) {
+        TEST_ASSERT(of_test_str_check(octets->data, value, octets->bytes)
+            == 1);
+        value += 1;
+    }
+
+    return value;
+}
+
+int
+of_match_populate(of_match_t *match, of_version_t version, int value)
+{
+    MEMSET(match, 0, sizeof(*match));
+    match->version = version;
+""")
+
+    for key, entry in match.of_match_members.items():
+        out.write("""
+    if (!(of_match_incompat[version] & 
+            OF_OXM_BIT(OF_OXM_INDEX_%(ku)s))) {
+        OF_MATCH_MASK_%(ku)s_EXACT_SET(match);
+        VAR_%(u_type)s_INIT(match->fields.%(key)s, value);
+        value += 1;
+    }
+
+""" % dict(key=key, u_type=entry["m_type"].upper(), ku=key.upper()))
+
+    out.write("""
+    if (value % 2) {
+        /* Sometimes set ipv4 addr masks to non-exact */
+        match->masks.ipv4_src = 0xffff0000;
+        match->masks.ipv4_dst = 0xfffff800;
+    }
+    return value;
+}
+
+int
+of_match_check(of_match_t *match, of_version_t version, int value)
+{
+    of_match_t check;
+
+    value = of_match_populate(&check, match->version, value);
+    TEST_ASSERT(value != 0);
+    TEST_ASSERT(MEMCMP(match, &check, sizeof(check)) == 0);
+
+    return value;
+}
+""")
+
+def gen_common_test_header(out, name):
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""
+/*
+ * Test header file
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ */
+
+#if !defined(_TEST_COMMON_H_)
+#define _TEST_COMMON_H_
+
+#define DISABLE_WARN_UNUSED_RESULT
+#include <loci/loci.h>
+#include <locitest/of_dup.h>
+#include <locitest/unittest.h>
+
+extern int global_error;
+extern int exit_on_error;
+
+/* @todo Make option for -k to continue tests if errors */
+#define RUN_TEST(test) do {                                             \\
+        int rv;                                                         \\
+        TESTCASE(test, rv);                                             \\
+        if (rv != TEST_PASS) {                                          \\
+            global_error=1;                                             \\
+            if (exit_on_error) return(1);                               \\
+        }                                                               \\
+    } while(0)
+
+#define TEST_OK(op) TEST_ASSERT((op) == OF_ERROR_NONE)
+#define TEST_INDIGO_OK(op) TEST_ASSERT((op) == INDIGO_ERROR_NONE)
+
+/*
+ * Declarations of functions to populate scalar values in a a class
+ */
+
+extern void of_test_str_fill(uint8_t *buf, int value, int len);
+extern int of_test_str_check(uint8_t *buf, int value, int len);
+
+
+extern int of_octets_populate(of_octets_t *octets, int value);
+extern int of_octets_check(of_octets_t *octets, int value);
+extern int of_match_populate(of_match_t *match, of_version_t version,
+                             int value);
+extern int of_match_check(of_match_t *match, of_version_t version, int value);
+extern int test_ident_macros(void);
+extern int test_dump_objs(void);
+
+/* In test_match_utils.c */
+extern int test_match_utils(void);
+
+extern int run_unified_accessor_tests(void);
+extern int run_match_tests(void);
+extern int run_utility_tests(void);
+
+extern int run_scalar_acc_tests(void);
+extern int run_list_tests(void);
+extern int run_message_tests(void);
+extern int run_setup_from_add_tests(void);
+
+extern int run_validator_tests(void);
+
+extern int run_list_limits_tests(void);
+
+extern int test_ext_objs(void);
+
+""")
+
+    for version in of_g.of_version_range:
+        for cls in of_g.standard_class_order:
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            if cls in type_maps.inheritance_map:
+                continue
+            out.write("""
+extern int %(cls)s_%(v_name)s_populate(
+    %(cls)s_t *obj, int value);
+extern int %(cls)s_%(v_name)s_check(
+    %(cls)s_t *obj, int value);
+extern int %(cls)s_%(v_name)s_populate_scalars(
+    %(cls)s_t *obj, int value);
+extern int %(cls)s_%(v_name)s_check_scalars(
+    %(cls)s_t *obj, int value);
+""" % dict(cls=cls, v_name=loxi_utils.version_to_name(version)))
+
+    out.write("""
+/*
+ * Declarations for list population and check primitives
+ */
+""")
+ 
+    for version in of_g.of_version_range:
+        for cls in of_g.ordered_list_objects:
+            if cls in type_maps.inheritance_map:
+                continue
+
+            if version in of_g.unified[cls]:
+               out.write("""
+extern int
+    list_setup_%(cls)s_%(v_name)s(
+    %(cls)s_t *list, int value);
+extern int
+    list_check_%(cls)s_%(v_name)s(
+    %(cls)s_t *list, int value);
+""" % dict(cls=cls, v_name=loxi_utils.version_to_name(version)))
+
+    out.write("\n#endif /* _TEST_COMMON_H_ */\n")
+
+def gen_common_test(out, name):
+    """
+    Generate common test content including main
+    """
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""
+/*
+ * Common test code for LOCI
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ */
+
+#define DISABLE_WARN_UNUSED_RESULT
+#include "loci_log.h"
+#include <loci/loci_obj_dump.h>
+#include <locitest/unittest.h>
+#include <locitest/test_common.h>
+
+#if !defined(__APPLE__)
+#include <mcheck.h>
+#define MCHECK_INIT mcheck(NULL)
+#else /* mcheck not available under OS X */
+#define MCHECK_INIT do { } while (0)
+#endif
+
+/**
+ * Exit on error if set to 1
+ */
+int exit_on_error = 1;
+
+/**
+ * Global error state: 0 is okay, 1 is error 
+ */
+int global_error = 0;
+
+extern int run_unified_accessor_tests(void);
+extern int run_match_tests(void);
+extern int run_utility_tests(void);
+
+extern int run_scalar_acc_tests(void);
+extern int run_list_tests(void);
+extern int run_message_tests(void);
+
+/**
+ * Macros for initializing and checking scalar types
+ *
+ * @param var The variable being initialized or checked
+ * @param val The integer value to set/check against, see below
+ *
+ * Note that equality means something special for strings.  Each byte
+ * is initialized to an incrementing value.  So check is done against that.
+ *
+ */
+
+""")
+    for t in scalar_types:
+        if t in integer_types:
+            out.write("""
+#define VAR_%s_INIT(var, val) var = (%s)(val)
+#define VAR_%s_CHECK(var, val) ((var) == (%s)(val))
+""" % (t.upper(), t, t.upper(), t))
+        else:
+            out.write("""
+#define VAR_%s_INIT(var, val) \\
+    of_test_str_fill((uint8_t *)&(var), val, sizeof(var))
+#define VAR_%s_CHECK(var, val) \\
+    of_test_str_check((uint8_t *)&(var), val, sizeof(var))
+""" % (t.upper(), t.upper()))
+
+    gen_fill_string(out)
+    gen_scalar_set_check_funs(out)
+    gen_list_set_check_funs(out)
+    gen_unified_accessor_funs(out)
+
+    gen_ident_tests(out)
+    gen_log_test(out)
+
+def gen_message_scalar_test(out, name):
+    """
+    Generate test cases for message objects, scalar accessors
+    """
+
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""
+/**
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ *
+ * Message-scalar tests for all versions
+ */
+
+#include <locitest/test_common.h>
+""")
+    for version in of_g.of_version_range:
+        v_name = loxi_utils.version_to_name(version)
+        out.write("""
+/**
+ * Message-scalar tests for version %s
+ */
+""" % v_name)
+        for cls in of_g.standard_class_order:
+            if cls in type_maps.inheritance_map:
+                continue
+            if version in of_g.unified[cls]:
+                message_scalar_test(out, version, cls)
+
+    out.write("""
+int
+run_scalar_acc_tests(void)
+{
+""")
+    for version in of_g.of_version_range:
+        v_name = loxi_utils.version_to_name(version)
+        for cls in of_g.standard_class_order:
+            if cls in type_maps.inheritance_map:
+                continue
+            if version in of_g.unified[cls]:
+                test_name = "%s_%s" % (cls, v_name)
+                out.write("    RUN_TEST(%s_scalar);\n" % test_name)
+
+    out.write("    return TEST_PASS;\n}\n");
+    
+def message_scalar_test(out, version, cls):
+    """
+    Generate one test case for the given version and class
+    """
+
+    members, member_types = scalar_member_types_get(cls, version)
+    length = of_g.base_length[(cls, version)]
+    v_name = loxi_utils.version_to_name(version)
+
+    out.write("""
+static int
+test_%(cls)s_%(v_name)s_scalar(void)
+{
+    %(cls)s_t *obj;
+
+    obj = %(cls)s_new(%(v_name)s);
+    TEST_ASSERT(obj != NULL);
+    TEST_ASSERT(obj->version == %(v_name)s);
+    TEST_ASSERT(obj->length == %(length)d);
+    TEST_ASSERT(obj->parent == NULL);
+    TEST_ASSERT(obj->object_id == %(u_cls)s);
+""" % dict(cls=cls, u_cls=cls.upper(), 
+           v_name=v_name, length=length, version=version))
+    if not type_maps.class_is_virtual(cls):
+        out.write("""
+    if (obj->wire_length_get != NULL) {
+        int length;
+
+        obj->wire_length_get((of_object_t *)obj, &length);
+        TEST_ASSERT(length == %(length)d);
+    }
+
+    /* Set up incrementing values for scalar members */
+    %(cls)s_%(v_name)s_populate_scalars(obj, 1);
+
+    /* Check values just set */
+    TEST_ASSERT(%(cls)s_%(v_name)s_check_scalars(obj, 1) != 0);
+""" % dict(cls=cls, u_cls=cls.upper(), 
+           v_name=v_name, length=length, version=version))
+
+    out.write("""
+    %(cls)s_delete(obj);
+
+    /* To do: Check memory */
+    return TEST_PASS;
+}
+""" % dict(cls=cls))
+
+# Get the members and list of scalar types for members of a given class
+def scalar_member_types_get(cls, version):
+    member_types = []
+
+    if not version in of_g.unified[cls]:
+        return ([], [])
+
+    if "use_version" in of_g.unified[cls][version]:
+        v = of_g.unified[cls][version]["use_version"]
+        members = of_g.unified[cls][v]["members"]
+    else:
+        members = of_g.unified[cls][version]["members"]
+    # Accumulate variables that are supported
+    for member in members:
+        m_type = member["m_type"]
+        m_name = member["name"]
+        if (not loxi_utils.type_is_scalar(m_type) or 
+            ignore_member(cls, version, m_name, m_type)):
+            continue
+        if not m_type in member_types:
+            member_types.append(m_type)
+
+    return (members, member_types)
+
+def scalar_funs_instance(out, cls, version, members, member_types):
+    """
+    Generate one instance of scalar set/check functions
+    """
+    out.write("""
+/**
+ * Populate the scalar values in obj of type %(cls)s, 
+ * version %(v_name)s 
+ * @param obj Pointer to an object to populate
+ * @param value The seed value to use in populating the object
+ * @returns The value after increments for this object's values
+ */
+int %(cls)s_%(v_name)s_populate_scalars(
+    %(cls)s_t *obj, int value) {
+""" % dict(cls=cls, v_name=loxi_utils.version_to_name(version)))
+    # Declare string types
+    for t in member_types:
+        out.write("    %s %s;\n" % (t, var_name_map(t)))
+    for member in members:
+        m_type = member["m_type"]
+        m_name = member["name"]
+        if (not loxi_utils.type_is_scalar(m_type) or
+            ignore_member(cls, version, m_name, m_type)):
+            continue
+        v_name = var_name_map(m_type);
+        out.write("""
+    VAR_%(u_type)s_INIT(%(v_name)s, value);
+    %(cls)s_%(m_name)s_set(obj, %(v_name)s);
+    value += 1;
+""" % dict(cls=cls, m_name=m_name, u_type=m_type.upper(), v_name=v_name))
+    out.write("""
+    return value;
+}
+""")
+    
+    out.write("""
+/**
+ * Check scalar values in obj of type %(cls)s, 
+ * version %(v_name)s 
+ * @param obj Pointer to an object to check
+ * @param value Starting value for checking
+ * @returns The value after increments for this object's values
+ */
+int %(cls)s_%(v_name)s_check_scalars(
+    %(cls)s_t *obj, int value) {
+""" % dict(cls=cls, v_name=loxi_utils.version_to_name(version)))
+
+    for t in member_types:
+        out.write("    %s %s;\n" % (t, var_name_map(t)))
+    for member in members:
+        m_type = member["m_type"]
+        m_name = member["name"]
+        if (not loxi_utils.type_is_scalar(m_type) or
+            ignore_member(cls, version, m_name, m_type)):
+            continue
+        v_name = var_name_map(m_type);
+        out.write("""
+    %(cls)s_%(m_name)s_get(obj, &%(v_name)s);
+    TEST_ASSERT(VAR_%(u_type)s_CHECK(%(v_name)s, value));
+    value += 1;
+""" % dict(cls=cls, m_name=m_name, u_type=m_type.upper(), v_name=v_name))
+
+    out.write("""
+    return value;
+}
+
+""")
+
+def gen_scalar_set_check_funs(out):
+    """
+    For each object class with scalar members, generate functions that 
+    set and check their values
+    """
+    for version in of_g.of_version_range:
+        for cls in of_g.standard_class_order:
+            (members, member_types) = scalar_member_types_get(cls, version)
+            scalar_funs_instance(out, cls, version, members, member_types)
+
+
+# Helper function to set up a subclass instance for a test
+def setup_instance(out, cls, subcls, instance, v_name, inst_len, version):
+    base_type = loxi_utils.list_to_entry_type(cls)
+    setup_template = """
+    %(subcls)s_init(%(inst)s, %(v_name)s, -1, 1);
+    %(cls)s_append_bind(list, 
+            (%(base_type)s_t *)%(inst)s);
+    value = %(subcls)s_%(v_name)s_populate(
+        %(inst)s, value);
+    cur_len += %(inst)s->length;
+    TEST_ASSERT(list->length == cur_len);
+"""
+    out.write("""
+    /* Append two instances of type %s */
+""" % subcls)
+    for i in range(2):
+        out.write(setup_template %
+                  dict(inst=instance, subcls=subcls, v_name=v_name, 
+                       base_type=base_type, cls=cls, inst_len=inst_len, 
+                       version=version))
+
+def check_instance(out, cls, subcls, instance, v_name, inst_len, version, last):
+    check_template = ""
+    if inst_len >= 0:
+        check_template = """
+    TEST_ASSERT(%(inst)s->length == %(inst_len)d);
+    if (%(inst)s->wire_length_get != NULL) {
+        int length;
+
+        %(inst)s->wire_length_get(
+            (of_object_t *)&elt, &length);
+        TEST_ASSERT(length == %(inst_len)d);
+    }
+"""
+    check_template += """
+    TEST_ASSERT(%(inst)s->object_id == %(elt_name)s);
+    value = %(subcls)s_%(v_name)s_check(
+        %(inst)s, value);
+    TEST_ASSERT(value != 0);
+"""
+    out.write("\n    /* Check two instances of type %s */" % instance)
+
+    out.write(check_template % 
+              dict(elt_name=loxi_utils.enum_name(subcls), inst_len=inst_len,
+                   inst=instance, subcls=subcls,
+                   v_name=loxi_utils.version_to_name(version)))
+    out.write("""\
+    TEST_OK(%(cls)s_next(list, &elt));
+""" % dict(cls=cls))
+
+    out.write(check_template % 
+              dict(elt_name=loxi_utils.enum_name(subcls), inst_len=inst_len,
+                   inst=instance, subcls=subcls,
+                   v_name=loxi_utils.version_to_name(version)))
+    if last:
+        out.write("""\
+    TEST_ASSERT(%(cls)s_next(list, &elt) == OF_ERROR_RANGE);
+""" % dict(cls=cls))
+    else:
+        out.write("""\
+    TEST_OK(%(cls)s_next(list, &elt));
+""" % dict(cls=cls))
+
+def setup_list_fn(out, version, cls):
+    """
+    Generate a helper function that populates a list with two
+    of each type of subclass it supports
+    """
+    out.write("""
+/**
+ * Set up a list of type %(cls)s with two of each type of subclass
+ */
+int
+list_setup_%(cls)s_%(v_name)s(
+    %(cls)s_t *list, int value)
+{
+""" % dict(cls=cls, v_name=loxi_utils.version_to_name(version)))
+    base_type = loxi_utils.list_to_entry_type(cls)
+    out.write("""
+    %(base_type)s_t elt;
+    int cur_len = 0;
+""" % dict(cls=cls, base_type=base_type))
+    
+    sub_classes =  type_maps.sub_class_map(base_type, version)
+    v_name = loxi_utils.version_to_name(version)
+
+    if len(sub_classes) == 0:
+        out.write("    /* No subclasses for %s */\n"% base_type)
+        out.write("    %s_t *elt_p;\n" % base_type)
+        out.write("\n    elt_p = &elt;\n")
+    else:
+        out.write("    /* Declare pointers for each subclass */\n")
+        for instance, subcls in sub_classes:
+            out.write("    %s_t *%s;\n" % (subcls, instance))
+        out.write("\n    /* Instantiate pointers for each subclass */\n")
+        for instance, subcls in sub_classes:
+            out.write("    %s = &elt.%s;\n" % (instance, instance))
+
+    if len(sub_classes) == 0: # No inheritance case
+        inst_len = loxi_utils.base_type_to_length(base_type, version)
+        setup_instance(out, cls, base_type, "elt_p", v_name, inst_len, version)
+    else:
+        for instance, subcls in sub_classes:
+            inst_len = of_g.base_length[(subcls, version)]
+            setup_instance(out, cls, subcls, instance, v_name, inst_len, version)
+    out.write("""
+
+    return value;
+}
+""")
+
+def check_list_fn(out, version, cls):
+    """
+    Generate a helper function that checks a list populated by above fn
+    """
+    out.write("""
+/**
+ * Check a list of type %(cls)s generated by 
+ * list_setup_%(cls)s_%(v_name)s
+ */
+int
+list_check_%(cls)s_%(v_name)s(
+    %(cls)s_t *list, int value)
+{
+""" % dict(cls=cls, v_name=loxi_utils.version_to_name(version)))
+    base_type = loxi_utils.list_to_entry_type(cls)
+    out.write("""
+    %(base_type)s_t elt;
+""" % dict(cls=cls, base_type=base_type))
+    
+    sub_classes =  type_maps.sub_class_map(base_type, version)
+    v_name = loxi_utils.version_to_name(version)
+
+    if len(sub_classes) == 0:
+        out.write("    /* No subclasses for %s */\n"% base_type)
+        out.write("    %s_t *elt_p;\n" % base_type)
+        out.write("\n    elt_p = &elt;\n")
+    else:
+        out.write("    /* Declare pointers for each subclass */\n")
+        for instance, subcls in sub_classes:
+            out.write("    %s_t *%s;\n" % (subcls, instance))
+        out.write("\n    /* Instantiate pointers for each subclass */\n")
+        for instance, subcls in sub_classes:
+            out.write("    %s = &elt.%s;\n" % (instance, instance))
+
+    out.write("    TEST_OK(%(cls)s_first(list, &elt));\n" % dict(cls=cls))
+    if len(sub_classes) == 0: # No inheritance case
+        if loxi_utils.class_is_var_len(base_type, version):
+            inst_len = -1
+        else:
+            inst_len = loxi_utils.base_type_to_length(base_type, version)
+        check_instance(out, cls, base_type, "elt_p", v_name, inst_len, 
+                       version, True)
+    else:
+        count = 0
+        for instance, subcls in sub_classes:
+            count += 1
+            if loxi_utils.class_is_var_len(subcls, version):
+                inst_len = -1
+            else:
+                inst_len = of_g.base_length[(subcls, version)]
+            check_instance(out, cls, subcls, instance, v_name, inst_len, 
+                           version, count==len(sub_classes))
+
+    out.write("""
+    return value;
+}
+""" % dict(base_type=base_type))
+
+def gen_list_set_check_funs(out):
+    for version in of_g.of_version_range:
+        for cls in of_g.ordered_list_objects:
+            if cls in type_maps.inheritance_map:
+                continue
+
+            if version in of_g.unified[cls]:
+                setup_list_fn(out, version, cls)
+                check_list_fn(out, version, cls)
+
+# Maybe: Get a map from list class to parent, mem_name of container
+
+def list_test(out, version, cls):
+    out.write("""
+static int
+test_%(cls)s_%(v_name)s(void)
+{
+""" % dict(cls=cls, v_name=loxi_utils.version_to_name(version)))
+    base_type = loxi_utils.list_to_entry_type(cls)
+
+    out.write("""    %(cls)s_t *list;
+    int value = 1;
+""" % dict(cls=cls, base_type=base_type))
+
+    out.write("""
+    list = %(cls)s_new(%(v_name)s);
+    TEST_ASSERT(list != NULL);
+    TEST_ASSERT(list->version == %(v_name)s);
+    TEST_ASSERT(list->length == 0);
+    TEST_ASSERT(list->parent == NULL);
+    TEST_ASSERT(list->object_id == %(enum_cls)s);
+
+    value = list_setup_%(cls)s_%(v_name)s(list, value);
+    TEST_ASSERT(value != 0);
+""" % dict(cls=cls, base_type=base_type, v_name=loxi_utils.version_to_name(version), 
+           enum_cls=loxi_utils.enum_name(cls)))
+
+    out.write("""
+    /* Now check values */
+    value = 1;
+    value = list_check_%(cls)s_%(v_name)s(list, value);
+    TEST_ASSERT(value != 0);
+""" % dict(cls=cls, v_name=loxi_utils.version_to_name(version)))
+
+    out.write("""
+    %(cls)s_delete(list);
+
+    return TEST_PASS;
+}
+""" % dict(cls=cls))
+
+def gen_list_test(out, name):
+    """
+    Generate base line test cases for lists
+    @param out The file handle to write to
+    """
+
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""
+/**
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ *
+ * Message-scalar tests for all versions
+ */
+
+#include <locitest/test_common.h>
+""")
+    
+    for version in of_g.of_version_range:
+        v_name = loxi_utils.version_to_name(version)
+        out.write("""
+/**
+ * Baseline list tests for version %s
+ */
+""" % v_name)
+        for cls in of_g.ordered_list_objects:
+            if cls in type_maps.inheritance_map:
+                continue
+            if version in of_g.unified[cls]:
+                list_test(out, version, cls)
+
+    out.write("""
+int
+run_list_tests(void)
+{
+""")
+    for version in of_g.of_version_range:
+        v_name = loxi_utils.version_to_name(version)
+        for cls in of_g.ordered_list_objects:
+            if cls in type_maps.inheritance_map:
+                continue
+            if version in of_g.unified[cls]:
+                test_name = "%s_%s" % (cls, v_name)
+                out.write("    RUN_TEST(%s);\n" % test_name)
+
+    out.write("\n    return TEST_PASS;\n}\n");
+
+def gen_match_test(out, name):
+    """
+    Generate baseline tests for match functions
+    """
+
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""\
+/**
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ *
+ * Message-scalar tests for all versions
+ * @fixme These are mostly hard coded now.
+ */
+
+#include <locitest/test_common.h>
+
+static int
+test_match_1(void)
+{
+    of_match_v1_t *m_v1;
+    of_match_v2_t *m_v2;
+    of_match_v3_t *m_v3;
+    of_match_v4_t *m_v4;
+    of_match_t match;
+    int value = 1;
+    int idx;
+    uint32_t exp_value;
+
+    /* Verify default values for ip mask map */
+    for (idx = 0; idx < OF_IP_MASK_MAP_COUNT; idx++) {
+        exp_value = (idx < 32) ? ~((1 << idx) - 1) : 0;
+        TEST_ASSERT(of_ip_index_to_mask(idx) == exp_value);
+        if (idx < 32) {
+            TEST_ASSERT(of_ip_mask_to_index(exp_value) == idx);
+        }
+    }
+
+    TEST_ASSERT(of_ip_mask_map_set(17, 0xabcdef00) == OF_ERROR_NONE);
+    TEST_ASSERT(of_ip_mask_to_index(0xabcdef00) == 17);
+    TEST_ASSERT(of_ip_index_to_mask(17) == 0xabcdef00);
+
+    TEST_ASSERT(of_ip_mask_map_set(62, 0xabcdefff) == OF_ERROR_NONE);
+    TEST_ASSERT(of_ip_mask_to_index(0xabcdefff) == 62);
+    TEST_ASSERT(of_ip_index_to_mask(62) == 0xabcdefff);
+
+    /* Test re-init */
+    of_ip_mask_map_init();
+    for (idx = 0; idx < OF_IP_MASK_MAP_COUNT; idx++) {
+        exp_value = (idx < 32) ? ~((1 << idx) - 1) : 0;
+        TEST_ASSERT(of_ip_index_to_mask(idx) == exp_value);
+        if (idx < 32) {
+            TEST_ASSERT(of_ip_mask_to_index(exp_value) == idx);
+        }
+    }
+""")
+
+    for version in of_g.of_version_range:
+        out.write("""
+    /* Create/populate/convert and delete for version %(v_name)s */
+    m_v%(version)d = of_match_v%(version)d_new(%(v_name)s);
+    TEST_ASSERT(m_v%(version)d != NULL);
+    TEST_ASSERT((value = of_match_populate(&match, %(v_name)s, value)) > 0);
+    TEST_OK(of_match_to_wire_match_v%(version)d(&match, m_v%(version)d));
+    of_match_v%(version)d_delete(m_v%(version)d);
+""" % dict(v_name=loxi_utils.version_to_name(version), version=version))
+
+    out.write("""
+    return TEST_PASS;
+}
+""")
+
+    out.write("""
+static int
+test_match_2(void)
+{
+    of_match_v1_t *m_v1;
+    of_match_v2_t *m_v2;
+    of_match_v3_t *m_v3;
+    of_match_v3_t *m_v4;
+    of_match_t match1;
+    of_match_t match2;
+    int value = 1;
+""")
+
+    for version in of_g.of_version_range:
+        out.write("""
+    TEST_ASSERT((value = of_match_populate(&match1, %(v_name)s, value)) > 0);
+    m_v%(version)d = of_match_v%(version)d_new(%(v_name)s);
+    TEST_ASSERT(m_v%(version)d != NULL);
+    TEST_OK(of_match_to_wire_match_v%(version)d(&match1, m_v%(version)d));
+    TEST_OK(of_match_v%(version)d_to_match(m_v%(version)d, &match2));
+    TEST_ASSERT(memcmp(&match1, &match2, sizeof(match1)) == 0);
+    of_match_v%(version)d_delete(m_v%(version)d);
+""" % dict(v_name=loxi_utils.version_to_name(version), version=version))
+
+    out.write("""
+    return TEST_PASS;
+}
+""")
+
+    out.write("""
+static int
+test_match_3(void)
+{
+    of_match_t match1;
+    of_match_t match2;
+    int value = 1;
+    of_octets_t octets;
+""")
+    for version in of_g.of_version_range:
+        out.write("""
+    /* Serialize to version %(v_name)s */
+    TEST_ASSERT((value = of_match_populate(&match1, %(v_name)s, value)) > 0);
+    TEST_ASSERT(of_match_serialize(%(v_name)s, &match1, &octets) == 
+        OF_ERROR_NONE);
+    TEST_ASSERT(of_match_deserialize(%(v_name)s, &match2, &octets) == 
+        OF_ERROR_NONE);
+    TEST_ASSERT(memcmp(&match1, &match2, sizeof(match1)) == 0);
+    FREE(octets.data);
+""" % dict(v_name=loxi_utils.version_to_name(version), version=version))
+
+    out.write("""
+    return TEST_PASS;
+}
+""")
+
+    out.write("""
+int run_match_tests(void)
+{
+    RUN_TEST(match_1);
+    RUN_TEST(match_2);
+    RUN_TEST(match_3);
+    RUN_TEST(match_utils);
+
+    return TEST_PASS;
+}
+""")
+
+def gen_msg_test(out, name):
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""
+/**
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ *
+ * Message-scalar tests for all versions
+ */
+
+#include <locitest/test_common.h>
+""")
+    for version in of_g.of_version_range:
+        for cls in of_g.ordered_messages:
+            if not (cls, version) in of_g.base_length:
+                continue
+            bytes = of_g.base_length[(cls, version)]
+            out.write("""
+static int
+test_%(cls)s_create_%(v_name)s(void)
+{
+    %(cls)s_t *obj;
+    uint8_t *msg_buf;
+    int value;
+    int len;
+
+    obj = %(cls)s_new(%(v_name)s);
+    TEST_ASSERT(obj != NULL);
+    TEST_ASSERT(obj->version == %(v_name)s);
+    TEST_ASSERT(obj->length == %(bytes)d);
+    TEST_ASSERT(obj->parent == NULL);
+    TEST_ASSERT(obj->object_id == %(enum)s);
+
+    /* Set up incrementing values for scalar members */
+    value = %(cls)s_%(v_name)s_populate_scalars(obj, 1);
+    TEST_ASSERT(value != 0);
+
+    /* Grab the underlying buffer from the message */
+    len = obj->length;
+    of_object_wire_buffer_steal((of_object_t *)obj, &msg_buf);
+    TEST_ASSERT(msg_buf != NULL);
+    %(cls)s_delete(obj);
+    /* TODO:  */
+    TEST_ASSERT(of_message_to_object_id(msg_buf, len) == %(enum)s);
+    obj = %(cls)s_new_from_message(OF_BUFFER_TO_MESSAGE(msg_buf));
+
+    TEST_ASSERT(obj != NULL);
+
+    /* @fixme Set up all message objects (recursively?) */
+
+    value = %(cls)s_%(v_name)s_check_scalars(obj, 1);
+    TEST_ASSERT(value != 0);
+
+    %(cls)s_delete(obj);
+
+    return TEST_PASS;
+}
+""" % dict(cls=cls, version=version, enum=loxi_utils.enum_name(cls),
+           v_name=loxi_utils.version_to_name(version), bytes=bytes))
+
+    out.write("""
+int
+run_message_tests(void)
+{
+""")
+    for version in of_g.of_version_range:
+        for cls in of_g.ordered_messages:
+            if not (cls, version) in of_g.base_length:
+                continue
+            test_name = "%s_create_%s" % (cls, loxi_utils.version_to_name(version))
+            out.write("    RUN_TEST(%s);\n" % test_name)
+
+    out.write("\n    return TEST_PASS;\n}\n");
+        
+
+def gen_list_setup_check(out, cls, version):
+    """
+    Generate functions that populate and check a list with two
+    of each type of subclass it supports
+    """
+    out.write("""
+/**
+ * Populate a list of type %(cls)s with two of each type of subclass
+ * @param list Pointer to the list to be populated
+ * @param value The seed value to use in populating the list
+ * @returns The value after increments for this object's values
+ */
+int
+%(cls)s_%(v_name)s_populate(
+    %(cls)s_t *list, int value)
+{
+""" % dict(cls=cls, v_name=loxi_utils.version_to_name(version)))
+    base_type = loxi_utils.list_to_entry_type(cls)
+    out.write("""
+    %(base_type)s_t elt;
+    int cur_len = 0;
+""" % dict(cls=cls, base_type=base_type))
+    
+    sub_classes =  type_maps.sub_class_map(base_type, version)
+    v_name = loxi_utils.version_to_name(version)
+
+    if len(sub_classes) == 0:
+        out.write("    /* No subclasses for %s */\n"% base_type)
+        out.write("    %s_t *elt_p;\n" % base_type)
+        out.write("\n    elt_p = &elt;\n")
+    else:
+        out.write("    /* Declare pointers for each subclass */\n")
+        for instance, subcls in sub_classes:
+            out.write("    %s_t *%s;\n" % (subcls, instance))
+        out.write("\n    /* Instantiate pointers for each subclass */\n")
+        for instance, subcls in sub_classes:
+            out.write("    %s = &elt.%s;\n" % (instance, instance))
+
+#     if type_maps.class_is_virtual(base_type):
+#         out.write("""\
+#     TEST_OK(%(base_type)s_header_init(
+#         (%(base_type)s_header_t *)&elt, %(v_name)s, -1, 1));
+# """ % dict(base_type=base_type, v_name=loxi_utils.version_to_name(version)))
+#     else:
+#         out.write("""\
+#     TEST_OK(%(base_type)s_init(&elt, %(v_name)s, -1, 1));
+# """ % dict(base_type=base_type, v_name=loxi_utils.version_to_name(version)))
+
+    if len(sub_classes) == 0: # No inheritance case
+        inst_len = loxi_utils.base_type_to_length(base_type, version)
+        setup_instance(out, cls, base_type, "elt_p", v_name, inst_len, version)
+    else:
+        for instance, subcls in sub_classes:
+            inst_len = of_g.base_length[(subcls, version)]
+            setup_instance(out, cls, subcls, instance, v_name, 
+                           inst_len, version)
+    out.write("""
+    return value;
+}
+""")
+    out.write("""
+/**
+ * Check a list of type %(cls)s generated by 
+ * %(cls)s_%(v_name)s_populate
+ * @param list Pointer to the list that was populated
+ * @param value Starting value for checking
+ * @returns The value after increments for this object's values
+ */
+int
+%(cls)s_%(v_name)s_check(
+    %(cls)s_t *list, int value)
+{
+""" % dict(cls=cls, v_name=loxi_utils.version_to_name(version)))
+    base_type = loxi_utils.list_to_entry_type(cls)
+    out.write("""
+    %(base_type)s_t elt;
+    int count = 0;
+    int rv;
+""" % dict(cls=cls, base_type=base_type))
+    
+
+    sub_classes =  type_maps.sub_class_map(base_type, version)
+    v_name = loxi_utils.version_to_name(version)
+
+    if len(sub_classes) == 0:
+        entry_count = 2
+        out.write("    /* No subclasses for %s */\n"% base_type)
+        out.write("    %s_t *elt_p;\n" % base_type)
+        out.write("\n    elt_p = &elt;\n")
+    else:
+        entry_count = 2 * len(sub_classes) # Two of each type appended
+        out.write("    /* Declare pointers for each subclass */\n")
+        for instance, subcls in sub_classes:
+            out.write("    %s_t *%s;\n" % (subcls, instance))
+        out.write("\n    /* Instantiate pointers for each subclass */\n")
+        for instance, subcls in sub_classes:
+            out.write("    %s = &elt.%s;\n" % (instance, instance))
+
+    out.write("    TEST_OK(%(cls)s_first(list, &elt));\n" % dict(cls=cls))
+    if len(sub_classes) == 0: # No inheritance case
+        if loxi_utils.class_is_var_len(base_type, version):
+            inst_len = -1
+        else:
+            inst_len = loxi_utils.base_type_to_length(base_type, version)
+        check_instance(out, cls, base_type, "elt_p", v_name, inst_len, 
+                       version, True)
+    else:
+        count = 0
+        for instance, subcls in sub_classes:
+            count += 1
+            if loxi_utils.class_is_var_len(subcls, version):
+                inst_len = -1
+            else:
+                inst_len = of_g.base_length[(subcls, version)]
+            check_instance(out, cls, subcls, instance, v_name, inst_len, 
+                           version, count==len(sub_classes))
+    out.write("""
+""" % dict(base_type=base_type))
+
+    out.write("""
+    /* Do an iterate to test the iterator */
+    %(u_cls)s_ITER(list, &elt, rv) {
+        count += 1;
+    }
+
+    TEST_ASSERT(rv == OF_ERROR_RANGE);
+    TEST_ASSERT(count == %(entry_count)d);
+
+    /* We shoehorn a test of the dup functions here */
+    {
+        %(cls)s_t *dup;
+
+        TEST_ASSERT((dup = %(cls)s_dup(list)) != NULL);
+        TEST_ASSERT(dup->length == list->length);
+        TEST_ASSERT(dup->object_id == list->object_id);
+        TEST_ASSERT(dup->version == list->version);
+        TEST_ASSERT(MEMCMP(OF_OBJECT_BUFFER_INDEX(dup, 0),
+            OF_OBJECT_BUFFER_INDEX(list, 0), list->length) == 0);
+        of_object_delete((of_object_t *)dup);
+
+        /* And now for the generic dup function */
+        TEST_ASSERT((dup = (%(cls)s_t *)
+            of_object_dup(list)) != NULL);
+        TEST_ASSERT(dup->length == list->length);
+        TEST_ASSERT(dup->object_id == list->object_id);
+        TEST_ASSERT(dup->version == list->version);
+        TEST_ASSERT(MEMCMP(OF_OBJECT_BUFFER_INDEX(dup, 0),
+            OF_OBJECT_BUFFER_INDEX(list, 0), list->length) == 0);
+        of_object_delete((of_object_t *)dup);
+    }
+
+    return value;
+}
+""" % dict(cls=cls, u_cls=cls.upper(), entry_count=entry_count))
+
+
+def gen_class_setup_check(out, cls, version):
+    out.write("""
+/**
+ * Populate all members of an object of type %(cls)s
+ * with incrementing values
+ * @param obj Pointer to an object to populate
+ * @param value The seed value to use in populating the object
+ * @returns The value after increments for this object's values
+ */
+
+int
+%(cls)s_%(v_name)s_populate(
+    %(cls)s_t *obj, int value)
+{
+""" % dict(cls=cls, v_name=loxi_utils.version_to_name(version)))
+    members, member_types = loxi_utils.all_member_types_get(cls, version)
+    for m_type in member_types:
+        if loxi_utils.type_is_scalar(m_type) or m_type in ["of_match_t", "of_octets_t"]:
+            out.write("    %s %s;\n" % (m_type, var_name_map(m_type)))
+        else:
+            out.write("    %s *%s;\n" % (m_type, var_name_map(m_type)))
+    out.write("""
+    /* Run thru accessors after new to ensure okay */
+""")
+    for member in members:
+        m_type = member["m_type"]
+        m_name = member["name"]
+        if loxi_utils.skip_member_name(m_name):
+            continue
+        if loxi_utils.type_is_scalar(m_type) or m_type in ["of_match_t", "of_octets_t"]:
+            out.write("""\
+    %(cls)s_%(m_name)s_get(obj, &%(var_name)s);
+""" % dict(var_name=var_name_map(m_type), cls=cls, m_name=m_name))
+        else:
+            sub_cls = m_type[:-2] # Trim _t
+            out.write("""\
+    {
+        %(sub_cls)s_t sub_cls;
+
+        /* Test bind */
+        %(cls)s_%(m_name)s_bind(obj, &sub_cls);
+    }
+""" % dict(var_name=var_name_map(m_type), cls=cls, 
+           m_name=m_name, sub_cls=sub_cls,
+           v_name=loxi_utils.version_to_name(version)))
+
+    out.write("""
+    value = %(cls)s_%(v_name)s_populate_scalars(
+        obj, value);
+    TEST_ASSERT(value != 0);
+""" % dict(cls=cls, v_name=loxi_utils.version_to_name(version)))
+
+    for member in members:
+        m_type = member["m_type"]
+        m_name = member["name"]
+        if loxi_utils.type_is_scalar(m_type): # Handled by call to scalar setup
+            continue
+        if loxi_utils.skip_member_name(m_name):
+            continue
+        if m_type == "of_match_t":
+            out.write("""\
+    value = of_match_populate(&%(var_name)s, %(v_name)s, value);
+    TEST_ASSERT(value != 0);
+    %(cls)s_%(m_name)s_set(
+        obj, &%(var_name)s);
+""" % dict(cls=cls, var_name=var_name_map(m_type), 
+           m_name=m_name, v_name=loxi_utils.version_to_name(version)))
+        elif m_type == "of_octets_t":
+            out.write("""\
+    value = of_octets_populate(&%(var_name)s, value);
+    TEST_ASSERT(value != 0);
+    %(cls)s_%(m_name)s_set(
+        obj, &%(var_name)s);
+    if (octets.bytes) {
+        FREE(octets.data);
+    }
+""" % dict(var_name=var_name_map(m_type), cls=cls, m_name=m_name))
+        else:
+            sub_cls = m_type[:-2] # Trim _t
+            out.write("""
+    %(var_name)s = %(sub_cls)s_new(%(v_name)s);
+    TEST_ASSERT(%(var_name)s != NULL);
+    value = %(sub_cls)s_%(v_name)s_populate(
+        %(var_name)s, value);
+    TEST_ASSERT(value != 0);
+    %(cls)s_%(m_name)s_set(
+        obj, %(var_name)s);
+    %(sub_cls)s_delete(%(var_name)s);
+""" % dict(cls=cls, sub_cls=sub_cls, m_name=m_name, m_type=m_type,
+           var_name=var_name_map(m_type),
+           v_name=loxi_utils.version_to_name(version)))
+
+    out.write("""
+    return value;
+}
+""")
+
+    out.write("""
+/**
+ * Check all members of an object of type %(cls)s
+ * populated by the above function
+ * @param obj Pointer to an object to check
+ * @param value Starting value for checking
+ * @returns The value after increments for this object's values
+ */
+
+int
+%(cls)s_%(v_name)s_check(
+    %(cls)s_t *obj, int value)
+{
+""" % dict(cls=cls, v_name=loxi_utils.version_to_name(version)))
+    members, member_types = loxi_utils.all_member_types_get(cls, version)
+    for m_type in member_types:
+        if loxi_utils.type_is_scalar(m_type): # Handled by call to scalar setup
+            continue
+        if loxi_utils.type_is_of_object(m_type):
+            continue
+        out.write("    %s %s;\n" % (m_type, var_name_map(m_type)))
+    out.write("""
+    value = %(cls)s_%(v_name)s_check_scalars(
+        obj, value);
+    TEST_ASSERT(value != 0);
+""" % dict(cls=cls, v_name=loxi_utils.version_to_name(version)))
+
+    for member in members:
+        m_type = member["m_type"]
+        m_name = member["name"]
+        if loxi_utils.type_is_scalar(m_type): # Handled by call to scalar setup
+            continue
+        if loxi_utils.skip_member_name(m_name):
+            continue
+        if m_type == "of_match_t":
+            out.write("""\
+    %(cls)s_%(m_name)s_get(obj, &%(var_name)s);
+    value = of_match_check(&%(var_name)s, %(v_name)s, value);
+""" % dict(cls=cls, var_name=var_name_map(m_type), m_name=m_name,
+           v_name=loxi_utils.version_to_name(version)))
+        elif m_type == "of_octets_t":
+            out.write("""\
+    %(cls)s_%(m_name)s_get(obj, &%(var_name)s);
+    value = of_octets_check(&%(var_name)s, value);
+""" % dict(cls=cls, var_name=var_name_map(m_type), m_name=m_name,
+           v_name=loxi_utils.version_to_name(version)))
+        else:
+            sub_cls = m_type[:-2] # Trim _t
+            out.write("""
+    { /* Use get/delete to access on check */
+        %(m_type)s *%(m_name)s_ptr;
+
+        %(m_name)s_ptr = %(cls)s_%(m_name)s_get(obj);
+        TEST_ASSERT(%(m_name)s_ptr != NULL);
+        value = %(sub_cls)s_%(v_name)s_check(
+            %(m_name)s_ptr, value);
+        TEST_ASSERT(value != 0);
+        %(sub_cls)s_delete(%(m_name)s_ptr);
+    }
+""" % dict(cls=cls, sub_cls=sub_cls, m_name=m_name, m_type=m_type,
+           var_name=var_name_map(m_type),
+           v_name=loxi_utils.version_to_name(version)))
+
+    out.write("""
+    /* We shoehorn a test of the dup functions here */
+    {
+        %(cls)s_t *dup;
+
+        TEST_ASSERT((dup = %(cls)s_dup(obj)) != NULL);
+        TEST_ASSERT(dup->length == obj->length);
+        TEST_ASSERT(dup->object_id == obj->object_id);
+        TEST_ASSERT(dup->version == obj->version);
+        TEST_ASSERT(MEMCMP(OF_OBJECT_BUFFER_INDEX(dup, 0),
+            OF_OBJECT_BUFFER_INDEX(obj, 0), obj->length) == 0);
+        of_object_delete((of_object_t *)dup);
+
+        /* And now for the generic dup function */
+        TEST_ASSERT((dup = (%(cls)s_t *)
+            of_object_dup(obj)) != NULL);
+        TEST_ASSERT(dup->length == obj->length);
+        TEST_ASSERT(dup->object_id == obj->object_id);
+        TEST_ASSERT(dup->version == obj->version);
+        TEST_ASSERT(MEMCMP(OF_OBJECT_BUFFER_INDEX(dup, 0),
+            OF_OBJECT_BUFFER_INDEX(obj, 0), obj->length) == 0);
+        of_object_delete((of_object_t *)dup);
+    }
+
+    return value;
+}
+""" % dict(cls=cls))
+
+def unified_accessor_test_case(out, cls, version):
+    """
+    Generate one test case for the given version and class
+    """
+
+    members, member_types = scalar_member_types_get(cls, version)
+    length = of_g.base_length[(cls, version)]
+    v_name = loxi_utils.version_to_name(version)
+
+    out.write("""
+static int
+test_%(cls)s_%(v_name)s(void)
+{
+    %(cls)s_t *obj;
+    obj = %(cls)s_new(%(v_name)s);
+    TEST_ASSERT(obj != NULL);
+    TEST_ASSERT(obj->version == %(v_name)s);
+    TEST_ASSERT(obj->length == %(length)d);
+    TEST_ASSERT(obj->parent == NULL);
+    TEST_ASSERT(obj->object_id == %(u_cls)s);
+""" % dict(cls=cls, u_cls=cls.upper(), 
+           v_name=v_name, length=length, version=version))
+    if (not type_maps.class_is_virtual(cls)) or loxi_utils.class_is_list(cls):
+        out.write("""
+    if (obj->wire_length_get != NULL) {
+        int length;
+
+        obj->wire_length_get((of_object_t *)obj, &length);
+        TEST_ASSERT(length == %(length)d);
+    }
+    if (obj->wire_type_get != NULL) {
+        of_object_id_t obj_id;
+
+        obj->wire_type_get((of_object_t *)obj, &obj_id);
+        TEST_ASSERT(obj_id == %(u_cls)s);
+    }
+
+    /* Set up incrementing values for members */
+    TEST_ASSERT(%(cls)s_%(v_name)s_populate(
+        obj, 1) != 0);
+
+    /* Check values just set */
+    TEST_ASSERT(%(cls)s_%(v_name)s_check(
+        obj, 1) != 0);
+""" % dict(cls=cls, u_cls=cls.upper(), 
+           v_name=v_name, length=length, version=version))
+
+    out.write("""
+    %(cls)s_delete(obj);
+
+    /* To do: Check memory */
+    return TEST_PASS;
+}
+""" % dict(cls=cls))
+
+
+def gen_unified_accessor_funs(out):
+    for version in of_g.of_version_range:
+        for cls in of_g.standard_class_order:
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            if cls in type_maps.inheritance_map:
+                continue
+            elif loxi_utils.class_is_list(cls):
+                gen_list_setup_check(out, cls, version)
+            else:
+                gen_class_setup_check(out, cls, version)
+
+def gen_unified_accessor_tests(out, name):
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""
+/**
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ *
+ * Unified simple class instantiation tests for all versions
+ */
+
+#include <locitest/test_common.h>
+""")
+    for version in of_g.of_version_range:
+        for cls in of_g.standard_class_order:
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            if cls in type_maps.inheritance_map:
+                continue
+            unified_accessor_test_case(out, cls, version)
+
+    out.write("""
+int
+run_unified_accessor_tests(void)
+{
+""")
+    for version in of_g.of_version_range:
+        v_name = loxi_utils.version_to_name(version)
+        for cls in of_g.standard_class_order:
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            if cls in type_maps.inheritance_map:
+                continue
+            test_name = "%s_%s" % (cls, v_name)
+            out.write("    RUN_TEST(%s);\n" % test_name)
+
+    out.write("    return TEST_PASS;\n}\n");
+
+
+
+################################################################
+#
+# Object duplication functions
+#
+# These exercise the accessors to create duplicate objects.
+# They are used in the LOCI test shim which sits in an OF
+# protocol stream.
+#
+# TODO
+# Resolve version stuff
+# Complete list dup
+
+def gen_dup_list(out, cls, version):
+    ver_name = loxi_utils.version_to_name(version)
+    elt_type = loxi_utils.list_to_entry_type(cls)
+    out.write("""
+/**
+ * Duplicate a list of type %(cls)s 
+ * using accessor functions
+ * @param src Pointer to object to be duplicated
+ * @returns A new object of type %(cls)s.
+ *
+ * The caller is responsible for deleting the returned value
+ */
+%(cls)s_t *
+%(cls)s_%(ver_name)s_dup(
+    %(cls)s_t *src)
+{
+    %(elt_type)s_t src_elt;
+    %(elt_type)s_t *dst_elt;
+    int rv;
+    %(cls)s_t *dst;
+
+    if ((dst = %(cls)s_new(src->version)) == NULL) {
+        return NULL;
+    }
+""" % dict(elt_type=elt_type, cls=cls, ver_name=ver_name))
+
+    out.write("""
+    %(u_cls)s_ITER(src, &src_elt, rv) {
+        if ((dst_elt = %(elt_type)s_%(ver_name)s_dup(&src_elt)) == NULL) {
+            of_object_delete((of_object_t *)dst);
+            return NULL;
+        }
+        _TRY_FREE(%(cls)s_append(dst, dst_elt),
+            dst, NULL);
+        of_object_delete((of_object_t *)dst_elt);
+    }
+
+    return dst;
+}
+""" % dict(u_cls=cls.upper(), elt_type=elt_type, cls=cls, ver_name=ver_name))
+
+
+def gen_dup_inheritance(out, cls, version):
+    ver_name = loxi_utils.version_to_name(version)
+    out.write("""
+/**
+ * Duplicate a super class object of type %(cls)s 
+ * @param src Pointer to object to be duplicated
+ * @returns A new object of type %(cls)s.
+ *
+ * The caller is responsible for deleting the returned value
+ */
+%(cls)s_t *
+%(cls)s_%(ver_name)s_dup(
+    %(cls)s_t *src)
+{
+""" % dict(cls=cls, ver_name=ver_name))
+
+    # For each subclass, check if this is an instance of that subclass
+    version_classes = type_maps.inheritance_data[cls][version]
+    for sub_cls in version_classes:
+        sub_enum = (cls + "_" + sub_cls).upper()
+        out.write("""
+    if (src->header.object_id == %(sub_enum)s) {
+        return (%(cls)s_t *)%(cls)s_%(sub_cls)s_%(ver_name)s_dup(
+            &src->%(sub_cls)s);
+    }
+""" % dict(sub_cls=sub_cls, ver_name=ver_name, sub_enum=sub_enum, cls=cls))
+
+    out.write("""
+    return NULL;
+}
+""")
+
+
+def gen_dup_cls(out, cls, version):
+    """
+    Generate duplication routine for class cls
+    """
+    ver_name = loxi_utils.version_to_name(version)
+
+    out.write("""
+/**
+ * Duplicate an object of type %(cls)s 
+ * using accessor functions
+ * @param src Pointer to object to be duplicated
+ * @returns A new object of type %(cls)s.
+ *
+ * The caller is responsible for deleting the returned value
+ */
+%(cls)s_t *
+%(cls)s_%(ver_name)s_dup(
+    %(cls)s_t *src)
+{
+    %(cls)s_t *dst;
+""" % dict(cls=cls, ver_name=ver_name))
+
+    # Get members and types for the class
+    members, member_types = loxi_utils.all_member_types_get(cls, version)
+
+    # Add declarations for each member type
+    for m_type in member_types:
+        if loxi_utils.type_is_scalar(m_type) or m_type in ["of_match_t", "of_octets_t"]:
+            # Declare instance of these
+            out.write("    %s %s;\n" % (m_type, var_name_map(m_type)))
+        else:
+            out.write("""
+    %(m_type)s src_%(v_name)s;
+    %(m_type)s *dst_%(v_name)s;
+"""  % dict(m_type=m_type, v_name=var_name_map(m_type)))
+
+    out.write("""
+    if ((dst = %(cls)s_new(src->version)) == NULL) {
+        return NULL;
+    }
+""" % dict(cls=cls))
+
+    for member in members:
+        m_type = member["m_type"]
+        m_name = member["name"]
+        if loxi_utils.skip_member_name(m_name):
+            continue
+        if loxi_utils.type_is_scalar(m_type): # Handled by call to scalar setup
+            out.write("""
+    %(cls)s_%(m_name)s_get(src, &%(v_name)s);
+    %(cls)s_%(m_name)s_set(dst, %(v_name)s);
+""" % dict(cls=cls, m_name=m_name, v_name=var_name_map(m_type)))
+        elif m_type in ["of_match_t", "of_octets_t"]:
+            out.write("""
+    %(cls)s_%(m_name)s_get(src, &%(v_name)s);
+    %(cls)s_%(m_name)s_set(dst, &%(v_name)s);
+""" % dict(cls=cls, m_name=m_name, v_name=var_name_map(m_type)))
+        else:
+            sub_cls = m_type[:-2] # Trim _t
+            out.write("""
+    %(cls)s_%(m_name)s_bind(
+        src, &src_%(v_name)s);
+    dst_%(v_name)s = %(sub_cls)s_%(ver_name)s_dup(&src_%(v_name)s);
+    if (dst_%(v_name)s == NULL) {
+        %(cls)s_delete(dst);
+        return NULL;
+    }
+    %(cls)s_%(m_name)s_set(dst, dst_%(v_name)s);
+    %(sub_cls)s_delete(dst_%(v_name)s);
+""" % dict(sub_cls=sub_cls, cls=cls, m_name=m_name, 
+           v_name=var_name_map(m_type), ver_name=ver_name))
+
+    out.write("""
+    return dst;
+}
+""")
+
+def gen_version_dup(out=sys.stdout):
+    """
+    Generate duplication routines for each object type
+    """
+    out.write("""
+/* Special try macro for duplicating */
+#define _TRY_FREE(op, obj, rv) do { \\
+        int _rv;                                                             \\
+        if ((_rv = (op)) < 0) {                                              \\
+            LOCI_LOG_ERROR("ERROR %d at %s:%d\\n", _rv, __FILE__, __LINE__);    \\
+            of_object_delete((of_object_t *)(obj));                          \\
+            return (rv);                                                     \\
+        }                                                                    \\
+    } while (0)
+""")
+
+    for version in of_g.of_version_range:
+        for cls in of_g.standard_class_order:
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            if cls in type_maps.inheritance_map:
+                gen_dup_inheritance(out, cls, version)
+            elif loxi_utils.class_is_list(cls):
+                gen_dup_list(out, cls, version)
+            else:
+                gen_dup_cls(out, cls, version)
+
+def gen_dup(out=sys.stdout):
+    """
+    Generate non-version specific duplication routines for each object type
+    """
+
+    for cls in of_g.standard_class_order:
+        out.write("""
+%(cls)s_t *
+%(cls)s_dup(
+    %(cls)s_t *src)
+{
+""" % dict(cls=cls))
+        for version in of_g.of_version_range:
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            hdr = "header." if cls in type_maps.inheritance_map else ""
+
+            ver_name = loxi_utils.version_to_name(version)
+            out.write("""
+    if (src->%(hdr)sversion == %(ver_name)s) {
+        return %(cls)s_%(ver_name)s_dup(src);
+    }
+""" % dict(cls=cls, ver_name=ver_name, hdr=hdr))
+
+        out.write("""
+    /* Class not supported in given version */
+    return NULL;
+}
+""")
+
+def dup_c_gen(out, name):
+    """
+    Generate the C file for duplication functions
+    """
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""\
+/*
+ * Duplication functions for all OF objects
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ *
+ * These are test functions for exercising accessors.  You can call
+ * of_object_dup for an efficient duplication.
+ */
+
+#define DISABLE_WARN_UNUSED_RESULT
+#include "loci_log.h"
+#include <locitest/of_dup.h>
+
+""")
+
+    gen_version_dup(out)
+    gen_dup(out)
+
+
+def dup_h_gen(out, name):
+    """
+    Generate the header file for duplication functions
+    """
+
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""
+/*
+ * Duplication function header file
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ */
+
+#if !defined(_OF_DUP_H_)
+#define _OF_DUP_H_
+
+#include <loci/loci.h>
+""")
+
+    for cls in of_g.standard_class_order:
+        out.write("""
+extern %(cls)s_t *
+    %(cls)s_dup(
+        %(cls)s_t *src);
+""" % dict(cls=cls))
+
+    for version in of_g.of_version_range:
+        for cls in of_g.standard_class_order:
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            ver_name = loxi_utils.version_to_name(version)
+            out.write("""
+extern %(cls)s_t *
+    %(cls)s_%(ver_name)s_dup(
+        %(cls)s_t *src);
+""" % dict(cls=cls, ver_name=ver_name))
+
+    out.write("\n#endif /* _OF_DUP_H_ */\n")
+
+def gen_log_test(out):
+    """
+    Generate test for obj log calls
+
+    Define a trivial handler for object logging; call all obj log fns
+    """
+    out.write("""
+
+/**
+ * Test object dump functions
+ */
+
+int
+test_dump_objs(void)
+{
+    of_object_t *obj;
+
+    FILE *out = fopen("/dev/null", "w");
+
+    /* Call each obj dump function */
+""")
+    for version in of_g.of_version_range:
+        for j, cls in enumerate(of_g.all_class_order):
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            if cls in type_maps.inheritance_map:
+                continue
+            out.write("""
+    obj = (of_object_t *)%(cls)s_new(%(version)s);
+    of_object_dump((loci_writer_f)fprintf, out, obj);
+    of_object_delete(obj);
+""" % dict(cls=cls, version=of_g.of_version_wire2name[version]))
+    
+    out.write("""
+    fclose(out);
+    return TEST_PASS;
+}
+""")
+
+def gen_ident_tests(out):
+    """
+    Generate tests for identifiers
+
+    For all idents, instantiate, test version supported macros
+    For flags, set it, test it, clear it, test it.
+    """
+    out.write("""
+/**
+ * Test cases for all flag accessor macros
+ * These only test self consistency (and that they compile)
+ */
+int
+test_ident_macros(void)
+{
+    int value __attribute__((unused));
+    uint32_t flags;
+
+""")
+
+    for ident, info in of_g.identifiers.items():
+        if not identifiers.defined_versions_agree(of_g.identifiers,
+                                                  of_g.target_version_list,
+                                                  ident):
+            # @fixme
+            continue
+        out.write("    value = %s;\n" % ident)
+        for version in of_g.target_version_list:
+            if version in info["values_by_version"].keys():
+                out.write("    TEST_ASSERT(%s_SUPPORTED(%s));\n" %
+                          (ident, of_g.of_version_wire2name[version]))
+            else:
+                out.write("    TEST_ASSERT(!%s_SUPPORTED(%s));\n" %
+                          (ident, of_g.of_version_wire2name[version]))
+        if flags.ident_is_flag(ident):
+            # Grab first supported version
+            for version in info["values_by_version"]:
+                break
+            out.write("""
+    flags = 0;
+    %(ident)s_SET(flags, %(ver_name)s);
+    TEST_ASSERT(flags == %(ident)s_BY_VERSION(%(ver_name)s));
+    TEST_ASSERT(%(ident)s_TEST(flags, %(ver_name)s));
+    %(ident)s_CLEAR(flags, %(ver_name)s);
+    TEST_ASSERT(flags == 0);
+    TEST_ASSERT(!%(ident)s_TEST(flags, %(ver_name)s));
+""" % dict(ident=ident, ver_name=of_g.of_version_wire2name[version]))
+
+    out.write("""
+    return TEST_PASS;
+}
+""")
+
diff --git a/c_gen/c_type_maps.py b/c_gen/c_type_maps.py
new file mode 100644
index 0000000..924243a
--- /dev/null
+++ b/c_gen/c_type_maps.py
@@ -0,0 +1,1107 @@
+# Copyright 2013, Big Switch Networks, Inc.
+#
+# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+# the following special exception:
+#
+# LOXI Exception
+#
+# As a special exception to the terms of the EPL, you may distribute libraries
+# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+# that copyright and licensing notices generated by LoxiGen are not altered or removed
+# from the LoxiGen Libraries and the notice provided below is (i) included in
+# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+# documentation for the LoxiGen Libraries, if distributed in binary form.
+#
+# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+#
+# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+# a copy of the EPL at:
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# 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
+# EPL for the specific language governing permissions and limitations
+# under the EPL.
+
+##
+# @brief C code generation for LOXI type related maps
+#
+
+import of_g
+import sys
+from generic_utils import *
+import loxi_front_end.oxm as oxm
+import loxi_front_end.type_maps as type_maps
+
+
+# Some number larger than small type values, but less then
+# reserved values like 0xffff
+max_type_value = 1000
+
+def gen_object_id_to_type(out):
+    out.write("""
+/**
+ * Map from object ID to primary wire type
+ *
+ * For messages, this is the header type; in particular for stats, this is
+ * the common stats request/response type.  For per-stats types, use the
+ * stats type map.  For things like actions, instructions or queue-props,
+ * this gives the "sub type".
+ */
+""")
+    for version in of_g.of_version_range:
+        out.write("static int\nof_object_to_type_map_v%d[OF_OBJECT_COUNT] = {\n"
+                  %version)
+        out.write("    -1, /* of_object, not a valid specific type */\n")
+        for j, cls in enumerate(of_g.all_class_order):
+            comma = ""
+            if j < len(of_g.all_class_order) - 1: # Avoid ultimate comma
+                comma = ","
+
+            if cls in type_maps.stats_reply_list:
+                out.write("    %d%s /* %s */\n" % 
+                          (type_maps.type_val[("of_stats_reply", version)],
+                           comma, cls))
+            elif cls in type_maps.stats_request_list:
+                out.write("    %d%s /* %s */\n" % 
+                          (type_maps.type_val[("of_stats_request", version)],
+                           comma, cls))
+            elif cls in type_maps.flow_mod_list:
+                out.write("    %d%s /* %s */\n" % 
+                          (type_maps.type_val[("of_flow_mod", version)],
+                           comma, cls))
+            elif (cls, version) in type_maps.type_val:
+                out.write("    %d%s /* %s */\n" % 
+                          (type_maps.type_val[(cls, version)], comma, cls))
+            elif type_maps.message_is_extension(cls, version):
+                out.write("    %d%s /* %s */\n" % 
+                          (type_maps.type_val[("of_experimenter", version)],
+                           comma, cls))
+            elif type_maps.action_is_extension(cls, version):
+                out.write("    %d%s /* %s */\n" % 
+                          (type_maps.type_val[("of_action_experimenter",
+                                               version)],
+                           comma, cls))
+            elif type_maps.action_id_is_extension(cls, version):
+                out.write("    %d%s /* %s */\n" % 
+                          (type_maps.type_val[("of_action_id_experimenter",
+                                               version)],
+                           comma, cls))
+            elif type_maps.instruction_is_extension(cls, version):
+                out.write("    %d%s /* %s */\n" % 
+                          (type_maps.type_val[("of_instruction_experimenter",
+                                               version)],
+                           comma, cls))
+            elif type_maps.queue_prop_is_extension(cls, version):
+                out.write("    %d%s /* %s */\n" % 
+                          (type_maps.type_val[("of_queue_prop_experimenter",
+                                               version)],
+                           comma, cls))
+            elif type_maps.table_feature_prop_is_extension(cls, version):
+                out.write("    %d%s /* %s */\n" % 
+                    (type_maps.type_val[("of_table_feature_prop_experimenter",
+                                         version)],
+                     comma, cls))
+            else:
+                out.write("    -1%s /* %s (invalid) */\n" % (comma, cls))
+        out.write("};\n\n")
+
+    out.write("""
+/**
+ * Unified map, indexed by wire version which is 1-based.
+ */
+int *of_object_to_type_map[OF_VERSION_ARRAY_MAX] = {
+    NULL,
+""")
+    for version in of_g.of_version_range:
+        out.write("    of_object_to_type_map_v%d,\n" % version)
+    out.write("""
+};
+""")
+
+def gen_object_id_to_extension_data(out):
+    out.write("""
+/**
+ * Extension data.
+ * @fixme There must be a better way to represent this data
+ */
+""")
+    for version in of_g.of_version_range:
+        out.write("""
+static of_experimenter_data_t
+of_object_to_extension_data_v%d[OF_OBJECT_COUNT] = {
+""" % version)
+        out.write("    {0, 0, 0}, /* of_object, not a valid specific type */\n")
+        for j, cls in enumerate(of_g.all_class_order):
+            comma = ""
+            if j < len(of_g.all_class_order) - 1: # Avoid ultimate comma
+                comma = ","
+
+            if type_maps.class_is_extension(cls, version):
+                exp_name = type_maps.extension_to_experimenter_macro_name(cls)
+                subtype = type_maps.extension_to_subtype(cls, version)
+                out.write("    {1, %s, %d}%s /* %s */\n" % 
+                          (exp_name, subtype, comma, cls))
+            else:
+                out.write("    {0, 0, 0}%s /* %s (non-extension) */\n" %
+                          (comma, cls))
+        out.write("};\n\n")
+
+    out.write("""
+/**
+ * Unified map, indexed by wire version which is 1-based.
+ */
+of_experimenter_data_t *of_object_to_extension_data[OF_VERSION_ARRAY_MAX] = {
+    NULL,
+""")
+    for version in of_g.of_version_range:
+        out.write("    of_object_to_extension_data_v%d,\n" % version)
+    out.write("""
+};
+""")
+
+def gen_type_to_object_id(out, type_str, prefix, template,
+                          value_array, max_val):
+    """
+    Generate C maps from various message class groups to object ids
+
+    For each version, create an array mapping the type info to the
+    object ID.  Then define an array containing those pointers.
+    """
+
+    # Create unified arrays and get length
+    arr_len = type_maps.type_array_len(value_array, max_val)
+    all_ars = []
+    for version, val_dict in value_array.items(): # Per version dict
+        ar = type_maps.dict_to_array(val_dict, max_val, type_maps.invalid_type)
+        all_ars.append(ar)
+
+    len_name = "%s_ITEM_COUNT" % prefix
+
+    for i, ar in enumerate(all_ars):
+        version = i + 1
+        out.write("static of_object_id_t\nof_%s_v%d[%s] = {\n" %
+                  (type_str, version, len_name))
+        for i in range(arr_len):
+            comma = ""
+            if i < arr_len - 1: # Avoid ultimate comma
+                comma = ","
+
+            # Per-version length check
+            if i < len(ar):
+                v = ar[i]
+            else:
+                v = type_maps.invalid_type
+
+            if v == type_maps.invalid_type:
+                out.write("    %-30s /* %d (Invalid) */\n" %
+                          ("OF_OBJECT_INVALID" + comma, i))
+            else:
+                name = (template % v.upper()) + comma
+                out.write("    %-30s /* %d */\n" % (name, i))
+        out.write("};\n")
+
+    out.write("""
+/**
+ * Maps from %(c_name)s wire type values to LOCI object ids
+ *
+ * Indexed by wire version which is 1-based.
+ */
+
+of_object_id_t *of_%(name)s[OF_VERSION_ARRAY_MAX] = {
+    NULL,
+""" % dict(name=type_str, c_name=prefix.lower()))
+    for version in of_g.of_version_range:
+        out.write("    of_%(name)s_v%(version)d,\n" % dict(name=type_str,
+                                                           version=version))
+    out.write("""
+};
+
+""" % dict(name=type_str, u_name=type_str.upper(), 
+           max_val=max_val, c_name=prefix.lower()))
+
+def gen_type_maps(out):
+    """
+    Generate various type maps
+    @param out The file handle to write to
+    """
+
+    out.write("#include <loci/loci.h>\n\n")
+
+    # Generate maps from wire type values to object IDs
+    gen_type_to_object_id(out, "action_type_to_id", "OF_ACTION",
+                          "OF_ACTION_%s", type_maps.action_types,
+                          max_type_value)
+    gen_type_to_object_id(out, "action_id_type_to_id", "OF_ACTION_ID",
+                          "OF_ACTION_ID_%s", type_maps.action_id_types,
+                          max_type_value)
+    gen_type_to_object_id(out, "instruction_type_to_id", "OF_INSTRUCTION",
+                          "OF_INSTRUCTION_%s", type_maps.instruction_types, 
+                          max_type_value)
+    gen_type_to_object_id(out, "queue_prop_type_to_id", "OF_QUEUE_PROP",
+                          "OF_QUEUE_PROP_%s", type_maps.queue_prop_types,
+                          max_type_value)
+    gen_type_to_object_id(out, "table_feature_prop_type_to_id",
+                          "OF_TABLE_FEATURE_PROP",
+                          "OF_TABLE_FEATURE_PROP_%s",
+                          type_maps.table_feature_prop_types,
+                          max_type_value)
+    gen_type_to_object_id(out, "meter_band_type_to_id", "OF_METER_BAND",
+                          "OF_METER_BAND_%s", type_maps.meter_band_types,
+                          max_type_value)
+    gen_type_to_object_id(out, "hello_elem_type_to_id", "OF_HELLO_ELEM",
+                          "OF_HELLO_ELEM_%s", type_maps.hello_elem_types,
+                          max_type_value)
+
+    # FIXME:  Multipart re-organization
+    gen_type_to_object_id(out, "stats_request_type_to_id", "OF_STATS_REQUEST",
+                          "OF_%s_STATS_REQUEST", type_maps.stats_types,
+                          max_type_value)
+    gen_type_to_object_id(out, "stats_reply_type_to_id", "OF_STATS_REPLY",
+                          "OF_%s_STATS_REPLY", type_maps.stats_types,
+                          max_type_value)
+    gen_type_to_object_id(out, "flow_mod_type_to_id", "OF_FLOW_MOD",
+                          "OF_FLOW_%s", type_maps.flow_mod_types,
+                          max_type_value)
+    gen_type_to_object_id(out, "oxm_type_to_id", "OF_OXM",
+                          "OF_OXM_%s", type_maps.oxm_types, max_type_value)
+    gen_type_to_object_id(out, "message_type_to_id", "OF_MESSAGE",
+                          "OF_%s", type_maps.message_types, max_type_value)
+
+    gen_object_id_to_type(out)
+    gen_object_id_to_extension_data(out)
+    # Don't need array mapping ID to stats types right now; handled directly
+    # gen_object_id_to_stats_type(out)
+
+
+def gen_type_to_obj_map_functions(out):
+    """
+    Generate the templated static inline type map functions
+    @param out The file handle to write to
+    """
+
+    ################################################################
+    # Generate all type-to-object-ID maps in a common way
+    ################################################################
+    map_template = """
+/**
+ * %(name)s wire type to object ID array.
+ * Treat as private; use function accessor below
+ */
+
+extern of_object_id_t *of_%(name)s_type_to_id[OF_VERSION_ARRAY_MAX];
+
+#define OF_%(u_name)s_ITEM_COUNT %(ar_len)d\n
+
+/**
+ * Map an %(name)s wire value to an OF object
+ * @param %(name)s The %(name)s type wire value
+ * @param version The version associated with the check
+ * @return The %(name)s OF object type
+ * @return OF_OBJECT_INVALID if type does not map to an object
+ * 
+ */
+static inline of_object_id_t
+of_%(name)s_to_object_id(int %(name)s, of_version_t version) 
+{
+    if (!OF_VERSION_OKAY(version)) {
+        return OF_OBJECT_INVALID;
+    }
+    if (%(name)s < 0 || %(name)s >= OF_%(u_name)s_ITEM_COUNT) {
+        return OF_OBJECT_INVALID;
+    }
+
+    return of_%(name)s_type_to_id[version][%(name)s];
+}
+"""
+    map_with_experimenter_template = """
+/**
+ * %(name)s wire type to object ID array.
+ * Treat as private; use function accessor below
+ */
+
+extern of_object_id_t *of_%(name)s_type_to_id[OF_VERSION_ARRAY_MAX];
+
+#define OF_%(u_name)s_ITEM_COUNT %(ar_len)d\n
+
+/**
+ * Map an %(name)s wire value to an OF object
+ * @param %(name)s The %(name)s type wire value
+ * @param version The version associated with the check
+ * @return The %(name)s OF object type
+ * @return OF_OBJECT_INVALID if type does not map to an object
+ * 
+ */
+static inline of_object_id_t
+of_%(name)s_to_object_id(int %(name)s, of_version_t version) 
+{
+    if (!OF_VERSION_OKAY(version)) {
+        return OF_OBJECT_INVALID;
+    }
+    if (%(name)s == OF_EXPERIMENTER_TYPE) {
+        return OF_%(u_name)s_EXPERIMENTER;
+    }
+    if (%(name)s < 0 || %(name)s >= OF_%(u_name)s_ITEM_COUNT) {
+        return OF_OBJECT_INVALID;
+    }
+
+    return of_%(name)s_type_to_id[version][%(name)s];
+}
+"""
+
+    stats_template = """
+/**
+ * %(name)s wire type to object ID array.
+ * Treat as private; use function accessor below
+ */
+
+extern of_object_id_t *of_%(name)s_type_to_id[OF_VERSION_ARRAY_MAX];
+
+#define OF_%(u_name)s_ITEM_COUNT %(ar_len)d\n
+
+/**
+ * Map an %(name)s wire value to an OF object
+ * @param %(name)s The %(name)s type wire value
+ * @param version The version associated with the check
+ * @return The %(name)s OF object type
+ * @return OF_OBJECT_INVALID if type does not map to an object
+ * 
+ */
+static inline of_object_id_t
+of_%(name)s_to_object_id(int %(name)s, of_version_t version) 
+{
+    if (!OF_VERSION_OKAY(version)) {
+        return OF_OBJECT_INVALID;
+    }
+    if (%(name)s == OF_EXPERIMENTER_TYPE) {
+        return OF_EXPERIMENTER_%(u_name)s;
+    }
+    if (%(name)s < 0 || %(name)s >= OF_%(u_name)s_ITEM_COUNT) {
+        return OF_OBJECT_INVALID;
+    }
+
+    return of_%(name)s_type_to_id[version][%(name)s];
+}
+"""
+    # Experimenter mapping functions
+    # Currently we support very few candidates, so we just do a
+    # list of if/elses
+    experimenter_function = """
+/**
+ * @brief Map a message known to be an exp msg to the proper object
+ *
+ * Assume that the message is a vendor/experimenter message.  Determine
+ * the specific object type for the message.
+ * @param msg An OF message object (uint8_t *)
+ * @param length The number of bytes in the message (for error checking)
+ * @param version Version of message
+ * @returns object ID of specific type if recognized or OF_EXPERIMENTER if not
+ *
+ * @todo put OF_EXPERIMENTER_<name> in loci_base.h
+ */
+
+static inline of_object_id_t
+of_message_experimenter_to_object_id(of_message_t msg, of_version_t version) {
+    uint32_t experimenter_id;
+    uint32_t subtype;
+
+    /* Extract experimenter and subtype value; look for match from type maps */
+    experimenter_id = of_message_experimenter_id_get(msg);
+    subtype = of_message_experimenter_subtype_get(msg);
+
+    /* Do a simple if/else search for the ver, experimenter and subtype */
+"""
+    first = True
+    for version, experimenter_lists in type_maps.extension_message_subtype.items():
+        for exp, subtypes in experimenter_lists.items():
+            experimenter_function += """
+    if ((experimenter_id == OF_EXPERIMENTER_ID_%(exp_name)s) && 
+            (version == %(ver_name)s)) {
+""" % dict(exp_name=exp.upper(), ver_name=of_g.wire_ver_map[version])
+            for ext_msg, subtype in subtypes.items():
+                experimenter_function += """
+        if (subtype == %(subtype)s) {
+            return %(ext_msg)s;
+        }
+""" % dict(subtype=subtype, ext_msg=ext_msg.upper())
+            experimenter_function += """
+    }
+"""
+    experimenter_function += """
+    return OF_EXPERIMENTER;
+}
+"""
+
+    # Message need different handling
+    msg_template = """
+/**
+ * %(name)s wire type to object ID array.
+ * Treat as private; use function accessor below
+ */
+
+extern of_object_id_t *of_%(name)s_type_to_id[OF_VERSION_ARRAY_MAX];
+
+#define OF_%(u_name)s_ITEM_COUNT %(ar_len)d\n
+
+/**
+ * Extract the type info from the message and determine its object type
+ * @param msg An OF message object (uint8_t *)
+ * @param length The number of bytes in the message (for error checking)
+ * @returns object ID or OF_OBJECT_INVALID if parse error
+ */
+
+static inline of_object_id_t
+of_message_to_object_id(of_message_t msg, int length) {
+    uint8_t type;
+    of_version_t ver;
+    of_object_id_t obj_id;
+    uint16_t stats_type;
+    uint8_t flow_mod_cmd;
+
+    if (length < OF_MESSAGE_MIN_LENGTH) {
+        return OF_OBJECT_INVALID;
+    }
+    type = of_message_type_get(msg);
+    ver = of_message_version_get(msg);
+    if (!OF_VERSION_OKAY(ver)) {
+        return OF_OBJECT_INVALID;
+    }
+
+    if (type >= OF_MESSAGE_ITEM_COUNT) {
+        return OF_OBJECT_INVALID;
+    }
+
+    obj_id = of_message_type_to_id[ver][type];
+
+    /* Remap to specific message if known */
+    if (obj_id == OF_EXPERIMENTER) {
+        if (length < OF_MESSAGE_EXPERIMENTER_MIN_LENGTH) {
+            return OF_OBJECT_INVALID;
+        }
+        return of_message_experimenter_to_object_id(msg, ver);
+    }
+
+    /* Remap to add/delete/strict version */
+    if (obj_id == OF_FLOW_MOD) {
+        if (length < OF_MESSAGE_MIN_FLOW_MOD_LENGTH(ver)) {
+            return OF_OBJECT_INVALID;
+        }
+        flow_mod_cmd = of_message_flow_mod_command_get(msg, ver);
+        obj_id = of_flow_mod_to_object_id(flow_mod_cmd, ver);
+    }
+
+    if ((obj_id == OF_STATS_REQUEST) || (obj_id == OF_STATS_REPLY)) {
+        if (length < OF_MESSAGE_MIN_STATS_LENGTH) {
+            return OF_OBJECT_INVALID;
+        }
+        stats_type = of_message_stats_type_get(msg);
+        if (obj_id == OF_STATS_REQUEST) {
+            obj_id = of_stats_request_to_object_id(stats_type, ver);
+        } else {
+            obj_id = of_stats_reply_to_object_id(stats_type, ver);
+        }
+    }
+
+    return obj_id;
+}
+"""
+
+    # Action types array gen
+    ar_len = type_maps.type_array_len(type_maps.action_types, max_type_value)
+    out.write(map_with_experimenter_template % 
+              dict(name="action", u_name="ACTION", ar_len=ar_len))
+
+    # Action ID types array gen
+    ar_len = type_maps.type_array_len(type_maps.action_id_types, max_type_value)
+    out.write(map_with_experimenter_template % 
+              dict(name="action_id", u_name="ACTION_ID", ar_len=ar_len))
+
+    # Instruction types array gen
+    ar_len = type_maps.type_array_len(type_maps.instruction_types,
+                                      max_type_value)
+    out.write(map_with_experimenter_template % 
+              dict(name="instruction", u_name="INSTRUCTION", ar_len=ar_len))
+
+    # Queue prop types array gen
+    ar_len = type_maps.type_array_len(type_maps.queue_prop_types,
+                                      max_type_value)
+    out.write(map_with_experimenter_template % 
+              dict(name="queue_prop", u_name="QUEUE_PROP", ar_len=ar_len))
+
+    # Table feature prop types array gen
+    ar_len = type_maps.type_array_len(type_maps.table_feature_prop_types,
+                                      max_type_value)
+    out.write(map_with_experimenter_template % 
+              dict(name="table_feature_prop", u_name="TABLE_FEATURE_PROP",
+                   ar_len=ar_len))
+
+    # Meter band types array gen
+    ar_len = type_maps.type_array_len(type_maps.meter_band_types,
+                                      max_type_value)
+    out.write(map_with_experimenter_template % 
+              dict(name="meter_band", u_name="METER_BAND", ar_len=ar_len))
+
+    # Hello elem types array gen
+    ar_len = type_maps.type_array_len(type_maps.hello_elem_types,
+                                      max_type_value)
+    out.write(map_template % 
+              dict(name="hello_elem", u_name="HELLO_ELEM", ar_len=ar_len))
+
+    # Stats types array gen
+    ar_len = type_maps.type_array_len(type_maps.stats_types,
+                                      max_type_value)
+    out.write(stats_template % 
+              dict(name="stats_reply", u_name="STATS_REPLY", ar_len=ar_len))
+    out.write(stats_template % 
+              dict(name="stats_request", u_name="STATS_REQUEST", 
+                   ar_len=ar_len))
+
+    ar_len = type_maps.type_array_len(type_maps.flow_mod_types, max_type_value)
+    out.write(map_template % 
+              dict(name="flow_mod", u_name="FLOW_MOD", ar_len=ar_len))
+
+    ar_len = type_maps.type_array_len(type_maps.oxm_types, max_type_value)
+    out.write("""
+/* NOTE: We could optimize the OXM and only generate OF 1.2 versions. */
+""")
+    out.write(map_template % 
+              dict(name="oxm", u_name="OXM", ar_len=ar_len))
+
+    out.write(experimenter_function)
+    # Must follow stats reply/request
+    ar_len = type_maps.type_array_len(type_maps.message_types, max_type_value)
+    out.write(msg_template % 
+              dict(name="message", u_name="MESSAGE", ar_len=ar_len))
+
+def gen_obj_to_type_map_functions(out):
+    """
+    Generate the static line maps from object IDs to types
+    @param out The file handle to write to
+    """
+
+    ################################################################
+    # Generate object ID to primary type map
+    ################################################################
+
+    out.write("""
+extern int *of_object_to_type_map[OF_VERSION_ARRAY_MAX];
+
+/**
+ * Map an object ID to its primary wire type value
+ * @param id An object ID
+ * @return For message objects, the type value in the OpenFlow header
+ * @return For non-message objects such as actions, instructions, OXMs
+ * returns the type value that appears in the respective sub-header
+ * @return -1 For improper version or out of bounds input
+ *
+ * NOTE that for stats request/reply, returns the header type, not the
+ * sub-type
+ *
+ * Also, note that the value is returned as a signed integer.  So -1 is
+ * an error code, while 0xffff is the usual "experimenter" code.
+ */
+static inline int
+of_object_to_wire_type(of_object_id_t id, of_version_t version)
+{
+    if (!OF_VERSION_OKAY(version)) {
+        return -1;
+    }
+    if (id < 0 || id >= OF_OBJECT_COUNT) {
+        return -1;
+    }
+    return of_object_to_type_map[version][id];
+}
+
+""")
+
+    # Now for experimenter ids
+    out.write("""
+/**
+ * Map from object ID to a triple, (is_extension, experimenter id, subtype)
+ */
+""")
+    out.write("""
+typedef struct of_experimenter_data_s {
+    int is_extension;  /* Boolean indication that this is an extension */
+    uint32_t experimenter_id;
+    uint32_t subtype;
+} of_experimenter_data_t;
+
+""")
+
+    out.write("""
+extern of_experimenter_data_t *of_object_to_extension_data[OF_VERSION_ARRAY_MAX];
+
+/**
+ * Map from the object ID of an extension to the experimenter ID
+ */
+static inline uint32_t
+of_extension_to_experimenter_id(of_object_id_t obj_id, of_version_t ver)
+{
+    if (obj_id < 0 || obj_id > OF_OBJECT_COUNT) {
+        return (uint32_t) -1;
+    }
+    /* @fixme: Verify ver? */
+    return of_object_to_extension_data[ver][obj_id].experimenter_id;
+}
+
+/**
+ * Map from the object ID of an extension to the experimenter subtype
+ */
+static inline uint32_t
+of_extension_to_experimenter_subtype(of_object_id_t obj_id, of_version_t ver)
+{
+    if (obj_id < 0 || obj_id > OF_OBJECT_COUNT) {
+        return (uint32_t) -1;
+    }
+    /* @fixme: Verify ver? */
+    return of_object_to_extension_data[ver][obj_id].subtype;
+}
+
+/**
+ * Boolean function indicating the the given object ID/version
+ * is recognized as a supported (decode-able) extension.
+ */
+static inline int
+of_object_id_is_extension(of_object_id_t obj_id, of_version_t ver)
+{
+    if (obj_id < 0 || obj_id > OF_OBJECT_COUNT) {
+        return (uint32_t) -1;
+    }
+    /* @fixme: Verify ver? */
+    return of_object_to_extension_data[ver][obj_id].is_extension;
+}
+""")
+
+    ################################################################
+    # Generate object ID to the stats sub-type map
+    ################################################################
+
+    out.write("""
+/**
+ * Map an object ID to a stats type
+ * @param id An object ID
+ * @return The wire value for the stats type
+ * @return -1 if not supported for this version
+ * @return -1 if id is not a specific stats type ID
+ *
+ * Note that the value is returned as a signed integer.  So -1 is
+ * an error code, while 0xffff is the usual "experimenter" code.
+ */
+
+static inline int
+of_object_to_stats_type(of_object_id_t id, of_version_t version)
+{
+    if (!OF_VERSION_OKAY(version)) {
+        return -1;
+    }
+    switch (id) {
+""")
+    # Assumes 1.2 contains all stats types and type values are
+    # the same across all versions
+    stats_names = dict()
+    for ver in of_g.of_version_range:
+        for name, value in type_maps.stats_types[ver].items():
+            if name in stats_names and (not value == stats_names[name]):
+                print "ERROR stats type differ violating assumption"
+                sys.exit(1)
+            stats_names[name] = value
+
+    for name, value in stats_names.items():
+        out.write("    case OF_%s_STATS_REPLY:\n" % name.upper())
+        out.write("    case OF_%s_STATS_REQUEST:\n" % name.upper())
+        for version in of_g.of_version_range:
+            if not name in type_maps.stats_types[version]:
+                out.write("        if (version == %s) break;\n" %
+                          of_g.of_version_wire2name[version])
+        out.write("        return %d;\n" % value)
+    out.write("""
+    default:
+        break;
+    }
+    return -1; /* Not recognized as stats type object for this version */
+}
+""")
+
+    ################################################################
+    # Generate object ID to the flow mod sub-type map
+    ################################################################
+
+    out.write("""
+/**
+ * Map an object ID to a flow-mod command value
+ * @param id An object ID
+ * @return The wire value for the flow-mod command
+ * @return -1 if not supported for this version
+ * @return -1 if id is not a specific stats type ID
+ *
+ * Note that the value is returned as a signed integer.  So -1 is
+ * an error code, while 0xffff is the usual "experimenter" code.
+ */
+
+static inline int
+of_object_to_flow_mod_command(of_object_id_t id, of_version_t version)
+{
+    if (!OF_VERSION_OKAY(version)) {
+        return -1;
+    }
+    switch (id) {
+""")
+    # Assumes 1.2 contains all stats types and type values are
+    # the same across all versions
+    flow_mod_names = dict()
+    for ver in of_g.of_version_range:
+        for name, value in type_maps.flow_mod_types[ver].items():
+            if name in flow_mod_names and \
+                    (not value == flow_mod_names[name]):
+                print "ERROR flow mod command differ violating assumption"
+                sys.exit(1)
+            flow_mod_names[name] = value
+
+    for name, value in flow_mod_names.items():
+        out.write("    case OF_FLOW_%s:\n" % name.upper())
+        for version in of_g.of_version_range:
+            if not name in type_maps.flow_mod_types[version]:
+                out.write("        if (version == %s) break;\n" %
+                          of_g.of_version_wire2name[version])
+        out.write("        return %d;\n" % value)
+    out.write("""
+    default:
+        break;
+    }
+    return -1; /* Not recognized as flow mod type object for this version */
+}
+
+""")
+
+def gen_type_maps_header(out):
+    """
+    Generate various header file declarations for type maps
+    @param out The file handle to write to
+    """
+
+    out.write("""
+/**
+ * Generic experimenter type value.  Applies to all except 
+ * top level message: Action, instruction, error, stats, queue_props, oxm
+ */
+#define OF_EXPERIMENTER_TYPE 0xffff
+""")
+    gen_type_to_obj_map_functions(out)
+    gen_obj_to_type_map_functions(out)
+
+    out.write("extern int *of_object_fixed_len[OF_VERSION_ARRAY_MAX];\n")
+
+    out.write("""
+/**
+ * Map a message in a wire buffer object to its OF object id.
+ * @param wbuf Pointer to a wire buffer object, populated with an OF message
+ * @returns The object ID of the message
+ * @returns OF_OBJECT_INVALID if unable to parse the message type
+ */
+
+static inline of_object_id_t
+of_wire_object_id_get(of_wire_buffer_t *wbuf)
+{
+    of_message_t msg;
+
+    msg = (of_message_t)WBUF_BUF(wbuf);
+    return of_message_to_object_id(msg, WBUF_CURRENT_BYTES(wbuf));
+}
+
+/**
+ * Use the type/length from the wire buffer and init the object
+ * @param obj The object being initialized
+ * @param base_object_id If > 0, this indicates the base object
+ * @param max_len If > 0, the max length to expect for the obj
+ * type for inheritance checking
+ * @return OF_ERROR_
+ *
+ * Used for inheritance type objects such as actions and OXMs
+ * The type is checked and if valid, the object is initialized.
+ * Then the length is taken from the buffer.
+ *
+ * Note that the object version must already be properly set.
+ */
+static inline int
+of_object_wire_init(of_object_t *obj, of_object_id_t base_object_id,
+                    int max_len)
+{
+    if (obj->wire_type_get != NULL) {
+        of_object_id_t id;
+        obj->wire_type_get(obj, &id);
+        if (!of_wire_id_valid(id, base_object_id)) {
+            return OF_ERROR_PARSE;
+        }
+        obj->object_id = id;
+        /* Call the init function for this object type; do not push to wire */
+        of_object_init_map[id]((of_object_t *)(obj), obj->version, -1, 0);
+    }
+    if (obj->wire_length_get != NULL) {
+        int length;
+        obj->wire_length_get(obj, &length);
+        if (length < 0 || (max_len > 0 && length > max_len)) {
+            return OF_ERROR_PARSE;
+        }
+        obj->length = length;
+    } else {
+        /* @fixme Does this cover everything else? */
+        obj->length = of_object_fixed_len[obj->version][base_object_id];
+    }
+
+    return OF_ERROR_NONE;
+}
+
+""")
+
+    # Generate the function that sets the object type fields
+    out.write("""
+
+/**
+ * Map a message in a wire buffer object to its OF object id.
+ * @param wbuf Pointer to a wire buffer object, populated with an OF message
+ * @returns The object ID of the message
+ * @returns OF_OBJECT_INVALID if unable to parse the message type
+ *
+ * Version must be set in the buffer prior to calling this routine
+ */
+
+static inline int
+of_wire_message_object_id_set(of_wire_buffer_t *wbuf, of_object_id_t id)
+{
+    int type;
+    of_version_t ver;
+    of_message_t msg;
+
+    msg = (of_message_t)WBUF_BUF(wbuf);
+
+    ver = of_message_version_get(msg);
+
+    /* ASSERT(id is a message object) */
+
+    if ((type = of_object_to_wire_type(id, ver)) < 0) {
+        return OF_ERROR_PARAM;
+    }
+    of_message_type_set(msg, type);
+
+    if ((type = of_object_to_stats_type(id, ver)) >= 0) {
+        /* It's a stats obj */
+        of_message_stats_type_set(msg, type);
+    }
+    if ((type = of_object_to_flow_mod_command(id, ver)) >= 0) {
+        /* It's a flow mod obj */
+        of_message_flow_mod_command_set(msg, ver, type);
+    }
+    if (of_object_id_is_extension(id, ver)) {
+        uint32_t val32;
+
+        /* Set the experimenter and subtype codes */
+        val32 = of_extension_to_experimenter_id(id, ver);
+        of_message_experimenter_id_set(msg, val32);
+        val32 = of_extension_to_experimenter_subtype(id, ver);
+        of_message_experimenter_subtype_set(msg, val32);
+    }
+
+    return OF_ERROR_NONE;
+}
+""")
+
+def gen_type_data_header(out):
+
+    out.write("""
+/****************************************************************
+ *
+ * The following declarations are for type and length calculations.
+ * Implementations may be found in of_type_maps.c
+ *
+ ****************************************************************/
+/*
+ * Special case length functions for objects with
+ */
+""")
+    for ((cls, name), prev) in of_g.special_offsets.items():
+        s_cls = cls[3:] # take off of_
+        out.write("""
+/**
+ * Special length calculation for %(cls)s->%(name)s.
+ * @param obj An object of type %(cls)s to check for 
+ * length of %(name)s
+ * @param bytes[out] Where to store the calculated length
+ *
+ * Preceding data member is %(prev)s.
+ */
+extern int of_length_%(s_cls)s_%(name)s_get(
+    %(cls)s_t *obj, int *bytes);
+
+/**
+ * Special offset calculation for %(cls)s->%(name)s.
+ * @param obj An object of type %(cls)s to check for 
+ * length of %(name)s
+ * @param offset[out] Where to store the calculated length
+ *
+ * Preceding data member is %(prev)s.
+ */
+extern int of_offset_%(s_cls)s_%(name)s_get(
+    %(cls)s_t *obj, int *offset);
+""" % dict(cls=cls, s_cls=s_cls, name=name, prev=prev))
+
+# NOT NEEDED YET
+#     # For non-message, variable length objects, give a fun that
+#     # calculates the length
+#     for cls in of_g.standard_class_order:
+#         s_cls = cls[3:] # take off of_
+#         if !type_is_var_len(cls, version):
+#             continue
+#         out.write("""
+# /**
+#  * Special length calculation for variable length object %(cls)s
+#  * @param obj An object of type %(cls)s whose length is being calculated
+#  * @param bytes[out] Where to store the calculated length
+#  *
+#  * The assumption is that the length member of the object is not
+#  * valid and the length needs to be calculated from other information
+#  * such as the parent.
+#  */
+# extern int of_length_%(s_cls)s_get(
+#     %(cls)s_t *obj, int *bytes);
+# """ % dict(cls=cls, s_cls=s_cls))        
+
+    out.write("""
+/****************************************************************
+ * Wire type/length functions.
+ ****************************************************************/
+
+extern void of_object_message_wire_length_get(of_object_t *obj, int *bytes);
+extern void of_object_message_wire_length_set(of_object_t *obj, int bytes);
+
+extern void of_oxm_wire_length_get(of_object_t *obj, int *bytes);
+extern void of_oxm_wire_length_set(of_object_t *obj, int bytes);
+extern void of_oxm_wire_object_id_get(of_object_t *obj, of_object_id_t *id);
+extern void of_oxm_wire_object_id_set(of_object_t *obj, of_object_id_t id);
+
+extern void of_tlv16_wire_length_get(of_object_t *obj, int *bytes);
+extern void of_tlv16_wire_length_set(of_object_t *obj, int bytes);
+
+extern void of_tlv16_wire_object_id_set(of_object_t *obj, of_object_id_t id);
+
+/* Wire length is uint16 at front of structure */
+extern void of_u16_len_wire_length_get(of_object_t *obj, int *bytes);
+extern void of_u16_len_wire_length_set(of_object_t *obj, int bytes);
+
+extern void of_action_wire_object_id_get(of_object_t *obj, of_object_id_t *id);
+extern void of_action_id_wire_object_id_get(of_object_t *obj, of_object_id_t *id);
+extern void of_instruction_wire_object_id_get(of_object_t *obj, 
+    of_object_id_t *id);
+extern void of_queue_prop_wire_object_id_get(of_object_t *obj, 
+    of_object_id_t *id);
+extern void of_table_feature_prop_wire_object_id_get(of_object_t *obj, 
+    of_object_id_t *id);
+extern void of_meter_band_wire_object_id_get(of_object_t *obj, 
+    of_object_id_t *id);
+extern void of_hello_elem_wire_object_id_get(of_object_t *obj, 
+    of_object_id_t *id);
+
+/** @fixme VERIFY LENGTH IS NUMBER OF BYTES OF ENTRY INCLUDING HDR */
+#define OF_OXM_MASKED_TYPE_GET(hdr) (((hdr) >> 8) & 0xff)
+#define OF_OXM_MASKED_TYPE_SET(hdr, val)                    \\
+    (hdr) = ((hdr) & 0xffff00ff) + (((val) & 0xff) << 8)
+
+#define OF_OXM_LENGTH_GET(hdr) ((hdr) & 0xff)
+#define OF_OXM_LENGTH_SET(hdr, val)                         \\
+    (hdr) = ((hdr) & 0xffffff00) + ((val) & 0xff)
+
+extern void of_packet_queue_wire_length_get(of_object_t *obj, int *bytes);
+extern void of_packet_queue_wire_length_set(of_object_t *obj, int bytes);
+
+extern void of_list_meter_band_stats_wire_length_get(of_object_t *obj,
+                                                    int *bytes);
+extern void of_meter_stats_wire_length_get(of_object_t *obj, int *bytes);
+extern void of_meter_stats_wire_length_set(of_object_t *obj, int bytes);
+extern int of_extension_object_wire_push(of_object_t *obj);
+
+""")
+
+
+def gen_length_array(out):
+    """
+    Generate an array giving the lengths of all objects/versions
+    @param out The file handle to which to write
+    """
+    out.write("""
+/**
+ * An array with the number of bytes in the fixed length part
+ * of each OF object
+ */
+""")
+
+    for version in of_g.of_version_range:
+        out.write("""
+static int\nof_object_fixed_len_v%d[OF_OBJECT_COUNT] = {
+    -1,   /* of_object is not instantiable */
+""" % version)
+        for i, cls in enumerate(of_g.all_class_order):
+            comma = ","
+            if i == len(of_g.all_class_order) - 1:
+                comma = ""
+            val = "-1" + comma
+            if (cls, version) in of_g.base_length:
+                val = str(of_g.base_length[(cls, version)]) + comma
+            out.write("    %-5s /* %d: %s */\n" % (val, i + 1, cls))
+        out.write("};\n")
+
+    out.write("""
+/**
+ * Unified map of fixed length part of each object
+ */
+int *of_object_fixed_len[OF_VERSION_ARRAY_MAX] = {
+    NULL,
+""")
+    for version in of_g.of_version_range:
+        out.write("    of_object_fixed_len_v%d,\n" % version)
+    out.write("""
+};
+""")
+
+    
+################################################################
+################################################################
+
+# THIS IS PROBABLY NOT NEEDED AND MAY NOT BE CALLED CURRENTLY
+def gen_object_id_to_stats_type(out):
+    out.write("""
+/**
+ * Map from message object ID to stats type
+ *
+ * All message object IDs are mapped for simplicity
+ */
+""")
+    for version in of_g.of_version_range:
+        out.write("int *of_object_to_stats_type_map_v%d = {\n" % (i+1))
+        out.write("    -1, /* of_object (invalid) */\n");
+        for cls in of_g.ordered_messages:
+            name = cls[3:]
+            name = name[:name.find("_stats")]
+            if (((cls in type_maps.stats_reply_list) or
+                 (cls in type_maps.stats_request_list)) and
+                name in type_maps.stats_types[i]):
+                out.write("    %d, /* %s */\n" %
+                          (type_maps.stats_types[i][name], cls))
+            else:
+                out.write("    -1, /* %s (invalid) */\n" % cls)
+        out.write("};\n\n")
+
+    out.write("""
+/**
+ * Unified map, indexed by wire version which is 1-based.
+ */
+int *of_object_to_stats_type_map[OF_VERSION_ARRAY_MAX] = {
+    NULL,
+""")
+    for version in of_g.of_version_range:
+        out.write("    of_object_to_stats_type_map_v%d,\n" % version)
+    out.write("""
+};
+""")
+
diff --git a/c_gen/c_validator_gen.py b/c_gen/c_validator_gen.py
new file mode 100644
index 0000000..3ab6acf
--- /dev/null
+++ b/c_gen/c_validator_gen.py
@@ -0,0 +1,302 @@
+# Copyright 2013, Big Switch Networks, Inc.
+#
+# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+# the following special exception:
+#
+# LOXI Exception
+#
+# As a special exception to the terms of the EPL, you may distribute libraries
+# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+# that copyright and licensing notices generated by LoxiGen are not altered or removed
+# from the LoxiGen Libraries and the notice provided below is (i) included in
+# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+# documentation for the LoxiGen Libraries, if distributed in binary form.
+#
+# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+#
+# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+# a copy of the EPL at:
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# 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
+# EPL for the specific language governing permissions and limitations
+# under the EPL.
+
+"""
+@brief Validator function generation
+
+Generates validator function files.
+
+"""
+
+import sys
+import of_g
+import loxi_front_end.match as match
+import loxi_front_end.flags as flags
+from generic_utils import *
+import loxi_front_end.type_maps as type_maps
+import loxi_utils.loxi_utils as loxi_utils
+import loxi_front_end.identifiers as identifiers
+from c_test_gen import var_name_map
+
+def gen_h(out, name):
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""
+/**
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ *
+ * Declarations of message validation functions. These functions check that an
+ * OpenFlow message is well formed. Specifically, they check internal length
+ * fields.
+ */
+
+#if !defined(_LOCI_VALIDATOR_H_)
+#define _LOCI_VALIDATOR_H_
+
+#include <loci/loci.h>
+
+/*
+ * Validate an OpenFlow message.
+ * @return 0 if message is valid, -1 otherwise.
+ */
+extern int of_validate_message(of_message_t msg, int len);
+
+#endif /* _LOCI_VALIDATOR_H_ */
+""")
+
+def gen_c(out, name):
+    loxi_utils.gen_c_copy_license(out)
+    out.write("""
+/**
+ *
+ * AUTOMATICALLY GENERATED FILE.  Edits will be lost on regen.
+ *
+ * Source file for OpenFlow message validation.
+ *
+ */
+
+#include "loci_log.h"
+#include <loci/loci.h>
+#include <loci/loci_validator.h>
+
+#define VALIDATOR_LOG(...) LOCI_LOG_ERROR("Validator Error: " __VA_ARGS__)
+
+""")
+
+    # Declarations
+    for version in of_g.of_version_range:
+        ver_name = loxi_utils.version_to_name(version)
+        for cls in reversed(of_g.standard_class_order):
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            if cls in type_maps.inheritance_map:
+                continue
+            out.write("""
+static inline int %(cls)s_%(ver_name)s_validate(uint8_t *buf, int len);\
+""" % dict(cls=cls, ver_name=ver_name))
+
+    out.write("\n")
+
+    # Definitions
+    for version in of_g.of_version_range:
+        ver_name = loxi_utils.version_to_name(version)
+        for cls in reversed(of_g.standard_class_order):
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            if cls in type_maps.inheritance_map:
+                continue
+            if loxi_utils.class_is_list(cls):
+                gen_list_validator(out, cls, version)
+            else:
+                gen_validator(out, cls, version)
+
+        out.write("""
+int
+of_validate_message_%(ver_name)s(of_message_t msg, int len)
+{
+    of_object_id_t object_id = of_message_to_object_id(msg, len);
+    uint8_t *buf = OF_MESSAGE_TO_BUFFER(msg);
+    switch (object_id) {
+""" % dict(ver_name=ver_name))
+        for cls in reversed(of_g.standard_class_order):
+            if not loxi_utils.class_in_version(cls, version):
+                continue
+            if cls in type_maps.inheritance_map:
+                continue
+            if loxi_utils.class_is_message(cls):
+                out.write("""\
+    case %(cls_id)s:
+        return %(cls)s_%(ver_name)s_validate(buf, len);
+""" % dict(ver_name=ver_name, cls=cls, cls_id=cls.upper()))
+        out.write("""\
+    default:
+        VALIDATOR_LOG("%(cls)s: could not map %(cls_id)s");
+        return -1;
+    }
+}
+""" % dict(ver_name=ver_name, cls=cls, cls_id=cls.upper()))
+
+    out.write("""
+int
+of_validate_message(of_message_t msg, int len)
+{
+    of_version_t version;
+    if (len < OF_MESSAGE_MIN_LENGTH ||
+        len != of_message_length_get(msg)) {
+        VALIDATOR_LOG("message length %d != %d", len,
+                      of_message_length_get(msg));
+        return -1;
+    }
+
+    version = of_message_version_get(msg);
+    switch (version) {
+""")
+
+    for version in of_g.of_version_range:
+        ver_name = loxi_utils.version_to_name(version)
+        out.write("""\
+    case %(ver_name)s:
+        return of_validate_message_%(ver_name)s(msg, len);
+""" % dict(ver_name=ver_name))
+
+    out.write("""\
+    default:
+        VALIDATOR_LOG("Bad version %%d", %(ver_name)s);
+        return -1;
+    }
+}
+""" % dict(ver_name=ver_name))
+
+def gen_validator(out, cls, version):
+    fixed_len = of_g.base_length[(cls, version)];
+    ver_name = loxi_utils.version_to_name(version)
+    out.write("""
+static inline int
+%(cls)s_%(ver_name)s_validate(uint8_t *buf, int len)
+{
+    if (len < %(fixed_len)s) {
+        VALIDATOR_LOG("Class %(cls)s.  Len %%d too small, < %%d", len, %(fixed_len)s);
+        return -1;
+    }
+""" % dict(cls=cls, ver_name=ver_name, cls_id=cls.upper(), fixed_len=fixed_len))
+    members, member_types = loxi_utils.all_member_types_get(cls, version)
+    for member in members:
+        m_type = member["m_type"]
+        m_name = member["name"]
+        m_offset = member['offset']
+        m_cls = m_type[:-2] # Trim _t
+        if loxi_utils.skip_member_name(m_name):
+            continue
+        if not loxi_utils.type_is_of_object(m_type):
+            continue
+        if not loxi_utils.class_is_var_len(m_cls, version):
+            continue
+        if cls == "of_packet_out" and m_name == "actions":
+            # See _PACKET_OUT_ACTION_LEN
+            out.write("""
+    {
+        uint16_t %(m_name)s_len;
+        buf_u16_get(buf + %(m_offset)s - 2, &%(m_name)s_len);
+        if (%(m_name)s_len + %(m_offset)s > len) {
+            VALIDATOR_LOG("Class %(cls)s, member %(m_name)s.  "
+                          "Len %%d and offset %%d too big for %%d",
+                          %(m_name)s_len, %(m_offset)s, len);
+            return -1;
+        }
+""" % dict(m_name=m_name, m_offset=m_offset, cls=cls))
+        else:
+            out.write("""
+    
+    {    int %(m_name)s_len = len - %(m_offset)s;
+   
+"""  % dict(m_name=m_name, m_offset=m_offset))
+        out.write("""
+        if (%(m_cls)s_%(ver_name)s_validate(buf + %(m_offset)s, %(m_name)s_len) < 0) {
+            return -1;
+        }
+    }
+""" % dict(m_name=m_name, m_cls=m_cls, ver_name=ver_name, m_offset=m_offset))
+    out.write("""
+    return 0;
+}
+""")
+
+def gen_list_validator(out, cls, version):
+    ver_name = loxi_utils.version_to_name(version)
+    e_cls = loxi_utils.list_to_entry_type(cls)
+    fixed_len = of_g.base_length[(e_cls, version)];
+    out.write("""
+static inline int
+%(cls)s_%(ver_name)s_validate(uint8_t *buf, int len)
+{
+""" % dict(cls=cls, ver_name=ver_name, cls_id=cls.upper(), e_cls=e_cls))
+
+    # TLV16
+    if loxi_utils.class_is_tlv16(e_cls):
+        subclasses = type_maps.inheritance_map[e_cls]
+        out.write("""\
+    while (len >= %(fixed_len)s) {
+        of_object_id_t e_id; 
+        uint16_t e_type, e_len;
+        buf_u16_get(buf, &e_type);
+        buf_u16_get(buf+2, &e_len);
+        e_id = %(e_cls)s_to_object_id(e_type, %(ver_name)s);
+        switch (e_id) {
+""" % dict(fixed_len=fixed_len, ver_name=ver_name, e_cls=e_cls))
+        for subcls in subclasses:
+            subcls = e_cls + '_' + subcls
+            if not loxi_utils.class_in_version(subcls, version):
+                continue
+            out.write("""\
+        case %(subcls_enum)s:
+            if (%(subcls)s_%(ver_name)s_validate(buf, e_len) < 0) {
+                return -1;
+            }
+            break;
+""" % dict(ver_name=ver_name, subcls=subcls, subcls_enum=loxi_utils.enum_name(subcls)))
+        out.write("""\
+        default:
+            return -1;
+        }
+        buf += e_len;
+        len -= e_len;
+    }
+    if (len != 0) {
+        return -1;
+    }
+""" % dict(e_cls=e_cls, ver_name=ver_name))
+
+    # U16 len
+    elif loxi_utils.class_is_u16_len(e_cls) or loxi_utils.class_is_action(e_cls):
+        out.write("""\
+    /* TODO verify U16 len elements */
+""" % dict())
+
+    # OXM
+    elif loxi_utils.class_is_oxm(e_cls):
+        out.write("""\
+    /* TODO verify OXM elements */
+""" % dict())
+
+    # Fixed length
+    elif not loxi_utils.class_is_var_len(e_cls, version):
+        out.write("""\
+    if ((len / %(fixed_len)s) * %(fixed_len)s != len) {
+        return -1;
+    }
+""" % dict(fixed_len=fixed_len))
+
+    # ???
+    else:
+        out.write("""\
+    /* XXX unknown element format */
+""" % dict())
+
+    out.write("""
+    return 0;
+}
+""")
diff --git a/c_gen/templates/.gitignore b/c_gen/templates/.gitignore
new file mode 100644
index 0000000..c3ed10e
--- /dev/null
+++ b/c_gen/templates/.gitignore
@@ -0,0 +1 @@
+*.cache
diff --git a/c_gen/templates/Doxyfile b/c_gen/templates/Doxyfile
new file mode 100644
index 0000000..983aba9
--- /dev/null
+++ b/c_gen/templates/Doxyfile
@@ -0,0 +1,1551 @@
+# Doxyfile 1.6.3
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = "LOCI OpenFlow Interfaces"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER         =
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = doc
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH        =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF      = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it parses.
+# With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this tag.
+# The format is ext=language, where ext is a file extension, and language is one of
+# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
+# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
+# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING      =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penality.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will rougly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE      = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC         = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES   = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS        = YES
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = YES
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES       = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
+# doxygen. The layout file controls the global structure of the generated output files
+# in an output format independent way. The create the layout file that represents
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name
+# of the layout file.
+
+LAYOUT_FILE            =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE           =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT                  = src inc/loci
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS          =
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE              = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE                =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH           =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS       =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH             =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER           =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS        =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER            =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER            =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET        =
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP         = YES
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE               =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING     =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
+# are set, an additional index file will be generated that can be used as input for
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
+# HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
+# For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION           =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+#  will be generated, which together with the HTML files, form an Eclipse help
+#  plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before the help appears.
+
+GENERATE_ECLIPSEHELP   = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX          = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW      = NO
+
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES       = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE           = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be implemented using a PHP enabled web server instead of at the web client using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server based approach is that it scales better to large projects and allows full text search. The disadvances is that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX         = YES
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA             =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD                =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH           =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS  =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED             =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED      =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES               =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH            =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = NO
+
+# By default doxygen will write a font called FreeSans.ttf to the output
+# directory and reference it in all dot files that doxygen generates. This
+# font does not include all possible unicode characters however, so when you need
+# these (or just want a differently looking font) you can specify the font name
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME           = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH           =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK               = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT       = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH               =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS           =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = YES
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP            = YES
diff --git a/c_gen/templates/README b/c_gen/templates/README
new file mode 100644
index 0000000..71c4a48
--- /dev/null
+++ b/c_gen/templates/README
@@ -0,0 +1,73 @@
+Introduction
+============
+
+LOCI is the C language module of LOXI, the Logical OpenFlow Extensible
+Interface. It provides a framework for managing OpenFlow objects in
+an object oriented fashion.
+
+All files in LOCI, even this README, are generated by LOXI. Please make
+modifications to LOXI instead of to these files directly.
+
+Compilation
+===========
+
+It's expected that users of LOCI will want to integrate it into their own build
+system. As an example, here's a simple command line to create a shared library
+on Linux:
+
+    gcc -fPIC -shared -I inc src/*.c -o loci.so
+
+LOCI has no dependencies beyond the C standard library.
+
+Documentation
+=============
+
+A Doxygen configuration file is provided. Just run `doxygen` to generate HTML
+documentation pages. Each OpenFlow object is linked to under the "Modules"
+tab.
+
+Usage
+=====
+
+Currently the best example code for using LOCI is the switchlight-core
+repository.
+
+Here's example code that creates a flow mod:
+
+    /* Create the match */
+    of_match_t match;
+    memset(&match, 0, sizeof(match));
+    match.fields.in_port = 1;
+    OF_MATCH_MASK_IN_PORT_EXACT_SET(&match);
+    match.fields.eth_type = 0x8000;
+    OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match);
+
+    /* Create a flow mod */
+    of_flow_add_t *flow_add = of_flow_add_new(OF_VERSION_1_0);
+    of_flow_add_idle_timeout_set(flow_add, 5);
+    of_flow_add_cookie_set(flow_add, 42);
+    of_flow_add_priority_set(flow_add, 10000);
+    of_flow_add_buffer_id_set(flow_add, -1);
+    if (of_flow_add_match_set(flow_add, &match)) {
+        fprintf(stderr, "Failed to set the match field\n");
+        abort();
+    }
+
+    /* Populate the action list */
+    of_list_action_t actions;
+    of_flow_add_actions_bind(flow_add, &actions);
+    int i;
+    for (i = 1; i <= 4; i++) {
+        of_action_output_t action;
+        of_action_output_init(&action, flow_add->version, -1, 1);
+        of_list_action_append_bind(&actions, (of_action_t *)&action);
+        of_action_output_port_set(&action, i);
+    }
+
+    /* Use the underlying buffer */
+    void *buf = WBUF_BUF(OF_OBJECT_TO_WBUF(flow_add));
+    uint16_t len = flow_add->length;
+    /* ... */
+
+    /* Free the flow mod */
+    of_flow_add_delete(flow_add);
diff --git a/c_gen/templates/bsn_ext.h b/c_gen/templates/bsn_ext.h
new file mode 100644
index 0000000..6afa211
--- /dev/null
+++ b/c_gen/templates/bsn_ext.h
@@ -0,0 +1,44 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/**
+ * BSN OpenFlow extension definition header file
+ */
+
+#ifndef _LOCI_BSN_EXT_H_
+#define _LOCI_BSN_EXT_H_
+
+/* Mirroring for destination, bit in port_config */
+#define OF_PORT_CONFIG_BSN_MIRROR_DEST (1 << 31) /* Mirror destination only */
+
+/* Point at which mirroring is to occur */
+#define OF_BSN_MIRROR_STAGE_INGRESS 0
+#define OF_BSN_MIRROR_STAGE_EGRESS 1
+
+#endif /* _LOCI_BSN_EXT_H_ */
diff --git a/c_gen/templates/loci_dox.h b/c_gen/templates/loci_dox.h
new file mode 100644
index 0000000..86c29db
--- /dev/null
+++ b/c_gen/templates/loci_dox.h
@@ -0,0 +1,55 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/**************************************************************************//**
+ * 
+ * loci Doxygen Header
+ * 
+ *****************************************************************************/
+#ifndef __LOCI_DOX_H__
+#define __LOCI_DOX_H__
+
+/**
+ * @defgroup loci loci - loci Description
+ *
+
+The documentation overview for this module should go here. 
+
+ *
+ * @{
+ *
+ * @defgroup loci-loci Public Interface
+ * @defgroup loci-config Compile Time Configuration
+ * @defgroup loci-porting Porting Macros
+ * 
+ * @}
+ *
+ */
+
+#endif /* __LOCI_DOX_H__ */
diff --git a/c_gen/templates/loci_dump.h b/c_gen/templates/loci_dump.h
new file mode 100644
index 0000000..12bba6e
--- /dev/null
+++ b/c_gen/templates/loci_dump.h
@@ -0,0 +1,101 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2012, Big Switch Networks, Inc. */
+
+#if !defined(_LOCI_DUMP_H_)
+#define _LOCI_DUMP_H_
+
+#include <loci/loci_base.h>
+#include <loci/of_match.h>
+#include <stdio.h>
+
+/* g++ requires this to pick up PRI, etc.
+ * See  http://gcc.gnu.org/ml/gcc-help/2006-10/msg00223.html
+ */
+#if !defined(__STDC_FORMAT_MACROS)
+#define __STDC_FORMAT_MACROS
+#endif
+#include <inttypes.h>
+
+typedef int (*loci_obj_dump_f)(loci_writer_f writer, void *cookie, of_object_t *obj);
+
+/****************************************************************
+ *
+ * Per-datatype dump macros
+ *
+ ****************************************************************/
+#define LOCI_DUMP_u8(writer, cookie, val) writer(cookie, "%u", (val))
+#define LOCI_DUMP_u16(writer, cookie, val) writer(cookie, "%u (0x%x)", (val), (val))
+#define LOCI_DUMP_u32(writer, cookie, val) writer(cookie, "%u (0x%x)", (val), (val))
+#define LOCI_DUMP_u64(writer, cookie, val) writer(cookie, "%" PRIu64 "(0x%" PRIx64 ")", (val), (val))
+
+/* @todo Add checks for special port numbers */
+#define LOCI_DUMP_port_no(writer, cookie, val) LOCI_DUMP_u32(writer, cookie, val)
+#define LOCI_DUMP_fm_cmd(writer, cookie, val) LOCI_DUMP_u16(writer, cookie, val)
+
+/* @todo Decode wildcards */
+#define LOCI_DUMP_wc_bmap(writer, cookie, val)         \
+    writer(cookie, "0x%" PRIx64, (val))
+#define LOCI_DUMP_match_bmap(writer, cookie, val)      \
+    writer(cookie, "0x%" PRIx64, (val))
+
+/* @todo Dump first N bytes of data */
+#define LOCI_DUMP_octets(writer, cookie, val)                                      \
+    writer(cookie, "%d bytes at location %p", (val).bytes, (val).data)
+
+#define LOCI_DUMP_mac(writer, cookie, val)                                 \
+    writer(cookie, "%02x:%02x:%02x:%02x:%02x:%02x",            \
+               (val).addr[0], (val).addr[1], (val).addr[2],     \
+               (val).addr[3], (val).addr[4], (val).addr[5])
+
+#define LOCI_DUMP_ipv4(writer, cookie, val)                                        \
+    writer(cookie, "%d.%d.%d.%d", val >> 24, (val >> 16) & 0xff,       \
+               (val >> 8) & 0xff, val & 0xff)
+
+#define LOCI_DUMP_ipv6(writer, cookie, val)                                        \
+    writer(cookie, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", \
+               (val).addr[0], (val).addr[1], (val).addr[2], (val).addr[3], \
+               (val).addr[4], (val).addr[5], (val).addr[6], (val).addr[7], \
+               (val).addr[8], (val).addr[9], (val).addr[10], (val).addr[11], \
+               (val).addr[12], (val).addr[13], (val).addr[14], (val).addr[15])
+
+#define LOCI_DUMP_string(writer, cookie, val) writer(cookie, "%s", val)
+
+#define LOCI_DUMP_port_name(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
+#define LOCI_DUMP_tab_name(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
+#define LOCI_DUMP_desc_str(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
+#define LOCI_DUMP_ser_num(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
+
+int loci_dump_match(loci_writer_f writer, void* cookie, of_match_t *match);
+#define LOCI_DUMP_match(writer, cookie, val) loci_dump_match(writer, cookie, &val)
+
+/**
+ * Generic version for any object
+ */
+int of_object_dump(loci_writer_f writer, void *cookie, of_object_t *obj);
+#endif /* _LOCI_DUMP_H_ */
diff --git a/c_gen/templates/loci_int.h b/c_gen/templates/loci_int.h
new file mode 100644
index 0000000..ce5ecb0
--- /dev/null
+++ b/c_gen/templates/loci_int.h
@@ -0,0 +1,45 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/******************************************************************************
+ *
+ *  /module/src/loci_int.h
+ *
+ *  loci Internal Header
+ *
+ *****************************************************************************/
+#ifndef __LOCI_INT_H__
+#define __LOCI_INT_H__
+
+
+
+
+
+#include <loci/loci.h> 
+#endif /* __LOCI_INT_H__ */
diff --git a/c_gen/templates/loci_log.c b/c_gen/templates/loci_log.c
new file mode 100644
index 0000000..cf34eae
--- /dev/null
+++ b/c_gen/templates/loci_log.c
@@ -0,0 +1,44 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2012, Big Switch Networks, Inc. */
+
+#include <stdarg.h>
+
+#include "loci_log.h"
+
+#include <loci/loci.h>
+
+static int
+loci_null_logger(loci_log_level_t level,
+                 const char *fname, const char *file, int line,
+                 const char *format, ...)
+{
+    return 0;
+}
+
+loci_logger_f loci_logger = loci_null_logger;
diff --git a/c_gen/templates/loci_log.h b/c_gen/templates/loci_log.h
new file mode 100644
index 0000000..3e22d81
--- /dev/null
+++ b/c_gen/templates/loci_log.h
@@ -0,0 +1,57 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2012, Big Switch Networks, Inc. */
+
+#if !defined(_LOCI_LOG_H_)
+#define _LOCI_LOG_H_
+
+#include <loci/loci_base.h>
+#include <loci/of_match.h>
+#include <stdio.h>
+
+/* g++ requires this to pick up PRI, etc.
+ * See  http://gcc.gnu.org/ml/gcc-help/2006-10/msg00223.html
+ */
+#if !defined(__STDC_FORMAT_MACROS)
+#define __STDC_FORMAT_MACROS
+#endif
+#include <inttypes.h>
+
+/**
+ * Per level log macros.  printf semantics
+ */
+
+#define LOCI_LOG_COMMON(level, ...) loci_logger(level, __func__, __FILE__, __LINE__, __VA_ARGS__)
+#define LOCI_LOG_TRACE(...) LOCI_LOG_COMMON(LOCI_LOG_LEVEL_TRACE, __VA_ARGS__)
+#define LOCI_LOG_VERBOSE(...) LOCI_LOG_COMMON(LOCI_LOG_LEVEL_VERBOSE, __VA_ARGS__)
+#define LOCI_LOG_INFO(...) LOCI_LOG_COMMON(LOCI_LOG_LEVEL_INFO, __VA_ARGS__)
+#define LOCI_LOG_WARN(...) LOCI_LOG_COMMON(LOCI_LOG_LEVEL_WARN, __VA_ARGS__)
+#define LOCI_LOG_ERROR(...) LOCI_LOG_COMMON(LOCI_LOG_LEVEL_ERROR, __VA_ARGS__)
+#define LOCI_LOG_MSG(...) LOCI_LOG_COMMON(LOCI_LOG_LEVEL_MSG, __VA_ARGS__)
+
+#endif /* _LOCI_LOG_H_ */
diff --git a/c_gen/templates/loci_show.h b/c_gen/templates/loci_show.h
new file mode 100644
index 0000000..86efab1
--- /dev/null
+++ b/c_gen/templates/loci_show.h
@@ -0,0 +1,328 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2012, Big Switch Networks, Inc. */
+
+#if !defined(_LOCI_SHOW_H_)
+#define _LOCI_SHOW_H_
+
+#include <loci/loci_base.h>
+#include <loci/of_match.h>
+#include <stdio.h>
+
+/* g++ requires this to pick up PRI, etc.
+ * See  http://gcc.gnu.org/ml/gcc-help/2006-10/msg00223.html
+ */
+#if !defined(__STDC_FORMAT_MACROS)
+#define __STDC_FORMAT_MACROS
+#endif
+#include <inttypes.h>
+
+typedef int (*loci_obj_show_f)(loci_writer_f writer,
+                               void *cookie, of_object_t *obj);
+
+/****************************************************************
+ *
+ * Per-datatype dump macros
+ *
+ ****************************************************************/
+#define LOCI_SHOW_u8(writer, cookie, val) writer(cookie, "%u", (val))
+#define LOCI_SHOW_u16(writer, cookie, val) writer(cookie, "%u (0x%x)", (val), (val))
+#define LOCI_SHOW_u32(writer, cookie, val) writer(cookie, "%u (0x%x)", (val), (val))
+#define LOCI_SHOW_u64(writer, cookie, val) writer(cookie, "%" PRIu64 "(0x%" PRIx64 ")", (val), (val))
+
+#define LOCI_SHOW_D_INT(cookie, macro, val) writer(cookie, "%" macro , val); 
+#define LOCI_SHOW_X_INT(cookie, macro, val) writer(cookie, "0x%" macro, val); 
+
+#define LOCI_SHOW_x8(writer, cookie, val) LOCI_SHOW_X_INT(cookie,  PRIx8, val)
+#define LOCI_SHOW_x16(writer, cookie, val) LOCI_SHOW_X_INT(cookie, PRIx16, val)
+#define LOCI_SHOW_x32(writer, cookie, val) LOCI_SHOW_X_INT(cookie, PRIx32, val)
+#define LOCI_SHOW_x64(writer, cookie, val) LOCI_SHOW_X_INT(cookie, PRIx64, val)
+#define LOCI_SHOW_d8(writer, cookie, val) LOCI_SHOW_D_INT(cookie, PRId8, val)
+#define LOCI_SHOW_d16(writer, cookie, val) LOCI_SHOW_D_INT(cookie, PRId16, val)
+#define LOCI_SHOW_d32(writer, cookie, val) LOCI_SHOW_D_INT(cookie, PRId32, val)
+#define LOCI_SHOW_d64(writer, cookie, val) LOCI_SHOW_D_INT(cookie, PRId64, val)
+
+
+
+/**
+ * Field-specific show macros. 
+ */
+#define LOCI_SHOW_u32_ipv6_flabel(writer, cookie, val)     LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u8_vlan_pcp(writer, cookie, val)         LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u32_ipv4_src(writer, cookie, val)        LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_ipv6_ipv6_dst(writer, cookie, val)       LOCI_SHOW_ipv6(writer, cookie, val)
+#define LOCI_SHOW_u32_arp_tpa(writer, cookie, val)         LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_u8_icmpv6_type(writer, cookie, val)      LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_mac_arp_sha(writer, cookie, val)         LOCI_SHOW_mac(writer, cookie, val)
+#define LOCI_SHOW_ipv6_ipv6_src(writer, cookie, val)       LOCI_SHOW_ipv6(writer, cookie, val)
+#define LOCI_SHOW_u16_sctp_src(writer, cookie, val)        LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u8_icmpv6_code(writer, cookie, val)      LOCI_SHOW_x8(writer, cookie, val)
+#define LOCI_SHOW_mac_eth_dst(writer, cookie, val)         LOCI_SHOW_mac(writer, cookie, val)
+#define LOCI_SHOW_mac_ipv6_nd_sll(writer, cookie, val)     LOCI_SHOW_mac(writer, cookie, val)
+#define LOCI_SHOW_u8_mpls_tc(writer, cookie, val)          LOCI_SHOW_x8(writer, cookie, val)
+#define LOCI_SHOW_u16_arp_op(writer, cookie, val)          LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u16_eth_type(writer, cookie, val)        LOCI_SHOW_x16(writer, cookie, val)
+#define LOCI_SHOW_ipv6_ipv6_nd_target(writer, cookie, val) LOCI_SHOW_ipv6(writer, cookie, val)
+#define LOCI_SHOW_u16_vlan_vid(writer, cookie, val)        LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_mac_arp_tha(writer, cookie, val)         LOCI_SHOW_mac(writer, cookie, val)
+#define LOCI_SHOW_port_no_in_port(writer, cookie, val)     LOCI_SHOW_port_no(writer, cookie, val)
+#define LOCI_SHOW_u8_ip_dscp(writer, cookie, val)          LOCI_SHOW_x8(writer, cookie, val)
+#define LOCI_SHOW_u16_sctp_dst(writer, cookie, val)        LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u8_icmpv4_code(writer, cookie, val)      LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u16_tcp_src(writer, cookie, val)         LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u32_arp_spa(writer, cookie, val)         LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_u8_ip_ecn(writer, cookie, val)           LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u16_udp_dst(writer, cookie, val)         LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_port_no_in_phy_port(writer, cookie, val) LOCI_SHOW_port_no(writer, cookie, val)
+#define LOCI_SHOW_u32_ipv4_dst(writer, cookie, val)        LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_mac_eth_src(writer, cookie, val)         LOCI_SHOW_mac(writer, cookie, val)
+#define LOCI_SHOW_u16_udp_src(writer, cookie, val)         LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_mac_ipv6_nd_tll(writer, cookie, val)     LOCI_SHOW_mac(writer, cookie, val)
+#define LOCI_SHOW_u8_icmpv4_type(writer, cookie, val)      LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u32_mpls_label(writer, cookie, val)      LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u16_tcp_dst(writer, cookie, val)         LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u8_ip_proto(writer, cookie, val)         LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u64_metadata(writer, cookie, val)        LOCI_SHOW_x64(writer, cookie, val)
+
+
+
+
+/* @todo Add checks for special port numbers */
+#define LOCI_SHOW_port_no(writer, cookie, val) writer(cookie, "%d", val)
+#define LOCI_SHOW_fm_cmd(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+
+/* @todo Decode wildcards */
+#define LOCI_SHOW_wc_bmap(writer, cookie, val)         \
+    writer(cookie, "0x%" PRIx64, (val))
+#define LOCI_SHOW_match_bmap(writer, cookie, val)      \
+    writer(cookie, "0x%" PRIx64, (val))
+
+/* @todo Dump first N bytes of data */
+#define LOCI_SHOW_octets(writer, cookie, val)                                      \
+    writer(cookie, "%d bytes at location %p", (val).bytes, (val).data)
+
+#define LOCI_SHOW_mac(writer, cookie, val)                                 \
+    writer(cookie, "%02x:%02x:%02x:%02x:%02x:%02x",            \
+               (val).addr[0], (val).addr[1], (val).addr[2],     \
+               (val).addr[3], (val).addr[4], (val).addr[5])
+
+#define LOCI_SHOW_ipv4(writer, cookie, val)                                        \
+    writer(cookie, "%d.%d.%d.%d", val >> 24, (val >> 16) & 0xff,       \
+               (val >> 8) & 0xff, val & 0xff)
+
+#define LOCI_SHOW_ipv6(writer, cookie, val)                                        \
+    writer(cookie, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", \
+               (val).addr[0], (val).addr[1], (val).addr[2], (val).addr[3], \
+               (val).addr[4], (val).addr[5], (val).addr[6], (val).addr[7], \
+               (val).addr[8], (val).addr[9], (val).addr[10], (val).addr[11], \
+               (val).addr[12], (val).addr[13], (val).addr[14], (val).addr[15])
+
+#define LOCI_SHOW_string(writer, cookie, val) writer(cookie, "%s", val)
+
+#define LOCI_SHOW_port_name(writer, cookie, val) LOCI_SHOW_string(writer, cookie, val)
+#define LOCI_SHOW_tab_name(writer, cookie, val) LOCI_SHOW_string(writer, cookie, val)
+#define LOCI_SHOW_desc_str(writer, cookie, val) LOCI_SHOW_string(writer, cookie, val)
+#define LOCI_SHOW_ser_num(writer, cookie, val) LOCI_SHOW_string(writer, cookie, val)
+
+int loci_show_match(loci_writer_f writer, void *cookie, of_match_t *match);
+#define LOCI_SHOW_match(writer, cookie, val) loci_show_match(writer, cookie, &val)
+
+/**
+ * Generic version for any object
+ */
+int of_object_show(loci_writer_f writer, void *cookie, of_object_t *obj);
+
+
+
+
+/**
+ * Choose a representation for each field that 
+ * makes the most sense for display to the user. 
+ */
+#define LOCI_SHOW_u32_xid(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u16_flags(writer, cookie, val) LOCI_SHOW_x16(writer, cookie, val)
+#define LOCI_SHOW_u64_packet_count(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_byte_count(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u32_flow_count(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_match_match(writer, cookie, val) LOCI_SHOW_match(writer, cookie, val)
+#define LOCI_SHOW_u8_table_id(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_port_no_out_port(writer, cookie, val) LOCI_SHOW_port_no(writer, cookie, val)
+#define LOCI_SHOW_u32_experimenter(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_subtype(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u8_index(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u32_mask(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u8_report_mirror_ports(writer, cookie, val) LOCI_SHOW_x8(writer, cookie, val)
+#define LOCI_SHOW_desc_str_mfr_desc(writer, cookie, val) LOCI_SHOW_desc_str(writer, cookie, val)
+#define LOCI_SHOW_desc_str_hw_desc(writer, cookie, val) LOCI_SHOW_desc_str(writer, cookie, val)
+#define LOCI_SHOW_desc_str_sw_desc(writer, cookie, val) LOCI_SHOW_desc_str(writer, cookie, val)
+#define LOCI_SHOW_ser_num_serial_num(writer, cookie, val) LOCI_SHOW_ser_num(writer, cookie, val)
+#define LOCI_SHOW_desc_str_dp_desc(writer, cookie, val) LOCI_SHOW_desc_str(writer, cookie, val)
+#define LOCI_SHOW_octets_data(writer, cookie, val) LOCI_SHOW_octets(writer, cookie, val)
+#define LOCI_SHOW_u16_err_type(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u16_code(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u64_datapath_id(writer, cookie, val) LOCI_SHOW_x64(writer, cookie, val)
+#define LOCI_SHOW_u32_n_buffers(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u8_n_tables(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u32_capabilities(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_actions(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u64_cookie(writer, cookie, val) LOCI_SHOW_x64(writer, cookie, val)
+#define LOCI_SHOW_u16_idle_timeout(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u16_hard_timeout(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u16_priority(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u32_buffer_id(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u8_reason(writer, cookie, val) LOCI_SHOW_x8(writer, cookie, val)
+#define LOCI_SHOW_u32_duration_sec(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_duration_nsec(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u16_miss_send_len(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u32_role(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u16_total_len(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_port_no_port_no(writer, cookie, val) LOCI_SHOW_port_no(writer, cookie, val)
+#define LOCI_SHOW_mac_hw_addr(writer, cookie, val) LOCI_SHOW_mac(writer, cookie, val)
+#define LOCI_SHOW_u32_config(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_advertise(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_port_no_port(writer, cookie, val) LOCI_SHOW_port_no(writer, cookie, val)
+#define LOCI_SHOW_u32_queue_id(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_dest_port(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_vlan_tag(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u8_copy_stage(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u16_max_len(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_mac_dl_addr(writer, cookie, val) LOCI_SHOW_mac(writer, cookie, val)
+#define LOCI_SHOW_u32_nw_addr(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_u8_nw_tos(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u16_tp_port(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_wc_bmap_wildcards(writer, cookie, val) LOCI_SHOW_wc_bmap(writer, cookie, val)
+#define LOCI_SHOW_port_name_name(writer, cookie, val) LOCI_SHOW_port_name(writer, cookie, val)
+#define LOCI_SHOW_u32_state(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_curr(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_advertised(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_supported(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_peer(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u64_rx_packets(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_tx_packets(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_rx_bytes(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_tx_bytes(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_rx_dropped(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_tx_dropped(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_rx_errors(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_tx_errors(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_rx_frame_err(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_rx_over_err(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_rx_crc_err(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_collisions(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u16_rate(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_tab_name_name(writer, cookie, val) LOCI_SHOW_tab_name(writer, cookie, val)
+#define LOCI_SHOW_u32_max_entries(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_active_count(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u64_lookup_count(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_matched_count(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u32_out_group(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u64_cookie_mask(writer, cookie, val) LOCI_SHOW_x64(writer, cookie, val)
+#define LOCI_SHOW_u32_reserved(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u16_command(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u8_group_type(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u32_group_id(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u16_ethertype(writer, cookie, val) LOCI_SHOW_x16(writer, cookie, val)
+#define LOCI_SHOW_u8_mpls_ttl(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u8_nw_ecn(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u8_nw_ttl(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u16_weight(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_port_no_watch_port(writer, cookie, val) LOCI_SHOW_port_no(writer, cookie, val)
+#define LOCI_SHOW_u32_watch_group(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_ref_count(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u64_metadata_mask(writer, cookie, val) LOCI_SHOW_x64(writer, cookie, val)
+#define LOCI_SHOW_mac_eth_src_mask(writer, cookie, val) LOCI_SHOW_mac(writer, cookie, val)
+#define LOCI_SHOW_mac_eth_dst_mask(writer, cookie, val) LOCI_SHOW_mac(writer, cookie, val)
+#define LOCI_SHOW_u32_ipv4_src_mask(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_u32_ipv4_dst_mask(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_u32_curr_speed(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_max_speed(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_match_bmap_match(writer, cookie, val) LOCI_SHOW_match_bmap(writer, cookie, val)
+#define LOCI_SHOW_u32_instructions(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_write_actions(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_apply_actions(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_types(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_max_groups_all(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_max_groups_select(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_max_groups_indirect(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_max_groups_ff(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_actions_all(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_actions_select(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_actions_indirect(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_actions_ff(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u64_generation_id(writer, cookie, val) LOCI_SHOW_x64(writer, cookie, val)
+#define LOCI_SHOW_octets_field(writer, cookie, val) LOCI_SHOW_octets(writer, cookie, val)
+#define LOCI_SHOW_u16_value(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u16_value_mask(writer, cookie, val) LOCI_SHOW_x16(writer, cookie, val)
+#define LOCI_SHOW_mac_value(writer, cookie, val) LOCI_SHOW_mac(writer, cookie, val)
+#define LOCI_SHOW_mac_value_mask(writer, cookie, val) LOCI_SHOW_mac(writer, cookie, val)
+#define LOCI_SHOW_u32_value(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_value_mask(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_oxm_header(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u8_value(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u8_value_mask(writer, cookie, val) LOCI_SHOW_x8(writer, cookie, val)
+#define LOCI_SHOW_port_no_value(writer, cookie, val) LOCI_SHOW_port_no(writer, cookie, val)
+#define LOCI_SHOW_port_no_value_mask(writer, cookie, val) LOCI_SHOW_port_no(writer, cookie, val)
+#define LOCI_SHOW_ipv6_value(writer, cookie, val) LOCI_SHOW_ipv6(writer, cookie, val)
+#define LOCI_SHOW_ipv6_value_mask(writer, cookie, val) LOCI_SHOW_ipv6(writer, cookie, val)
+#define LOCI_SHOW_u64_value(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_value_mask(writer, cookie, val) LOCI_SHOW_x64(writer, cookie, val)
+#define LOCI_SHOW_u64_write_setfields(writer, cookie, val) LOCI_SHOW_x64(writer, cookie, val)
+#define LOCI_SHOW_u64_apply_setfields(writer, cookie, val) LOCI_SHOW_x64(writer, cookie, val)
+#define LOCI_SHOW_u64_metadata_match(writer, cookie, val) LOCI_SHOW_x64(writer, cookie, val)
+#define LOCI_SHOW_u64_metadata_write(writer, cookie, val) LOCI_SHOW_x64(writer, cookie, val)
+#define LOCI_SHOW_u32_packet_in_mask_equal_master(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_packet_in_mask_slave(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_port_status_mask_equal_master(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_port_status_mask_slave(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_flow_removed_mask_equal_master(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u32_flow_removed_mask_slave(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u8_auxiliary_id(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u32_meter_id(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_rate(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_burst_size(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u8_prec_level(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u64_packet_band_count(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_byte_band_count(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u32_max_meter(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_band_types(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
+#define LOCI_SHOW_u8_max_bands(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u8_max_color(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u64_packet_in_count(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_u64_byte_in_count(writer, cookie, val) LOCI_SHOW_u64(writer, cookie, val)
+#define LOCI_SHOW_octets_experimenter_data(writer, cookie, val) LOCI_SHOW_octets(writer, cookie, val)
+#define LOCI_SHOW_u32_dst(writer, cookie, val)        LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_u32_service(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_status(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u16_subtype(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u32_ipv4_addr(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_u32_ipv4_netmask(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
+
+
+
+
+#endif /* _LOCI_SHOW_H_ */
diff --git a/c_gen/templates/locitest/locitest_config.c b/c_gen/templates/locitest/locitest_config.c
new file mode 100644
index 0000000..c7c6fa2
--- /dev/null
+++ b/c_gen/templates/locitest/locitest_config.c
@@ -0,0 +1,49 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2012, Big Switch Networks, Inc. */
+
+/******************************************************************************
+ *
+ *  /module/src/locitest_config.c
+ *
+ *  locitest Config Information
+ *
+ *****************************************************************************/
+#include <locitest/locitest_config.h> 
+#include <locitest/locitest.h> 
+#include "locitest_int.h" 
+#include <stdlib.h>
+#include <string.h>
+
+
+
+/* <auto.start.cdefs(LOCITEST_CONFIG_HEADER).source> */
+/* <auto.end.cdefs(LOCITEST_CONFIG_HEADER).source> */
+
+
+
diff --git a/c_gen/templates/locitest/locitest_enums.c b/c_gen/templates/locitest/locitest_enums.c
new file mode 100644
index 0000000..7c3f074
--- /dev/null
+++ b/c_gen/templates/locitest/locitest_enums.c
@@ -0,0 +1,47 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2012, Big Switch Networks, Inc. */
+
+/******************************************************************************
+ *
+ *  /module/src/locitest_enums.c
+ *
+ *  locitest Enum Definitions
+ *
+ *****************************************************************************/
+#include <locitest/locitest_config.h> 
+#include <locitest/locitest.h> 
+#include "locitest_int.h" 
+
+
+
+#include <stdlib.h>
+#include <string.h>
+
+/* <auto.start.enum(ALL).source> */
+/* <auto.end.enum(ALL).source> */
diff --git a/c_gen/templates/locitest/locitest_int.h b/c_gen/templates/locitest/locitest_int.h
new file mode 100644
index 0000000..b058604
--- /dev/null
+++ b/c_gen/templates/locitest/locitest_int.h
@@ -0,0 +1,46 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2012, Big Switch Networks, Inc. */
+
+/******************************************************************************
+ *
+ *  /module/src/locitest_int.h
+ *
+ *  locitest Internal Header
+ *
+ *****************************************************************************/
+#ifndef __LOCITEST_INT_H__
+#define __LOCITEST_INT_H__
+
+
+#include <locitest/locitest_config.h>
+
+
+
+#include <locitest/locitest.h> 
+#endif /* __LOCITEST_INT_H__ */
diff --git a/c_gen/templates/locitest/test_ext.c b/c_gen/templates/locitest/test_ext.c
new file mode 100644
index 0000000..1efcaf6
--- /dev/null
+++ b/c_gen/templates/locitest/test_ext.c
@@ -0,0 +1,69 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2012, Big Switch Networks, Inc. */
+
+/**
+ * Test extensions
+ */
+
+#include <locitest/test_common.h>
+
+/**
+ * Simple tests for extension objects
+ */
+
+int
+test_ext_objs(void)
+{
+    of_action_bsn_mirror_t *obj;
+
+    obj = of_action_bsn_mirror_new(OF_VERSION_1_0);
+    TEST_ASSERT(obj != NULL);
+    TEST_ASSERT(obj->object_id == OF_ACTION_BSN_MIRROR);
+
+    TEST_ASSERT(of_action_to_object_id(OF_EXPERIMENTER_TYPE, OF_VERSION_1_0) ==
+                OF_ACTION_EXPERIMENTER);
+
+    TEST_ASSERT(of_action_id_to_object_id(OF_EXPERIMENTER_TYPE, OF_VERSION_1_0) ==
+                OF_ACTION_ID_EXPERIMENTER);
+
+    TEST_ASSERT(of_instruction_to_object_id(OF_EXPERIMENTER_TYPE, OF_VERSION_1_0) ==
+                OF_INSTRUCTION_EXPERIMENTER);
+
+    TEST_ASSERT(of_queue_prop_to_object_id(OF_EXPERIMENTER_TYPE, OF_VERSION_1_0) ==
+                OF_QUEUE_PROP_EXPERIMENTER);
+
+    TEST_ASSERT(of_meter_band_to_object_id(OF_EXPERIMENTER_TYPE, OF_VERSION_1_0) ==
+                OF_METER_BAND_EXPERIMENTER);
+
+    TEST_ASSERT(of_table_feature_prop_to_object_id(OF_EXPERIMENTER_TYPE,
+                                                   OF_VERSION_1_3) ==
+                OF_TABLE_FEATURE_PROP_EXPERIMENTER);
+
+    return TEST_PASS;
+}
diff --git a/c_gen/templates/locitest/test_list_limits.c b/c_gen/templates/locitest/test_list_limits.c
new file mode 100644
index 0000000..aef91d8
--- /dev/null
+++ b/c_gen/templates/locitest/test_list_limits.c
@@ -0,0 +1,100 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/**
+ * Test that list append fails gracefully when running out of wire buffer
+ * space.
+ */
+
+#include <locitest/test_common.h>
+
+static int
+test_list_limits(void)
+{
+    of_flow_stats_reply_t *obj = of_flow_stats_reply_new(OF_VERSION_1_0);
+    of_list_flow_stats_entry_t list;
+    of_flow_stats_entry_t *element = of_flow_stats_entry_new(OF_VERSION_1_0);
+    int i = 0;
+
+    of_flow_stats_reply_entries_bind(obj, &list);
+
+    ASSERT(element != NULL);
+
+
+    while (1) {
+        int rv = of_list_flow_stats_entry_append(&list, element);
+        ASSERT(rv == OF_ERROR_NONE || rv == OF_ERROR_RESOURCE);
+        if (rv != OF_ERROR_NONE) {
+            break;
+        }
+        i++;
+    }
+
+    ASSERT(i == 744);
+
+    of_flow_stats_entry_delete(element);
+    of_flow_stats_reply_delete(obj);
+    return TEST_PASS;
+}
+
+static int
+test_list_limits_bind(void)
+{
+    of_flow_stats_reply_t *obj = of_flow_stats_reply_new(OF_VERSION_1_0);
+    of_list_flow_stats_entry_t list;
+    int i = 0;
+    of_flow_stats_reply_entries_bind(obj, &list);
+
+
+    while (1) {
+        of_flow_stats_entry_t element;
+        int rv; 
+        of_flow_stats_entry_init(&element, OF_VERSION_1_0, -1, 1);
+        rv = of_list_flow_stats_entry_append_bind(&list, &element);
+        ASSERT(rv == OF_ERROR_NONE || rv == OF_ERROR_RESOURCE);
+        if (rv != OF_ERROR_NONE) {
+            break;
+        }
+        i++;
+    }
+
+    ASSERT(i == 744);
+
+    of_flow_stats_reply_delete(obj);
+    return TEST_PASS;
+}
+
+int
+run_list_limits_tests(void)
+{
+    RUN_TEST(list_limits);
+    RUN_TEST(list_limits_bind);
+
+    return TEST_PASS;
+}
diff --git a/c_gen/templates/locitest/test_match_utils.c b/c_gen/templates/locitest/test_match_utils.c
new file mode 100644
index 0000000..6e4a95e
--- /dev/null
+++ b/c_gen/templates/locitest/test_match_utils.c
@@ -0,0 +1,222 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/**
+ *
+ * Match utility test cases
+ *
+ */
+
+#include <locitest/test_common.h>
+
+int
+test_match_utils(void)
+{
+    of_mac_addr_t m1 = {{0,0,1,1,3,3}};
+    of_mac_addr_t m2 = {{0,0,1,1,3,3}};  /* m1 == m2 */
+    of_mac_addr_t m3 = {{0,0,1,1,1,1}};  /* m1 is more specific than m3 */
+    of_mac_addr_t m4 = {{0xf,0,1,1,3,3}};  /* m1 is not more specific m4 */
+    of_mac_addr_t m5 = {{0,0,1,1,3,0xf}};  /* m1 is not more specific m5 */
+
+    of_mac_addr_t m_mask1 = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}};
+    of_mac_addr_t m_mask2 = {{0xff, 0xff, 0xff, 0xff, 0, 0}};
+
+    /* m1 matches m2 for mask1 */
+    /* m1 matches m2 for mask2 */
+    /* m1 does not match m3, m4, m5 for mask1 */
+    /* m1 matches m3, m5 for mask2 */
+    /* m1 does not match m4 for mask2 */
+
+    of_ipv6_t i1 = {{0,0,0,0,1,1,1,1,3,3,3,3,7,7,7,7}};  /* same as above */
+    of_ipv6_t i2 = {{0,0,0,0,1,1,1,1,3,3,3,3,7,7,7,7}};  
+    of_ipv6_t i3 = {{0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1}};
+    of_ipv6_t i4 = {{0xf,0,0,0,1,1,1,1,3,3,3,3,7,7,7,7}};
+    of_ipv6_t i5 = {{0,0,0,0,1,1,1,1,3,3,3,3,7,7,7,0xf}};
+
+    of_ipv6_t i_mask1 = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                          0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}};
+    of_ipv6_t i_mask2 = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                          0, 0, 0, 0, 0, 0, 0, 0}};
+
+    /* Same relationships as above */
+
+    uint32_t v1 = 3;  /* same as above */
+    uint32_t v2 = 3;
+    uint32_t v3 = 1;
+    uint32_t v4 = 4;
+    uint32_t v5 = (1 << 31) | 1;
+
+    uint32_t u32_mask1 = -1;
+    uint32_t u32_mask2 = 1;
+
+    uint64_t w1 = 3;  /* same as above */
+    uint64_t w2 = 3;
+    uint64_t w3 = 1;
+    uint64_t w4 = 4;
+    uint64_t w5 = (1LL << 63) | 1LL;
+
+    uint64_t u64_mask1 = -1;
+    uint64_t u64_mask2 = 1;
+
+    /* Match structures */
+    of_match_t match1, match2;
+
+    TEST_ASSERT(OF_MORE_SPECIFIC_MAC_ADDR(&m1, &m2));
+    TEST_ASSERT(OF_MORE_SPECIFIC_MAC_ADDR(&m1, &m3));
+    TEST_ASSERT(!OF_MORE_SPECIFIC_MAC_ADDR(&m1, &m4));
+    TEST_ASSERT(!OF_MORE_SPECIFIC_MAC_ADDR(&m1, &m5));
+
+    TEST_ASSERT(OF_MORE_SPECIFIC_IPV6(&i1, &i2));
+    TEST_ASSERT(OF_MORE_SPECIFIC_IPV6(&i1, &i3));
+    TEST_ASSERT(!OF_MORE_SPECIFIC_IPV6(&i1, &i4));
+    TEST_ASSERT(!OF_MORE_SPECIFIC_IPV6(&i1, &i5));
+
+    TEST_ASSERT(OF_MORE_SPECIFIC_INT(v1, v2));
+    TEST_ASSERT(OF_MORE_SPECIFIC_INT(v1, v3));
+    TEST_ASSERT(!OF_MORE_SPECIFIC_INT(v1, v4));
+    TEST_ASSERT(!OF_MORE_SPECIFIC_INT(v1, v5));
+
+    TEST_ASSERT(OF_MORE_SPECIFIC_INT(w1, w2));
+    TEST_ASSERT(OF_MORE_SPECIFIC_INT(w1, w3));
+    TEST_ASSERT(!OF_MORE_SPECIFIC_INT(w1, w4));
+    TEST_ASSERT(!OF_MORE_SPECIFIC_INT(w1, w5));
+
+    /* Test restricted matches on macs */
+    TEST_ASSERT(OF_RESTRICTED_MATCH_MAC_ADDR(&m1, &m2, &m_mask1));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_MAC_ADDR(&m1, &m3, &m_mask1));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_MAC_ADDR(&m1, &m4, &m_mask1));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_MAC_ADDR(&m1, &m5, &m_mask1));
+
+    TEST_ASSERT(OF_RESTRICTED_MATCH_MAC_ADDR(&m1, &m2, &m_mask2));
+    TEST_ASSERT(OF_RESTRICTED_MATCH_MAC_ADDR(&m1, &m3, &m_mask2));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_MAC_ADDR(&m1, &m4, &m_mask2));
+    TEST_ASSERT(OF_RESTRICTED_MATCH_MAC_ADDR(&m1, &m5, &m_mask2));
+
+    /* Test overlap */
+    TEST_ASSERT(OF_OVERLAP_MAC_ADDR(&m1, &m2, &m_mask1, &m_mask2));
+    TEST_ASSERT(OF_OVERLAP_MAC_ADDR(&m1, &m3, &m_mask1, &m_mask2));
+    TEST_ASSERT(!OF_OVERLAP_MAC_ADDR(&m1, &m3, &m_mask1, &m_mask1));
+    TEST_ASSERT(!OF_OVERLAP_MAC_ADDR(&m1, &m4, &m_mask1, &m_mask2));
+    TEST_ASSERT(OF_OVERLAP_MAC_ADDR(&m1, &m5, &m_mask1, &m_mask2));
+
+    /* Test restricted matches on ipv6 */
+    TEST_ASSERT(OF_RESTRICTED_MATCH_IPV6(&i1, &i2, &i_mask1));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_IPV6(&i1, &i3, &i_mask1));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_IPV6(&i1, &i4, &i_mask1));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_IPV6(&i1, &i5, &i_mask1));
+
+    TEST_ASSERT(OF_RESTRICTED_MATCH_IPV6(&i1, &i2, &i_mask2));
+    TEST_ASSERT(OF_RESTRICTED_MATCH_IPV6(&i1, &i3, &i_mask2));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_IPV6(&i1, &i4, &i_mask2));
+    TEST_ASSERT(OF_RESTRICTED_MATCH_IPV6(&i1, &i5, &i_mask2));
+
+    /* Test overlap */
+    TEST_ASSERT(OF_OVERLAP_IPV6(&i1, &i2, &i_mask1, &i_mask2));
+    TEST_ASSERT(OF_OVERLAP_IPV6(&i1, &i3, &i_mask1, &i_mask2));
+    TEST_ASSERT(!OF_OVERLAP_IPV6(&i1, &i3, &i_mask1, &i_mask1));
+    TEST_ASSERT(!OF_OVERLAP_IPV6(&i1, &i4, &i_mask1, &i_mask2));
+    TEST_ASSERT(OF_OVERLAP_IPV6(&i1, &i5, &i_mask1, &i_mask2));
+
+    /* Test restricted matches on uint32 */
+    TEST_ASSERT(OF_RESTRICTED_MATCH_INT(v1, v2, u32_mask1));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_INT(v1, v3, u32_mask1));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_INT(v1, v4, u32_mask1));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_INT(v1, v5, u32_mask1));
+
+    TEST_ASSERT(OF_RESTRICTED_MATCH_INT(v1, v2, u32_mask2));
+    TEST_ASSERT(OF_RESTRICTED_MATCH_INT(v1, v3, u32_mask2));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_INT(v1, v4, u32_mask2));
+    TEST_ASSERT(OF_RESTRICTED_MATCH_INT(v1, v5, u32_mask2));
+
+    /* Test overlap */
+    TEST_ASSERT(OF_OVERLAP_INT(v1, v2, u32_mask1, u32_mask2));
+    TEST_ASSERT(OF_OVERLAP_INT(v1, v3, u32_mask1, u32_mask2));
+    TEST_ASSERT(!OF_OVERLAP_INT(v1, v3, u32_mask1, u32_mask1));
+    TEST_ASSERT(!OF_OVERLAP_INT(v1, v4, u32_mask1, u32_mask2));
+    TEST_ASSERT(OF_OVERLAP_INT(v1, v5, u32_mask1, u32_mask2));
+
+    /* Test restricted matches on uint64 */
+    TEST_ASSERT(OF_RESTRICTED_MATCH_INT(w1, w2, u64_mask1));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_INT(w1, w3, u64_mask1));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_INT(w1, w4, u64_mask1));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_INT(w1, w5, u64_mask1));
+
+    TEST_ASSERT(OF_RESTRICTED_MATCH_INT(w1, w2, u64_mask2));
+    TEST_ASSERT(OF_RESTRICTED_MATCH_INT(w1, w3, u64_mask2));
+    TEST_ASSERT(!OF_RESTRICTED_MATCH_INT(w1, w4, u64_mask2));
+    TEST_ASSERT(OF_RESTRICTED_MATCH_INT(w1, w5, u64_mask2));
+
+    /* Test overlap */
+    TEST_ASSERT(OF_OVERLAP_INT(w1, w2, u64_mask1, u64_mask2));
+    TEST_ASSERT(OF_OVERLAP_INT(w1, w3, u64_mask1, u64_mask2));
+    TEST_ASSERT(!OF_OVERLAP_INT(w1, w3, u64_mask1, u64_mask1));
+    TEST_ASSERT(!OF_OVERLAP_INT(w1, w4, u64_mask1, u64_mask2));
+    TEST_ASSERT(OF_OVERLAP_INT(w1, w5, u64_mask1, u64_mask2));
+
+    /* Test match stuctures */
+    of_match_populate(&match1, OF_VERSION_1_2, 1);
+    of_match_populate(&match2, OF_VERSION_1_2, 1);
+    TEST_ASSERT(of_match_eq(&match1, &match2));
+    TEST_ASSERT(of_match_eq(&match2, &match1));
+    TEST_ASSERT(of_match_more_specific(&match1, &match2));
+    TEST_ASSERT(of_match_more_specific(&match2, &match1));
+    TEST_ASSERT(of_match_overlap(&match1, &match2));
+    TEST_ASSERT(of_match_overlap(&match2, &match1));
+
+    /* Change match2 so it still is extended by match1 */
+    memset(&match2.masks.eth_dst, 0, sizeof(of_mac_addr_t));
+    TEST_ASSERT(of_match_more_specific(&match1, &match2));
+    TEST_ASSERT(!of_match_more_specific(&match2, &match1));
+    TEST_ASSERT(!of_match_eq(&match1, &match2));
+    TEST_ASSERT(of_match_overlap(&match1, &match2));
+    TEST_ASSERT(of_match_overlap(&match2, &match1));
+
+    /* Now change a value so that matches disagree */
+    match2.fields.in_port++;
+    TEST_ASSERT(!of_match_more_specific(&match1, &match2));
+    TEST_ASSERT(!of_match_overlap(&match1, &match2));
+    TEST_ASSERT(!of_match_overlap(&match2, &match1));
+    /* Clear inport mask on match2 and should extend again */
+    match2.masks.in_port = 0;
+    TEST_ASSERT(of_match_more_specific(&match1, &match2));
+    TEST_ASSERT(of_match_overlap(&match1, &match2));
+    TEST_ASSERT(of_match_overlap(&match2, &match1));
+
+    /* Now change mask so the overlap, but not more specific */
+    match1.fields.in_port = 0x7;
+    match1.masks.in_port = 0x7;
+    match2.fields.in_port = 0xe;
+    match2.masks.in_port = 0xe;
+    TEST_ASSERT(!of_match_more_specific(&match1, &match2));
+    TEST_ASSERT(!of_match_more_specific(&match2, &match1));
+    TEST_ASSERT(of_match_overlap(&match1, &match2));
+    TEST_ASSERT(of_match_overlap(&match2, &match1));
+    
+    return TEST_PASS;
+}
diff --git a/c_gen/templates/locitest/test_setup_from_add.c b/c_gen/templates/locitest/test_setup_from_add.c
new file mode 100644
index 0000000..6988572
--- /dev/null
+++ b/c_gen/templates/locitest/test_setup_from_add.c
@@ -0,0 +1,132 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/**
+ * Test code for setup from flow add routines
+ */
+
+#include <locitest/test_common.h>
+
+#if !defined(__APPLE__)
+#include <mcheck.h>
+#define MCHECK_INIT mcheck(NULL)
+#else /* mcheck not available under OS X */
+#define MCHECK_INIT do { } while (0)
+#endif
+
+
+static int
+test_removed_setup_from_add(void)
+{
+    of_flow_removed_t *removed;
+    of_flow_add_t *add;
+    of_match_t m1, m2;
+
+    TEST_ASSERT((add = of_flow_add_new(OF_VERSION_1_0)) != NULL);
+    TEST_ASSERT((removed = of_flow_removed_new(OF_VERSION_1_0)) != NULL);
+
+    TEST_ASSERT(of_flow_add_OF_VERSION_1_0_populate(add, 1) != 0);
+    TEST_ASSERT(of_flow_add_match_get(add, &m1) == 0);
+
+    TEST_ASSERT(of_flow_removed_setup_from_flow_add(removed, add) == 0);
+    TEST_ASSERT(of_flow_removed_match_get(removed, &m2) == 0);
+    TEST_ASSERT(memcmp(&m1, &m2, sizeof(m1)) == 0);
+
+    of_flow_add_delete(add);
+    of_flow_removed_delete(removed);
+
+    return TEST_PASS;
+}
+
+
+static int
+test_stats_entry_setup_from_add(void)
+{
+    of_flow_add_t *add;
+    of_flow_stats_entry_t *entry;
+    of_match_t m1, m2;
+    of_list_action_t *list;
+    of_list_action_t list_out;
+
+    TEST_ASSERT((add = of_flow_add_new(OF_VERSION_1_0)) != NULL);
+    TEST_ASSERT((entry = of_flow_stats_entry_new(OF_VERSION_1_0)) != NULL);
+
+    TEST_ASSERT(of_flow_add_OF_VERSION_1_0_populate(add, 1) != 0);
+    TEST_ASSERT(of_flow_add_match_get(add, &m1) == 0);
+
+    TEST_ASSERT(of_flow_stats_entry_setup_from_flow_add(entry, add, NULL) == 0);
+    TEST_ASSERT(of_flow_stats_entry_match_get(entry, &m2) == 0);
+    TEST_ASSERT(memcmp(&m1, &m2, sizeof(m1)) == 0);
+
+    of_flow_add_delete(add);
+    of_flow_stats_entry_delete(entry);
+
+    /* @todo check action lists agree */
+
+    /* Same with an external action list */
+
+    TEST_ASSERT((add = of_flow_add_new(OF_VERSION_1_0)) != NULL);
+    TEST_ASSERT((entry = of_flow_stats_entry_new(OF_VERSION_1_0)) != NULL);
+
+    TEST_ASSERT(of_flow_add_OF_VERSION_1_0_populate(add, 1) != 0);
+    TEST_ASSERT(of_flow_add_match_get(add, &m1) == 0);
+
+    list = of_list_action_new(OF_VERSION_1_0);
+    TEST_ASSERT(list != NULL);
+    TEST_ASSERT(of_list_action_OF_VERSION_1_0_populate(list, 1) != 0);
+
+    /* Verify matches agree */
+    TEST_ASSERT(of_flow_stats_entry_setup_from_flow_add(entry, add, list) == 0);
+    TEST_ASSERT(of_flow_stats_entry_match_get(entry, &m2) == 0);
+    TEST_ASSERT(memcmp(&m1, &m2, sizeof(m1)) == 0);
+
+    of_list_action_init(&list_out, OF_VERSION_1_0, 0, 1);
+    of_flow_stats_entry_actions_bind(entry, &list_out);
+
+    /* Verify lists agree */
+    TEST_ASSERT(list->length == list_out.length);
+    TEST_ASSERT(memcmp(WBUF_BUF(list->wire_object.wbuf),
+                       WBUF_BUF(list_out.wire_object.wbuf),
+                       list->length));
+
+    of_flow_add_delete(add);
+    of_list_action_delete(list);
+    of_flow_stats_entry_delete(entry);
+
+    return TEST_PASS;
+}
+
+
+int run_setup_from_add_tests(void)
+{
+    RUN_TEST(removed_setup_from_add);
+    RUN_TEST(stats_entry_setup_from_add);
+
+    return TEST_PASS;
+}
diff --git a/c_gen/templates/locitest/test_utils.c b/c_gen/templates/locitest/test_utils.c
new file mode 100644
index 0000000..adc6d42
--- /dev/null
+++ b/c_gen/templates/locitest/test_utils.c
@@ -0,0 +1,128 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/**
+ *
+ * Test utility functions
+ *
+ */
+
+#include <locitest/test_common.h>
+#include <loci/of_utils.h>
+
+/**
+ * Test has output port utility function
+ */
+int
+test_has_outport(void)
+{
+    of_list_action_t *list;
+    of_action_t elt;
+    of_action_set_dl_src_t *set_dl_src;
+    of_action_output_t *output;
+
+    set_dl_src = &elt.set_dl_src;
+    output = &elt.output;
+
+    list = of_list_action_new(OF_VERSION_1_0);
+    TEST_ASSERT(list != NULL);
+
+    TEST_ASSERT(of_action_list_has_out_port(list, OF_PORT_DEST_WILDCARD));
+    TEST_ASSERT(!of_action_list_has_out_port(list, 1));
+
+    /* Add some other action */
+    of_action_set_dl_src_init(set_dl_src, OF_VERSION_1_0, -1, 1);
+    TEST_OK(of_list_action_append_bind(list, (of_action_t *)set_dl_src));
+
+    TEST_ASSERT(of_action_list_has_out_port(list, OF_PORT_DEST_WILDCARD));
+    TEST_ASSERT(!of_action_list_has_out_port(list, 1));
+
+    /* Add port 2 */
+    of_action_output_init(output, OF_VERSION_1_0, -1, 1);
+    TEST_OK(of_list_action_append_bind(list, (of_action_t *)output));
+    of_action_output_port_set(output, 2);
+
+    TEST_ASSERT(of_action_list_has_out_port(list, OF_PORT_DEST_WILDCARD));
+    TEST_ASSERT(!of_action_list_has_out_port(list, 1));
+    TEST_ASSERT(of_action_list_has_out_port(list, 2));
+
+    /* Add port 1 */
+    of_action_output_init(output, OF_VERSION_1_0, -1, 1);
+    TEST_OK(of_list_action_append_bind(list, (of_action_t *)output));
+    of_action_output_port_set(output, 1);
+
+    TEST_ASSERT(of_action_list_has_out_port(list, OF_PORT_DEST_WILDCARD));
+    TEST_ASSERT(of_action_list_has_out_port(list, 1));
+    TEST_ASSERT(of_action_list_has_out_port(list, 2));
+
+    /* Start over and put action at front of list */
+    of_list_action_delete(list);
+
+    list = of_list_action_new(OF_VERSION_1_0);
+    TEST_ASSERT(list != NULL);
+
+    /* Add port 2 */
+    of_action_output_init(output, OF_VERSION_1_0, -1, 1);
+    TEST_OK(of_list_action_append_bind(list, (of_action_t *)output));
+    of_action_output_port_set(output, 2);
+
+    TEST_ASSERT(of_action_list_has_out_port(list, OF_PORT_DEST_WILDCARD));
+    TEST_ASSERT(!of_action_list_has_out_port(list, 1));
+    TEST_ASSERT(of_action_list_has_out_port(list, 2));
+
+    /* Add some other action */
+    of_action_set_dl_src_init(set_dl_src, OF_VERSION_1_0, -1, 1);
+    TEST_OK(of_list_action_append_bind(list, (of_action_t *)set_dl_src));
+
+    TEST_ASSERT(of_action_list_has_out_port(list, OF_PORT_DEST_WILDCARD));
+    TEST_ASSERT(!of_action_list_has_out_port(list, 1));
+    TEST_ASSERT(of_action_list_has_out_port(list, 2));
+
+    /* Add port 1 */
+    of_action_output_init(output, OF_VERSION_1_0, -1, 1);
+    TEST_OK(of_list_action_append_bind(list, (of_action_t *)output));
+    of_action_output_port_set(output, 1);
+
+    TEST_ASSERT(of_action_list_has_out_port(list, OF_PORT_DEST_WILDCARD));
+    TEST_ASSERT(of_action_list_has_out_port(list, 1));
+    TEST_ASSERT(of_action_list_has_out_port(list, 2));
+
+    of_list_action_delete(list);
+
+    return TEST_PASS;
+}
+
+int
+run_utility_tests(void)
+{
+    RUN_TEST(has_outport);
+    RUN_TEST(dump_objs);
+
+    return TEST_PASS;
+}
diff --git a/c_gen/templates/locitest/test_validator.c b/c_gen/templates/locitest/test_validator.c
new file mode 100644
index 0000000..cac67f7
--- /dev/null
+++ b/c_gen/templates/locitest/test_validator.c
@@ -0,0 +1,113 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/**
+ * Test message validator
+ *
+ * Run the message validator on corrupt messages to ensure it catches them.
+ */
+
+#include "loci_log.h"
+
+#include <locitest/test_common.h>
+#include <loci/loci_validator.h>
+
+static int
+test_validate_fixed_length(void)
+{
+    of_table_stats_request_t *obj = of_table_stats_request_new(OF_VERSION_1_0);
+    of_message_t msg = OF_OBJECT_TO_MESSAGE(obj);
+
+    TEST_ASSERT(of_validate_message(msg, of_message_length_get(msg)) == 0);
+
+    of_message_length_set(msg, of_message_length_get(msg) - 1);
+    TEST_ASSERT(of_validate_message(msg, of_message_length_get(msg)) == -1);
+
+    of_table_stats_request_delete(obj);
+    return TEST_PASS;
+}
+
+static int
+test_validate_fixed_length_list(void)
+{
+    of_table_stats_reply_t *obj = of_table_stats_reply_new(OF_VERSION_1_0);
+    of_list_table_stats_entry_t list;
+    of_table_stats_entry_t element;
+    of_message_t msg; 
+    of_table_stats_reply_entries_bind(obj, &list);
+    of_table_stats_entry_init(&element, OF_VERSION_1_0, -1, 1);
+    of_list_table_stats_entry_append_bind(&list, &element);
+    of_list_table_stats_entry_append_bind(&list, &element);
+    msg = OF_OBJECT_TO_MESSAGE(obj);
+
+    TEST_ASSERT(of_validate_message(msg, of_message_length_get(msg)) == 0);
+
+    of_message_length_set(msg, of_message_length_get(msg) - 1);
+    TEST_ASSERT(of_validate_message(msg, of_message_length_get(msg)) == -1);
+
+    of_table_stats_reply_delete(obj);
+    return TEST_PASS;
+}
+
+static int
+test_validate_tlv16_list(void)
+{
+    of_flow_modify_t *obj = of_flow_modify_new(OF_VERSION_1_0);
+    of_list_action_t list;
+    of_action_set_tp_dst_t element1;
+    of_action_output_t element2;
+    of_message_t msg; 
+    of_flow_modify_actions_bind(obj, &list);
+    of_action_set_tp_dst_init(&element1, OF_VERSION_1_0, -1, 1);
+    of_list_action_append_bind(&list, (of_action_t *)&element1);
+    of_action_output_init(&element2, OF_VERSION_1_0, -1, 1);
+    of_list_action_append_bind(&list, (of_action_t *)&element2);
+    msg = OF_OBJECT_TO_MESSAGE(obj);
+
+    TEST_ASSERT(of_validate_message(msg, of_message_length_get(msg)) == 0);
+
+    of_message_length_set(msg, of_message_length_get(msg) - 1);
+    TEST_ASSERT(of_validate_message(msg, of_message_length_get(msg)) == -1);
+
+    of_message_length_set(msg, of_message_length_get(msg) + 2);
+    TEST_ASSERT(of_validate_message(msg, of_message_length_get(msg)) == -1);
+
+    of_flow_modify_delete(obj);
+    return TEST_PASS;
+}
+
+int
+run_validator_tests(void)
+{
+    RUN_TEST(validate_fixed_length);
+    RUN_TEST(validate_fixed_length_list);
+    RUN_TEST(validate_tlv16_list);
+
+    return TEST_PASS;
+}
diff --git a/c_gen/templates/locitest/unittest.h b/c_gen/templates/locitest/unittest.h
new file mode 100644
index 0000000..7ffc413
--- /dev/null
+++ b/c_gen/templates/locitest/unittest.h
@@ -0,0 +1,56 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+#ifndef UNITTEST_H
+#define UNITTEST_H
+
+#include <stdio.h>
+
+#define TEST_PASS 1
+#define TEST_FAIL 0
+
+#define TESTCASE(foo, rv) do {                                          \
+        fprintf(stderr, "test %s:", #foo);                              \
+        fprintf(stderr, "  %s\n", (rv = test_##foo()) ? "PASS" : "FAIL"); \
+    } while (0)
+
+#define TEST_ASSERT(result) if (!(result)) do {                         \
+        fprintf(stderr, "\nTEST ASSERT FAILURE "                        \
+               #result " :: %s:%d\n",__FILE__,__LINE__);                \
+        ASSERT(0);                                                      \
+        return TEST_FAIL;                                               \
+    } while (0)
+
+#define TEST_ASSERT_EQUAL(expected, result) \
+    TEST_ASSERT(((expected) == (result)))
+
+#define TEST_ASSERT_NOT_EQUAL(expected, result) \
+    TEST_ASSERT(((expected) != (result)))
+
+#endif
diff --git a/c_gen/templates/of_buffer.h b/c_gen/templates/of_buffer.h
new file mode 100644
index 0000000..05cc587
--- /dev/null
+++ b/c_gen/templates/of_buffer.h
@@ -0,0 +1,139 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/****************************************************************
+ *
+ * Low level buffer manipulation functions
+ * Requires low level type defs
+ *
+ ****************************************************************/
+
+#ifndef _OF_BUFFER_H_
+#define _OF_BUFFER_H_
+
+#include <loci/loci_base.h>
+#include <stdio.h>
+
+/* Function type used for a "free" operation of a low level buffer */
+typedef void (*of_buffer_free_f)(void *buf);
+
+
+/****************************************************************
+ *
+ * Low level buffers accessors handling endian and alignment
+ *
+ ****************************************************************/
+
+static inline void
+buf_ipv6_get(uint8_t *buf, of_ipv6_t *val) {
+    MEMCPY(val, buf, sizeof(*val));
+    IPV6_NTOH(val, val); /* probably a no-op */
+}
+
+static inline void
+buf_mac_get(uint8_t *buf, of_mac_addr_t *val) {
+    MEMCPY(val, buf, sizeof(*val));
+}
+
+static inline void
+buf_u64_get(uint8_t *buf, uint64_t *val) {
+    MEMCPY(val, buf, sizeof(*val));
+    *val = U64_NTOH(*val);
+}
+
+static inline void
+buf_u32_get(uint8_t *buf, uint32_t *val) {
+    MEMCPY(val, buf, sizeof(*val));
+    *val = U32_NTOH(*val);
+}
+
+static inline void
+buf_u16_get(uint8_t *buf, uint16_t *val) {
+    MEMCPY(val, buf, sizeof(uint16_t));
+    *val = U16_NTOH(*val);
+}
+
+static inline void
+buf_u8_get(uint8_t *buf, uint8_t *val) {
+    *val = *buf;
+}
+
+static inline void
+buf_octets_get(uint8_t *buf, uint8_t *dst, int bytes) {
+    MEMCPY(dst, buf, bytes);
+}
+
+static inline void
+buf_ipv6_set(uint8_t *buf, of_ipv6_t *val) {
+    /* FIXME:  If this is not a NO-OP, need to change the code */
+#if 1
+    MEMCPY(buf, val, sizeof(*val));
+#else
+    of_ipv6_t w_val;
+    MEMCPY(&w_val, val sizeof(w_val));
+    IPV6_HTON(w_val, w_val);
+    MEMCPY(buf, &w_val, sizeof(w_val));
+#endif
+}
+
+static inline void
+buf_mac_addr_set(uint8_t *buf, of_mac_addr_t *val) {
+    MEMCPY(buf, val, sizeof(of_mac_addr_t));
+}
+
+static inline void
+buf_u64_set(uint8_t *buf, uint64_t val) {
+    val = U64_HTON(val);
+    MEMCPY(buf, &val, sizeof(uint64_t));
+}
+
+static inline void
+buf_u32_set(uint8_t *buf, uint32_t val) {
+    val = U32_HTON(val);
+    MEMCPY(buf, &val, sizeof(uint32_t));
+}
+
+static inline void
+buf_u16_set(uint8_t *buf, uint16_t val) {
+    val = U16_NTOH(val);
+    MEMCPY(buf, &val, sizeof(uint16_t));
+}
+
+static inline void
+buf_u8_set(uint8_t *buf, uint8_t val) {
+    *buf = val;
+}
+
+static inline void
+buf_octets_set(uint8_t *buf, uint8_t *src, int bytes) {
+    MEMCPY(buf, src, bytes);
+}
+
+
+#endif /* _OF_BUFFER_H_ */
diff --git a/c_gen/templates/of_doc.h b/c_gen/templates/of_doc.h
new file mode 100644
index 0000000..9e352f0
--- /dev/null
+++ b/c_gen/templates/of_doc.h
@@ -0,0 +1,439 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/**
+ * @file of_doc.h
+ * @brief Documentation of sample functions
+ *
+ * This file is for documentation purposes only
+ *
+ * Once the code is in a working state, this documentation will be 
+ * transfered to the actual source files
+ *
+ * The functions documented here are simple templates for accessors that
+ * are used for all accessor members of LOCI objects.  Data types are
+ * divided into:
+ *
+ * @li @c scalar Things like uint8_t, uint16_t, of_mac_addr_t as well as
+ * fixed length strings
+ * @li @c octets Arbitrary length strings of binary data
+ * @li @c composite Data members which are structures
+ * @li @c list The list abstraction for data members
+ * @li @c list_element An element of a list (usually a composite object)
+ *
+ * List elements get special treatment for iterating across a list or 
+ * appending new entries to the list.  All others have 'set' and 'get'
+ * operations.  
+ *
+ * Scalars operations are "stateless" in that they simply
+ * update the underlying data or return that data.  
+ *
+ * Composites and list members update structures to point to the
+ * underlying data.  As a result, care must be taken that objects are
+ * not freed when linked composite or list members remain referring to
+ * the underlying data structure.  Currently: Note that reference
+ * counting won't solve this with the current approach as the
+ * referring objects may be automatic and not subject to alloc/free
+ * operations.
+ */
+
+
+
+/**
+ * Generic documentation for scalar get methods
+ * @param obj The object being accessed
+ * @param value A pointer to a scalar instance of the proper type
+ * @return OF_ERROR_XXX
+ *
+ * Accesses the underlying wire buffer at the appropriate offset to
+ * retrieve and convert the value, placing the result in *value.
+ *
+ * Examples of scalar types include:
+ * @li uint8_t
+ * @li uint16_t
+ * @li uint32_t
+ * @li uint64_t
+ * @li of_mac_addr_t
+ *
+ * Examples calls include:
+ * @li rv = of_port_status_reason_get(obj, &reason)
+ * @li rv = of_table_mod_config_get(obj, &config)
+ *
+ * An object instance can call directly as:
+ * @li rv = obj->reason_get(obj, &reason);    obj is an of_table_mod_t *
+ * @li rv = obj->config_get(obj, &config);    obj is an of_table_mod_t *
+ */
+extern int of_object_scalar_member_get(of_object_t *obj, uint32_t *value);
+
+/**
+ * Generic documentation for scalar set methods
+ * @param obj The object being accessed
+ * @param value Call by value parameter with the value to set
+ * @return OF_ERROR_XXX
+ *
+ * Converts value to the proper wire representation and writes it to
+ * the underlying wire buffer at the appropriate offset.
+ */
+extern int of_object_scalar_member_set(of_object_t *obj, uint32_t value);
+
+/**
+ * Generic documentation for an octets data get method
+ * @param obj The object being accessed
+ * @param value A pointer to an of_octets_t structure to be filled out 
+ * @return OF_ERROR_XXX
+ *
+ * NOTE: 
+ * Sets *bytes to the number of bytes in the octet string.
+ */
+extern int of_object_octets_member_data_get(of_object_t *obj, of_octets_t *value);
+
+/**
+ * Generic documentation for an octets data set method
+ * @param obj The object being accessed
+ * @param value Pointer to an of_octets_t structure pointing to memory from
+ * which data will be copied to wire buffer
+ * @return OF_ERROR_XXX
+ *
+ * Copies data from the memory pointed to by value into the underlying 
+ * wire buffer, extending the buffer if necessary.  The length of obj 
+ * is updated.
+ *
+ * If the length of obj changes (because the existing octets instance is of
+ * a different length) its internal length accessor is called to update
+ * anything tracking its length.  This may call the object's parent
+ * length accessor with the update.
+ */
+extern int of_object_octets_member_data_set(of_object_t *obj, of_octets_t *value);
+
+/**
+ * Generic documentation for an octets pointer get method
+ * @param obj The object being accessed
+ * @param value Pointer to an of_octets_t structure to be initialized
+ * @return OF_ERROR_XXX
+ *
+ * Set the octets object *value to point to the underlying data buffer.  The
+ * length member of *value is set as well.
+ *
+ * The result should be treated as READ ONLY information as modifying
+ * the buffer could cause corruption of the underlying LOCI object.
+ * To change the value (especially the length) of an octets data member,
+ * allocate and set a memory buffer and use the octets_member_data_set 
+ * function.
+ */
+extern int of_object_octets_member_ptr_get(of_object_t *obj, of_octets_t *value);
+
+/**
+ * Generic documentation for a composite sub-object get method
+ * @param obj The object being accessed
+ * @param value Pointer to an object (the sub-object) of the proper type
+ * @return OF_ERROR_XXX
+ *
+ * A composite is a structure with multiple components.  On a 'get'
+ * operation, a pointer (value) to an unused instance of the appropriate 
+ * type is passed to this routine.  That instance is intialized with the
+ * proper accessor functions for the sub-object type and the wire object
+ * is set up to point to obj's wire buffer at the appropriate offset.
+ *
+ * If changes are made to the sub-object (*value) and those changes
+ * affect the length, then the corresponding composite_set must be
+ * called to commit those changes to the parent.
+ */
+extern int of_object_composite_member_get(of_object_t *obj, 
+                                          of_object_t *value);
+
+/**
+ * Generic documentation for a composite sub-object set method
+ * @param obj The object being accessed
+ * @param value Pointer to an object (the sub-object) of the proper type
+ * @return OF_ERROR_XXX
+ *
+ * A composite is a structure with multiple components.  On a 'set'
+ * operation, a pointer (value) to an instance of the appropriate type
+ * is passed to this routine.  
+ *
+ * If the parent (obj) and the child (value) point to the same underlying
+ * wire object, then the changes to the underlying buffer are already
+ * recorded.
+ *
+ * Otherwise, any existing value of the sub-object is replaced
+ * by copying the wire buffer contents from value's wire buffer to obj's
+ * wire buffer at the appropriate offset.
+ *
+ * In either case, the length of the parent will be updated if it changes.
+ */
+extern int of_object_composite_member_set(of_object_t *obj, 
+                                          of_object_t *value);
+
+/**
+ * Generic documentation for a list sub-object get method
+ * @param obj The object being accessed
+ * @param value Pointer to an object (the list sub-object)
+ * @return OF_ERROR_XXX
+ *
+ * A list is an array of instances of objects of a common (possibly
+ * polymorphic) type.  On a 'get' operation, a pointer (value) to an
+ *  unused instance of the appropriate list type is passed to this
+ * routine.  That instance is intialized with the proper accessor
+ * functions for the list type and the wire object is set up to point
+ * to obj's wire buffer at the appropriate offset.
+ *
+ * Currently, the list object returned by a 'get' operation should not
+ * be altered, although changes that do not affect the length of
+ * sub-objects will work.
+ *
+ * Rather, lists should either be cleared and set from completely new
+ * instances using 'list_set', or they may be built using the append
+ * operations described below.
+ *
+ * @sa of_object_list_append_bind
+ * @sa of_object_list_append
+ */
+extern int of_object_list_member_get(of_object_t *obj, 
+                                     of_list_object_t *value);
+
+/**
+ * Generic documentation for a list entry first call
+ * @param obj The list object being accessed
+ * @param value Pointer to a generic list entry instance
+ * @return OF_ERROR_RANGE if the list is empty
+ *
+ * A list is an array of instances of objects of a common (possibly
+ * polymorphic) type.  
+ *
+ * This routine is intended for iterating through a list for
+ * reading.  Normally a 'get' operation will be done on the parent
+ * of the list to retrieve (a pointer to) the list, and then this routine
+ * will be called to set up a generic entry representing the first 
+ * element of the list.
+ *
+ * @sa of_object_list_entry_next
+ */
+extern int of_object_list_entry_first(of_list_object_t *obj, 
+                                      of_object_t *value);
+
+/**
+ * Generic documentation for a list entry next call
+ * @param obj The list object being accessed
+ * @param value Pointer to a generic list entry instance
+ * @return OF_ERROR_RANGE if the value already points to the last item 
+ * in the list
+
+ * A list is an array of instances of objects of a common (possibly
+ * polymorphic) type.  
+ *
+ * The corresponding list_entry_first must be called on the pair of
+ * parameters initially.  There after, this routine will advance the
+ * pointers in the wire object of value to the subsequent entry in the
+ * list.
+ *
+ * Changes should not be made to list items using these routines,
+ * although 'set' operations which do not change the length of the
+ * instance will work.
+ *
+ * @sa of_object_list_entry_first
+ */
+extern int of_object_list_entry_next(of_list_object_t *obj, 
+                                     of_object_t *value);
+
+/**
+ * Generic documentation for a list append bind function
+ * @param obj The list object being accessed
+ * @param value Pointer to a generic list entry instance
+ * @return OF_ERROR_XXX
+ *
+ * A list is an array of instances of objects of a common (possibly
+ * polymorphic) type.
+ *
+ * This function prepares the list for the process of appending an
+ * item to its tail.  The parameter value is a pointer to a generic
+ * list entry instance.  Its wire buffer is bound to that of the list
+ * at the end of the list.  The length of the list is updated according
+ * to the current value setting which must be accurate.
+ *
+ * Note that since the child has not been bound to a buffer, no
+ * values have been properly recorded for the object; they must
+ * be set after this _bind call.
+ *
+ * @sa of_object_list_entry_append
+ */
+extern int of_object_list_entry_append_bind(of_list_object_t *obj, 
+                                            of_object_t *value);
+
+/**
+ * Generic documentation for a list append function
+ * @param obj The list object being accessed
+ * @param value Pointer to a list object to be appended
+ * @return OF_ERROR_XXX
+ *
+ * A list is an array of instances of objects of a common (possibly
+ * polymorphic) type.
+ *
+ * This function takes a fully formed list entry, value, and copies
+ * that value to the end of the list.  No object ownership changes
+ * with this call.
+ *
+ * @sa of_object_list_entry_append_bind
+ */
+extern int of_object_list_entry_append(of_list_object_t *obj, 
+                                       of_object_t *value);
+
+/* This is from loci.h */
+
+/**
+ * Inheritance super class for of_queue_prop
+ *
+ * This class is the union of of_queue_prop classes.  You can refer
+ * to it untyped by refering to the member 'header' whose structure
+ * is common across all sub-classes.
+ */
+
+union of_queue_prop_u {
+    of_queue_prop_header_t header; /* Generic instance */
+    of_queue_prop_min_rate_t min_rate;
+    of_queue_prop_max_rate_t max_rate;
+    of_queue_prop_experimenter_t experimenter;
+};
+
+/**
+ * Inheritance super class for of_action
+ *
+ * This class is the union of of_action classes.  You can refer
+ * to it untyped by refering to the member 'header' whose structure
+ * is common across all sub-classes.
+ */
+
+union of_action_u {
+    of_action_header_t header; /* Generic instance */
+    of_action_copy_ttl_out_t copy_ttl_out;
+    of_action_set_mpls_tc_t set_mpls_tc;
+    of_action_set_field_t set_field;
+    of_action_set_nw_tos_t set_nw_tos;
+    of_action_dec_mpls_ttl_t dec_mpls_ttl;
+    of_action_set_nw_dst_t set_nw_dst;
+    of_action_set_mpls_label_t set_mpls_label;
+    of_action_group_t group;
+    of_action_set_nw_src_t set_nw_src;
+    of_action_set_vlan_vid_t set_vlan_vid;
+    of_action_set_mpls_ttl_t set_mpls_ttl;
+    of_action_pop_vlan_t pop_vlan;
+    of_action_set_tp_dst_t set_tp_dst;
+    of_action_pop_mpls_t pop_mpls;
+    of_action_push_vlan_t push_vlan;
+    of_action_set_vlan_pcp_t set_vlan_pcp;
+    of_action_enqueue_t enqueue;
+    of_action_set_tp_src_t set_tp_src;
+    of_action_experimenter_t experimenter;
+    of_action_set_nw_ttl_t set_nw_ttl;
+    of_action_copy_ttl_in_t copy_ttl_in;
+    of_action_set_nw_ecn_t set_nw_ecn;
+    of_action_strip_vlan_t strip_vlan;
+    of_action_set_dl_dst_t set_dl_dst;
+    of_action_push_mpls_t push_mpls;
+    of_action_dec_nw_ttl_t dec_nw_ttl;
+    of_action_set_dl_src_t set_dl_src;
+    of_action_set_queue_t set_queue;
+    of_action_output_t output;
+};
+
+/**
+ * Inheritance super class for of_instruction
+ *
+ * This class is the union of of_instruction classes.  You can refer
+ * to it untyped by refering to the member 'header' whose structure
+ * is common across all sub-classes.
+ */
+
+union of_instruction_u {
+    of_instruction_header_t header; /* Generic instance */
+    of_instruction_clear_actions_t clear_actions;
+    of_instruction_write_actions_t write_actions;
+    of_instruction_goto_table_t goto_table;
+    of_instruction_apply_actions_t apply_actions;
+    of_instruction_experimenter_t experimenter;
+    of_instruction_write_metadata_t write_metadata;
+};
+
+/**
+ * Inheritance super class for of_oxm
+ *
+ * This class is the union of of_oxm classes.  You can refer
+ * to it untyped by refering to the member 'header' whose structure
+ * is common across all sub-classes.
+ */
+
+union of_oxm_u {
+    of_oxm_header_t header; /* Generic instance */
+    of_oxm_ipv6_flabel_t ipv6_flabel;
+    of_oxm_ipv6_dst_masked_t ipv6_dst_masked;
+    of_oxm_vlan_pcp_t vlan_pcp;
+    of_oxm_ipv4_src_t ipv4_src;
+    of_oxm_ipv6_dst_t ipv6_dst;
+    of_oxm_arp_tpa_t arp_tpa;
+    of_oxm_icmpv6_type_t icmpv6_type;
+    of_oxm_arp_sha_t arp_sha;
+    of_oxm_ipv6_src_t ipv6_src;
+    of_oxm_sctp_src_t sctp_src;
+    of_oxm_icmpv6_code_t icmpv6_code;
+    of_oxm_metadata_masked_t metadata_masked;
+    of_oxm_eth_src_masked_t eth_src_masked;
+    of_oxm_eth_dst_t eth_dst;
+    of_oxm_ipv6_nd_sll_t ipv6_nd_sll;
+    of_oxm_mpls_tc_t mpls_tc;
+    of_oxm_arp_op_t arp_op;
+    of_oxm_vlan_vid_masked_t vlan_vid_masked;
+    of_oxm_eth_type_t eth_type;
+    of_oxm_in_phy_port_t in_phy_port;
+    of_oxm_vlan_vid_t vlan_vid;
+    of_oxm_arp_tha_t arp_tha;
+    of_oxm_arp_tpa_masked_t arp_tpa_masked;
+    of_oxm_in_port_t in_port;
+    of_oxm_ip_dscp_t ip_dscp;
+    of_oxm_sctp_dst_t sctp_dst;
+    of_oxm_icmpv4_code_t icmpv4_code;
+    of_oxm_eth_dst_masked_t eth_dst_masked;
+    of_oxm_tcp_src_t tcp_src;
+    of_oxm_ip_ecn_t ip_ecn;
+    of_oxm_ipv6_src_masked_t ipv6_src_masked;
+    of_oxm_ipv4_src_masked_t ipv4_src_masked;
+    of_oxm_udp_dst_t udp_dst;
+    of_oxm_arp_spa_t arp_spa;
+    of_oxm_ipv6_nd_target_t ipv6_nd_target;
+    of_oxm_ipv4_dst_t ipv4_dst;
+    of_oxm_ipv4_dst_masked_t ipv4_dst_masked;
+    of_oxm_eth_src_t eth_src;
+    of_oxm_udp_src_t udp_src;
+    of_oxm_ipv6_nd_tll_t ipv6_nd_tll;
+    of_oxm_icmpv4_type_t icmpv4_type;
+    of_oxm_mpls_label_t mpls_label;
+    of_oxm_tcp_dst_t tcp_dst;
+    of_oxm_ip_proto_t ip_proto;
+    of_oxm_metadata_t metadata;
+    of_oxm_arp_spa_masked_t arp_spa_masked;
+};
+
diff --git a/c_gen/templates/of_message.h b/c_gen/templates/of_message.h
new file mode 100644
index 0000000..77066bc
--- /dev/null
+++ b/c_gen/templates/of_message.h
@@ -0,0 +1,252 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/*
+ * These routines manipulate a low level buffer assuming it holds
+ * an OpenFlow message. 
+ */
+
+#if !defined(_OF_MESSAGE_H_)
+#define _OF_MESSAGE_H_
+
+#include <loci/of_buffer.h>
+
+typedef uint8_t *of_message_t;
+
+/* A few key common header offsets */
+#define OF_MESSAGE_VERSION_OFFSET 0
+#define OF_MESSAGE_TYPE_OFFSET 1
+#define OF_MESSAGE_LENGTH_OFFSET 2
+#define OF_MESSAGE_XID_OFFSET 4
+#define OF_MESSAGE_HEADER_LENGTH 8
+#define OF_MESSAGE_STATS_TYPE_OFFSET 8
+#define OF_MESSAGE_FLOW_MOD_COMMAND_OFFSET(version) ((version) == 1 ? 56 : 25)
+
+#define OF_MESSAGE_MIN_LENGTH 8
+#define OF_MESSAGE_MIN_STATS_LENGTH (OF_MESSAGE_STATS_TYPE_OFFSET + 2)
+#define OF_MESSAGE_MIN_FLOW_MOD_LENGTH(version)  ((version) == 1 ? 57 : 26)
+
+#define OF_MESSAGE_EXPERIMENTER_ID_OFFSET 8
+#define OF_MESSAGE_EXPERIMENTER_SUBTYPE_OFFSET 12
+#define OF_MESSAGE_EXPERIMENTER_MIN_LENGTH 16
+
+/**
+ * The "default" free message function; NULL means use nominal malloc/free
+ */
+#define OF_MESSAGE_FREE_FUNCTION NULL
+
+/**
+ * Map a message to the uint8_t * start of the message
+ */
+#define OF_MESSAGE_TO_BUFFER(msg) ((uint8_t *)(msg))
+
+/**
+ * Map a uint8_t * to a message object
+ */
+#define OF_BUFFER_TO_MESSAGE(buf) ((of_message_t)(buf))
+
+/****************************************************************
+ *
+ * Message field accessors.
+ *
+ * These do no range checking and assume a buffer with sufficient
+ * length to access the data.  These are low level accessors used
+ * during the parsing and coersion stage of message processing.
+ *
+ * Fields include:  version, message type, message length,
+ * transaction id, stats type (now multi-part type), experimenter id,
+ * experimenter type
+ *
+ ****************************************************************/
+
+/**
+ * @brief Get/set version of a message
+ * @param msg Pointer to the message buffer of sufficient length
+ * @param version Data for set operation
+ * @returns get returns version
+ */
+
+static inline of_version_t
+of_message_version_get(of_message_t msg) {
+    return (of_version_t)msg[OF_MESSAGE_VERSION_OFFSET];
+}
+
+static inline void
+of_message_version_set(of_message_t msg, of_version_t version) {
+    buf_u8_set(msg, (uint8_t)version);
+}
+
+/**
+ * @brief Get/set OpenFlow type of a message
+ * @param msg Pointer to the message buffer of sufficient length
+ * @param value Data for set operation
+ * @returns get returns message type
+ */
+
+static inline uint8_t
+of_message_type_get(of_message_t msg) {
+    return msg[OF_MESSAGE_TYPE_OFFSET];
+}
+
+static inline void
+of_message_type_set(of_message_t msg, uint8_t value) {
+    buf_u8_set(msg + OF_MESSAGE_TYPE_OFFSET, value);
+}
+
+/**
+ * @brief Get/set in-buffer length of a message
+ * @param msg Pointer to the message buffer of sufficient length
+ * @param len Data for set operation
+ * @returns get returns length in host order
+ */
+
+static inline uint16_t
+of_message_length_get(of_message_t msg) {
+    uint16_t val;
+    buf_u16_get(msg + OF_MESSAGE_LENGTH_OFFSET, &val);
+    return val;
+}
+
+static inline void
+of_message_length_set(of_message_t msg, uint16_t len) {
+    buf_u16_set(msg + OF_MESSAGE_LENGTH_OFFSET, len);
+}
+
+
+/**
+ * @brief Get/set transaction ID of a message
+ * @param msg Pointer to the message buffer of sufficient length
+ * @param xid Data for set operation
+ * @returns get returns xid in host order
+ */
+
+static inline uint32_t
+of_message_xid_get(of_message_t msg) {
+    uint32_t val;
+    buf_u32_get(msg + OF_MESSAGE_XID_OFFSET, &val);
+    return val;
+}
+
+static inline void
+of_message_xid_set(of_message_t msg, uint32_t xid) {
+    buf_u32_set(msg + OF_MESSAGE_XID_OFFSET, xid);
+}
+
+/**
+ * @brief Get/set stats type of a message
+ * @param msg Pointer to the message buffer of sufficient length
+ * @param type Data for set operation
+ * @returns get returns stats type in host order
+ */
+
+static inline uint16_t
+of_message_stats_type_get(of_message_t msg) {
+    uint16_t val;
+    buf_u16_get(msg + OF_MESSAGE_STATS_TYPE_OFFSET, &val);
+    return val;
+}
+
+static inline void
+of_message_stats_type_set(of_message_t msg, uint16_t type) {
+    buf_u16_set(msg + OF_MESSAGE_STATS_TYPE_OFFSET, type);
+}
+
+
+/**
+ * @brief Get/set experimenter ID of a message
+ * @param msg Pointer to the message buffer of sufficient length
+ * @param experimenter_id Data for set operation
+ * @returns get returns experimenter id in host order
+ */
+
+static inline uint32_t
+of_message_experimenter_id_get(of_message_t msg) {
+    uint32_t val;
+    buf_u32_get(msg + OF_MESSAGE_EXPERIMENTER_ID_OFFSET, &val);
+    return val;
+}
+
+static inline void
+of_message_experimenter_id_set(of_message_t msg, uint32_t experimenter_id) {
+    buf_u32_set(msg + OF_MESSAGE_EXPERIMENTER_ID_OFFSET, experimenter_id);
+}
+
+
+/**
+ * @brief Get/set experimenter message type (subtype) of a message
+ * @param msg Pointer to the message buffer of sufficient length
+ * @param subtype Data for set operation
+ * @returns get returns experimenter message type in host order
+ */
+
+static inline uint32_t
+of_message_experimenter_subtype_get(of_message_t msg) {
+    uint32_t val;
+    buf_u32_get(msg + OF_MESSAGE_EXPERIMENTER_SUBTYPE_OFFSET, &val);
+    return val;
+}
+
+static inline void
+of_message_experimenter_subtype_set(of_message_t msg,
+                                    uint32_t subtype) {
+    buf_u32_set(msg + OF_MESSAGE_EXPERIMENTER_SUBTYPE_OFFSET,
+                subtype);
+}
+
+/**
+ * Flow mod command changed from 16 to 8 bits on the wire from 1.0 to 1.1
+ */
+static inline uint8_t
+of_message_flow_mod_command_get(of_message_t msg, of_version_t version) {
+    uint16_t val16;
+    uint8_t val8;
+
+    if (version == OF_VERSION_1_0) {
+        buf_u16_get(msg + OF_MESSAGE_FLOW_MOD_COMMAND_OFFSET(version), &val16);
+        val8 = val16;
+    } else {
+        buf_u8_get(msg + OF_MESSAGE_FLOW_MOD_COMMAND_OFFSET(version), &val8);
+    }
+    return val8;
+}
+
+static inline void
+of_message_flow_mod_command_set(of_message_t msg, of_version_t version, 
+                                uint8_t command) {
+    uint16_t val16;
+
+    if (version == OF_VERSION_1_0) {
+        val16 = command;
+        buf_u16_set(msg + OF_MESSAGE_FLOW_MOD_COMMAND_OFFSET(version), val16);
+    } else {
+        buf_u8_set(msg + OF_MESSAGE_FLOW_MOD_COMMAND_OFFSET(version), command);
+    }
+}
+
+#endif /* _OF_MESSAGE_H_ */
diff --git a/c_gen/templates/of_object.c b/c_gen/templates/of_object.c
new file mode 100644
index 0000000..a5cfecd
--- /dev/null
+++ b/c_gen/templates/of_object.c
@@ -0,0 +1,728 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/****************************************************************
+ *
+ * of_object.c
+ *
+ * These are the low level object constructor/destructor operators.
+ *
+ ****************************************************************/
+
+#include "loci_log.h"
+#include <loci/loci.h>
+#include <loci/loci_validator.h>
+
+#if defined(OF_OBJECT_TRACKING)
+#include <BigList/biglist.h>
+
+loci_object_track_t loci_global_tracking;
+
+#define TRACK (&loci_global_tracking)
+#define TRACK_OBJS (TRACK->objects)
+#define CHECK_MAX(val, max) if ((val) > (max)) (max) = (val)
+
+#endif
+
+/**
+ * Create a generic new object and possibly underlying wire buffer
+ * @param bytes The number of bytes to allocate in the underlying buffer
+ *
+ * If bytes <= 0, do not allocate a wire buffer.
+ *
+ * Note that this is an internal function.  The class specific
+ * new functions should be called to properly initialize and track an
+ * OF object.
+ */
+
+of_object_t *
+of_object_new(int bytes)
+{
+    of_object_t *obj;
+
+    if ((obj = (of_object_t *)MALLOC(sizeof(of_generic_t))) == NULL) {
+        return NULL;
+    }
+    MEMSET(obj, 0, sizeof(of_generic_t));
+
+    if (bytes > 0) {
+        if ((obj->wire_object.wbuf = of_wire_buffer_new(bytes)) == NULL) {
+            FREE(obj);
+            return NULL;
+        }
+        obj->wire_object.owned = 1;
+    }
+
+    return obj;
+}
+
+/**
+ * The delete function for LOCI objects
+ *
+ * @param obj Pointer to the object to be deleted
+ *
+ * This can be called on any LOCI object; it should not need to be
+ * overridden.
+ */
+
+void
+of_object_delete(of_object_t *obj)
+{
+    if (obj == NULL) {
+        return;
+    }
+
+#if defined(OF_OBJECT_TRACKING)
+    ASSERT(obj->track_info.magic == OF_OBJECT_TRACKING_MAGIC &&
+           "of_object double free?");
+    LOCI_LOG_TRACE("OF obj delete %p.  Wire buf %p.\n", obj,
+                   obj->wire_object.wbuf);
+    ASSERT(TRACK->count_current > 0);
+    TRACK->count_current -= 1;
+    TRACK->deletes += 1;
+
+    TRACK_OBJS = biglist_remove_link_free(TRACK_OBJS,
+                                          obj->track_info.bl_entry);
+    obj->track_info.magic = 0;
+#endif
+
+    /*
+     * Make callback if present
+     */
+    if (obj->track_info.delete_cb != NULL) {
+        obj->track_info.delete_cb(obj);
+    }
+
+    if (obj->wire_object.owned) {
+        of_wire_buffer_free(obj->wire_object.wbuf);
+    }
+
+    FREE(obj);
+}
+
+/**
+ * Duplicate an object
+ * @param src The object to be duplicated
+ * @returns Pointer to the duplicate or NULL on error.  Caller is responsible
+ * for freeing the returned object.
+ */
+
+of_object_t *
+of_object_dup_(of_object_t *src)
+{
+    of_object_t *dst;
+    of_object_init_f init_fn;
+
+    if ((dst = (of_object_t *)MALLOC(sizeof(of_generic_t))) == NULL) {
+        return NULL;
+    }
+
+    MEMSET(dst, 0, sizeof(*dst));
+
+    /* Allocate a minimal wire buffer assuming we will not write to it. */
+    if ((dst->wire_object.wbuf = of_wire_buffer_new(src->length)) == NULL) {
+        FREE(dst);
+        return NULL;
+    }
+
+    dst->wire_object.owned = 1;
+
+    init_fn = of_object_init_map[src->object_id];
+    init_fn(dst, src->version, src->length, 0);
+
+    MEMCPY(OF_OBJECT_BUFFER_INDEX(dst, 0),
+           OF_OBJECT_BUFFER_INDEX(src, 0),
+           src->length);
+
+    return dst;
+}
+
+#if defined(OF_OBJECT_TRACKING)
+
+/**
+ * Record an object for tracking
+ *
+ * @param obj The object being tracked
+ * @param file The file name where the allocation is happening
+ * @param line The line number in the file where the alloc is happening
+ */
+
+void
+of_object_track(of_object_t *obj, const char *file, int line)
+{
+    if (obj != NULL) {
+        LOCI_LOG_TRACE("OF obj track %p, wire buf %p\n%s:%d\\n",
+                      obj, obj->wire_object.wbuf, file, line);
+        obj->track_info.file = file;
+        obj->track_info.line = line;
+        TRACK_OBJS = biglist_prepend(TRACK_OBJS, (void *)obj);
+        obj->track_info.bl_entry = TRACK_OBJS;
+        obj->track_info.magic = OF_OBJECT_TRACKING_MAGIC;
+
+        TRACK->allocs += 1;
+        TRACK->count_current += 1;
+        CHECK_MAX(TRACK->count_current, TRACK->count_max);
+    }
+}
+
+/**
+ * The dup function when tracking is enabled
+ */
+
+of_object_t *
+of_object_dup_tracking(of_object_t *src, const char *file, int line)
+{
+    of_object_t *obj;
+
+    obj = of_object_dup_(src);
+    of_object_track(obj, file, line);
+
+    return obj;
+}
+
+/**
+ * Display track info for one object
+ */
+
+void
+of_object_track_output(of_object_t *obj, loci_writer_f writer, void* cookie)
+{
+    const char *offset;
+    static const char *unknown = "Unknown file";
+
+    if (obj->track_info.file) {
+        offset = strstr(obj->track_info.file, "Modules/");
+        if (offset == NULL) {
+            offset = obj->track_info.file;
+        } else {
+            offset += 8; /* Jump over Modules/ too */
+        }
+    } else {
+        offset = unknown;
+    }
+    writer(cookie, "obj %p. type %s.\n%s:%d\n",
+               obj, of_object_id_str[obj->object_id],
+               offset, obj->track_info.line);
+}
+
+/**
+ * Dump out the current object list from LOCI
+ *
+ * @param log_fn The output printf vector
+ *
+ */
+
+void
+of_object_track_report(loci_writer_f writer, void* cookie)
+{
+    biglist_t *elt;
+    of_object_t *obj;
+    int count = 0;
+
+    writer(cookie, "\nLOCI Outstanding object list.\n");
+    writer(cookie, "Objs: Current %d. Max %d. Created %d. Deleted %d\n",
+               TRACK->count_current, TRACK->count_max, TRACK->allocs,
+               TRACK->deletes);
+    if (TRACK_OBJS) {
+        BIGLIST_FOREACH_DATA(elt, TRACK_OBJS, of_object_t *, obj) {
+            of_object_track_output(obj, writer, cookie);
+            ++count;
+        }
+    }
+    if (count != TRACK->count_current) {
+        writer(cookie, "\nERROR:  List has %d, but track count is %d\n",
+                   count, TRACK->count_current);
+    }
+    writer(cookie, "\nEnd of outstanding object list\n");
+}
+
+#endif
+
+/**
+ * Generic new from message call
+ */
+
+of_object_t *
+of_object_new_from_message(of_message_t msg, int len)
+{
+    of_object_id_t object_id;
+    of_object_t *obj;
+    of_version_t version;
+
+    version = of_message_version_get(msg);
+    if (!OF_VERSION_OKAY(version)) {
+        return NULL;
+    }
+
+    if (of_validate_message(msg, len) != 0) {
+        LOCI_LOG_ERROR("message validation failed\n");
+        return NULL;
+    }
+
+    object_id = of_message_to_object_id(msg, len);
+    ASSERT(object_id != OF_OBJECT_INVALID);
+
+    if ((obj = of_object_new(-1)) == NULL) {
+        return NULL;
+    }
+
+    of_object_init_map[object_id](obj, version, 0, 0);
+
+    if (of_object_buffer_bind(obj, OF_MESSAGE_TO_BUFFER(msg), len, 
+                              OF_MESSAGE_FREE_FUNCTION) < 0) {
+        FREE(obj);
+        return NULL;
+    }
+    obj->length = len;
+    obj->version = version;
+
+#if defined(OF_OBJECT_TRACKING)
+    /* @FIXME Would be nice to get caller; for now only in cxn_instance */
+    of_object_track(obj, __FILE__, __LINE__);
+#endif
+
+    return obj;
+}
+
+/**
+ * Bind an existing buffer to an LOCI object
+ *
+ * @param obj Pointer to the object to be updated
+ * @param buf Pointer to the buffer to bind to obj
+ * @param bytes Length of buf
+ * @param buf_free An optional free function to be applied to
+ * buf on deallocation
+ *
+ * This can be called on any LOCI object; it should not need to be
+ * overridden.
+ */
+
+int
+of_object_buffer_bind(of_object_t *obj, uint8_t *buf, int bytes, 
+                      of_buffer_free_f buf_free)
+{
+    of_wire_object_t *wobj;
+    of_wire_buffer_t *wbuf;
+
+    ASSERT(buf != NULL);
+    ASSERT(bytes > 0);
+    // ASSERT(wobj is not bound);
+
+    wobj = &obj->wire_object;
+    MEMSET(wobj, 0, sizeof(*wobj));
+
+    wbuf = of_wire_buffer_new_bind(buf, bytes, buf_free);
+    if (wbuf == NULL) {
+        return OF_ERROR_RESOURCE;
+    }
+
+    wobj->wbuf = wbuf;
+    wobj->owned = 1;
+    obj->length = bytes;
+
+    return OF_ERROR_NONE;
+}
+
+/**
+ * Connect a child to a parent at the wire buffer level
+ *
+ * @param parent The top level object to bind to
+ * @param child The sub-object connecting to the parent
+ * @param offset The offset at which to attach the child RELATIVE 
+ * TO THE PARENT in the buffer
+ * @param bytes The amount of the buffer dedicated to the child; see below
+ * @param inc_ref_count Should the ref count of the parent be incremented
+ * 
+ * This is used for 'get' accessors for composite types as well as
+ * iterator functions for lists, both read (first/next) and write
+ * (append_init, append_advance).
+ *
+ * Connect a child object to a parent by setting up the child's
+ * wire_object to point to the parent's underlying buffer.  The value
+ * of the parameter bytes is important in determining how the child
+ * is initialized:
+ * @li If bytes <= 0, the length and type of the child are not modified;
+ * no additional space is added to the buffer.
+ * @li If bytes > 0, the current wire buffer is grown to 
+ * accomodate this many bytes.  This is to support append operations.
+ *
+ * If an error is returned, future references to the child object
+ * (until it is reinitialized) are undefined.
+ */
+static void
+object_child_attach(of_object_t *parent, of_object_t *child, 
+                       int offset, int bytes)
+{
+    of_wire_object_t *c_wobj; /* Pointer to child's wire object */
+    of_wire_buffer_t *wbuf; /* Pointer to common wire buffer manager */
+
+    child->parent = parent;
+    wbuf = parent->wire_object.wbuf;
+
+    /* Set up the child's wire buf to point to same as parent */
+    c_wobj = &child->wire_object;
+    c_wobj->wbuf = wbuf;
+    c_wobj->obj_offset = parent->wire_object.obj_offset + offset;
+    c_wobj->owned = 0;
+
+    /*
+     * bytes determines if this is a read or write setup.
+     * If > 0, grow the buffer to accomodate the space
+     * Otherwise do nothing
+     */
+    if (bytes > 0) { /* Set internal length, request buffer space */
+        int tot_bytes; /* Total bytes to request for buffer if updated */
+
+        /* Set up space for the child in the parent's buffer */
+        tot_bytes = parent->wire_object.obj_offset + offset + bytes;
+
+        of_wire_buffer_grow(wbuf, tot_bytes);
+        child->length = bytes;
+    }
+    /* if bytes == 0 don't do anything */
+}
+
+/**
+ * Check for room in an object's wire buffer.
+ * @param obj The object being checked
+ * @param new_len The desired length
+ * @return Boolean
+ */
+
+int
+of_object_can_grow(of_object_t *obj, int new_len)
+{
+    return OF_OBJECT_ABSOLUTE_OFFSET(obj, new_len) <=
+        WBUF_ALLOC_BYTES(obj->wire_object.wbuf);
+}
+
+/**
+ * Set the xid of a message object
+ * @param obj The object being accessed
+ * @param xid The xid value to store in the wire buffer
+ * @return OF_ERROR_
+ * Since the XID is common across all versions, this is used
+ * for all XID accessors.
+ */
+
+int
+of_object_xid_set(of_object_t *obj, uint32_t xid)
+{
+    of_wire_buffer_t *wbuf;
+
+    if ((wbuf = OF_OBJECT_TO_WBUF(obj)) == NULL) {
+        return OF_ERROR_PARAM;
+    }
+    of_wire_buffer_u32_set(wbuf, 
+        OF_OBJECT_ABSOLUTE_OFFSET(obj, OF_MESSAGE_XID_OFFSET), xid);
+    return OF_ERROR_NONE;
+}
+
+/**
+ * Get the xid of a message object
+ * @param obj The object being accessed
+ * @param xid Pointer to where to store the xid value
+ * @return OF_ERROR_
+ * Since the XID is common across all versions, this is used
+ * for all XID accessors.
+ */
+
+int
+of_object_xid_get(of_object_t *obj, uint32_t *xid)
+{
+    of_wire_buffer_t *wbuf;
+
+    if ((wbuf = OF_OBJECT_TO_WBUF(obj)) == NULL) {
+        return OF_ERROR_PARAM;
+    }
+    of_wire_buffer_u32_get(wbuf, 
+        OF_OBJECT_ABSOLUTE_OFFSET(obj, OF_MESSAGE_XID_OFFSET), xid);
+    return OF_ERROR_NONE;
+}
+
+/****************************************************************
+ *
+ * Generic list operation implementations
+ *
+ ****************************************************************/
+
+/**
+ * Set up a child for appending to a parent list
+ * @param parent The parent; must be a list object
+ * @param child The child object; must be of type list element
+ * @return OF_ERROR_
+ *
+ * Attaches the wire buffer of the parent to the child by pointing
+ * the child to the end of the parent.
+ * 
+ * Set the wire length and type from the child.
+ * Update the parent length adding the current child length
+ *
+ * After calling this function, the child object may be updated
+ * resulting in changes to the parent's wire buffer
+ * 
+ */ 
+
+int
+of_list_append_bind(of_object_t *parent, of_object_t *child)
+{
+    if (parent == NULL || child == NULL ||
+           parent->wire_object.wbuf == NULL) {
+        return OF_ERROR_PARAM;
+    }
+
+    if (!of_object_can_grow(parent, parent->length + child->length)) {
+        return OF_ERROR_RESOURCE;
+    }
+
+    object_child_attach(parent, child, parent->length, 
+                        child->length);
+
+    /* Update the wire length and type if needed */
+    if (child->wire_length_set) {
+        child->wire_length_set(child, child->length);
+    }
+
+    if (child->wire_type_set) {
+        child->wire_type_set(child, child->object_id);
+    }
+
+    /* Update the parent's length */
+    of_object_parent_length_update(parent, child->length);
+
+    OF_LENGTH_CHECK_ASSERT(parent);
+
+    return OF_ERROR_NONE;
+}
+
+/**
+ * Generic atomic list append operation
+ * @param list The list to which an item is being appended
+ * @param item THe item to append to the list
+ *
+ * The contents of the item are copied to the end of the list.
+ * Currently assumes the list is at the end of its parent.
+ */
+int
+of_list_append(of_object_t *list, of_object_t *item)
+{
+    int new_len;
+
+    new_len = list->length + item->length;
+
+    if (!of_object_can_grow(list, new_len)) {
+        return OF_ERROR_RESOURCE;
+    }
+
+    of_wire_buffer_grow(list->wire_object.wbuf,
+                        OF_OBJECT_ABSOLUTE_OFFSET(list, new_len));
+
+    MEMCPY(OF_OBJECT_BUFFER_INDEX(list, list->length),
+           OF_OBJECT_BUFFER_INDEX(item, 0), item->length);
+
+    /* Update the list's length */
+    of_object_parent_length_update(list, item->length);
+
+    OF_LENGTH_CHECK_ASSERT(list);
+
+    return OF_ERROR_NONE;
+}
+
+/**
+ * Generic list first function
+ * @param parent The parent; must be a list object
+ * @param child The child object; must be of type list element
+ * @return OF_ERROR_RANGE if list is empty
+ * @return OF_ERROR_
+ *
+ * Sets up the child to point to the first element in the list
+ *
+ * Child init must be called before this is called.
+ *
+ * @note TREAT AS PRIVATE
+ * Does not fully initialized object
+ */
+int
+of_list_first(of_object_t *parent, of_object_t *child)
+{
+    if (parent->length == 0) { /* Empty list */
+        return OF_ERROR_RANGE;
+    }
+
+    object_child_attach(parent, child, 0, 0);
+
+    return OF_ERROR_NONE;
+}
+
+/**
+ * Return boolean indicating if child is pointing to last entry in parent
+ * @param parent The parent; must be a list object
+ * @param child The child object; must be of type list element
+ * @return OF_ERROR_RANGE if list is empty
+ * @return OF_ERROR_
+ *
+ */
+static int
+of_list_is_last(of_object_t *parent, of_object_t *child)
+{
+    if (child->wire_object.obj_offset + child->length >= 
+        parent->wire_object.obj_offset + parent->length) {
+        return 1;
+    }
+
+    return 0;
+}
+
+/**
+ * Generic list next function
+ * @param parent The parent; must be a list object
+ * @param child The child object; must be of type list element
+ * @return OF_ERROR_RANGE if at end of list
+ * @return OF_ERROR_
+ *
+ * Advances the child to point to the subsequent element in the list.
+ * The wire buffer object must not have been modified since the 
+ * previous call to _first or _next.
+ *
+ * @note TREAT AS PRIVATE
+ * Does not fully initialized object
+ */ 
+int
+of_list_next(of_object_t *parent, of_object_t *child)
+{
+    int offset;
+
+    ASSERT(child->length > 0);
+
+    /* Get offset of parent */
+    if (of_list_is_last(parent, child)) {
+        return OF_ERROR_RANGE; /* We were on the last object */
+    }
+
+    /* Offset is relative to parent start */
+    offset = (child->wire_object.obj_offset - parent->wire_object.obj_offset) +
+        child->length;
+    object_child_attach(parent, child, offset, 0);
+
+    return OF_ERROR_NONE;
+}
+
+void
+of_object_wire_buffer_steal(of_object_t *obj, uint8_t **buffer)
+{
+    ASSERT(obj != NULL);
+    of_wire_buffer_steal(obj->wire_object.wbuf, buffer);
+    obj->wire_object.wbuf = NULL;
+}
+
+/*
+ * Set member:
+ *    get_wbuf_extent
+ *    find offset of start of member
+ *    if offset is at wbuf_extent (append new data)
+ *        copy data at extent
+ *        update parent length
+ *    else
+ *        find length of current entry
+ *        move from end of current to extent to create (or remove) space
+ *        copy data to offset
+ *        update my length -- NEED LOCAL INFO TO DO THIS for some cases
+ */
+
+/* Also need: get offset of member for all combinations */
+/* Also need: get length of member for all combinations */
+#if 0
+/**
+ * Append the wire buffer data from src to the end of dst's wire buffer
+ */
+int
+of_object_append_buffer(of_object_t *dst, of_object_t *src)
+{
+    of_wire_buffer_t *s_wbuf, *d_wbuf;
+    int orig_len, dst_offset, src_offset;
+
+    d_wbuf = OF_OBJECT_TO_WBUF(dst);
+    s_wbuf = OF_OBJECT_TO_WBUF(src);
+    dst_offset = dst->wire_object.obj_offset + dst_length;
+    src_offset = src->wire_object.obj_offset;
+    OF_WIRE_BUFFER_INIT_CHECK(d_wbuf, dst_offset + src->length);
+    MEMCPY(OF_WBUF_BUFFER_POINTER(d_wbuf, dst_offset),
+           OF_WBUF_BUFFER_POINTER(s_wbuf, 0), src->length);
+
+    orig_len = dst->length;
+    dst->length += src->length;
+
+    return OF_ERROR_NONE;
+}
+
+/**
+ * Set the length of the actions object in a packet_in object
+ */
+
+int
+of_packet_out_actions_length_set(of_packet_t *obj, int len)
+{
+    if (obj == NULL || obj->object_id != OF_PACKET_IN ||
+        obj->wire_object.wbuf == NULL) {
+        return OF_ERROR_PARAM;
+    }
+
+    obj->actions_len_set(obj, len);
+}
+
+int
+_packet_out_data_offset_get(of_packet_t *obj)
+{
+    if (obj == NULL || obj->object_id != OF_PACKET_IN ||
+        obj->wire_object.wbuf == NULL) {
+        return -1;
+    }
+
+    return OF_PACKET_OUT_FIXED_LENGTH + _packet_out_actions_length_get(obj);
+}
+
+
+/**
+ * Simple length derivation function
+ *
+ * Most variable length fields are alone at the end of a structure.
+ * Their length is a simple calculation, just the total length of
+ * the parent minus the length of the non-variable part of the 
+ * parent's class type.
+ *
+ * @param parent The parent object
+ * @param length (out) Where to store the length of the final 
+ * variable length member
+ */
+int
+of_object_simple_length_derive(of_object_t *obj, int *length)
+{
+    
+}
+#endif
diff --git a/c_gen/templates/of_object.h b/c_gen/templates/of_object.h
new file mode 100644
index 0000000..cb9342e
--- /dev/null
+++ b/c_gen/templates/of_object.h
@@ -0,0 +1,176 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/*
+ * @fixme THIS FILE NEEDS CLEANUP.  It may just go away.
+ * 
+ * Low level internal header file.  Defines inheritance mechanism for
+ * LOCI objects.  In general, the routines in this file should not be
+ * called directly.  Rather the class-specific operations should be 
+ * used from loci.h.
+ *
+ * TREAT THESE FUNCTIONS AS PRIVATE.  THEY ARE GENERALLY HELPER
+ * FUNCTIONS FOR LOCI TYPE SPECIFIC IMPLEMENTATIONS
+ */
+
+#if !defined(_OF_OBJECT_H_)
+#define _OF_OBJECT_H_
+
+#include <loci/of_buffer.h>
+#include <loci/of_match.h>
+#include <loci/loci_base.h>
+#include <loci/of_message.h>
+
+#if defined(OF_OBJECT_TRACKING)
+#include <BigList/biglist.h>
+#endif
+
+/**
+ * This is the number of bytes reserved for metadata in each
+ * of_object_t instance.
+ */
+#define OF_OBJECT_METADATA_BYTES 32
+
+/****************************************************************
+ * General list operations: first, next, append_setup, append_advance
+ ****************************************************************/
+
+/* General list first operation */
+extern int of_list_first(of_object_t *parent, of_object_t *child);
+
+/* General list next operation */
+extern int of_list_next(of_object_t *parent, of_object_t *child);
+
+/* General list append bind operation */
+extern int of_list_append_bind(of_object_t *parent, of_object_t *child);
+
+/* Append a copy of item to list */
+extern int of_list_append(of_object_t *list, of_object_t *item);
+
+extern of_object_t *of_object_new(int bytes);
+extern of_object_t * of_object_dup_(of_object_t *src);
+
+/**
+ * Callback function prototype for deleting an object
+ */
+typedef void (*of_object_delete_callback_f)(of_object_t *obj);
+
+#if defined(OF_OBJECT_TRACKING)
+/**
+ * When tracking is enabled, the location of each new or dup
+ * call of an OF object is recorded and a list is kept of all
+ * outstanding objects.
+ *
+ * This dovetails with using objects to track outstanding operations
+ * for barrier processing.
+ */
+
+/**
+ * Global tracking stats
+ */
+typedef struct loci_object_track_s {
+    biglist_t *objects;
+    int count_current;
+    uint32_t count_max;
+    uint32_t allocs;
+    uint32_t deletes;
+} loci_object_track_t;
+
+extern loci_object_track_t loci_global_tracking;
+
+/* Remap dup call to tracking */
+extern of_object_t * of_object_dup_tracking(of_object_t *src,
+                                            const char *file, int line);
+#define of_object_dup(src) of_object_dup_tracking(src, __FILE__, __LINE__)
+extern void of_object_track(of_object_t *obj, const char *file, int line);
+
+extern void of_object_track_output(of_object_t *obj, loci_writer_f writer, void* cookie); 
+extern void of_object_track_report(loci_writer_f writer, void* cookie); 
+
+/**
+ * The data stored in each object related to tracking and
+ * The LOCI client may install a delete callback function to allow
+ * the notification of an object's destruction.
+ */
+
+typedef struct of_object_track_info_s {
+    of_object_delete_callback_f delete_cb;  /* To be implemented */
+    void *delete_cookie;
+
+    /* Track file and line where allocated */
+    const char *file;
+    int line;
+    biglist_t *bl_entry; /* Pointer to self */
+    uint32_t magic; /* validation value */
+} of_object_track_info_t;
+
+#define OF_OBJECT_TRACKING_MAGIC 0x11235813
+#else
+
+/* Use native dup call */
+#define of_object_dup of_object_dup_
+
+/**
+ * When tracking is not enabled, we still support a delete callback
+ */
+
+typedef struct of_object_track_info_s {
+    of_object_delete_callback_f delete_cb;  /* To be implemented */
+    void *delete_cookie;
+} of_object_track_info_t;
+
+#endif
+
+extern int of_object_xid_set(of_object_t *obj, uint32_t xid);
+extern int of_object_xid_get(of_object_t *obj, uint32_t *xid);
+
+/* Bind a buffer to an object, usually for parsing the buffer */
+extern int of_object_buffer_bind(of_object_t *obj, uint8_t *buf, 
+                                 int bytes, of_buffer_free_f buf_free);
+
+
+/**
+ * Steal a wire buffer from an object.
+ * @param obj The object whose buffer is being removed
+ * @param buffer[out] A handle for the pointer to the uint8_t * returned
+ *
+ * The wire buffer is taken from the object and its wirebuffer is set to
+ * NULL.  The ref_count of the wire buffer is not changed.
+ */
+extern void of_object_wire_buffer_steal(of_object_t *obj, uint8_t **buffer);
+extern int of_object_append_buffer(of_object_t *dst, of_object_t *src);
+
+extern of_object_t *of_object_new_from_message(of_message_t msg, int len);
+
+/* Delete an OpenFlow object without reference to its type */
+extern void of_object_delete(of_object_t *obj);
+
+int of_object_can_grow(of_object_t *obj, int new_len);
+
+#endif /* _OF_OBJECT_H_ */
diff --git a/c_gen/templates/of_type_maps.c b/c_gen/templates/of_type_maps.c
new file mode 100644
index 0000000..ef1df37
--- /dev/null
+++ b/c_gen/templates/of_type_maps.c
@@ -0,0 +1,799 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/****************************************************************
+ *
+ * Functions related to mapping wire values to object types
+ * and lengths
+ *
+ ****************************************************************/
+
+#include <loci/loci.h>
+#include <loci/of_message.h>
+
+/****************************************************************
+ * Top level OpenFlow message length functions
+ ****************************************************************/
+
+/**
+ * Get the length of a message object as reported on the wire
+ * @param obj The object to check
+ * @param bytes (out) Where the length is stored
+ * @returns OF_ERROR_ code
+ */
+void
+of_object_message_wire_length_get(of_object_t *obj, int *bytes)
+{
+    of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
+    ASSERT(wbuf != NULL);
+    // ASSERT(obj is message)
+    *bytes = of_message_length_get(OF_OBJECT_TO_MESSAGE(obj));
+}
+
+/**
+ * Set the length of a message object as reported on the wire
+ * @param obj The object to check
+ * @param bytes The new length of the object
+ * @returns OF_ERROR_ code
+ */
+void
+of_object_message_wire_length_set(of_object_t *obj, int bytes)
+{
+    of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
+    ASSERT(wbuf != NULL);
+
+    // ASSERT(obj is message)
+    of_message_length_set(OF_OBJECT_TO_MESSAGE(obj), bytes);
+}
+
+/****************************************************************
+ * TLV16 type/length functions
+ ****************************************************************/
+
+/**
+ * Many objects are TLVs and use uint16 for the type and length values
+ * stored on the wire at the beginning of the buffer.
+ */
+#define TLV16_WIRE_TYPE_OFFSET 0
+#define TLV16_WIRE_LENGTH_OFFSET 2
+
+/**
+ * Get the length field from the wire for a standard TLV
+ * object that uses uint16 for both type and length.
+ * @param obj The object being referenced
+ * @param bytes (out) Where to store the length
+ */
+
+void
+of_tlv16_wire_length_get(of_object_t *obj, int *bytes)
+{
+    uint16_t val16;
+    of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
+    ASSERT(wbuf != NULL);
+
+    of_wire_buffer_u16_get(wbuf, 
+           OF_OBJECT_ABSOLUTE_OFFSET(obj, TLV16_WIRE_LENGTH_OFFSET), &val16);
+    *bytes = val16;
+}
+
+/**
+ * Set the length field in the wire buffer for a standard TLV
+ * object that uses uint16 for both type and length.
+ * @param obj The object being referenced
+ * @param bytes The length value to use
+ */
+
+void
+of_tlv16_wire_length_set(of_object_t *obj, int bytes)
+{
+    of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
+    ASSERT(wbuf != NULL);
+
+    of_wire_buffer_u16_set(wbuf, 
+        OF_OBJECT_ABSOLUTE_OFFSET(obj, TLV16_WIRE_LENGTH_OFFSET), bytes);
+}
+
+/**
+ * Get the type field from the wire for a standard TLV object that uses
+ * uint16 for both type and length.
+ * @param obj The object being referenced
+ * @param wire_type (out) Where to store the type
+ */
+
+static void
+of_tlv16_wire_type_get(of_object_t *obj, int *wire_type)
+{
+    uint16_t val16;
+    of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
+
+    of_wire_buffer_u16_get(wbuf, OF_OBJECT_ABSOLUTE_OFFSET(obj, 
+           TLV16_WIRE_TYPE_OFFSET), &val16);
+
+    *wire_type = val16;
+}
+
+/**
+ * Set the object ID based on the wire buffer for any TLV object
+ * @param obj The object being referenced
+ * @param id The ID value representing what should be stored.
+ */
+
+void
+of_tlv16_wire_object_id_set(of_object_t *obj, of_object_id_t id)
+{
+    int wire_type;
+    of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
+    ASSERT(wbuf != NULL);
+
+    wire_type = of_object_to_type_map[obj->version][id];
+    ASSERT(wire_type >= 0);
+
+    of_wire_buffer_u16_set(wbuf, 
+        OF_OBJECT_ABSOLUTE_OFFSET(obj, TLV16_WIRE_TYPE_OFFSET), wire_type);
+
+    if (wire_type == OF_EXPERIMENTER_TYPE) {
+        of_extension_object_id_set(obj, id);
+    }
+}
+
+/**
+ * Get the object ID of an extended action
+ * @param obj The object being referenced
+ * @param id Where to store the object ID
+ * @fixme:  This should be auto generated
+ *
+ * If unable to map to known extension, set id to generic "experimenter"
+ */
+
+#define OF_ACTION_EXPERIMENTER_ID_OFFSET 4
+#define OF_ACTION_EXPERIMENTER_SUBTYPE_OFFSET 8
+
+
+static void
+extension_action_object_id_get(of_object_t *obj, of_object_id_t *id)
+{
+    uint32_t exp_id;
+    uint8_t *buf;
+
+    *id = OF_ACTION_EXPERIMENTER;
+
+    buf = OF_OBJECT_BUFFER_INDEX(obj, 0);
+    
+    buf_u32_get(buf + OF_ACTION_EXPERIMENTER_ID_OFFSET, &exp_id);
+
+    switch (exp_id) {
+    case OF_EXPERIMENTER_ID_BSN: {
+        uint32_t subtype;
+        buf_u32_get(buf + OF_ACTION_EXPERIMENTER_SUBTYPE_OFFSET, &subtype);
+        switch (subtype) {
+        case 1: *id = OF_ACTION_BSN_MIRROR; break;
+        case 2: *id = OF_ACTION_BSN_SET_TUNNEL_DST; break;
+        }
+        break;
+    }
+    case OF_EXPERIMENTER_ID_NICIRA: {
+        uint16_t subtype;
+        buf_u16_get(buf + OF_ACTION_EXPERIMENTER_SUBTYPE_OFFSET, &subtype);
+        switch (subtype) {
+        case 18: *id = OF_ACTION_NICIRA_DEC_TTL; break;
+        }
+        break;
+    }
+    }
+}
+
+/**
+ * Set wire data for extension objects, not messages.
+ *
+ * Currently only handles BSN mirror; ignores all others
+ */
+
+void
+of_extension_object_id_set(of_object_t *obj, of_object_id_t id)
+{
+    uint8_t *buf = OF_OBJECT_BUFFER_INDEX(obj, 0);
+    
+    switch (id) {
+    case OF_ACTION_BSN_MIRROR:
+    case OF_ACTION_ID_BSN_MIRROR:
+        buf_u32_set(buf + OF_ACTION_EXPERIMENTER_ID_OFFSET,
+                    OF_EXPERIMENTER_ID_BSN);
+        buf_u32_set(buf + OF_ACTION_EXPERIMENTER_SUBTYPE_OFFSET, 1);
+        break;
+    case OF_ACTION_BSN_SET_TUNNEL_DST:
+    case OF_ACTION_ID_BSN_SET_TUNNEL_DST:
+        buf_u32_set(buf + OF_ACTION_EXPERIMENTER_ID_OFFSET,
+                    OF_EXPERIMENTER_ID_BSN);
+        buf_u32_set(buf + OF_ACTION_EXPERIMENTER_SUBTYPE_OFFSET, 2);
+        break;
+    case OF_ACTION_NICIRA_DEC_TTL:
+    case OF_ACTION_ID_NICIRA_DEC_TTL:
+        buf_u32_set(buf + OF_ACTION_EXPERIMENTER_ID_OFFSET,
+                    OF_EXPERIMENTER_ID_NICIRA);
+        buf_u16_set(buf + OF_ACTION_EXPERIMENTER_SUBTYPE_OFFSET, 18);
+        break;
+    default:
+        break;
+    }
+}
+
+/**
+ * Get the object ID of an extended action
+ * @param obj The object being referenced
+ * @param id Where to store the object ID
+ * @fixme:  This should be auto generated
+ *
+ * If unable to map to known extension, set id to generic "experimenter"
+ */
+
+static void
+extension_action_id_object_id_get(of_object_t *obj, of_object_id_t *id)
+{
+    uint32_t exp_id;
+    uint8_t *buf;
+
+    *id = OF_ACTION_ID_EXPERIMENTER;
+
+    buf = OF_OBJECT_BUFFER_INDEX(obj, 0);
+    
+    buf_u32_get(buf + OF_ACTION_EXPERIMENTER_ID_OFFSET, &exp_id);
+
+    switch (exp_id) {
+    case OF_EXPERIMENTER_ID_BSN: {
+        uint32_t subtype;
+        buf_u32_get(buf + OF_ACTION_EXPERIMENTER_SUBTYPE_OFFSET, &subtype);
+        switch (subtype) {
+        case 1: *id = OF_ACTION_ID_BSN_MIRROR; break;
+        case 2: *id = OF_ACTION_ID_BSN_SET_TUNNEL_DST; break;
+        }
+        break;
+    }
+    case OF_EXPERIMENTER_ID_NICIRA: {
+        uint16_t subtype;
+        buf_u16_get(buf + OF_ACTION_EXPERIMENTER_SUBTYPE_OFFSET, &subtype);
+        switch (subtype) {
+        case 18: *id = OF_ACTION_ID_NICIRA_DEC_TTL; break;
+        }
+        break;
+    }
+    }
+}
+
+
+/**
+ * Get the object ID based on the wire buffer for an action object
+ * @param obj The object being referenced
+ * @param id Where to store the object ID
+ */
+
+
+void
+of_action_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
+{
+    int wire_type;
+
+    of_tlv16_wire_type_get(obj, &wire_type);
+    if (wire_type == OF_EXPERIMENTER_TYPE) {
+        extension_action_object_id_get(obj, id);
+        return;
+    }
+
+    ASSERT(wire_type >= 0 && wire_type < OF_ACTION_ITEM_COUNT);
+
+    *id = of_action_type_to_id[obj->version][wire_type];
+    ASSERT(*id != OF_OBJECT_INVALID);
+}
+
+/**
+ * Get the object ID based on the wire buffer for an action ID object
+ * @param obj The object being referenced
+ * @param id Where to store the object ID
+ */
+
+
+void
+of_action_id_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
+{
+    int wire_type;
+
+    of_tlv16_wire_type_get(obj, &wire_type);
+    if (wire_type == OF_EXPERIMENTER_TYPE) {
+        extension_action_id_object_id_get(obj, id);
+        return;
+    }
+
+    ASSERT(wire_type >= 0 && wire_type < OF_ACTION_ID_ITEM_COUNT);
+
+    *id = of_action_id_type_to_id[obj->version][wire_type];
+    ASSERT(*id != OF_OBJECT_INVALID);
+}
+
+/**
+ * @fixme to do when we have instruction extensions
+ * See extension_action above
+ */
+
+static int
+extension_instruction_object_id_get(of_object_t *obj, of_object_id_t *id)
+{
+    (void)obj;
+
+    *id = OF_INSTRUCTION_EXPERIMENTER;
+
+    return OF_ERROR_NONE;
+}
+
+/**
+ * Get the object ID based on the wire buffer for an instruction object
+ * @param obj The object being referenced
+ * @param id Where to store the object ID
+ */
+
+void
+of_instruction_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
+{
+    int wire_type;
+
+    of_tlv16_wire_type_get(obj, &wire_type);
+    if (wire_type == OF_EXPERIMENTER_TYPE) {
+        extension_instruction_object_id_get(obj, id);
+        return;
+    }
+
+    ASSERT(wire_type >= 0 && wire_type < OF_INSTRUCTION_ITEM_COUNT);
+
+    *id = of_instruction_type_to_id[obj->version][wire_type];
+    ASSERT(*id != OF_OBJECT_INVALID);
+}
+
+
+/**
+ * @fixme to do when we have queue_prop extensions
+ * See extension_action above
+ */
+
+static void
+extension_queue_prop_object_id_get(of_object_t *obj, of_object_id_t *id)
+{
+    (void)obj;
+
+    *id = OF_QUEUE_PROP_EXPERIMENTER;
+}
+
+/**
+ * Get the object ID based on the wire buffer for an queue_prop object
+ * @param obj The object being referenced
+ * @param id Where to store the object ID
+ */
+
+void
+of_queue_prop_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
+{
+    int wire_type;
+
+    of_tlv16_wire_type_get(obj, &wire_type);
+    if (wire_type == OF_EXPERIMENTER_TYPE) {
+        extension_queue_prop_object_id_get(obj, id);
+        return;
+    }
+
+    ASSERT(wire_type >= 0 && wire_type < OF_QUEUE_PROP_ITEM_COUNT);
+
+    *id = of_queue_prop_type_to_id[obj->version][wire_type];
+    ASSERT(*id != OF_OBJECT_INVALID);
+}
+
+
+/**
+ * @fixme to do when we have table_feature_prop extensions
+ * See extension_action above
+ */
+
+static void
+extension_table_feature_prop_object_id_get(of_object_t *obj, of_object_id_t *id)
+{
+    (void)obj;
+
+    *id = OF_TABLE_FEATURE_PROP_EXPERIMENTER;
+}
+
+/**
+ * Table feature property object ID determination
+ *
+ * @param obj The object being referenced
+ * @param id Where to store the object ID
+ */
+
+void
+of_table_feature_prop_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
+{
+    int wire_type;
+
+    of_tlv16_wire_type_get(obj, &wire_type);
+    if (wire_type == OF_EXPERIMENTER_TYPE) {
+        extension_table_feature_prop_object_id_get(obj, id);
+        return;
+    }
+
+    ASSERT(wire_type >= 0 && wire_type < OF_TABLE_FEATURE_PROP_ITEM_COUNT);
+
+    *id = of_table_feature_prop_type_to_id[obj->version][wire_type];
+    ASSERT(*id != OF_OBJECT_INVALID);
+}
+
+/**
+ * Get the object ID based on the wire buffer for meter_band object
+ * @param obj The object being referenced
+ * @param id Where to store the object ID
+ */
+
+void
+of_meter_band_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
+{
+    int wire_type;
+
+    of_tlv16_wire_type_get(obj, &wire_type);
+    if (wire_type == OF_EXPERIMENTER_TYPE) {
+        *id = OF_METER_BAND_EXPERIMENTER;
+        return;
+    }
+
+    ASSERT(wire_type >= 0 && wire_type < OF_METER_BAND_ITEM_COUNT);
+
+    *id = of_meter_band_type_to_id[obj->version][wire_type];
+    ASSERT(*id != OF_OBJECT_INVALID);
+}
+
+/**
+ * Get the object ID based on the wire buffer for a hello_elem object
+ * @param obj The object being referenced
+ * @param id Where to store the object ID
+ */
+
+void
+of_hello_elem_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
+{
+    int wire_type;
+
+    of_tlv16_wire_type_get(obj, &wire_type);
+    ASSERT(wire_type >= 0 && wire_type < OF_HELLO_ELEM_ITEM_COUNT);
+    *id = of_hello_elem_type_to_id[obj->version][wire_type];
+    ASSERT(*id != OF_OBJECT_INVALID);
+}
+
+/****************************************************************
+ * OXM type/length functions.
+ ****************************************************************/
+
+/* Where does the OXM type-length header lie in the buffer */
+#define OXM_HDR_OFFSET 0
+
+/**
+ * Get the OXM header (type-length fields) from the wire buffer
+ * associated with an OXM object
+ *
+ * Will return if error; set hdr to the OXM header
+ */
+
+#define _GET_OXM_TYPE_LEN(obj, tl_p, wbuf) do {                         \
+        wbuf = OF_OBJECT_TO_WBUF(obj);                                  \
+        ASSERT(wbuf != NULL);                                           \
+        of_wire_buffer_u32_get(wbuf,                                    \
+            OF_OBJECT_ABSOLUTE_OFFSET(obj, OXM_HDR_OFFSET), (tl_p));    \
+    } while (0)
+
+#define _SET_OXM_TYPE_LEN(obj, tl_p, wbuf) do {                         \
+        wbuf = OF_OBJECT_TO_WBUF(obj);                                  \
+        ASSERT(wbuf != NULL);                                           \
+        of_wire_buffer_u32_set(wbuf,                                    \
+            OF_OBJECT_ABSOLUTE_OFFSET(obj, OXM_HDR_OFFSET), (tl_p));    \
+    } while (0)
+
+/**
+ * Get the length of an OXM object from the wire buffer
+ * @param obj The object whose wire buffer is an OXM type
+ * @param bytes (out) Where length is stored 
+ */
+
+void
+of_oxm_wire_length_get(of_object_t *obj, int *bytes)
+{
+    uint32_t type_len;
+    of_wire_buffer_t *wbuf;
+
+    _GET_OXM_TYPE_LEN(obj, &type_len, wbuf);
+    *bytes = OF_OXM_LENGTH_GET(type_len);
+}
+
+/**
+ * Set the length of an OXM object in the wire buffer
+ * @param obj The object whose wire buffer is an OXM type
+ * @param bytes Value to store in wire buffer
+ */
+
+void
+of_oxm_wire_length_set(of_object_t *obj, int bytes)
+{
+    uint32_t type_len;
+    of_wire_buffer_t *wbuf;
+
+    ASSERT(bytes >= 0 && bytes < 256);
+
+    /* Read-modify-write */
+    _GET_OXM_TYPE_LEN(obj, &type_len, wbuf);
+    OF_OXM_LENGTH_SET(type_len, bytes);
+    of_wire_buffer_u32_set(wbuf, 
+           OF_OBJECT_ABSOLUTE_OFFSET(obj, OXM_HDR_OFFSET), type_len);
+}
+
+/**
+ * Get the object ID of an OXM object based on the wire buffer type
+ * @param obj The object whose wire buffer is an OXM type
+ * @param id (out) Where the ID is stored 
+ */
+
+void
+of_oxm_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
+{
+    uint32_t type_len;
+    int wire_type;
+    of_wire_buffer_t *wbuf;
+
+    _GET_OXM_TYPE_LEN(obj, &type_len, wbuf);
+    wire_type = OF_OXM_MASKED_TYPE_GET(type_len);
+    *id = of_oxm_to_object_id(wire_type, obj->version);
+}
+
+/**
+ * Set the wire type of an OXM object based on the object ID passed
+ * @param obj The object whose wire buffer is an OXM type
+ * @param id The object ID mapped to an OXM wire type which is stored
+ */
+
+void
+of_oxm_wire_object_id_set(of_object_t *obj, of_object_id_t id)
+{
+    uint32_t type_len;
+    int wire_type;
+    of_wire_buffer_t *wbuf;
+
+    ASSERT(OF_OXM_VALID_ID(id));
+
+    /* Read-modify-write */
+    _GET_OXM_TYPE_LEN(obj, &type_len, wbuf);
+    wire_type = of_object_to_wire_type(id, obj->version);
+    ASSERT(wire_type >= 0);
+    OF_OXM_MASKED_TYPE_SET(type_len, wire_type);
+    of_wire_buffer_u32_set(wbuf, 
+           OF_OBJECT_ABSOLUTE_OFFSET(obj, OXM_HDR_OFFSET), type_len);
+}
+
+
+
+#define OF_U16_LEN_LENGTH_OFFSET 0
+
+/**
+ * Get the wire length for an object with a uint16 length as first member
+ * @param obj The object being referenced
+ * @param bytes Pointer to location to store length
+ */
+void
+of_u16_len_wire_length_get(of_object_t *obj, int *bytes)
+{
+    of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
+    uint16_t u16;
+
+    ASSERT(wbuf != NULL);
+
+    of_wire_buffer_u16_get(wbuf, 
+           OF_OBJECT_ABSOLUTE_OFFSET(obj, OF_U16_LEN_LENGTH_OFFSET),
+           &u16);
+
+    *bytes = u16;
+}
+
+/**
+ * Set the wire length for an object with a uint16 length as first member
+ * @param obj The object being referenced
+ * @param bytes The length of the object
+ */
+
+void
+of_u16_len_wire_length_set(of_object_t *obj, int bytes)
+{
+    of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
+    ASSERT(wbuf != NULL);
+
+    /* ASSERT(obj is u16-len entry) */
+
+    of_wire_buffer_u16_set(wbuf, 
+           OF_OBJECT_ABSOLUTE_OFFSET(obj, OF_U16_LEN_LENGTH_OFFSET),
+           bytes);
+}
+
+
+#define OF_PACKET_QUEUE_LENGTH_OFFSET(ver) \
+    (((ver) >= OF_VERSION_1_2) ? 8 : 4)
+
+/**
+ * Get the wire length for a packet queue object
+ * @param obj The object being referenced
+ * @param bytes Pointer to location to store length
+ *
+ * The length is a uint16 at the offset indicated above
+ */
+void
+of_packet_queue_wire_length_get(of_object_t *obj, int *bytes)
+{
+    of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
+    uint16_t u16;
+    int offset;
+
+    ASSERT(wbuf != NULL);
+
+    /* ASSERT(obj is packet queue obj) */
+    offset = OF_PACKET_QUEUE_LENGTH_OFFSET(obj->version);
+    of_wire_buffer_u16_get(wbuf, OF_OBJECT_ABSOLUTE_OFFSET(obj, offset),
+                           &u16);
+
+    *bytes = u16;
+}
+
+/**
+ * Set the wire length for a 1.2 packet queue object
+ * @param obj The object being referenced
+ * @param bytes The length of the object
+ *
+ * The length is a uint16 at the offset indicated above
+ */
+
+void
+of_packet_queue_wire_length_set(of_object_t *obj, int bytes)
+{
+    of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
+    int offset;
+
+    ASSERT(wbuf != NULL);
+
+    /* ASSERT(obj is packet queue obj) */
+    offset = OF_PACKET_QUEUE_LENGTH_OFFSET(obj->version);
+    of_wire_buffer_u16_set(wbuf, OF_OBJECT_ABSOLUTE_OFFSET(obj, offset),
+                                  bytes);
+}
+
+/**
+ * Get the wire length for a meter band stats list
+ * @param obj The object being referenced
+ * @param bytes Pointer to location to store length
+ *
+ * Must a meter_stats object as a parent
+ */
+
+void
+of_list_meter_band_stats_wire_length_get(of_object_t *obj, int *bytes)
+{
+    ASSERT(obj->parent != NULL);
+    ASSERT(obj->parent->object_id == OF_METER_STATS);
+
+    /* We're counting on the parent being properly initialized already.
+     * The length is stored in a uint16 at offset 4 of the parent.
+     */
+    *bytes = obj->parent->length - OF_OBJECT_FIXED_LENGTH(obj->parent);
+}
+
+#define OF_METER_STATS_LENGTH_OFFSET 4
+
+/**
+ * Get/set the wire length for a meter stats object
+ * @param obj The object being referenced
+ * @param bytes Pointer to location to store length
+ *
+ * It's almost a TLV....
+ */
+
+void
+of_meter_stats_wire_length_get(of_object_t *obj, int *bytes)
+{
+    uint16_t val16;
+    of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
+    ASSERT(wbuf != NULL);
+    of_wire_buffer_u16_get(wbuf, 
+               OF_OBJECT_ABSOLUTE_OFFSET(obj, OF_METER_STATS_LENGTH_OFFSET),
+               &val16);
+    *bytes = val16;
+}
+
+void
+of_meter_stats_wire_length_set(of_object_t *obj, int bytes)
+{
+    of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
+    ASSERT(wbuf != NULL);
+
+    of_wire_buffer_u16_set(wbuf, 
+        OF_OBJECT_ABSOLUTE_OFFSET(obj, OF_METER_STATS_LENGTH_OFFSET), bytes);
+}
+
+/*
+ * Non-message extension push wire values
+ */
+
+int
+of_extension_object_wire_push(of_object_t *obj)
+{
+    of_action_bsn_mirror_t *action_mirror;
+    of_action_id_bsn_mirror_t *action_id_mirror;
+    of_action_bsn_set_tunnel_dst_t *action_set_tunnel_dst;
+    of_action_id_bsn_set_tunnel_dst_t *action_id_set_tunnel_dst;
+    of_action_nicira_dec_ttl_t *action_nicira_dec_ttl;
+    of_action_id_nicira_dec_ttl_t *action_id_nicira_dec_ttl;
+
+    /* Push exp type, subtype */
+    switch (obj->object_id) {
+    case OF_ACTION_BSN_MIRROR:
+        action_mirror = (of_action_bsn_mirror_t *)obj;
+        of_action_bsn_mirror_experimenter_set(action_mirror,
+            OF_EXPERIMENTER_ID_BSN);
+        of_action_bsn_mirror_subtype_set(action_mirror, 1);
+        break;
+    case OF_ACTION_ID_BSN_MIRROR:
+        action_id_mirror = (of_action_id_bsn_mirror_t *)obj;
+        of_action_id_bsn_mirror_experimenter_set(action_id_mirror,
+            OF_EXPERIMENTER_ID_BSN);
+        of_action_id_bsn_mirror_subtype_set(action_id_mirror, 1);
+        break;
+    case OF_ACTION_BSN_SET_TUNNEL_DST:
+        action_set_tunnel_dst = (of_action_bsn_set_tunnel_dst_t *)obj;
+        of_action_bsn_set_tunnel_dst_experimenter_set(action_set_tunnel_dst,
+            OF_EXPERIMENTER_ID_BSN);
+        of_action_bsn_set_tunnel_dst_subtype_set(action_set_tunnel_dst, 2);
+        break;
+    case OF_ACTION_ID_BSN_SET_TUNNEL_DST:
+        action_id_set_tunnel_dst = (of_action_id_bsn_set_tunnel_dst_t *)obj;
+        of_action_id_bsn_set_tunnel_dst_experimenter_set(action_id_set_tunnel_dst,
+            OF_EXPERIMENTER_ID_BSN);
+        of_action_id_bsn_set_tunnel_dst_subtype_set(action_id_set_tunnel_dst, 2);
+        break;
+    case OF_ACTION_NICIRA_DEC_TTL:
+        action_nicira_dec_ttl = (of_action_nicira_dec_ttl_t *)obj;
+        of_action_nicira_dec_ttl_experimenter_set(action_nicira_dec_ttl,
+            OF_EXPERIMENTER_ID_NICIRA);
+        of_action_nicira_dec_ttl_subtype_set(action_nicira_dec_ttl, 18);
+        break;
+    case OF_ACTION_ID_NICIRA_DEC_TTL:
+        action_id_nicira_dec_ttl = (of_action_id_nicira_dec_ttl_t *)obj;
+        of_action_id_nicira_dec_ttl_experimenter_set(action_id_nicira_dec_ttl,
+            OF_EXPERIMENTER_ID_NICIRA);
+        of_action_id_nicira_dec_ttl_subtype_set(action_id_nicira_dec_ttl, 18);
+        break;
+    default:
+        break;
+    }
+
+    return OF_ERROR_NONE;
+}
diff --git a/c_gen/templates/of_utils.c b/c_gen/templates/of_utils.c
new file mode 100644
index 0000000..f9c1972
--- /dev/null
+++ b/c_gen/templates/of_utils.c
@@ -0,0 +1,78 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/****************************************************************
+ * File: of_utils.h
+ *
+ * Some utilities provided based on LOCI code generation
+ *
+ ****************************************************************/
+
+#include <loci/of_utils.h>
+
+
+/**
+ * Check if the given port is used as an output for any entry on the list
+ * @param actions The list of actions being checked
+ * @param outport The port being sought
+ * @returns Boolean, true if entry has an output action to outport
+ *
+ * @fixme VERSION Currently only OF 1.0 supported
+ * @fixme Check for error return in accessor
+ *
+ * If outport is "wildcard", the test should be ignored, so return true
+ */
+
+int
+of_action_list_has_out_port(of_list_action_t *actions, of_port_no_t outport)
+{
+    of_action_t elt;
+    of_action_output_t *output;
+    int loop_rv;
+    of_port_no_t port_no;
+    int rv = 0;
+
+    if (outport == OF_PORT_DEST_WILDCARD) { /* Same as OFPP_ANY */
+        return 1;
+    }
+
+    output = &elt.output;
+    OF_LIST_ACTION_ITER(actions, &elt, loop_rv) {
+        if (output->object_id == OF_ACTION_OUTPUT) {
+            of_action_output_port_get(output, &port_no);
+            if (port_no == outport) {
+                rv = 1;
+                break;
+            }
+        }
+    }
+
+    return rv;
+}
+
diff --git a/c_gen/templates/of_utils.h b/c_gen/templates/of_utils.h
new file mode 100644
index 0000000..1a3a29a
--- /dev/null
+++ b/c_gen/templates/of_utils.h
@@ -0,0 +1,45 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/****************************************************************
+ * File: of_utils.h
+ *
+ * Header file for some utilities provided based on LOCI code generation
+ *
+ ****************************************************************/
+
+#ifndef OF_UTILS_H
+#define OF_UTILS_H
+
+#include <loci/loci.h>
+
+extern int of_action_list_has_out_port(of_list_action_t *actions, 
+                                       of_port_no_t outport);
+
+#endif
diff --git a/c_gen/templates/of_wire_buf.c b/c_gen/templates/of_wire_buf.c
new file mode 100644
index 0000000..acfcb84
--- /dev/null
+++ b/c_gen/templates/of_wire_buf.c
@@ -0,0 +1,159 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+/****************************************************************
+ *
+ * of_wire_buf.c
+ *
+ * Implementation of more complicated of_wire_buf operations
+ *
+ ****************************************************************/
+
+#include <loci/loci.h>
+
+#if 0
+static of_match_v1_t *
+wire_buf_v1_to_match(of_wire_buffer_t *wbuf, int offset)
+{
+    of_match_v1_t *match;
+    match = of_match_v1_new(OF_VERSION_1_0);
+    return match;
+}
+
+/*
+ * First pass at wire buf to match conversions.  These involve a lot
+ * of copying and could be made more efficient.
+ */
+int
+of_wire_buffer_of_match_get(of_object_t *obj, int offset, of_match_t *match)
+{
+    switch (obj->version) {
+    case OF_VERSION_1_0:
+        break;
+    case OF_VERSION_1_1:
+        break;
+    case OF_VERSION_1_2:
+        break;
+    default:
+        return OF_ERROR_VERSION;
+        break;
+    }
+
+    return OF_ERROR_NONE;
+}
+
+/**
+ * Write a host match structure into the wire buffer
+ * @param obj The object that owns the buffer to write to
+ * @param offset The start location in the wire buffer
+ * @param match Pointer to the host match object
+ * @param cur_len The current length of the object in the buffer
+ *
+ * If the current length is different than the length of the new data
+ * being written, then move the remains of the buffer.  This only applies
+ * to version 1.2 (though it should apply to 1.1).
+ */
+
+int
+of_wire_buffer_of_match_set(of_object_t *obj, int offset, 
+                            of_match_t *match, int cur_len)
+{
+    // of_octets_t octets;
+
+    switch (obj->version) {
+    case OF_VERSION_1_0:
+        break;
+    case OF_VERSION_1_1:
+        break;
+    case OF_VERSION_1_2:
+        // of_match_v3_serialize(match, &octets);
+        break;
+    default:
+        return OF_ERROR_VERSION;
+        break;
+    }
+
+    return OF_ERROR_NONE;
+}
+#endif
+
+/**
+ * Replace data in the data buffer, possibly with a new
+ * length or appending to buffer.
+ *
+ * @param wbuf The wire buffer being updated.
+ * @param offset The start point of the update
+ * @param old_len The number of bytes being replaced
+ * @param data Source of bytes to write into the buffer
+ * @param new_len The number of bytes to write
+ *
+ * The buffer may grow for this operation.  Current byte count
+ * is pre-grow for the replace.
+ *
+ * The current byte count for the buffer is updated.
+ * 
+ */
+
+void
+of_wire_buffer_replace_data(of_wire_buffer_t *wbuf, 
+                            int offset, 
+                            int old_len,
+                            uint8_t *data,
+                            int new_len)
+{
+    int bytes;
+    uint8_t *src_ptr, *dst_ptr;
+    int cur_bytes;
+
+    ASSERT(wbuf != NULL);
+
+    cur_bytes = wbuf->current_bytes;
+
+    /* Doesn't make sense; mismatch in current buffer info */
+    ASSERT(old_len + offset <= wbuf->current_bytes);
+
+    if (old_len < new_len) {
+        of_wire_buffer_grow(wbuf, offset + new_len);
+    } else {
+        wbuf->current_bytes += (new_len - old_len); // may decrease size
+    }
+
+    if ((old_len + offset < cur_bytes) && (old_len != new_len)) {
+        /* Need to move back of buffer */
+        src_ptr = &wbuf->buf[offset + old_len];
+        dst_ptr = &wbuf->buf[offset + new_len];
+        bytes = cur_bytes - (offset + old_len);
+        MEMMOVE(dst_ptr, src_ptr, bytes);
+    }
+
+    dst_ptr = &wbuf->buf[offset];
+    MEMCPY(dst_ptr, data, new_len);
+
+    ASSERT(wbuf->current_bytes == cur_bytes + (new_len - old_len));
+}
diff --git a/c_gen/templates/of_wire_buf.h b/c_gen/templates/of_wire_buf.h
new file mode 100644
index 0000000..cf1ee17
--- /dev/null
+++ b/c_gen/templates/of_wire_buf.h
@@ -0,0 +1,884 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # 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
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+/* Copyright 2013, Big Switch Networks, Inc. */
+
+#if !defined(_OF_WIRE_BUF_H_)
+#define _OF_WIRE_BUF_H_
+
+#include <string.h>
+#include <loci/loci_base.h>
+#include <loci/of_object.h>
+#include <loci/of_match.h>
+#include <loci/of_buffer.h>
+
+/****************************************************************
+ *
+ * Wire buffer declaration, constructor, data alloc, delete
+ *
+ ****************************************************************/
+
+/* Maximum length of an OpenFlow message. All wire buffers allocated for
+ * new objects (that don't come from a message) are this length to avoid
+ * needing to grow the buffers. */
+#define OF_WIRE_BUFFER_MAX_LENGTH 65535
+
+/**
+ * Buffer management structure
+ */
+typedef struct of_wire_buffer_s {
+    /** Pointer to a monolithic data buffer */
+    uint8_t *buf;
+
+    /** Length of buffer actually allocated */
+    int alloc_bytes;
+    /** Current extent actually used */
+    int current_bytes;
+    /** If not NULL, use this to dealloc buf */
+    of_buffer_free_f free;
+} of_wire_buffer_t;
+
+/**
+ * Decouples object from underlying wire buffer
+ *
+ * Called a 'slice' in some places.
+ */
+typedef struct of_wire_object_s {
+    /** A pointer to the underlying buffer's management structure. */
+    of_wire_buffer_t *wbuf;  
+    /** The start offset for this object relative to the start of the
+     * underlying buffer */
+    int obj_offset;
+    /* Boolean, whether the object owns the wire buffer. */
+    char owned;
+} of_wire_object_t;
+
+#define WBUF_BUF(wbuf) (wbuf)->buf
+#define WBUF_ALLOC_BYTES(wbuf) (wbuf)->alloc_bytes
+#define WBUF_CURRENT_BYTES(wbuf) (wbuf)->current_bytes
+
+/**
+ * For read access, throw an error code if current buffer
+ * is not big enough.
+ * @param wbuf Pointer to an of_wire_buffer_t structure
+ * @param offset The extent of the buffer required
+ */
+#define OF_WIRE_BUFFER_ACCESS_CHECK(wbuf, offset)                      \
+    ASSERT(((wbuf) != NULL) && (WBUF_BUF(wbuf) != NULL) &&             \
+           (offset > 0) && (WBUF_CURRENT_BYTES(wbuf) >= offset))
+
+/*
+ * Index a wire buffer
+ * Index a wire object (from obj_offset)
+ * Index a LOCI object
+ */
+
+/**
+ * Return a pointer to a particular offset in a wire buffer's data
+ * @param wbuf Pointer to an of_wire_buffer_t structure
+ * @param offset The location to reference
+ */
+#define OF_WIRE_BUFFER_INDEX(wbuf, offset) (&((WBUF_BUF(wbuf))[offset]))
+
+/**
+ * Return a pointer to a particular offset in the underlying buffer
+ * associated with a wire object
+ * @param wobj Pointer to an of_wire_object_t structure
+ * @param offset The location to reference relative to the start of the object
+ */
+#define OF_WIRE_OBJECT_INDEX(wobj, offset) \
+    OF_WIRE_BUFFER_INDEX((wobj)->wbuf, (offset) + (wobj)->obj_offset)
+
+/****************************************************************
+ * Object specific macros; of_object_t includes a wire_object
+ ****************************************************************/
+
+/**
+ * Return a pointer to a particular offset in the underlying buffer
+ * associated with a wire object
+ * @param obj Pointer to an of_object_t object
+ * @param offset The location to reference relative to the start of the object
+ */
+#define OF_OBJECT_BUFFER_INDEX(obj, offset) \
+    OF_WIRE_OBJECT_INDEX(&((obj)->wire_object), offset)
+
+/**
+ * Return the absolute offset as an integer from a object-relative offset
+ * @param obj Pointer to an of_wire_object_t structure
+ * @param offset The location to reference relative to the start of the object
+ */
+#define OF_OBJECT_ABSOLUTE_OFFSET(obj, offset) \
+    ((obj)->wire_object.obj_offset + offset)
+
+
+/**
+ * Map a generic object to the underlying wire buffer object (not the octets)
+ *
+ * Treat as private
+ */
+#define OF_OBJECT_TO_WBUF(obj) ((obj)->wire_object.wbuf)
+
+
+
+/**
+ * Minimum allocation size for wire buffer object
+ */
+#define OF_WIRE_BUFFER_MIN_ALLOC_BYTES 128
+
+/**
+ * Allocate a wire buffer object and the underlying data buffer.
+ * The wire buffer is initally empty (current_bytes == 0).
+ * @param a_bytes The number of bytes to allocate.
+ * @returns A wire buffer object if successful or NULL
+ */
+static inline of_wire_buffer_t *
+of_wire_buffer_new(int a_bytes)
+{
+    of_wire_buffer_t *wbuf;
+
+    wbuf = (of_wire_buffer_t *)MALLOC(sizeof(of_wire_buffer_t));
+    if (wbuf == NULL) {
+        return NULL;
+    }
+    MEMSET(wbuf, 0, sizeof(of_wire_buffer_t));
+
+    if (a_bytes < OF_WIRE_BUFFER_MIN_ALLOC_BYTES) {
+        a_bytes = OF_WIRE_BUFFER_MIN_ALLOC_BYTES;
+    }
+
+    if ((wbuf->buf = (uint8_t *)MALLOC(a_bytes)) == NULL) {
+        FREE(wbuf);
+        return NULL;
+    }
+    MEMSET(wbuf->buf, 0, a_bytes);
+    wbuf->current_bytes = 0;
+    wbuf->alloc_bytes = a_bytes;
+
+    return (of_wire_buffer_t *)wbuf;
+}
+
+/**
+ * Allocate a wire buffer object and bind it to an existing buffer.
+ * @param buf       Existing buffer.
+ * @param bytes     Size of buf.
+ * @param buf_free  Function called to deallocate buf.
+ * @returns A wire buffer object if successful or NULL
+ */
+static inline of_wire_buffer_t *
+of_wire_buffer_new_bind(uint8_t *buf, int bytes, of_buffer_free_f buf_free)
+{
+    of_wire_buffer_t *wbuf;
+
+    wbuf = (of_wire_buffer_t *)MALLOC(sizeof(of_wire_buffer_t));
+    if (wbuf == NULL) {
+        return NULL;
+    }
+
+    wbuf->buf = buf;
+    wbuf->free = buf_free;
+    wbuf->current_bytes = bytes;
+    wbuf->alloc_bytes = bytes;
+
+    return (of_wire_buffer_t *)wbuf;
+}
+
+static inline void
+of_wire_buffer_free(of_wire_buffer_t *wbuf)
+{
+    if (wbuf == NULL) return;
+
+    if (wbuf->buf != NULL) {
+        if (wbuf->free != NULL) {
+            wbuf->free(wbuf->buf);
+        } else {
+            FREE(wbuf->buf);
+        }
+    }
+
+    FREE(wbuf);
+}
+
+static inline void
+of_wire_buffer_steal(of_wire_buffer_t *wbuf, uint8_t **buffer)
+{
+    *buffer = wbuf->buf;
+    /* Mark underlying data buffer as taken */
+    wbuf->buf = NULL;
+    of_wire_buffer_free(wbuf);
+}
+
+/**
+ * Increase the currently used length of the wire buffer.
+ * Will fail an assertion if the allocated length is not long enough.
+ *
+ * @param wbuf Pointer to the wire buffer structure
+ * @param bytes Total number of bytes buffer should grow to
+ */
+
+static inline void
+of_wire_buffer_grow(of_wire_buffer_t *wbuf, int bytes)
+{
+    ASSERT(wbuf != NULL);
+    ASSERT(wbuf->alloc_bytes >= bytes);
+    if (bytes > wbuf->current_bytes) {
+        wbuf->current_bytes = bytes;
+    }
+}
+
+/* TBD */
+
+
+/**
+ * Get a uint8_t scalar from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value Pointer to where to put value
+ *
+ * The underlying buffer accessor funtions handle endian and alignment.
+ */
+
+static inline void
+of_wire_buffer_u8_get(of_wire_buffer_t *wbuf, int offset, uint8_t *value)
+{
+    OF_WIRE_BUFFER_ACCESS_CHECK(wbuf, offset + (int) sizeof(uint8_t));
+    buf_u8_get(OF_WIRE_BUFFER_INDEX(wbuf, offset), value);
+}
+
+/**
+ * Set a uint8_t scalar in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value The value to store
+ *
+ * The underlying buffer accessor funtions handle endian and alignment.
+ */
+
+static inline void
+of_wire_buffer_u8_set(of_wire_buffer_t *wbuf, int offset, uint8_t value)
+{
+    OF_WIRE_BUFFER_ACCESS_CHECK(wbuf, offset + (int) sizeof(uint8_t));
+    buf_u8_set(OF_WIRE_BUFFER_INDEX(wbuf, offset), value);
+}
+
+/**
+ * Get a uint16_t scalar from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value Pointer to where to put value
+ *
+ * The underlying buffer accessor funtions handle endian and alignment.
+ */
+
+static inline void
+of_wire_buffer_u16_get(of_wire_buffer_t *wbuf, int offset, uint16_t *value)
+{
+    OF_WIRE_BUFFER_ACCESS_CHECK(wbuf, offset + (int) sizeof(uint16_t));
+    buf_u16_get(OF_WIRE_BUFFER_INDEX(wbuf, offset), value);
+}
+
+/**
+ * Set a uint16_t scalar in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value The value to store
+ *
+ * The underlying buffer accessor funtions handle endian and alignment.
+ */
+
+static inline void
+of_wire_buffer_u16_set(of_wire_buffer_t *wbuf, int offset, uint16_t value)
+{
+    OF_WIRE_BUFFER_ACCESS_CHECK(wbuf, offset + (int) sizeof(uint16_t));
+    buf_u16_set(OF_WIRE_BUFFER_INDEX(wbuf, offset), value);
+}
+
+/**
+ * Get a uint32_t scalar from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value Pointer to where to put value
+ *
+ * The underlying buffer accessor funtions handle endian and alignment.
+ */
+
+static inline void
+of_wire_buffer_u32_get(of_wire_buffer_t *wbuf, int offset, uint32_t *value)
+{
+    OF_WIRE_BUFFER_ACCESS_CHECK(wbuf, offset + (int) sizeof(uint32_t));
+    buf_u32_get(OF_WIRE_BUFFER_INDEX(wbuf, offset), value);
+}
+
+/**
+ * Set a uint32_t scalar in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value The value to store
+ *
+ * The underlying buffer accessor funtions handle endian and alignment.
+ */
+
+static inline void
+of_wire_buffer_u32_set(of_wire_buffer_t *wbuf, int offset, uint32_t value)
+{
+    OF_WIRE_BUFFER_ACCESS_CHECK(wbuf, offset + (int) sizeof(uint32_t));
+    buf_u32_set(OF_WIRE_BUFFER_INDEX(wbuf, offset), value);
+}
+
+/**
+ * Get a uint64_t scalar from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value Pointer to where to put value
+ *
+ * The underlying buffer accessor funtions handle endian and alignment.
+ */
+
+static inline void
+of_wire_buffer_u64_get(of_wire_buffer_t *wbuf, int offset, uint64_t *value)
+{
+    OF_WIRE_BUFFER_ACCESS_CHECK(wbuf, offset + (int) sizeof(uint64_t));
+    buf_u64_get(OF_WIRE_BUFFER_INDEX(wbuf, offset), value);
+}
+
+/**
+ * Set a uint64_t scalar in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value The value to store
+ *
+ * The underlying buffer accessor funtions handle endian and alignment.
+ */
+
+static inline void
+of_wire_buffer_u64_set(of_wire_buffer_t *wbuf, int offset, uint64_t value)
+{
+    OF_WIRE_BUFFER_ACCESS_CHECK(wbuf, offset + (int) sizeof(uint64_t));
+    buf_u64_set(OF_WIRE_BUFFER_INDEX(wbuf, offset), value);
+}
+
+/**
+ * Get a generic OF match structure from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value Pointer to the structure to update
+ *
+ * NOT IMPLEMENTED.
+ *
+ */
+
+static inline void
+of_wire_buffer_match_get(int version, of_wire_buffer_t *wbuf, int offset,
+                      of_match_t *value)
+{
+    ASSERT(0);
+}
+
+/**
+ * Set a generic OF match structure in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value Pointer to the structure to store
+ *
+ * NOT IMPLEMENTED.
+ *
+ */
+
+static inline void
+of_wire_buffer_match_set(int version, of_wire_buffer_t *wbuf, int offset,
+                      of_match_t *value)
+{
+    ASSERT(0);
+}
+
+/**
+ * Get a port description object from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value Pointer to the structure to fill out
+ *
+ * NOT IMPLEMENTED.
+ *
+ * @fixme Where should this go?
+ */
+
+static inline void
+of_wire_buffer_of_port_desc_get(int version, of_wire_buffer_t *wbuf, int offset,
+                             void *value)
+{
+    ASSERT(0);
+}
+
+/**
+ * Set a port description object in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value Pointer to the structure to fill out
+ *
+ * NOT IMPLEMENTED.
+ *
+ * @fixme Where should this go?
+ */
+
+static inline void
+of_wire_buffer_of_port_desc_set(int version, of_wire_buffer_t *wbuf, int offset,
+                             void *value)
+{
+    ASSERT(0);
+}
+
+/**
+ * Get a port number scalar from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value Pointer to where to put value
+ *
+ * Port numbers are version specific.
+ */
+
+static inline void
+of_wire_buffer_port_no_get(int version, of_wire_buffer_t *wbuf, int offset,
+                        of_port_no_t *value)
+{
+    uint16_t v16;
+    uint32_t v32;
+
+    switch (version) {
+    case OF_VERSION_1_0:
+        of_wire_buffer_u16_get(wbuf, offset, &v16);
+        *value = v16;
+        break;
+    case OF_VERSION_1_1:
+    case OF_VERSION_1_2:
+    case OF_VERSION_1_3:
+        of_wire_buffer_u32_get(wbuf, offset, &v32);
+        *value = v32;
+        break;
+    default:
+        ASSERT(0);
+    }
+}
+
+/**
+ * Set a port number scalar from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value The value to store in the buffer
+ *
+ * Port numbers are version specific.
+ */
+
+static inline void
+of_wire_buffer_port_no_set(int version, of_wire_buffer_t *wbuf, int offset,
+                      of_port_no_t value)
+{
+
+    switch (version) {
+    case OF_VERSION_1_0:
+        of_wire_buffer_u16_set(wbuf, offset, (uint16_t)value);
+        break;
+    case OF_VERSION_1_1:
+    case OF_VERSION_1_2:
+    case OF_VERSION_1_3:
+        of_wire_buffer_u32_set(wbuf, offset, (uint32_t)value);
+        break;
+    default:
+        ASSERT(0);
+    }
+}
+
+/**
+ * Get a flow mod command value from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value Pointer to where to put value
+ */
+
+static inline void
+of_wire_buffer_fm_cmd_get(int version, of_wire_buffer_t *wbuf, int offset,
+                        of_fm_cmd_t *value)
+{
+    uint16_t v16;
+    uint8_t v8;
+
+    switch (version) {
+    case OF_VERSION_1_0:
+        of_wire_buffer_u16_get(wbuf, offset, &v16);
+        *value = v16;
+        break;
+    case OF_VERSION_1_1:
+    case OF_VERSION_1_2:
+    case OF_VERSION_1_3:
+        of_wire_buffer_u8_get(wbuf, offset, &v8);
+        *value = v8;
+        break;
+    default:
+        ASSERT(0);
+    }
+}
+
+/**
+ * Set a flow mod command value in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value The value to store
+ */
+
+static inline void
+of_wire_buffer_fm_cmd_set(int version, of_wire_buffer_t *wbuf, int offset,
+                      of_fm_cmd_t value)
+{
+    switch (version) {
+    case OF_VERSION_1_0:
+        of_wire_buffer_u16_set(wbuf, offset, (uint16_t)value);
+        break;
+    case OF_VERSION_1_1:
+    case OF_VERSION_1_2:
+    case OF_VERSION_1_3:
+        of_wire_buffer_u8_set(wbuf, offset, (uint8_t)value);
+        break;
+    default:
+        ASSERT(0);
+    }
+}
+
+/**
+ * Get a wild card bitmap value from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value Pointer to where to store the value
+ */
+
+static inline void
+of_wire_buffer_wc_bmap_get(int version, of_wire_buffer_t *wbuf, int offset,
+                        of_wc_bmap_t *value)
+{
+    uint32_t v32;
+    uint64_t v64;
+
+    switch (version) {
+    case OF_VERSION_1_0:
+    case OF_VERSION_1_1:
+        of_wire_buffer_u32_get(wbuf, offset, &v32);
+        *value = v32;
+        break;
+    case OF_VERSION_1_2:
+    case OF_VERSION_1_3:
+        of_wire_buffer_u64_get(wbuf, offset, &v64);
+        *value = v64;
+        break;
+    default:
+        ASSERT(0);
+    }
+}
+
+/**
+ * Set a wild card bitmap value in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value The value to store
+ */
+
+static inline void
+of_wire_buffer_wc_bmap_set(int version, of_wire_buffer_t *wbuf, int offset,
+                      of_wc_bmap_t value)
+{
+    switch (version) {
+    case OF_VERSION_1_0:
+    case OF_VERSION_1_1:
+        of_wire_buffer_u32_set(wbuf, offset, (uint32_t)value);
+        break;
+    case OF_VERSION_1_2:
+    case OF_VERSION_1_3:
+        of_wire_buffer_u64_set(wbuf, offset, (uint64_t)value);
+        break;
+    default:
+        ASSERT(0);
+    }
+}
+
+/* match bitmap and wildcard bitmaps followed the same pattern */
+#define of_wire_buffer_match_bmap_get of_wire_buffer_wc_bmap_get
+#define of_wire_buffer_match_bmap_set of_wire_buffer_wc_bmap_set
+
+/* Derived functions, mostly for fixed length name strings */
+#define of_wire_buffer_char_get of_wire_buffer_u8_get
+#define of_wire_buffer_char_set of_wire_buffer_u8_set
+
+
+/**
+ * Get an octet object from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value Pointer to where to put value
+ *
+ * of_octets_t is treated specially as the high level functions pass around
+ * pointers for "get" operators.
+ *
+ * Important: The length of data to copy is stored in the value->bytes
+ * variable.
+ */
+
+static inline void
+of_wire_buffer_octets_data_get(of_wire_buffer_t *wbuf, int offset,
+                               of_octets_t *value)
+{
+    OF_WIRE_BUFFER_ACCESS_CHECK(wbuf, offset + OF_OCTETS_BYTES_GET(value));
+    buf_octets_get(OF_WIRE_BUFFER_INDEX(wbuf, offset),
+                   OF_OCTETS_POINTER_GET(value),
+                   OF_OCTETS_BYTES_GET(value));
+}
+
+/**
+ * Set an octet object in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value Pointer to the octet stream to store
+ * @param cur_len Current length of data in the buffer
+ *
+ * of_octets_t is treated specially as the high level functions pass around
+ * pointers for "get" operators.
+ *
+ * @fixme Need to take into account cur_len
+ */
+
+static inline void
+of_wire_buffer_octets_data_set(of_wire_buffer_t *wbuf, int offset,
+                               of_octets_t *value, int cur_len)
+{
+    // FIXME need to adjust length of octets member in buffer
+    ASSERT(cur_len == 0 || cur_len == value->bytes);
+
+    OF_WIRE_BUFFER_ACCESS_CHECK(wbuf, offset + OF_OCTETS_BYTES_GET(value));
+    buf_octets_set(OF_WIRE_BUFFER_INDEX(wbuf, offset),
+                   OF_OCTETS_POINTER_GET(value),
+                   OF_OCTETS_BYTES_GET(value));
+}
+
+static inline void
+_wbuf_octets_set(of_wire_buffer_t *wbuf, int offset, uint8_t *src, int bytes) {
+    of_octets_t octets;
+    OF_OCTETS_POINTER_SET(&octets, src);
+    OF_OCTETS_BYTES_SET(&octets, bytes);
+    of_wire_buffer_octets_data_set(wbuf, offset, &octets, bytes);
+}
+
+static inline void
+_wbuf_octets_get(of_wire_buffer_t *wbuf, int offset, uint8_t *dst, int bytes) {
+    of_octets_t octets;
+    OF_OCTETS_POINTER_SET(&octets, dst);
+    OF_OCTETS_BYTES_SET(&octets, bytes);
+    of_wire_buffer_octets_data_get(wbuf, offset, &octets);
+}
+
+
+/**
+ * Get a MAC address from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param mac Pointer to the mac address location
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_mac_get(buf, offset, mac) \
+    _wbuf_octets_get(buf, offset, (uint8_t *)mac, 6)
+
+/**
+ * Set a MAC address in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param mac The variable holding the mac address to store
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_mac_set(buf, offset, mac) \
+    _wbuf_octets_set(buf, offset, (uint8_t *)&mac, 6)
+
+
+/**
+ * Get a port name string from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param mac The mac address
+ *
+ * Uses the octets function.
+ */
+#define of_wire_buffer_port_name_get(buf, offset, portname) \
+    _wbuf_octets_get(buf, offset, (uint8_t *)portname, \
+                           OF_MAX_PORT_NAME_LEN)
+
+/**
+ * Set a port name address in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param portname Where to store the port name
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_port_name_set(buf, offset, portname) \
+    _wbuf_octets_set(buf, offset, (uint8_t *)portname, \
+                           OF_MAX_PORT_NAME_LEN)
+
+
+/**
+ * Get a table name string from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param portname The port name
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_tab_name_get(buf, offset, tabname) \
+    _wbuf_octets_get(buf, offset, (uint8_t *)tabname, \
+                           OF_MAX_TABLE_NAME_LEN)
+
+/**
+ * Set a table name address in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param mac Where to store the table name
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_tab_name_set(buf, offset, tabname) \
+    _wbuf_octets_set(buf, offset, (uint8_t *)tabname, \
+                           OF_MAX_TABLE_NAME_LEN)
+
+/**
+ * Get a description string from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param desc Where to store the description string
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_desc_str_get(buf, offset, desc) \
+    _wbuf_octets_get(buf, offset, (uint8_t *)desc, OF_DESC_STR_LEN)
+
+/**
+ * Set a description string in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param desc The description string
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_desc_str_set(buf, offset, desc) \
+    _wbuf_octets_set(buf, offset, (uint8_t *)desc, OF_DESC_STR_LEN)
+
+/**
+ * Get a serial number string from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param sernum Where to store the serial number string
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_ser_num_get(buf, offset, sernum) \
+    _wbuf_octets_get(buf, offset, (uint8_t *)sernum, OF_SERIAL_NUM_LEN)
+
+/**
+ * Set a serial number string in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param desc The serial number string
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_ser_num_set(buf, offset, sernum) \
+    _wbuf_octets_set(buf, offset, (uint8_t *)sernum, OF_SERIAL_NUM_LEN)
+
+/**
+ * Get an ipv6 address from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param addr Pointer to where to store the ipv6 address
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_ipv6_get(buf, offset, addr) \
+    _wbuf_octets_get(buf, offset, (uint8_t *)addr, sizeof(of_ipv6_t))
+
+/**
+ * Set an ipv6 address in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param addr The variable holding ipv6 address to store
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_ipv6_set(buf, offset, addr) \
+    _wbuf_octets_set(buf, offset, (uint8_t *)&addr, sizeof(of_ipv6_t))
+
+/* Relocate data from start offset to the end of the buffer to a new position */
+static inline void
+of_wire_buffer_move_end(of_wire_buffer_t *wbuf, int start_offset, int new_offset)
+{
+    int bytes;
+    int new_length;
+
+    if (new_offset > start_offset) {
+        bytes =  new_offset - start_offset;
+        new_length = wbuf->alloc_bytes + bytes;
+        OF_WIRE_BUFFER_ACCESS_CHECK(wbuf, new_length);
+    } else {
+        bytes =  start_offset - new_offset;
+        new_length = wbuf->alloc_bytes - bytes;
+    }
+
+    MEMMOVE(&wbuf->buf[new_offset], &wbuf->buf[start_offset], bytes);
+    wbuf->alloc_bytes = new_length;
+}
+
+/* Given a wire buffer object and the offset of the start of an of_match struct,
+ * return its total length in the buffer
+ */
+static inline int
+of_match_bytes(of_wire_buffer_t *wbuf, int offset) {
+    uint16_t len;
+    of_wire_buffer_u16_get(wbuf, offset + 2, &len);
+    return OF_MATCH_BYTES(len);
+}
+
+extern void
+of_wire_buffer_replace_data(of_wire_buffer_t *wbuf, 
+                            int offset, 
+                            int old_len,
+                            uint8_t *data,
+                            int new_len);
+
+#endif /* _OF_WIRE_BUF_H_ */
diff --git a/c_gen/util.py b/c_gen/util.py
new file mode 100644
index 0000000..d4b25bf
--- /dev/null
+++ b/c_gen/util.py
@@ -0,0 +1,41 @@
+# Copyright 2013, Big Switch Networks, Inc.
+#
+# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+# the following special exception:
+#
+# LOXI Exception
+#
+# As a special exception to the terms of the EPL, you may distribute libraries
+# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+# that copyright and licensing notices generated by LoxiGen are not altered or removed
+# from the LoxiGen Libraries and the notice provided below is (i) included in
+# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+# documentation for the LoxiGen Libraries, if distributed in binary form.
+#
+# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+#
+# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+# a copy of the EPL at:
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# 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
+# EPL for the specific language governing permissions and limitations
+# under the EPL.
+
+"""
+Utilities for generating the target C code
+"""
+import os
+import loxi_utils.loxi_utils as utils
+
+templates_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'templates')
+template_path = [templates_dir, templates_dir + '/locitest']
+
+def render_template(out, name, **context):
+    utils.render_template(out, name, template_path, context)
+
+def render_static(out, name):
+    utils.render_static(out, name, template_path)