Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Mar 2001 12:57:10 -0800
From:      Alfred Perlstein <bright@wintelcom.net>
To:        net@freebsd.org
Subject:   proper way to test for INET/INET6?
Message-ID:  <20010325125710.S9431@fw.wintelcom.net>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010325125710.S9431>