Merge into master from pull request #261:
Remove more dead code from LOCI (https://github.com/floodlight/loxigen/pull/261)
diff --git a/c_gen/c_code_gen.py b/c_gen/c_code_gen.py
index 3fa4f3a..e4e2403 100644
--- a/c_gen/c_code_gen.py
+++ b/c_gen/c_code_gen.py
@@ -313,7 +313,6 @@
     @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)
     out.write("\n#endif /* Match header file */\n")
@@ -386,14 +385,6 @@
 #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,
@@ -402,7 +393,6 @@
 
     # gen_base_types(out)
 
-    gen_flow_add_setup_function_declarations(out)
     out.write("""
 /****************************************************************
  *
@@ -410,33 +400,6 @@
  *
  ****************************************************************/
 
-/**
- * Generic experimenter type value.  Applies to all except
- * top level message: Action, instruction, error, stats, queue_props, oxm
- */
-#define OF_EXPERIMENTER_TYPE 0xffff
-
-int of_experimenter_stats_request_to_object_id(uint32_t experimenter, uint32_t subtype, int ver);
-int of_experimenter_stats_reply_to_object_id(uint32_t experimenter, uint32_t subtype, int ver);
-
-of_object_id_t of_action_to_object_id(int action, of_version_t version);
-of_object_id_t of_action_id_to_object_id(int action_id, of_version_t version);
-of_object_id_t of_instruction_to_object_id(int instruction, of_version_t version);
-of_object_id_t of_instruction_id_to_object_id(int instruction, of_version_t version);
-of_object_id_t of_queue_prop_to_object_id(int queue_prop, of_version_t version);
-of_object_id_t of_table_feature_prop_to_object_id(int table_feature_prop, of_version_t version);
-of_object_id_t of_meter_band_to_object_id(int meter_band, of_version_t version);
-of_object_id_t of_hello_elem_to_object_id(int hello_elem, of_version_t version);
-of_object_id_t of_stats_reply_to_object_id(int stats_reply, of_version_t version);
-of_object_id_t of_stats_request_to_object_id(int stats_request, of_version_t version);
-of_object_id_t of_error_msg_to_object_id(uint16_t error_msg, of_version_t version);
-of_object_id_t of_flow_mod_to_object_id(int flow_mod, of_version_t version);
-of_object_id_t of_group_mod_to_object_id(int group_mod, of_version_t version);
-of_object_id_t of_oxm_to_object_id(uint32_t type_len, of_version_t version);
-of_object_id_t of_message_experimenter_to_object_id(of_message_t msg, of_version_t version);
-of_object_id_t of_message_to_object_id(of_message_t msg, int length);
-of_object_id_t of_bsn_tlv_to_object_id(int tlv_type, of_version_t version);
-
 int of_object_wire_init(of_object_t *obj, of_object_id_t base_object_id, int max_len);
 
 extern const int *const of_object_fixed_len[OF_VERSION_ARRAY_MAX];
@@ -1116,86 +1079,6 @@
 
 """)
 
