Question about netinet/ip.h
Charles Swiger
cswiger at mac.com
Wed May 31 12:10:11 PDT 2006
On Jun 1, 2006, at 12:57 AM, 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?
Well, that struct definition is relying on the compiler to squeeze
the bitfields into the smallest space required. Some platforms
define ip_hl and ip_v as a char called ip_vhl instead:
/*
* Structure of an internet header, naked of options.
*/
struct ip {
#ifdef _IP_VHL
u_char ip_vhl; /* version << 4 | header
length >> 2 */
#else
[ ...bitfields vary based on BYTE_ORDER... ]
> And my second question:do these "#define ..." directives allocate
> space in the
> structure?
No. They define bitmasks to access each flag bit.
--
-Chuck
More information about the freebsd-net
mailing list