Ethereal-dev: Re: [Ethereal-dev] referencing specific tcp protocol data

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Gilbert Ramirez <gram@xxxxxxxxxxxxxxx>
Date: 29 Mar 2002 14:10:49 -0600
On Fri, 2002-03-29 at 13:38, Phil Williams wrote:
> >
> > A "proto_node" contains a "field_info" pointer; a "field_info", as
> > defined in <epan/proto.h>, contains:
> >
> > 	a "header_field_info" pointer;
> >
> > 	an "fvalue_t" pointer;
> >
> > 	a bunch of other information.
> >
> > The "header_field_info" structure points to a structure that represents
> > an attribute; the "fvalue_t" pointer points to a structure that
> > represents a value.
> >
> > The only problem is that the attributes are identified by
> > "header_field_info" pointers rather than by name.  If we provided
> > routines to look up "header_field_info" structures by name, that
> > probably wouldn't be a problem.
> >
> 
> Well in this case, can I not get access to the data I require by looking
> up using header_field_info pointers, rather than names?
> With the tree being (attribute, value), is the attribute (eg for TCP
> header length) always the same? If so wouldn't it be possible to
> get access to the data that I require?  Though this is less elegant than
> using the actual names should it be feasible?
> If so, what values / names do these header_field_info pointers take?
> 

Let's say we add a new function,

int
proto_registar_lookup_abbrev(const char*)

Then you could find the ID via:

tcp_hdr_len_id = proto_registar_lookup_abbrev("tcp.hdr_len")

With that, you could get an array of field_info pointers, since
a proto_tree might have more than 1 such field_info, via:

GPtrArray*
proto_get_finfo_ptr_array(proto_tree *tree, int id)

Then you could iterate across the array. For each field_finfo, you could
get the integer value via:

fvalue_get_integer(finfo_ptr->value);

--gilbert