> Hi all,
>
> I have question regarding tvbuff:
>
> I've got very strange behaviour of tvbuffs (strange for me of course).
> There is a structure (below) I defined. I'm trying to copy 118 bytes from
> tvbuff to myvar (type of mystruct), and what I got:
>
> first 93 bytes were copied correctly, but rest seemed to be shifted by 3
> bytes. It means that after field10 each field has different value. I've
> tried to copy this another way, first 93 bytes then 25 shifted by
> 3(please, see commented lines below, of course "myvar" wasn't a pointer),
> but anyway last field (field17) was incorrect. It seems that field11
> starts in another block.
>
> I can still get value of each field one by one usig tvb_get_guint8 (ntohs
> ...) functions. But it consumes too much time.
>
> Could anybody explain me if there is any way to have coherent and
> continuous data?
>
> Content of packet I dissect is above UDP layer, first comes 27 bytes of
> header and then interesting data (mentioned 118 bytes).
>
> typedef struct struct_t {
> guint8 field1[8];
> guint8 filed2[4];
> guint32 field3;
> guint8 field4[4];
> gchar field5[63];
> guint8 field6;
> guint8 field7;
> guint8 field8[4];
> guint8 field9;
> guint8 field10[3];
> guint32 field11;
> guint32 field12;
> guint32 field13;
> guint32 field14;
> guint32 field15;
> guint8 field16;
> guint32 field17;
> } mystruct;
>
> int myfunction () {
>
> mystruct *myvar;
>
> /* same result
> myvar = (struct_t *)tvb_get_ptr(tvb, offset+3, 118); */
>
> /* same result
> tvb_memcpy(tvb, (guint8*)&myvar, offset+3, 93);
> tvb_memcpy(tvb, ((guint8*)&myvar)+93, offset+93, 25);
>
> myvar = (struct_t *)tvb_memdup(tvb, offset+3, 118);*/
>
> }
>
> Thanks and best regards
>
> Michal