Commit Graph

43 Commits

Author SHA1 Message Date
Moshe Kaplan f413260df9 WSLUA: Add new lua function register_packet_menu()
This adds support to Wireshark for custom context menus for packets, so
that when a packet's context menu is opened (e.g., by right-clicking),
Wireshark can support doing things like "run a program" or
"open a URL" with a field from the packet as a parameter. Note that
this is similar to ArcSight's integration commands feature.

For example, it could be used like the following:

```
ROBTEX_URL = "https://www.robtex.com/dns-lookup/"
local function search_robtex(...)
    local fields = {...};

    for i, field in ipairs( fields ) do
        if (field.name == 'http.host') then
            browser_open_url(ROBTEX_URL .. field.value)
            break
        end
    end
end
register_packet_menu("Search host in Robtex", search_robtex, "http.host");
```

Fixes issue #14998
2022-12-07 18:47:14 +00:00
Moshe Kaplan 1c3a9af869 Add files with WS_DLL_PUBLIC to Doxygen
Add @file markers for most files that
contain functions exported with
WS_DLL_PUBLIC so that Doxygen will
generate documentation for them.
2021-11-29 21:27:45 +00:00
Gerald Combs 6ee1390b86 Qt: Make Lua dialogs children of the main window.
Pass the funnel operations ID to new_text_window and new_dialog so that
we can assign parent widgets when we create new FunnelTextDialogs and
FunnelStringDialog. This should ensure that they're destroyed properly.
Ping #17590.
2021-11-15 20:03:16 +00:00
Developer Alexander 69fb2a17e4 lua: dialog with prefilled values
new_dialog() lua api gets extended to enable that dialog fields can be
prefilled by lua scripts instead of always starting empty.
2021-07-13 06:52:55 +00:00
Stig Bjørlykke 553e9e83d2 Lua: Add redissect_packets()
Add Lua function redissect_packets() to redissect packets in live
capture. The use case is to reload packets after a preference change.
2021-06-21 09:52:46 +02:00
João Valverde ff9acff6f2 Replace usage of GLogLevel flags everywhere
ws_log_domains.h needs to be included before wslog.h to be used
to define WS_LOG_DOMAIN. Also the definition for enum ws_log_level
needs to be exported for other APIs so move that to ws_log_domains.h
and rename the file to ws_log_defs.h to reflect the new scope.
2021-06-17 12:00:10 +01:00
Moshe Kaplan c7e89940b5 funnel: Remove unused typedefs
Remove typedefs `funnel_tree_window_t`,
`funnel_node_t`, and `funnel_progress_window_t`
as none of them are used.
2020-12-30 11:02:41 +00:00
rbroker 1f75d7b3b9 wslua: Add ability to query current temporary color filter text
The LUA API provides the "set_color_filter_slot" function, but without
a corresponding "get_" function, it's very hard for two LUA dissectors
to co-exist without one overwriting any color filters set by the other.

It also looks like the documentation comment for
"set_color_filter_slot" had an off-by-one error, which I've corrected
as I was adding almost identical documentation for the new API.

Change-Id: Ic54d23be555ec12e1830bbe6f84a1b04d04fd4f0
Reviewed-on: https://code.wireshark.org/review/37511
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-06-25 08:02:27 +00:00
Stig Bjørlykke 499d912f4b funnel: Free callback data
Free allocated callback data in FunnelStringDialog, TextWindow and
registered menu items. Also free strings used in FunnelStringDialog.

Bug: 16177
Change-Id: I9a129b8975a55d1dc89fe851116feebe82763bca
Reviewed-on: https://code.wireshark.org/review/34945
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-11-05 15:21:30 +00:00
Stig Bjørlykke 6cab8c57bd funnel: Fix memleaks in funnel_remove_menu
The loop to remove all matching callbacks was skipping every second
entry which would give some leaks when reloading Lua plugins.

Add funnel_cleanup() to be called in epan_cleanup() at shutdown
to remove all allocated menu entries.

Change-Id: I3a50ba2070c8675fee1385f25e9e109db57c2dc5
Reviewed-on: https://code.wireshark.org/review/31769
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2019-01-28 10:57:30 +00:00
Dario Lombardo 55c68ee69c epan: use SPDX indentifiers.
Skipping dissectors dir for now.

