Commit Graph

92 Commits

Author SHA1 Message Date
Hadriel Kaplan 04c39bb097 Add Lua heuristic dissector support
This adds the ability for Lua scripts to register heuristic dissectors
for any protocol that has registered a heuristic dissector list, such
as UDP, TCP, and ~50 others. The Lua function can also establish a
conversation tied to its Proto dissector, to avoid having to check the
heuristics for the same flow. The example dissector in the testsuite
has also been enhanced to include a heuristic dissector, to verify
the functionality and provide an example implementation.

Change-Id: Ie232602779f43d3418fe8db09c61d5fc0b59597a
Reviewed-on: https://code.wireshark.org/review/576
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-14 07:29:15 +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 217f9fd0d9 Fix Bug 9728 'Lua: ProtoField.bool() VALUESTRING argument is not optional 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-07 19:19:54 +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 e8e3f1011b Removed a wrong sanity check in ByteArray base64_decode.
svn path=/trunk/; revision=54379
2013-12-23 12:19:16 +00:00
Stig Bjørlykke df25b7a7e0 Improved out-of-bounds check in TvbRange ustringz and le_ustringz.
This functions should probably be marked as obsoleted now that we
have support for encoding in stringz.

svn path=/trunk/; revision=54372
2013-12-22 22:19:41 +00:00
Stig Bjørlykke 8a4f419f60 Made TvbRange strsize take an optional encoding argument.
svn path=/trunk/; revision=54371
2013-12-22 22:09:06 +00:00
Stig Bjørlykke a48a5a164f Made TvbRange string and stringz take an optional encoding argument, and
removed the yet-another-string-function string_enc and stringz_enc.

Documented the encoding argument.

svn path=/trunk/; revision=54356
2013-12-22 13:08:39 +00:00
Jakub Zawadzki be733f3041 Move epan/base64.[ch] to wsutil/ with function name change.
svn path=/trunk/; revision=54326
2013-12-21 14:38:51 +00:00
Guy Harris 0f86a86f47 Add new string_enc and stringz_enc methods that take an encoding value
as an argument, just as the add_packet_field method for a tree does.

Use tvb_get_string_enc() and tvb_get_stringz_enc() rather than
tvb_get_string(), tvb_get_stringz(), tvb_get_unicode_string(), and
tvb_get_unicode_stringz().  Treat "ustring" as meaning "UTF-16-encoded
Unicode string" rather than "UCS-2-encoded subset-of-Unicode string".

svn path=/trunk/; revision=54310
2013-12-20 20:29:27 +00:00
Evan Huus a6415ece0a Rename a couple of to_str functions to have ep_ in the name. This makes it
obvious that the returned string is ephemeral, and opens up the original names
in the API for versions that take a wmem pool (and thus can work in any scope).

svn path=/trunk/; revision=54249
2013-12-19 15:49:09 +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
Martin Mathieson 485faca86d Add cast to try to fix buildbot failure
svn path=/trunk/; revision=54218
2013-12-18 13:37:20 +00:00
Stig Bjørlykke 52a05e6275 Added ByteArray base64_decode().
svn path=/trunk/; revision=54215
2013-12-18 12:55:43 +00:00
Stig Bjørlykke 52ce5acbdf Detect out-of-bounds when handling zero terminated strings from a TvbRange.
This avoids a wireshark crash.

svn path=/trunk/; revision=53470
2013-11-21 08:42:21 +00:00
Jakub Zawadzki 8c11584ce1 Make wslua byte_to_str[] array of char[3] instead of pointers to char.
XXX, it should use byte_to_hex() from to_str.c

svn path=/trunk/; revision=53350
2013-11-15 23:33:02 +00:00
Pascal Quantin 102c452bcb More emem -> wmem conversion:
- tvb_get_g_stringz()/tvb_get_ephemeral_stringz()/tvb_get_seasonal_stringz() -> tvb_get_stringz()
- tvb_get_g_stringz_enc()/tvb_get_ephemeral_stringz_enc() -> tvb_get_stringz_enc()
- tvb_get_ephemeral_unicode_stringz() -> tvb_get_unicode_stringz()
- tvb_bcd_dig_to_ep_str() -> tvb_bcd_dig_to_wmem_packet_str()
- update docs accordingly

svn path=/trunk/; revision=52180
2013-09-22 20:04:35 +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 f74bd06ecf Removed return value from ByteArray append and prepend, as this did push
the same ByteArray twice (and thus calling the GC twice).
This should fix bug 4461.

Changed ByteArray concat to create a new array to be returned.

svn path=/trunk/; revision=51872
2013-09-09 17:49:22 +00:00
Stig Bjørlykke 5f35d91ace Added TvbRange strsize().
svn path=/trunk/; revision=51470
2013-08-22 11:58:32 +00:00
Stig Bjørlykke 7d7bf98a8e Added TvbRange uncompress().
svn path=/trunk/; revision=48422
2013-03-19 17:15:27 +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
Bill Meier 9e436c6c4a Fix a misspelled word; Do some minor tweaking of the wording of a few comments.
svn path=/trunk/; revision=47903
2013-02-26 15:10:28 +00:00
Bill Meier 96a24cc79f Fix spelling/typos found using a list of commonly misspelled words.
The misspellings were mostly in comments but some were
in text strings visible to the user.


svn path=/trunk/; revision=47899
2013-02-26 04:42:26 +00:00
Bill Meier a6e56df8b6 it's ==> its & its ==> it's as needed.
svn path=/trunk/; revision=47898
2013-02-26 02:38:52 +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
Anders Broman 68160dac5c From "temp4746":
wslua TvbRange:le_ustring/ustring buffer overflow's.
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8175

svn path=/trunk/; revision=47012
2013-01-10 06:55:16 +00:00
Stig Bjørlykke 55aae6767c From mathewt via bug 8012:
Fixed lua le_int64() and le_uint64().

svn path=/trunk/; revision=46151
2012-11-23 11:20:35 +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
Jeff Morriss fe5f076b5c Fix Coverity 702397: reference tvbr *after* checking that it is not NULL.
svn path=/trunk/; revision=43115
2012-06-05 15:26:09 +00:00
Anders Broman 7d17553acc From Evan Huus: Fix memory leaks in wslua_tvb.c fix typos in wslu_proto.c https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7202
svn path=/trunk/; revision=42281
2012-04-27 06:02:45 +00:00
Stig Bjørlykke 0352ac8e8f From Robert G. Jakabosky via bug 5575:
Fix memory errors in Lua dissectors.
- Free Tvb when created from ByteArray.
- Free TvbRange correctly.
- Free string from get_persconffile_path and get_datafile_path.
- Some code cleanup.

svn path=/trunk/; revision=39744
2011-11-06 17:39:13 +00:00
Stig Bjørlykke 72cdab4c31 From Alex Vallee via bug 6346:
Added Lua TvbRange unicode string methods.

svn path=/trunk/; revision=39225
2011-10-02 17:02:10 +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
Jeff Morriss 23c5165169 Clarify that Tvb_reported_length_remaining may return -1
svn path=/trunk/; revision=38485
2011-08-11 13:45:42 +00:00
Jeff Morriss fa4d32113c From Alexander Stein via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6175 :
The attached patch adds the method reported_length_remaining to tvb.

svn path=/trunk/; revision=38464
2011-08-11 00:49:43 +00:00
Jeff Morriss 4ee1d732fb Add a Tvb_reported_len Lua API; this may help satisfy bug 6175.
svn path=/trunk/; revision=38461
2011-08-10 21:45:53 +00:00
Stig Bjørlykke b3d0f00015 From Tony Trinh via bug 5960:
Fix TvbRange:string() so that it returns a string that contains all bytes
of the range, including zeroes (instead of being truncated at first zero).

svn path=/trunk/; revision=37763
2011-06-23 11:06:34 +00:00
Stig Bjørlykke 5934925554 Rename Tvb_new_real to ByteArray_tvb, as it's a ByteArray function.
Documentation is generated from code.

This fixes bug 5199.

svn path=/trunk/; revision=37761
2011-06-23 10:43:49 +00:00
Stig Bjørlykke 6df263d634 Rename Tvb_tvb to TvbRange_tvb, as it's a TvbRange function.
Documentation is generated from code.

This fixes bug 5006.

svn path=/trunk/; revision=37760
2011-06-23 10:28:53 +00:00
Jeff Morriss f3f9f2697f Make TVBs opaque for most users.
Convert TVB_RAW_OFFSET() and TVB_GET_DS_TVB() into functions.

svn path=/trunk/; revision=37422
2011-05-27 03:06:50 +00:00