Date: Tue, 9 Jul 2002 14:00:38 -0400 (EDT) From: Kelly Yancey <kbyanc@posi.net> To: Juan Francisco Rodriguez Hervella <jrh@it.uc3m.es> Cc: freebsd-net@FreeBSD.ORG Subject: Re: About "sockaddr_in" and "sockaddr_in6" structures Message-ID: <Pine.BSF.4.05.10207091352310.3338-100000@kronos.networkrichmond.com> In-Reply-To: <3D2AE6BB.7CD0CEC7@it.uc3m.es>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.10207091352310.3338-100000>