Wireshark mailing list archives
How to get a header_field_info instance from its id?
From: yves baumes <yves.baumes () celoxica com>
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 ___________________________________________________________________________ Sent via: Wireshark-dev mailing list <wireshark-dev () wireshark org> Archives: https://www.wireshark.org/lists/wireshark-dev Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev mailto:wireshark-dev-request () wireshark org?subject=unsubscribe
Current thread:
- How to get a header_field_info instance from its id? yves baumes (Aug 19)
- Re: How to get a header_field_info instance from its id? mmann78 (Aug 19)
- Re: How to get a header_field_info instance from its id? Jakub Zawadzki (Aug 19)