]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ip/tools.cc
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 21 Misc Functions */
19 #include <sys/socket.h>
22 #include <netinet/in.h>
24 #if HAVE_NETINET_IN6_H
25 #include <netinet/in6.h>
28 int Ip::EnableIpv6
= IPV6_OFF
;
34 // check for usable IPv6 sockets
35 int s
= socket(PF_INET6
, SOCK_STREAM
, 0);
37 debugs(3, 2, "IPv6 not supported on this machine. Auto-Disabled.");
38 EnableIpv6
= IPV6_OFF
;
42 // Test for v4-mapping capability
43 // (AKA. the operating system supports RFC 3493 section 5.3)
44 #if defined(IPV6_V6ONLY)
46 if (setsockopt(s
, IPPROTO_IPV6
, IPV6_V6ONLY
, (char *) &tos
, sizeof(int)) == 0) {
47 debugs(3, 2, "Detected IPv6 hybrid or v4-mapping stack...");
48 EnableIpv6
|= IPV6_SPECIAL_V4MAPPING
;
50 debugs(3, 2, "Detected split IPv4 and IPv6 stacks ...");
51 EnableIpv6
|= IPV6_SPECIAL_SPLITSTACK
;
54 // compliance here means they at least supply the option for compilers building code
55 // even if possibly to return hard-coded -1 on use.
56 debugs(3, 2, "Missing RFC 3493 compliance - attempting split IPv4 and IPv6 stacks ...");
57 EnableIpv6
|= IPV6_SPECIAL_SPLITSTACK
;
61 debugs(3, 2, "IPv6 transport " << (EnableIpv6
?"Enabled":"Disabled"));
63 debugs(3, 2, "IPv6 transport forced OFF by build parameters.");
64 EnableIpv6
= IPV6_OFF
;