Commit Graph

87 Commits

Author SHA1 Message Date
Hadriel Kaplan 281055af9c Lua: add functions for more field information
Add Lua functions so a plugin can introspect field information, such
as the type of field, flags, tvb, etc. Also add a couple of Tvb and
ByteArray methods. And cleanup the TreeItem code a little.

Change-Id: I7b58ce589ace91cce14b8abccd01ceabb63e2653
Reviewed-on: https://code.wireshark.org/review/6500
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.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>
2015-07-09 01:49:11 +00:00
Gerald Combs cac102eee3 Change a lot of http:// URLs to https://.
Most of our sites are now HTTPS-only. Update URLs accordingly. Update
other URLs while we're at it. Remove or comment out dead links.

Change-Id: I7c4f323e6585d22760bb90bf28fc0faa6b893a33
Reviewed-on: https://code.wireshark.org/review/7621
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-03-10 19:30:50 +00:00
Guy Harris 56446270f9 "Break" the Acme reader so that the tests work.
We don't want to have to change the pcap-ng file against which we
compare, so we hardcode the year here to be the same as the year from
the pcap-ng capture.

Change-Id: Ibd83d06e035341f617b8285f6ba51c749c38a177
Reviewed-on: https://code.wireshark.org/review/7448
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-03-01 07:13:02 +00:00
Hadriel Kaplan ceb8d954d2 Lua: Expose tcp_dissect_pdus() to Lua
Provide a way for Lua-based dissectors to invoke tcp_dissect_pdus()
to make TCP-based dissection easier.

Bug: 9851
Change-Id: I91630ebf1f1fc1964118b6750cc34238e18a8ad3
Reviewed-on: https://code.wireshark.org/review/6778
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Hadriel Kaplan <hadrielk@yahoo.com>
2015-01-27 15:14:12 +00:00
Guy Harris 612e286b9e Fix test script to test Lua Pinfo, and fix problem it found.
The test script was running lua/nstime.lua rather than lua/pinfo.lua for
the Pinfo test, and the Pinfo test was testing the ipproto property for
a Pinfo, but that was removed.

Change-Id: Iccdccd265dd550e41640af3acd607362f1f2f02e
Reviewed-on: https://code.wireshark.org/review/6747
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-23 01:52:24 +00:00
Hadriel Kaplan 3cc6aee32a Lua: regex test suite fails with UTF-8 locale
Due to the change in change-id Ib43e16a9d98d08e5ddaff81fd3235f5b64d7b95b, the setlocale() call has been moved earlier in tshark's processing, such that Lua plugins load with the environment locale instead of C-locale. Since that matches Wireshark's behavior, it's good, but it causes the Lua regex test suite to fail. So the test suite needs to be fixed.

Bug: 10824
Change-Id: I3dcad15a9e247a1e42d2f708ccfb7272de2fe960
Reviewed-on: https://code.wireshark.org/review/6226
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
2015-01-02 13:09:16 +00:00
Hadriel Kaplan f7b6dcc58c Lua: allow a Dissector object to be passed in for register_heuristic
Bug: 10695
Change-Id: I81181b2d00fcb5f0c25ab89bbe4968897f47a3a6
Reviewed-on: https://code.wireshark.org/review/6131
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-12-31 16:01:51 +00:00
Hadriel Kaplan 2391a436e6 Bug 10233 - Wireshark crashes if Lua heuristic dissector returns true
Because call_heur_dissector_direct() didn't set the pinfo->heur_list_name
before calling the heuristic dissector, heur_dissect_lua() would invoke
report_failure().  Unfortunately, calling report_failure() within a dissector
can cause problems because GTK continues invoking timed callbacks while
it displays the modal dialog created by report_failure()... without yet
returning from report_failure().  In such a case, it's possible for
epan_dissect_run() to be called while still within the execution of a
previous call to epan_dissect_run(), which casues an assert since
epan_dissect_run() is not reentrant.

So this commit both fixes the call_heur_dissector_direct() bug as well
as avoids using report_failure() within heur_dissect_lua().  It also
upadtes the dissector.lua script used in the testsuite to match the one
pubshied on the wiki, since that script's heuristic dissector triggered
the bug.

