Java Code Examples for com.sun.nio.sctp.SctpSocketOption#equals()

The following examples show how to use com.sun.nio.sctp.SctpSocketOption#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SctpNet.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
         throws IOException {
     if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
        throw new IllegalArgumentException(
                "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved");
    } else if (name.equals(SCTP_INIT_MAXSTREAMS)) {
        /* container for holding maxIn/Out streams */
        int[] values = new int[2];
        SctpNet.getInitMsgOption0(fd, values);
        return InitMaxStreams.create(values[0], values[1]);
    } else if (name.equals(SCTP_PRIMARY_ADDR)) {
        return getPrimAddrOption0(fd, assocId);
    } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
        name.equals(SCTP_EXPLICIT_COMPLETE) ||
        name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
        name.equals(SCTP_NODELAY) ||
        name.equals(SO_SNDBUF) ||
        name.equals(SO_RCVBUF) ||
        name.equals(SO_LINGER)) {
        return getIntOption(fd, name);
    } else {
        throw new AssertionError("Unknown socket option");
    }
}
 
Example 2
Source File: SctpNet.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
         throws IOException {
     if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
        throw new IllegalArgumentException(
                "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved");
    } else if (name.equals(SCTP_INIT_MAXSTREAMS)) {
        /* container for holding maxIn/Out streams */
        int[] values = new int[2];
        SctpNet.getInitMsgOption0(fd, values);
        return InitMaxStreams.create(values[0], values[1]);
    } else if (name.equals(SCTP_PRIMARY_ADDR)) {
        return getPrimAddrOption0(fd, assocId);
    } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
        name.equals(SCTP_EXPLICIT_COMPLETE) ||
        name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
        name.equals(SCTP_NODELAY) ||
        name.equals(SO_SNDBUF) ||
        name.equals(SO_RCVBUF) ||
        name.equals(SO_LINGER)) {
        return getIntOption(fd, name);
    } else {
        throw new AssertionError("Unknown socket option");
    }
}
 
Example 3
Source File: SctpMultiChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public <T> T getOption(SctpSocketOption<T> name, Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        return (T)SctpNet.getSocketOption(fdVal, name, assocId);
    }
}
 
Example 4
Source File: SctpMultiChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public <T> T getOption(SctpSocketOption<T> name, Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        return (T)SctpNet.getSocketOption(fdVal, name, assocId);
    }
}
 
Example 5
Source File: SctpMultiChannelImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
                                      T value,
                                      Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!(supportedOptions().contains(name)))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        SctpNet.setSocketOption(fdVal, name, value, assocId);
    }
    return this;
}
 
Example 6
Source File: SctpNet.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
         throws IOException {
     if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
        throw new IllegalArgumentException(
                "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved");
    } else if (name.equals(SCTP_INIT_MAXSTREAMS)) {
        /* container for holding maxIn/Out streams */
        int[] values = new int[2];
        SctpNet.getInitMsgOption0(fd, values);
        return InitMaxStreams.create(values[0], values[1]);
    } else if (name.equals(SCTP_PRIMARY_ADDR)) {
        return getPrimAddrOption0(fd, assocId);
    } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
        name.equals(SCTP_EXPLICIT_COMPLETE) ||
        name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
        name.equals(SCTP_NODELAY) ||
        name.equals(SO_SNDBUF) ||
        name.equals(SO_RCVBUF) ||
        name.equals(SO_LINGER)) {
        return getIntOption(fd, name);
    } else {
        throw new AssertionError("Unknown socket option");
    }
}
 
Example 7
Source File: SctpMultiChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
                                      T value,
                                      Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!(supportedOptions().contains(name)))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        SctpNet.setSocketOption(fdVal, name, value, assocId);
    }
    return this;
}
 
Example 8
Source File: SctpMultiChannelImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
                                      T value,
                                      Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!(supportedOptions().contains(name)))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        SctpNet.setSocketOption(fdVal, name, value, assocId);
    }
    return this;
}
 
Example 9
Source File: SctpNet.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
         throws IOException {
     if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
        throw new IllegalArgumentException(
                "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved");
    } else if (name.equals(SCTP_INIT_MAXSTREAMS)) {
        /* container for holding maxIn/Out streams */
        int[] values = new int[2];
        SctpNet.getInitMsgOption0(fd, values);
        return InitMaxStreams.create(values[0], values[1]);
    } else if (name.equals(SCTP_PRIMARY_ADDR)) {
        return getPrimAddrOption0(fd, assocId);
    } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
        name.equals(SCTP_EXPLICIT_COMPLETE) ||
        name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
        name.equals(SCTP_NODELAY) ||
        name.equals(SO_SNDBUF) ||
        name.equals(SO_RCVBUF) ||
        name.equals(SO_LINGER)) {
        return getIntOption(fd, name);
    } else {
        throw new AssertionError("Unknown socket option");
    }
}
 
Example 10
Source File: SctpMultiChannelImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
                                      T value,
                                      Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!(supportedOptions().contains(name)))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        SctpNet.setSocketOption(fdVal, name, value, assocId);
    }
    return this;
}
 
Example 11
Source File: SctpMultiChannelImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
                                      T value,
                                      Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!(supportedOptions().contains(name)))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        SctpNet.setSocketOption(fdVal, name, value, assocId);
    }
    return this;
}
 
Example 12
Source File: SctpNet.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
         throws IOException {
     if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
        throw new IllegalArgumentException(
                "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved");
    } else if (name.equals(SCTP_INIT_MAXSTREAMS)) {
        /* container for holding maxIn/Out streams */
        int[] values = new int[2];
        SctpNet.getInitMsgOption0(fd, values);
        return InitMaxStreams.create(values[0], values[1]);
    } else if (name.equals(SCTP_PRIMARY_ADDR)) {
        return getPrimAddrOption0(fd, assocId);
    } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
        name.equals(SCTP_EXPLICIT_COMPLETE) ||
        name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
        name.equals(SCTP_NODELAY) ||
        name.equals(SO_SNDBUF) ||
        name.equals(SO_RCVBUF) ||
        name.equals(SO_LINGER)) {
        return getIntOption(fd, name);
    } else {
        throw new AssertionError("Unknown socket option");
    }
}
 
Example 13
Source File: SctpMultiChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
                                      T value,
                                      Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!(supportedOptions().contains(name)))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        SctpNet.setSocketOption(fdVal, name, value, assocId);
    }
    return this;
}
 
Example 14
Source File: SctpMultiChannelImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
                                      T value,
                                      Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!(supportedOptions().contains(name)))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        SctpNet.setSocketOption(fdVal, name, value, assocId);
    }
    return this;
}
 
Example 15
Source File: SctpNet.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
         throws IOException {
     if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
        throw new IllegalArgumentException(
                "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved");
    } else if (name.equals(SCTP_INIT_MAXSTREAMS)) {
        /* container for holding maxIn/Out streams */
        int[] values = new int[2];
        SctpNet.getInitMsgOption0(fd, values);
        return InitMaxStreams.create(values[0], values[1]);
    } else if (name.equals(SCTP_PRIMARY_ADDR)) {
        return getPrimAddrOption0(fd, assocId);
    } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
        name.equals(SCTP_EXPLICIT_COMPLETE) ||
        name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
        name.equals(SCTP_NODELAY) ||
        name.equals(SO_SNDBUF) ||
        name.equals(SO_RCVBUF) ||
        name.equals(SO_LINGER)) {
        return getIntOption(fd, name);
    } else {
        throw new AssertionError("Unknown socket option");
    }
}
 
Example 16
Source File: SctpMultiChannelImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
                                      T value,
                                      Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!(supportedOptions().contains(name)))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        SctpNet.setSocketOption(fdVal, name, value, assocId);
    }
    return this;
}
 
Example 17
Source File: SctpNet.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
static <T> void setSocketOption(int fd,
                                SctpSocketOption<T> name,
                                T value,
                                int assocId)
        throws IOException {
    if (value == null)
        throw new IllegalArgumentException("Invalid option value");

    if (name.equals(SCTP_INIT_MAXSTREAMS)) {
        InitMaxStreams maxStreamValue = (InitMaxStreams)value;
        SctpNet.setInitMsgOption0(fd,
             maxStreamValue.maxInStreams(), maxStreamValue.maxOutStreams());
    } else if (name.equals(SCTP_PRIMARY_ADDR) ||
               name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {

        SocketAddress addr  = (SocketAddress) value;
        if (addr == null)
            throw new IllegalArgumentException("Invalid option value");

        Net.checkAddress(addr);
        InetSocketAddress netAddr = (InetSocketAddress)addr;

        if (name.equals(SCTP_PRIMARY_ADDR)) {
            setPrimAddrOption0(fd,
                               assocId,
                               netAddr.getAddress(),
                               netAddr.getPort());
        } else {
            setPeerPrimAddrOption0(fd,
                                   assocId,
                                   netAddr.getAddress(),
                                   netAddr.getPort(),
                                   IPv4MappedAddresses());
        }
    } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
        name.equals(SCTP_EXPLICIT_COMPLETE) ||
        name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
        name.equals(SCTP_NODELAY) ||
        name.equals(SO_SNDBUF) ||
        name.equals(SO_RCVBUF) ||
        name.equals(SO_LINGER)) {
        setIntOption(fd, name, value);
    } else {
        throw new AssertionError("Unknown socket option");
    }
}
 
