ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] dissection question

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Tue, 16 Feb 2010 16:11:34 -0800
On Feb 16, 2010, at 12:22 PM, Brian Oleksa wrote:

>                        //status
>                        proto_tree_add_uint(helen_sub_tree, hf_helen_routerstatus, tvb, offset, 1, FALSE);
>                        offset += 1;

		...

>                        //cpu % used
>                        proto_tree_add_uint(helen_sub_tree, hf_helen_cpuusage, tvb, offset, 1, FALSE);
>                        offset += 1;
> 
>                        *//interface count*
>                        interfacecount = tvb_get_guint8(tvb, offset);
>                        proto_tree_add_uint(helen_sub_tree, hf_helen_interface_count, tvb, offset, 1, FALSE);

The last argument to proto_tree_add_uint() is not a Boolean specifying the byte order, it's the actual integral value to put into the tree.  The last argument to proto_tree_add_item() is a Boolean specifying the byte order.

For the interface count, you want

                       proto_tree_add_uint(helen_sub_tree, hf_helen_interface_count, tvb, offset, 1, interfacecount);

For status and cpu % used, you probably want to use proto_tree_add_item().

>                            *//interface active*
>                            proto_tree_add_uint(helen_sub_tree, hf_helen_interfaceActivity, tvb, offset, 1, FALSE);

You want proto_tree_add_item() there, too.