src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java
author chegar
Thu, 21 Nov 2019 12:14:29 +0000
changeset 59205 afcc8af048e6
parent 59204 7b10581e9632
permissions -rw-r--r--
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     1
/*
59204
7b10581e9632 8232097: (sctp) SctpNet.init() results in java.lang.UnsatisfiedLinkError
chegar
parents: 47216
diff changeset
     2
 * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     4
 *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4669
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4669
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    10
 *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    15
 * accompanied this code).
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    16
 *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4669
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4669
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4669
diff changeset
    23
 * questions.
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    24
 */
11823
ee83ae88512d 7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents: 10137
diff changeset
    25
package sun.nio.ch.sctp;
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    26
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    27
import java.io.FileDescriptor;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    28
import java.io.IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    29
import java.net.InetAddress;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    30
import java.net.InetSocketAddress;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    31
import java.net.SocketAddress;
4669
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    32
import java.nio.channels.AlreadyBoundException;
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    33
import java.util.Set;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    34
import java.util.HashSet;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    35
import java.security.AccessController;
23582
d5fa3327ab3a 8038177: Eliminate unnecessary dependency to sun.security.action
mchung
parents: 23010
diff changeset
    36
import java.security.PrivilegedAction;
59205
afcc8af048e6 8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents: 59204
diff changeset
    37
import sun.net.util.IPAddressUtil;
11823
ee83ae88512d 7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents: 10137
diff changeset
    38
import sun.nio.ch.IOUtil;
ee83ae88512d 7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents: 10137
diff changeset
    39
import sun.nio.ch.Net;
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    40
import com.sun.nio.sctp.SctpSocketOption;
9679
d98ae8bc45fc 7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents: 7668
diff changeset
    41
