Commit Graph

175 Commits

Author SHA1 Message Date
Guy Harris 9855beff31 Make the type of the second argument to a DATFunc_heur_table explicit.
It's always pased a heur_dissector_list_t *, so give it that type,
rather than having it be a generic pointer.

Change-Id: Ia6a045bb1b96c2f6ef3e23f27928e0b52f7cfb9f
Reviewed-on: https://code.wireshark.org/review/5713
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-11 01:51:07 +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 e38e82852e Lua: Fix for register dissectors only once.
The postdissector may be registered before adding the dissector function.

Change-Id: I2285824835491ac91e00515bfb18eb471888eaf8
Reviewed-on: https://code.wireshark.org/review/5106
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>
Tested-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-11-04 11:49:14 +00:00
Stig Bjørlykke 15e78de432 Lua: Register dissectors only once.
Change-Id: I883e8560e9d101d34760d09715255e4fccc9eb98
Reviewed-on: https://code.wireshark.org/review/5022
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-11-04 07:52:21 +00:00
Stig Bjørlykke c6feecff74 Lua: Only register postdissectors once.
Change-Id: Id41e4ebd19e0b80faa06f628d689bdb77f2b84c9
Reviewed-on: https://code.wireshark.org/review/5023
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-10-31 12:26:21 +00:00
Stig Bjørlykke a0d5ef8ff7 Lua: Added support for FT_EUI64.
Bug: 10603
Change-Id: I21da496834b83466585f5b77f87970e3fab28b12
Reviewed-on: https://code.wireshark.org/review/4894
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-10-22 19:54:25 +00:00
Stig Bjørlykke 147e7fe510 Lua: Added ProtoField.none
This field can be used for adding filterable subtree entries.

Change-Id: Id395c9a8194dc00e6544170631b48d71ae9dd33e
Reviewed-on: https://code.wireshark.org/review/4573
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
2014-10-18 18:25:40 +00:00
Guy Harris 25d9a7b5f1 Don't use <ctype.h> macros, and eliminate an include of <ctype.h>.
This avoids locale-dependent tests.

Change-Id: I709ff6b1a837fb0390b29f911d3b9ef1015a2d1e
Reviewed-on: https://code.wireshark.org/review/4758
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-17 06:09:11 +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
Stig Bjørlykke d89cc1cf9a ASN1: Added support for using #.REGISTER_NEW
This will register BER PDU-dissectors as "new".
Return number of bytes dissected from dissector_try_* functions.
Return number of bytes dissected in DissectorTable:try()

This will make it possible to get dissected length when using
dissector_try_*() and dissected ASN.1 length in Lua when using
DissectorTable:try() (as we already have for Dissector:call).

Change-Id: Iee17a68dc214fa0fb50b25fc927026ad7c1cbce4
Reviewed-on: https://code.wireshark.org/review/4531
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-10-07 20:27:35 +00:00
Gerald Combs 9033f137a9 Revert "ASN1: Added support for using #.REGISTER_NEW"
This temporarily reverts commit
acc09c2aa2.

Change-Id: I7a55c8c2da3f65e914b90648ee92c84efd57f1a0
Reviewed-on: https://code.wireshark.org/review/4525
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-10-07 16:34:18 +00:00
Stig Bjørlykke acc09c2aa2 ASN1: Added support for using #.REGISTER_NEW
This will register BER PDU-dissectors as "new".
Return number of bytes dissected from dissector_try_* functions.
Return number of bytes dissected in DissectorTable:try()

This will make it possible to get dissected length when using
dissector_try_*() and dissected ASN.1 length in Lua when using
DissectorTable:try() (as we already have for Dissector:call).

Change-Id: I8802a812bd484c1e8794c618b87e676003aea94a
Reviewed-on: https://code.wireshark.org/review/4493
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-10-07 16:23:55 +00:00
Bill Meier cc286bad25 Various minor changes:
- Create/use some extended value_strings
- Remove unneeded #includes;
- Do whitespace changes;
- Add editor modelines.

