Wireshark-bugs: [Wireshark-bugs] [Bug 4700] New: WSLUA improvement (ProtoField.bool extension)
Date: Mon, 19 Apr 2010 17:55:13 -0700 (PDT)

           Summary: WSLUA improvement (ProtoField.bool extension)
           Product: Wireshark
           Version: SVN
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Low
         Component: Wireshark
        AssignedTo: wireshark-bugs@xxxxxxxxxxxxx
        ReportedBy: tamas.regos@xxxxxxxxxxxx

Build Information:
Version 1.3.5-wslua-improvements

Copyright 1998-2010 Gerald Combs <gerald@xxxxxxxxxxxxx> and contributors.
This is free software; see the source for copying conditions. There is NO

Compiled with GTK+ 2.16.6, with GLib 2.22.4, with WinPcap (version unknown),
with libz 1.2.3, without POSIX capabilities, without libpcre, with SMI 0.4.8,
with c-ares 1.7.1, with Lua 5.1, without Python, with GnuTLS 2.8.5, with Gcrypt
1.4.5, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Apr 19
2010), with AirPcap, with new_packet_list.

Running on 32-bit Windows Vista Service Pack 1, build 6001, with WinPcap
4.1.1 (packet.dll version, based on libpcap version 1.0 branch
1_0_rel0b (20091008), GnuTLS 2.8.5, Gcrypt 1.4.5, without AirPcap.

Built using Microsoft Visual C++ 9.0 build 30729

Wireshark is Open Source Software released under the GNU General Public

Check the man page and http://www.wireshark.org for more information.
I'd like to introduce a 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])

The required modifications are attached in .diff patch files. All of them has
some extra reformatting (unnecessary white space removals) too.
The following file revisions were the latest one in SVN (under trunk).

wslua.diff (for rev 31716)
1 main change in typedef struct _wslua_field_t
- value_string* vs;
+ const void* vs;

wslua_tree.diff (for rev 31401)
1 main change which is actually a bug and it affects this improvements.
Do I need to create a separate bug for this in case of correcting this for
version 1.2.x?

- item =
+ item =

lua_toboolean <-> luaL_checknumber
This must be checknumber, otherwise with lua_boolean we mask the input octet to
1 bit...

wslua_proto.diff (for rev 32320)
This has the most changes.

Changes in static const struct base_display_string_t base_displays[]
New function: static true_false_string* true_false_string_from_table(lua_State*
L, int idx)
Changes in WSLUA_CONSTRUCTOR ProtoField_new(lua_State* L)
New function: static int ProtoField_boolean(lua_State* L, enum ftenum type)
New definition: #define PROTOFIELD_BOOL(lower,FT) static int
ProtoField_##lower(lua_State* L) { return ProtoField_boolean(L,FT); } 
New definition: PROTOFIELD_BOOL(bool,FT_BOOLEAN)
Changes in WSLUA_METAMETHOD ProtoField_tostring(lua_State* L)

An example:
Old: ProtoField.bool("proto.sig_ind", "Signalling Indication", "Signalling
New: ProtoField.bool("proto.sig_ind", "Signalling Indication", 8, gtp_sig_ind,
QOS_SIG_IND_MASK, "Signalling Indication")
  gtp_sig_ind = {
      "Optimised for signalling traffic", -- if true; index 1 is hardcoded in
      "Not optimised for signalling traffic" -- if false; index 2 is hardcoded
in wslua_proto.c

If these changes will be committed/approved then the Wireshark's Lua API
Reference Manual should be also updated like this:
http://www.wireshark.org/docs/wsug_html_chunked/wsluarm_modules.html ProtoField.bool(abbr, [name], [bitfield], [true_false_string],
[mask], [desc])

    Abbreviated name of the field (the string used in filters)

name (optional)
    Actual name of the field (the string that appears in the tree)

bitfield (optional)
    Number of bits in the field containing the bitfield (e.g.: BASE_NONE, 8,
16, 24, 32, 64)

true_false_string (optional)
    A table containing the text that corresponds to true and false values

mask (optional)
    Integer mask of this field

desc (optional)
    Description of the field

Is a separated bug needed for the doc?


Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.