-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);
-""")
-
 ################################################################
 #
 # List accessor code generation
diff --git a/c_gen/c_match.py b/c_gen/c_match.py
index 7fd6a21..bc05747 100644
--- a/c_gen/c_match.py
+++ b/c_gen/c_match.py
@@ -194,36 +194,13 @@
 }
 
 /**
- * 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
+ * @brief Map from mask to OF 1.0 wildcard
  */
 
 extern int of_ip_mask_to_index(uint32_t mask);
 
 /**
- * @brief Map from index to mask
+ * @brief Map from OF 1.0 wildcard to mask
  */
 
 extern uint32_t of_ip_index_to_mask(int index);
@@ -249,68 +226,6 @@
     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. */
-
-    OF_OXM_INDEX_BSN_IN_PORTS_128 = 36,
-    OF_OXM_INDEX_BSN_LAG_ID = 37,
-    OF_OXM_INDEX_BSN_VRF = 38,
-    OF_OXM_INDEX_BSN_GLOBAL_VRF_ALLOWED = 39,
-    OF_OXM_INDEX_BSN_L3_INTERFACE_CLASS_ID = 40,
-    OF_OXM_INDEX_BSN_L3_SRC_CLASS_ID = 41,
-    OF_OXM_INDEX_BSN_L3_DST_CLASS_ID = 42,
-    OF_OXM_INDEX_BSN_EGR_PORT_GROUP_ID = 43,
-    OF_OXM_INDEX_BSN_UDF0 = 44,
-    OF_OXM_INDEX_BSN_UDF1 = 45,
-    OF_OXM_INDEX_BSN_UDF2 = 46,
-    OF_OXM_INDEX_BSN_UDF3 = 47,
-    OF_OXM_INDEX_BSN_UDF4 = 48,
-    OF_OXM_INDEX_BSN_UDF5 = 49,
-    OF_OXM_INDEX_BSN_UDF6 = 50,
-    OF_OXM_INDEX_BSN_UDF7 = 51,
-};
-
-#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
@@ -346,88 +261,7 @@
 #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 const 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 */
-const uint64_t of_match_incompat[4] = {
-    -1,
-    OF_MATCH_V1_INCOMPAT,
-    OF_MATCH_V2_INCOMPAT,
-    0
-};
-
-""")
-
+""" % dict(key=key, ku=key.upper()))
 
 def gen_unified_match_to_v1(out):
     """
@@ -1243,61 +1077,8 @@
 
 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
  */
 