Change-Id: I2e1ea37dddfd5e8656c90c0d45a6596c4912bb2c
Reviewed-on: https://code.wireshark.org/review/4065
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-09-10 16:17:29 +00:00
Bill Meier 93cc6f004f Fix some spelling & grammar.
Change-Id: Iedeaa411caa0823922dd79c27897a2349d4e6907
Reviewed-on: https://code.wireshark.org/review/4054
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-09-09 19:43:27 +00:00
Stig Bjørlykke 8c0d3ae47e Return number of bytes dissected in dissector:call
This does not work for old-style dissectors as they always return
the number of bytes in incoming buffer and not the number of bytes
dissected.  This is noted in the documentation.

Change-Id: I5b236a73952cac3efc830e40276283bed9af1f87
Reviewed-on: https://code.wireshark.org/review/2237
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-06-17 17:16:56 +00:00
Stig Bjørlykke 235617399c Fix documentation for DissectorTable_get_dissector
Change-Id: Ic8db06249c6326505b7f5c4518c3af2c6961066a
Reviewed-on: https://code.wireshark.org/review/2234
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-06-15 17:56:25 +00:00
Hadriel Kaplan 2c1e673fa2 Allow chained calls with Lua TreeItem functions, and fix a couple of minor 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-28 04:27:43 +00:00
Hadriel Kaplan da1af6e549 Add filterable expert info for Lua
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-26 05:20:17 +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
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
Hadriel Kaplan 8a9bba861a Fix Bug 9853: 'Lua: trying to get/access a Preference before its registered causes a segfault'
Accessing a pref before it's registered causes a segfault, because prefs_p->next
is not being checked for NULL in wslua_proto.c:Prefs__index().

Change-Id: I270978ddb9238a9e8d2c533a96fc01ee0df385c7
Reviewed-on: https://code.wireshark.org/review/563
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-03-09 09:57:35 +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
Evan Huus 54cccefef6 Fix build with recent lua changes.
Use FT_NONE instead of 0 to initialize an enum.
Drop use of lround/llround since they are not available on Windows.

Change-Id: I3961c1921304bafc090c763f0d6de8532f0b3510
Reviewed-on: https://code.wireshark.org/review/425
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-02-27 22:00:49 +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 bd36fe1bcb Fix bug 6357: Lua all_field_infos() broken within tap/listener
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-25 21:06:50 +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
Hadriel Kaplan 7f074364b6 Fix bug 9790: Lua: wslua allows duplicate field registration
As discussed in bug 3513 and 9709, one can register more than one new ProtoFields for
the same field name. Of course C-code can do that too, and does a LOT apparently, but
if they're not similar ftypes then things can get scrweed up in display filters.

So this change prevents duplicate field registration of dissimilar ftypes. The
similarity is based on the discussion on the mailing list, and the listing in
README.developer has been updated to refelect that as well.

Also, this change adds a testscript for Proto/ProtoFields.

Change-Id: I43bd323f785245941a21289647332a19adec2a9d
Reviewed-on: https://code.wireshark.org/review/285
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-02-21 20:57:43 +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 2466a7c6f1 Fix Bug 9725 'Lua: ProtoField.new() is buggy'
Using ProtoField.new() is dicey.  Many of the optional arguments don't properly check the lua stack - they call lua_isnil() for their index number, instead of lua_gettop() to see the stack size.  lua_isnil() may return false in such cases.

Change-Id: I83ca1e5fc34e71ec35899adbedabcee69571b9fe
Reviewed-on: https://code.wireshark.org/review/118
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-02-05 07:40:01 +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
Alexis La Goutte 0ce7d1790d Make Buildbot Happy
Fix : ./wslua_proto.c:1261:1: error: 'ProtoField_systemid' defined but not used [-Werror=unused-function]

