wireshark: get inheritance data from IR
diff --git a/wireshark_gen/__init__.py b/wireshark_gen/__init__.py
index 0395013..174abf8 100644
--- a/wireshark_gen/__init__.py
+++ b/wireshark_gen/__init__.py
@@ -36,38 +36,6 @@
 
 DissectorField = namedtuple("DissectorField", ["fullname", "name", "type", "base"])
 
-# TODO move into IR
-def create_superclass_map():
-    superclasses = {}
-    for supercls, subcls_set in loxi_front_end.type_maps.inheritance_map.items():
-        for subcls in subcls_set:
-            superclasses[supercls + '_' + subcls] = supercls
-
-    for version, versioned in loxi_front_end.type_maps.message_types.items():
-        for subcls in versioned:
-            superclasses['of_' + subcls] = 'of_message'
-
-    for version, versioned in loxi_front_end.type_maps.extension_message_subtype.items():
-        for experimenter, classes in versioned.items():
-            for cls in classes:
-                superclasses[cls] = 'of_experimenter_' + experimenter
-
-    for version, versioned in loxi_front_end.type_maps.extension_action_subtype.items():
-        for experimenter, classes in versioned.items():
-            for cls in classes:
-                superclasses[cls] = 'of_action_' + experimenter
-
-    for version, versioned in loxi_front_end.type_maps.stats_types.items():
-        for subcls in versioned:
-            superclasses['of_' + subcls + '_stats_request'] = 'of_stats_request'
-            superclasses['of_' + subcls + '_stats_reply'] = 'of_stats_reply'
-
-    for version, versioned in loxi_front_end.type_maps.flow_mod_types.items():
-        for subcls in versioned:
-            superclasses['of_flow_' + subcls] = 'of_flow_mod'
-
-    return superclasses
-
 def create_fields():
     r = []
     proto_names = { 1: 'of10', 2: 'of11', 3: 'of12', 4: 'of13' }
@@ -85,15 +53,7 @@
     return r
 
 def generate(out, name):
-    superclasses = create_superclass_map()
-    all_classes = sorted(of_g.unified.keys())
-
-    for cls in all_classes:
-        if cls not in superclasses:
-            print cls + ": " + superclasses.get(cls, "NONE")
-
     context = {
-        'superclasses': superclasses,
         'fields': create_fields(),
     }
     utils.render_template(out, "openflow.lua", [templates_dir], context)
diff --git a/wireshark_gen/templates/_ofclass_dissector.lua b/wireshark_gen/templates/_ofclass_dissector.lua
index 6f27f12..cc8d865 100644
--- a/wireshark_gen/templates/_ofclass_dissector.lua
+++ b/wireshark_gen/templates/_ofclass_dissector.lua
@@ -26,10 +26,23 @@
 :: # under the EPL.
 ::
 :: from loxi_ir import *
+:: attrs = []
+:: if ofclass.virtual: attrs.append("virtual")
+:: if ofclass.superclass: attrs.append("child")
+:: if not ofclass.superclass: attrs.append("top-level")
+-- ${' '.join(attrs)} class ${ofclass.name}
+:: if ofclass.superclass:
+-- Child of ${ofclass.superclass}
+:: #endif
+:: if ofclass.virtual:
+-- Discriminator is ${ofclass.discriminator.name}
+:: #endif
 function ${name}(buf, subtree)
 :: for m in ofclass.members:
 :: if isinstance(m, OFTypeMember):
     -- type ${m.name}
+:: elif isinstance(m, OFDiscriminatorMember):
+    -- discriminator ${m.name}
 :: elif isinstance(m, OFDataMember):
     -- data ${m.name}
 :: elif isinstance(m, OFLengthMember):
diff --git a/wireshark_gen/templates/openflow.lua b/wireshark_gen/templates/openflow.lua
index 5832779..8b9b1c1 100644
--- a/wireshark_gen/templates/openflow.lua
+++ b/wireshark_gen/templates/openflow.lua
@@ -62,26 +62,35 @@
 :: #endfor
 }
 
-:: for supercls in set(sorted(superclasses.values())):
-local ${supercls}_dissectors = {
+-- Subclass maps for virtual classes
 :: for version, ofproto in ir.items():
-    [${version}] = {},
+:: for ofclass in ofproto.classes:
+:: if ofclass.virtual:
+${ofclass.name}_v${version}_dissectors = {}
+:: #endif
 :: #endfor
-}
 :: #endfor
 
+--- Dissectors for each class
+
 :: for version, ofproto in ir.items():
 :: for ofclass in ofproto.classes:
 :: name = 'dissect_%s_v%d' % (ofclass.name, version)
-:: typeval = 0
 :: include('_ofclass_dissector.lua', name=name, ofclass=ofclass)
-:: if ofclass.name in superclasses:
-${superclasses[ofclass.name]}_dissectors[${version}][${typeval}] = ${name}
+:: if ofclass.superclass:
+:: discriminator_value = 0
+${ofclass.superclass}_v${version}_dissectors[${discriminator_value}] = ${name}
 
 :: #endif
 :: #endfor
 :: #endfor
 
+local of_message_dissectors = {
+:: for version in ir:
+    [${version}] = of_header_v${version}_dissectors,
+:: #endfor
+}
+
 function dissect_of_message(buf, root)
     local subtree = root:add(p_of, buf(0))
     subtree:add(fields['of10.header.version'], buf(0,1))