On Tue, Mar 19, 2002 at 03:18:20AM -0500, Paul E. Erkkila wrote:
> Thanks, I've integrated what i could quickly into my current working
> version (attached).
I've merged your working version in, and checked the result in.
> I think i finally grok the add_item/add_* versions :p, i'll fix
> those soon hehehe
I've already fixed them in the checked-in version.
"proto_tree_add_item()" takes, as the final argument, an indication of
whether the item to be put in is big-endian or little-endian (this is
relevant only for integral items); it does all the work of fetching the
data from the tvbuff for you.
Note that copying the entire packet to a buffer, and then extracting
data from the buffer, as your code was doing, has a number of
disadvantages:
1) you can't just use numbers in the buffer directly - you'd
have to fetch them with routines or macros to do the right
byte-ordering (if you were doing your development on a
x86-based PC, or other little-endian machine, it happened to
work for you by luck, because the fields appear to be
little-endian; it doesn't work on big-endian machines,
though);
2) if the compiler puts padding into the structure, you may not
get the results you expect;
3) if the entire structure isn't available from the packet,
*none* of it gets dissected;
so I kept the "proto_tree_add_item()" calls, and converted other calls
to "proto_tree_add_item()" calls as well.