Date: Tue, 27 Mar 2001 11:36:50 +0900 From: itojun@iijlab.net To: "Jonathan Graehl" <jonathan@graehl.org> Cc: "Freebsd-Net" <freebsd-net@freebsd.org> Subject: Re: proper way to test for INET/INET6? Message-ID: <13702.985660610@coconut.itojun.org> In-Reply-To: jonathan's message of Mon, 26 Mar 2001 12:30:15 PST. <NCBBLOALCKKINBNNEDDLGECKDNAA.jonathan@graehl.org>
next in thread | previous in thread | raw e-mail | index | archive | help
I guess you are talking about completely different topic from the original submitter. >Such hashing and comparison can be done more efficiently with functions tailored >for IPv4 or IPv6 addresses. Generic sockaddr*-taking library functions could >maintain this efficiency. I suppose in theory (since the sin6_flowinfo member >of sockaddr_in6 is supposed to be zeroed before the application sees it, and >likewise for the sin_zero of sockaddr_in) that a protocol independent >comparison/hash of sockaddr structures could simply operate on the raw bytes. I have no objection in putting such code like: switch (sa->sa_family) { case AF_INET: hash = compact(&((struct sockaddr_in *)sa)->sin_addr, 4); break; case AF_INET6: hash = compact(&((struct sockaddr_in6 *)sa)->sin6_addr, 16); break; default: errx(1, "unknown address family %d", sa->sa_family); } you don't need to know what kind of address family is supported by the kernel underneath, in this code fragment. itojun 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?13702.985660610>