Bug: 10233
Change-Id: If022604347745fadac01c02d370ca1a5d3f88b5b
Reviewed-on: https://code.wireshark.org/review/6040
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
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:13:56 +00:00
Michael Mann 6d207fe5f4 Remove private_data member from packet_info structure.
Dissectors should pass data directly to their subdissectors through the data parameter (of new-style dissectors). This avoids unintentional "trampling" from other dissectors trying to "share" private_data member.

Change-Id: I2efef5c8dfeef64588ba3ac6e695b469238c6468
Reviewed-on: https://code.wireshark.org/review/5487
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-12-01 14:05:44 +00:00
Evan Huus 45fb37718e Fix lua bindings to handle timestamp precision changes
The recent wiretap changes broke the generation of init.lua among other things,
though it did coincidentally fix one of the "yuck" comments in the generator
regex.

(Note that this is entirely untested, because out-of-tree init.lua is and always
has been broken, but it should work)

Change-Id: Id0c27b31c596613997de4ba2f6088eb9d6c8fc53
Reviewed-on: https://code.wireshark.org/review/4361
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-09-29 02:35:29 +00:00
Guy Harris 6db77b000f Allow wtap_read() and wtap_seek_read() to return records other than packets.
Add a "record type" field to "struct wtap_pkthdr"; currently, it can be
REC_TYPE_PACKET, for a record containing a packet, or
REC_TYPE_FILE_TYPE_SPECIFIC, for records containing file-type-specific
data.

Modify code that reads packets to be able to handle non-packet records,
even if that just means ignoring them.

Rename some routines to indicate that they handle more than just
packets.

We don't yet have any libwiretap code that supplies records other than
REC_TYPE_PACKET or that supporting writing records other than
REC_TYPE_PACKET, or any code to support plugins for handling
REC_TYPE_FILE_TYPE_SPECIFIC records; this is just the first step for bug
8590.

Change-Id: Idb40b78f17c2c3aea72031bcd252abf9bc11c813
Reviewed-on: https://code.wireshark.org/review/1773
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-24 18:31:25 +00:00
Evan Huus a1e6b10239 Fix lua directory tests.
The underlying directory iterator is not guaranteed to return directories in the
same order according to the glib documentation, so don't rely on the directory
order being the same when testing it.
https://developer.gnome.org/glib/2.37/glib-File-Utilities.html#g-dir-read-name

Bug:10009
Change-Id: I4b1078e1f3981921b1e83c4f77b4bc30a5d21b46
Reviewed-on: https://code.wireshark.org/review/1671
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-21 03:17:15 +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 dd002649c3 Add tvb_get and proto_tree_add for string-encoded timestamps
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-04-14 11:47:39 +00:00
Hadriel Kaplan 8c2bb80574 Add various functions for Lua directory handling and path info
This adds new functions to get plugins path info, find out if a directory
exists, make a new one, remove one, etc. It also creates a file environment
for user-supplied Lua scripts, to prevent global variable contamination as
well as supply the script-specific file name.  Some other minor cleanup was
done as I found them.

A new testsuite was added to test the existing and new directory functions.

Change-Id: I19bd587b5e8a73d89b8521af73670e023314fb33
Reviewed-on: https://code.wireshark.org/review/832
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-26 07:37:34 +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 21a61a8cb1 Add Lua Struct.values() function, and prevent coercion in all Struct functions
This adds a Struct.values() function to get the number of values
needed/returned with Struct.pack/unpack. It also changes the existing
Struct functions such that they don't coerce a non-string argument
into a string. (not preventing it confused a user on ask.wireshark.org)

Change-Id: I93d5846105e55b67680e1c276a7286535c77b039
Reviewed-on: https://code.wireshark.org/review/790
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-23 07:05:30 +00:00
Hadriel Kaplan 69af33f0f3 Fix spelling mistakes in Lua test scripts
Change-Id: I8671eb3d3b46ec5c723a6545451ecbb33a10c807
Reviewed-on: https://code.wireshark.org/review/788
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-03-22 17:42:16 +00:00
Hadriel Kaplan 66719c9b6a Add way for Lua file reader to save state per file read/write ops
Lua can create a file reader/writer, to open new capture file
formats or write to new ones. To save local state, it can save
things in Lua itself; but since there can be multiple open files
at the same time (for example during a reload), the Lua script
won't know for which file and state its read/write functions are
being invoked for. To remedy this, and also provide a convenient
way to store such state, this commit adds the ability for a Lua
script to store a Lua table in the wtap/wtap_dumper's priv
data member, just like C-code-based reader/writers do.

Change-Id: Ifc9e0d5f0379accee56f2a04b6080238670fec52
Reviewed-on: https://code.wireshark.org/review/766
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-22 08:06:47 +00:00
Hadriel Kaplan c8a98f37ec Fix lua file testsuite not working and weak heuristic readers not being registered
The testsuite for Lua file reader/writer uses the acme_file.lua script to
generate a pcapng file from an Acme sipmsg.log file. It then compares the
tshark verbose output of this new pcapng file to a sip.pcapng file in
the test/captures directory that was previously made. Unfortunately, the
acme_file.lua script generates a timestamp based on local system timezone,
rather than UTC, so the testsuite fails if not run in the EST timezone where
the sip.pcapng file was originally made. This has now been fixed.

Also, trying to register new weak heuristic readers fails because the GArray
is terminated with a NULL-based row without Glib knowing about that. So this
commit changes it to let Glib handle the NULL-terminated row, so that appending
takes it into account automatically.

Change-Id: I037ce1cfbda03585b3a1e159df78ff8ebb41fc32
Reviewed-on: https://code.wireshark.org/review/741
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-03-19 17:02:40 +00:00
Michael Mann 04d9501306 Add capture file reader/writer support for Lua so scripts can implement new capture file formats.
This enables a Lua script to implement a brand new capture file format reader/writer, so that for example one could write a script to read from vendor-specific "logs" of packets, and show them as normal packets in wireshark.

Change-Id: Id394edfffa94529f39789844c382b7ab6cc2d814
Reviewed-on: https://code.wireshark.org/review/431
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-19 05:04:54 +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 9961ee369c Fix Bug 9870 'Lua: trying to call/get an invalid name results in a get-loop error'
Due to the change I made previously for how methods are accessed, if you try
to access one that doesn't exist (for example mistype it or whatever), you get
an internal Lua error about a loop in table get, as opposed to the right error
message about the field not existing.

That's because I had set the class' metatable __index metamethod to point to
the class table, which of course has the metatable with the __index
metamethod, causing a lookup loop.  Blech.

Change-Id: I20d3717feadd45f652c2640e1671846184e7082d
Reviewed-on: https://code.wireshark.org/review/593
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-11 05:30:58 +00:00
Hadriel Kaplan ea46cdc474 Add GLib's regex library into Lua
While Lua's built-in pattern support is ok for simple things, many people end
up wanting a real regex engine. Since Wireshark already includes the GLib
Regex library (a wrapper for PCRE), it makes sense to expose that library to
Lua scripts. This has been done using Lrexlib, one of the most popular regex
bindings for Lua. Lrexlib didn't support binding GLib's Regex in particular -
it does for PCRE but GLib is a different API - so I've done that. A fairly
thorough testsuite came along with that, which has been incorporated into the
wireshark wslua testuites as well in this commit.

Change-Id: I05811d1edf7af8d7c9f4f081de6850f31c0717c7
Reviewed-on: https://code.wireshark.org/review/332
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-10 07:11:12 +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
Pascal Quantin 58db464aff Remove executable bit from a few files
Change-Id: Ib9be221e3d325379c8b665ab73d976254bb23bb6
Reviewed-on: https://code.wireshark.org/review/342
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-02-24 22:34:26 +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 696353c129 Add test suite for verifying Lua global variables/tables of previous releases have not disappeared.
Several bugs have been introduced due to changing of perl scripts or #define names, such
that things exported into Lua have dissapeared or changed unintentionally. This commit
adds a test suite which compares the Lua global table with the ones from previous
releases (1.8 and 1.10), to verify nothing has gone missing. New items can be added, but
old ones cannot go away. The added script to verify these things, called 'verify_globals.lua',
also has the ability to display what's new - i.e., what was not in the olrder releases.

Lastly, this commit also fixes a bug: MENU_STAT_ENDPOINT became MENU_STAT_ENDPOINT_LIST
due to a change in the make-init-lua.pl perl script in this 1.11 release.

Change-Id: Iba143d1a436e706970635a5f8cc2b317955392bf
Reviewed-on: https://code.wireshark.org/review/284
Reviewed-by: Evan Huus <eapache@gmail.com>
Tested-by: Evan Huus <eapache@gmail.com>
2014-02-21 16:28:07 +00:00
Evan Huus 3f2be6dbe8 Revert "Add test suite for verifying Lua global variables/tables of previous releases have not disappeared."
This reverts commit 5b7f00178f.