import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    42
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    43
public class SctpNet {
23582
d5fa3327ab3a 8038177: Eliminate unnecessary dependency to sun.security.action
mchung
parents: 23010
diff changeset
    44
    private static final String osName = AccessController.doPrivileged(
d5fa3327ab3a 8038177: Eliminate unnecessary dependency to sun.security.action
mchung
parents: 23010
diff changeset
    45
        (PrivilegedAction<String>) () -> System.getProperty("os.name"));
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    46
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    47
    /* -- Miscellaneous SCTP utilities -- */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    48
7545
409091945418 7004439: SCTP_SET_PEER_PRIMARY_ADDR throws SocketException on Linux
chegar
parents: 5506
diff changeset
    49
    private static boolean IPv4MappedAddresses() {
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    50
        if ("SunOS".equals(osName)) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    51
            /* Solaris supports IPv4Mapped Addresses with bindx */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    52
            return true;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    53
        } /* else {  //other OS/implementations  */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    54
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    55
        /* lksctp/linux requires Ipv4 addresses */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    56
        return false;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    57
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    58
4669
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    59
    static boolean throwAlreadyBoundException() throws IOException {
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    60
        throw new AlreadyBoundException();
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    61
    }
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    62
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    63
    static void listen(int fd, int backlog) throws IOException {
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    64
        listen0(fd, backlog);
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    65
    }
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    66
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    67
    static int connect(int fd, InetAddress remote, int remotePort)
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    68
            throws IOException {
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    69
        return connect0(fd, remote, remotePort);
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    70
    }
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    71
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    72
    static void close(int fd) throws IOException {
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    73
        close0(fd);
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    74
    }
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    75
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    76
    static void preClose(int fd) throws IOException {
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    77
        preClose0(fd);
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    78
    }
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    79
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    80
    /**
4669
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
    81
     * @param  oneToOne
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    82
     *         if {@code true} returns a one-to-one sctp socket, otherwise
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    83
     *         returns a one-to-many sctp socket
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    84
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    85
    static FileDescriptor socket(boolean oneToOne) throws IOException {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    86
        int nativefd = socket0(oneToOne);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    87
        return IOUtil.newFD(nativefd);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    88
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    89
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    90
    static void bindx(int fd, InetAddress[] addrs, int port, boolean add)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    91
            throws IOException {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    92
        bindx(fd, addrs, port, addrs.length, add,
7545
409091945418 7004439: SCTP_SET_PEER_PRIMARY_ADDR throws SocketException on Linux
chegar
parents: 5506
diff changeset
    93
                IPv4MappedAddresses());
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    94
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    95
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    96
    static Set<SocketAddress> getLocalAddresses(int fd)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    97
            throws IOException {
18212
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
    98
        Set<SocketAddress> set = null;
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    99
        SocketAddress[] saa = getLocalAddresses0(fd);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   100
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   101
        if (saa != null) {
18212
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   102
            set = getRevealedLocalAddressSet(saa);
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   103
        }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   104
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   105
        return set;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   106
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   107
18212
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   108
    private static Set<SocketAddress> getRevealedLocalAddressSet(
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   109
            SocketAddress[] saa)
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   110
    {
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   111
         SecurityManager sm = System.getSecurityManager();
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   112
         Set<SocketAddress> set = new HashSet<>(saa.length);
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   113
         for (SocketAddress sa : saa) {
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   114
             set.add(getRevealedLocalAddress(sa, sm));
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   115
         }
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   116
         return set;
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   117
    }
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   118
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   119
    private static SocketAddress getRevealedLocalAddress(SocketAddress sa,
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   120
                                                         SecurityManager sm)
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   121
    {
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   122
        if (sm == null || sa == null)
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   123
            return sa;
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   124
        InetSocketAddress ia = (InetSocketAddress)sa;
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   125
        try{
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   126
            sm.checkConnect(ia.getAddress().getHostAddress(), -1);
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   127
            // Security check passed
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   128
        } catch (SecurityException e) {
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   129
            // Return loopback address
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   130
            return new InetSocketAddress(InetAddress.getLoopbackAddress(),
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   131
                                         ia.getPort());
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   132
        }
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   133
        return sa;
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   134
    }
22f8c33b0690 8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents: 14342
diff changeset
   135
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   136
    static Set<SocketAddress> getRemoteAddresses(int fd, int assocId)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   137
            throws IOException {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   138
        HashSet<SocketAddress> set = null;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   139
        SocketAddress[] saa = getRemoteAddresses0(fd, assocId);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   140
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   141
        if (saa != null) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   142
            set = new HashSet<SocketAddress>(saa.length);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   143
            for (SocketAddress sa : saa)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   144
                set.add(sa);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   145
        }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   146
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   147
        return set;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   148
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   149
10137
d92637d3d673 7068616: NIO libraries do not build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9679
diff changeset
   150
    static <T> void setSocketOption(int fd,
d92637d3d673 7068616: NIO libraries do not build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9679
diff changeset
   151
                                    SctpSocketOption<T> name,
d92637d3d673 7068616: NIO libraries do not build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9679
diff changeset
   152
                                    T value,
d92637d3d673 7068616: NIO libraries do not build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9679
diff changeset
   153
                                    int assocId)
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   154
            throws IOException {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   155
        if (value == null)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   156
            throw new IllegalArgumentException("Invalid option value");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   157
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   158
        if (name.equals(SCTP_INIT_MAXSTREAMS)) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   159
            InitMaxStreams maxStreamValue = (InitMaxStreams)value;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   160
            SctpNet.setInitMsgOption0(fd,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   161
                 maxStreamValue.maxInStreams(), maxStreamValue.maxOutStreams());
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   162
        } else if (name.equals(SCTP_PRIMARY_ADDR) ||
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   163
                   name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   164
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   165
            SocketAddress addr  = (SocketAddress) value;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   166
            if (addr == null)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   167
                throw new IllegalArgumentException("Invalid option value");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   168
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   169
            Net.checkAddress(addr);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   170
            InetSocketAddress netAddr = (InetSocketAddress)addr;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   171
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   172
            if (name.equals(SCTP_PRIMARY_ADDR)) {
59205
afcc8af048e6 8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents: 59204
diff changeset
   173
                InetAddress inetAddress = netAddr.getAddress();
afcc8af048e6 8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents: 59204
diff changeset
   174
                if (inetAddress.isLinkLocalAddress()) {
afcc8af048e6 8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents: 59204
diff changeset
   175
                    inetAddress = IPAddressUtil.toScopedAddress(inetAddress);
afcc8af048e6 8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents: 59204
diff changeset
   176
                }
7545
409091945418 7004439: SCTP_SET_PEER_PRIMARY_ADDR throws SocketException on Linux
chegar
parents: 5506
diff changeset
   177
                setPrimAddrOption0(fd,
409091945418 7004439: SCTP_SET_PEER_PRIMARY_ADDR throws SocketException on Linux
chegar
parents: 5506
diff changeset
   178
                                   assocId,
59205
afcc8af048e6 8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents: 59204
diff changeset
   179
                                   inetAddress,
7545
409091945418 7004439: SCTP_SET_PEER_PRIMARY_ADDR throws SocketException on Linux
chegar
parents: 5506
diff changeset
   180
                                   netAddr.getPort());
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   181
            } else {
7545
409091945418 7004439: SCTP_SET_PEER_PRIMARY_ADDR throws SocketException on Linux
chegar
parents: 5506
diff changeset
   182
                setPeerPrimAddrOption0(fd,
409091945418 7004439: SCTP_SET_PEER_PRIMARY_ADDR throws SocketException on Linux
chegar
parents: 5506
diff changeset
   183
                                       assocId,
409091945418 7004439: SCTP_SET_PEER_PRIMARY_ADDR throws SocketException on Linux
chegar
parents: 5506
diff changeset
   184
                                       netAddr.getAddress(),
409091945418 7004439: SCTP_SET_PEER_PRIMARY_ADDR throws SocketException on Linux
chegar
parents: 5506
diff changeset
   185
                                       netAddr.getPort(),
409091945418 7004439: SCTP_SET_PEER_PRIMARY_ADDR throws SocketException on Linux
chegar
parents: 5506
diff changeset
   186
                                       IPv4MappedAddresses());
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   187
            }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   188
        } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   189
            name.equals(SCTP_EXPLICIT_COMPLETE) ||
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   190
            name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   191
            name.equals(SCTP_NODELAY) ||
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   192
            name.equals(SO_SNDBUF) ||
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   193
            name.equals(SO_RCVBUF) ||
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   194
            name.equals(SO_LINGER)) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   195
            setIntOption(fd, name, value);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   196
        } else {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   197
            throw new AssertionError("Unknown socket option");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   198
        }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   199
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   200
10137
d92637d3d673 7068616: NIO libraries do not build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9679
diff changeset
   201
    static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   202
             throws IOException {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   203
         if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   204
            throw new IllegalArgumentException(
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   205
                    "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   206
        } else if (name.equals(SCTP_INIT_MAXSTREAMS)) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   207
            /* container for holding maxIn/Out streams */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   208
            int[] values = new int[2];
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   209
            SctpNet.getInitMsgOption0(fd, values);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   210
            return InitMaxStreams.create(values[0], values[1]);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   211
        } else if (name.equals(SCTP_PRIMARY_ADDR)) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   212
            return getPrimAddrOption0(fd, assocId);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   213
        } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   214
            name.equals(SCTP_EXPLICIT_COMPLETE) ||
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   215
            name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   216
            name.equals(SCTP_NODELAY) ||
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   217
            name.equals(SO_SNDBUF) ||
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   218
            name.equals(SO_RCVBUF) ||
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   219
            name.equals(SO_LINGER)) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   220
            return getIntOption(fd, name);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   221
        } else {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   222
            throw new AssertionError("Unknown socket option");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   223
        }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   224
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   225
10137
d92637d3d673 7068616: NIO libraries do not build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9679
diff changeset
   226
    static void setIntOption(int fd, SctpSocketOption<?> name, Object value)
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   227
            throws IOException {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   228
        if (value == null)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   229
            throw new IllegalArgumentException("Invalid option value");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   230
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   231
        Class<?> type = name.type();
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   232
        if (type != Integer.class && type != Boolean.class)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   233
            throw new AssertionError("Should not reach here");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   234
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   235
        if (name == SO_RCVBUF ||
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   236
            name == SO_SNDBUF)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   237
        {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   238
            int i = ((Integer)value).intValue();
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   239
            if (i < 0)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   240
                throw new IllegalArgumentException(
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   241
                        "Invalid send/receive buffer size");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   242
        } else if (name == SO_LINGER) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   243
            int i = ((Integer)value).intValue();
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   244
            if (i < 0)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   245
                value = Integer.valueOf(-1);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   246
            if (i > 65535)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   247
                value = Integer.valueOf(65535);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   248
        } else if (name.equals(SCTP_FRAGMENT_INTERLEAVE)) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   249
            int i = ((Integer)value).intValue();
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   250
            if (i < 0 || i > 2)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   251
                throw new IllegalArgumentException(
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   252
                        "Invalid value for SCTP_FRAGMENT_INTERLEAVE");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   253
        }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   254
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   255
        int arg;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   256
        if (type == Integer.class) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   257
            arg = ((Integer)value).intValue();
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   258
        } else {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   259
            boolean b = ((Boolean)value).booleanValue();
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   260
            arg = (b) ? 1 : 0;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   261
        }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   262
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   263
        setIntOption0(fd, ((SctpStdSocketOption)name).constValue(), arg);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   264
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   265
10137
d92637d3d673 7068616: NIO libraries do not build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9679
diff changeset
   266
    static Object getIntOption(int fd, SctpSocketOption<?> name)
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   267
            throws IOException {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   268
        Class<?> type = name.type();
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   269
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   270
        if (type != Integer.class && type != Boolean.class)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   271
            throw new AssertionError("Should not reach here");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   272
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   273
        if (!(name instanceof SctpStdSocketOption))
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   274
            throw new AssertionError("Should not reach here");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   275
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   276
        int value = getIntOption0(fd,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   277
                ((SctpStdSocketOption)name).constValue());
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   278
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   279
        if (type == Integer.class) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   280
            return Integer.valueOf(value);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   281
        } else {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   282
            return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   283
        }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   284
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   285
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   286
    static void shutdown(int fd, int assocId)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   287
            throws IOException {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   288
        shutdown0(fd, assocId);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   289
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   290
3072
a801b122142f 6855335: Several changes in the SCTP implementation.
chegar
parents: 2542
diff changeset
   291
    static FileDescriptor branch(int fd, int assocId) throws IOException {
a801b122142f 6855335: Several changes in the SCTP implementation.
chegar
parents: 2542
diff changeset
   292
        int nativefd = branch0(fd, assocId);
a801b122142f 6855335: Several changes in the SCTP implementation.
chegar
parents: 2542
diff changeset
   293
        return IOUtil.newFD(nativefd);
a801b122142f 6855335: Several changes in the SCTP implementation.
chegar
parents: 2542
diff changeset
   294
    }
a801b122142f 6855335: Several changes in the SCTP implementation.
chegar
parents: 2542
diff changeset
   295
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   296
    /* Native Methods */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   297
    static native int socket0(boolean oneToOne) throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   298
4669
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   299
    static native void listen0(int fd, int backlog) throws IOException;
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   300
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   301
    static native int connect0(int fd, InetAddress remote, int remotePort)
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   302
        throws IOException;
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   303
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   304
    static native void close0(int fd) throws IOException;
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   305
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   306
    static native void preClose0(int fd) throws IOException;
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   307
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   308
    static native void bindx(int fd, InetAddress[] addrs, int port, int length,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   309
            boolean add, boolean preferIPv6) throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   310
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   311
    static native int getIntOption0(int fd, int opt) throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   312
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   313
    static native void setIntOption0(int fd, int opt, int arg)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   314
        throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   315
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   316
    static native SocketAddress[] getLocalAddresses0(int fd) throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   317
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   318
    static native SocketAddress[] getRemoteAddresses0(int fd, int assocId)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   319
            throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   320
3072
a801b122142f 6855335: Several changes in the SCTP implementation.
chegar
parents: 2542
diff changeset
   321
    static native int branch0(int fd, int assocId) throws IOException;
a801b122142f 6855335: Several changes in the SCTP implementation.
chegar
parents: 2542
diff changeset
   322
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   323
    static native void setPrimAddrOption0(int fd, int assocId, InetAddress ia,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   324
            int port) throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   325
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   326
    static native void setPeerPrimAddrOption0(int fd, int assocId,
7545
409091945418 7004439: SCTP_SET_PEER_PRIMARY_ADDR throws SocketException on Linux
chegar
parents: 5506
diff changeset
   327
            InetAddress ia, int port, boolean preferIPv6) throws IOException;
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   328
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   329
    static native SocketAddress getPrimAddrOption0(int fd, int assocId)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   330
            throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   331
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   332
    /* retVals [0] maxInStreams, [1] maxOutStreams */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   333
    static native void getInitMsgOption0(int fd, int[] retVals) throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   334
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   335
    static native void setInitMsgOption0(int fd, int arg1, int arg2)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   336
            throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   337
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   338
    static native void shutdown0(int fd, int assocId);
4669
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   339
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   340
    static native void init();
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   341
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   342
    static {
59204
7b10581e9632 8232097: (sctp) SctpNet.init() results in java.lang.UnsatisfiedLinkError
chegar
parents: 47216
diff changeset
   343
        IOUtil.load();   // loads nio & net native libraries
7b10581e9632 8232097: (sctp) SctpNet.init() results in java.lang.UnsatisfiedLinkError
chegar
parents: 47216
diff changeset
   344
        java.security.AccessController.doPrivileged(
7b10581e9632 8232097: (sctp) SctpNet.init() results in java.lang.UnsatisfiedLinkError
chegar
parents: 47216
diff changeset
   345
                new java.security.PrivilegedAction<Void>() {
7b10581e9632 8232097: (sctp) SctpNet.init() results in java.lang.UnsatisfiedLinkError
chegar
parents: 47216
diff changeset
   346
                    public Void run() {
7b10581e9632 8232097: (sctp) SctpNet.init() results in java.lang.UnsatisfiedLinkError
chegar
parents: 47216
diff changeset
   347
                        System.loadLibrary("sctp");
7b10581e9632 8232097: (sctp) SctpNet.init() results in java.lang.UnsatisfiedLinkError
chegar
parents: 47216
diff changeset
   348
                        return null;
7b10581e9632 8232097: (sctp) SctpNet.init() results in java.lang.UnsatisfiedLinkError
chegar
parents: 47216
diff changeset
   349
                    }
7b10581e9632 8232097: (sctp) SctpNet.init() results in java.lang.UnsatisfiedLinkError
chegar
parents: 47216
diff changeset
   350
                });
4669
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   351
        init();
11d1dbd3598d 6915313: Reorganize implementation to make it more feasible to port to JDK6
chegar
parents: 3072
diff changeset
   352
    }
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   353
}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   354