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

many locals in lua file

0

Hello,

I'm writing a tool that transfers some XML file into a LUA file. The XML file contains above 100 messages.

I have to have as minimum following 2 statements for each message:

local p_multi = Proto("multi", "MultiProto");
local f=p_multi.fields

meaning that I have at least 200 'local' records which is limited by LUA. I've tried to use it as follows, but getting an error:

local locals={}
locals.p_multi = Proto("multi", "MultiProto");
locals.f=p_multi.fields

I've also tried to remove the local statement, but in Wireshark I've received an empty message content (i.e all the fields were with null value)

p_multi = Proto("multi", "MultiProto");
f=p_multi.fields

Any suggestion how to solve it?

Thank you :)

asked 13 Sep '17, 21:55

BMWE's gravatar image

BMWE
467811
accept rate: 100%

edited 13 Sep '17, 22:00

I've found how can I reduce to a single local instead of two. but this still can be problematic as number of messages can be above 200 (different small messages send on the network).

(13 Sep '17, 22:12) BMWE

One Answer:

0

Replacing locals.f=p_multi.fields with locals.f=locals.p_multi.fields and doing same in all relevant places solved the issue

answered 18 Sep '17, 01:48

BMWE's gravatar image

BMWE
467811
accept rate: 100%

Hello, I am also generating lua dissectors. Do you mind me asking what these are for?

Maybe we could share some knowledge. Here are a few examples:

https://github.com/Open-Markets-Initiative/wireshark-lua

Bill

(03 Oct '17, 13:13) william

Hi,

Having a glimpse on your work and it seems good. I'll have some additional look later.

(04 Oct '17, 07:08) BMWE