This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Calling Lua from C Dissector

0

Hello,

I was given a lua dissector and I need to call this dissector from another dissector that I wrote in C. Is there anyway that I can accomplish this. My dissector currently calls another C dissector without issue using the find_dissector(string) function. When I do this with the lua script, it just return null. I know that the all dissectors work on their own.

Thank you.

asked 23 Jun '15, 14:16

TheSuperShoe's gravatar image

TheSuperShoe
6112
accept rate: 0%


One Answer:

0

I found a "fix" to my issue.

I had to check in my dissect function if the handle was null, then call find_dissector() again. The other C dissectors I use are fine being called from my proto_reg_handoff_() function.

My guess is that the lua dissectors are not registered at the same time as the C dissectors, therefor the C dissector could not find the lua until it was dissecting.

answered 24 Jun '15, 13:28

TheSuperShoe's gravatar image

TheSuperShoe
6112
accept rate: 0%

Yes, something has to be done "first", and it's the C-code dissectors. Really the Lua scripts don't even get loaded until all the C-code based initialization is done.

If you can change the Lua script, you could have the Lua-based dissector register itself to be invoked by the C-code based one. In other words, instead of making the C-code find the Lua-based dissector to invoke it, reverse it and have the C-code based one create a dissector table (register_dissector_table()), so the Lua script can register itself in that table (using DissectorTable.get("myCCodeDissector") in Lua).

(24 Jun '15, 14:50) Hadriel