Re: dlil_inject_if_input
Re: dlil_inject_if_input
- Subject: Re: dlil_inject_if_input
- From: Justin Walker <email@hidden>
- Date: Sat, 18 Sep 2004 16:59:13 -0700
On Sep 18, 2004, at 16:05, Adrian Bool wrote:
On 18 Sep 2004, at 06:55, Matt Jaffa wrote:
despite the fact that some of the other stuff might be wrong, why
wouldn't the ip_v be the right version? The output does print out 4
like it should be.
I had a look at /usr/include/netinit.h for the definition of struct ip,
Keep in mind that _IP_VHL *is* defined when it is used in the kernel.
struct ip {
#ifdef _IP_VHL
u_char ip_vhl; /* version << 4 | header
length >> 2 */
#else
#if BYTE_ORDER == LITTLE_ENDIAN
u_int ip_hl:4, /* header length */
ip_v:4; /* version */
#endif
#if BYTE_ORDER == BIG_ENDIAN
u_int ip_v:4, /* version */
ip_hl:4; /* header length */
#endif
I am confused now, as I thought that ENDIANness was the ordering of
bytes. I that were the case then there would be no need to change
round the nibbles depending upon the ENDIANness of the local machine.
Try something like this on big-endian (PPC) and little-endian (x86)
machines:
struct xx
{ unsigned int xa:4;
unsigned int xb:4;
char xc;
};
struct xx XX;
main()
{ XX.xa = 4;
XX.xb = 5;
XX.xc = 255;
printf("%x\n",*(int *)&XX);
}
PPC: 45ff0000
x86: ff54
The bit-ordering is the same, but the layout of bit-fields within a
"storage unit" follows the layout in the source...(it makes sense,
really). That's why the endianness distinction is made when using
bitfields. You want the 'first' byte to show '45' in both orientations
(my code doesn't distinguish, hence one is the reverse of the other).
Cheers,
Justin
--
Justin C. Walker, Curmudgeon-At-Large *
Institute for General Semantics | When LuteFisk is outlawed
| Only outlaws will have
| LuteFisk
*--------------------------------------*-------------------------------*
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden