Commit Graph

76 Commits

Author SHA1 Message Date
JC Wren e2bcee6ac4 Make FT_{U}INT64 behave more like FT_{U}INT32, add support for FT_{U}INT{40,48,56}
Change-Id: I57354c309ecf3a0c8f0c7cff485638027f30bb19
Reviewed-on: https://code.wireshark.org/review/5813
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-02-21 16:57:52 +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
Hadriel Kaplan fac8356610 Make all Lua code use wmem not emem
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>
2015-01-04 21:02:38 +00:00
Michael Mann 553da37446 Create BASE_DOT, BASE_DASH, and BASE_SEMICOLON types for the FT_BYTES field type.
These "bases" will put a ".", "-", or ":" respectively between hexidecimal bytes in the field in packet view and display filter.  FT_BYTES with BASE_NONE will have no separator in the packet view, but continue to have the ':' as a separator in the display filter.

Converted the "string" hf_ entries that used tvb_fc_to_str as a string to use proto_tree_add_item with FT_BYTES/BASE_DOT type.

Converted applicable tvb_bytes_to_ep_str_punct() calls to use the new BASE values.

Change-Id: I2442185bb314d04a3ff2ba57883652ecd738b5f9
Reviewed-on: https://code.wireshark.org/review/6098
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-04 16:32:03 +00:00
Hadriel Kaplan 445ddc8336 Lua: FieldInfo '==' check isn't really equality
The FieldInfo metamethod for equality (letting you use the '==' operator)
doesn't check for equality, but rather if the left-hand side is within
the right-hand side. It should be equality instead. Also, all of the
FieldInfo operate overloads should push a boolean even if they're false
result.

Bug: 10820
Change-Id: Ibddaab29713f26d22ddb4d5804b9edb15e93fd79
Reviewed-on: https://code.wireshark.org/review/6186
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-01 22:24:38 +00:00
Alexis La Goutte fad9b76e32 wslua field: fix Copy-paste error (CID 1158590 & 1158589)
Change-Id: I566ddd2930b5c86bc32ca9ba12cd4be7d994bd22
Reviewed-on: https://code.wireshark.org/review/6168
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-12-31 17:12:24 +00:00
Hadriel Kaplan 0bf38f7aec Lua: getting fieldinfo.value for FT_NONE causes assert
Retrieving an FT_NONE field's value through `fieldinfo.value` or
`fieldinfo()` causes an assert.  It should retrieve the label instead.

Bug: 10815
Change-Id: Ia80443f3dd046b2cc31d1dff70d599e96d6f6fe3
Reviewed-on: https://code.wireshark.org/review/6150
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Hadriel Kaplan <hadrielk@yahoo.com>
2014-12-31 06:34:21 +00:00
Michael Mann 71c02b20eb Create FT_FCWWN field type.
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-12-28 20:05:29 +00:00
Hadriel Kaplan ceeeea089a Lua accessor for Protocol field type gets wrong data
When a Lua dissector/tap accesses the value of a Field of FT_PROTOCOL ftype, the
returned ByteArray contains the wrong data.  Also, calling such a field's
tostring() method returns a string of "(unknown)" instead of the hex of the
data.

Bug: 10801
Change-Id: I8a0642dc0e41af444d211bbe4106cd21207084a6
Reviewed-on: https://code.wireshark.org/review/6003
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.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>
2014-12-25 15:14:36 +00:00
Stig Bjørlykke 3e34273b58 Lua: Fixed some memory leakages.
Change-Id: I5e14c2e5a3868ec40d1989876b06919aa9ece4a1
Reviewed-on: https://code.wireshark.org/review/5138
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-11-06 05:06:19 +00:00
Stig Bjørlykke b653564fe2 Lua: luaL_checkstring does not return NULL
Removed all checks for NULL strings to cleanup the code.

Change-Id: Ia890cd9b206296f586e85214f07765f14984580b
Reviewed-on: https://code.wireshark.org/review/4632
Tested-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-10-13 19:06:40 +00:00
Bill Meier 07698d536b Adjust some whitespace to match editor modelines.
Change-Id: Ia22cac3ebd7a454c156f98d967e6fd61f708a2b3
Reviewed-on: https://code.wireshark.org/review/4489
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-10-06 02:55:49 +00:00
Evan Huus d47ae54806 Replace linked list of proto fields with array
This is substantially more memory-efficient, shaving another ~1.5MB off our base
usage. It also lets us remove the annoying extra "last_field" pointer and
simplify proto_register_field_common(). It also accidentally fixed what may
have been a memory leak in proto_unregister_field().

