On 24/10/2011 16:49, Teto wrote:
> Hi,
> I know it's a silly question but can't test it (refactoring of my
> plugin). I want to retrieve a 32 bits number but if I use
> tvb_get_bits32, I need to pass useless parameters (in my case) since I
> want to retrieve all 32 bits.
> guint32 tvb_get_bits32 ( tvbuff_t * tvb,
> gint bit_offset,
> const gint no_of_bits,
> const gboolean little_endian
> );
> I guess you can use tvb_get_bits32 to retrieve 8 bits into a guint32
> for example . Is that true ?
>
> tvb_get_letoh24 / tvb_get_letohl look more straightforward but I don't
> understand how they transform the number.
> letoh stands for "local to host" ? why the "24" ? I guess the last "l"
> in tvb_get_letohl is for little endian ?
>
> Regards
> Matt
The tvb accessors names indicate the endianess of the bytes in the packet,
e.g. get_n* gets bytes in network format and get_le* get bytes in little
endian, the "toh" part indicates the conversion will be done to the native
host format, and any suffix indicates the number of bits to be retrieved from
the tvb, e.g. "24" is obviously 24 bits, "l" is less obviously a long or 32 bits.
So in your case you would use tvb_get_ntohl() or tvb_get_letohl() depending on
the endianess of the bytes in your tvb.
--
Regards,
Graham Bloice