@@ -1305,25 +1086,29 @@
 of_ip_mask_to_index(uint32_t mask)
 {
     int idx;
-
-    OF_IP_MASK_INIT_CHECK;
+    uint32_t cmask;
 
     /* Handle most common cases directly */
-    if ((mask == 0) && (of_ip_mask_map[63] == 0)) {
+    if (mask == 0) {
         return 63;
     }
-    if ((mask == 0xffffffff) && (of_ip_mask_map[0] == 0xffffffff)) {
+    if (mask == 0xffffffff) {
         return 0;
     }
 
-    for (idx = 0; idx < OF_IP_MASK_MAP_COUNT; idx++) {
-        if (mask == of_ip_mask_map[idx]) {
-            return idx;
-        }
+    if ((~mask + 1) & ~mask) {
+        LOCI_LOG_INFO("OF 1.0: Could not map IP addr mask 0x%x", mask);
+        return 63;
     }
 
-    LOCI_LOG_INFO("OF 1.0: Could not map IP addr mask 0x%x", mask);
-    return 0x3f;
+    idx = 0;
+    cmask = ~mask;
+    while (cmask) {
+        cmask >>= 1;
+        idx += 1;
+    }
+
+    return idx;
 }
 
 /**
@@ -1333,22 +1118,17 @@
 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);
+    if (index >= 32) {
         return 0;
+    } else {
+        return 0xffffffff << index;
     }
-
-    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_test_gen.py b/c_gen/c_test_gen.py
index 57d141d..5501ed3 100644
--- a/c_gen/c_test_gen.py
+++ b/c_gen/c_test_gen.py
@@ -255,16 +255,26 @@
     match->version = version;
 """)
 
-    for key, entry in match.of_match_members.items():
+    def populate_match_version(wire_version, keys):
         out.write("""
-    if (!(of_match_incompat[version] &
-            OF_OXM_BIT(OF_OXM_INDEX_%(ku)s))) {
+    if (version == %d) {\
+""" % wire_version)
+        for key in keys:
+            entry = match.of_match_members[key]
+            out.write("""
         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("""
     }
 
-""" % dict(key=key, u_type=entry["m_type"].upper(), ku=key.upper()))
+""")
+
+    populate_match_version(1, match.of_v1_keys)
+    populate_match_version(2, match.of_v2_keys)
+    populate_match_version(3, match.match_keys_sorted)
+    populate_match_version(4, match.match_keys_sorted)
 
     out.write("""
     if (value % 2) {
@@ -958,25 +968,7 @@
     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++) {
+    for (idx = 0; idx < 64; idx++) {
         exp_value = (idx < 32) ? ~((1 << idx) - 1) : 0;
         TEST_ASSERT(of_ip_index_to_mask(idx) == exp_value);
         if (idx < 32) {
@@ -1093,7 +1085,6 @@
     %(cls)s_t *obj;
     uint8_t *msg_buf;
     int value;
-    int len;
     of_object_id_t object_id;
 
     obj = %(cls)s_new(%(v_name)s);
@@ -1111,12 +1102,9 @@
     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);
diff --git a/c_gen/c_type_maps.py b/c_gen/c_type_maps.py
index 6e6f3fe..6c45d4d 100644
--- a/c_gen/c_type_maps.py
+++ b/c_gen/c_type_maps.py
@@ -34,689 +34,7 @@
 from generic_utils import *
 import c_gen.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_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 const 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.
- */
-
-const of_object_id_t *const 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
-    """
-
-    # Generate maps from wire type values to object IDs
-    gen_type_to_object_id(out, "error_msg_type_to_id", "OF_ERROR_MSG",
-                          "OF_%s_ERROR_MSG", type_maps.error_types,
-                          max_type_value)
-    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, "instruction_id_type_to_id", "OF_INSTRUCTION_ID",
-                          "OF_INSTRUCTION_ID_%s", type_maps.instruction_id_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)
-    gen_type_to_object_id(out, "group_mod_type_to_id", "OF_GROUP_MOD",
-                          "OF_GROUP_%s", type_maps.group_mod_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_type_to_object_id(out, "bsn_tlv_type_to_id", "OF_BSN_TLV",
-                          "OF_BSN_TLV_%s", type_maps.bsn_tlv_types,
-                          max_type_value)
-
-def gen_type_to_obj_map_functions(out):
-    """
-    Generate the templated 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 const of_object_id_t *const 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
- *
- */
-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 const of_object_id_t *const 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
- *
- */
-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];
-}
-"""
-    table_features_prop_template = """
-/**
- * %(name)s wire type to object ID array.
- * Treat as private; use function accessor below
- */
-
-extern const of_object_id_t *const 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
- *
- */
-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 == 0xfffe) {
-        return OF_%(u_name)s_EXPERIMENTER;
-    }
-    if (%(name)s == 0xffff) {
-        return OF_%(u_name)s_EXPERIMENTER_MISS;
-    }
-    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 const of_object_id_t *const 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
- *
- */
-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];
-}
-"""
-
-    error_msg_template = """
-/**
- * %(name)s wire type to object ID array.
- * Treat as private; use function accessor below
- */
-
-extern const of_object_id_t *const 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
- *
- */
-of_object_id_t
-of_error_msg_to_object_id(uint16_t %(name)s, of_version_t version)
-{
-    if (!OF_VERSION_OKAY(version)) {
-        return OF_OBJECT_INVALID;
-    }
-    if (%(name)s == OF_EXPERIMENTER_TYPE) {
-        return OF_EXPERIMENTER_ERROR_MSG;
-    }
-    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
- */
-
-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 */
-"""
-    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 const of_object_id_t *const 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
- */
-
-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;
-    uint16_t err_type;
-    uint8_t flow_mod_cmd;
-    uint32_t experimenter, subtype;
-    uint16_t group_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 (stats_type == OF_STATS_TYPE_EXPERIMENTER) {
-            if (length < OF_MESSAGE_STATS_EXPERIMENTER_MIN_LENGTH) {
-                return OF_OBJECT_INVALID;
-            }
-            experimenter = of_message_stats_experimenter_id_get(msg);
-            subtype = of_message_stats_experimenter_subtype_get(msg);
-            if (obj_id == OF_STATS_REQUEST) {
-                obj_id = of_experimenter_stats_request_to_object_id(experimenter, subtype, ver);
-            } else {
-                obj_id = of_experimenter_stats_reply_to_object_id(experimenter, subtype, ver);
-            }
-        } else {
-            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);
-            }
-        }
-    }
-
-    if (obj_id == OF_ERROR_MSG) {
-        if (length < OF_MESSAGE_MIN_ERROR_LENGTH) {
-            return OF_OBJECT_INVALID;
-        }
-        err_type = of_message_error_type_get(msg);
-        obj_id = of_error_msg_to_object_id(err_type, ver);
-    }
-
-    if (obj_id == OF_GROUP_MOD) {
-        if (length < OF_MESSAGE_MIN_GROUP_MOD_LENGTH) {
-            return OF_OBJECT_INVALID;
-        }
-        group_mod_cmd = of_message_group_mod_command_get(msg);
-        obj_id = of_group_mod_to_object_id(group_mod_cmd, ver);
-    }
-
-    return obj_id;
-}
-"""
-
-    oxm_template = """
-/**
- * oxm wire type to object ID array.
- * Treat as private; use function accessor below
- */
-
-extern const of_object_id_t *const of_oxm_type_to_id[OF_VERSION_ARRAY_MAX];
-
-#define OF_OXM_ITEM_COUNT %(ar_len)d\n
-
-/**
- * Map an oxm wire value to an OF object
- * @param oxm The oxm type wire value
- * @param version The version associated with the check
- * @return The oxm OF object type
- * @return OF_OBJECT_INVALID if type does not map to an object
- *
- */
-of_object_id_t
-of_oxm_to_object_id(uint32_t type_len, of_version_t version)
-{
-    if (!OF_VERSION_OKAY(version)) {
-        return OF_OBJECT_INVALID;
-    }
-
-    uint16_t class = (type_len >> 16) & 0xffff;
-    uint8_t masked_type = (type_len >> 8) & 0xff;
-
-    if (class == 0x8000) {
-        if (masked_type < 0 || masked_type >= OF_OXM_ITEM_COUNT) {
-            return OF_OBJECT_INVALID;
-        }
-
-        return of_oxm_type_to_id[version][masked_type];
-    } else if (class == 0x0003) {
-        switch (masked_type) {
-        case 0x00: return OF_OXM_BSN_IN_PORTS_128;
-        case 0x01: return OF_OXM_BSN_IN_PORTS_128_MASKED;
-        case 0x02: return OF_OXM_BSN_LAG_ID;
-        case 0x03: return OF_OXM_BSN_LAG_ID_MASKED;
-        case 0x04: return OF_OXM_BSN_VRF;
-        case 0x05: return OF_OXM_BSN_VRF_MASKED;
-        case 0x06: return OF_OXM_BSN_GLOBAL_VRF_ALLOWED;
-        case 0x07: return OF_OXM_BSN_GLOBAL_VRF_ALLOWED_MASKED;
-        case 0x08: return OF_OXM_BSN_L3_INTERFACE_CLASS_ID;
-        case 0x09: return OF_OXM_BSN_L3_INTERFACE_CLASS_ID_MASKED;
-        case 0x0a: return OF_OXM_BSN_L3_SRC_CLASS_ID;
-        case 0x0b: return OF_OXM_BSN_L3_SRC_CLASS_ID_MASKED;
-        case 0x0c: return OF_OXM_BSN_L3_DST_CLASS_ID;
-        case 0x0d: return OF_OXM_BSN_L3_DST_CLASS_ID_MASKED;
-        case 0x10: return OF_OXM_BSN_UDF0;
-        case 0x11: return OF_OXM_BSN_UDF0_MASKED;
-        case 0x12: return OF_OXM_BSN_UDF1;
-        case 0x13: return OF_OXM_BSN_UDF1_MASKED;
-        case 0x14: return OF_OXM_BSN_UDF2;
-        case 0x15: return OF_OXM_BSN_UDF2_MASKED;
-        case 0x16: return OF_OXM_BSN_UDF3;
-        case 0x17: return OF_OXM_BSN_UDF3_MASKED;
-        case 0x18: return OF_OXM_BSN_UDF4;
-        case 0x19: return OF_OXM_BSN_UDF4_MASKED;
-        case 0x1a: return OF_OXM_BSN_UDF5;
-        case 0x1b: return OF_OXM_BSN_UDF5_MASKED;
-        case 0x1c: return OF_OXM_BSN_UDF6;
-        case 0x1d: return OF_OXM_BSN_UDF6_MASKED;
-        case 0x1e: return OF_OXM_BSN_UDF7;
-        case 0x1f: return OF_OXM_BSN_UDF7_MASKED;
-        default: return OF_OBJECT_INVALID;
-        }
-    } else {
-        return OF_OBJECT_INVALID;
-    }
-}
-"""
-
-    # 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))
-
-    # Instruction ID types array gen
-    ar_len = type_maps.type_array_len(type_maps.instruction_id_types, max_type_value)
-    out.write(map_with_experimenter_template %
-              dict(name="instruction_id", u_name="INSTRUCTION_ID", 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(table_features_prop_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.error_types,
-                                      max_type_value)
-    out.write(error_msg_template %
-              dict(name="error_msg", u_name="ERROR_MSG", ar_len=ar_len))
-#     out.write(error_msg_function)
-
-    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.group_mod_types,
-                                      max_type_value)
-    out.write(map_template %
-              dict(name="group_mod", u_name="GROUP_MOD", ar_len=ar_len))
-
-    # OXM
-    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(oxm_template % dict(ar_len=ar_len))
-
-    # Messages
-    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))
-
-    # BSN TLV elem types array gen
-    ar_len = type_maps.type_array_len(type_maps.bsn_tlv_types,
-                                      max_type_value)
-    out.write(map_template %
-              dict(name="bsn_tlv", u_name="BSN_TLV", ar_len=ar_len))
-
 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.
