From owner-freebsd-net@FreeBSD.ORG Wed May 31 19:05:15 2006 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7352B16B73D for ; Wed, 31 May 2006 19:05:15 +0000 (UTC) (envelope-from rpaulo@fnop.net) Received: from core.fnop.net (core.fnop.net [209.67.220.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9510F43D6A for ; Wed, 31 May 2006 19:05:10 +0000 (GMT) (envelope-from rpaulo@fnop.net) Received: from core.fnop.net (core [209.67.220.162]) by core.fnop.net (Postfix) with ESMTP id 27E5510EE4F; Wed, 31 May 2006 20:03:35 +0100 (WEST) Received: by core.fnop.net (Postfix, from userid 32767) id DD7D110EE4A; Wed, 31 May 2006 20:03:34 +0100 (WEST) X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on core.fnop.net X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO,RCVD_IN_SORBS_DUL autolearn=no version=3.1.0 Received: from sigma.internal.fnop.net (87-196-87-87.net.novis.pt [87.196.87.87]) by core.fnop.net (Postfix) with ESMTP id B71BC10ED9B; Wed, 31 May 2006 20:03:33 +0100 (WEST) Date: Wed, 31 May 2006 20:13:31 +0100 Message-ID: <87fyiq9fdw.wl%rpaulo@fnop.net> From: Rui Paulo To: Emil Kondayan In-Reply-To: <200605312157.04027.emil@ekon-bg.com> References: <200605291103.k4TB38uo097477@freefall.freebsd.org> <200605312157.04027.emil@ekon-bg.com> User-Agent: Wanderlust/2.14.0 (Africa) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: ClamAV using ClamSMTP Cc: freebsd-net@freebsd.org Subject: Re: Question about netinet/ip.h X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 May 2006 19:05:32 -0000 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).