Ethereal-dev: Re: [Ethereal-dev] adding multiple values to tree

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Gilbert Ramirez <gram@xxxxxxxxxxxxxxx>
Date: Tue, 31 Jan 2006 09:16:27 -0600
We don't know which version of the ethereal source code you are using.
Can you show us line 1895 of epan/proto.c ? (a few lines before, and a
few lines after, too, would be good).

--gilbert

On 1/31/06, Lars Dörner <mail@xxxxxxxxx> wrote:
> Hy
>
> I got a PDU which is build like that:
>
> 1. a value how many video rectangles are coming.
> 2. for each rectangle a header describing the rect followed by the
> rect-data.
>
> Now I'm dissecting this pdu. It works fine with Debug messages but
> trying to add it do the tree like this :
>
> - Protocol
>          -  number of rect
>                  - header rect 1
>          - header rect 2
>                         ...
>
> Always brings this:   Warn Dissector bug, protocol XYZ, in packet 802:
> proto.c:1895: failed assertion "DISSECTOR_ASSERT_NOT_REACHED"
>
>  Following the code:
>
>
> static int dissect_framebufferupdate(tvbuff_t * tvb, packet_info * pinfo,
> proto_tree * tree)
> {
>         static uint16_t count = 0, i = 0;
>         static unsigned int offset2 = 4;
>         uint16_t n_rects = 0;
>         uint32_t length = 0;
>         uint32_t offset = 0;
>         uint32_t avaible = tvb_reported_length_remaining(tvb, offset);
>         teststruct memstruct;
>
>         if (avaible >= 4)
>         {
>                 n_rects = tvb_get_ntohs(tvb,2);
>                 if (i == 0)
>                 {
>                         count = n_rects;
>                         i++;
>                 }
>         }else
>         {
>                 pinfo->desegment_offset = offset;
>                 pinfo->desegment_len = 1;
>                 return (-1);
>         }
>
>         while(count>0)
>         {
>
>                 if (avaible >(12+offset2))
>                 {
>                         memstruct.x = tvb_get_ntohs(tvb,(offset2));
>                         memstruct.y = tvb_get_ntohs(tvb,(2+offset2));
>                         memstruct.w = tvb_get_ntohs(tvb,(4+offset2));
>                         memstruct.h = tvb_get_ntohs(tvb,(6+offset2));
>                         memstruct.encoding = tvb_get_ntohl(tvb,(8+offset2));
>
>                 }else
>                 {
>                         pinfo->desegment_offset = offset;
>                         pinfo->desegment_len =1;
>                         return (-1);
>                 }
>
>                 length = decoder(memstruct.x, memstruct.y, memstruct.w,
> memstruct.h, memstruct.encoding);
>
>
>                 if (avaible <= (12 + length + offset2))
>                 {
>                         pinfo->desegment_offset = offset;
>                         pinfo->desegment_len = 1;
>
>                         return(-1);
>                 }else
>                 {
>                         proto_tree *ti,*xyz_tree;
> /* Set the protocol column */
>
>                         if(check_col(pinfo->cinfo,COL_INFO))
>                         {
>                                 col_add_str(pinfo->cinfo, COL_INFO,
> "FrameBuffer Update");
>                         }
>
>                                 if (tree)
>                         {
>                                 ti = proto_tree_add_item(tree,proto_xyz,
> tvb, 0, -1, FALSE);
>                                 xyz_tree = proto_item_add_subtree(ti,
> ett_xyz);
>                                 proto_tree_add_uint(xyz_tree,
> hf_xyz_fb_update_n_rects, tvb, 2, 2, n_rects);
>                                 proto_tree_add_int(xyz_tree,
> hf_xyz_fb_update_x , tvb, 4, 2, memstruct.x);
>                                 printf("x: %d\n",memstruct.x);
>                                 proto_tree_add_int(xyz_tree,
> hf_xyz_fb_update_y, tvb, 6, 2, memstruct.y);
>                                 printf("y: %d\n",memstruct.y);
>                                 proto_tree_add_int(xyz_tree,
> hf_xyz_fb_update_w, tvb, 8, 2, memstruct.w);
>                                 proto_tree_add_int(xyz_tree,
> hf_xyz_fb_update_h, tvb, 10, 2, memstruct.h);
>                                 proto_tree_add_int(xyz_tree,
> hf_xyz_fb_update_encoding, tvb, 12, 4, memstruct.encoding);
>                         }
>                         count --;
>                         printf(" counter: %d\n", count);
>                         offset2 = (offset2 + 13 + length);
>                 }
>         }
>
>         if (count == 0 )
>         {
>                 i = 0;
>                 offset2 = 0x04;
>         }
>
>
> }
>
> _______________________________________________
> Ethereal-dev mailing list
> Ethereal-dev@xxxxxxxxxxxx
> http://www.ethereal.com/mailman/listinfo/ethereal-dev
>
>