From owner-freebsd-net@FreeBSD.ORG Thu Jun 5 15:56:55 2008 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 965371065677 for ; Thu, 5 Jun 2008 15:56:55 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: from ik-out-1112.google.com (ik-out-1112.google.com [66.249.90.176]) by mx1.freebsd.org (Postfix) with ESMTP id 260628FC12 for ; Thu, 5 Jun 2008 15:56:54 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: by ik-out-1112.google.com with SMTP id c30so406944ika.3 for ; Thu, 05 Jun 2008 08:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent:sender; bh=aNA+3m7G34TihAYJBQ5VstWebQ8IN2OyPrqXrdkM3bI=; b=Lmp1k+XQkWCof2r1WHfLfiWxZ3vTVXz7xJPAOIR++u/pMZVuY9nLFz6jLN7rLCG7/M xCm6Hc6FUJGFm2iuTWA0ntrZGg36Aiwjwa0h3KOxcoIbCdTPh5P8tz60DU3snH71qHIm luN9DFGPcQsx3toWFrWDnGmjzHlhU8I35dU1E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent:sender; b=w6oUdXDZPhYB5YYqvO5Zb3X5nYbaticLNEiwH2AlIUmIm10YCmd9uS/ge0QGZSQiwg WCb2DMkI8OsMwclDmTY2Z2/60QsR5vwfVn3cHpurWz9+PJYXGqieKr3JCodR+MjHknPZ 90ctkkaiSdcAqSmZnUx+J8xmrBSYlGpKzqeoU= Received: by 10.210.77.3 with SMTP id z3mr1107091eba.183.1212681413663; Thu, 05 Jun 2008 08:56:53 -0700 (PDT) Received: from epsilon.local ( [92.250.76.8]) by mx.google.com with ESMTPS id z33sm1881241ikz.0.2008.06.05.08.56.51 (version=SSLv3 cipher=RC4-MD5); Thu, 05 Jun 2008 08:56:53 -0700 (PDT) Date: Thu, 5 Jun 2008 16:56:46 +0100 From: Rui Paulo To: marc.loerner@hob.de Message-ID: <20080605155646.GC6864@epsilon.local> References: <200806051712.47048.marc.loerner@hob.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200806051712.47048.marc.loerner@hob.de> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: Rui Paulo Cc: freebsd-net@freebsd.org Subject: Re: Probable Bug in tcp.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: Thu, 05 Jun 2008 15:56:55 -0000 On Thu, Jun 05, 2008 at 05:12:47PM +0200, =?ISO-8859-1?Q?Marc_L=F6rner_ wrote: > Hello, > I probably found a bug in declaration of "struct tcphdr"! > > struct tcphdr { > u_short th_sport; /* source port */ > u_short th_dport; /* destination port */ > tcp_seq th_seq; /* sequence number */ > tcp_seq th_ack; /* acknowledgement number */ > #if BYTE_ORDER == LITTLE_ENDIAN > u_int th_x2:4, /* (unused) */ <---here > th_off:4; /* data offset */ <--- > #endif > #if BYTE_ORDER == BIG_ENDIAN > u_int th_off:4, /* data offset */ > th_x2:4; /* (unused) */ > #endif > u_char th_flags; > > First of all I have the problam of misalignment of th_off. Because in this way > always 4 bytes are read and the the bits of th_off are replaced. Then the 4 > bytes are written back. > > But should (th_x and th_off) not only be 1 byte in whole -> only read and > write 1 byte? > > I think if this was changed, my misalignment problems would go away! I'm not sure what you mean. Please supply more information, like: 1) Are you running on little endian? Or big endian? 2) th_x2 + th_off are 1 byte in size. What do you mean? 3) What is exactly the effect? I don't understand the "replaced", "written back" etc. sentence. Regards, -- Rui Paulo