We have a Wireshark dissector written in lua.
There is a top-level script ‘general.lua’ which contains:
<code>-- Create a protocol object
xran_protocol = Proto("xran", "<snip>") <-- line 27
<snip>
</code>
<code>-- Create a protocol object
xran_protocol = Proto("xran", "<snip>") <-- line 27
<snip>
</code>
-- Create a protocol object
xran_protocol = Proto("xran", "<snip>") <-- line 27
<snip>
and we have a second script ‘cplane.lua’ to handle part of the protocol, which contains:
<code>require "general"
-- Create a protocol object
xran_cplane_proto = Proto("cplane", "<snip>")
<snip>
debug_level = xran_protocol.prefs.c_plane_debug_level <-- line 348
<snip>
</code>
<code>require "general"
-- Create a protocol object
xran_cplane_proto = Proto("cplane", "<snip>")
<snip>
debug_level = xran_protocol.prefs.c_plane_debug_level <-- line 348
<snip>
</code>
require "general"
-- Create a protocol object
xran_cplane_proto = Proto("cplane", "<snip>")
<snip>
debug_level = xran_protocol.prefs.c_plane_debug_level <-- line 348
<snip>
Without the require statement I see:
<code>Lua Error: cplane.lua:348: attempt to index global 'xran_protocol' (a nil value)
</code>
<code>Lua Error: cplane.lua:348: attempt to index global 'xran_protocol' (a nil value)
</code>
Lua Error: cplane.lua:348: attempt to index global 'xran_protocol' (a nil value)
So I added require but then get:
<code>general.lua:27: bad argument
#2 to 'Proto' (Proto new: there cannot be two protocols with the same
description)
</code>
<code>general.lua:27: bad argument
#2 to 'Proto' (Proto new: there cannot be two protocols with the same
description)
</code>
general.lua:27: bad argument
#2 to 'Proto' (Proto new: there cannot be two protocols with the same
description)
Is require causing the code in general.lua to be executed twice?
What is the correct way for the second script to access xran_protocol?