Change-Id: I717b66bfbc7cc81b83f8c2cbc011fcad643796aa
Reviewed-on: https://code.wireshark.org/review/25694
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 19:29:45 +00:00
Stig Bjørlykke ebdaace002 Lua: Added reload_lua_plugins
This makes it possible to trigger reloading Lua plugins from
within a Lua plugin.  This can be used when having a plugin to
update local plugins from a external source.

Renamed reload() to reload_packets() to clarify what's reloaded,
and added a alias (marked as obsoleted) from reload().

Change-Id: I4e529992af5f651613950329e73718dbda317d2e
Reviewed-on: https://code.wireshark.org/review/13024
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-01-11 07:43:36 +00:00
Stig Bjørlykke 2fd168c134 epan: Don't export deregister functions
Most of the deregister functions are used internally from Lua
while reloading plugins.  Don't export them for others to use.

Change-Id: I919dbfa807f696c38d409ca7206104a0fba1ae65
Reviewed-on: https://code.wireshark.org/review/12508
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2015-12-11 08:35:11 +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
Gerald Combs e91ca72a44 Qt: Add initial Lua support.
Add a FunnelStatistics class, which is the main interface between the Qt
UI and the Funnel API.

Add FunnelTextDialog, which implements the text_window, ProgDlg, menu,
and other routines. Add FunnelStringDialog, which implements dlg_new.

We currently only support "Tools" menu items (MENU_TOOLS_UNSORTED, aka
REGISTER_TOOLS_GROUP_UNSORTED). Add a disabled placeholder to the
"Tools" menu in case we don't load any scripts.

Use "struct progdlg" instead of needlessly casting to
funnel_progress_window_t.

To do:
- Add support for MENU_STAT_UNSORTED, MENU_STAT_GENERIC, etc.
- Make the firewall config generator a Lua script?
- Add FunnelGraphDialog? It seems like it would be useful to
  make QCustomPlot accessible to Lua scripts.

Ping-Bug: 9845
Change-Id: Iefff02e9032ed1853666f7902509ed08b431e7a7
Reviewed-on: https://code.wireshark.org/review/9523
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-07-07 20:49:30 +00:00
Guy Harris cfcbb28671 Clean up ftype-conversion and dfilter error message string handling.
Have dfilter_compile() take an additional gchar ** argument, pointing to
a gchar * item that, on error, gets set to point to a g_malloc()ed error
string.  That removes one bit of global state from the display filter
parser, and doesn't impose a fixed limit on the error message strings.

Have fvalue_from_string() and fvalue_from_unparsed() take a gchar **
argument, pointer to a gchar * item, rather than an error-reporting
function, and set the gchar * item to point to a g_malloc()ed error
string on an error.

Allow either gchar ** argument to be null; if the argument is null, no
error message is allocated or provided.

Change-Id: Ibd36b8aaa9bf4234aa6efa1e7fb95f7037493b4c
Reviewed-on: https://code.wireshark.org/review/6608
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-18 10:22:59 +00:00
Guy Harris 1c297771c3 Rename and move ui/stat_menu.h to epan/stat_groups.h.
The groups are, technically, independent of the notion of a menu, and,
if we have mechanisms by which taps that are not only GUI
toolkit-independent but independent of the *existence* of a GUI can be
registered, they might want to register themselves in a group just in
case they're running in a program that has a GUI.

Also, this might fix the Debian package build.

Change-Id: I29435681e79748fd4f2e0c5ac872cd11f831d172
Reviewed-on: https://code.wireshark.org/review/2830
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-03 20:30:42 +00:00
Guy Harris 5e28386540 Move stat_menu.h to libui.
Change-Id: I7bed7f7931845bc41035535cc62e1fe17c71047d
Reviewed-on: https://code.wireshark.org/review/2726
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-06-30 21:37:34 +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
Balint Reczey 1ebdb2e521 Export libwireshark symbols using WS_DLL_PUBLIC define
Also remove old WS_VAR_IMPORT define and related Makefile magic
everywhere in the project.

svn path=/trunk/; revision=47992
2013-03-01 23:53:11 +00:00
Jeff Morriss 300eb81514 Fix up some indentation and trailing white space.
svn path=/trunk/; revision=45009
2012-09-19 19:34:17 +00:00
Evan Huus dd01cc0490 From Niels Widger via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7725
Add get_filter method to Wireshark's Lua interface (to correspond with the
already-exposed set_filter method).

svn path=/trunk/; revision=44916
2012-09-15 13:58:57 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Stig Bjørlykke b979f2da27 From bug 6057:
Lua API: add support to temporary color filters (10 color slots)

