Lua Script (if condition judgement) is invalid
I just have next script in next,
tox_flag_frag = 0
tox_flag_reliablesn = 1
tox_flag_life = 0
I expect cmdindex = 14, but finally cmdindex is 26 , not sure why (tox_flag_frag > 0) judgement is invalid?
cmdindex = 10
if (tox_flag_frag > 0) then
cmdindex = cmdindex + 12
end
if (tox_flag_reliablesn > 0) then
cmdindex = cmdindex + 4
end
if (tox_flag_life > 0) then
cmdindex = cmdindex + 4
end
Comments
Can you update the question with output of
wireshark -v
orHelp->About Wireshark:Wireshark
.Output below from
Tools->Lua->Evaluate
with version 4.0.3.My labtop is Mac,
next is output of Help->About Wireshark:Wireshark.
==============================================
Version 3.6.7 (v3.6.7-0-g4a304d7ec222) Copyright 1998-2022 Gerald Combs [email protected] and contributors. License GPLv2+: GNU GPL version 2 or later https://www.gnu.org/licenses/gpl-2.0.htmlThis is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiled (64-bit) using Clang 13.0.0 (clang-1300.0.29.30), with Qt 5.15.3, with libpcap, without POSIX capabilities, with GLib 2.68.4, with zlib 1.2.11, with Lua 5.2.4, with GnuTLS 3.6.15 and PKCS #11 support, with Gcrypt 1.8.7, with MIT Kerberos, with MaxMind DB resolver, with nghttp2 1.46.0, with brotli, with LZ4, with Zstandard, with Snappy, with libxml2 2.9.9, with libsmi 0.4.8, with QtMultimedia, with ... (more)
Is it possible the flags are not being reinitialized on successive passes through the code?
here is more code with flag variable initialization, and also I use debug_func to dump flag variable and cmdindex,
the flag variable is expected as next :
tox_flag_frag = 0
tox_flag_reliablesn = 1
tox_flag_life = 0
but the cmdindex is 22 when debug_func(299, tox_flag_reliablesn, tox_flag_life, tox_flag_frag, cmdindex), this is unexpected...
Don't understand why this happen...
================================================
(more)What is the value of
curindex
and what is the value oftox_flag
after this call:The
tvb()
offset field is 0-based, so perhaps you're off by 1? From https://www.wireshark.org/docs/wsdg_h...: