Thanks for the quick reply!
I am doing the field registration the normal way:
static hf_register_info hf[] = {
{ &hf_pep_header_sync_pattern,
{
"SYNC Pattern",
"pep.header_sync_pattern",
FT_BYTES,
BASE_HEX,
NULL,
0,
"This field should always be D00BED00"
}
},
etc.......
I plan to have our database/tool generate this for all fields. So I guess the IDs
should all be generated OK. I guess I just need to lookup the IDs given the
fieldname. I do not see any other dissectors using any dfilter calls, I suppose
that is frowned upon. Is it possible to call dfilter_lookup_token in my
dissector?
Is there another, better way to do this?
-----Original Message-----
From: Gilbert Ramirez [mailto:gram@xxxxxxxxxx]
Sent: Friday, February 16, 2001 10:43 AM
To: Nicholas, John S
Cc: ethereal-dev@xxxxxxxxxxxx
Subject: Re: [Ethereal-users] Can I get the field ID?
On Fri, Feb 16, 2001 at 10:15:15AM -0800, Nicholas, John S wrote:
> Hi,
>
> I am trying to implement a dissector with out knowing the details of the structure being decoded.
> I fact I do know the structure, but it would be much easier to code if I can fill a structure (actually
> more than one) with the field names and type, length, etc. We have a tool/database that has the
> format information and I want to be able to have that tool fill in the structure for me. Anyway, I think
> I can do it if I can get the ID (used by proto_tree_add_item) given a string containing a fieldname.
>
> In other words, how do I do this?
> proto_tree_add_item(pep_tree_sub, stringtmp, tvb, offset, 4, value32);
>
> where stringtmp is a variable containing "hf_pep_t0462_status"
This is a question better-suited for ethereal-dev; I'm moving
the discussion there.
How do you plan on handling the field registration? Ethereal needs
to know the names of all your fields so that it can do display
filtering for you. When you register your fields, you get the ID.
Name->ID translation is done via dfilter_lookup_token(),
in the dfilter code. Arguably, the name->id translation should
be handled in proto.c. It just so happened that the dfilter
code was the first thing that needed it, so I put it there.
--gilbert