Commit Graph

25 Commits

Author SHA1 Message Date
Daniel Dulaney 62af671bf3 Lua: add DissectorTable.try_heuristics() function
Add DissectorTable.try_heuristics(name, tvb, pinfo, tree). Previously,
there was no way for a Lua plugin to run an existing heuristic
dissector.

Based on Gerrit change 18718. Closes #17220.
2021-03-26 07:15:16 +00:00
Stig Bjørlykke ebfa1f8a4b wslua: Return nil from Dissector.get() when not found
Return nil from Dissector.get() and DissectorTable.get() when the
reference is not found. This can be used to check for existence of
a dissector or dissector table before use.

We already do this for DissectorTable.get_dissector().
2020-11-05 06:23:24 +00:00
Gerald Combs 87be7fa23c wslua: Update the dissector docs.
Add content from https://wiki.wireshark.org/LuaAPI/Dissector,
https://wiki.wireshark.org/LuaAPI/Pref, and
https://wiki.wireshark.org/LuaAPI/Proto. Update as needed.

Change-Id: I74a167feb9db0fcdb723501e4692da020db1ab2c
Reviewed-on: https://code.wireshark.org/review/36629
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-03-30 08:55:19 +00:00
Guy Harris 20800366dd HTTPS (almost) everywhere.
Change all wireshark.org URLs to use https.

Fix some broken links while we're at it.

Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c
Reviewed-on: https://code.wireshark.org/review/34089
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-26 18:44:40 +00:00
Peter Wu a80b4fdd40 Lua: remove lua_data_handle
Use call_data_dissector directly for the same effect as lua_data_handle.

Remove the special case where DissectorTable.get_dissector() returns the
data dissector for an unsupported type. The documentation says that nil
is returned if the handle is not found, that seems more appropriate.

Change-Id: I128ef90b79bda925a4329202a0b9956e1cf16200
Reviewed-on: https://code.wireshark.org/review/34032
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
2019-07-21 17:00:18 +00:00
Martin Kaiser bfad6f03d6 wslua: add a Proto parameter to DissectorTable.new()
Add an optional paramter of type Proto to DissectorTable.new().
If the caller provides a Proto, we can get the protocol id and
use it when we register the dissector table.

Change-Id: I3ab0819c41fa97288ec962d8d495b63d4750ce4b
Reviewed-on: https://code.wireshark.org/review/33608
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-06-16 02:39:18 +00:00
Martin Kaiser 13795914a1 wslua: clean up DissectorTable_new()
Reorder the code to have a single return statement at the end.
Take advantage of the fact that WSLUA_OPTARG_ERROR terminates
the C function that called it.

Do only the parameter checks in the switch-case statement.

Get rid of the intermediate steps when we copy name and ui_name.

Change-Id: Ie8917d19589a6ee16a4a5d14f2c1711d35cc8114
Reviewed-on: https://code.wireshark.org/review/33607
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-06-16 02:15:05 +00:00
Martin Kaiser bf8bc8e007 wslua: add support for ft_none dissector tables
The C code introduced ft_none dissector tables some time ago. They have
no indicator to select the next protocol, only Decode As is supported
for them.

Allow lua code to create ft_none dissector tables as well. The patch
is trying to make as few changes as possible to DissectorTable_new().

Change-Id: Ie3ff58f092e6922ab7878d202c7484a64b2430a3
Reviewed-on: https://code.wireshark.org/review/33588
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-06-14 13:39:27 +00:00
Martin Kaiser a3481933f9 wslua: fix error handling for invalid dissector table
Calling DissectorTables's try method for a dissector table of an unknown
type crashes Wireshark.

local dt = DissectorTable.get("iso14443.subdissector")
dt:try(0, tvbuf, pinfo, tree)

causes a segmentation fault

Thread 1 "wireshark" received signal SIGSEGV, Segmentation fault.
except_pop () at /media/sf_wireshark.git/epan/except.c:264
264       set_top(top->except_down);
(gdb) print top
$1 = (struct except_stacknode *) 0x2
(gdb) bt
    at /media/sf_wireshark.git/epan/packet.c:590

