com.maverick.sshd.tunnel
Class SocketForwardingChannel

java.lang.Object
  extended by com.maverick.sshd.Channel
      extended by com.maverick.sshd.tunnel.ForwardingChannel
          extended by com.maverick.sshd.tunnel.SocketForwardingChannel
All Implemented Interfaces:
com.maverick.ssh.components.SshComponent
Direct Known Subclasses:
LocalForwardingChannel, RemoteForwardingChannel

public abstract class SocketForwardingChannel
extends ForwardingChannel

An abstract forwarding channel implementation for use with forwarding both local and remote sockets.

Author:
Lee David Painter
See Also:
ForwardingChannel

Nested Class Summary
protected  class SocketForwardingChannel.QueuedData
           
 
Field Summary
 
Fields inherited from class com.maverick.sshd.tunnel.ForwardingChannel
hostToConnect, originatingHost, originatingPort, portToConnect
 
Fields inherited from class com.maverick.sshd.Channel
connection, localwindow, localWindowLock, state
 
Constructor Summary
SocketForwardingChannel(String channeltype)
          Construct the forwarding channel.
 
Method Summary
protected  boolean canClose()
          Can this channel close?
protected abstract  byte[] createChannel()
          Called when the channel is being created.
protected  void evaluateClosure()
          set the closePending flag to true and attempt to close the channel
protected  void evaluateWindowSpace(long remaining)
          Called to evaluate the window space available.
protected  void onChannelClosed()
          Called when the channel has been closed to enable resources to be freed.
protected  void onChannelClosing()
          does nothing
protected  void onChannelData(byte[] data)
          Called by the channel when data arrives from the remote side.
protected  void onChannelFree()
          does nothing
protected  void onChannelOpen()
          does nothing
protected  void onChannelOpenConfirmation()
          Called when the channel has been confirmed as open by the remote side - this method is only called when the channel has been requested by this side of the connection
protected  void onChannelRequest(String parm1, boolean parm2, byte[] parm3)
          Called when a channel request is received.
protected  void onExtendedData(byte[] data, int type)
          does nothing
protected  void onLocalEOF()
          The start of the tunnel has gone EOF , if the end of the tunnel has already gone EOF then close the tunnel.
protected  void onRemoteClose()
          We override this to make sure that all data from the socket has been sent before we close our side of the channel
protected  void onRemoteEOF()
          The end of the tunnel has gone EOF , if the start of the tunnel has already gone EOF then close the tunnel.
protected abstract  byte[] openChannel(byte[] parm1)
          Called when the channel is being opened.
 void sendChannelData(org.apache.mina.core.buffer.IoBuffer buf, Runnable r)
           
 
Methods inherited from class com.maverick.sshd.tunnel.ForwardingChannel
getHost, getInformation, getOriginatingHost, getOriginatingPort, getPort
 
Methods inherited from class com.maverick.sshd.Channel
addEventListener, addInputListener, addOutputListener, close, getConnection, getContext, getLocalId, getLocalPacket, getLocalWindow, getName, getQueueSize, getRemoteId, getRemotePacket, getRemoteWindow, getSessionIdentifier, hasQueuedData, idle, isClosed, isClosing, isEOF, isLocalEOF, isOpen, isRemoteEOF, onChannelOpenFailure, onWindowAdjust, queueSize, registerExtendedData, removeEventListener, sendChannelData, sendChannelRequest, sendEOF, sendExtendedData, sendRequestResponse, sendWindowAdjust
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketForwardingChannel

public SocketForwardingChannel(String channeltype)
Construct the forwarding channel.

Parameters:
channeltype - the type of channel i.e. "forwarded-tcpip"
Method Detail

onChannelOpen

protected void onChannelOpen()
does nothing

Specified by:
onChannelOpen in class Channel

onChannelOpenConfirmation

protected void onChannelOpenConfirmation()
Description copied from class: Channel
Called when the channel has been confirmed as open by the remote side - this method is only called when the channel has been requested by this side of the connection

Specified by:
onChannelOpenConfirmation in class Channel

createChannel

protected abstract byte[] createChannel()
                                 throws IOException,
                                        com.maverick.ssh.ChannelOpenException
Description copied from class: Channel
Called when the channel is being created. You can return data to be sent in the channel open request, or null for none.

Specified by:
createChannel in class Channel
Returns:
byte[]
Throws:
IOException
com.maverick.ssh.ChannelOpenException

sendChannelData

public void sendChannelData(org.apache.mina.core.buffer.IoBuffer buf,
                            Runnable r)
Overrides:
sendChannelData in class Channel

onChannelData

protected void onChannelData(byte[] data)
Description copied from class: Channel
Called by the channel when data arrives from the remote side.

Specified by:
onChannelData in class Channel

onExtendedData

protected void onExtendedData(byte[] data,
                              int type)
does nothing

Specified by:
onExtendedData in class Channel

onChannelRequest

protected void onChannelRequest(String parm1,
                                boolean parm2,
                                byte[] parm3)
Description copied from class: Channel
Called when a channel request is received.

Specified by:
onChannelRequest in class Channel

onChannelFree

protected void onChannelFree()
does nothing

Specified by:
onChannelFree in class Channel

onChannelClosing

protected void onChannelClosing()
does nothing

Specified by:
onChannelClosing in class Channel

canClose

protected boolean canClose()
Description copied from class: Channel
Can this channel close?

Overrides:
canClose in class Channel
Returns:
true if there is no queued data, else false

onRemoteClose

protected void onRemoteClose()
We override this to make sure that all data from the socket has been sent before we close our side of the channel

Overrides:
onRemoteClose in class Channel

evaluateClosure

protected void evaluateClosure()
set the closePending flag to true and attempt to close the channel


onChannelClosed

protected void onChannelClosed()
Description copied from class: Channel
Called when the channel has been closed to enable resources to be freed.

Specified by:
onChannelClosed in class Channel

onLocalEOF

protected void onLocalEOF()
The start of the tunnel has gone EOF , if the end of the tunnel has already gone EOF then close the tunnel.

Specified by:
onLocalEOF in class Channel

onRemoteEOF

protected void onRemoteEOF()
The end of the tunnel has gone EOF , if the start of the tunnel has already gone EOF then close the tunnel.

Specified by:
onRemoteEOF in class Channel

evaluateWindowSpace

protected void evaluateWindowSpace(long remaining)
Description copied from class: Channel
Called to evaluate the window space available. Send a window adjust message if there if the minimum amount of space is not available.

Specified by:
evaluateWindowSpace in class Channel

openChannel

protected abstract byte[] openChannel(byte[] parm1)
                               throws WriteOperationRequest,
                                      com.maverick.ssh.ChannelOpenException
Description copied from class: Channel
Called when the channel is being opened. You can retrun data to be sent in the channel open confirmation message, or null for none.

Specified by:
openChannel in class Channel
Returns:
byte[]
Throws:
WriteOperationRequest
com.maverick.ssh.ChannelOpenException


Copyright © 2012. All Rights Reserved.