struct iphdr in include/linux/ip.h (probably bug in headerfile)
Hello,
The following definition in linux/include/ip.h is creating problems.
How does Endianness affect BIT ORDER
IT affetc only BYTE ORDER
------------------------------------------------------------------------
struct iphdr {
#if defined(__LITTLE_ENDIAN_BITFIELD)
__u8 ihl:4,
version:4;
#elif defined (__BIG_ENDIAN_BITFIELD)
__u8 version:4,
ihl:4;--------------------------------------------------------------------------
Here I have a network device which works on both little endian and big endian machines.
I found out that the driver of the device was saying unrecognizable packet when i assign
strcut iphdr *ip;
ip->version=4
ip->ihl=5
on bigendian machines.
It is because the two fields are swapped and start of the iphdr is 5 instead of 4.
The device is seeing 5 at the version and saying neither ipv4 nor ipv6 packet found.
I had to do the following to remove the error
*((unsigned char*)ip) = 0x45;
Had anyone noticed IT
S Kartikeyan
Quoted 6 lines · k8 s <[email protected]> writes:
Hello,
The following definition in
linux/include/ip.his creating problems.How does Endianness affect BIT ORDER
IT affetc only BYTE ORDER
Bit order and byte order are independent properties of the architecture. That's why they are configured with different macros.
Quoted 8 lines
------------------------------------------------------------------------
struct iphdr {#if defined(__LITTLE_ENDIAN_BITFIELD) __u8 ihl:4, version:4; #elif defined (__BIG_ENDIAN_BITFIELD) __u8 version:4, ihl:4;
Quoted 5 lines
--------------------------------------------------------------------------
Here I have a network device which works on both little endian and big endian machines.
I found out that the driver of the device was saying unrecognizable packet when i assign
The you probably didn't define the right macro of the ones referenced above.
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 6 lines · On Maw, 2005-06-21 at 08:15, k8 s wrote:
Hello,
The following definition in
linux/include/ip.his creating problems.How does Endianness affect BIT ORDER
IT affetc only BYTE ORDER
Bitfield order is a compiler property. Byte order is usually a processor property and the two are not exactly connected.
A compiler given two bit fields can pack them from the high bit or from the low bit and may do different things depending on the platform. The defines tell the kernel whether the compiler packs bitfields into the low bits first or the high bits first.