From owner-freebsd-net@FreeBSD.ORG Tue Jun 7 21:49:07 2005 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 A712716A41C for ; Tue, 7 Jun 2005 21:49:07 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.45]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7403A43D1D for ; Tue, 7 Jun 2005 21:49:07 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from mac.com (smtpin08-en2 [10.13.10.153]) by smtpout.mac.com (Xserve/8.12.11/smtpout11/MantshX 4.0) with ESMTP id j57Ln4A5025149; Tue, 7 Jun 2005 14:49:04 -0700 (PDT) Received: from [192.168.1.6] (pool-68-161-53-96.ny325.east.verizon.net [68.161.53.96]) (authenticated bits=0) by mac.com (Xserve/smtpin08/MantshX 4.0) with ESMTP id j57Ln2ZJ000262; Tue, 7 Jun 2005 14:49:03 -0700 (PDT) In-Reply-To: <42A611B8.7040102@elischer.org> References: <42A5BCEB.8020109@kuhtz.com> <42A5D5DE.2010407@elischer.org> <70FFA13A-E2C1-4CCE-B430-F948EECC1B96@mac.com> <42A611B8.7040102@elischer.org> Mime-Version: 1.0 (Apple Message framework v730) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <188A3523-CCA5-4765-BCA4-3E0E8B3375B0@mac.com> Content-Transfer-Encoding: 7bit From: Charles Swiger Date: Tue, 7 Jun 2005 17:49:00 -0400 To: Julian Elischer X-Mailer: Apple Mail (2.730) Cc: Christian Kuhtz , freebsd-net@freebsd.org Subject: Re: divert sock api q 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: Tue, 07 Jun 2005 21:49:07 -0000 On Jun 7, 2005, at 5:29 PM, Julian Elischer wrote: >> I agree with your suggestion, but how can you have an ip_vhl of >> 0x42? Doesn't a valid IP packet need to have a header length of >> at least 5 (5 << 2 == 20 bytes)? > > huh? > the first byte of an IP packet is not the length.. the first byte > you see on a > packet trace will be the 4 bit version followed by a 4 bit HEADER > length, > followed by 8 bits of TOS (type of Service) and 16 bits of total > packet length. Agreed, but note that I said "header length" above, too. The smallest possible IP packet, without any IP options set, has an IP header length of 20, yes? http://www.ietf.org/rfc/rfc0791.txt, page 10, says: " IHL: 4 bits Internet Header Length is the length of the internet header in 32 bit words, and thus points to the beginning of the data. Note that the minimum value for a correct header is 5." ...and from : #define IPVERSION 4 /* * Structure of an internet header, naked of options. */ struct ip { #ifdef _IP_VHL u_char ip_vhl; /* version << 4 | header length >> 2 */ #else #if BYTE_ORDER == LITTLE_ENDIAN u_int ip_hl:4, /* header length */ ip_v:4; /* version */ #endif #if BYTE_ORDER == BIG_ENDIAN u_int ip_v:4, /* version */ ip_hl:4; /* header length */ #endif [ ... ] #define IP_VHL_BORING 0x45 0x45 means ip_v == 4 (IPv4) and ip_hl == 5 (five 32-bit words, or 20 bytes >> 2). > (it's in big-endian format.. beware) Sure. Network wire order is always big endian. :-) -- -Chuck