It unfortunately complicates proto_get_next_protocol_field() to require
refetching the protocol each time, but that is itself just an array-lookup under
the covers (and isn't much used), so I don't expect the performance hit to be
noticable.

Change-Id: I8e1006b2326d6563fc3b710b827cc99b54440df1
Reviewed-on: https://code.wireshark.org/review/1225
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-04-21 15:37:06 +00:00
Hadriel Kaplan f52626cc83 Add tvb_get and proto_tree_add for string-encoded byte arrays
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-17 14:04:19 +00:00
Hadriel Kaplan de441241ef Enhance Lua API doc generator and add more API info
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-25 05:30:11 +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 860747e1e7 Adds some Lua helper functions: some commonly used functions, and to help 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-25 21:06:21 +00:00
Bill Meier 11b5c15fdb Remove trailing whitespace
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-25 20:46:49 +00:00
Hadriel Kaplan 9246a709bf Cleanup on aisle 5: normalizes the Lua code to follow common schema/model
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-21 02:05:35 +00:00
Hadriel Kaplan 2e7f771a18 Adds support for Lua Int64 and UInt64 operators, functions, and general
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-02-04 00:37:46 +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 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
Michael Mann 7ec4582b4f Add FT_SYSTEM_ID type and convert the dissectors that use print_system_id with FT_BYTES to now use FT_SYSTEM_ID type.
svn path=/trunk/; revision=54383
2013-12-23 15:18:48 +00:00
Stig Bjørlykke 3b73e8b479 Renamed new_TvbRange to push_TvbRange and use this when creating a new
TvbRange from a FieldInfo.

This should fix the crash in bug #9483.

svn path=/trunk/; revision=54247
2013-12-19 15:26:31 +00:00
Guy Harris 9812f55dbb Include <epan/dfilter/dfilter.h> in files that use display filter
routines.

svn path=/trunk/; revision=53772
2013-12-03 23:08:46 +00:00
Jakub Zawadzki b6512582ab try to fix buildbot:
./wslua_field.c:32:31: fatal error: ftypes/ftypes-int.h: No such file or directory

svn path=/trunk/; revision=53225
2013-11-10 14:00:29 +00:00
Jakub Zawadzki 9a6810481d Fix buildbot:
wslua_field.c(179) : error C2037: left of 'val_to_string_repr' specifies undefined struct/union '_ftype_t'

svn path=/trunk/; revision=53224
2013-11-10 13:38:07 +00:00
Michael Mann 17679ee25d Cannot define Field refering ProtoField defined in LUA. Bug 3513 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3513)
When a new Field is created, does as following: 

* Check whether that field is registered, by using `proto_registrar_get_byname`. This is current behavior.
* (patched) If not registered, check whether that field is defined in LUA and will be registered. This is performed in `wslua_is_field_available` accessing LUA context.
* If not, an error "a field with this name must exist"  occurs.


svn path=/trunk/; revision=52771
2013-10-22 17:41:06 +00:00
Michael Mann ee208c8dcc Add support for RELATIVE-OID ASN.1 type. Bug 9192 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9192)
From Ed Beroset.

svn path=/trunk/; revision=52393
2013-10-06 02:31:10 +00:00
Pascal Quantin a0c53ffaa1 emem -> wmem conversion:
- ep_tvb_get_bits() -> wmem_packet_tvb_get_bits()
- tvb_g_memdup()/ep_tvb_memdup() -> tvb_memdup()
- tvb_fake_unicode()/tvb_get_ephemeral_faked_unicode() -> tvb_get_faked_unicode()
- tvb_get_g_string()/tvb_get_ephemeral_string()/tvb_get_seasonal_string() -> tvb_get_string()
- tvb_get_g_unicode_string()/tvb_get_ephemeral_unicode_string() -> tvb_get_unicode_string()
- tvb_get_ephemeral_string_enc() -> tvb_get_string_enc()
- update docs accordingly

