Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] Question for how to show the value of Length rightin wiresha

From: "Kukosa, Tomas" <tomas.kukosa@xxxxxxxxxxx>
Date: Fri, 27 Apr 2007 07:48:20 +0200
Hi,

the last parameter of proto_tree_add_item() function /which you probably
use to add field into the tree/ indicates if ineger field is little or
big endian. Fot little endian (your case) it has to be TRUE.

You should use e.g. FT_BYTES for your data field, it has variable
length.


-----Original Message-----
From: wireshark-dev-bounces@xxxxxxxxxxxxx
[mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] On Behalf Of li yang
Sent: Friday, April 27, 2007 5:02 AM
To: wireshark-dev@xxxxxxxxxxxxx
Subject: [Wireshark-dev] Question for how to show the value of Length
rightin wireshark plugin

Hi,All
    I just start how to write a plugin for own protocal in wireshark
and meet a problem
    Our protocal is based on ethernet and looks like this
    | Length |  Data |  CRC   |

    The length field hold 2 bytes and stands for the length of the data,
    eg, if value is 0x B6 01 , should means the value is 0x 01B6 (438
in decimal)

    I code like followed
	{ &hf_foo_length,
	{ "foo Length",           "foo.length",
	FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
	"", HFILL }
	},

	{ &hf_foo_data,
	{ "foo Data",	"foo.data",	
	FT_UINT16, BASE_HEX,	NULL, 0x0,
	"", HFILL }},

	{ &hf_rdc_crc,
	{ "foo CRC",           "foo.crc",
	FT_UINT32, BASE_DEC, NULL, 0x0,
	"", HFILL }
	}

  I can get the right value in dissect_foo( ) via the followed code.
    data_length = tvb_get_letohs(tvb, offset);

But in the tree view,
1> It always should the Length value is 0xB601 (46593 in decimal)
2> can not show the data field rightly.

So,
1> How could I slove this problem?
2> How could I declare the data in the hf_register_info structure if
the data's length is changeable.

Thanks!!!
_______________________________________________
Wireshark-dev mailing list
Wireshark-dev@xxxxxxxxxxxxx
http://www.wireshark.org/mailman/listinfo/wireshark-dev