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

Lua dissector preferences scope?

0

I'm writing a dissector in Lua and I have two functions besides my dissection functions in the script. Previously, within the dissection function I would be able to get the value of the prefs, and then use them as I see fit.

However, since I have two other function, I want those prefs to be inputs to those functions. These functions run only once, outside of the dissection function. However, when I try to input the prefs into the functions Wireshark says that they are of nil value, I suspect the go out of scope.

My code is structured as follows:

-- Protocol Initialization 
-- ProtoField Initialization
-- ProtoField Registration
-- Pref Definitions

function proto.dissector(tvbuf, pktinfo, root) – dissection stuff A = proto.prefs.a B = proto.prefs.b – dissection stuff end

function fun1(A, B) – function def end x, y, z = fun1(A, B) – function call

function fun2(A, B) – function def end i, j = fun2(A, B) – function call

I’ve tried putting the prefs before and after the dissection function with no luck. Is there anyway to take those prefs and use them in fun1 and fun2? The interesting thing is the returned values, like I and j, can be used in the dissection function no problem.

asked 18 Apr ‘17, 10:05

Irfan%20Hossain's gravatar image

Irfan Hossain
116611
accept rate: 0%