loci: fix bug in new wire type parsers

Using the unified class's discriminator was incorrect because the discriminator
can change offset and length between OpenFlow versions.

Also added tests that would have caught this bug.
diff --git a/c_gen/c_test_gen.py b/c_gen/c_test_gen.py
index 5b74649..316a2b3 100644
--- a/c_gen/c_test_gen.py
+++ b/c_gen/c_test_gen.py
@@ -543,6 +543,24 @@
     TEST_ASSERT(obj->object_id == %(u_cls)s);
 """ % dict(cls=cls, u_cls=cls.upper(),
            v_name=v_name, length=length, version=version))
+
+    # If this class is a concrete member of an inheritance hierarchy,
+    # run the hierarchy's root wire type parser and assert it returns
+    # the expected object id.
+    ofclass = loxi_globals.unified.class_by_name(cls)
+    if ofclass and not ofclass.virtual:
+        root = ofclass
+        while root.superclass:
+            root = root.superclass
+        if root.virtual:
+            out.write("""
+    {
+        of_object_id_t object_id;
+        %(root_cls)s_wire_object_id_get(obj, &object_id);
+        TEST_ASSERT(object_id == %(u_cls)s);
+    }
+""" % dict(root_cls=root.name, u_cls=cls.upper()))
+
     if not type_maps.class_is_virtual(cls):
         out.write("""
     if (obj->wire_length_get != NULL) {
@@ -1106,6 +1124,7 @@
     uint8_t *msg_buf;
     int value;
     int len;
+    of_object_id_t object_id;
 
     obj = %(cls)s_new(%(v_name)s);
     TEST_ASSERT(obj != NULL);
@@ -1114,6 +1133,9 @@
     TEST_ASSERT(obj->parent == NULL);
     TEST_ASSERT(obj->object_id == %(enum)s);
 
+    of_header_wire_object_id_get(obj, &object_id);
+    TEST_ASSERT(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);
diff --git a/c_gen/codegen.py b/c_gen/codegen.py
index 6f0f6e9..af4dfa4 100644
--- a/c_gen/codegen.py
+++ b/c_gen/codegen.py
@@ -89,11 +89,10 @@
     if not uclass.virtual:
         return None
 
-    discriminator = uclass.discriminator
-
     # Generate a dict of version -> ParseWireTypesVersion
     versioned = {}
     for version, ofclass in sorted(uclass.version_classes.items()):
+        discriminator = ofclass.discriminator
         subclasses = [ParseWireTypesSubclass(class_name=subclass.name,
                                              value=subclass.member_by_name(discriminator.name).value,
                                              virtual=subclass.virtual)