loci: remove most type_maps code
These functions were only used by the old validator.
diff --git a/c_gen/c_code_gen.py b/c_gen/c_code_gen.py
index 3fa4f3a..10acf1f 100644
--- a/c_gen/c_code_gen.py
+++ b/c_gen/c_code_gen.py
@@ -386,14 +386,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,
@@ -410,33 +402,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];
diff --git a/c_gen/c_test_gen.py b/c_gen/c_test_gen.py
index 57d141d..d94691f 100644
--- a/c_gen/c_test_gen.py
+++ b/c_gen/c_test_gen.py
@@ -1093,7 +1093,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 +1110,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..859abd8 100644
--- a/c_gen/c_type_maps.py
+++ b/c_gen/c_type_maps.py
@@ -34,629 +34,6 @@
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("""
@@ -696,27 +73,6 @@
%(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/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;
}