aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua/wslua_listener.c
AgeCommit message (Collapse)AuthorFilesLines
2017-12-16wslua: Fix memory leakagesStig Bjørlykke1-1/+1
Free some variables in error handling. Change-Id: I0d0653962b11f760c31872aa7e5b5f1d20c54dcb Reviewed-on: https://code.wireshark.org/review/24842 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-10-15Remove superfluous null-checks before strdup/freeAhmad Fatoum1-1/+1
NULL checks were removed for following free functions: - g_free "If mem is NULL it simply returns" https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html#g-free - g_slist_free(_full)? "NULL is considered to be the empty list" https://developer.gnome.org/glib/stable/glib-Singly-Linked-Lists.html - g_strfreev "If str_array is NULL, this function simply returns." https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strfreev - g_slice_free "If mem is NULL, this macro does nothing." https://developer.gnome.org/glib/stable/glib-Memory-Slices.html#g-slice-free - g_match_info_free "not NULL... otherwise does nothing" https://developer.gnome.org/glib/stable/glib-Perl-compatible-regular-expressions.html#g-match-info-free - dfilter_free defined in Wireshark code. Returns early when passed NULL epan/dfilter/dfilter.c They were also removed around calls to g_strdup where applicable: - g_strdup "If str is NULL it returns NULL." https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strdup Change-Id: Ie80c2db89bef531edc3aed7b7c9f654e1d654d04 Reviewed-on: https://code.wireshark.org/review/23406 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: João Valverde <j@v6e.pt>
2017-08-27Lua: fix crash on invalid Dissector.list("food") invocationPeter Wu1-1/+1
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>
2016-07-26Use ws_g_warning in wslua.Michael Mann1-5/+6
The g_warning calls seem legitimate, so "hide" them from checkAPIs.pl. Change-Id: I6d25b08e22aeeb0244e07836385f2b67d6261546 Reviewed-on: https://code.wireshark.org/review/16703 Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-06-19Revert "tap: change glib functions to wmem."Pascal Quantin1-3/+3
This reverts commit 2e9f3c5d366eaa7139fc877b5301392166b3f985. It breaks the registration of codec, dissector and libwiretap plugins. Change-Id: I4ef91dd192f765adf87ea9fe9f3693e25dbd24de Reviewed-on: https://code.wireshark.org/review/16012 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-06-17tap: change glib functions to wmem.Dario Lombardo1-3/+3
Change-Id: I878ae6b121a669f9b7f4e1e57bc079f0cb44c0bf Reviewed-on: https://code.wireshark.org/review/15270 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Evan Huus <eapache@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-06-14wslua: Drop unused "push_code" macro parameterPeter Wu1-1/+1
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-01-24Add the packet number to the packet_info structure, and use it.Guy Harris1-1/+1
That removes most of the uses of the frame number field in the frame_data structure. Change-Id: Ie22e4533e87f8360d7c0a61ca6ffb796cc233f22 Reviewed-on: https://code.wireshark.org/review/13509 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-31Don't cast away constness.Guy Harris1-4/+3
Change-Id: I37a1923c2e463346244cd5e56daf22122d119d78 Reviewed-on: https://code.wireshark.org/review/12976 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-17Lua: Do not deregister Listener in __gc.Stig Bjørlykke1-10/+5
Listeners should not be deregistered in __gc because they will go out of scope while in use. Instead free allocated data when deregistering the Listener (Listener.remove() and Reload Lua Plugins). Bug: 11722 Change-Id: Iadf6506757df06e476ac3cac38c05f1d1d497dc4 Reviewed-on: https://code.wireshark.org/review/11924 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2015-09-03Lua: Check if having listeners before removeStig Bjørlykke1-1/+1
This avoids a warning when trying to remove a listener twice. g_ptr_array_remove: assertion 'array' failed Change-Id: I0bcbbbe3b3393a8455b51fad80c5716fc38ac50e Reviewed-on: https://code.wireshark.org/review/10370 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2015-08-11Added Reload Lua plugins.Stig Bjørlykke1-6/+43
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-03Make sure per-packet tap callbacks return gbooleans.Gerald Combs1-4/+4
The tap API changed the return type of per-packet listener callbacks from int to gboolean back in 2009. Update a bunch of functions and some documentation accordingly. Change-Id: I79affe65db975caed3cc296a7e2985b7b9cdf4cc Reviewed-on: https://code.wireshark.org/review/9853 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-02-13wslua*: Add editor modelines; Fix indentation, etc as needed.Bill Meier1-0/+12
Change-Id: I6df5d46f4b263104aa9cb6353cc987087cdb867e Reviewed-on: https://code.wireshark.org/review/7102 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2015-01-27Lua: Expose tcp_dissect_pdus() to LuaHadriel Kaplan1-4/+1
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-23Use luaL_{check,opt}integer() rather than luaL_{check,opt}int().Guy Harris1-1/+1
Lua prior to 5.3 defined luaL_{check,opt}int() as macros wrapping luaL_{check,opt}integer() with a cast to int; Lua 5.3 doesn't. It sounds as if the Lua developers are deprecating luaL_{check,opt}int(): http://osdir.com/ml/general/2014-10/msg46568.html Change-Id: I2d0b649dcd57ede124f31d39f7945f342ae9b18f Reviewed-on: https://code.wireshark.org/review/6744 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Guy Harris <guy@alum.mit.edu> Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Tested-by: Hadriel Kaplan <hadrielk@yahoo.com>
2015-01-04Make all Lua code use wmem not ememHadriel Kaplan1-8/+6
Changed all remaining code in wslua that was using emem, to use wmem or simpler methods. Bug: 9927 Change-Id: I3d19a770e0fd77d996bdb6b61a76a722cc2bcd55 Reviewed-on: https://code.wireshark.org/review/6109 Petri-Dish: Michael Mann <mmann78@netscape.net> 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: Michael Mann <mmann78@netscape.net>
2014-03-25Enhance Lua API doc generator and add more API infoHadriel Kaplan1-17/+34
This enhances the Lua API doc generator Perl script to handle meta-information in description comments, such as bold, italics, raw code, version info, etc. The supported markup and codes are documented in make-wsluarm.pl. It's not beautiful Perl code (I don't know Perl), and I'd rather do it using Lua, but I think keeping it Perl makes more sense in the long run. Change-Id: I477b3ebe770075dcea9ec52708e2d6fb5758d2f4 Reviewed-on: https://code.wireshark.org/review/802 Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04Remove all $Id$ from top of fileAlexis La Goutte1-2/+0
(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-02-27Fix coverity warnings for all wslua files. (redux)Hadriel Kaplan1-2/+3
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-25Fix bug 6357: Lua all_field_infos() broken within tap/listenerHadriel Kaplan1-0/+12
The current API for Lua provides a global function "all_field_infos()" which returns all the populated field_info nodes in the current proto_tree. By default all_field_infos() "works", in the literal sense: it returns exactly the fields the previous dissectors of the packet have populated at that instant of time. But of course dissectors don't populate all the applicable fields most of the time, because of the TRY_TO_FAKE_THIS_ITEM optimization where they don't fill in things that aren't needed at the time by a display, color, or tap's dfilter. So this commit offers a way to force the dissectors to populate all the applicable field_infos in the tree, by setting the proto_tree to be visible. Obviously that is going to impact performance, since it basically bypasses the TRY_TO_FAKE_THIS_ITEM optimization; so the patch only does this if the Lua script author told it to explicitly, by adding an argument to Listener.new() and register_postdissector(). Change-Id: I11d3559fbe8c14fbadf1b51415a3701dc1200b7b Reviewed-on: https://code.wireshark.org/review/286 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-02-25Adds some Lua helper functions: some commonly used functions, and to help ↵Hadriel Kaplan1-0/+30
troubleshooting Lua scripts There are some common things people need to do, such as convert to/from hex or get the raw binary string in a ByteArray/Tvb/TvbRange. These have been added, as well as some tests for them in the testsuites. Also, functions have been added to allow a script to get all the available tap types and filter fields, since they are not exactly what one can see in the Wireshark gui. Change-Id: I92e5e4eae713bb90d79b0c024eaa4e55b99cc96b Reviewed-on: https://code.wireshark.org/review/249 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-02-21Cleanup on aisle 5: normalizes the Lua code to follow common schema/modelHadriel Kaplan1-49/+35
Over time the various wslua classes/functions have gotten moldy, with different ways of doing similar things. Some of it can't be changed without breaking backwards compatibility for Lua scripts, so I didn't do that. But I did what I could. The biggest change is a refactoring of how accessors/attributes are handled in the code, so that most of them work the same way using the same code. Specific changes made: * Added null/expired checking macro to class declarations for many classes * Removed extraneous pointer/expired checking, since checkFoo() does that already * Fixed "errors" reported by clang static analyzer; they were false positives, but it was easier to get it to stop complaining by changing the code * Moved internal wslua functions from wslua_utils.c into a new 'wslua_internals.c' file * Changed Listener/NSTime/Pinfo/Proto to use a common setter/getter accessor/attribute code model, instead of each of them doing their own * Fixed some API doc mistakes, mostly around attributes that were documented as read-only but were actually read-write Change-Id: Idddafc5fbd3545ebff29e063acc767e1c743a1a9 Reviewed-on: https://code.wireshark.org/review/271 Reviewed-by: Evan Huus <eapache@gmail.com> Tested-by: Evan Huus <eapache@gmail.com>
2014-01-31Fix for Bug-9711 Lua: the Lua stack is growing slightly during initialization.Hadriel Kaplan1-1/+1
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>
2013-09-13Explicit inclusion of emem.hJörg Mayer1-0/+2
svn path=/trunk/; revision=52000
2013-03-16From beroset:Anders Broman1-5/+5
remove C++ incompatibilities https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 svn path=/trunk/; revision=48337
2013-02-25Fix typos/errors and make Lua API more consistent.Michael Mann1-10/+16
From Hadriel Kaplan, bug 8393 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8393) svn path=/trunk/; revision=47885
2012-09-20We always HAVE_CONFIG_H so don't bother checking whether we have it or not.Jeff Morriss1-2/+0
svn path=/trunk/; revision=45016
2012-06-28Update Free Software Foundation address.Jakub Zawadzki1-1/+1
(COPYING will be updated in next commit) svn path=/trunk/; revision=43536
2012-06-25From Tony Trinh:Anders Broman1-2/+2
Update Lua from 5.1 to 5.2 https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7400 svn path=/trunk/; revision=43479
2011-04-21Include config.h only from .c files.Stig Bjørlykke1-0/+4
This avoids a warning building epan.c which includes both config.h and wslua.h (duplicate defines from config.h) svn path=/trunk/; revision=36751
2010-10-21Aw, man, I knew this code was parsed, but I missed the docbook part. Revert ↵Jeff Morriss1-46/+26
34598 and 34599. svn path=/trunk/; revision=34602
2010-10-21Make the indentation consistent.Jeff Morriss1-61/+81
Pull function names to column 0 - except when necessary for autoregistration. Put function comments before the function. For readability, put the macros for functions before the function too. Put class functions before the class. svn path=/trunk/; revision=34599
2010-01-28Fix various gcc -Wshadow warnings.Bill Meier1-6/+6
svn path=/trunk/; revision=31716
2009-10-11Removed unused function tap_draw_cb_error_handler().Stig Bjørlykke1-6/+0
svn path=/trunk/; revision=30518
2009-10-11Make more functions static.Stig Bjørlykke1-6/+6
svn path=/trunk/; revision=30517
2009-06-08Changed g_strdup_printf -> ep_strdup_printf.Stig Bjørlykke1-2/+1
Use correct modifier for converting gint64 and guint64 to string. Added __gc for Int64 and UInt64. Fixed some indents. svn path=/trunk/; revision=28655
2009-06-05Have tap listeners specify whether the "packet" routine requiresGuy Harris1-36/+44
a protocol tree; the column values. This includes stats-tree listeners. Have the routines to build the packet list, and to retap packets, honor those requirements. This means that cf_retap_packets() no longer needs an argument to specify whether to construct the column values or not, so get rid of that argument. This also means that there's no need for a tap to have a fake filter to ensure that the protocol tree will be built, so don't set up a fake "frame" filter. While we're at it, clean up some cases where "no filter" was represented as a null string rather than a null pointer. Have a routine to return an indication of the number of tap listeners with filters; use that rather than the global num_tap_filters. Clean up some indentation and some gboolean vs. gint items. svn path=/trunk/; revision=28645
2009-05-08Adjusted arguments used in Lua Pref.statictext()Stig Bjørlykke1-2/+2
Update Lua documentation: - Fixed Pref.enum, Pref.range and Pref.statictext - Fixed the equivalent comment for pinfo.cols - Do not have a comment star (*) in the documentation - Be consistent and start all sentences with a capital letter svn path=/trunk/; revision=28304
2009-03-13From Jakub Zawadzki (bug 3331):Stig Bjørlykke1-1/+1
g_free() is NULL safe, so we don't need check against it. svn path=/trunk/; revision=27718
2008-08-05luis.ontanon@gmail.com => luis@ontanon.orgLuis Ontanon1-1/+1
svn path=/trunk/; revision=25937
2008-07-26From Balint ReczeyLuis Ontanon1-3/+4
Fix for https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2453 The patch fixes the problem by extending the original "outstanding stuff" approach. Now the pointer itself won't be NULLified, instead we track the pointers with their expiry state in structs in the outstanding_stuff list. The Lua objects refers to those structs instead of the actual pointers and checks the expiry state of the pointers before accessing them. The pointers are marked expired when the dissection of the frame is finished and the allocated struct is freed by Lua's garbage collector. If the garbage collector hits the struct when it holds a not expired pointer, it marks it as expired (that means we don't have any object in Lua referring to the pointer) and the struct will be freed at the end of the dissection of the frame. this is for the 1.0 branch svn path=/trunk/; revision=25845
2008-04-25From: Márton Németh:Jaap Keuter1-2/+2
The luaL_reg structure consists of two pointers: char* and a pointer to a function. The last entry should also reflect this: it should be { NULL, NULL } instead of { 0, 0 }. svn path=/trunk/; revision=25175
2008-04-12From Marton Nemeth (bug 2447):Stig Bjørlykke1-1/+1
In help the not all of the following chapters begins with uppercase: 10.4.1. saving capture files 10.4.2. obtaining dissection data 10.4.3. GUI support 10.4.4. post-dissection packet analysis 10.4.5. obtaining packet information 10.4.6. functions for writing dissectors 10.4.7. adding information to the dissection tree 10.4.8. functions for handling packet data 10.4.9. Utility Functions svn path=/trunk/; revision=24933
2006-12-23get rid of an unused variable.Luis Ontanon1-3/+0
svn path=/trunk/; revision=20208
2006-12-23- Fix an error in the tap listener callbackLuis Ontanon1-7/+5
- add some comments to console.lua svn path=/trunk/; revision=20206
2006-10-24Improve the documentation generatorsLuis Ontanon1-1/+1
add some docs. svn path=/trunk/; revision=19671
2006-10-18Add module information for generated docsLuis Ontanon1-1/+3
svn path=/trunk/; revision=19595
2006-10-17Several changes:Luis Ontanon1-25/+7
- do not #include a c code file in wslua_register.c compile a separate boject - add the console and evaluate windows - add some useful vars to the lua environment - some cleanup - add the dtd generator code (currently disabled) svn path=/trunk/; revision=19579
2006-09-25Move the Lua interface into epan... (not a plugin anymore).Luis Ontanon1-0/+332
- Rename Tap into Listener - add a mechanism to pass protocols' tap data to the Listener svn path=/trunk/; revision=19319