Commit Graph

102 Commits

Author SHA1 Message Date
Gerald Combs 61dd06ed9f Lua: Switch from disable_lua to enable_lua.
Deprecate "disable_lua" in favor of "enable_lua". Configuration options
typically use "true" or a similar value to enable features. Using
"disable_lua = false" to enable Lua seems odd.

Change-Id: I224acad0559d409ea0a28b5555d1eb898564328c
Reviewed-on: https://code.wireshark.org/review/28773
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-07-20 06:42:38 +00:00
Guy Harris 8db1616ec3 Get rid of more autotoolsisms.
Change-Id: I124732adf3c3da511c206932544b4d533404cfc5
Reviewed-on: https://code.wireshark.org/review/27332
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-04 19:14:34 +00:00
Dario Lombardo 8cd389e161 replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.
The first is deprecated, as per https://spdx.org/licenses/.

Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed
Reviewed-on: https://code.wireshark.org/review/25661
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 14:57:36 +00:00
Gerald Combs f5a8711ef1 Qt: About dialog updates.
Open lua scripts when double-clicked. Behavior depends on your system
configuration. Add tooltips accordingly.

Let Qt wrap the "Wireshark" tab information.

Set column widths by eyeballing their contents.

Elide the Folders and Plugins strings in the middle.

Fixup placeholder text capitalization.

Draw links using the palette link color.

Change-Id: Ic141eae05541480ec1e254c55fd81728d04713d9
Reviewed-on: https://code.wireshark.org/review/25510
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-31 04:55:37 +00:00
Stig Bjørlykke c9b6887d84 wslua: Fix logger after g6a5e90f2
The Qt log output changes in g6a5e90f2 changed the Qt message handler
to use g_log.  Lua logging already used g_log.  The Qt variant of
funnel logger, which is used by Lua as g_log backend, is currently
using qDebug and this gives recursive calls to g_log and thus an assert.

Rewrite the lua logging to not use g_log.

Change-Id: Icf4f0022a11cb32d2b4f413f76d946f2506e283d
Reviewed-on: https://code.wireshark.org/review/24888
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-12-19 12:18:20 +00:00
João Valverde 6be572006e plugins: Add backward compatibility for personal lua scripts
Relax requirements for upgrades and make running side-by-side installations
more convenient.

Change-Id: I5299eed005a4748c54465dec90f477adb577e056
Reviewed-on: https://code.wireshark.org/review/23619
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2017-09-20 17:07:47 +00:00
João Valverde 8db4ddd40c Rename get_plugin_dir() for consistency
WS_DLL_PUBLIC const char *get_plugin_dir(void);
WS_DLL_PUBLIC const char *get_plugins_pers_dir(void);

Opt for the plural form consistently (for public functions at least).

Change-Id: I8a5861ad7f90f9c87168bd3275bd9dbc5c83b749
Reviewed-on: https://code.wireshark.org/review/23608
Petri-Dish: João Valverde <j@v6e.pt>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-09-20 01:00:37 +00:00
João Valverde 69f0cb0cef wsutil: Initialize and store plugin personal dir
Obviate allocation on every call to get_plugins_pers_dir().

Change-Id: I089ae499f93739d490d4552f59b5db5996f7d26f
Reviewed-on: https://code.wireshark.org/review/23495
Petri-Dish: João Valverde <j@v6e.pt>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: João Valverde <j@v6e.pt>
2017-09-11 16:48:49 +00:00
Guy Harris ae3fd56b20 Check for errors running the Lua scripts.
Also, fix error messages reported for lua_load() to speak of
precompilation, not execution (the script isn't *executed* until
lua_pcall() is called).

Change-Id: I7ac9ee6e5df7612f9af141e51958fbfad38a4083
Reviewed-on: https://code.wireshark.org/review/23023
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-08-08 21:03:25 +00:00
Peter Wu d5fdbef7f4 cmake,wslua,wsutil: load files from run/ instead of source tree
Fixes Lua on macOS, tested with an out-of-tree build:

    WS_BIN_PATH=$PWD/run ../wireshark/test/test.sh -s wslua

