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

 

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

Reply via email to