OSQA is unmaintained. Help us figure out where to go from here.

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, 10:05

Irfan%20Hossain's gravatar image

Irfan Hossain
113611
accept rate: 0%

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×636
×429
×39
×2

question asked: 18 Apr, 10:05

question was seen: 246 times

last updated: 18 Apr, 10:05

p​o​w​e​r​e​d by O​S​Q​A