Wireshark-dev: Re: [Wireshark-dev] Does lua provide something like range strings?
From: Richard Sharpe <[email protected]>
Date: Wed, 10 Oct 2018 09:40:19 -0700
On Wed, Oct 10, 2018 at 9:30 AM Peter Wu <[email protected]> wrote:
>
> On Tue, Oct 09, 2018 at 11:38:29AM -0700, Richard Sharpe wrote:
> > On Tue, Oct 9, 2018 at 7:14 AM Peter Wu <[email protected]> wrote:
> > >
> > > Hi Richard,
> > >
> > > On Mon, Oct 08, 2018 at 10:59:35AM -0700, Richard Sharpe wrote:
> > > > I am wondering if the Lua interp in Wireshark provides the equivalent
> > > > of range strings?
> > > >
> > > > Does anyone know?
> > > >
> > > > I guess I could make the indexes strings, since they are associative
> > > > arrays anyway but looking up a value in a range would be difficult.
> > >
> > > There does not seem to be support for range strings, but it could be
> > > added. See value_string_from_table in epan/wslua/wslua_proto_field.c for
> > > an example.
> > >
> > > I suppose that the natural syntax would be:
> > >
> > >     local your_range_string = {
> > >         { 0, 24, "First quarter" },
> > >         { 25, 54, "Second quarter" },
> > >     };
> >
> > Hmmm, I think it might need more than that:
> >
> > #define WSLUA_OPTARG_ProtoField_new_VALUESTRING 4 /* A table
> > containing the text that
> >         corresponds to the values, or a table containing unit name for
> > the values if base is
> >         `base.UNIT_STRING`, or one of `frametype.NONE`,
> > `frametype.REQUEST`, `frametype.RESPONSE`,
> >         `frametype.ACK` or `frametype.DUP_ACK` if field type is
> > ftypes.FRAMENUM. */
> >
> > The code handling a new ProtoField assumes that arg 4 is a ValueString
> > ... there would have to be some way to indicate that it is a range
> > string.
> >
> > The BASE field is field 5. We could have symbols ORed into that, I guess.
>
> Right, the current documentation already contains a case for
> base.UNIT_STRING, you would have to add an additional base.RANGE_STRING.
>
> Will you be working on this feature?

I have started. Give me a few days.

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)(传说杜康是酒的发明者)