1 /*
2  * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This code is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License version 2 only, as
8  * published by the Free Software Foundation.  Oracle designates this
9  * particular file as subject to the "Classpath" exception as provided
10  * by Oracle in the LICENSE file that accompanied this code.
11  *
12  * This code is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15  * version 2 for more details (a copy is included in the LICENSE file that
16  * accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License version
19  * 2 along with this work; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21  *
22  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23  * or visit www.oracle.com if you need additional information or have any
24  * questions.
25  *
26  */
27 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
28 package sun.nio.ch;
29 import java.net.SocketOption;
30 import java.net.StandardSocketOptions;
31 import java.net.ProtocolFamily;
32 import java.net.StandardProtocolFamily;
33 import java.util.Map;
34 import java.util.HashMap;
35 class SocketOptionRegistry {
SocketOptionRegistry()36     private SocketOptionRegistry() { }
37     private static class RegistryKey {
38         private final SocketOption<?> name;
39         private final ProtocolFamily family;
RegistryKey(SocketOption<?> name, ProtocolFamily family)40         RegistryKey(SocketOption<?> name, ProtocolFamily family) {
41             this.name = name;
42             this.family = family;
43         }
hashCode()44         public int hashCode() {
45             return name.hashCode() + family.hashCode();
46         }
equals(Object ob)47         public boolean equals(Object ob) {
48             if (ob == null) return false;
49             if (!(ob instanceof RegistryKey)) return false;
50             RegistryKey other = (RegistryKey)ob;
51             if (this.name != other.name) return false;
52             if (this.family != other.family) return false;
53             return true;
54         }
55     }
56     private static class LazyInitialization {
57         static final Map<RegistryKey,OptionKey> options = options();
options()58         private static Map<RegistryKey,OptionKey> options() {
59             Map<RegistryKey,OptionKey> map =
60                 new HashMap<RegistryKey,OptionKey>();
61             map.put(new RegistryKey(StandardSocketOptions.SO_BROADCAST, Net.UNSPEC), new OptionKey(1, 6));
62             map.put(new RegistryKey(StandardSocketOptions.SO_KEEPALIVE, Net.UNSPEC), new OptionKey(1, 9));
63             map.put(new RegistryKey(StandardSocketOptions.SO_LINGER, Net.UNSPEC), new OptionKey(1, 13));
64             map.put(new RegistryKey(StandardSocketOptions.SO_SNDBUF, Net.UNSPEC), new OptionKey(1, 7));
65             map.put(new RegistryKey(StandardSocketOptions.SO_RCVBUF, Net.UNSPEC), new OptionKey(1, 8));
66             map.put(new RegistryKey(StandardSocketOptions.SO_REUSEADDR, Net.UNSPEC), new OptionKey(1, 2));
67             map.put(new RegistryKey(StandardSocketOptions.TCP_NODELAY, Net.UNSPEC), new OptionKey(6, 1));
68             map.put(new RegistryKey(StandardSocketOptions.IP_TOS, StandardProtocolFamily.INET), new OptionKey(0, 1));
69             map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_IF, StandardProtocolFamily.INET), new OptionKey(0, 32));
70             map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_TTL, StandardProtocolFamily.INET), new OptionKey(0, 33));
71             map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_LOOP, StandardProtocolFamily.INET), new OptionKey(0, 34));
72             map.put(new RegistryKey(StandardSocketOptions.IP_TOS, StandardProtocolFamily.INET6), new OptionKey(41, 67));
73             map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_IF, StandardProtocolFamily.INET6), new OptionKey(41, 17));
74             map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_TTL, StandardProtocolFamily.INET6), new OptionKey(41, 18));
75             map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_LOOP, StandardProtocolFamily.INET6), new OptionKey(41, 19));
76             map.put(new RegistryKey(ExtendedSocketOption.SO_OOBINLINE, Net.UNSPEC), new OptionKey(1, 10));
77             return map;
78         }
79     }
findOption(SocketOption<?> name, ProtocolFamily family)80     public static OptionKey findOption(SocketOption<?> name, ProtocolFamily family) {
81         RegistryKey key = new RegistryKey(name, family);
82         return LazyInitialization.options.get(key);
83     }
84 }
85