wireshark_gen: resolve enum wire types during generation
Instead of indirecting at runtime. This fixes reading all enums.
diff --git a/wireshark_gen/__init__.py b/wireshark_gen/__init__.py
index 0ab5a95..c4ff7f4 100644
--- a/wireshark_gen/__init__.py
+++ b/wireshark_gen/__init__.py
@@ -43,6 +43,17 @@
ofclass_name[3:],
member_name)
+def get_reader(version, cls, m):
+ """
+ Decide on a reader function to use for the given field
+ """
+ ofproto = of_g.ir[version]
+ enum = ofproto.enum_by_name(m.oftype)
+ if enum and 'wire_type' in enum.params:
+ return "read_" + enum.params['wire_type']
+ else:
+ return "read_" + m.oftype.replace(')', '').replace('(', '_')
+
def get_field_info(version, cls, name, oftype):
"""
Decide on a Wireshark type and base for a given field.
diff --git a/wireshark_gen/templates/_ofclass_dissector.lua b/wireshark_gen/templates/_ofclass_dissector.lua
index f1c81b0..4aef886 100644
--- a/wireshark_gen/templates/_ofclass_dissector.lua
+++ b/wireshark_gen/templates/_ofclass_dissector.lua
@@ -26,7 +26,7 @@
:: # under the EPL.
::
:: from loxi_ir import *
-:: from wireshark_gen import make_field_name
+:: from wireshark_gen import make_field_name, get_reader
:: attrs = []
:: if ofclass.virtual: attrs.append("virtual")
:: if ofclass.superclass: attrs.append("child")
@@ -45,7 +45,7 @@
:: continue
:: #endif
:: field_name = make_field_name(version, ofclass.name, m.name)
-:: reader_name = "read_" + m.oftype.replace(')', '').replace('(', '_')
+:: reader_name = get_reader(version, ofclass, m)
${reader_name}(reader, ${version}, subtree, '${field_name}')
:: #endfor
return '${ofclass.name}'
diff --git a/wireshark_gen/templates/_oftype_readers.lua b/wireshark_gen/templates/_oftype_readers.lua
index 1db9f1f..5b255a5 100644
--- a/wireshark_gen/templates/_oftype_readers.lua
+++ b/wireshark_gen/templates/_oftype_readers.lua
@@ -97,10 +97,6 @@
end
end
-function read_ofp_flow_mod_flags(reader, version, subtree, field_name)
- read_scalar(reader, subtree, field_name, 2)
-end
-
function read_list_of_action_t(reader, version, subtree, field_name)
if reader.is_empty() then
return