]>
Commit | Line | Data |
---|---|---|
055421ee AJ |
1 | /* |
2 | * DEBUG: section 21 Misc Functions | |
3 | * AUTHOR: Amos Jeffries | |
4 | * | |
5 | * SQUID Web Proxy Cache http://www.squid-cache.org/ | |
6 | * ---------------------------------------------------------- | |
7 | * | |
8 | * Squid is the result of efforts by numerous individuals from | |
9 | * the Internet community; see the CONTRIBUTORS file for full | |
10 | * details. Many organizations have provided support for Squid's | |
11 | * development; see the SPONSORS file for full details. Squid is | |
12 | * Copyrighted (C) 2001 by the Regents of the University of | |
13 | * California; see the COPYRIGHT file for full details. Squid | |
14 | * incorporates software developed and/or copyrighted by other | |
15 | * sources; see the CREDITS file for full details. | |
16 | * | |
17 | * This program is free software; you can redistribute it and/or modify | |
18 | * it under the terms of the GNU General Public License as published by | |
19 | * the Free Software Foundation; either version 2 of the License, or | |
20 | * (at your option) any later version. | |
21 | * | |
22 | * This program is distributed in the hope that it will be useful, | |
23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 | * GNU General Public License for more details. | |
26 | * | |
27 | * You should have received a copy of the GNU General Public License | |
28 | * along with this program; if not, write to the Free Software | |
29 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
30 | * | |
31 | */ | |
32 | ||
33 | #include "config.h" | |
055421ee AJ |
34 | #include "Debug.h" |
35 | #include "ip/tools.h" | |
36 | ||
37 | #if HAVE_SYS_SOCKET_H | |
38 | #include <sys/socket.h> | |
39 | #endif | |
40 | #if HAVE_NETINET_IN_H | |
41 | #include <netinet/in.h> | |
42 | #endif | |
43 | #if HAVE_NETINET_IN6_H | |
44 | #include <netinet/in6.h> | |
45 | #endif | |
46 | ||
47 | int Ip::EnableIpv6 = IPV6_OFF; | |
48 | ||
49 | void | |
50 | Ip::ProbeTransport() | |
51 | { | |
52 | #if USE_IPV6 | |
53 | // check for usable IPv6 sockets | |
54 | int s = socket(PF_INET6, SOCK_STREAM, 0); | |
55 | if (s < 0) { | |
56 | debugs(3, 2, "IPv6 not supported on this machine. Auto-Disabled."); | |
57 | EnableIpv6 = IPV6_OFF; | |
58 | return; | |
59 | } | |
60 | ||
61 | // Test for v4-mapping capability | |
62 | int tos = 0; | |
6df7ad56 | 63 | if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &tos, sizeof(int)) == 0) { |
055421ee AJ |
64 | debugs(3, 2, "Detected IPv6 hybrid or v4-mapping stack..."); |
65 | EnableIpv6 |= IPV6_SPECIAL_V4MAPPING; | |
66 | } else { | |
67 | debugs(3, 2, "Detected split IPv4 and IPv6 stacks ..."); | |
e0209dae | 68 | EnableIpv6 |= IPV6_SPECIAL_SPLITSTACK; |
055421ee AJ |
69 | } |
70 | close(s); | |
71 | ||
72 | debugs(3, 2, "IPv6 transport " << (EnableIpv6?"Enabled":"Disabled")); | |
73 | #else | |
74 | debugs(3, 2, "IPv6 transport forced OFF by build parameters."); | |
75 | EnableIpv6 = IPV6_OFF; | |
76 | #endif | |
77 | } |