Dear all,
I'm still trying to understand how strings should be handled. So I read
the README.developer.
First of all I have the impression that i should use
proto_item*
proto_tree_add_item(tree, id, tvb, start, length, little_endian);
whenever possible compared to the more specific ones like
proto_item *
proto_tree_add_uint(tree, id, tvb, start, length, value);
Is that correct?
However, I decided to use proto_tree_add_item. So the text says that
the last argument is a flag describing little/big endian. I'm assuming
that describes the format of the item in the tvb. This would mean for
IETF protocol it is always big endian. If this is correct I would suggest
to introduce two constants, one for big one for little endian.
Assuming that this is correct I do not understand the example given in
the file:
guint8 th_0 = tvb_get_guint8(tvb, offset);
proto_tree_add_item(bf_tree, hf_sna_th_fid, tvb, offset, 1,
th_0);
I would have expected
proto_tree_add_item(bf_tree, hf_sna_th_fid, tvb, offset, 1, TRUE
or FALSE);
So why do I need to extract the value of th_0 and how is that related to
to the
byte order? Is the byte order coded in the th_0?
The last thing which I do not understand is why is there a difference
between
proto_tree_add_item(parameter_tree, hf_text_interface_identifier,
parameter_tvb, TEXT_INTERFACE_IDENTIFIER_OFFSET,
interface_identifier_length,
BIG_ENDIAN);
and
proto_tree_add_string(parameter_tree, hf_text_interface_identifier,
parameter_tvb, TEXT_INTERFACE_IDENTIFIER_OFFSET,
interface_identifier_length,
tvb_get_ptr(parameter_tvb,
TEXT_INTERFACE_IDENTIFIER_OFFSET, interface_identifier_length);
where
{ &hf_text_interface_identifier,
{ "Text interface identifier", "iua.text_interface_identifier",
FT_STRING, BASE_DEC, NULL, 0x0,
"", HFILL }
},
The string in the tvb is NOT zero terminated and is displayed correctly
by the proto_tree_add_item but
not by the proto_tree_add_string. In the proto_tree_add_string the bytes
highlighted are correct but the
string displayed is as long as needed to find a NULL in the memory. For
me this seems to be a bug.
Thank you very much in advance for your help
Best regards
Michael
Michael.Tuexen@xxxxxxxxxxxxxxxxx