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

How do I setup Wireshark to run Lua’s CLRPackage

0
1

I previously asked this question about Wireshark setup for running Lua's CLRPackage and it was answered here. The problem is, after version 1.10.9, it appears that some startup search paths or something related have changed. Could someone provide the changes that occurred after 1.10.9 that affect where libraries and other scripts are searched?

I receive the following error if I run the setup with any version after 1.10.9:

Loading Error

The line in init.lua is:

DATA_DIR = datafile_path()

Update

I looks like this is from a previous init.lua file that was being copied, after updating to the latest version, the error is now:

alt text

Update 2 To answer some of the questions:

  • How did you load the "CLRPackage.lua" file? Did you put it in Wireshark's personal plugins directory, or load it using "dofile()", or load it from the command line using the "-X lua_script:..." command?

It was placed in the C:\Program Files (x86)\Wireshark\lua directory

  • Where exactly is the "luanet.lua" file?

I actually dont see this file anywhere, but there is a luanet.dll in the clibs directory (C:\Program Files (x86)\Wireshark\clibs)

  • What is line 15 of CLRPackage.lua?

This is the code: if not luanet then require 'luanet' end

Update 3 Update for additional questions

  • I don't know how this worked even before 1.11.3, unless CLRPackage.lua amended the cpath.

I looked inside of the CLRPackage.lua and I dont see any place it appends to the cpath. The test program that is included does however append the LUA_DEV\clibs directory to package.cpath, but I dont think thats part of the core dll's.

  • How did you get CLRPackage installed? Did you need to compile Wireshark from source code to use CLRPackage? Or did you need to install LuaRocks or some other package?

I didnt compile any of the files provided, I just copied them from the zip file provided. I've tried to compile them using VS2010 but I havent had any luck.

  • What are your Wireshark personal and global plugins directories named? Open Wireshark, go to Help->About Wireshark, and click on the Folders tab. It will list a personal and global plugins directories.

Here is the complete list:

Folders

asked 02 Feb '15, 06:29

SwDevMan81's gravatar image

SwDevMan81
363612
accept rate: 50%

edited 02 Feb '15, 11:52

Just to be clear: it was working fine in 1.10.9 but failed in 1.10.10?

(02 Feb '15, 08:25) Hadriel

@Hadriel - So I went through all the revisions to determine when it actually broke. It looks like it stopped working at 1.11.3, which looks like a change from Lua 5.1 to 5.2.

(02 Feb '15, 09:27) SwDevMan81

A lot changed for Wireshark's Lua in version 1.11.3. I'm not sure this is related to the change to Lua 5.2, though, because the error message above appears to show wireshark can't find the "luanet" Lua module in the path. The various directory paths that it's trying are missing the subdirectory that file is in, presumably.

So some questions: How did you load the "CLRPackage.lua" file? Did you put it in Wireshark's personal plugins directory, or load it using "dofile()", or load it from the command line using the "-X lua_script:..." command? And where exactly is the "luanet.lua" file? And what is line 15 of CLRPackage.lua?

(02 Feb '15, 10:13) Hadriel

@Hadriel - I update the question to address your questions. Let me know if you need more. All the locations and files that I copied match the answer provided here

(02 Feb '15, 10:38) SwDevMan81

OK, so the problem is that "luanet.dll" is a binary module, which means its directory (the "clibs" one) needs to be in Lua's "package.cpath" global variable, and it's not. There was a change in 1.11.3 to handle the various changes to environments, Lua 5.2., and module paths... but it only changed/fixed the Lua "package.path" variable, not "package.cpath" (this change).

So I can fix that, but I'm not sure it will be enough, because it won't add "clibs" because that's not a default directory, of either Lua or Wireshark. I don't know how this worked even before 1.11.3, unless CLRPackage.lua amended the cpath.

So some more questions: How did you get CLRPackage installed? Did you need to compile Wireshark from source code to use CLRPackage? Or did you need to install LuaRocks or some other package?

What are your Wireshark personal and global plugins directories named? Open Wireshark, go to Help->About Wireshark, and click on the Folders tab. It will list a personal and global plugins directories.

(02 Feb '15, 11:34) Hadriel

@Hadriel - Updated with more information, thanks for the help on this.

(02 Feb '15, 11:55) SwDevMan81

Well those plugin directories look normal, so I can't figure out why "CLRPackage.lua" was loaded at all to begin with, since it's not in one of those plugin directories. Are there any Lua files in those plugin directories? (even an "init.lua")

(02 Feb '15, 12:58) Hadriel

@Hadriel - If I navigate to the Personal Plugins and Global Plugins, there are no lua scripts in those folders.

(02 Feb '15, 13:37) SwDevMan81

Do you remember where you got the CLRPackage zip file? I googled but got various hits, none of which look like the definitive source.

(02 Feb '15, 13:57) Hadriel

@Hadriel - I downloaded it from here. Inside the zip file, its LuaInterface > LuaInterface > lua > CLRPackage.lua

(02 Feb '15, 14:08) SwDevMan81
showing 5 of 10 show 5 more comments

One Answer:

1

I doubt that Luainterface will work with Wireshark anymore, because it looks like it was compiled for Lua 5.0 and 5.1 compatibility, but not 5.2. But you can find out... to get past the current issue of not finding the "luanet.dll" file, put this in your init.lua file, at the end of the init.lua file:

package.cpath = DATA_DIR .. "\\clibs\\?.dll;" .. package.cpath

Hopefully that should make Wireshark's Lua find the luanet.dll file when it loads CLRPackage.lua, but again my guess is at that point you'll hit another problem because it's not compiled for Lua 5.2 compatibility. You might have to upgrade to the current fork of Luainterface, which appears to be NLua.

answered 02 Feb '15, 19:35

Hadriel's gravatar image

Hadriel
2.7k2939
accept rate: 18%

I think you are right. I also added package.path = DATA_DIR .. "\\lua\\?.lua;" .. package.path to init.lua to get it to not error on startup, but now it just hangs at 99% at Handing off plugins.... So I'm guessing its because of the Lua incompatibility you mentioned.

(03 Feb '15, 05:32) SwDevMan81

@Hadriel - I'm trying to build against Lua 5.2, but I'm having some porting issues. Is there any chance you could help with conversion. I tried NLua and it doesnt appear to support the stock Lua 5.2 source (I think theyve made modifications, which wont help when using the Lua thats built in Wireshark). The questions are here

(05 Feb '15, 11:13) SwDevMan81

Unfortunately I don't use Windows nor have a Windows system.

(12 Feb '15, 10:44) Hadriel

@Hadriel - No problem, I've actually got it to work now. I took the LuaInterface code and updated it for Lua 5.2 and compiled with VS 2010 targeting .NET 4.0 and Lua52.dll. I actually went back and built the LuaInterface for Lua 5.1 with VS 2010 targeting .NET 2.0 and Lua5.1.dll. I dont have a good place to host these but I could put them somewhere if you have a recommendation. Then I'll provide an answer to how to install like the previous question detailed. Thanks for the support on this, the answer you provided led me in the right direction.

(12 Feb '15, 11:18) SwDevMan81

@SwDevMan81 Hi could you elaborate on how you did it exactely so that we could try to build LuaInterface code and update it for Lua 5.2 as well? Thank you

(06 Mar '15, 05:40) smuellener