Date: Wed, 31 May 2006 20:13:31 +0100 From: Rui Paulo <rpaulo@NetBSD.org> To: Emil Kondayan <emil@ekon-bg.com> Cc: freebsd-net@freebsd.org Subject: Re: Question about netinet/ip.h Message-ID: <87fyiq9fdw.wl%rpaulo@fnop.net> In-Reply-To: <200605312157.04027.emil@ekon-bg.com> References: <200605291103.k4TB38uo097477@freefall.freebsd.org> <200605312157.04027.emil@ekon-bg.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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).
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87fyiq9fdw.wl%rpaulo>