Ask Your Question
0

how to register a new LUA based dissector only to udp src port

asked 2018-02-27 14:09:55 +0000

BMWE gravatar image

Hello,

I'd like to register my new dissector only to a udp src port

Therefore using following code

udp_table = DissectorTable.get("udp.port")
udp_table:add(7777,trivial_proto)

is not a good idea. I'd be glad to have an example how to do it to a specific udp source port (or destination port).

Thank you all

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-03-26 00:39:54 +0000

MarkoPaul0 gravatar image

I don't believe it is possible to register your dissector for a source port as opposed to a destination port. You can only register your dissector for "a port". However, what you can do is register your UDP dissector for that port and then in your dissector return 0 if you detect that the src_port is actually not what you want. Let me give you an example:

local p_triv = Proto.new("triv", "Trivial Protocol")

function p_triv.dissector(buf, pinfo, tree)
    if pinfo.src_port ~= 77777 then
        return 0;  --lets wireshark know nothing was dissected, other dissectors can be called
    end

    --Dissect your trivial protocol packet here
end
udp_table = DissectorTable.get("udp.port")
udp_table:add(7777,trivial_proto)

I hope this helps!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-02-27 14:09:55 +0000

Seen: 2,502 times

Last updated: Mar 26 '18