ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] range_string does not work?

From: "Zhang, Long \(Roger\)" <zhangl@xxxxxxxxxxxxxxxxxx>
Date: Thu, 8 Jan 2009 09:23:32 +0800

Thanks! I tried with mask 0x0. It works. But not for 0x7.

 

Roger

 


From: wireshark-dev-bounces@xxxxxxxxxxxxx [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] On Behalf Of Anders Broman
Sent: Wednesday, January 07, 2009 10:07 PM
To: Developer support list for Wireshark
Subject: RE: [Wireshark-dev] range_string does not work?

 

Hi,

I don't think "mask" (0x7) works(is implemented) for rangestrings.

Regards

Anders

 


From: wireshark-dev-bounces@xxxxxxxxxxxxx on behalf of Jaap Keuter
Sent: Wed 1/7/2009 2:40 PM
To: Developer support list for Wireshark
Subject: Re: [Wireshark-dev] range_string does not work?

Hi,

 

Is this the same as bug 2893? Stig, was this to be ported to stable?

 

Thanx,

Jaap


On 7 jan 2009, at 13:41, "Zhang, Long \(Roger\)" <zhangl@xxxxxxxxxxxxxxxxxx> wrote:

Hi,

 

I am based on Wireshark 1.0.0 on RHEL5 and Windows. Now I am suspecting  the range_string does not work  when it is put to hf_register_info[].

 

Here is my experience. I declared a range_string atttype_vals and hf_att_type.  I want to add hf_att_type to tree with proto_tree_add_item(). But I found when the hf_att_type value is 4, it is displayed as “Unknown” instead of “EPS attach”.

 

 

static const range_string atttype_vals[] = {

                {0, 1, "EPS attach"},

                {2, 2, "Combined EPS/IMSI attach"},

                {3, 7, "EPS attach"},

                {0, 0, NULL}

};

 

 

 

 

                {&hf_att_type,

                {"EPS attach type",

                        "nas.atttype",

                        FT_UINT8, BASE_RANGE_STRING | BASE_DEC, RVALS(atttype_vals), 0x07,

                        "EPS attach type", HFILL }},

 

 

 

        proto_tree_add_item(tree, hf_att_type, tvb, *po, 1, FALSE);

 

 

 

I tried to fix the problem by change proto_tree_set_uint() to add different handle. For range_string, handle it with rval_to_str(). For value_string, use val_to_str(). But it does not work. Anybody knows the problem? I see there is few RVALS is used.  

 

/* Set the FT_UINT{8,16,24,32} value */

static void

proto_tree_set_uint(field_info *fi, guint32 value)

{

        header_field_info       *hfinfo;

        guint32                 integer;

 

        hfinfo = fi->hfinfo;

        integer = value;

 

        if (hfinfo->bitmask) {

                /* Mask out irrelevant portions */

                integer &= hfinfo->bitmask;

 

                /* Shift bits */

                if (hfinfo->bitshift > 0) {

                        integer >>= hfinfo->bitshift;

                }

        }

 

        if (hfinfo->type == FT_BOOLEAN) {

                const true_false_string  *tfstring = &tfs_true_false;

                if (hfinfo->strings) {

                        tfstring = (const struct true_false_string*) hfinfo->strings;

                }

                col_custom_set_fstr(fi->hfinfo, "%s", value ? tfstring->true_string : tfstring->false_string);

        } else if (hfinfo->strings) {

                col_custom_set_fstr(fi->hfinfo, "%s", val_to_str(integer, cVALS(hfinfo->strings), "%d"));

        } else if (IS_BASE_DUAL(hfinfo->display)) {

                col_custom_set_fstr(fi->hfinfo, hfinfo_uint_value_format(hfinfo), integer, integer);

        } else {

                col_custom_set_fstr(fi->hfinfo, hfinfo_uint_value_format(hfinfo), integer);

        }

        fvalue_set_uinteger(&fi->value, integer);

}

 

 

Thanks,

Roger

 

ng=EN-US style='font-size: 9.0pt;font-family:Arial'>Thanks,

Roger

 

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