com.mindbright.ssh2
Class SSH2Channel

java.lang.Object
  |
  +--com.mindbright.ssh2.SSH2Channel
Direct Known Subclasses:
SSH2StreamChannel

public abstract class SSH2Channel
extends java.lang.Object

This is the abstract base class for all channels as defined in the connection protocol spec. Each channel has a specific type (e.g. session). Each channel type is implemented by a subclass to this class. This base class makes no assumptions as to how data is handled by the channel it only implements methods which are used from the multiplexing code in SSH2Connection.

When implementing a new channel type or implementing an existing one differntly from what available one typically subclasses SSH2StreamChannel instead of SSH2Channel directly since it implements the notion of streams (through use of java.io.InputStream and java.io.OutputStream) and flow control. Only a very specific implementation of a channel would need to subclass SSH2Channel directly.

See Also:
SSH2Connection, SSH2StreamChannel

Field Summary
protected  int channelId
           
protected  int channelType
           
protected  java.util.Vector closeListeners
           
protected  boolean closeReceived
           
protected  boolean closeSent
           
protected  SSH2Connection connection
           
protected  java.lang.Object creator
           
protected  boolean deleted
           
protected  boolean eofReceived
           
protected  boolean eofSent
           
protected  java.lang.Object openMonitor
           
protected  int openStatus
           
protected  int peerChanId
           
protected  int rxCurrWinSz
           
protected  int rxInitWinSz
           
protected  int rxMaxPktSz
           
static int STATUS_CLOSED
           
static int STATUS_FAILED
           
static int STATUS_OPEN
           
static int STATUS_UNDEFINED
           
protected  int txCurrWinSz
           
protected  int txInitWinSz
           
protected  int txMaxPktSz
           
 
Constructor Summary
protected SSH2Channel(int channelType, SSH2Connection connection, java.lang.Object creator)
           
 
Method Summary
 void addCloseListener(SSH2ChannelCloseListener closeListener)
           
 void close()
           
protected abstract  void closeImpl()
           
protected  void data(SSH2TransportPDU pdu)
           
protected abstract  void eofImpl()
           
protected  void extData(SSH2TransportPDU pdu)
           
 SSH2Connection getConnection()
           
 java.lang.Object getCreator()
           
 int getId()
           
 int getPeerId()
           
 java.lang.String getType()
           
protected  void handleRequest(SSH2TransportPDU pdu)
           
protected abstract  void handleRequestImpl(java.lang.String reqType, boolean wantReply, SSH2TransportPDU pdu)
           
protected  void init(int peerChanId, int txInitWinSz, int txMaxPktSz)
           
protected  void openConfirmation(SSH2TransportPDU pdu)
           
protected abstract  void openConfirmationImpl(SSH2TransportPDU pdu)
           
protected  void openFailure(int reasonCode, java.lang.String reasonText, java.lang.String langTag)
           
protected abstract  boolean openFailureImpl(int reasonCode, java.lang.String reasonText, java.lang.String langTag)
           
 int openStatus()
           
protected  void recvClose()
           
protected  void recvEOF()
           
 void removeCloseListener(SSH2ChannelCloseListener closeListener)
           
protected  void requestFailure(SSH2TransportPDU pdu)
           
protected  void requestSuccess(SSH2TransportPDU pdu)
           
protected  void sendClose()
           
protected  void sendEOF()
           
protected  void transmit(SSH2TransportPDU pdu)
           
 void waitUntilClosed()
           
protected  void windowAdjust(SSH2TransportPDU pdu)
           
protected abstract  void windowAdjustImpl(int inc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_UNDEFINED

public static final int STATUS_UNDEFINED
See Also:
Constant Field Values

STATUS_OPEN

public static final int STATUS_OPEN
See Also:
Constant Field Values

STATUS_CLOSED

public static final int STATUS_CLOSED
See Also:
Constant Field Values

STATUS_FAILED

public static final int STATUS_FAILED
See Also:
Constant Field Values

connection

protected SSH2Connection connection

closeListeners

protected java.util.Vector closeListeners

channelType

protected int channelType

channelId

protected int channelId

peerChanId

protected int peerChanId

rxMaxPktSz

protected int rxMaxPktSz

rxInitWinSz

protected int rxInitWinSz

rxCurrWinSz

protected int rxCurrWinSz

txInitWinSz

protected int txInitWinSz

txCurrWinSz

protected int txCurrWinSz

txMaxPktSz

protected int txMaxPktSz

eofSent

protected volatile boolean eofSent

eofReceived

protected volatile boolean eofReceived

closeReceived

protected volatile boolean closeReceived

closeSent

protected volatile boolean closeSent

deleted

protected volatile boolean deleted

creator

protected java.lang.Object creator

openMonitor

protected java.lang.Object openMonitor

openStatus

protected int openStatus
Constructor Detail

SSH2Channel

protected SSH2Channel(int channelType,
                      SSH2Connection connection,
                      java.lang.Object creator)
Method Detail

openConfirmation

protected final void openConfirmation(SSH2TransportPDU pdu)

openFailure

protected final void openFailure(int reasonCode,
                                 java.lang.String reasonText,
                                 java.lang.String langTag)

windowAdjust

protected final void windowAdjust(SSH2TransportPDU pdu)

data

protected void data(SSH2TransportPDU pdu)

extData

protected void extData(SSH2TransportPDU pdu)

handleRequest

protected final void handleRequest(SSH2TransportPDU pdu)

requestSuccess

protected void requestSuccess(SSH2TransportPDU pdu)

requestFailure

protected void requestFailure(SSH2TransportPDU pdu)

recvEOF

protected final void recvEOF()

recvClose

protected final void recvClose()

sendEOF

protected final void sendEOF()

sendClose

protected final void sendClose()

init

protected void init(int peerChanId,
                    int txInitWinSz,
                    int txMaxPktSz)

transmit

protected void transmit(SSH2TransportPDU pdu)

openStatus

public int openStatus()

waitUntilClosed

public void waitUntilClosed()

close

public final void close()

getType

public java.lang.String getType()

getId

public int getId()

getPeerId

public int getPeerId()

getCreator

public java.lang.Object getCreator()

getConnection

public SSH2Connection getConnection()

openConfirmationImpl

protected abstract void openConfirmationImpl(SSH2TransportPDU pdu)

openFailureImpl

protected abstract boolean openFailureImpl(int reasonCode,
                                           java.lang.String reasonText,
                                           java.lang.String langTag)

windowAdjustImpl

protected abstract void windowAdjustImpl(int inc)

eofImpl

protected abstract void eofImpl()

closeImpl

protected abstract void closeImpl()

handleRequestImpl

protected abstract void handleRequestImpl(java.lang.String reqType,
                                          boolean wantReply,
                                          SSH2TransportPDU pdu)

addCloseListener

public final void addCloseListener(SSH2ChannelCloseListener closeListener)

removeCloseListener

public void removeCloseListener(SSH2ChannelCloseListener closeListener)