179126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski/*
279126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * Copyright (c) 2008, 2009,  Oracle and/or its affiliates. All rights reserved.
379126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski *
479126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
579126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski *
679126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * This code is free software; you can redistribute it and/or modify it
779126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * under the terms of the GNU General Public License version 2 only, as
879126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * published by the Free Software Foundation.  Oracle designates this
979126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * particular file as subject to the "Classpath" exception as provided
1079126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * by Oracle in the LICENSE file that accompanied this code.
1179126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski *
1279126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * This code is distributed in the hope that it will be useful, but WITHOUT
1379126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1479126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1579126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * version 2 for more details (a copy is included in the LICENSE file that
1679126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * accompanied this code).
1779126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski *
1879126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * You should have received a copy of the GNU General Public License version
1979126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * 2 along with this work; if not, write to the Free Software Foundation,
2079126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2179126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski *
2279126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2379126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * or visit www.oracle.com if you need additional information or have any
2479126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski * questions.
2579126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski *
2679126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski */
2779126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski// AUTOMATICALLY GENERATED FILE - DO NOT EDIT
2879126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebskipackage sun.nio.ch;
2979126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebskiimport java.net.SocketOption;
3079126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebskiimport java.net.StandardSocketOptions;
3179126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebskiimport java.net.ProtocolFamily;
3279126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebskiimport java.net.StandardProtocolFamily;
3379126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebskiimport java.util.Map;
3479126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebskiimport java.util.HashMap;
3579126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebskiclass SocketOptionRegistry {
3679126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski    private SocketOptionRegistry() { }
3779126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski    private static class RegistryKey {
3879126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski        private final SocketOption<?> name;
3979126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski        private final ProtocolFamily family;
4079126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski        RegistryKey(SocketOption<?> name, ProtocolFamily family) {
4179126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            this.name = name;
4279126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            this.family = family;
4379126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski        }
4479126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski        public int hashCode() {
4579126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            return name.hashCode() + family.hashCode();
4679126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski        }
4779126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski        public boolean equals(Object ob) {
4879126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            if (ob == null) return false;
4979126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            if (!(ob instanceof RegistryKey)) return false;
5079126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            RegistryKey other = (RegistryKey)ob;
5179126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            if (this.name != other.name) return false;
5279126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            if (this.family != other.family) return false;
5379126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            return true;
5479126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski        }
5579126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski    }
5679126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski    private static class LazyInitialization {
5779126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski        static final Map<RegistryKey,OptionKey> options = options();
5879126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski        private static Map<RegistryKey,OptionKey> options() {
5979126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            Map<RegistryKey,OptionKey> map =
6079126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski                new HashMap<RegistryKey,OptionKey>();
6179126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(StandardSocketOptions.SO_BROADCAST, Net.UNSPEC), new OptionKey(1, 6));
6279126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(StandardSocketOptions.SO_KEEPALIVE, Net.UNSPEC), new OptionKey(1, 9));
6379126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(StandardSocketOptions.SO_LINGER, Net.UNSPEC), new OptionKey(1, 13));
6479126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(StandardSocketOptions.SO_SNDBUF, Net.UNSPEC), new OptionKey(1, 7));
6579126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(StandardSocketOptions.SO_RCVBUF, Net.UNSPEC), new OptionKey(1, 8));
6679126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(StandardSocketOptions.SO_REUSEADDR, Net.UNSPEC), new OptionKey(1, 2));
6779126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(StandardSocketOptions.TCP_NODELAY, Net.UNSPEC), new OptionKey(6, 1));
6879126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(StandardSocketOptions.IP_TOS, StandardProtocolFamily.INET), new OptionKey(0, 1));
6979126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_IF, StandardProtocolFamily.INET), new OptionKey(0, 32));
7079126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_TTL, StandardProtocolFamily.INET), new OptionKey(0, 33));
7179126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_LOOP, StandardProtocolFamily.INET), new OptionKey(0, 34));
7279126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_IF, StandardProtocolFamily.INET6), new OptionKey(41, 17));
7379126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_TTL, StandardProtocolFamily.INET6), new OptionKey(41, 18));
7479126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(StandardSocketOptions.IP_MULTICAST_LOOP, StandardProtocolFamily.INET6), new OptionKey(41, 19));
7579126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            map.put(new RegistryKey(ExtendedSocketOption.SO_OOBINLINE, Net.UNSPEC), new OptionKey(1, 10));
7679126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski            return map;
7779126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski        }
7879126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski    }
7979126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski    public static OptionKey findOption(SocketOption<?> name, ProtocolFamily family) {
8079126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski        RegistryKey key = new RegistryKey(name, family);
8179126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski        return LazyInitialization.options.get(key);
8279126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski    }
8379126799e8d17a5da735cf252d2865254cdd295fPiotr Jastrzebski}
84