aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua
AgeCommit message (Collapse)AuthorFilesLines
2019-12-18De-camel-ize "Wireshark" in a few places.Gerald Combs1-1/+0
The _wslua_main struct / WireShark class appears to have never been used, so remove it. Change-Id: Id80fb2c2065accedf632ea4cc467d566d10870de Reviewed-on: https://code.wireshark.org/review/35480 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2019-11-05funnel: Free callback dataStig Bjørlykke1-0/+1
Free one more allocated callback data in TextWindow. This is needed because text_win_close_cb() is also doing the same as TextWindow__gc(). Bug: 16177 Change-Id: I7c2211e154a6db1dccd22df824e76cce575040c9 Reviewed-on: https://code.wireshark.org/review/34990 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2019-11-05funnel: Free callback dataStig Bjørlykke2-2/+10
Free allocated callback data in FunnelStringDialog, TextWindow and registered menu items. Also free strings used in FunnelStringDialog. Bug: 16177 Change-Id: I9a129b8975a55d1dc89fe851116feebe82763bca Reviewed-on: https://code.wireshark.org/review/34945 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-10-28wslua: Fix memleak of unregistered ProtoExpertStig Bjørlykke2-4/+20
If a ProtoExpert object was created, but not linked to a Proto, then the object and some fields (abbrev, text) would leak. This is a follow-up to g79fef2ae. Change-Id: Ic0b44e8b70895a19d9b52a0e44064a1e76a58fa0 Reviewed-on: https://code.wireshark.org/review/34876 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
2019-10-28wslua: Fix memleak of unregistered ProtoField stringsStig Bjørlykke2-1/+3
If a ProtoField object was created, but not linked to a Proto, then the strings field and all elements (depending on type) would leak. This is a follow-up to g79fef2ae and fixes the real issue in g44870fb1. Change-Id: I01880a92bb20fae45f68c754b07daeb07630deec Reviewed-on: https://code.wireshark.org/review/34872 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Vasil Velichkov <vvvelichkov@gmail.com> Reviewed-by: Roland Knall <rknall@gmail.com>
2019-10-16wslua: Improve parameter check in ProtoField.new()Stig Bjørlykke1-10/+24
Improve paremeter check in ProtoField.new() when using ftypes.CHAR: - Check valid base types and give an error when not supported instead of terminate in a g_error() (base.DEC is not supported). - Give an error if used with base.UNIT_STRING instead of silently remove the flags. - Support base.RANGE_STRING instead of removing the flag. Support using base.NONE with a valuestring. Add ftypes.CHAR to the list of supported types. Change-Id: I0e3f9698074c807f5da0de23ccd1be7446271135 Reviewed-on: https://code.wireshark.org/review/34783 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-10-16wslua: Add ProtoField.char()Stig Bjørlykke1-4/+29
ProtoField.new() already support ftypes.CHAR, so add ProtoField.char() to complete the support for FT_CHAR in Lua. Change-Id: I0568f874fd667f834584a07af14bdda9bb03856b Reviewed-on: https://code.wireshark.org/review/34784 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-10-15Lua: Use space for indentStig Bjørlykke1-6/+6
Remove use of TAB. Change-Id: Ic2a08f6b325e1fc52a5b043aa09e8f98dacd8c5e Reviewed-on: https://code.wireshark.org/review/34780 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2019-10-14Lua: Support FT_CHAR in FieldStig Bjørlykke1-0/+1
Add support for fetching FT_CHAR field values. Bug: 16129 Change-Id: I0e3b0c784277e259fb7cd1725254fc7a723f6d1e Reviewed-on: https://code.wireshark.org/review/34775 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2019-07-28HTTPS In Even More Places, update some links.Guy Harris1-1/+1
Fall back on the Wayback Machine for some links. Change-Id: I6a44a2caaeb4fa521c2f08196e7c36069e3bb842 Reviewed-on: https://code.wireshark.org/review/34103 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-26HTTPS (almost) everywhere.Guy Harris29-29/+29
Change all wireshark.org URLs to use https. Fix some broken links while we're at it. Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c Reviewed-on: https://code.wireshark.org/review/34089 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-22wslua: pinfo: make p2p_dir accessible to lua dissectorsMartin Kaiser2-0/+9
Some dissectors populate pinfo->p2p_dir with a packet's direction (incoming / outgoing). Make this info available to lua dissectors. Add a simple test for Pinfo's new p2p_dir attribute to the wslua test suite. It checks that p2p_dir is unknown for dhcp packets. (The dhcp dissector does not set p2p_dir). Change-Id: I8cc39a11cff840d10ef7fa94d30cbac8bf9b533f Reviewed-on: https://code.wireshark.org/review/33935 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
2019-07-21Lua: remove lua_data_handlePeter Wu3-7/+2
Use call_data_dissector directly for the same effect as lua_data_handle. Remove the special case where DissectorTable.get_dissector() returns the data dissector for an unsupported type. The documentation says that nil is returned if the handle is not found, that seems more appropriate. Change-Id: I128ef90b79bda925a4329202a0b9956e1cf16200 Reviewed-on: https://code.wireshark.org/review/34032 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
2019-06-16wslua: add a Proto parameter to DissectorTable.new()Martin Kaiser1-4/+10
Add an optional paramter of type Proto to DissectorTable.new(). If the caller provides a Proto, we can get the protocol id and use it when we register the dissector table. Change-Id: I3ab0819c41fa97288ec962d8d495b63d4750ce4b Reviewed-on: https://code.wireshark.org/review/33608 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-06-16wslua: clean up DissectorTable_new()Martin Kaiser1-27/+32
Reorder the code to have a single return statement at the end. Take advantage of the fact that WSLUA_OPTARG_ERROR terminates the C function that called it. Do only the parameter checks in the switch-case statement. Get rid of the intermediate steps when we copy name and ui_name. Change-Id: Ie8917d19589a6ee16a4a5d14f2c1711d35cc8114 Reviewed-on: https://code.wireshark.org/review/33607 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx> Petri-Dish: Martin Kaiser <wireshark@kaiser.cx> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-06-14wslua: add support for ft_none dissector tablesMartin Kaiser1-2/+7
The C code introduced ft_none dissector tables some time ago. They have no indicator to select the next protocol, only Decode As is supported for them. Allow lua code to create ft_none dissector tables as well. The patch is trying to make as few changes as possible to DissectorTable_new(). Change-Id: Ie3ff58f092e6922ab7878d202c7484a64b2430a3 Reviewed-on: https://code.wireshark.org/review/33588 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx> Petri-Dish: Martin Kaiser <wireshark@kaiser.cx> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-05-26wslua: fix error handling for invalid dissector tableMartin Kaiser1-1/+1
Calling DissectorTables's try method for a dissector table of an unknown type crashes Wireshark. local dt = DissectorTable.get("iso14443.subdissector") dt:try(0, tvbuf, pinfo, tree) causes a segmentation fault Thread 1 "wireshark" received signal SIGSEGV, Segmentation fault. except_pop () at /media/sf_wireshark.git/epan/except.c:264 264 set_top(top->except_down); (gdb) print top $1 = (struct except_stacknode *) 0x2 (gdb) bt at /media/sf_wireshark.git/epan/packet.c:590 My gut feeling (I haven't verified this) is that we should not call luaL_error() inside a TRY-CATCH block. DissectorTable_try does this when the type of the dissector table is not supported. Fall back to the data dissector in this case and bring up an expert info instead of aborting the dissection completely. Change-Id: I9a49f738a99b2618014f41050d8c0bf6bfbb4138 Reviewed-on: https://code.wireshark.org/review/33357 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-05-26wslua: print the correct type for FT_NONE dissector tablesMartin Kaiser1-0/+5
We added FT_NONE dissector tables a while ago. These tables can only be used for Decode As. Support such dissector tables in lua's print() function. print(DissectorTable.get("iso14443.subdissector")) will now print DissectorTable iso14443.subdissector only for Decode As: Change-Id: I9f5a2f6d6b1edb2a53ca1d2c0ae158c16fddf05f Reviewed-on: https://code.wireshark.org/review/33356 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx> Petri-Dish: Martin Kaiser <wireshark@kaiser.cx> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-05-20wslua(pinfo): fix typoAlexis La Goutte1-2/+2
Change-Id: Ifc808baf3ea495f632be00bcfb122b78d80a7854 Reviewed-on: https://code.wireshark.org/review/33267 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-05-17Lua: define table.unpack for Lua 5.1 for compatibilityPeter Wu1-0/+8
Lua 5.2 moves unpack to table.unpack, be sure to define this for Lua 5.1 or LuaJIT. This fixes an error with https://github.com/Lekensteyn/kdnet when using LuaJIT. Change-Id: Ib9e4591d9edb1cb3b0c1e86172331055f9f457d9 Ping-Bug: 15745 Reviewed-on: https://code.wireshark.org/review/33046 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-05Have wtap_read() fill in a wtap_rec and Buffer.Guy Harris1-9/+9
That makes it - and the routines that implement it - work more like the seek-read routine. Change-Id: I0cace2d0e4c9ebfc21ac98fd1af1ec70f60a240d Reviewed-on: https://code.wireshark.org/review/32727 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-04-04epan: Convert our PROTO_ITEM_ macros to inline functions.Gerald Combs2-7/+7
Convert our various PROTO_ITEM_ macros to inline functions and document them. Change-Id: I070b15d4f70d2189217a177ee8ba2740be36327c Reviewed-on: https://code.wireshark.org/review/32706 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-02-26wslua: simplify __WSLUA_REGISTER_META and _CLASSMartin Kaiser1-8/+8
Get rid of ATTRS_BLOCK, which is either empty or sets a value for attr. We can initialize attr in any case, either to NULL or to the attributes provided by the caller. This makes the code a bit easier to read (at least for me). Change-Id: Ib26ea5ec099b365303de5aaf407470ad48b126f9 Reviewed-on: https://code.wireshark.org/review/32186 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx> Petri-Dish: Martin Kaiser <wireshark@kaiser.cx> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-02-07wslua: do not partially disable the Lua API when run as rootPeter Wu1-19/+6
Users should not be starting Wireshark as root user (sudo or root login). If they do, then they can already execute arbitrary code via C plugins, or read and write arbitrary files. Limiting the Lua API will not really help these users to prevent breaking their system further. Therefore remove all artificial restrictions and allow users to run user-supplied scripts by default. If for whatever policy reason this flag is set to false, then only Lua dissectors from the global system directory are executed. It is their responsibility not to provide a free root shell to the user. Note that "running_superuser" will also be true if setuid root while the effective and real user is no longer root. This happens due to relinquish_special_privs_perm(). In this case, disabling the Lua API is just annoying with no benefits. Change-Id: Ie8a38e6160d861f02cbb70dcd1d90462153f4665 Link: https://www.wireshark.org/lists/wireshark-dev/201902/msg00004.html Reviewed-on: https://code.wireshark.org/review/31913 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Dario Lombardo <lomato@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-02-07wslua: do not load console.lua when run as rootPeter Wu1-1/+3
dofile is currently disabled whenever Wireshark or tshark was started as root, calling it will result in Lua errors on startup. Even if dofile were not disabled, the Lua Evaluate menu option enables arbitrary Lua code execution. The other options (Console, help links) are not that important either, so just disable it when run as root. Change-Id: I0785fe9b3d4678d71ae1e0178811dada471c3525 Link: https://www.wireshark.org/lists/wireshark-dev/201902/msg00004.html Reviewed-on: https://code.wireshark.org/review/31912 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Dario Lombardo <lomato@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-29wslua: Don't defer deletion of subtree indexesStig Bjørlykke1-5/+2
The subtree indexes are only used in the dissector so it's not needed to defer the deletion. Change-Id: I33600897a186c078cc1021cde5a1d90054d475c8 Reviewed-on: https://code.wireshark.org/review/31800 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-29wslua: Update wslua_register_menu() documentationStig Bjørlykke2-1/+3
Add missing group values. Update regex to match TELEPHONY_MTP3. Change-Id: I709a416e30d79c2de69887548015a3c1ecfe5bab Reviewed-on: https://code.wireshark.org/review/31779 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-28wslua: Improve syntax error messageStig Bjørlykke1-3/+3
The filename is included in the error message from Lua so we don't need to display this twice. Change-Id: I00aa7255ff24b07b9f45a8e814a97b61c35936e1 Reviewed-on: https://code.wireshark.org/review/31768 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2019-01-28lua: fix build with Lua 5.1 due to missing LUA_OK macroPeter Wu1-1/+1
Change-Id: If367f79172c8222c65fd9d95a050e75194df852d Fixes: v2.9.1rc0-556-g6a49c72974 ("wslua: include Lua stack trace in startup error messages") Reviewed-on: https://code.wireshark.org/review/31771 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-28wslua: include Lua stack trace in startup error messagesPeter Wu1-6/+28
Error messages without a stack trace are rather hard to debug for more complex Lua dissectors. Be sure to append one, it will look like this: tshark: Lua: Error during loading: /tmp/kdnet/kdnet.lua:13: bad argument #3 to 'proto_field_constructor' (Display must be either base.NONE, base.DOT, base.DASH, base.COLON or base.SPACE) stack traceback: [C]: in function 'proto_field_constructor' /tmp/kdnet/kdnet.lua:13: in function 'add_field' /tmp/kdnet/kdnet.lua:35: in function 'add_fields' /tmp/kdnet/kdnet.lua:242: in main chunk It would be nice to reuse the error handler for dissector calls as well, but I am not sure whether this works with absolute indices which are used almost everywhere in wslua. Change-Id: I89b2dcd360fce3865e1bf052b9fe03e888aae167 Reviewed-on: https://code.wireshark.org/review/31763 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-27wslua_pinfo: fix memleaks on setting addresses in PinfoPeter Wu1-1/+5
Fixes memory leaks reported by ASAN for the test_wslua_pinfo test. Change-Id: Id7e79e63559db1e7f8b27d566048eab9268d9237 Reviewed-on: https://code.wireshark.org/review/31754 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-27wslua: fix memleak of unregistered ProtoField fieldPeter Wu2-2/+21
If a ProtoField object was created, but not linked to a Proto, then some fields (name, abbrev, blob) could leak. Fixes ASAN test failures for four wslua tests. Change-Id: I570ea154153b505ba81edb2bbf538e6dc1438728 Reviewed-on: https://code.wireshark.org/review/31750 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-27wslua: fix memleaks related to Proto and PrefPeter Wu4-46/+49
Proto objects were only freed while reloading Lua plugins, be sure to release these on program exit too. Fix missing deallocation of heur_list (matches per-protocol cleanup in proto_cleanup_base). Be sure to keep a reference to the "Pref" object after registering it to a Proto, otherwise it could be garbage-collected early, resulting in memleaks (because the preference was still in use). Fixes a lot of memory leaks reported by ASAN for tests, ten tests were affected by Proto_new leaks, four were affected by the new_pref leaks. Change-Id: Ica52718849a33eda614775f533dc0fcefec9cc74 Reviewed-on: https://code.wireshark.org/review/31746 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-27wslua_listener: fix memleak in tap packet callbackPeter Wu1-1/+4
Addresses memleaks reported by ASAN for: test_wslua_listener test_wslua_nstime test_wslua_pinfo test_wslua_field Change-Id: I221382844ee0bfd7ffc274bbb27eded0e221f9cf Reviewed-on: https://code.wireshark.org/review/31742 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-26wslua_field: fix memory leaks in Field_newPeter Wu2-40/+47
Change the "Field" type to actually point to a structure. Do not cheat and overload the pointer to mean "char*" in one context, and "header_field_info*" in another. It was very confusing. Implement Field__gc to free the Field structure that was allocated in Field_new. This fixes the memory leak in Field_new. Now the test_wslua_field test passes when executed with ASAN and a bunch of other wslua tests also improve. Change-Id: Ibc4318b76bb893151fd40c3fbc595402fba7a60a Reviewed-on: https://code.wireshark.org/review/31743 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2019-01-26wslua_nstime: fix memleak for bad arguments to NSTimePeter Wu1-4/+5
luaL_optinteger will raise an error when the argument is an invalid number. Delay the allocation to avoid a leak. Fixes the test_wslua_nstime test under ASAN. Change-Id: I6856fd218897565a60786d820f43192b41d489f2 Reviewed-on: https://code.wireshark.org/review/31744 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-26wslua_file_handler: fix leak of opt_commentPeter Wu2-1/+4
Since v2.9.1rc0-528-g31aba351e2, it is clear that wtap file formats should free earlier comments before writing a new one. Do so. Fixes leaks reported by ASAN for test_wslua_file_acme_reader. Change-Id: Iafb643f01f5973f2d3b88f244ee70e8c0c451080 Reviewed-on: https://code.wireshark.org/review/31738 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-25wiretap: fix memleaks with wtap_rec::opt_commentPeter Wu2-0/+6
The memory ownership of wtap_rec::opt_comment was not clear. Users of wtap were leaking memory (editcap.c). wtap readers were not sure about freeing old comments (erf) or simply ignored memleaks (pcapng). To fix this, ensure opt_comment is owned by wtap_rec and free it with wtap_rec_cleanup. The erf issue was already addressed since cf_get_packet_comment properly duplicates wth.opt_comment memory. - wtap file formats (readers): - Should allocate memory for new comments. - Should free a comment from an earlier read before writing a new one. - Users of wth: - Can only assume that opt_comment remains valid until the next read. - Can assume that wtap_dump does not modify the comment. - For random access (wtap_seek_read): should call wtap_rec_cleanup to free the comment. The test_tshark_z_expert_comment and test_text2pcap_sip_pcapng tests now pass when built with ASAN. This change was created by carefully looking at all users opt "opt_comment" and cf_get_packet_comment. Thanks to Vasil Velichkov for an initial patch which helped validating this version. Bug: 7515 Change-Id: If3152d1391e7e0d9860f04f3bc2ec41a1f6cc54b Reviewed-on: https://code.wireshark.org/review/31713 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Vasil Velichkov <vvvelichkov@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-21wslua: register attributes along with their classMartin Kaiser12-79/+24
At the moment, wslua first registers a class and then adds its attributes in a second step. This registration creates empty __getters and __setters tables which are later populated with the getter and setter methods of the attributes. Looking at the code and the comments, it seems that this was meant to be a temporary solution. Eventually, attributes should be stored in wslua_class' attrs field. The code to read and write attributes was already updated to handle this. Add new macros WSLUA_REGISTER_CLASS/_META_WITH_ATTRS that store the attributes in wslua_class. Defining new macros is simpler than modifying WSLUA_REGISTER_CLASS/_META to register attributes. If we did the latter, we'd have to add an empty attribute list for all classes without attributes. We can now drop the WSLUA_REGISTER_ATTRIBUTES macro and the wslua_reg_attributes function. Using this new way of registering attributes, the __getters and __setters tables are still available. The tests is the test suite that rely on those tables still pass. Change-Id: I526b9116435645c9c54ab69a05c3c7f3d459ec33 Reviewed-on: https://code.wireshark.org/review/31417 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx> Petri-Dish: Martin Kaiser <wireshark@kaiser.cx> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-09Clarify the name and description for a link-layer encapsulation type.Guy Harris1-2/+2
What we were calling the "name" is actually a description to show to users; what were calling the "short name" is just the name to use on the command line. Rename some routines and structure members, and put the name first and description second in the table. Expand some descriptions to give more details (e.g., to be more than just a capitalized version of the name). Fix the CamelCase capitalization of InfiniBand. Change-Id: I060b8bd86573880efd0fab044401b449469563eb Reviewed-on: https://code.wireshark.org/review/31472 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-01Add a "failed" return for tap packet routines.Guy Harris1-4/+7
This allows taps that can fail to report an error and fail; a failed tap's packet routine won't be called again, so they don't have to keep track of whether they've failed themselves. We make the return value from the packet routine an enum. Don't have a separate type for the per-packet routine for "follow" taps; they're expected to act like tap packet routines, so just use the type for tap packet routines. One tap packet routine returned -1; that's not a valid return value, and wasn't one before this change (the return value was a boolean), so presume the intent was "don't redraw". Another tap routine's early return, without doing any work, returned TRUE; this is presumably an error (no work done, no need to redraw), so presumably it should be "don't redraw". Clean up some white space while we're at it. Change-Id: Ia7d2b717b2cace4b13c2b886e699aa4d79cc82c8 Reviewed-on: https://code.wireshark.org/review/31283 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-12-30Revert "Add routines to load Lua programs that assume the path is UTF-8 on ↵Peter Wu2-171/+2
Windows." This reverts commit 5953756305388724545f0df46d286be2f02c048a. The public API should not be polluted with Windows-specific hacks. As we already override dofile/loadfile, those should be fixed instead. Ping-Bug: 15118 Change-Id: Ia9d5e64e8ef14032f982f695ffd4cac59067bb17 Reviewed-on: https://code.wireshark.org/review/31134 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-12-29Lua: fix crash in reloading Lua plugins that use FileHandlerPeter Wu1-18/+43
Reloading Lua plugins did not actually remove registered FileHandler instances which resulted in a use-after-free of lua_State. Fix this by tracking instances and release them in wslua_deregister_filehandlers. Other required fixes to allow reregistration after reloading: - Fix END_FILEHANDLER_ROUTINE not to block all new registrations. - wtap file subtypes are apparently persistent, even after "unregistering". Fix this by looking up the previous subtype that matches the FileHandler short name. Add a small sanity check to wtap_register_file_type_subtypes to prevent internal handlers from being overwritten. This patch creates a potential memleak of registered_file_handlers as wslua_deregister_filehandlers is not called on program exit (yet?). Bug: 13264 Change-Id: I4f5935cde6ff8dc4de333359bad3efca96d4fb9b Reviewed-on: https://code.wireshark.org/review/31068 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-12-27Try to squeeze some bytes out of the frame_data structure.Guy Harris2-3/+3
Make the time stamp precision a 4-bit bitfield, so, when combined with the other bitfields, we have 32 bits. That means we put the flags at the same structure level as the time stamp precision, so they can be combined; that gets rid of an extra "flags." for references to the flags. Put the two pointers next to each other, and after a multiple of 8 bytes worth of other fields, so that there's no padding before or between them. It's still not down to 64 bytes, which is the next lower power of 2, so there's more work to do. Change-Id: I6f3e9d9f6f48137bbee8f100c152d2c42adb8fbe Reviewed-on: https://code.wireshark.org/review/31213 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-12-18Lua: Fix compilation with Lua 5.1.Gerald Combs1-0/+5
Change-Id: Idd4aa36ee95e985560867094d423128e51aacfb1 Reviewed-on: https://code.wireshark.org/review/31095 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-12-17Add routines to load Lua programs that assume the path is UTF-8 on Windows.Guy Harris2-2/+166
Add ws_dofile() and ws_loadfile(), which are like the substitute dofile() and loadfile() we provide, but that, on Windows, take a UTF-8 path rather than a path in the local code page. Use that to load console.lua. This means we can load console.lua on Windows even if the full path to it includes non-ASCII characters. Bug: 15118 Change-Id: Iaa00639563fe53a34e1e24e42022f3886a38e7c5 Reviewed-on: https://code.wireshark.org/review/31075 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-12-03CMake: Simplify CMAKE_INSTALL_DATADIR usageJoão Valverde1-7/+1
Change-Id: I414aa551b8e9315a654f4da62b882e787d4f6d53 Reviewed-on: https://code.wireshark.org/review/30904 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2018-11-29CMake: Change some install() paths to match NSIS packageJoão Valverde1-1/+7
Currently our Windows code looks for data files in the same folder as the binary executable (presumably to make the application relocatable, although it should be possible to improve this with relative paths?). Ping-Bug: 15301 Change-Id: I0fef4e87dc9d1d8edef81dd11755761fddd0fd12 Reviewed-on: https://code.wireshark.org/review/30819 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2018-11-16Use an enum for compression types in various interfaces.Guy Harris3-5/+5
This: 1) means that we don't have to flag the compression argument with a comment to indicate what it means (FALSE doesn't obviously say "not compressed", WTAP_UNCOMPRESSED does); 2) leaves space in the interfaces in question for additional compression types. (No, this is not part 1 of an implementation of additional compression types, it's just an API cleanup. Implementing additional compression types involves significant work in libwiretap, as well as UI changes to replace "compress the file" checkboxes with something to indicate *how* to compress the file, or to always use some other form of compression). Change-Id: I1d23dc720be10158e6b34f97baa247ba8a537abf Reviewed-on: https://code.wireshark.org/review/30660 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-11-16Use the dump parameters structure for non-pcapng-specific stuff.Guy Harris1-7/+6
Use it for all the per-file information, including the per-file link-layer type and the per-file snapshot length. Change-Id: Id75687c7faa6418a2bfcf7f8198206a9f95db629 Reviewed-on: https://code.wireshark.org/review/30616 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>