svn path=/trunk/; revision=54397
2013-12-23 18:12:04 +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 ae97f5d3bd Improved the valuestring documentation.
svn path=/trunk/; revision=54311
2013-12-20 21:15:04 +00:00
Evan Huus c38424311f Replace one more g_memmove with memmove, add a cast to make the Lua stuff
compile.

svn path=/trunk/; revision=54296
2013-12-20 14:45:24 +00:00
Stig Bjørlykke db3c476e6c Rewrote ProtoField_new to:
- Allow both string and integer for type and base (improve usability).
- Check valid base and mask for different types (avoid crashes).
- Remove ftypes.PROTOCOL from valid types.

This should fix bug #9549.

svn path=/trunk/; revision=54292
2013-12-20 13:33:48 +00:00
Jakub Zawadzki c67d38cf15 Rename base_display_* to field_display
This is preparation to support ->display for FT_STRING values.

svn path=/trunk/; revision=53820
2013-12-07 10:41:42 +00:00
Jakub Zawadzki 5518639af2 Fix buildbot:
wslua_proto.c(1700) : error C2065: 'TRY' : undeclared identifier

svn path=/trunk/; revision=53233
2013-11-10 16:57:29 +00:00
Michael Mann 02a8391535 Require dissector_try_string to pass a data parameter to its subdissectors. There weren't that many calls, so might as well modify the function than create a need for dissector_try_string_new.
svn path=/trunk/; revision=53049
2013-11-02 15:52:25 +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
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 9c3487a569 Added DissectorTable_set and DissectorTable_remove_all to simplify changing
registered port numbers in PROTO.prefs_changed.

Now we only need this code in Lua plugins having port numbers prefs:

PROTO.prefs.ports = Pref.range ("Ports", 0, "Port numbers", 65535)

PROTO.prefs_changed()
  local udp_table = DissectorTable.get ("udp.port")
  udp_table:set (PROTO.prefs.ports, PROTO)
end

svn path=/trunk/; revision=51860
2013-09-09 05:45:24 +00:00
Evan Huus 9507f56495 Fix lua docstring causing the buildbot's documentation step to fail.
svn path=/trunk/; revision=51828
2013-09-07 22:00:02 +00:00
Stig Bjørlykke 7d3d67407c Added support for a "prefs_change" function in Lua scripts, which is called
when the preferences for the dissector are changed.

This is not a 100% correct implementation at the time because the
prefs_changed function in all Lua plugins will be called whenever
a preference in a single Lua plugin is changed.

svn path=/trunk/; revision=51818
2013-09-07 11:27:38 +00:00
Stig Bjørlykke a8638eec90 Added support for integer range in DissectorTable_add and DissectorTable_remove.
This was requested in bug 6762.

svn path=/trunk/; revision=51817
2013-09-07 11:07:18 +00:00
Stig Bjørlykke 452bfe4ce0 A small documentation fix for DissectorTable_remove.
svn path=/trunk/; revision=51816
2013-09-07 11:01:52 +00:00
Stig Bjørlykke 6b93b0e1dc Added syntax and range checks for Lua Prefs.range default values.
Fixed some small memory leakages.

svn path=/trunk/; revision=51815
2013-09-07 10:56:52 +00:00
Stig Bjørlykke f9f29d0307 Make the Lua dissector "init" routine work again.
svn path=/trunk/; revision=51805
2013-09-06 22:22:27 +00:00
Stig Bjørlykke 0f13e3c95d Add support for 64 bit value string in Lua.
Lua cannot store a 64 bit integer with full precision, which is used
for keys in tables, so this is not a 100% solution.  But it will probably
be good enough for value strings, and it is better to have some support
than no support.

svn path=/trunk/; revision=50988
2013-07-28 20:59:59 +00:00
Stig Bjørlykke ca9c78088b Document that ProtoField INT64 and UINT64 does not support value string.
svn path=/trunk/; revision=50484
2013-07-10 16:51:54 +00:00
Stig Bjørlykke 5289c9564d Use luaL_optnumber for ProtoField mask, to avoid a signed cast.
This fixes bug 5734.

svn path=/trunk/; revision=50483
2013-07-10 16:33:30 +00:00
Guy Harris 001a6eb165 Squelch some "casting away constness" warnings.
svn path=/trunk/; revision=48542
2013-03-24 23:49:22 +00:00
Anders Broman e022d129bd From beroset:
made implicit casts explicit and changed a number of fields and function return values from base_display_e to unsigned because the enum was not a comprehensive list of all possible values

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416

svn path=/trunk/; revision=48289
2013-03-14 06:45:55 +00:00
Guy Harris 6b629c4d92 Move show_exception() and show_reported_bounds_error() to
epan/show_exception.c, as it's used outside
epan/dissectors/packet-frame.c.  Update their callers to include
<epan/show_exception.h> to get their declaration.

Add a CATCH_NONFATAL_ERRORS macro that catches all exceptions that, if
there's more stuff in the packet to dissect after the dissector call
that threw the exception, doesn't mean you shouldn't go ahead and
dissect that stuff.  Use it in all those cases, including ones where
BoundsError was inappropriately being caught (you want those passed up
to the top level, so that the packet is reported as having been cut
short in the capture process).

Add a CATCH_BOUNDS_ERRORS macro that catches all exceptions that
correspond to running past the end of the data for a tvbuff; use it
rather than explicitly catching those exceptions individually, and
rather than just catching all exceptions (the only place that
DissectorError should be caught, for example, is at the top level, so
dissector bugs show up in the protocol tree).

Don't catch and then immediately rethrow exceptions without doing
anything else; just let the exceptions go up to the final catcher.

Use show_exception() to report non-fatal errors, rather than doing it
yourself.
 
If a dissector is called from Lua, catch all non-fatal errors and use
show_exception() to report them rather than catching only
ReportedBoundsError and adding a proto_malformed item.

Don't catch exceptions when constructing a trailer tvbuff in
packet-ieee8023.c - just construct it after the payload has been
dissected, and let whatever exceptions that throws be handled at the top
level.

Avoid some TRY/CATCH/ENDTRY cases by using checks such as
tvb_bytes_exist() before even looking in the tvbuff.

svn path=/trunk/; revision=47924
2013-02-27 22:43:54 +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 d26c9b88cf Fix Lua 5.2 panic problems.
From Hadriel Kaplan, bug 7400 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7400)

svn path=/trunk/; revision=47874
2013-02-25 16:20:27 +00:00
Guy Harris 80b0bc752e Add a new WSLUA_CLASS_FNREG_ALIAS() macro to register methods where the
function name isn't the same as the method name; this is used if we're
providing compatibility aliases for method names.

Use WSLUA_CLASS_FNREG() and WSLUA_CLASS_FNREG_ALIAS() for all method
registrations.

Fix the spelling of "prepend", but leave a compatibility alias in place.

svn path=/trunk/; revision=47667
2013-02-15 01:38:45 +00:00
Guy Harris 8ed7a73e22 Fix a bunch of warnings.
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
sizeof.

Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
strtol() and strtoul().

Change some data types to avoid those implicit conversion warnings.

When assigning a constant to a float, make sure the constant isn't a
double, by appending "f" to the constant.

Constify a bunch of variables, parameters, and return values to
eliminate warnings due to strings being given const qualifiers.  Cast
away those warnings in some cases where an API we don't control forces
us to do so.

Enable a bunch of additional warnings by default.  Note why at least
some of the other warnings aren't enabled.

randpkt.c and text2pcap.c are used to build programs, so they don't need
to be in EXTRA_DIST.

If the user specifies --enable-warnings-as-errors, add -Werror *even if
the user specified --enable-extra-gcc-flags; assume they know what
they're doing and are willing to have the compile fail due to the extra
GCC warnings being treated as errors.

