struct iphdr in include/linux/ip.h (probably bug in headerfile)

From: k8 s
Date: Tue Jun 21 2005 - 04:13:07 EST


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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/