Previously programs that were ran from the build directory would load
data files (radius/, diameter/, init.lua) from the source directory.
Then in the case of Lua, files were loaded from the program directory
($BUILDDIR/run/init.lua on Linux) or source directory
(sSOURCEDIR/epan/wslua/console.lua).

On macOS, this does not work for Lua since files are installed into
$BUILDDIR/run/Wireshark.app/Contents/Resources/share/wireshark/init.lua
instead. Since CMake always copies data files (radius, console.lua,
etc.) into the build directory, make get_datafile_dir() return this
"run" directory instead.

Change-Id: If97d2f5686271caf9ad4d4e4fc58e902dc592a98
Reviewed-on: https://code.wireshark.org/review/19330
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-12-20 13:16:57 +00:00
Jeff Morriss 38682523f9 Lua: allow creating TVBs after calling other (Lua) dissectors.
Don't set `lua_tvb` (or any of the other global variables) to NULL after a
Lua dissector is called: it's possible that the caller is also a Lua dissector
which may want/need that (global) variable to still be set (to the value it
had before the sub-dissector was called).

This fixes the problem reported in:
https://ask.wireshark.org/questions/56110/lua-error-tvbs-can-only-be-created-and-used-in-dissectors

Making these variables not be a globals (as suggested at the top of
init_wslua.c) might be a better solution--for another day.

Change-Id: I14fb8ec35b62abeda3f3471a323b88c80537a06e
Reviewed-on: https://code.wireshark.org/review/18095
Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Peter Wu <peter@lekensteyn.nl>
2016-10-14 17:00:06 +00:00
João Valverde 917d34c4de Add PI_DEPRECATED expert info group
Change-Id: Ibc43b1976d5827e8c40252a5200852fbcd00b70c
Reviewed-on: https://code.wireshark.org/review/16763
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: João Valverde <j@v6e.pt>
2016-08-05 13:59:25 +00:00
Michael Mann 1da1f945e2 Fix checkAPI.pl warnings about printf
Many of the complaints from checkAPI.pl for use of printf are when its embedded
in an #ifdef and checkAPI isn't smart enough to figure that out.
The other (non-ifdef) use is dumping internal structures (which is a type of
debug functionality)
Add a "ws_debug_printf" macro for printf to pacify the warnings.

Change-Id: I63610e1adbbaf2feffb4ec9d4f817247d833f7fd
Reviewed-on: https://code.wireshark.org/review/16623
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-07-25 04:26:50 +00:00
Stig Bjørlykke 5112d1ec27 Lua: Fix add and remove Fields when reload Lua plugins
Reset wslua_dfilter and remove the Field tap_listener when
reloading plugins.

Check for tap listeners in rescan_packets() after ws_epan_new()
because Lua may register the Lua field tap when adding Fields.

Bug: 12328
Change-Id: Ibbd8339033132c6f3b61d7e9c9ced9ed2b9affec
Reviewed-on: https://code.wireshark.org/review/14871
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2016-04-11 17:59:11 +00:00
Peter Wu c82cbfdc72 wslua: Abort on out of memory
The current wslua code does not properly handle out of memory
conditions. Since recovering from OOM is difficult in many places, just
abort the program (which is done by g_realloc).

Change-Id: Idae68d08c90c82ba5df18a28cc1e507d61d20e78
Reviewed-on: https://code.wireshark.org/review/14786
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-04-10 21:51:14 +00:00
Peter Wu 4a37458c5d lua: fix reload with -Xlua_script
Use ex_opt_get_nth instead of ex_opt_get_next to avoid consuming the
parameters. This ensures that lua scripts via the "-Xlua_script"
parameter are also reloaded.

Change-Id: I316726cdf99f7ee3d738d3632a7f639ea8596f96
Reviewed-on: https://code.wireshark.org/review/14870
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-04-10 21:48:16 +00:00
Stig Bjørlykke 6f220a343e Lua: Remove heur dissectors when reload Lua plugins
When reloading Lua plugins all registered heuristic dissectors
must be removed.

