net.c revision a687db7ce86c97d884b7ee1a68f59fcddf4d1c2a
/*
* Copyright (C) 2004, 2005, 2007, 2008 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* 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 ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC 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.16 2008/04/02 23:46:57 tbox Exp $ */
#include <config.h>
#include <errno.h>
#include <unistd.h>
#include <isc/strerror.h>
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRANY)
#endif
void InitSockets(void);
static isc_result_t
SOCKET s;
char strbuf[ISC_STRERRORSIZE];
int errval;
if (s == INVALID_SOCKET) {
errval = WSAGetLastError();
switch (errval) {
case WSAEAFNOSUPPORT:
case WSAEPROTONOSUPPORT:
case WSAEINVAL:
return (ISC_R_NOTFOUND);
default:
"socket() %s: %s",
"failed"),
strbuf);
return (ISC_R_UNEXPECTED);
}
}
closesocket(s);
return (ISC_R_SUCCESS);
}
static void
initialize_action(void) {
InitSockets();
#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);
}
isc_net_probeipv6(void) {
initialize();
return (ipv6_result);
}
isc_net_probeunix(void) {
return (ISC_R_NOTFOUND);
}
#ifdef ISC_PLATFORM_HAVEIPV6
#ifdef WANT_IPV6
static void
try_ipv6only(void) {
#ifdef IPV6_V6ONLY
SOCKET s;
int 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 == INVALID_SOCKET) {
"socket() %s: %s",
"failed"),
strbuf);
return;
}
on = 1;
goto close;
}
closesocket(s);
/* check for UDP sockets */
if (s == INVALID_SOCKET) {
"socket() %s: %s",
"failed"),
strbuf);
return;
}
on = 1;
goto close;
}
closeocket(s);
return;
#endif /* IPV6_V6ONLY */
}
static void
initialize_ipv6only(void) {
try_ipv6only) == ISC_R_SUCCESS);
}
static void
try_ipv6pktinfo(void) {
int s, on;
char strbuf[ISC_STRERRORSIZE];
int optname;
result = isc_net_probeipv6();
if (result != ISC_R_SUCCESS) {
return;
}
/* we only use this for UDP sockets */
if (s == INVALID_SOCKET) {
"socket() %s: %s",
"failed"),
strbuf);
return;
}
#ifdef IPV6_RECVPKTINFO
#else
#endif
on = 1;
goto close;
}
closesocket(s);
return;
}
static void
initialize_ipv6pktinfo(void) {
try_ipv6pktinfo) == ISC_R_SUCCESS);
}
#endif /* WANT_IPV6 */
#endif /* ISC_PLATFORM_HAVEIPV6 */
isc_net_probe_ipv6only(void) {
#ifdef ISC_PLATFORM_HAVEIPV6
#ifdef WANT_IPV6
#else
#endif
#endif
return (ipv6only_result);
}
isc_net_probe_ipv6pktinfo(void) {
#ifdef ISC_PLATFORM_HAVEIPV6
#ifdef WANT_IPV6
#else
#endif
#endif
return (ipv6pktinfo_result);
}
void
isc_net_disableipv4(void) {
initialize();
if (ipv4_result == ISC_R_SUCCESS)
}
void
isc_net_disableipv6(void) {
initialize();
if (ipv6_result == ISC_R_SUCCESS)
}
void
isc_net_enableipv4(void) {
initialize();
if (ipv4_result == ISC_R_DISABLED)
}
void
isc_net_enableipv6(void) {
initialize();
if (ipv6_result == ISC_R_DISABLED)
}