svn path=/trunk/; revision=37801
2011-06-27 11:07:31 +00:00
Stig Bjørlykke 671bb28270 Only include config.h in C files, to avoid multiple inclusion.
svn path=/trunk/; revision=30180
2009-09-28 17:40:07 +00:00
Bill Meier 8c685a67e7 Rename a variable ('free') so checkAPIs doesn't incorrectly flag it.
svn path=/trunk/; revision=27627
2009-03-06 22:49:27 +00:00
Luis Ontanon f0fb0817ce The forgotten file!
svn path=/trunk/; revision=25979
2008-08-11 02:01:09 +00:00
Luis Ontanon 42c3239a1a luis.ontanon@gmail.com => luis@ontanon.org
svn path=/trunk/; revision=25937
2008-08-05 21:03:46 +00:00
Guy Harris 1bc049906a Add some GCC warnings to the standard set, and add some others to the
--enable-extra-gcc-checks set.

If we turn on -pedantic, try turning on -Wno-long-long as well, so that
it's not *so* pedantic that it rejects the 64-bit integral data types
that we explicitly require.

Constify a bunch of stuff, and make some other changes, to get rid of
warnings.

Clean up some indentation.

svn path=/trunk/; revision=21526
2007-04-23 10:59:26 +00:00
Luis Ontanon aa235a4262 + browser_open_url()
+ browser_open_data_file()


svn path=/trunk/; revision=20223
2006-12-27 01:46:42 +00:00
Luis Ontanon 8dee75cf68 have the funnel client passing the destructors for btn data structures to the funnel.
Although useless in practice, it is better to implement it this way... the funnel mini gui might be used by other modules in the future.


svn path=/trunk/; revision=19440
2006-10-05 16:25:13 +00:00
Luis Ontanon e23201c62a - Make sure that the registration files are created whenever there's a change
- get rid of 5.0.2 stuff
- add the apply_filter() API


svn path=/trunk/; revision=19406
2006-10-03 14:27:45 +00:00
Luis Ontanon 161b9a55ea more Lua APIs:
- set_filter() : sets the main window filter
- reload() : reloads the current capture file
- copy_to_clipboard() : copies its first arfg to the clipboard
- open_capture_file() : opens a capture file for viewing (still broken)


svn path=/trunk/; revision=19404
2006-10-03 12:07:10 +00:00
Luis Ontanon 2e7726b3ff * rename REGISTER_STAT_GROUP_E -> register_stat_group_t
* Add a "Tools" menu
* allow wslua's register_menu to register menu items into more menus


svn path=/trunk/; revision=19338
2006-09-27 17:12:42 +00:00
Ronnie Sahlberg 89f022b12b name change
svn path=/trunk/; revision=18197
2006-05-21 05:12:17 +00:00
Luis Ontanon 2e93b8b751 TextWindow:
- add buttons
  - make editable




svn path=/trunk/; revision=17773
2006-03-30 19:42:49 +00:00
Luis Ontanon 568ad6c34e + retap_packets()
+ complete gtk TextWindow
+ fix elua_dumper
+ fix elua_proto


svn path=/trunk/; revision=17462
2006-03-05 02:01:16 +00:00
Luis Ontanon 1e1f260d26 This was missing from last check-in
svn path=/trunk/; revision=17254
2006-02-11 15:22:43 +00:00
Luis Ontanon 3196dfeaf6 - fix a leak
- register the funnel mini-api ASAP


svn path=/trunk/; revision=17189
2006-02-06 23:54:54 +00:00
Luis Ontanon fc89f6d439 The simple dialog
svn path=/trunk/; revision=17172
2006-02-06 01:27:05 +00:00
Luis Ontanon 50d651fe5b * add an option to funnel_register_menu to retap the packets right after been called
* add a set_close_cllback function to the textwindow mini-api to set a callback to be called when the window gets closed.
* fix few issues regarding the closing of the window


svn path=/trunk/; revision=17165
2006-02-05 20:02:41 +00:00
Luis Ontanon 2e36cb403a - add a register_menu funnel
- remove the field_menu altoghether (It was not what I thought)
- move a declaration to the start of a function to allow VC6 to compile



svn path=/trunk/; revision=17161
2006-02-05 03:59:56 +00:00
Luis Ontanon e487660dfc The funneled GUI mini API.
A very reduced set of gui ops (by now just a text window) that can be funneled to dissectors (even plugins) via epan.


svn path=/trunk/; revision=17149
2006-02-04 19:56:50 +00:00