Ask Your Question
0

Custom sub protocols registering with a custom protocol's dissector table

asked 2019-07-09 22:39:58 +0000

mancha gravatar image

Hi, I am writing lua dissectors for a) A custom protocol b) A (many) custom sub-protocols.

In the custom protocol:

The custom protocol can be used with its registration to the udp.port. DissectorTable.get("udp.port"):add_for_decode_as(CUSTOM_PROTO)

It creates a table for the sub protocols to register with dissectorTable = DissectorTable.new("myCustomProtocol", "Custom Protocol");

In the custom sub-protocol:

The custom sub-protocol tries to register with the custom protocol DissectorTable.get("myCustomProtocol"):add_for_decode_as(CUSTOM_SUB_PROTO)

Error:

When loading the dissectors at startup, wireshark says "bad argument #1 to 'get' (DissectorTable_get: no such dissector_table)"

What am I doing wrong/not doing?

Thanks Madhav.

edit retag flag offensive close merge delete

Comments

In the custom sub-protocol, can you try adding an init() function, and perform the dissector table registration within that function instead?

Ref: See Lekensteyn's answer to the question, How to add to a Lua DissectorTable? over at StackOverflow.

cmaynard gravatar imagecmaynard ( 2019-07-19 20:47:21 +0000 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-07-10 04:15:25 +0000

Guy Harris gravatar image

What am I doing wrong

Assuming that Wireshark correctly supports Lua dissectors registering dissector tables and Lua dissectors registering in those dissector tables.

For non-Lua dissectors, there are routines that are called during the first pass of dissector initialization - those routines register protocols, dissectors, protocol fields, and dissector tables - and routines that are called during the second pass of dissector initialization - those routines fetch named dissector handles and field information, and register in dissector tables. All pass 1 routines are called before any pass 2 routine is called, ensuring that, for example, all dissector tables are created before any dissector tries to register in the table.

No mechanism to do that is provided for Lua dissectors, so you would have to manually ensure that the protocol's dissector creates the new dissector table before the sub-protocol's dissector tries to register in it; that means you'll have to put both of the protocol implementations in the same Lua source file, as, if they were in separate files, there would be no way to ensure that the protocol's Lua file gets run before the sub-protocol's Lua file.

I have filed bug 15907 for this problem.

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: 2019-07-09 22:39:58 +0000

Seen: 92 times

Last updated: Jul 10