net.c revision aa39170da817cae7b4c6c735cc832e05ec3d2351
/*
* Copyright (C) 1999-2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: net.c,v 1.5 2002/10/29 04:40:25 marka Exp $ */
#include <config.h>
#include <errno.h>
#include <unistd.h>
#include <isc/strerror.h>
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRANY)
#endif
static isc_result_t
int s;
char strbuf[ISC_STRERRORSIZE];
int errval;
if (s == -1) {
errval = WSAGetLastError();
switch (errval) {
case WSAEAFNOSUPPORT:
case WSAEPROTONOSUPPORT:
#ifdef EINVAL
case EINVAL:
#endif
return (ISC_R_NOTFOUND);
default:
"socket() %s: %s",
"failed"),
strbuf);
return (ISC_R_UNEXPECTED);
}
}
#ifdef ISC_PLATFORM_HAVEIPV6
#ifdef WANT_IPV6
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
struct sockaddr_in6 sin6;
unsigned int len;
/*
* Check to see if IPv6 is broken, as is common on Linux.
*/
{
"retrieving the address of an IPv6 "
"socket from the kernel failed.");
"IPv6 support is disabled.");
} else {
if (len == sizeof(struct sockaddr_in6))
else {
"IPv6 structures in kernel and "
"user space do not match.");
"IPv6 support is disabled.");
}
}
}
#endif
#endif
#endif
closesocket(s);
return (result);
}
static void
initialize_action(void) {
#ifdef ISC_PLATFORM_HAVEIPV6
#ifdef WANT_IPV6
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
#endif
#endif
#endif
}
static void
initialize(void) {
}
isc_net_probeipv4(void) {
initialize();
return (ipv4_result);
}
#ifdef ISC_PLATFORM_HAVEIPV6
#ifdef WANT_IPV6
isc_net_probeipv6(void) {
initialize();
return (ipv6_result);
}
static void
try_ipv6only(void) {
#ifdef IPV6_V6ONLY
int s, on;
char strbuf[ISC_STRERRORSIZE];
#endif
result = isc_net_probeipv6();
if (result != ISC_R_SUCCESS) {
return;
}
#ifndef IPV6_V6ONLY
return;
#else
/* check for TCP sockets */
if (s == -1) {
"socket() %s: %s",
"failed"),
strbuf);
return;
}
on = 1;
goto close;
}
close(s);
/* check for UDP sockets */
if (s == -1) {
"socket() %s: %s",
"failed"),
strbuf);
return;
}
on = 1;
goto close;
}
close(s);
close(s);
return;
#endif
}
static void
initialize_ipv6only(void) {
try_ipv6only) == ISC_R_SUCCESS);
}
#endif
#endif
isc_net_probe_ipv6only(void) {
#ifdef ISC_PLATFORM_HAVEIPV6
#ifdef WANT_IPV6
#else
#endif
#endif
return (ipv6only_result);
}