svn path=/trunk/; revision=52172
2013-09-22 15:50:55 +00:00
Evan Huus 6df83e8078 Add _g_ to the names of functions that allocate glib memory. This is a bit more
explicit, and frees up the "generic" names (like tvb_memdup) for new signatures
that take the appropriate wmem pool.

Majority of the conversion done with sed.

svn path=/trunk/; revision=52164
2013-09-21 17:04:41 +00:00
Jörg Mayer f348cd5678 Explicit inclusion of emem.h
svn path=/trunk/; revision=52000
2013-09-13 08:49:38 +00:00
Stig Bjørlykke 8bde188792 Fixed FieldInfo documentation.
svn path=/trunk/; revision=51920
2013-09-10 10:07:40 +00:00
Stig Bjørlykke 408b498a12 Return ByteArray as "value" for FieldInfo's with type FT_NONE (which has data).
This fixes bug 5201.

svn path=/trunk/; revision=51903
2013-09-09 21:42:49 +00:00
Stig Bjørlykke f8624cef20 Initialize all tvb values in FieldInfo_get_range.
This fixes bug 5200.

svn path=/trunk/; revision=51899
2013-09-09 21:20:26 +00:00
Jakub Zawadzki 9cfac1227d Replace hfinfo pointer to same_name_prev, with same_name_prev_id.
svn path=/trunk/; revision=51175
2013-08-06 20:53:47 +00:00
Evan Huus 6ad3aeb3d9 From Hadriel Kaplan and myself via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8496
Iterate backwards through the linked list of identically-named fields in the lua
bindings since the list is, in fact, created backwards by
proto_register_field_init(). There is some question about whether that is
actually intended, but the rest of the code seems to assume it's normal so we
will too. It was possibly a performance consideration, though that's not
well-documented if so.

Either way, this is the simplest and safest method of fixing the issue with the
lua bindings. See the bug for more analysis.

svn path=/trunk/; revision=48495
2013-03-23 02:53:41 +00:00
Anders Broman 27744ecc2d From beroset:
remove C++ incompatibilities 
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416

svn path=/trunk/; revision=48337
2013-03-16 08:12:29 +00:00
Michael Mann 2c7844cc69 Fix typos/errors and make Lua API more consistent.
From Hadriel Kaplan, bug 8393 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8393)

svn path=/trunk/; revision=47885
2013-02-25 22:05:28 +00:00
Michael Mann 0f3f207967 Bugfix Lua pinfo.cols.protocol not holding value in postdissector
From Hadriel Kaplan, bug 6020 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6020)

svn path=/trunk/; revision=47877
2013-02-25 17:32:25 +00:00
Evan Huus 7bfb66f02f Invert the if statement into the common form:
if (error) return error;

do normal things;

svn path=/trunk/; revision=47829
2013-02-23 00:09:08 +00:00
Evan Huus f62c7e0b42 Add a return statement accidentally removed in r47783 and tweak the
brace placement so it's more obvious why the return is needed.

svn path=/trunk/; revision=47828
2013-02-23 00:06:30 +00:00
Evan Huus ceb5b89c84 Add modelines, fix indentation to be a consistent 4-spaces throughout.
svn path=/trunk/; revision=47784
2013-02-20 23:49:06 +00:00
Evan Huus fb88b48088 From Hadrien Kaplan via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8357
Fix the Lua tostring() method on FieldInfo objects such that it always returns
a string, although the string might be '(unknown)', '(none)', or '(n/a)'. This
is more conformant to Lua's API style.

Also create a new 'FieldInfo.display' accessor table member, which Lua
scripts can use instead of tostring() to get what the GUI displays.

From me:
Misc indentation fixes, remove redundant 'return' statement.

svn path=/trunk/; revision=47783
2013-02-20 23:40:24 +00:00
Jeff Morriss 3729335973 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45016
2012-09-20 01:48:30 +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
Anders Broman 6efe4ea27c From Tony Trinh:
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-25 20:28:14 +00:00
Stig Bjørlykke 9c7e12c572 Introduce NSTime Lua object to handle nstime_t.
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-08-19 08:36:02 +00:00
Stig Bjørlykke 43851d797d Include config.h only from .c files.
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
2011-04-21 13:13:39 +00:00