Initial oftest skeleton with wrapper generators and pylibopenflow
diff --git a/tools/munger/scripts/action_gen.py b/tools/munger/scripts/action_gen.py
new file mode 100644
index 0000000..22c7b4b
--- /dev/null
+++ b/tools/munger/scripts/action_gen.py
@@ -0,0 +1,97 @@
+#!/usr/bin/python
+#
+# This python script generates action subclasses
+#
+
+import re
+
+print """
+# Python OpenFlow action wrapper classes
+
+from ofp import *
+
+# This will never happen; done to avoid lint warning
+if __name__ == '__main__':
+ def of_message_parse(msg): return None
+
+"""
+
+################################################################
+#
+# Action subclasses
+#
+################################################################
+
+action_structs = [
+ 'output',
+ 'vlan_vid',
+ 'vlan_pcp',
+ 'dl_addr',
+ 'nw_addr',
+ 'tp_port',
+ 'nw_tos',
+ 'vendor_header']
+
+action_types = [
+ 'output',
+ 'set_vlan_vid',
+ 'set_vlan_pcp',
+ 'strip_vlan',
+ 'set_dl_src',
+ 'set_dl_dst',
+ 'set_nw_src',
+ 'set_nw_dst',
+ 'set_nw_tos',
+ 'set_tp_src',
+ 'set_tp_dst',
+ 'enqueue',
+ 'vendor'
+]
+action_types.sort()
+
+action_class_map = {
+ 'output' : 'ofp_action_output',
+ 'set_vlan_vid' : 'ofp_action_vlan_vid',
+ 'set_vlan_pcp' : 'ofp_action_vlan_pcp',
+ 'strip_vlan' : 'ofp_action_header',
+ 'set_dl_src' : 'ofp_action_dl_addr',
+ 'set_dl_dst' : 'ofp_action_dl_addr',
+ 'set_nw_src' : 'ofp_action_nw_addr',
+ 'set_nw_dst' : 'ofp_action_nw_addr',
+ 'set_nw_tos' : 'ofp_action_nw_tos',
+ 'set_tp_src' : 'ofp_action_tp_port',
+ 'set_tp_dst' : 'ofp_action_tp_port',
+ 'enqueue' : 'ofp_action_enqueue',
+ 'vendor' : 'ofp_action_vendor_header'
+}
+
+template = """
+class action_--TYPE--(--PARENT_TYPE--):
+ \"""
+ Wrapper class for --TYPE-- action object
+ \"""
+ def __init__(self):
+ --PARENT_TYPE--.__init__(self)
+ self.type = --ACTION_NAME--
+ self.len = self.__len__()
+ def show(self, prefix=''):
+ print prefix + "action_--TYPE--"
+ --PARENT_TYPE--.show(self, prefix)
+"""
+
+if __name__ == '__main__':
+ for (t, parent) in action_class_map.items():
+ action_name = "OFPAT_" + t.upper()
+ to_print = re.sub('--TYPE--', t, template)
+ to_print = re.sub('--PARENT_TYPE--', parent, to_print)
+ to_print = re.sub('--ACTION_NAME--', action_name, to_print)
+ print to_print
+
+ # Generate a list of action classes
+ print "action_class_list = ("
+ prev = None
+ for (t, parent) in action_class_map.items():
+ if prev:
+ print " action_" + prev + ","
+ prev = t
+ print " action_" + prev + ")"