| 1 | initial version |
How to access fields in custom packet context menus?
1500: WSLUA: Add new lua function register_packet_menu()
(There is NO !!! error checking in this so anything other than a vanilla TCP packet will have issues)
You can kick the tires by copying the script below into the Wireshark gui Lua console then click "Evaluate" to add the menu entry.
The set_filter() is the "Prepare" step and the "apply_filter() applies so you could have a "Prepare Filter" and "Apply Filter". There is also a Lua copy_to_clipboard(text) that might save you a step before copying to another Wireshark instance.
local function tcp_conv_filter(...)
local tcp_filter = ""
local fields = {...};
for i, field in ipairs( fields ) do
if (field.name == 'tcp.port' or field.name == "ip.addr") then
if (tcp_filter ~= "") then
tcp_filter = tcp_filter .. " && "
end
tcp_filter = tcp_filter .. field.name .. " == " .. field.display
end
end
set_filter(tcp_filter)
apply_filter()
end
register_packet_menu("XXX My Conversation Filters XXX/TCP", tcp_conv_filter, "tcp.port");