Recursive ethertype reader
diff --git a/wireshark_gen/__init__.py b/wireshark_gen/__init__.py
index 5c02e06..a610f3f 100644
--- a/wireshark_gen/__init__.py
+++ b/wireshark_gen/__init__.py
@@ -52,6 +52,8 @@
enum = ofproto.enum_by_name(m.oftype)
if enum and 'wire_type' in enum.params:
return "read_" + enum.params['wire_type']
+ elif (cls.name, m.name) in field_info.reader_overrides:
+ return field_info.reader_overrides[(cls.name, m.name)]
else:
return "read_" + m.oftype.replace(')', '').replace('(', '_')
diff --git a/wireshark_gen/field_info.py b/wireshark_gen/field_info.py
index 94e5243..3b76937 100644
--- a/wireshark_gen/field_info.py
+++ b/wireshark_gen/field_info.py
@@ -171,3 +171,7 @@
"cookie": "HEX",
"datapath_id": "HEX",
}
+
+reader_overrides = {
+ ("of_packet_in", "data"): "read_ethernet",
+}
diff --git a/wireshark_gen/templates/_oftype_readers.lua b/wireshark_gen/templates/_oftype_readers.lua
index c13c206..f389de4 100644
--- a/wireshark_gen/templates/_oftype_readers.lua
+++ b/wireshark_gen/templates/_oftype_readers.lua
@@ -192,3 +192,12 @@
return
end
end
+
+function read_ethernet(reader, version, subtree, field_name)
+ if reader.is_empty() then
+ return
+ end
+ local child_subtree = subtree:add(fields[field_name], reader.peek_all(0))
+ child_subtree:set_text("Ethernet packet")
+ ethernet_dissector:call(reader.read_all():tvb(), current_pkt, child_subtree)
+end
diff --git a/wireshark_gen/templates/openflow.lua b/wireshark_gen/templates/openflow.lua
index cad61a5..ccee27f 100644
--- a/wireshark_gen/templates/openflow.lua
+++ b/wireshark_gen/templates/openflow.lua
@@ -40,6 +40,9 @@
:: include('_ofreader.lua')
p_of = Proto ("of", "OpenFlow")
+ethernet_dissector = Dissector.get("eth")
+
+current_pkt = nil
local openflow_versions = {
:: for version in loxi_globals.OFVersions.all_supported:
@@ -140,6 +143,7 @@
-- of dissector function
function p_of.dissector (buf, pkt, root)
local offset = 0
+ current_pkt = pkt
repeat
if buf:len() - offset >= 4 then
msg_len = buf(offset+2,2):uint()