Question about netinet/ip.h
Rui Paulo
rpaulo at NetBSD.org
Wed May 31 12:05:32 PDT 2006
At Wed, 31 May 2006 21:57:03 -0700,
Emil Kondayan wrote:
>
> Can someone tell me why "ip_hl" and "ip_v" are of type "u_int" when the
> structure is packed and they only fill a byte?
u_int means unsigned int and they only fill a byte because 4 + 4 = 8
bits (a byte) (I'm not going into the "Why is a byte 8 bits?" question ;-).
This structure is composed of bitfields and it means that when you
access a bitfield element (for example, ip_hl) you are only
manipulating 4 bits instead of sizeof(unsigned int) bytes (8 bit
several computer arquitectures).
Any C book should explain bitfield structs/unions clearly.
> And my second question:do these "#define ..." directives allocate space in the
> structure?
No, read about the C pre-processor (again, in every C book).
More information about the freebsd-net
mailing list