net.c revision 2bd63eca275f4292452f6cb79cfb00a1065dd069
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * Copyright (C) 2004, 2005, 2007-2009, 2011-2015 Internet Systems Consortium, Inc. ("ISC")
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * Copyright (C) 1999-2003 Internet Software Consortium.
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * Permission to use, copy, modify, and/or distribute this software for any
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * purpose with or without fee is hereby granted, provided that the above
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * copyright notice and this permission notice appear in all copies.
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * PERFORMANCE OF THIS SOFTWARE.
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence * Definitions about UDP port range specification. This is a total mess of
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * portability variants: some use sysctl (but the sysctl names vary), some use
78da321b437bbb690ef570ccf17dcc8583a5a4a0Mark Andrews * system-specific interfaces, some have the same interface for IPv4 and IPv6,
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * some separate them, etc...
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * The last resort defaults: use all non well known port space
a5c30de2601a1d130a15a78cf3dc7610a02b2d85Mark Andrews#endif /* ISC_NET_PORTRANGELOW */
78da321b437bbb690ef570ccf17dcc8583a5a4a0Mark Andrews#endif /* ISC_NET_PORTRANGEHIGH */
78da321b437bbb690ef570ccf17dcc8583a5a4a0Mark Andrews#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRANY)
440164d3e36353a4b9801fcc05fe66b6cf1fb8ceMark Andrewsconst struct in6_addr isc_net_in6addrany = IN6ADDR_ANY_INIT;
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrewsstatic isc_once_t once_ipv6only = ISC_ONCE_INIT;
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrewsstatic isc_once_t once_ipv6pktinfo = ISC_ONCE_INIT;
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrewsstatic isc_result_t ipv4_result = ISC_R_NOTFOUND;
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrewsstatic isc_result_t ipv6_result = ISC_R_NOTFOUND;
a5c30de2601a1d130a15a78cf3dc7610a02b2d85Mark Andrewsstatic isc_result_t ipv6only_result = ISC_R_NOTFOUND;
a5c30de2601a1d130a15a78cf3dc7610a02b2d85Mark Andrewsstatic isc_result_t ipv6pktinfo_result = ISC_R_NOTFOUND;
78da321b437bbb690ef570ccf17dcc8583a5a4a0Mark Andrews "socket() %s: %s",
78da321b437bbb690ef570ccf17dcc8583a5a4a0Mark Andrews RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews /* check for TCP sockets */
440164d3e36353a4b9801fcc05fe66b6cf1fb8ceMark Andrews "socket() %s: %s",
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, (const char *)&on,
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews sizeof(on)) < 0) {
78da321b437bbb690ef570ccf17dcc8583a5a4a0Mark Andrews /* check for UDP sockets */
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews "socket() %s: %s",
a5c30de2601a1d130a15a78cf3dc7610a02b2d85Mark Andrews if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, (const char *)&on,
a5c30de2601a1d130a15a78cf3dc7610a02b2d85Mark Andrews sizeof(on)) < 0) {
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews#endif /* IPV6_V6ONLY */
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * XXXMPA requires win32/socket.c to be updated to support
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * WSASendMsg and WSARecvMsg which are themselves Winsock
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews * and compiler version dependent.
a5c30de2601a1d130a15a78cf3dc7610a02b2d85Mark Andrews /* we only use this for UDP sockets */
78da321b437bbb690ef570ccf17dcc8583a5a4a0Mark Andrews "socket() %s: %s",
a5c30de2601a1d130a15a78cf3dc7610a02b2d85Mark Andrews if (setsockopt(s, IPPROTO_IPV6, optname, (const char *) &on,
a5c30de2601a1d130a15a78cf3dc7610a02b2d85Mark Andrews sizeof(on)) < 0) {
a5c30de2601a1d130a15a78cf3dc7610a02b2d85Mark Andrews#endif /* __notyet__ */
a5c30de2601a1d130a15a78cf3dc7610a02b2d85Mark Andrews#endif /* WANT_IPV6 */
a5c30de2601a1d130a15a78cf3dc7610a02b2d85Mark Andrews#endif /* ISC_PLATFORM_HAVEIPV6 */
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews#endif /* __notyet__ */
a5c30de2601a1d130a15a78cf3dc7610a02b2d85Mark Andrewsisc_net_getudpportrange(int af, in_port_t *low, in_port_t *high) {
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews return (ISC_R_SUCCESS); /* we currently never fail in this function */