diff --git a/c_gen/codegen.py b/c_gen/codegen.py
index 9af9223..7cb46db 100644
--- a/c_gen/codegen.py
+++ b/c_gen/codegen.py
@@ -173,8 +173,6 @@
 def generate_type_maps(install_dir):
     # Collect legacy code
     tmp = StringIO()
-    c_type_maps.gen_type_to_obj_map_functions(tmp)
-    c_type_maps.gen_type_maps(tmp)
     c_type_maps.gen_length_array(tmp)
     c_type_maps.gen_extra_length_array(tmp)
 
diff --git a/c_gen/loxi_utils_legacy.py b/c_gen/loxi_utils_legacy.py
index 48aaca0..f898957 100644
--- a/c_gen/loxi_utils_legacy.py
+++ b/c_gen/loxi_utils_legacy.py
@@ -134,35 +134,6 @@
                    "of_bsn_gentable_entry_desc_stats_entry", "of_bsn_gentable_entry_stats_entry",
                    "of_bsn_gentable_desc_stats_entry"]
 
-def class_is_oxm(cls):
-    """
-    Return True if cls_name is an OXM object
-    """
-    if cls.find("of_oxm") == 0:
-        return True
-    return False
-
-def class_is_action(cls):
-    """
-    Return True if cls_name is an action object
-
-    Note that action_id is not an action object, though it has
-    the same header.  It looks like an action header, but the type
-    is used to identify a kind of action, it does not indicate the
-    type of the object following.
-    """
-    if cls.find("of_action_id") == 0:
-        return False
-    if cls.find("of_action") == 0:
-        return True
-
-    # For each vendor, check for vendor specific action
-    for exp in of_g.experimenter_name_to_id:
-        if cls.find("of_action" + exp) == 0:
-            return True
-
-    return False
-
 def class_is_list(cls):
     """
     Return True if cls_name is a list object
diff --git a/c_gen/match.py b/c_gen/match.py
index d9fdee5..59653a0 100644
--- a/c_gen/match.py
+++ b/c_gen/match.py
@@ -586,12 +586,6 @@
     "metadata"
     ]
 
-def oxm_index(key):
-    """
-    What's the index called for a match key
-    """
-    return "OF_OXM_INDEX_" + key.upper()
-
 ##
 # Check that all members in the hash are recognized as match keys
 def match_sanity_check():
diff --git a/c_gen/templates/locitest/test_ext.c b/c_gen/templates/locitest/test_ext.c
index 75f4a00..7bd0998 100644
--- a/c_gen/templates/locitest/test_ext.c
+++ b/c_gen/templates/locitest/test_ext.c
@@ -46,28 +46,5 @@
     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-1,
-                                                   OF_VERSION_1_3) ==
-                OF_TABLE_FEATURE_PROP_EXPERIMENTER);
-
-    TEST_ASSERT(of_table_feature_prop_to_object_id(OF_EXPERIMENTER_TYPE,
-                                                   OF_VERSION_1_3) ==
-                OF_TABLE_FEATURE_PROP_EXPERIMENTER_MISS);
-
     return TEST_PASS;
 }