1 /* 2 * Copyright 2011 The Netty Project 3 * 4 * The Netty Project licenses this file to you under the Apache License, 5 * version 2.0 (the "License"); you may not use this file except in compliance 6 * with the License. You may obtain a copy of the License at: 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations 14 * under the License. 15 */ 16 package io.netty.channel.sctp; 17 18 import com.sun.nio.sctp.Association; 19 import io.netty.channel.Channel; 20 import io.netty.channel.ChannelFuture; 21 import io.netty.channel.ChannelPromise; 22 23 import java.net.InetAddress; 24 import java.net.InetSocketAddress; 25 import java.util.Set; 26 27 /** 28 * A SCTP/IP {@link Channel} interface for single SCTP association. 29 * 30 * <p> 31 * The SctpChannel is a message-oriented, connected transport which supports multi-streaming and multi-homing. 32 * </p> 33 */ 34 public interface SctpChannel extends Channel { 35 @Override 36 SctpServerChannel parent(); 37 38 /** 39 * Returns the underlying SCTP association. 40 */ 41 Association association(); 42 43 /** 44 * Return the (primary) local address of the SCTP channel. 45 * 46 * Please note that, this return the first local address in the underlying SCTP Channel's 47 * local address iterator to support Netty Channel API. In other words, its the application's 48 * responsibility to keep track of it's local primary address. 49 * 50 * (To set a local address as primary, the application can request by calling local SCTP stack, 51 * with SctpStandardSocketOption.SCTP_PRIMARY_ADDR option). 52 */ 53 @Override 54 InetSocketAddress localAddress(); 55 56 /** 57 * Return all local addresses of the SCTP channel. 58 * Please note that, it will return more than one address if this channel is using multi-homing 59 */ 60 Set<InetSocketAddress> allLocalAddresses(); 61 62 /** 63 * Returns the {@link SctpChannelConfig} configuration of the channel. 64 */ 65 @Override 66 SctpChannelConfig config(); 67 68 /** 69 * Return the (primary) remote address of the SCTP channel. 70 * 71 * Please note that, this return the first remote address in the underlying SCTP Channel's 72 * remote address iterator to support Netty Channel API. In other words, its the application's 73 * responsibility to keep track of it's peer's primary address. 74 * 75 * (The application can request it's remote peer to set a specific address as primary by 76 * calling the local SCTP stack with SctpStandardSocketOption.SCTP_SET_PEER_PRIMARY_ADDR option) 77 */ 78 @Override 79 InetSocketAddress remoteAddress(); 80 81 /** 82 * Return all remote addresses of the SCTP server channel. 83 * Please note that, it will return more than one address if the remote is using multi-homing. 84 */ 85 Set<InetSocketAddress> allRemoteAddresses(); 86 87 /** 88 * Bind a address to the already bound channel to enable multi-homing. 89 * The Channel bust be bound and yet to be connected. 90 */ 91 ChannelFuture bindAddress(InetAddress localAddress); 92 93 /** 94 * Bind a address to the already bound channel to enable multi-homing. 95 * The Channel bust be bound and yet to be connected. 96 * 97 * Will notify the given {@link ChannelPromise} and return a {@link ChannelFuture} 98 */ 99 ChannelFuture bindAddress(InetAddress localAddress, ChannelPromise promise); 100 101 /** 102 * Unbind the address from channel's multi-homing address list. 103 * The address should be added already in multi-homing address list. 104 */ 105 ChannelFuture unbindAddress(InetAddress localAddress); 106 107 /** 108 * Unbind the address from channel's multi-homing address list. 109 * The address should be added already in multi-homing address list. 110 * 111 * Will notify the given {@link ChannelPromise} and return a {@link ChannelFuture} 112 */ 113 ChannelFuture unbindAddress(InetAddress localAddress, ChannelPromise promise); 114 }