Guy
Yes... am I also fixing how I add stuff to the trees.
I always just used proto_tree_add_uint_format.... but I am fixing
these as well.
Does each packet have to have it's own hf_value..?? Or could I just use
something like that following for all strings (hf_helen_text)..??
{ &hf_helen_text,
{ "Text", "helen.text", FT_STRING, BASE_NONE, NULL, 0x0,
"Text", HFILL}}
I can see that I misread the developers guide.
It says:
IMPORTANT
Do not use functions such as strcat() or strcpy().
But it says nothing about strncpy(). :-)
I am also fixing all the places where I used "hf_helen_length".
What is wrong with using hf_helen_length (as this could be very generic)..??
For example... would you create a hf_value such as (hf_helen_nos) for
the following example..??
// Number of Satellites:
guint8 nos;
nos = tvb_get_guint8(tvb,offset);
proto_tree_add_uint_format(helen_sub_tree,
hf_helen_length, tvb, offset, 1, 0,
"Number of Satellites: %d", nos);
What would this hf_item look like..?? Would it look something like this..??
{ &hf_helen_nos,
{ "nos", "helen.len", FT_UINT8, BASE_DEC, NULL, 0x0,
"nos", HFILL}},
Thanks,
Brian
Guy Harris wrote:
On Jan 25, 2010, at 1:11 PM, Brian Oleksa wrote:
char flowname[9];
strncpy(flowname, ptr, 8);
flowname[8] = '\0';
ptr += 8;
proto_tree_add_uint_format(helen_sub_tree,
hf_helen_length, tvb, offset, 8, 0,
"Flowname: %s", flowname);
It's a string, not a number, so don't use proto_tree_add_uint_format(), or any other proto_tree_add_uint routine.
If it's an 8-octet field containing a null-padded string (presumably the string can have 8 octets), you should use something such as
proto_tree_add_string(helen_sub_tree, hf_helen_flowname, tvb, offset, 8, flowname);
In the developers README file... it tells you NOT to use strcpy...but
instead use g_snprintf().
It doesn't say "don't use strncpy()".
___________________________________________________________________________
Sent via: Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
Archives: http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe