From owner-freebsd-net Sun Mar 25 12:57:14 2001 Delivered-To: freebsd-net@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id CEB4737B719 for ; Sun, 25 Mar 2001 12:57:10 -0800 (PST) (envelope-from bright@fw.wintelcom.net) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id f2PKvAZ26677 for net@freebsd.org; Sun, 25 Mar 2001 12:57:10 -0800 (PST) Date: Sun, 25 Mar 2001 12:57:10 -0800 From: Alfred Perlstein To: net@freebsd.org Subject: proper way to test for INET/INET6? Message-ID: <20010325125710.S9431@fw.wintelcom.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i X-all-your-base: are belong to us. Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org I'm wondering how one is supposed to test for INET6 support in the kernel. Currently a few places do it in a somewhat bogus fashion like this: s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); if (s == -1) have_v6 = 0; else close(s); But this is wrong because unless errno is EPROTONOSUPPORT this might mean something else is horribly wrong. There's also at least one place that happens to check for EPROTONOSUPPORT, but it also erroniously checks for EPFNOSUPPORT and EAFNOSUPPORT which are actually the result one would get if they passed invalid arguments to socket(2). So what's the right thing to do here? -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message