Wireshark-dev: [Wireshark-dev] Lua dissector for raw 802.11 data frames
From: "Kanstrup, Mikael" <Mikael.Kanstrup@xxxxxxxx>
Date: Fri, 18 May 2018 13:35:41 +0000
?Hi,


I am working on a dissector that dissects a proprietary protocol that uses raw 802.11 data frames. The protocol specification is not open so I won't be able to contribute the dissector. I've therefore chosen to implement it in Lua.


Without patching Wireshark's 802.11 dissector I'm not able to register my own dissector. So seeking advice on proper ways to proceed and implement.


I can get it working by adding support for heuristic sub-dissectors on 802.11 data frames. An unfinished example uploaded here:

https://code.wireshark.org/review/#/c/27641/?


With that patch applied a Lua dissector can then register for and analyze the frames like this:

local proto_example = Proto("example", "example protocol")

function is_example_protocol(tvb, pinfo)
    -- check frame header and decide whether example protocol
    return true
end

function proto_example.dissector(tvb, pinfo, tree)
    if not is_example_protocol(tvb) then
        return 0
    end
    -- Skip 802.11 frame header
    local n = 30
    pinfo.cols.info = ""
    pinfo.cols.protocol = "Example"
    tree = tree:add(proto_example, tvb)
    tree:add(f.data, tvb(n));
    return tvb:len()
end

proto_example:register_heuristic("wlan_data", proto_example.dissector)

f = proto_example.fields
f.data = ProtoField.bytes("example.data", "data")


/Mikael