o-gs / dji-firmware-tools

Tools for handling firmwares of DJI products, with focus on quadcopters.
GNU General Public License v3.0
1.44k stars 404 forks source link

Lua version used for wireshark dissectors #153

Open pcabreracamara opened 4 years ago

pcabreracamara commented 4 years ago

Hi all,

After compiling wireshark with Lua 5.2.4, when wireshark/Lua is loading the plugins, it founds some errors related to local variable declarations at the beginning of each lua file:

Lua: Error during loading:
 .../wireshark/plugins/dji-dumlv1-general.lua:4: attempt to index global 'DJI_DUMLv1_PROTO' (a nil value)

The same error is repeated when tries to load "dji-dumlv1-camera.lua", "dji-dumlv1-flyc.lua" and "dji-dumlv1-gimbal.lua" files. I guess must be related to specific changes from Lua versions (local variables scope), but I don't know how to adapt the local variables declaration causing these errors:

local f = DJI_DUMLv1_PROTO.fields
local enums = {}

Could someone please let me know a working version of Lua for these dissectors ? Any help to avoid the "nil value" error would be appreciated.

I just fixed a minor error in the "dji-dumlv1-proto.lua" plugin, adding the absolute paths in the dofile commands (lines 489 to 492), to avoid the error: dofile: file does not exist.

Thank you very much, Pedro

mefistotelis commented 4 years ago

I'm using Wireshark 3.0.2, which has Lua 5.2.4 as well.

My init.lua is:


dofile('dji-dumlv1-proto.lua')

dofile('dji-p3-flyrec-proto.lua')
dofile('dji-p3-batt-proto.lua')
dofile('dji-p3.lua')

dofile('dji-mavic-flyrec-proto.lua')
dofile('dji-mavic.lua')

dofile('dji-spark-flyrec-proto.lua')
dofile('dji-spark.lua')

dofile('dji-write-kml.lua')

And in the same folder, I have symlinks to all the LUA files.

pcabreracamara commented 4 years ago

Thank you, I'm going to update wireshark as mine is version 2.6.4, I'll let you know if this was the cause.

pcabreracamara commented 4 years ago

Yep, moving lua files out of generic plugins folder and using your init.lua file in the personal configuration folder solved the issue, Thank you very much Mefistotelis.

mrlnc commented 2 years ago

Hi everybody! I had the same issue and still couldn't get it to run after reading this issue.

Wireshark seems to have changed behavior, executing any Lua files in the plugins directory or its subdirectories. So, the plugins directory must only include the init.lua file.

Further, dofile apparently requires absolute paths or that files are located in the current directory.

These are my steps to get the dissectors running

On macOS and Linux, the local plugin directory is here: ~/.local/lib/wireshark/plugins

For me, looks like this:

/Users/merlin/.local/lib/wireshark
├── dji
│   ├── dji-dumlv1-camera.lua
│   ├── dji-dumlv1-flyc.lua
│   ├── dji-dumlv1-general.lua
│   ├── dji-dumlv1-gimbal.lua
│   ├── dji-dumlv1-proto.lua
│   ├── dji-mavic-flyrec-proto.lua
│   ├── dji-mavic.lua
│   ├── dji-p3-batt-proto.lua
│   ├── dji-p3-flyrec-proto.lua
│   ├── dji-p3.lua
│   ├── dji-spark-flyrec-proto.lua
│   ├── dji-spark.lua
│   └── dji-write-kml.lua
└── plugins
    └── init.lua

And absolute paths in dofile:

~/.l/l/wireshark » grep -r dofile .
./plugins/init.lua:dofile('/Users/merlin/.local/lib/wireshark/dji/dji-dumlv1-proto.lua')
./plugins/init.lua:dofile('/Users/merlin/.local/lib/wireshark/dji/dji-p3-flyrec-proto.lua')
./plugins/init.lua:dofile('/Users/merlin/.local/lib/wireshark/dji/dji-p3-batt-proto.lua')
./plugins/init.lua:dofile('/Users/merlin/.local/lib/wireshark/dji/dji-p3.lua')
./plugins/init.lua:dofile('/Users/merlin/.local/lib/wireshark/dji/dji-mavic-flyrec-proto.lua')
./plugins/init.lua:dofile('/Users/merlin/.local/lib/wireshark/dji/dji-mavic.lua')
./plugins/init.lua:dofile('/Users/merlin/.local/lib/wireshark/dji/dji-spark-flyrec-proto.lua')
./plugins/init.lua:dofile('/Users/merlin/.local/lib/wireshark/dji/dji-spark.lua')
./plugins/init.lua:dofile('/Users/merlin/.local/lib/wireshark/dji/dji-write-kml.lua')
./dji/dji-dumlv1-proto.lua:dofile('/Users/merlin/.local/lib/wireshark/dji/dji-dumlv1-general.lua')
./dji/dji-dumlv1-proto.lua:dofile('/Users/merlin/.local/lib/wireshark/dji/dji-dumlv1-camera.lua')
./dji/dji-dumlv1-proto.lua:dofile('/Users/merlin/.local/lib/wireshark/dji/dji-dumlv1-flyc.lua')
./dji/dji-dumlv1-proto.lua:dofile('/Users/merlin/.local/lib/wireshark/dji/dji-dumlv1-gimbal.lua')

Hope this helps! @mefistotelis would be great if you could check, I can do a PR to update the docs, too!

mefistotelis commented 2 years ago

Thanks; I have not seen such issue yet, so no opinion.

whal-e3 commented 8 months ago

modification of @mrlnc 's solution half-worked on windows 11.

I changed every lines with dofile(). Both init.lua and dji-dumlv1-proto.lua.

To something like this... dofile('C:\\Users\\<user-name>\\AppData\\Roaming\\Wireshark\\dji\\dji-mavic.lua')

Now error message is gone. But still not getting parsed DUML packets... Can someone help with this?