My gut feeling (I haven't verified this) is that we should not call luaL_error()
inside a TRY-CATCH block. DissectorTable_try does this when the type of the
dissector table is not supported.

Fall back to the data dissector in this case and bring up an expert info
instead of aborting the dissection completely.

Change-Id: I9a49f738a99b2618014f41050d8c0bf6bfbb4138
Reviewed-on: https://code.wireshark.org/review/33357
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-05-26 13:08:38 +00:00
Martin Kaiser 0ab91dd96a wslua: print the correct type for FT_NONE dissector tables
We added FT_NONE dissector tables a while ago. These tables can only be
used for Decode As. Support such dissector tables in lua's print() function.

print(DissectorTable.get("iso14443.subdissector"))

will now print

DissectorTable iso14443.subdissector only for Decode As:

Change-Id: I9f5a2f6d6b1edb2a53ca1d2c0ae158c16fddf05f
Reviewed-on: https://code.wireshark.org/review/33356
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-05-26 06:32:58 +00:00
Gerald Combs 5a674d05c9 wslua: Convert more comment markup to Asciidoctor.
Convert links, source code blocks, and admonitions.

Change-Id: I50c8daa19a115c23f7501b91dbfd904779a609c9
Reviewed-on: https://code.wireshark.org/review/25720
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-02-11 17:12:52 +00:00
Dario Lombardo ff6e2fbb1b wslua: use SPDX identifiers.
Change-Id: I80d9d4e3ffc25eebf09e6ef693c378b77554e1b8
Reviewed-on: https://code.wireshark.org/review/25693
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-09 12:31:21 +00:00
Peter Wu f3ba318e09 Lua: fix crash on invalid Dissector.list("food") invocation
The Dissector.list, Listener.list and Field.list functions do not accept
a parameter. Passing one however results in a crash because the first
element is not the expected table, but the first function parameter.

Change-Id: I8483d0aa20716045472f30f5b41a449bed549b05
Reviewed-on: https://code.wireshark.org/review/23209
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2017-08-27 13:45:09 +00:00
Michael Mann 6a6d7ea34f Convert range API to always use wmem memory.
This is mostly to address memory leaks in range preferences (the biggest
user of range functionality) on shutdown.
Now range preferences must use epan scoped memory when referencing
internal preference structures to keep consistency.

Change-Id: Idc644f59b5b42fa1d46891542b53ff13ea754157
Reviewed-on: https://code.wireshark.org/review/19387
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-01-07 00:44:10 +00:00
Guy Harris a4c8ebc18b Don't do any Decode As stuff for dissector tables not used with Decode As.
Have all dissector tables have a "supports Decode As" flag, which
defaults to FALSE, and which is set to TRUE if a register_decode_as()
refers to it.

When adding a dissector to a dissector table with a given key, only add
it for Decode As if the dissector table supports it.

For non-FT_STRING dissector tables, always check for multiple entries
for the same protocol with different dissectors, and report an error if
we found them.

This means there's no need for the creator of a dissector table to
specify whether duplicates of that sort should be allowed - we always do
the check when registering something for "Decode As" (in a non-FT_STRING
dissector table), and just don't bother registering anything for "Decode
As" if the dissector table doesn't support "Decode As", so there's no
check done for those dissector tables.

Change-Id: I4a1fdea3bddc2af27a65cfbca23edc99b26c0eed
Reviewed-on: https://code.wireshark.org/review/17402
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-31 00:08:01 +00:00
Peter Wu f6e223c895 wslua: Drop unused "push_code" macro parameter
Reduce noise, no caller has used this parameter since its introduction.
Msotly automated regex search and replace.

Change-Id: I4b1180bfee8544b38d19c9c440ff5b9b0dc080b2
Reviewed-on: https://code.wireshark.org/review/14790
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-06-14 18:32:51 +00:00
Joerg Mayer 7e5dae90d6 Fix warnings/errors of type -Wused-but-marked-unused
Change-Id: I34c2d9953272822da0745d1b24c64d8466e43b37
Reviewed-on: https://code.wireshark.org/review/14668
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
2016-03-28 13:27:52 +00:00
Michael Mann e37275bfde Associate dissector tables and heuristic subdissector lists with a protocol.
This will make it easier to determine protocol dependencies.

Some LLC OUI dissector tables didn't have an associated protocol, so they were left without one (-1 used)

Change-Id: I6339f16476510ef3f393d6fb5d8946419bfb4b7d
Reviewed-on: https://code.wireshark.org/review/14446
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-03-17 00:05:17 +00:00
Stig Bjørlykke 0ae6a19f7d Revert "Lua: Remove WSLUA_ERROR on dissecting error"
This reverts commit 0f2a0e83fb.

Change-Id: Ifc40f99385a5948a033bb611b4ce8a0fa615b333
Reviewed-on: https://code.wireshark.org/review/13837
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2016-02-08 21:59:55 +00:00
Stig Bjørlykke 0f2a0e83fb Lua: Remove WSLUA_ERROR on dissecting error
On error in Dissector_call and DissectorTable_try we should not
terminate with WSLUA_ERROR because the error is already reported
in the tree with show_exception().

Change-Id: I60739f12cb8b16fe2270f47701286fd0dbf04c6f
Reviewed-on: https://code.wireshark.org/review/13819
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-02-08 16:54:34 +00:00
Michael Mann 1474f49f19 new_register_dissector -> register_dissector for remaining uses.
Mostly plugins, but also LUA and generated skinny dissector.

Change-Id: Ifeb4205442f9a60875266b4e82841ff38b4fdb63
Reviewed-on: https://code.wireshark.org/review/12515
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-12-11 03:42:37 +00:00
Michael Mann 74541a9596 Don't allow multiple registrations of a protocol in dissector tables.
The target here is the Decode As dialog where protocols have multiple registrations into a dissector table and that shows up as multiple entries in the Decode As dialog list with the same name so users are unsure which "dissector" they are choosing.

The "default" behavior (done in this commit) is to not allow duplicates for a dissector table, whether its part of Decode As or not.  It's just ENFORCED for Decode As.

Bug: 3949
Change-Id: Ibe14fa61aaeca0881f9cc39b78799e314b5e8127
Reviewed-on: https://code.wireshark.org/review/11405
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-04 12:39:40 +00:00
Gerald Combs 6d10efc6dd Qt: Add the Dissector Tables dialog.
Add the "Internals" menu under the View menu instead of at the top level
for now at least. Add the Dissector Tables dialog there.

Change-Id: Ieb23b0015591bac196e4ef94e3443832288333f9
Reviewed-on: https://code.wireshark.org/review/10654
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-09-27 16:19:05 +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 0caf0616ba Lua: split up wslua files into class-based files
The size of some of the wslua source files has grown large, and it's hard
to quickly find things. So split them up based on class name, as much as
seems reasonable. Also have the make-wsluarm.pl Perl script handle this.

Change-Id: Ib495ec5c2a4df90495c0a05504856288a0b09213
Reviewed-on: https://code.wireshark.org/review/9579
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
2015-07-12 02:08:24 +00:00