* struct iphdr in include/linux/ip.h (probably bug in headerfile)
@ 2005-06-21 7:15 k8 s
2005-06-21 11:48 ` Andreas Schwab
2005-06-21 12:27 ` Alan Cox
0 siblings, 2 replies; 3+ messages in thread
From: k8 s @ 2005-06-21 7:15 UTC (permalink / raw)
To: linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: struct iphdr in include/linux/ip.h (probably bug in headerfile)
2005-06-21 7:15 struct iphdr in include/linux/ip.h (probably bug in headerfile) k8 s
@ 2005-06-21 11:48 ` Andreas Schwab
2005-06-21 12:27 ` Alan Cox
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2005-06-21 11:48 UTC (permalink / raw)
To: k8 s; +Cc: linux-kernel
k8 s <uint32@gmail.com> writes:
> Hello,
>
> The following definition in linux/include/ip.h is 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.
> ------------------------------------------------------------------------
> 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
The you probably didn't define the right macro of the ones referenced
above.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
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."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: struct iphdr in include/linux/ip.h (probably bug in headerfile)
2005-06-21 7:15 struct iphdr in include/linux/ip.h (probably bug in headerfile) k8 s
2005-06-21 11:48 ` Andreas Schwab
@ 2005-06-21 12:27 ` Alan Cox
1 sibling, 0 replies; 3+ messages in thread
From: Alan Cox @ 2005-06-21 12:27 UTC (permalink / raw)
To: k8 s; +Cc: Linux Kernel Mailing List
On Maw, 2005-06-21 at 08:15, k8 s wrote:
> Hello,
>
> The following definition in linux/include/ip.h is 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-06-21 12:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-21 7:15 struct iphdr in include/linux/ip.h (probably bug in headerfile) k8 s
2005-06-21 11:48 ` Andreas Schwab
2005-06-21 12:27 ` Alan Cox
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.