How to access fields in custom packet context menus?
Hi!
I am currently struggling with witing a Lua Tap. I've come closer to what I want, but I guess it's still hacky.
Anyhow, I've found out about a New Feature in Wireshark 4.2 โ Custom Packet Context Menus and I think it's great! I don't have any issues in calling register_packet_menu()
to see the wanted context menu entry - that works like a charm.
However, I am struggling to access the packet fields of the selected packet where the context menu is opened at.
Unfortunately, Moshe Kaplan's post omits the interesting part for me:
What's behind local fields = { ... };
? A full example would be nice to see here!
This seems to be a placeholder because it's not valid syntax.
I've tried to call all_field_infos()
- as this is my current workaround in the Lua tap as well to access the data I am interested in. But it turns out that this gives the following error:
Lua: Error During execution of Packet Menu Callback:
<some Lua script file name>:<line number>: wslua_all_field_infos: Cannot be called outside a listener or dissector
I guess that I am missing some basic Wireshark Lua scripting aspect for packet field access here.
More specific questions could be:
- How do I access the USB source address here (
usb.src
)? - How do I access the fields of (multiple!) frames inside of a packet of a custom protocol?
Thanks for your help!