Example 18
Source File: SctpNet.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
static <T> void setSocketOption(int fd,
                                SctpSocketOption<T> name,
                                T value,
                                int assocId)
        throws IOException {
    if (value == null)
        throw new IllegalArgumentException("Invalid option value");

    if (name.equals(SCTP_INIT_MAXSTREAMS)) {
        InitMaxStreams maxStreamValue = (InitMaxStreams)value;
        SctpNet.setInitMsgOption0(fd,
             maxStreamValue.maxInStreams(), maxStreamValue.maxOutStreams());
    } else if (name.equals(SCTP_PRIMARY_ADDR) ||
               name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {

        SocketAddress addr  = (SocketAddress) value;
        if (addr == null)
            throw new IllegalArgumentException("Invalid option value");

        Net.checkAddress(addr);
        InetSocketAddress netAddr = (InetSocketAddress)addr;

        if (name.equals(SCTP_PRIMARY_ADDR)) {
            setPrimAddrOption0(fd,
                               assocId,
                               netAddr.getAddress(),
                               netAddr.getPort());
        } else {
            setPeerPrimAddrOption0(fd,
                                   assocId,
                                   netAddr.getAddress(),
                                   netAddr.getPort(),
                                   IPv4MappedAddresses());
        }
    } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
        name.equals(SCTP_EXPLICIT_COMPLETE) ||
        name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
        name.equals(SCTP_NODELAY) ||
        name.equals(SO_SNDBUF) ||
        name.equals(SO_RCVBUF) ||
        name.equals(SO_LINGER)) {
        setIntOption(fd, name, value);
    } else {
        throw new AssertionError("Unknown socket option");
    }
}
 
Example 19
Source File: SctpNet.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
static <T> void setSocketOption(int fd,
                                SctpSocketOption<T> name,
                                T value,
                                int assocId)
        throws IOException {
    if (value == null)
        throw new IllegalArgumentException("Invalid option value");

    if (name.equals(SCTP_INIT_MAXSTREAMS)) {
        InitMaxStreams maxStreamValue = (InitMaxStreams)value;
        SctpNet.setInitMsgOption0(fd,
             maxStreamValue.maxInStreams(), maxStreamValue.maxOutStreams());
    } else if (name.equals(SCTP_PRIMARY_ADDR) ||
               name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {

        SocketAddress addr  = (SocketAddress) value;
        if (addr == null)
            throw new IllegalArgumentException("Invalid option value");

        Net.checkAddress(addr);
        InetSocketAddress netAddr = (InetSocketAddress)addr;

        if (name.equals(SCTP_PRIMARY_ADDR)) {
            setPrimAddrOption0(fd,
                               assocId,
                               netAddr.getAddress(),
                               netAddr.getPort());
        } else {
            setPeerPrimAddrOption0(fd,
                                   assocId,
                                   netAddr.getAddress(),
                                   netAddr.getPort(),
                                   IPv4MappedAddresses());
        }
    } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
        name.equals(SCTP_EXPLICIT_COMPLETE) ||
        name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
        name.equals(SCTP_NODELAY) ||
        name.equals(SO_SNDBUF) ||
        name.equals(SO_RCVBUF) ||
        name.equals(SO_LINGER)) {
        setIntOption(fd, name, value);
    } else {
        throw new AssertionError("Unknown socket option");
    }
}
 
Example 20
Source File: SctpNet.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
static <T> void setSocketOption(int fd,
                                SctpSocketOption<T> name,
                                T value,
                                int assocId)
        throws IOException {
    if (value == null)
        throw new IllegalArgumentException("Invalid option value");

    if (name.equals(SCTP_INIT_MAXSTREAMS)) {
        InitMaxStreams maxStreamValue = (InitMaxStreams)value;
        SctpNet.setInitMsgOption0(fd,
             maxStreamValue.maxInStreams(), maxStreamValue.maxOutStreams());
    } else if (name.equals(SCTP_PRIMARY_ADDR) ||
               name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {

        SocketAddress addr  = (SocketAddress) value;
        if (addr == null)
            throw new IllegalArgumentException("Invalid option value");

        Net.checkAddress(addr);
        InetSocketAddress netAddr = (InetSocketAddress)addr;

        if (name.equals(SCTP_PRIMARY_ADDR)) {
            setPrimAddrOption0(fd,
                               assocId,
                               netAddr.getAddress(),
                               netAddr.getPort());
        } else {
            setPeerPrimAddrOption0(fd,
                                   assocId,
                                   netAddr.getAddress(),
                                   netAddr.getPort(),
                                   IPv4MappedAddresses());
        }
    } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
        name.equals(SCTP_EXPLICIT_COMPLETE) ||
        name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
        name.equals(SCTP_NODELAY) ||
        name.equals(SO_SNDBUF) ||
        name.equals(SO_RCVBUF) ||
        name.equals(SO_LINGER)) {
        setIntOption(fd, name, value);
    } else {
        throw new AssertionError("Unknown socket option");
    }
}