The base
table (which includes base.HEX
, base.DEC
, etc.) is defined in init.lua
, which Wireshark/Tshark automatically loads at startup. That error you're seeing is an indication that either:
1) init.lua
was not loaded (e.g., because it could not be found)
OR
2) base
was accidentally overwritten somewhere in your script (e.g., base = nil
) before base.HEX
These are the default installation locations for init.lua
:
- OS X wireshark.org packages:
/Applications/Wireshark.app/Contents/Resources/share/wireshark/init.lua
- Ubuntu:
/etc/wireshark/init.lua
- Windows wireshark.org installer:
C:\Program Files\Wireshark\init.lua
- Builds from source on UN*X:
/usr/local/share/wireshark/init.lua
Problem 1 above is typically seen in development builds of Wireshark. That is, you're building Wireshark in a sandbox, you've set the install prefix to a local build directory, yet when you start Wireshark (even with WIRESHARK_RUN_FROM_BUILD_DIRECTORY
environment variable set to 1
), it still cannot find init.lua
. The workaround is to copy init.lua
(and console.lua
, which is a helpful tool loaded by init.lua
) to your home directory, which is in the Lua initialization path, and restart Wireshark/Tshark.
UPDATE:
In your init.lua, you've loaded your script at line 34 before any of the Wireshark variables are declared (the base
table is defined at line 247). Any file loading should be done at the end of init.lua (when initialization is complete). However, I don't recommend modifying C:\Program Files\Wireshark\init.lua
because any errors introduced there break initialization for all other scripts. Instead, you should:
- Create/edit
C:\Users\*username*\AppData\Roaming\Wireshark\init.lua
OR
- Delete your original
init.lua
changes, and move your Lua script into C:\Program Files\Wireshark\plugins\1.8.0\
(where 1.8.0
is the current version of Wireshark), where it would be loaded automatically without any other file modification.
answered 10 May '12, 14:13
helloworld
3.1k●4●20●41
accept rate: 28%
thank you for your reply, but i defined base as base={} and this works
I assume you define "works" as in "the interpreter no longer complains about your previous problem". If, on the other hand, you define "works" here as: "the bitfield is displayed in hexadecimal format", then your change does not "work" as intended.
If you set
base = {}
, thenbase.HEX
isnil
, which means you effectively have:Specifying
nil
there tellsProtoField
to use the default, which isbase.DEC
. So, your protocol tree would show:instead of:
In init.lua, I defined the path to my dissector:
…and Wireshark loads my dissector, so I suppose that Wireshark sees
init.lua
.init.lua
andconsole.lua
exist inC:\Program Files\Wireshark</code>.
What version of Wireshark are you running?
The
base
table is only defined ininit.lua
in any standard Wireshark installation. If you’re indeed loadinginit.lua
, then something in your script (or loaded by your script) is likely overwritingbase
. You can quickly test this by adding a couple debug-prints before and after loading your script:Wireshark version: Version 1.6.7 OS Windows
i did debug print, restart wireshark and i recieved following error Lua: Error during loading: [string “C:\Program Files\Wireshark\init.lua”]:33: attempt to index global ‘base’ (a nil value)
Ok. This would be easier to troubleshoot if we could see the entire contents of your
init.lua
. Please copy and paste it into http://pastebin.com and link it here.http://pastebin.com/uK2AnTTP
You’re loading your file way too early in
init.lua
. See updated answer.