From owner-freebsd-net Tue Jul 9 11: 0:54 2002 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 3078637B400 for ; Tue, 9 Jul 2002 11:00:51 -0700 (PDT) Received: from kronos.networkrichmond.com (kronos.networkrichmond.com [64.240.180.22]) by mx1.FreeBSD.org (Postfix) with ESMTP id 803C443E4A for ; Tue, 9 Jul 2002 11:00:50 -0700 (PDT) (envelope-from kbyanc@posi.net) X-Provider: NetworkRichmond, Inc. http://www.networkrichmond.com/ Received: from localhost (kbyanc@localhost) by kronos.networkrichmond.com (8.9.3/8.9.3/antispam) with ESMTP id OAA04886; Tue, 9 Jul 2002 14:00:38 -0400 (EDT) Date: Tue, 9 Jul 2002 14:00:38 -0400 (EDT) From: Kelly Yancey X-Sender: kbyanc@kronos.networkrichmond.com To: Juan Francisco Rodriguez Hervella Cc: freebsd-net@FreeBSD.ORG Subject: Re: About "sockaddr_in" and "sockaddr_in6" structures In-Reply-To: <3D2AE6BB.7CD0CEC7@it.uc3m.es> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Tue, 9 Jul 2002, Juan Francisco Rodriguez Hervella wrote: > Hello: > > I'm seeing that "struct sockaddr_in" has a field like this: > > char sin_zero[8]; > > Why ? > Could anyone explain me what's used for ? > > Could it be bad if I'd add the same field to > "sockaddr_in6" ? > > PS: I'm trying to implement divert sockets for > IPv6 using the KAME implementation of "ip6fw". > > Thanks. > > JFRH. > The minimum size of a sockaddr's address portion (as defined in sys/socket.h) is 14 bytes (max is SOCK_MAXADDRLEN = 255); combined with the size of the sa_len and sa_family fields you get a minimum length of 16 bytes for the entire structure. The sin_zero field of sockaddr_in is to pad the structure out to this minimum length. Given that a sockaddr_in6 is already larger than the minimum required, there really isn't any point in adding the padding field to it. Kelly -- Kelly Yancey -- kbyanc@{posi.net,FreeBSD.org} To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message