Wireshark-dev: Re: [Wireshark-dev] how to retrieve a guint32

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Mon, 24 Oct 2011 10:27:53 -0700
On Oct 24, 2011, at 8:49 AM, Teto wrote:

> 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" ?

"Little-endian to host", and the "l" stands for "long".

The "'l' stands for 'long'" is a historical artifact; in 4.2BSD (and probably earlier), there were "ntohl()" and "htonl()" routines to convert a C "long", which, at the time, was 32 bits long on 16-bit and 32-bit platforms, between "network byte order" (big-endian) and "host byte order".  There were also "ntohs()" and "htons()" to convert a C "short", which was 16 bits on those platforms.

> why the "24" ?

24 bits.

> I guess the last "l"
> in  tvb_get_letohl is for little endian ?

Nope, "long".