author | erikj |
Thu, 24 Mar 2016 14:23:37 +0100 | |
changeset 36672 | 9e18f32e76c9 |
permissions | -rw-r--r-- |
36672
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
1 |
/* |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
2 |
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
3 |
* |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
5 |
* |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. Oracle designates this |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
9 |
* particular file as subject to the "Classpath" exception as provided |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
10 |
* by Oracle in the LICENSE file that accompanied this code. |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
11 |
* |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
12 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
13 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
14 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
15 |
* version 2 for more details (a copy is included in the LICENSE file that |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
16 |
* accompanied this code). |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
17 |
* |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License version |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
19 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
20 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
21 |
* |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
22 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
23 |
* or visit www.oracle.com if you need additional information or have any |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
24 |
* questions. |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
25 |
* |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
26 |
*/ |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
27 |
@@END_COPYRIGHT@@ |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
28 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
29 |
#include <stdio.h> |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
30 |
#ifdef _WIN32 |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
31 |
#include <winsock2.h> |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
32 |
#include <ws2tcpip.h> |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
33 |
#else |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
34 |
#include <sys/types.h> |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
35 |
#include <sys/socket.h> |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
36 |
#include <netinet/in.h> |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
37 |
#include <netinet/tcp.h> |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
38 |
#endif |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
39 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
40 |
/* Defines SO_REUSEPORT */ |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
41 |
#if !defined(SO_REUSEPORT) |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
42 |
#ifdef _WIN32 |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
43 |
#define SO_REUSEPORT 0 |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
44 |
#elif __linux__ |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
45 |
#define SO_REUSEPORT 15 |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
46 |
#elif __solaris__ |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
47 |
#define SO_REUSEPORT 0x100e |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
48 |
#elif defined(AIX) || defined(MACOSX) |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
49 |
#define SO_REUSEPORT 0x0200 |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
50 |
#else |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
51 |
#define SO_REUSEPORT 0 |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
52 |
#endif |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
53 |
#endif |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
54 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
55 |
/* On Solaris, "sun" is defined as a macro. Undefine to make package |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
56 |
declaration valid */ |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
57 |
#undef sun |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
58 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
59 |
/* To be able to name the Java constants the same as the C constants without |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
60 |
having the preprocessor rewrite those identifiers, add PREFIX_ to all |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
61 |
identifiers matching a C constant. The PREFIX_ is filtered out in the |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
62 |
makefile. */ |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
63 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
64 |
@@START_HERE@@ |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
65 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
66 |
package sun.nio.ch; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
67 |
import java.net.SocketOption; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
68 |
import java.net.StandardSocketOptions; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
69 |
import java.net.ProtocolFamily; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
70 |
import java.net.StandardProtocolFamily; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
71 |
import java.util.Map; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
72 |
import java.util.HashMap; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
73 |
class SocketOptionRegistry { |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
74 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
75 |
private SocketOptionRegistry() { } |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
76 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
77 |
private static class RegistryKey { |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
78 |
private final SocketOption<?> name; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
79 |
private final ProtocolFamily family; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
80 |
RegistryKey(SocketOption<?> name, ProtocolFamily family) { |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
81 |
this.name = name; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
82 |
this.family = family; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
83 |
} |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
84 |
public int hashCode() { |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
85 |
return name.hashCode() + family.hashCode(); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
86 |
} |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
87 |
public boolean equals(Object ob) { |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
88 |
if (ob == null) return false; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
89 |
if (!(ob instanceof RegistryKey)) return false; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
90 |
RegistryKey other = (RegistryKey)ob; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
91 |
if (this.name != other.name) return false; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
92 |
if (this.family != other.family) return false; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
93 |
return true; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
94 |
} |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
95 |
} |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
96 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
97 |
private static class LazyInitialization { |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
98 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
99 |
static final Map<RegistryKey,OptionKey> options = options(); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
100 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
101 |
private static Map<RegistryKey,OptionKey> options() { |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
102 |
Map<RegistryKey,OptionKey> map = |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
103 |
new HashMap<RegistryKey,OptionKey>(); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
104 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_SO_BROADCAST, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
105 |
Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_BROADCAST)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
106 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_SO_KEEPALIVE, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
107 |
Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_KEEPALIVE)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
108 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_SO_LINGER, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
109 |
Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_LINGER)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
110 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_SO_SNDBUF, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
111 |
Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_SNDBUF)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
112 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_SO_RCVBUF, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
113 |
Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_RCVBUF)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
114 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_SO_REUSEADDR, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
115 |
Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_REUSEADDR)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
116 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_SO_REUSEPORT, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
117 |
Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_REUSEPORT)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
118 |
// IPPROTO_TCP is 6 |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
119 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_TCP_NODELAY, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
120 |
Net.UNSPEC), new OptionKey(6, TCP_NODELAY)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
121 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
122 |
// IPPROTO_IP is 0 |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
123 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_TOS, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
124 |
StandardProtocolFamily.INET), new OptionKey(0, IP_TOS)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
125 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_MULTICAST_IF, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
126 |
StandardProtocolFamily.INET), new OptionKey(0, IP_MULTICAST_IF)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
127 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_MULTICAST_TTL, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
128 |
StandardProtocolFamily.INET), new OptionKey(0, IP_MULTICAST_TTL)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
129 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_MULTICAST_LOOP, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
130 |
StandardProtocolFamily.INET), new OptionKey(0, IP_MULTICAST_LOOP)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
131 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
132 |
#ifdef AF_INET6 |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
133 |
// IPPROTO_IPV6 is 41 |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
134 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_TOS, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
135 |
StandardProtocolFamily.INET6), new OptionKey(41, IPV6_TCLASS)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
136 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_MULTICAST_IF, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
137 |
StandardProtocolFamily.INET6), new OptionKey(41, IPV6_MULTICAST_IF)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
138 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_MULTICAST_TTL, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
139 |
StandardProtocolFamily.INET6), new OptionKey(41, IPV6_MULTICAST_HOPS)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
140 |
map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_MULTICAST_LOOP, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
141 |
StandardProtocolFamily.INET6), new OptionKey(41, IPV6_MULTICAST_LOOP)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
142 |
#endif |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
143 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
144 |
map.put(new RegistryKey(ExtendedSocketOption.PREFIX_SO_OOBINLINE, |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
145 |
Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_OOBINLINE)); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
146 |
return map; |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
147 |
} |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
148 |
} |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
149 |
|
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
150 |
public static OptionKey findOption(SocketOption<?> name, ProtocolFamily family) { |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
151 |
RegistryKey key = new RegistryKey(name, family); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
152 |
return LazyInitialization.options.get(key); |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
153 |
} |
9e18f32e76c9
8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff
changeset
|
154 |
} |