Simplifying reader functions
diff --git a/wireshark_gen/templates/_oftype_readers.lua b/wireshark_gen/templates/_oftype_readers.lua
index 9a5e4fa..10f13ca 100644
--- a/wireshark_gen/templates/_oftype_readers.lua
+++ b/wireshark_gen/templates/_oftype_readers.lua
@@ -135,7 +135,7 @@
local action_len = reader2.peek(2, 2):uint()
local child_reader = reader2.slice(action_len)
local child_subtree = list:add(fields[field_name], child_reader.peek_all(0))
- local info = dissect_of_action(child_reader, child_subtree, version)
+ local info = of_action_dissectors[version](child_reader, child_subtree)
child_subtree:set_text(info)
end
list:set_text("List of actions")
@@ -151,7 +151,7 @@
local port_desc_len = 64
local child_reader = reader.slice(port_desc_len)
local child_subtree = list:add(fields[field_name], child_reader.peek_all(0))
- local info = dissect_of_port_desc(child_reader, child_subtree, version)
+ local info = of_port_desc_dissectors[version](child_reader, child_subtree)
child_subtree:set_text(info)
end
end
@@ -166,7 +166,7 @@
local stats_len = reader.peek(0,2):uint()
local child_reader = reader.slice(stats_len)
local child_subtree = list:add(fields[field_name], child_reader.peek_all(0))
- local info = dissect_of_flow_stats_entry(child_reader, child_subtree, version)
+ local info = of_flow_stats_entry_dissectors[version](child_reader, child_subtree)
child_subtree:set_text(info)
end
end
@@ -181,7 +181,7 @@
local stats_len = 112
local child_reader = reader.slice(stats_len)
local child_subtree = list:add(fields[field_name], child_reader.peek_all(0))
- local info = dissect_of_port_stats_entry(child_reader, child_subtree, version)
+ local info = of_port_stats_entry_dissectors[version](child_reader, child_subtree)
child_subtree:set_text(info)
end
end
@@ -196,7 +196,7 @@
local stats_len = 24
local child_reader = reader.slice(stats_len)
local child_subtree = list:add(fields[field_name], child_reader.peek_all(0))
- local info = dissect_of_table_stats_entry(child_reader, child_subtree, version)
+ local info = of_table_stats_entry_dissectors[version](child_reader, child_subtree)
child_subtree:set_text(info)
end
end
@@ -211,7 +211,7 @@
local stats_len = 40
local child_reader = reader.slice(stats_len)
local child_subtree = list:add(fields[field_name], child_reader.peek_all(0))
- local info = dissect_of_queue_stats_entry(child_reader, child_subtree, version)
+ local info = of_queue_stats_entry_dissectors[version](child_reader, child_subtree)
child_subtree:set_text(info)
end
end
@@ -244,7 +244,7 @@
local match_len = 4 + reader2.peek(3,1):uint()
local child_reader = reader2.slice(match_len)
local child_subtree = list:add(fields[field_name], child_reader.peek_all(0))
- local info = dissect_of_oxm(child_reader, child_subtree, version)
+ local info = of_oxm_dissectors[version](child_reader, child_subtree)
child_subtree:set_text(info)
end
subtree:set_text("OXM")
@@ -256,7 +256,7 @@
return
end
local child_subtree = subtree:add(fields[field_name], reader.peek_all(0))
- local info = dissect_of_instruction(reader, child_subtree, version)
+ local info = of_instruction_dissectors[version](reader, child_subtree)
child_subtree:set_text("Instructions")
end
@@ -270,7 +270,7 @@
local bucket_len = reader.peek(0,2):uint()
local child_reader = reader.slice(bucket_len)
local child_subtree = bucket_list_subtree:add(fields[field_name], child_reader.peek_all(0))
- local info = dissect_of_bucket(child_reader, child_subtree, version)
+ local info = of_bucket_dissectors[version](child_reader, child_subtree)
child_subtree:set_text(info)
end
end
@@ -280,6 +280,6 @@
return
end
local child_subtree = subtree:add(fields[field_name], reader.peek_all(0))
- local info = dissect_of_oxm(reader, child_subtree, version)
+ local info = of_oxm_dissectors[version](reader, child_subtree)
child_subtree:set_text(info)
end
diff --git a/wireshark_gen/templates/openflow.lua b/wireshark_gen/templates/openflow.lua
index 931843d..bdbe2ec 100644
--- a/wireshark_gen/templates/openflow.lua
+++ b/wireshark_gen/templates/openflow.lua
@@ -39,8 +39,6 @@
:: include('_ofreader.lua')
-:: include('_oftype_readers.lua')
-
p_of = Proto ("of", "OpenFlow")
local openflow_versions = {
@@ -104,25 +102,25 @@
local of_message_dissectors = {
:: for version in ir:
- [${version.wire_version}] = of_header_v${version.wire_version}_dissectors,
+ [${version.wire_version}] = dissect_of_header_v${version.wire_version},
:: #endfor
}
local of_oxm_dissectors = {
:: for version in ir:
- [${version.wire_version}] = of_oxm_v${version.wire_version}_dissectors,
+ [${version.wire_version}] = dissect_of_oxm_v${version.wire_version},
:: #endfor
}
local of_action_dissectors = {
:: for version in ir:
- [${version.wire_version}] = of_action_v${version.wire_version}_dissectors,
+ [${version.wire_version}] = dissect_of_action_v${version.wire_version},
:: #endfor
}
local of_instruction_dissectors = {
:: for version in ir:
- [${version.wire_version}] = of_instruction_v${version.wire_version}_dissectors,
+ [${version.wire_version}] = dissect_of_instruction_v${version.wire_version},
:: #endfor
}
@@ -140,13 +138,13 @@
local of_stats_reply_dissectors = {
:: for version in ir:
- [${version.wire_version}] = of_stats_reply_v${version.wire_version}_dissectors,
+ [${version.wire_version}] = dissect_of_stats_reply_v${version.wire_version},
:: #endfor
}
local of_stats_request_dissectors = {
:: for version in ir:
- [${version.wire_version}] = of_stats_request_v${version.wire_version}_dissectors,
+ [${version.wire_version}] = dissect_of_stats_request_v${version.wire_version},
:: #endfor
}
@@ -174,6 +172,8 @@
:: #endfor
}
+:: include('_oftype_readers.lua')
+
function dissect_of_message(buf, root)
local reader = OFReader.new(buf)
local subtree = root:add(p_of, buf(0))
@@ -186,95 +186,11 @@
end
local info = "unknown"
- info = of_message_dissectors[version_val][type_val](reader, subtree)
+ info = of_message_dissectors[version_val](reader, subtree)
return protocol, info
end
-function dissect_of_oxm(reader, subtree, version_val)
- local type_val = reader.peek(0,4):uint()
- local info = "unknown"
- if of_oxm_dissectors[version_val] and of_oxm_dissectors[version_val][type_val] then
- info = of_oxm_dissectors[version_val][type_val](reader, subtree)
- end
-
- return info
-end
-
-function dissect_of_action(reader, subtree, version_val)
- local type_val = reader.peek(0,2):uint()
- local info = "unknown"
- if of_action_dissectors[version_val] and of_action_dissectors[version_val][type_val] then
- info = of_action_dissectors[version_val][type_val](reader, subtree)
- end
-
- return info
-end
-
-function dissect_of_instruction(reader, subtree, version_val)
- local type_val = reader.peek(0,2):uint()
- local info = "unknown"
- if of_instruction_dissectors[version_val] and of_instruction_dissectors[version_val][type_val] then
- info = of_instruction_dissectors[version_val][type_val](reader, subtree)
- end
-
- return info
-end
-
-function dissect_of_bucket(reader, subtree, version_val)
- local info = "unknown"
- if of_bucket_dissectors[version_val] then
- info = of_bucket_dissectors[version_val](reader, subtree)
- end
-
- return info
-end
-
-function dissect_of_port_desc(reader, subtree, version_val)
- local info = "unknown"
- if of_port_desc_dissectors[version_val] then
- info = of_port_desc_dissectors[version_val](reader, subtree)
- end
-
- return info
-end
-
-function dissect_of_flow_stats_entry(reader, subtree, version_val)
- local info = "unknown"
- if of_flow_stats_entry_dissectors[version_val] then
- info = of_flow_stats_entry_dissectors[version_val](reader, subtree)
- end
-
- return info
-end
-
-function dissect_of_port_stats_entry(reader, subtree, version_val)
- local info = "unknown"
- if of_port_stats_entry_dissectors[version_val] then
- info = of_port_stats_entry_dissectors[version_val](reader, subtree)
- end
-
- return info
-end
-
-function dissect_of_table_stats_entry(reader, subtree, version_val)
- local info = "unknown"
- if of_table_stats_entry_dissectors[version_val] then
- info = of_table_stats_entry_dissectors[version_val](reader, subtree)
- end
-
- return info
-end
-
-function dissect_of_queue_stats_entry(reader, subtree, version_val)
- local info = "unknown"
- if of_queue_stats_entry_dissectors[version_val] then
- info = of_queue_stats_entry_dissectors[version_val](reader, subtree)
- end
-
- return info
-end
-
-- of dissector function
function p_of.dissector (buf, pkt, root)
local offset = 0