aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua/wslua_tree.c
AgeCommit message (Collapse)AuthorFilesLines
2015-01-04Lua: replace proto_tree_add_text callsHadriel Kaplan1-1/+8
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>
2014-12-28Create FT_FCWWN field type.Michael Mann1-0/+2
Also, convert the "string" hf_ entries that used tvb_fcwwn_to_str as a string to use proto_tree_add_item with FT_FCWWN type. Change-Id: I4ca77870499fd8239584a70874998b5d194a7167 Reviewed-on: https://code.wireshark.org/review/6036 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-11-09Convert the Lua reference to AsciiDoc.Gerald Combs1-2/+2
Move it to the Developer's Guide while we're here. Nudge the markup in epan/wslua where needed. Note that we should probably convert it to AsciiDoc (if we're going to keep it in the DG) or Doxygen. Change-Id: Ie175111043f98b7a37eeeb8d185a833d8e866f8b Reviewed-on: https://code.wireshark.org/review/5203 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-10-09Lua: Improved TreeItem:add documentation.Stig Bjørlykke1-9/+13
The protofield is optional and can not be replaced with 'nil' as with the other fields for this function. Change-Id: I2b1dd7f290264394b400cea2110b65b657c71456 Reviewed-on: https://code.wireshark.org/review/4549 Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Hadriel Kaplan <hadrielk@yahoo.com> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-04-17Add tvb_get and proto_tree_add for string-encoded byte arraysHadriel Kaplan1-0/+22
This commit adds tvb_get_string_bytes and proto_tree_add_bytes_item routines for getting GByteArrays fields from the tvb when they are encoded in ASCII hex string form. The proto_tree_add_bytes_item routine is also usable for normal binary encoded byte arrays, and has the advantage of retrieving the array values even if there's no proto tree. It also exposes the routines to Lua, both so that a Lua script can take advantage of this, but also so I can write a testsuite to test the functions. Change-Id: I112a038653df6482a5d0ebe7c95708f207319e20 Reviewed-on: https://code.wireshark.org/review/1158 Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-16Fix "might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]" warning ↵Bill Meier1-4/+4
from gcc 4.9. Change-Id: I8495d746f47c0e2528f88295771f86197d22d159 Reviewed-on: https://code.wireshark.org/review/1166 Reviewed-by: Bill Meier <wmeier@newsguy.com> Tested-by: Bill Meier <wmeier@newsguy.com>
2014-04-14Fix typo and make buildbot doc happyAlexis La Goutte1-1/+1
Change-Id: I9e60fd8a8353e740c1b57f52daac86b1af1b784f Reviewed-on: https://code.wireshark.org/review/1106 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-04-14Try to make happy Ubuntu BuildbotAlexis La Goutte1-3/+3
../../../epan/wslua/wslua_tree.c: In function 'TreeItem_add_packet_field': ../../../epan/wslua/wslua_tree.c:151:14: error: variable 'tvbr' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered] ../../../epan/wslua/wslua_tree.c:154:9: error: variable 'ett' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered] ../../../epan/wslua/wslua_tree.c:159:9: error: variable 'nargs' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered] Change-Id: I1720a62613f4bf94ae2f8649a04139a7899fb106 Reviewed-on: https://code.wireshark.org/review/1103 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-14Add tvb_get and proto_tree_add for string-encoded timestampsHadriel Kaplan1-6/+129
This commit adds tvb_get_string_time and proto_tree_add_time_item routines for getting nstime fields from the tvb when they are encoded in ASCII string form. The proto_tree_add_time_item routine is also usable for normal big/little-endian encoded time_t, and has the advantage of retrieving the value even if there's no proto tree. It also exposes the routines to Lua, both so that a Lua script can take advantage of this, but also so I can write a testsuite to test the functions. Change-Id: I955da10f68f2680e3da3a5be5ad8fdce7ed6808c Reviewed-on: https://code.wireshark.org/review/1084 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-28Allow chained calls with Lua TreeItem functions, and fix a couple of minor ↵Hadriel Kaplan1-19/+65
errors. A common Lua idiom is to use chained calls, i.e. tree:foo():bar():choo(). This actually works for tree:add() because it returns the new child tree item which is then the one being applied to the next chained call. But it doesn't work beyond that for things like set_generated() and so on. So this commit fixes that. This also fixes the Lua tree:add() function for the FT_BOOL type to let it be a Lua boolean value. And it reverts a previous change to Struct.tohex() to allow coercion of the argument. Change-Id: I10f819d363163914ba320c87d4bedebe5b50cacf Reviewed-on: https://code.wireshark.org/review/851 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-26Add filterable expert info for LuaHadriel Kaplan1-6/+97
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-25Enhance Lua API doc generator and add more API infoHadriel Kaplan1-17/+25
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-4/+4
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-25Remove trailing whitespaceBill Meier1-1/+1
Change-Id: I8116f63ff88687c8db3fd6e8e23b22ab2f759af0 Reviewed-on: https://code.wireshark.org/review/385 Reviewed-by: Bill Meier <wmeier@newsguy.com> Tested-by: Bill Meier <wmeier@newsguy.com>
2014-02-21Cleanup on aisle 5: normalizes the Lua code to follow common schema/modelHadriel Kaplan1-74/+30
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-02-07Fix Bug 9728 'Lua: ProtoField.bool() VALUESTRING argument is not optional ↵Hadriel Kaplan1-8/+22
but was supposed to be' Similar to bug 9725 and ProtoField.new(), the way the VALUESTRING argument is being checked in the code for ProtoField.bool() ends up making it non-optional. This patch fixes that, along with some minor API documentation fixes (text). Change-Id: Iadb9a8ace9c5514fc623d882301fe16b637fe4ce Reviewed-on: https://code.wireshark.org/review/125 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Evan Huus <eapache@gmail.com>
2014-02-04Adds support for Lua Int64 and UInt64 operators, functions, and generalHadriel Kaplan1-2/+2
usefulness, working around bug #9162 until Lua 5.3 is released. The existing Int64 and UInt64 classes provide virtually no usefullness, other than for creating a string of their value. While one could then write Lua code to convert the string to Lua numbers and such, ultimately Lua has no native 64-bit integer support, making such a task difficult to handle in Lua. This change adds a host of functions and operators to the existing Int64 (gint64) and UInt64 (guint64) classes, to enable true 64-bit integer support on par with native Lua numbers. A test script is also provided, which tests the functions/operators. Change-Id: I4c5f8f5219b9a88198902283bd32ddf24c346bbe Reviewed-on: https://code.wireshark.org/review/83 Tested-by: Evan Huus <eapache@gmail.com> Reviewed-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>
2014-01-14Don't cast away constness.Guy Harris1-1/+1
svn path=/trunk/; revision=54796
2013-12-23Add FT_SYSTEM_ID type and convert the dissectors that use print_system_id ↵Michael Mann1-0/+1
with FT_BYTES to now use FT_SYSTEM_ID type. svn path=/trunk/; revision=54383
2013-10-06Add support for RELATIVE-OID ASN.1 type. Bug 9192 ↵Michael Mann1-0/+1
(https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9192) From Ed Beroset. svn path=/trunk/; revision=52393
2013-09-13Explicit inclusion of emem.hJörg Mayer1-0/+2
svn path=/trunk/; revision=52000
2013-09-10Added TreeItem prepend_text().Stig Bjørlykke1-0/+19
svn path=/trunk/; revision=51924
2013-09-08Couldn't quite figure out how to make the expert items in proto.c and the ↵Michael Mann1-1/+1
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-08-05Completely remove support for proto_item_set_expert_flags.Michael Mann1-20/+0
svn path=/trunk/; revision=51144
2013-03-16From beroset:Anders Broman1-6/+6
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-3/+3
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
2012-06-05Fix Coverity 702396: tvbr is ep_ allocated so it can't be NULL.Jeff Morriss1-7/+1
svn path=/trunk/; revision=43116
2012-05-14tvb_unicode_strsize() returns number of bytes, NOT number of UCS-2 characters.Jakub Zawadzki1-3/+1
svn path=/trunk/; revision=42622
2012-05-14Get rid of remaining Booleans-as-encoding-arguments inGuy Harris1-10/+87
proto_tree_add_item() calls. Add new "add_packet_field" method to the TreeItem class, taking a protocol field (*not* a protocol), TvbRange, and encoding value as arguments. Add the ENC_ values to init.lua. Make them all hex #defines so make-init-lua.pl can easily extract them. Export tvb_unicode_strsize() for use by Lua (and elsewhere as desired). Note that it handles UTF-16 and UTF-8, and fix the comment to note that its count of hexadectets *does* include the null terminator (that's what the code does). svn path=/trunk/; revision=42621
2011-08-19Introduce NSTime Lua object to handle nstime_t.Stig Bjørlykke1-0/+4
This object can be used to retreive other absolute and relative time fields, create and modify nstime_t values and put generated time values in the tree. Also added ProtoField.absolute_time and ProtoField.relative_time. svn path=/trunk/; revision=38616
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-60/+32
34598 and 34599. svn path=/trunk/; revision=34602
2010-10-21Make the indentation consistent.Jeff Morriss1-33/+61
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-05-12From Tamas Regos:Anders Broman1-1/+1
WSLUA improvement. The existing ProtoField.bool looks like the following: ProtoField.bool(abbr, [name], [desc]) But checking any protocol dissector with bool protofield, it can be seen that in C code we have more options than thru the WSLUA interface. E.g.: {&hf_gtp_qos_sig_ind,{"Signalling Indication", "gtp.sig_ind", FT_BOOLEAN, 8, TFS(&gtp_sig_ind), GTP_EXT_QOS_SIG_IND_MASK, NULL, HFILL}}, So I've extended ProtoField.bool to have more options like this: ProtoField.bool(abbr, [name], [bitfield], [true_false_string], [mask], [desc]) https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4700 svn path=/trunk/; revision=32771
2010-05-12From Tamas Regos:Anders Broman1-46/+29
Whitspace changes svn path=/trunk/; revision=32770
2010-01-01Use correct length for FT_STRINGZ when adding the item to the tree.Stig Bjørlykke1-1/+4
svn path=/trunk/; revision=31401
2009-10-02From Beth via bug 4049:Stig Bjørlykke1-0/+3
Add support for FT_BOOLEAN fields to FieldInfo and TreeItem. svn path=/trunk/; revision=30249
2009-09-10From Diego:Anders Broman1-0/+20
proto_item_set_len is missing from Lua API. https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3994 svn path=/trunk/; revision=29837
2009-06-08Added a missing check for expired TreeItem.Stig Bjørlykke1-22/+28
Fixed some indents. svn path=/trunk/; revision=28668
2009-05-08Adjusted arguments used in Lua Pref.statictext()Stig Bjørlykke1-6/+6
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-01-27Corrected some defines. Use defines when appropriate.Stig Bjørlykke1-7/+7
Document last argument to DissectorTable.new(). svn path=/trunk/; revision=27309
2008-09-16Adds 64 bit integer handling to Lua interface.Balint Reczey1-2/+2
Fixes bug 2750. svn path=/trunk/; revision=26216
2008-08-05luis.ontanon@gmail.com => luis@ontanon.orgLuis Ontanon1-1/+1
svn path=/trunk/; revision=25937
2008-07-29Try to get the docbook buildbot runnig.Luis Ontanon1-1/+1
Do not generate doc items for wslua garbage collectors (they are transparet) svn path=/trunk/; revision=25857
2008-07-26From Balint ReczeyLuis Ontanon1-28/+66
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