Change-Id: Idf09d25270847970713b67d02bcd7cbc411a4e9c
Reviewed-on: https://code.wireshark.org/review/280
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-02-21 02:16:51 +00:00
Hadriel Kaplan 5b7f00178f Add test suite for verifying Lua global variables/tables of previous releases have not disappeared.
Several bugs have been introduced due to changing of perl scripts or #define names, such
that things exported into Lua have dissapeared or changed unintentionally. This commit
adds a test suite which compares the Lua global table with the ones from previous
releases (1.8 and 1.10), to verify nothing has gone missing. New items can be added, but
old ones cannot go away. The added script to verify these things, called 'verify_globals.lua',
also has the ability to display what's new - i.e., what was not in the olrder releases.

Lastly, this commit also fixes a bug: MENU_STAT_ENDPOINT became MENU_STAT_ENDPOINT_LIST
due to a change in the make-init-lua.pl perl script in this 1.11 release.

Change-Id: Ic46172904256dc535b0fe4543237c07dddb3b9b5
Reviewed-on: https://code.wireshark.org/review/242
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-02-21 02:06:18 +00:00
Hadriel Kaplan fe769e7350 Add 4 more test scripts for Lua, and its own testsuite menu
This adds test scripts for verifying Pinfo, Address, Field, FieldInfo, NSTime
and Listener classes/functions.  It also moves Lua test scripts out of
unittests and into its own new testsuite.

Change-Id: I65c238fd459efb96db3f8f9145842cd038dea7c7
Reviewed-on: https://code.wireshark.org/review/270
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-02-20 18:42:13 +00:00
Hadriel Kaplan c4f1777a97 Adds support for Lua struct library so one can pack/unpack binary structures
This is based on Roberto Ierusalimschy's struct library, along with additional
options based on Flemming Madsen's patch to the lua-users mailing list, and
some changes I made to support 64-bit integer packing/unpacking.  Details
are in the top comments for wslua_struct.c.  This also includes a test script.

Change-Id: Ifcd0116ba013d5c760927721c8d6e9f28965534b
Reviewed-on: https://code.wireshark.org/review/98
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-02-14 10:11:50 +00:00
Hadriel Kaplan 58fe488822 Lua: add ability for scripts loaded from command-line to be passed arguments
This change adds the ability to pass on to lua scripts loaded from the
command-line (tshark or wireshark) additional arguments supplied by the
command-line.  This will help us in our testsuites, but also might be
useful for user-created scripts.  The additional arguments are passed in
using the '-X' eXtension switch.

Change-Id: Ib94cdf1ffd194ca84692fee7816665e4ff95efbd
Reviewed-on: https://code.wireshark.org/review/156
Reviewed-by: Evan Huus <eapache@gmail.com>
Tested-by: Evan Huus <eapache@gmail.com>
2014-02-13 22:32:58 +00:00
Hadriel Kaplan f5a1786ea1 Add test suite for Lua dissector-related functions
This isn't super-fancy, but it runs a simple protocol dissector and verifies the tshark output
matches what it expects.  Things like Proto, ProtoField, Field, Tvb, TvbRange, etc., are used
in an example dissector script - it dissects DNS... partially.  Enough to make sure things
aren't fundamentally broken.  This provides something to add on top of later as well.

Change-Id: Icf3c8e9534944bcf4c4f6150f02a9a43f999cd75
Reviewed-on: https://code.wireshark.org/review/126
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-02-09 19:55:43 +00:00
Hadriel Kaplan 4e8832bb0a Fix bug 9736 'Lua: new Int64/UInt64 functions don't prevent division by zero'
OK, in all fairness this does a bit more than just fix that bug. It also
adds a 'Int64()' and 'UInt64()' __call metamethods. I generally dislike
using __call metamethods, because they're often unintuitive (for example
the wireshark Field and FielInfo use this in a bizarre fashion).  But this
happens to be a perfect use for it, and very natural, imho.  Another change
is to make the metatables of classes visible to scripts. There was never
really a good reason not to make them visible, and they have to be visible
to do things like use __call on a plain table... not to mention I need them
to be visible to run test scripts verifying evrything is kosher.

I also updated the test suite to test for the div/mod by zero.

Change-Id: Ia4c594c8f59d4e799090716bd032ba2815df032f
Reviewed-on: https://code.wireshark.org/review/149
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-02-09 16:04:36 +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