From owner-freebsd-net@FreeBSD.ORG Wed May 31 19:09:59 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 8FBD516B9B4 for ; Wed, 31 May 2006 19:09:59 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from pi.codefab.com (pi.codefab.com [199.103.21.227]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1E83B43D68 for ; Wed, 31 May 2006 19:09:57 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from localhost (localhost [127.0.0.1]) by pi.codefab.com (Postfix) with ESMTP id 526495CF5; Wed, 31 May 2006 15:09:56 -0400 (EDT) X-Virus-Scanned: amavisd-new at codefab.com Received: from pi.codefab.com ([127.0.0.1]) by localhost (pi.codefab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CKXZ-373Pt3P; Wed, 31 May 2006 15:09:54 -0400 (EDT) Received: from [199.103.21.238] (pan.codefab.com [199.103.21.238]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by pi.codefab.com (Postfix) with ESMTP id DDB055CB5; Wed, 31 May 2006 15:09:54 -0400 (EDT) In-Reply-To: <200605312157.04027.emil@ekon-bg.com> References: <200605291103.k4TB38uo097477@freefall.freebsd.org> <200605312157.04027.emil@ekon-bg.com> Mime-Version: 1.0 (Apple Message framework v750) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <6AE303E5-13FD-4328-BDF4-25BACF429806@mac.com> Content-Transfer-Encoding: 7bit From: Charles Swiger Date: Wed, 31 May 2006 15:09:50 -0400 To: Emil Kondayan X-Mailer: Apple Mail (2.750) 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:10:11 -0000 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