Merge into master from pull request #201:
of_table_feature_prop_experimenter_miss type value fix (https://github.com/floodlight/loxigen/pull/201)
diff --git a/c_gen/c_type_maps.py b/c_gen/c_type_maps.py
index d4525ba..ac4a972 100644
--- a/c_gen/c_type_maps.py
+++ b/c_gen/c_type_maps.py
@@ -229,7 +229,43 @@
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.
@@ -538,7 +574,7 @@
# 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 %
+ out.write(table_features_prop_template %
dict(name="table_feature_prop", u_name="TABLE_FEATURE_PROP",
ar_len=ar_len))
diff --git a/c_gen/templates/locitest/test_ext.c b/c_gen/templates/locitest/test_ext.c
index 87f9916..75f4a00 100644
--- a/c_gen/templates/locitest/test_ext.c
+++ b/c_gen/templates/locitest/test_ext.c
@@ -61,9 +61,13 @@
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,
+ 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;
}
diff --git a/c_gen/templates/of_type_maps.c b/c_gen/templates/of_type_maps.c
index 6026512..3ea7b6f 100644
--- a/c_gen/templates/of_type_maps.c
+++ b/c_gen/templates/of_type_maps.c
@@ -373,19 +373,6 @@
/**
- * @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
@@ -398,15 +385,7 @@
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);
+ *id = of_table_feature_prop_to_object_id(wire_type, obj->version);
}
/**
diff --git a/openflow_input/standard-1.3 b/openflow_input/standard-1.3
index af7e501..e922a59 100644
--- a/openflow_input/standard-1.3
+++ b/openflow_input/standard-1.3
@@ -1692,21 +1692,20 @@
};
struct of_table_feature_prop_experimenter : of_table_feature_prop {
- uint16_t type == 65535;
+ uint16_t type == 65534;
uint16_t length;
uint32_t experimenter;
uint32_t subtype;
of_octets_t experimenter_data;
};
-// Not yet supported
-// struct of_table_feature_prop_experimenter_miss : of_table_feature_prop {
-// uint16_t type;
-// uint16_t length;
-// uint32_t experimenter;
-// uint32_t subtype;
-// of_octets_t experimenter_data;
-// };
+struct of_table_feature_prop_experimenter_miss : of_table_feature_prop {
+ uint16_t type == 65535;
+ uint16_t length;
+ uint32_t experimenter;
+ uint32_t subtype;
+ of_octets_t experimenter_data;
+};
struct of_table_features {
uint16_t length;