Bug: 12251
Change-Id: Ib7da6df347fb9294f5394ae531b582bf6d2730bb
Reviewed-on: https://code.wireshark.org/review/14429
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2016-03-13 10:51:44 +00:00
Martin Kaiser ddcafa06df wslua: don't crash if disable_lua = true in init.lua
in wslua_init(), our lua instance L is set to NULL if
disable_lua is true in init.lua
make sure that we leave wslua_init() in this case

if we don't, we crash in lua_pop(L,1); with L==NULL

Program received signal SIGSEGV, Segmentation fault.
0x00007fffefb41a73 in lua_settop () from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
(gdb) bt
 #0  0x00007fffefb41a73 in lua_settop () from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
 #1  0x00007ffff4fb50e4 in wslua_init (cb=cb@entry=0x516f40 <splash_update(register_action_e, char const*, void*)>,
    client_data=client_data@entry=0x0) at init_wslua.c:900
 [...]

Bug:12196
Change-Id: Ic338c4edcb897c0eaa9b6755bbb6c9991ec6ed02
Reviewed-on: https://code.wireshark.org/review/14228
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2016-02-28 18:27:08 +00:00
Guy Harris e9b2859c45 Clean up modelines and indentation.
HT tab stops are set every 8 spaces on UN*X; UN*X tools that treat an HT
character as tabbing to 4-space tab stops, or that even are configurable
but *default* to 4-space tab stops (I'm looking at *you*, Xcode!) are
broken.  tab-width: 4, tabstop=4, and tabSize=4 are errors if you ever
expect anybody to look at your file with a UN*X tool, and every text
file will probably be looked at by a UN*X tool at some point, so Don't
Do That.

Adjust indentation to reflect the mode lines.

Change-Id: Icf0831717de10fc615971fa1cf75af2f1ea2d03d
Reviewed-on: https://code.wireshark.org/review/14150
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-25 21:34:36 +00:00
Stig Bjørlykke 6b9a628e54 Lua: remove unneeded todo comments
Change-Id: I2591a0f21092a251e6fc4393e97ae0594318dfdf
Reviewed-on: https://code.wireshark.org/review/10214
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2015-08-23 18:38:13 +00:00
Stig Bjørlykke bde416afcc Lua: Moved deregister out of wslua_cleanup
Change-Id: Ia43aa0e5f09400ef9923288b362256094a1241b8
Reviewed-on: https://code.wireshark.org/review/9998
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2015-08-12 13:23:07 +00:00
Stig Bjørlykke f1a4db34b3 Lua: Remove unneeded call in wslua_cleanup
Change-Id: I0cda00001b40e5951d680d72dbc8043cbe8b9309
Reviewed-on: https://code.wireshark.org/review/9980
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2015-08-11 20:06:36 +00:00
Stig Bjørlykke ecc4f756bd Added Reload Lua plugins.
This is initial support for reloading Lua plugins without
restarting the application.

Still todo:
- Deregister FileHandlers
- Support deregister ProtoField with existing abbrev (same_name_hfinfo)
- Add a progress dialog when reloading many plugins
- Search for memory leakages in wslua functions

Change-Id: I48870d8741251705ca15ffe1068613fcb0cb18c1
Reviewed-on: https://code.wireshark.org/review/5028
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2015-08-11 12:09:07 +00:00
Hadriel Kaplan 23163520ad Lua: add plugin version info
Expose a "set_plugin_info" global function to set the Lua plugin's
version information. Also, put info about Lua scripts loaded from
the command-line into the help output, not just for scripts loaded
from plugin direvtories.

Bug: 11315
Change-Id: I8bc425ed1ed0dfdc1d05178754f44d44e0b209b5
Reviewed-on: https://code.wireshark.org/review/9593
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-07-23 09:22:44 +00:00
Hadriel Kaplan 281055af9c Lua: add functions for more field information
Add Lua functions so a plugin can introspect field information, such
as the type of field, flags, tvb, etc. Also add a couple of Tvb and
ByteArray methods. And cleanup the TreeItem code a little.

Change-Id: I7b58ce589ace91cce14b8abccd01ceabb63e2653
Reviewed-on: https://code.wireshark.org/review/6500
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Hadriel Kaplan <hadrielk@yahoo.com>
2015-07-09 01:49:11 +00:00
Hadriel Kaplan dd8311d2ed Lua: split init/cleanup routines
The epan init routines have been split up into init vs. cleanup, where the
init routines are only invoked when a file is opened, and the cleanup ones are
invoked multiple times, such as on a re-scan of packets.

Since the Lua API's Proto.init() callback is supposed to be invoked at both
init and cleanup times, the wslua code now invokes it in both of epan's init
and cleanup routines.

Change-Id: I51a4d8bc02630a4d2db5408c37f7eb8f6e0ce88c
Reviewed-on: https://code.wireshark.org/review/9491
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Hadriel Kaplan <hadrielk@yahoo.com>
2015-07-04 05:26:27 +00:00
Balint Reczey e187b5396e Don't try to clean up uninitialized Lua and crash
Reported to Debian BTS at:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=786704

Change-Id: I3045a68f0dd557bf64ea26a488a1bcece4828fec
Reviewed-on: https://code.wireshark.org/review/8765
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Balint Reczey <balint@balintreczey.hu>
2015-06-09 04:18:48 +00:00
Gerald Combs b255d8a1a1 CMake: Update wslua build and test.
Process wslua/CMakeLists.txt using add_subdirectory instead of
include. Generate files in the build directory instead of the source
directory.

Copy lua scripts to DATAFILE_DIR instead of DATAFILE_DIR/lua. That's
where init.lua looks for console.lua.

Always set WIRESHARK_RUN_FROM_BUILD_DIRECTORY when testing. We
presumably want to test our source files and not files which may or
may not be in the system path.

When we're running from the build directory look for lua scripts in both
the Autotools and CMake build locations.

Change-Id: Ic15ab8c58ff1b170d000c9b3e0a329af2ec44b7b
Reviewed-on: https://code.wireshark.org/review/7590
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-03-12 16:37:51 +00:00
Hadriel Kaplan ceb8d954d2 Lua: Expose tcp_dissect_pdus() to Lua
Provide a way for Lua-based dissectors to invoke tcp_dissect_pdus()
to make TCP-based dissection easier.

Bug: 9851
Change-Id: I91630ebf1f1fc1964118b6750cc34238e18a8ad3
Reviewed-on: https://code.wireshark.org/review/6778
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Hadriel Kaplan <hadrielk@yahoo.com>
2015-01-27 15:14:12 +00:00
Hadriel Kaplan aec1bcf9a1 Lua can free tvbuffs too early
Lua-created tvbuffs should be kept around for the duration of pinfo's
lifetime, instead of only for the duration of frame dissection. So
instead of using the frame dissector's frame_end_routine, we'll register
a callback to wmem for pinfo pool's allocator.

Bug: 10888
Change-Id: I3e9db671c3f2a7cab9e258aca17f3be8acaf2417
Reviewed-on: https://code.wireshark.org/review/6768
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Hadriel Kaplan <hadrielk@yahoo.com>
2015-01-25 19:11:01 +00:00
Hadriel Kaplan 7c9d6ff73a Lua: replace proto_tree_add_text calls
Replace proto_tree_add_text() calls in Lua API code, to use Lua-specific hfinfo items.

Bug: 10828
Change-Id: I9b5899106502a9bdbc748b5ec0f27b787d374562
Reviewed-on: https://code.wireshark.org/review/6296
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2015-01-04 09:07:02 +00:00
Hadriel Kaplan d7c3edd39c Lua: replace deprecated functions
Remove deprecated functions from Lua API code: tvb_length and
tvb_length_remaining. The calls to proto_tree_add_text() are
left in, as I have no idea what to replace them with. The calls
to ep_* are being left in, as they're removed by change-id
I3d19a770e0fd77d996bdb6b61a76a722cc2bcd55.

Bug: 10822
Change-Id: Ib0686f90be1edc892d3ecf401b91eb7484540b3e
Reviewed-on: https://code.wireshark.org/review/6247
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-01-03 13:18:17 +00:00
Hadriel Kaplan f7b6dcc58c Lua: allow a Dissector object to be passed in for register_heuristic
Bug: 10695
Change-Id: I81181b2d00fcb5f0c25ab89bbe4968897f47a3a6
Reviewed-on: https://code.wireshark.org/review/6131
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-12-31 16:01:51 +00:00
Hadriel Kaplan 2391a436e6 Bug 10233 - Wireshark crashes if Lua heuristic dissector returns true
Because call_heur_dissector_direct() didn't set the pinfo->heur_list_name
before calling the heuristic dissector, heur_dissect_lua() would invoke
report_failure().  Unfortunately, calling report_failure() within a dissector
can cause problems because GTK continues invoking timed callbacks while
it displays the modal dialog created by report_failure()... without yet
returning from report_failure().  In such a case, it's possible for
epan_dissect_run() to be called while still within the execution of a
previous call to epan_dissect_run(), which casues an assert since
epan_dissect_run() is not reentrant.

So this commit both fixes the call_heur_dissector_direct() bug as well
as avoids using report_failure() within heur_dissect_lua().  It also
upadtes the dissector.lua script used in the testsuite to match the one
pubshied on the wiki, since that script's heuristic dissector triggered
the bug.

Bug: 10233
Change-Id: If022604347745fadac01c02d370ca1a5d3f88b5b
Reviewed-on: https://code.wireshark.org/review/6040
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Hadriel Kaplan <hadrielk@yahoo.com>
2014-12-25 15:13:56 +00:00
Hadriel Kaplan f3fe29f0fc Add paths to Lua package.path so require works for user scripts
This adds the global and personal plugins directories to the
package.path setting in Lua, so doing 'require' will work
properly.

Change-Id: Iec33bc60cd7d41aa122da456db91d4ccc3085f82
Reviewed-on: https://code.wireshark.org/review/841
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-27 05:03:39 +00:00
Hadriel Kaplan 8c2bb80574 Add various functions for Lua directory handling and path info
This adds new functions to get plugins path info, find out if a directory
exists, make a new one, remove one, etc. It also creates a file environment
for user-supplied Lua scripts, to prevent global variable contamination as
well as supply the script-specific file name.  Some other minor cleanup was
done as I found them.

A new testsuite was added to test the existing and new directory functions.

Change-Id: I19bd587b5e8a73d89b8521af73670e023314fb33
Reviewed-on: https://code.wireshark.org/review/832
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-26 07:37:34 +00:00
Hadriel Kaplan da1af6e549 Add filterable expert info for Lua
This adds the ability for a Lua script to register expert info fields,
similar to C-code dissectors. This change also removes the need for
the expert_add_info_format_internal() function. Existing Lua scripts
do not have to change, because the existing expert info function
uses the internal "_ws.lua" protocol instead of nothing; but using
the new functionality provides more benefits since it correctly
registers the expert info fields to the dissector's protocol.

The test suite was amended to generate both old and new forms.

Change-Id: Ib5ae74e927cfa81312baf7b04ff4104b0b4f936e
Reviewed-on: https://code.wireshark.org/review/830
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-26 05:20:17 +00:00
Hadriel Kaplan 04c39bb097 Add Lua heuristic dissector support
This adds the ability for Lua scripts to register heuristic dissectors
for any protocol that has registered a heuristic dissector list, such
as UDP, TCP, and ~50 others. The Lua function can also establish a
conversation tied to its Proto dissector, to avoid having to check the
heuristics for the same flow. The example dissector in the testsuite
has also been enhanced to include a heuristic dissector, to verify
the functionality and provide an example implementation.

Change-Id: Ie232602779f43d3418fe8db09c61d5fc0b59597a
Reviewed-on: https://code.wireshark.org/review/576
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-14 07:29:15 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Hadriel Kaplan c826191be0 Fix coverity warnings for all wslua files. (redux)
This fixes/addresses all the coverity warnings shown by
the buildbots. (I hope)

Change-Id: Ic2722df97c577d274e3cf3f0cbdca1902edde047
Reviewed-on: https://code.wireshark.org/review/423
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-02-27 21:23:09 +00:00
Hadriel Kaplan 58fe488822 Lua: add ability for scripts loaded from command-line to be passed arguments
This change adds the ability to pass on to lua scripts loaded from the
command-line (tshark or wireshark) additional arguments supplied by the
command-line.  This will help us in our testsuites, but also might be
useful for user-created scripts.  The additional arguments are passed in
using the '-X' eXtension switch.

Change-Id: Ib94cdf1ffd194ca84692fee7816665e4ff95efbd
Reviewed-on: https://code.wireshark.org/review/156
Reviewed-by: Evan Huus <eapache@gmail.com>
Tested-by: Evan Huus <eapache@gmail.com>
2014-02-13 22:32:58 +00:00
Hadriel Kaplan 3d59ff9e95 Fix for Bug-9711 Lua: the Lua stack is growing slightly during initialization.
Change-Id: I689319c0071fdb42583e8bd7633d8f0660c92f1b
Reviewed-on: https://code.wireshark.org/review/51
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-01-31 16:31:59 +00:00
Stig Bjørlykke 436fe9c85e Lua: Improved running in build directory.
Load system init.lua from build-directory/epan/wslua
Set Lua datafile_path to source-directory/epan/wslua
Made dofile() search in source-directory/epan/wslua

Change-Id: I009234eb8193c1ed3260455b245c256c9747930f
2014-01-30 07:53:18 +00:00
Guy Harris 834c79a07e Don't cast away constness.
svn path=/trunk/; revision=54796
2014-01-14 18:12:14 +00:00
Stig Bjørlykke 74394f2cf7 Added expired handling to FieldInfo.
This avoids using free'd pointers (which leads to crash) when
assigning FieldInfos to global variables.

svn path=/trunk/; revision=54623
2014-01-07 14:46:17 +00:00
Guy Harris 0cc1545d05 Move most of the plugin code from epan to wsutil and remove all
knowledge of particular types of plugins.  Instead, let particular types
of plugins register with the common plugin code, giving a name and a
routine to recognize that type of plugin.

In particular applications, only process the relevant plugin types.

Add a Makefile.common to the codecs directory.

svn path=/trunk/; revision=53710
2013-12-02 08:30:29 +00:00
Michael Mann 79d58dc670 Add Lua cleanup on shutdown, to help with memory leak detection. Bug 5575 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5575)
From Robert G. Jakabosky

