THIS IS A TEST INSTANCE. Feel free to ask and answer questions, but take care to avoid triggering too many notifications.
0

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

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

BMWE's avatar
1
BMWE
asked 2018-02-27 14:09:55 +0000
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

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!

MarkoPaul0's avatar
1
MarkoPaul0
answered 2018-03-26 00:39:54 +0000
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer