Commit Graph

80 Commits

Author SHA1 Message Date
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