Wireshark-dev: [Wireshark-dev] How to get a header_field_info instance from its id?

From: yves baumes <yves.baumes@xxxxxxxxxxxx>
Date: Wed, 19 Aug 2015 16:45:21 +0200
Hi everyone,

I am currently developping a dissector. And I have some basic questions.

My first one would be: how do I get the header_field_info structure instance from its structure id? Here is what I'm trying to achieve:

static int hf_instr_id = -1;
[...]

    { &hf_instr_id,
{ "Instrument Identifier", "my_proto.instr_id", FT_UINT64, BASE_DEC, NULL, 0x00,
        "[...]", HFILL }
    },

[...]
    ptvcursor_add(cursor, hf_instr_id, 8, ENC_LITTLE_ENDIAN);


In the line just above I'd like to replace the length (which is 8) by something roughly looking like that:

    int len = ftype_len(gap_hfinfo.hfi[xxx]->type);
    ptvcursor_add(cursor, hf_instr_id, len, ENC_LITTLE_ENDIAN);

One of my issue is that gap_hfinfo array (which contains all the header_fields_info instances) is static to the proto.c file. And I find no accessors to it.
Is there an actual way that I've overlooked?
Or do I need to keep a pointer to header_field_info structure in the first place?

Second question: I've took a quick glance at others dissectors.
It looks like every one of them provide their integer fields' size twice:
- in the header_field_info
- and also as a parameter of ptvcursor_add()/proto_tree_add_item().

Is there a reason for doing that? Historical?

Regards
Yves BAUMES