svn path=/trunk/; revision=46748
2012-12-26 05:57:06 +00:00
Stig Bjørlykke 37c7d006ad Added check for missing/empty ProtoField abbrev also in
integer, boolean, time and other cases.

svn path=/trunk/; revision=46302
2012-11-30 11:01:01 +00:00
Stig Bjørlykke a875f6a6e8 Added check for missing/empty ProtoField abbrev.
svn path=/trunk/; revision=46078
2012-11-18 19:15:34 +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
Anders Broman 45e9efc6a9 From Evan Huus:
Fix leaks

- don't g_strdup a string just to use it in a g_strdup_printf
- clean up properly in error cases in lua bindings
- misc. other missing g_free() calls
- one missing fclose() in the new 80211_utils

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7454

svn path=/trunk/; revision=43617
2012-07-09 01:56:27 +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
Chris Maynard 973b45c401 Add a "fallthrough" comment to avoid a missing break report from Coverity. Fixes Coverity CID 702382 Missing break in switch.
svn path=/trunk/; revision=42845
2012-05-25 01:49:49 +00:00
Anders Broman fec821f303 From Evan Huus:
Fix Three memory leaks and a bad if-condition, as caught by CppCheck.

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7272

svn path=/trunk/; revision=42738
2012-05-21 07:42: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
Anders Broman 48fc51f835 From Evan Huus: Fix memory leaks in wslua_proto.c
svn path=/trunk/; revision=42280
2012-04-27 05:51:47 +00:00
Jeff Morriss ea02598924 Fix the rest of of https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6764 :
The Lua API does not have FT_*, it has ftypes.*, so use that in the
documentation.  Also, list out each ft so the user knows what the available
options are.

svn path=/trunk/; revision=41035
2012-02-16 03:00:52 +00:00
Jeff Morriss 38550ff3ce Fix part of https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6764 :
The Lua API does not have BASE_*, it has base.*, so use that.  Also, list out
each base so the user knows what the available options are.

svn path=/trunk/; revision=41024
2012-02-14 03:37:19 +00:00
Jeff Morriss d92857dd6b As suggested in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6763 :
Give an example of a Pref.range's default value.

svn path=/trunk/; revision=41023
2012-02-14 03:24:19 +00:00
Guy Harris 6f59700722 Fix usage of g_ascii_strdown() and g_ascii_strup() - they do *not*
modify the string in place, they return a g_mallocated modified version
of the string passed into them.

svn path=/trunk/; revision=40727
2012-01-25 23:03:33 +00:00
Stig Bjørlykke 43c34aaf8e Do not return from within a TRY/CATCH/ENDTRY because this will make the
except stack invalid, and will lead to a crash.

In this case it was when calling a dissector from a table in a Lua script.

svn path=/trunk/; revision=39748
2011-11-07 07:41:03 +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 5a466a5246 Don't ep_strdup the protocol name when register a dissector, because
this name will be collected when loading a capture file and the name
will be gone.

svn path=/trunk/; revision=39681
2011-10-30 21:32:27 +00:00
Stig Bjørlykke 447de1178d Allow signed integers displayed as BASE_HEX_DEC.
svn path=/trunk/; revision=39571
2011-10-25 19:04:10 +00:00
Stig Bjørlykke 2d62e550b7 Added another Lua warning:
- FT_FRAMENUM can not have a bitmask.

svn path=/trunk/; revision=39563
2011-10-25 11:20:54 +00:00
Stig Bjørlykke 943c8b97ed Added Lua error messages when:
- Adding a INT64/UINT64 field with a value string (currently unsupported).
- Trying to display a signed integer as hexadecimal.

svn path=/trunk/; revision=39562
2011-10-25 11:13:11 +00:00
Stig Bjørlykke f7956e0e1d Add a method to fetch protocol description.
svn path=/trunk/; revision=38736
2011-08-25 18:52:54 +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
Jörg Mayer c15ff441c6 Replace deprecated glib functions.
In order to compile the whole project with -DG_DISABLE_DEPRECATED
the mate plugin needs to replace its usage of GMemChunk.
All other places should be clean.

svn path=/trunk/; revision=38392
2011-08-07 18:15:45 +00:00
Stig Bjørlykke a4dc6c0a7d Added check for invalid chars in abbrev in ProtoField functions.
This fixes bug 5569.

svn path=/trunk/; revision=37787
2011-06-25 19:39:16 +00:00
Stig Bjørlykke 1255b45566 Remove "range" from Lua's Pref.range(), as this value shall be fetched from
the "default".

This fixes bug 5896.

svn path=/trunk/; revision=37786
2011-06-25 15:42:41 +00:00
Stig Bjørlykke 0f24c1eb09 From Tony Trinh via bug 5894:
Added argument validation to Pref.range.

svn path=/trunk/; revision=37785
2011-06-25 15:24:55 +00:00
Stig Bjørlykke dfb3cde56b Use guint32 internally to store mask.
This may fix bug 5734.

svn path=/trunk/; revision=37762
2011-06-23 10:52:40 +00:00
Jeff Morriss fcac4a1d7d Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5930 :
with a variant of the patch submitted by Alexander Stein on the -dev list:

Allow FT_FRAMENUMs to be added (as base BASE_NONE).  My change from Alexander's
patch is to disallow BASE_NONE for non-framenum integers.

svn path=/trunk/; revision=37239
2011-05-18 15:33:07 +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
Guy Harris c0e5dc8489 Zero is zero is zero, as Gertrude Stein didn't say.
svn path=/trunk/; revision=36639
2011-04-14 06:28:25 +00:00
Bill Meier 8a07e469f3 Fix a number of msvc level 4 "Unreachable code" warnings by removing unneeded
return statements.

svn path=/trunk/; revision=35709
2011-01-30 22:32:25 +00:00
Guy Harris a8bc4a0d13 Rename the routines that handle dissector tables with unsigned integer
keys to have _uint in their names, to match the routines that handle
dissector tables with string keys.  (Using _port can confuse people into
thinking they're intended solely for use with TCP/UDP/etc. ports when,
in fact, they work better for things such as Ethernet types, where the
binding of particular values to particular protocols are a lot
stronger.)

svn path=/trunk/; revision=35224
2010-12-20 05:35:29 +00:00
Jeff Morriss 9f3acc1e25 Aw, man, I knew this code was parsed, but I missed the docbook part. Revert 34598 and 34599.
svn path=/trunk/; revision=34602
2010-10-21 12:41:15 +00:00
Jeff Morriss 383df3dfe5 Make the indentation consistent.
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-10-21 02:50:27 +00:00
Stig Bjørlykke 92312f16e9 Declare error as volatile to avoid warning on opensolaris:
variable 'error' might be clobbered by `longjmp' or `vfork'

svn path=/trunk/; revision=33754
2010-08-10 07:43:05 +00:00
Anders Broman 96e9317c66 From Tamas Regos:
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-12 10:31:41 +00:00
Anders Broman 0107015266 From Tamas Regos:
Whitspace changes

svn path=/trunk/; revision=32770
2010-05-12 08:08:01 +00:00
Jaap Keuter b1ddbed608 Fix for bug 4695:
Modify ProtoField_tostring() to ProtoField__tostring() 
and clean up description.

svn path=/trunk/; revision=32517
2010-04-19 18:48:12 +00:00
Stig Bjørlykke d1d432bd10 From Didier Gautheron via bug 4622:
Double and float are BASE_NONE not BASE_DEC.

svn path=/trunk/; revision=32320
2010-03-28 19:02:52 +00:00
Bill Meier 9c4e559887 Fix various gcc -Wshadow warnings.
svn path=/trunk/; revision=31716
2010-01-28 15:39:15 +00:00
Stig Bjørlykke 31e116d74a Use correct field types for signed integer.
svn path=/trunk/; revision=31449
2010-01-05 15:37:45 +00:00