jdk/src/share/classes/com/sun/nio/sctp/SctpStandardSocketOption.java
author chegar
Thu, 16 Apr 2009 17:42:00 +0100
changeset 2542 d859108aea12
child 5506 202f599c92aa
permissions -rw-r--r--
4927640: Implementation of the sctp protocol Summary: An implementation-specific API for the Stream Control Transmission Protocol Reviewed-by: alanb, michaelm, jccollet
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     1
/*
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     2
 * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
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
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    23
 * have any questions.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    24
 */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    25
package com.sun.nio.sctp;
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.net.SocketAddress;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    28
import sun.nio.ch.SctpStdSocketOption;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    29
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    30
/**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    31
 * SCTP channels supports the socket options defined by this class
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    32
 * (as well as those listed in the particular channel class) and may support
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    33
 * additional Implementation specific socket options.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    34
 *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    35
 * @since 1.7
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    36
 */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    37
public class SctpStandardSocketOption {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    38
    private SctpStandardSocketOption() {}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    39
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    40
     * Enables or disables message fragmentation.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    41
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    42
     * <P> The value of this socket option is a {@code Boolean} that represents
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    43
     * whether the option is enabled or disabled. If enabled no SCTP message
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    44
     * fragmentation will be performed. Instead if a message being sent
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    45
     * exceeds the current PMTU size, the message will NOT be sent and
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    46
     * an error will be indicated to the user.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    47
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    48
     * <P> It is implementation specific whether or not this option is
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    49
     * supported.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    50
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    51
    public static final SctpSocketOption<Boolean> SCTP_DISABLE_FRAGMENTS = new
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    52
        SctpStdSocketOption<Boolean>("SCTP_DISABLE_FRAGMENTS", Boolean.class,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    53
        sun.nio.ch.SctpStdSocketOption.SCTP_DISABLE_FRAGMENTS);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    54
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    55
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    56
     * Enables or disables explicit message completion.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    57
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    58
     * <p> The value of this socket option is a {@code Boolean} that represents
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    59
     * whether the option is enabled or disabled. When this option is enabled,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    60
     * the {@code send} method may be invoked multiple times to a send message.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    61
     * The {@code isComplete} parameter of the {@link MessageInfo} must only
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    62
     * be set to {@code true} for the final send to indicate that the message is
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    63
     * complete. If this option is disabled then each individual {@code send}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    64
     * invocation is considered complete.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    65
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    66
     * <P> The default value of the option is {@code false} indicating that the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    67
     * option is disabled. It is implementation specific whether or not this
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    68
     * option is supported.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    69
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    70
    public static final SctpSocketOption<Boolean> SCTP_EXPLICIT_COMPLETE = new
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    71
        SctpStdSocketOption<Boolean>("SCTP_EXPLICIT_COMPLETE", Boolean.class,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    72
        sun.nio.ch.SctpStdSocketOption.SCTP_EXPLICIT_COMPLETE);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    73
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    74
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    75
     * Fragmented interleave controls how the presentation of messages occur
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    76
     * for the message receiver. There are three levels of fragment interleave
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    77
     * defined. Two of the levels effect {@link SctpChannel}, while
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    78
     * {@link SctpMultiChannel} is effected by all three levels.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    79
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    80
     * <P> This option takes an {@code Integer} value. It can be set to a value
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    81
     * of {@code 0}, {@code 1} or {@code 2}.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    82
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    83
     * <P> Setting the three levels provides the following receiver
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    84
     * interactions:
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    85
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    86
     * <P> {@code level 0} - Prevents the interleaving of any messages. This
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    87
     * means that when a partial delivery begins, no other messages will be
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    88
     * received except the message being partially delivered. If another message
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    89
     * arrives on a different stream (or association) that could be delivered,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    90
     * it will be blocked waiting for the user to read all of the partially
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    91
     * delivered message.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    92
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    93
     * <P> {@code level 1} - Allows interleaving of messages that are from
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    94
     * different associations. For {@code SctpChannel}, level 0 and
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    95
     * level 1 have the same meaning since an {@code SctpChannel} always
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    96
     * receives messages from the same association. Note that setting an {@code
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    97
     * SctpMultiChannel} to this level may cause multiple partial
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    98
     * delivers from different associations but for any given association, only
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    99
     * one message will be delivered until all parts of a message have been
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   100
     * delivered. This means that one large message, being read with an
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   101
     * association identification of "X", will block other messages from
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   102
     * association "X" from being delivered.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   103
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   104
     * <P> {@code level 2} - Allows complete interleaving of messages. This
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   105
     * level requires that the sender carefully observe not only the peer
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   106
     * {@code Association} but also must pay careful attention to the stream
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   107
     * number. With this option enabled a partially delivered message may begin
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   108
     * being delivered for association "X" stream "Y" and the next subsequent
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   109
     * receive may return a message from association "X" stream "Z". Note that
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   110
     * no other messages would be delivered for association "X" stream "Y"
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   111
     * until all of stream "Y"'s partially delivered message was read.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   112
     * Note that this option effects both channel types.  Also note that
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   113
     * for an {@code SctpMultiChannel} not only may another streams
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   114
     * message from the same association be delivered from the next receive,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   115
     * some other associations message may be delivered upon the next receive.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   116
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   117
     * <P> It is implementation specific whether or not this option is
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   118
     * supported.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   119
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   120
    public static final SctpSocketOption<Integer> SCTP_FRAGMENT_INTERLEAVE =
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   121
            new SctpStdSocketOption<Integer>("SCTP_FRAGMENT_INTERLEAVE",
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   122
                  Integer.class,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   123
                  sun.nio.ch.SctpStdSocketOption.SCTP_FRAGMENT_INTERLEAVE);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   124
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   125
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   126
     * The maximum number of streams requested by the local endpoint during
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   127
     * association initialization.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   128
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   129
     * <P> The value of this socket option is an {@link
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   130
     * SctpStandardSocketOption.InitMaxStreams InitMaxStreams}, that represents
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   131
     * the maximum number of inbound and outbound streams that an association
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   132
     * on the channel is prepared to support.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   133
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   134
     * <P> For an {@link SctpChannel} this option may only be used to
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   135
     * change the number of inbound/outbound streams prior to connecting.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   136
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   137
     * <P> For an {@link SctpMultiChannel} this option determines
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   138
     * the maximum number of inbound/outbound streams new associations setup
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   139
     * on the channel will be prepared to support.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   140
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   141
     * <P> For an {@link SctpServerChannel} this option determines the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   142
     * maximum number of inbound/outbound streams accepted sockets will
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   143
     * negotiate with their connecting peer.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   144
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   145
     * <P> In all cases the value set by this option is used in the negotiation
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   146
     * of new associations setup on the channel's socket and the actual
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   147
     * maximum number of inbound/outbound streams that have been negotiated
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   148
     * with the peer can be retrieved from the appropriate {@link
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   149
     * Association}. The {@code Association} can be retrieved from the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   150
     * {@link AssociationChangeNotification.AssocChangeEvent#COMM_UP COMM_UP}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   151
     * {@link AssociationChangeNotification} belonging to that association.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   152
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   153
     * <p> This value is bounded by the actual implementation. In other
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   154
     * words the user may be able to support more streams than the Operating
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   155
     * System. In such a case, the Operating System limit may override the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   156
     * value requested by the user. The default value of 0 indicates to use
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   157
     * the endpoints default value.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   158
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   159
    public static final SctpSocketOption
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   160
        <SctpStandardSocketOption.InitMaxStreams> SCTP_INIT_MAXSTREAMS =
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   161
        new SctpStdSocketOption<SctpStandardSocketOption.InitMaxStreams>(
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   162
        "SCTP_INIT_MAXSTREAMS", SctpStandardSocketOption.InitMaxStreams.class);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   163
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   164
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   165
     * Enables or disables a Nagle-like algorithm.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   166
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   167
     * <P> The value of this socket option is a {@code Boolean} that represents
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   168
     * whether the option is enabled or disabled. SCTP uses an algorithm like
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   169
     * <em>The Nagle Algorithm</em> to coalesce short segments and
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   170
     * improve network efficiency.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   171
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   172
    public static final SctpSocketOption<Boolean> SCTP_NODELAY =
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   173
        new SctpStdSocketOption<Boolean>("SCTP_NODELAY", Boolean.class,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   174
        sun.nio.ch.SctpStdSocketOption.SCTP_NODELAY);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   175
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   176
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   177
     * Requests that the local SCTP stack use the given peer address as
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   178
     * the association primary.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   179
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   180
     * <P> The value of this socket option is a {@code SocketAddress}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   181
     * that represents the peer address that the local SCTP stack should use as
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   182
     * the association primary. The address must be one of the association
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   183
     * peer's addresses.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   184
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   185
     * <P> An {@code SctpMultiChannel} can control more than one
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   186
     * association, the association parameter must be given when setting or
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   187
     * retrieving this option.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   188
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   189
     * <P> Since {@code SctpChannel} only controls one association,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   190
     * the association parameter is not required and this option can be
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   191
     * set or queried directly.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   192
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   193
     public static final SctpSocketOption<SocketAddress> SCTP_PRIMARY_ADDR =
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   194
             new SctpStdSocketOption<SocketAddress>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   195
             ("SCTP_PRIMARY_ADDR", SocketAddress.class);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   196
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   197
     /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   198
     * Requests that the peer mark the enclosed address as the association
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   199
     * primary.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   200
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   201
     * <P> The value of this socket option is a {@code SocketAddress}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   202
     * that represents the local address that the peer should use as its
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   203
     * primary address. The given address must be one of the association's
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   204
     * locally bound addresses.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   205
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   206
     * <P> An {@code SctpMultiChannel} can control more than one
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   207
     * association, the association parameter must be given when setting or
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   208
     * retrieving this option.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   209
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   210
     * <P> Since {@code SctpChannel} only controls one association,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   211
     * the association parameter is not required and this option can be
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   212
     * queried directly.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   213
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   214
     * <P> Note, this is a set only option and cannot be retrieved by {@code
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   215
     * getOption}. It is implementation specific whether or not this
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   216
     * option is supported.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   217
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   218
    public static final SctpSocketOption<SocketAddress> SCTP_SET_PEER_PRIMARY_ADDR =
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   219
            new SctpStdSocketOption<SocketAddress>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   220
            ("SCTP_SET_PEER_PRIMARY_ADDR", SocketAddress.class);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   221
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   222
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   223
     * The size of the socket send buffer.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   224
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   225
     * <p> The value of this socket option is an {@code Integer} that is the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   226
     * size of the socket send buffer in bytes. The socket send buffer is an
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   227
     * output buffer used by the networking implementation. It may need to be
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   228
     * increased for high-volume connections. The value of the socket option is
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   229
     * a <em>hint</em> to the implementation to size the buffer and the actual
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   230
     * size may differ. The socket option can be queried to retrieve the actual
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   231
     * size.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   232
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   233
     * <p> For {@code SctpChannel}, this controls the amount of data
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   234
     * the SCTP stack may have waiting in internal buffers to be sent. This
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   235
     * option therefore bounds the maximum size of data that can be sent in a
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   236
     * single send call.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   237
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   238
     * <P> For {@code SctpMultiChannel}, the effect is the same as for {@code
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   239
     * SctpChannel}, except that it applies to all associations. The option
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   240
     * applies to each association's window size separately.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   241
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   242
     * <p> An implementation allows this socket option to be set before the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   243
     * socket is bound or connected. Whether an implementation allows the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   244
     * socket send buffer to be changed after the socket is bound is system
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   245
     * dependent.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   246
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   247
    public static final SctpSocketOption<Integer> SO_SNDBUF =
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   248
        new SctpStdSocketOption<Integer>("SO_SNDBUF", Integer.class,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   249
        sun.nio.ch.SctpStdSocketOption.SO_SNDBUF);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   250
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   251
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   252
     * The size of the socket receive buffer.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   253
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   254
     * <P> The value of this socket option is an {@code Integer} that is the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   255
     * size of the socket receive buffer in bytes. The socket receive buffer is
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   256
     * an input buffer used by the networking implementation. It may need to be
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   257
     * increased for high-volume connections or decreased to limit the possible
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   258
     * backlog of incoming data. The value of the socket option is a
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   259
     * <em>hint</em> to the implementation to size the buffer and the actual
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   260
     * size may differ.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   261
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   262
     * <P> For {@code SctpChannel}, this controls the receiver window size.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   263
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   264
     * <P> For {@code SctpMultiChannel}, the meaning is implementation
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   265
     * dependent. It might control the receive buffer for each association bound
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   266
     * to the socket descriptor or it might control the receive buffer for the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   267
     * whole socket.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   268
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   269
     * <p> An implementation allows this socket option to be set before the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   270
     * socket is bound or connected. Whether an implementation allows the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   271
     * socket receive buffer to be changed after the socket is bound is system
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   272
     * dependent.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   273
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   274
    public static final SctpSocketOption<Integer> SO_RCVBUF =
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   275
        new SctpStdSocketOption<Integer>("SO_RCVBUF", Integer.class,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   276
        sun.nio.ch.SctpStdSocketOption.SO_RCVBUF);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   277
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   278
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   279
     * Linger on close if data is present.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   280
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   281
     * <p> The value of this socket option is an {@code Integer} that controls
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   282
     * the action taken when unsent data is queued on the socket and a method
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   283
     * to close the socket is invoked. If the value of the socket option is zero
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   284
     * or greater, then it represents a timeout value, in seconds, known as the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   285
     * <em>linger interval</em>. The linger interval is the timeout for the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   286
     * {@code close} method to block while the operating system attempts to
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   287
     * transmit the unsent data or it decides that it is unable to transmit the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   288
     * data. If the value of the socket option is less than zero then the option
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   289
     * is disabled. In that case the {@code close} method does not wait until
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   290
     * unsent data is transmitted; if possible the operating system will transmit
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   291
     * any unsent data before the connection is closed.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   292
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   293
     * <p> This socket option is intended for use with sockets that are configured
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   294
     * in {@link java.nio.channels.SelectableChannel#isBlocking() blocking} mode
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   295
     * only. The behavior of the {@code close} method when this option is
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   296
     * enabled on a non-blocking socket is not defined.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   297
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   298
     * <p> The initial value of this socket option is a negative value, meaning
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   299
     * that the option is disabled. The option may be enabled, or the linger
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   300
     * interval changed, at any time. The maximum value of the linger interval
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   301
     * is system dependent. Setting the linger interval to a value that is
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   302
     * greater than its maximum value causes the linger interval to be set to
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   303
     * its maximum value.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   304
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   305
    public static final SctpSocketOption<Integer> SO_LINGER =
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   306
        new SctpStdSocketOption<Integer>("SO_LINGER", Integer.class,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   307
        sun.nio.ch.SctpStdSocketOption.SO_LINGER);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   308
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   309
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   310
     * This class is used to set the maximum number of inbound/outbound streams
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   311
     * used by the local endpoint during association initialization. An
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   312
     * instance of this class is used to set the {@link
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   313
     * SctpStandardSocketOption#SCTP_INIT_MAXSTREAMS SCTP_INIT_MAXSTREAMS}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   314
     * socket option.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   315
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   316
     * @since 1.7
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   317
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   318
    public static class InitMaxStreams {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   319
        private int maxInStreams;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   320
        private int maxOutStreams;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   321
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   322
        private InitMaxStreams(int maxInStreams, int maxOutStreams) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   323
           this.maxInStreams = maxInStreams;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   324
           this.maxOutStreams = maxOutStreams;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   325
        }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   326
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   327
        /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   328
         * Creates an InitMaxStreams instance.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   329
         *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   330
         * @param  maxInStreams
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   331
         *         The maximum number of inbound streams, where
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   332
         *         {@code 0 <= maxInStreams <= 65536}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   333
         *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   334
         * @param  maxOutStreams
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   335
         *         The maximum number of outbound streams, where
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   336
         *         {@code 0 <= maxOutStreams <= 65536}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   337
         *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   338
         * @return  An {@code InitMaxStreams} instance
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   339
         *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   340
         * @throws  IllegalArgumentException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   341
         *          If an argument is outside of specified bounds
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   342
         */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   343
        public static InitMaxStreams create
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   344
              (int maxInStreams, int maxOutStreams) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   345
            if (maxOutStreams < 0 || maxOutStreams > 65535)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   346
                throw new IllegalArgumentException(
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   347
                      "Invalid maxOutStreams value");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   348
            if (maxInStreams < 0 || maxInStreams > 65535)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   349
                throw new IllegalArgumentException(
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   350
                      "Invalid maxInStreams value");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   351
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   352
            return new InitMaxStreams(maxInStreams, maxOutStreams);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   353
        }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   354
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   355
        /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   356
         * Returns the maximum number of inbound streams.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   357
         *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   358
         * @return  Maximum inbound streams
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   359
         */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   360
        public int maxInStreams() {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   361
            return maxInStreams;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   362
        }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   363
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   364
        /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   365
         * Returns the maximum number of outbound streams.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   366
         *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   367
         * @return  Maximum outbound streams
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   368
         */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   369
        public int maxOutStreams() {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   370
            return maxOutStreams;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   371
        }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   372
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   373
        /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   374
         * Returns a string representation of this init max streams, including
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   375
         * the maximum in and out bound streams.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   376
         *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   377
         * @return  A string representation of this init max streams
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   378
         */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   379
        @Override
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   380
        public String toString() {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   381
            StringBuilder sb = new StringBuilder();
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   382
            sb.append(super.toString()).append(" [");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   383
            sb.append("maxInStreams:").append(maxInStreams);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   384
            sb.append("maxOutStreams:").append(maxOutStreams).append("]");
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   385
            return sb.toString();
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   386
        }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   387
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   388
        /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   389
         * Returns true if the specified object is another {@code InitMaxStreams}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   390
         * instance with the same number of in and out bound streams.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   391
         *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   392
         * @param  obj
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   393
         *         The object to be compared with this init max streams
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   394
         *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   395
         * @return  true if the specified object is another
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   396
         *          {@code InitMaxStreams} instance with the same number of in
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   397
         *          and out bound streams
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   398
         */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   399
        @Override
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   400
        public boolean equals(Object obj) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   401
            if (obj != null && obj instanceof InitMaxStreams) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   402
                InitMaxStreams that = (InitMaxStreams) obj;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   403
                if (this.maxInStreams == that.maxInStreams &&
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   404
                    this.maxOutStreams == that.maxOutStreams)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   405
                    return true;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   406
            }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   407
            return false;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   408
        }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   409
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   410
        /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   411
         * Returns a hash code value for this init max streams.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   412
         */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   413
        @Override
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   414
        public int hashCode() {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   415
            int hash = 7 ^ maxInStreams ^ maxOutStreams;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   416
            return hash;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   417
        }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   418
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   419
}