[BusyBox] udhcp patches/ endianess
Rainer Weikusat
rainer.weikusat at sncag.com
Tue Feb 1 08:45:24 UTC 2005
Russ Dill <Russ.Dill at asu.edu> writes:
> On Mon, 2005-01-31 at 16:54 +0100, Rainer Weikusat wrote:
>> Compile-time support for different endianesses.
>
> That isn't the right fix,
Let's see:
This is for the little-endian case:
static inline uint16_t pad_octet_left(uint8_t v, uint8_t pad)
{
return pad | v << 8;
}
The following memory layout should be simulated:
pad v
On a LSB machine, this means 'pad' is the LSB and v the MSB. Which
gives the number pad | v << 8.
static inline uint16_t pad_octet_right(uint8_t v, uint8_t pad)
{
return v | pad << 8;
}
memory layout: v pad
number v | pad << 8
Now for big endian:
static inline uint16_t pad_octet_left(uint8_t v, uint8_t pad)
{
return pad << 8 | v;
}
memory layout: pad v
number: pad << 8 | v
static inline uint16_t pad_octet_right(uint8_t v, uint8_t pad)
{
return v << 8 | pad;
}
memory layout: v pad
number: v << 8 | pad
So unless I am very much mistaken, this is correct for both
cases.
> btw, who replaced the endian safe checksum
> function, with one that isn't?!
As you have pointed out in a previous e-mail: I have the source and
can twist that to my liking (for instance, I like working timeout
algorithms and I dislike sending out packets containing 302
meaningless zero octets).
More information about the busybox
mailing list