Ask Your Question

Revision history [back]

How get index of buffer in post dissector lua

Hi everybody, I want to parse vendor specific field which is included topology response in 1905 message. How can i get beginning of index of the field in buffer.

set_plugin_info(onsemi_vs_post_info)
vs_info = Field.new("ieee1905.vendor_specific.info")
vs_oui = Field.new("ieee1905.vendor_specific.oui")
message_id = Field.new("ieee1905.message_id");

onsemi_proto = Proto("OnSemiVS", "OnSemi vendor specific")

local al_mac = ProtoField.string("OnSemiVS.al_mac", "source mac address")
local message_type = ProtoField.string("OnSemiVS.message_type", "message type")
local device_uptime = ProtoField.uint32("OnSemiVS.device_uptime", "device up time")
local fw_version_len = ProtoField.uint32("OnSemiVS.fw_version_len", "fw version length")

onsemi_proto.fields = {al_mac, message_type, device_uptime, fw_version_len}

function onsemi_proto.dissector(buffer, pinfo, tree)

    local l_vs_info = vs_info()
    local l_vs_oui = vs_oui()
    local l_message_id = message_id()

    if tostring(l_vs_oui) == tostring(0xac6fbb) and tostring(l_message_id)== "0x00001426" then

        subtree = tree:add(onsemi_proto, "VS custom parser")
        --needed beginning of address of ieee1905.vendor_specific.info
        subtree:add(al_mac, tostring( buffer(xxx, 6) ) ) 
    end

end

register_postdissector(onsemi_proto)