loci: remove extra_length
The "extra length" was the total length of members at non-fixed offsets. We're
going to include this in the base length instead.
diff --git a/c_gen/c_code_gen.py b/c_gen/c_code_gen.py
index 38f1ab1..b708c65 100644
--- a/c_gen/c_code_gen.py
+++ b/c_gen/c_code_gen.py
@@ -403,7 +403,6 @@
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];
-extern const int *const of_object_extra_len[OF_VERSION_ARRAY_MAX];
""")
c_type_maps.gen_type_data_header(out)
c_match.gen_declarations(out)
@@ -1600,7 +1599,7 @@
MEMSET(obj, 0, sizeof(*obj));
}
if (bytes < 0) {
- bytes = of_object_fixed_len[version][%(enum)s] + of_object_extra_len[version][%(enum)s];
+ bytes = of_object_fixed_len[version][%(enum)s];
}
obj->version = version;
obj->length = bytes;
@@ -1655,7 +1654,7 @@
%(cls)s_t *obj;
int bytes;
- bytes = of_object_fixed_len[version][%(enum)s] + of_object_extra_len[version][%(enum)s];
+ bytes = of_object_fixed_len[version][%(enum)s];
if ((obj = (%(cls)s_t *)of_object_new(%(max_length)s)) == NULL) {
return NULL;
diff --git a/c_gen/c_test_gen.py b/c_gen/c_test_gen.py
index 7765a3e..dacc8bf 100644
--- a/c_gen/c_test_gen.py
+++ b/c_gen/c_test_gen.py
@@ -541,7 +541,7 @@
"""
members, member_types = scalar_member_types_get(cls, version)
- length = of_g.base_length[(cls, version)] + of_g.extra_length.get((cls, version), 0)
+ length = of_g.base_length[(cls, version)]
v_name = loxi_utils.version_to_name(version)
out.write("""
@@ -1097,7 +1097,7 @@
continue
if type_maps.class_is_virtual(cls):
continue
- bytes = of_g.base_length[(cls, version)] + of_g.extra_length.get((cls, version), 0)
+ bytes = of_g.base_length[(cls, version)]
out.write("""
static int
test_%(cls)s_create_%(v_name)s(void)
@@ -1531,7 +1531,7 @@
"""
members, member_types = scalar_member_types_get(cls, version)
- length = of_g.base_length[(cls, version)] + of_g.extra_length.get((cls, version), 0)
+ length = of_g.base_length[(cls, version)]
v_name = loxi_utils.version_to_name(version)
out.write("""
diff --git a/c_gen/c_type_maps.py b/c_gen/c_type_maps.py
index c7a175f..17f63ca 100644
--- a/c_gen/c_type_maps.py
+++ b/c_gen/c_type_maps.py
@@ -115,44 +115,3 @@
out.write("""
};
""")
-
-
-def gen_extra_length_array(out):
- """
- Generate an array giving the extra 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 extra length part
- * of each OF object
- */
-""")
-
- for version in of_g.of_version_range:
- out.write("""
-static const int\nof_object_extra_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.extra_length.get((cls, version), 0)) + comma
- out.write(" %-5s /* %d: %s */\n" % (val, i + 1, cls))
- out.write("};\n")
-
- out.write("""
-/**
- * Unified map of extra length part of each object
- */
-const int *const of_object_extra_len[OF_VERSION_ARRAY_MAX] = {
- NULL,
-""")
- for version in of_g.of_version_range:
- out.write(" of_object_extra_len_v%d,\n" % version)
- out.write("""
-};
-""")
diff --git a/c_gen/codegen.py b/c_gen/codegen.py
index fa3a79b..dba3d53 100644
--- a/c_gen/codegen.py
+++ b/c_gen/codegen.py
@@ -186,7 +186,6 @@
# Collect legacy code
tmp = StringIO()
c_type_maps.gen_length_array(tmp)
- c_type_maps.gen_extra_length_array(tmp)
with template_utils.open_output(install_dir, "loci/src/of_type_maps.c") as out:
util.render_template(out, "of_type_maps.c", legacy_code=tmp.getvalue())
diff --git a/c_gen/of_g_legacy.py b/c_gen/of_g_legacy.py
index 401c89d..87e0680 100644
--- a/c_gen/of_g_legacy.py
+++ b/c_gen/of_g_legacy.py
@@ -273,13 +273,6 @@
## Map from class, wire_version to size of fixed part of class
base_length = {}
-## Map from class, wire_version to size of variable-offset, fixed length part of class
-extra_length = {
- ("of_packet_in", 3): 2,
- ("of_packet_in", 4): 2,
- ("of_packet_in", 5): 2,
-}
-
## Boolean indication of variable length, per class, wire_version,
is_fixed_length = set()