Wireshark mailing list archives

Re: accessing multiple occurrences of the same field with lua


From: Hadriel Kaplan <HKaplan () acmepacket com>
Date: Sat, 9 Mar 2013 15:09:51 +0000


On Mar 9, 2013, at 3:41 AM, Cristian Constantin <const.crist () googlemail com> wrote:
cristian: if I need tag as a number I should use:

tonumber (tostring (tag))

right?


You can do it that way - but looking at the C-code it looks like you can also just do this:
    local myval = tag.value
or this:
    local myval = tag()

In both of those cases 'myval' will be a Lua number of the tag value as well, because a FieldInfo object for a 
"m3ua.parameter_length" field value is a FT_UINT16 type internally, so getting its value should get you a Lua number.  
Any FieldInfo of an internal type FT_FLOAT/DOUBLE/UINTx/INTx will give a Lua number when its value is retrieved. 
(except FT_UINT64/FT_INT64)  Or at least the code looks like it will do that, I haven't tried it myself.

-hadriel

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe


Current thread: