From owner-freebsd-net Mon Mar 26 18:37: 4 2001 Delivered-To: freebsd-net@freebsd.org Received: from coconut.itojun.org (coconut.itojun.org [210.160.95.97]) by hub.freebsd.org (Postfix) with ESMTP id 4F7AF37B71B for ; Mon, 26 Mar 2001 18:37:01 -0800 (PST) (envelope-from itojun@itojun.org) Received: from kiwi.itojun.org (localhost.itojun.org [127.0.0.1]) by coconut.itojun.org (8.9.3+3.2W/3.7W) with ESMTP id LAA13704; Tue, 27 Mar 2001 11:36:50 +0900 (JST) To: "Jonathan Graehl" Cc: "Freebsd-Net" In-reply-to: jonathan's message of Mon, 26 Mar 2001 12:30:15 PST. X-Template-Reply-To: itojun@itojun.org X-Template-Return-Receipt-To: itojun@itojun.org X-PGP-Fingerprint: F8 24 B4 2C 8C 98 57 FD 90 5F B4 60 79 54 16 E2 Subject: Re: proper way to test for INET/INET6? From: itojun@iijlab.net Date: Tue, 27 Mar 2001 11:36:50 +0900 Message-ID: <13702.985660610@coconut.itojun.org> Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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