From me: cleanup so that it applies to trunk.

svn path=/trunk/; revision=52798
2013-10-23 16:47:02 +00:00
Michael Mann 9ccefb0ecd Prefix all "Wireshark application specific" display filters with a "_ws." to distinguish them from dissector filters.
This was committed now to get it into the 1.11 release so users can start getting used to the changed filter names.

svn path=/trunk/; revision=52462
2013-10-09 12:56:19 +00:00
Michael Mann 1b009df749 Couldn't quite figure out how to make the expert items in proto.c and the LUA API filterable (suggestions welcome!), but I wanted to start forcing dissectors to use the filterable expert API (nothing like compile errors to force change!). I created expert_add_info_format_internal (original expert_add_info_format) and used it as a placeholder for proto.c/LUA API until a solution is created. The "new" expert_add_info_format will be the "old" expert_add_info_format_text, and I'll slowly do the search/replace.
For those with dissectors outside the source tree, please see tools/convert_expert_add_info_format.pl for help with the conversion.  Please do not use expert_add_info_format_internal, as it's support time will be very short lived.

svn path=/trunk/; revision=51844
2013-09-08 19:32:10 +00:00
Stig Bjørlykke 7d3d67407c Added support for a "prefs_change" function in Lua scripts, which is called
when the preferences for the dissector are changed.

This is not a 100% correct implementation at the time because the
prefs_changed function in all Lua plugins will be called whenever
a preference in a single Lua plugin is changed.

svn path=/trunk/; revision=51818
2013-09-07 11:27:38 +00:00