pyloxi: use the same subtemplate for action and common classes
diff --git a/py_gen/templates/_ofclass.py b/py_gen/templates/_ofclass.py
new file mode 100644
index 0000000..ff8b21b
--- /dev/null
+++ b/py_gen/templates/_ofclass.py
@@ -0,0 +1,42 @@
+:: nonskip_members = [m for m in ofclass.members if not m.skip]
+class ${ofclass.pyname}(${superclass}):
+:: for m in ofclass.type_members:
+    ${m.name} = ${m.value}
+:: #endfor
+
+    def __init__(${', '.join(['self'] + ["%s=None" % m.name for m in nonskip_members])}):
+:: for m in nonskip_members:
+        if ${m.name} != None:
+            self.${m.name} = ${m.name}
+        else:
+            self.${m.name} = ${m.oftype.gen_init_expr()}
+:: #endfor
+        return
+
+    def pack(self):
+        packed = []
+:: include("_pack.py", ofclass=ofclass)
+        return ''.join(packed)
+
+    @staticmethod
+    def unpack(buf):
+        obj = ${ofclass.pyname}()
+:: include("_unpack.py", ofclass=ofclass)
+        return obj
+
+    def __eq__(self, other):
+        if type(self) != type(other): return False
+:: for m in nonskip_members:
+        if self.${m.name} != other.${m.name}: return False
+:: #endfor
+        return True
+
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
+    def show(self):
+        import loxi.pp
+        return loxi.pp.pp(self)
+
+    def pretty_print(self, q):
+:: include('_pretty_print.py', ofclass=ofclass)
diff --git a/py_gen/templates/action.py b/py_gen/templates/action.py
index 8f08ced..089cc53 100644
--- a/py_gen/templates/action.py
+++ b/py_gen/templates/action.py
@@ -50,48 +50,7 @@
     pass
 
 :: for ofclass in ofclasses:
-:: nonskip_members = [m for m in ofclass.members if not m.skip]
-class ${ofclass.pyname}(Action):
-:: for m in ofclass.type_members:
-    ${m.name} = ${m.value}
-:: #endfor
-
-    def __init__(self, ${', '.join(["%s=None" % m.name for m in nonskip_members])}):
-:: for m in nonskip_members:
-        if ${m.name} != None:
-            self.${m.name} = ${m.name}
-        else:
-            self.${m.name} = ${m.oftype.gen_init_expr()}
-:: #endfor
-
-    def pack(self):
-        packed = []
-:: include("_pack.py", ofclass=ofclass)
-        return ''.join(packed)
-
-    @staticmethod
-    def unpack(buf):
-        obj = ${ofclass.pyname}()
-:: include("_unpack.py", ofclass=ofclass)
-        return obj
-
-    def __eq__(self, other):
-        if type(self) != type(other): return False
-        if self.type != other.type: return False
-:: for m in nonskip_members:
-        if self.${m.name} != other.${m.name}: return False
-:: #endfor
-        return True
-
-    def __ne__(self, other):
-        return not self.__eq__(other)
-
-    def show(self):
-        import loxi.pp
-        return loxi.pp.pp(self)
-
-    def pretty_print(self, q):
-:: include('_pretty_print.py', ofclass=ofclass)
+:: include('_ofclass.py', ofclass=ofclass, superclass="Action")
 
 :: #endfor
 
diff --git a/py_gen/templates/common.py b/py_gen/templates/common.py
index fbcec25..c9af309 100644
--- a/py_gen/templates/common.py
+++ b/py_gen/templates/common.py
@@ -54,50 +54,8 @@
     return util.unpack_list(packet_queue.unpack, "!4xH", buf)
 
 :: for ofclass in ofclasses:
-class ${ofclass.pyname}(object):
-:: for m in ofclass.type_members:
-    ${m.name} = ${m.value}
+:: include('_ofclass.py', ofclass=ofclass, superclass="object")
+
 :: #endfor
 
-    def __init__(self, ${', '.join(["%s=None" % m.name for m in ofclass.members])}):
-:: for m in ofclass.members:
-        if ${m.name} != None:
-            self.${m.name} = ${m.name}
-        else:
-            self.${m.name} = ${m.oftype.gen_init_expr()}
-:: #endfor
-
-    def pack(self):
-        packed = []
-:: include("_pack.py", ofclass=ofclass)
-        return ''.join(packed)
-
-    @staticmethod
-    def unpack(buf):
-        assert(len(buf) >= ${ofclass.min_length}) # Should be verified by caller
-        obj = ${ofclass.pyname}()
-:: include("_unpack.py", ofclass=ofclass)
-        return obj
-
-    def __eq__(self, other):
-        if type(self) != type(other): return False
-:: for m in ofclass.members:
-        if self.${m.name} != other.${m.name}: return False
-:: #endfor
-        return True
-
-    def __ne__(self, other):
-        return not self.__eq__(other)
-
-    def show(self):
-        import loxi.pp
-        return loxi.pp.pp(self)
-
-    def pretty_print(self, q):
-:: include('_pretty_print.py', ofclass=ofclass)
-
-:: if ofclass.name.startswith("of_match_v"):
-match = ${ofclass.pyname}
-
-:: #endif
-:: #endfor
+match = match_v1