Package com.trilead.ssh2.channel
Class ChannelManager
- java.lang.Object
-
- com.trilead.ssh2.channel.ChannelManager
-
- All Implemented Interfaces:
MessageHandler
public class ChannelManager extends java.lang.Object implements MessageHandler
ChannelManager. Please read the comments in Channel.java.Besides the crypto part, this is the core of the library.
- Version:
- $Id: ChannelManager.java,v 1.2 2008/03/03 07:01:36 cplattne Exp $
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Vectorchannelsprivate intglobalFailedCounterprivate intglobalSuccessCounterprivate java.util.VectorlistenerThreadsprivate booleanlistenerThreadsAllowedprivate static Loggerlogprivate intnextLocalChannelprivate java.util.HashMapremoteForwardingsprivate booleanshutdown(package private) TransportManagertmprivate java.util.HashMapx11_magic_cookies
-
Constructor Summary
Constructors Constructor Description ChannelManager(TransportManager tm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private intaddChannel(Channel c)X11ServerDatacheckX11Cookie(java.lang.String hexFakeCookie)voidcloseAllChannels()voidcloseChannel(Channel c, java.lang.String reason, boolean force)intgetAvailable(Channel c, boolean extended)private ChannelgetChannel(int id)intgetChannelData(Channel c, boolean extended, byte[] target, int off, int len)voidhandleEndMessage(java.lang.Throwable cause)Called to inform that no more messages will be delivered.voidhandleMessage(byte[] msg, int msglen)private java.io.IOExceptionioException(java.lang.String msg, Channel c)voidmsgChannelClose(byte[] msg, int msglen)voidmsgChannelData(byte[] msg, int msglen)voidmsgChannelEOF(byte[] msg, int msglen)voidmsgChannelExtendedData(byte[] msg, int msglen)voidmsgChannelFailure(byte[] msg, int msglen)voidmsgChannelOpen(byte[] msg, int msglen)voidmsgChannelOpenConfirmation(byte[] msg, int msglen)voidmsgChannelOpenFailure(byte[] msg, int msglen)voidmsgChannelRequest(byte[] msg, int msglen)voidmsgChannelSuccess(byte[] msg, int msglen)voidmsgChannelWindowAdjust(byte[] msg, int msglen)voidmsgGlobalFailure()voidmsgGlobalRequest(byte[] msg, int msglen)voidmsgGlobalSuccess()ChannelopenDirectTCPIPChannel(java.lang.String host_to_connect, int port_to_connect, java.lang.String originator_IP_address, int originator_port)ChannelopenSessionChannel()voidregisterThread(IChannelWorkerThread thr)voidregisterX11Cookie(java.lang.String hexFakeCookie, X11ServerData data)private voidremoveChannel(int id)voidrequestCancelGlobalForward(int bindPort)voidrequestChannelTrileadPing(Channel c)voidrequestExecCommand(Channel c, java.lang.String cmd)intrequestGlobalForward(java.lang.String bindAddress, int bindPort, java.lang.String targetAddress, int targetPort)voidrequestGlobalTrileadPing()voidrequestPTY(Channel c, java.lang.String term, int term_width_characters, int term_height_characters, int term_width_pixels, int term_height_pixels, byte[] terminal_modes)voidrequestShell(Channel c)voidrequestSubSystem(Channel c, java.lang.String subSystemName)voidrequestX11(Channel c, boolean singleConnection, java.lang.String x11AuthenticationProtocol, java.lang.String x11AuthenticationCookie, int x11ScreenNumber)voidsendData(Channel c, byte[] buffer, int pos, int len)voidsendEOF(Channel c)voidsendOpenConfirmation(Channel c)voidunRegisterX11Cookie(java.lang.String hexFakeCookie, boolean killChannels)private booleanwaitForChannelRequestResult(Channel c)intwaitForCondition(Channel c, long timeout, int condition_mask)Wait until for a condition.private booleanwaitForGlobalRequestResult()private voidwaitUntilChannelOpen(Channel c)
-
-
-
Field Detail
-
log
private static final Logger log
-
x11_magic_cookies
private java.util.HashMap x11_magic_cookies
-
tm
TransportManager tm
-
channels
private java.util.Vector channels
-
nextLocalChannel
private int nextLocalChannel
-
shutdown
private boolean shutdown
-
globalSuccessCounter
private int globalSuccessCounter
-
globalFailedCounter
private int globalFailedCounter
-
remoteForwardings
private java.util.HashMap remoteForwardings
-
listenerThreads
private java.util.Vector listenerThreads
-
listenerThreadsAllowed
private boolean listenerThreadsAllowed
-
-
Constructor Detail
-
ChannelManager
public ChannelManager(TransportManager tm)
-
-
Method Detail
-
getChannel
private Channel getChannel(int id)
-
removeChannel
private void removeChannel(int id)
-
addChannel
private int addChannel(Channel c)
-
waitUntilChannelOpen
private void waitUntilChannelOpen(Channel c) throws java.io.IOException
- Throws:
java.io.IOException
-
waitForGlobalRequestResult
private final boolean waitForGlobalRequestResult() throws java.io.IOException- Throws:
java.io.IOException
-
waitForChannelRequestResult
private final boolean waitForChannelRequestResult(Channel c) throws java.io.IOException
- Throws:
java.io.IOException
-
registerX11Cookie
public void registerX11Cookie(java.lang.String hexFakeCookie, X11ServerData data)
-
unRegisterX11Cookie
public void unRegisterX11Cookie(java.lang.String hexFakeCookie, boolean killChannels)
-
checkX11Cookie
public X11ServerData checkX11Cookie(java.lang.String hexFakeCookie)
-
closeAllChannels
public void closeAllChannels()
-
closeChannel
public void closeChannel(Channel c, java.lang.String reason, boolean force) throws java.io.IOException
- Throws:
java.io.IOException
-
sendEOF
public void sendEOF(Channel c) throws java.io.IOException
- Throws:
java.io.IOException
-
sendOpenConfirmation
public void sendOpenConfirmation(Channel c) throws java.io.IOException
- Throws:
java.io.IOException
-
sendData
public void sendData(Channel c, byte[] buffer, int pos, int len) throws java.io.IOException
- Throws:
java.io.IOException
-
requestGlobalForward
public int requestGlobalForward(java.lang.String bindAddress, int bindPort, java.lang.String targetAddress, int targetPort) throws java.io.IOException- Throws:
java.io.IOException
-
requestCancelGlobalForward
public void requestCancelGlobalForward(int bindPort) throws java.io.IOException- Throws:
java.io.IOException
-
registerThread
public void registerThread(IChannelWorkerThread thr) throws java.io.IOException
- Throws:
java.io.IOException
-
openDirectTCPIPChannel
public Channel openDirectTCPIPChannel(java.lang.String host_to_connect, int port_to_connect, java.lang.String originator_IP_address, int originator_port) throws java.io.IOException
- Throws:
java.io.IOException
-
openSessionChannel
public Channel openSessionChannel() throws java.io.IOException
- Throws:
java.io.IOException
-
requestGlobalTrileadPing
public void requestGlobalTrileadPing() throws java.io.IOException- Throws:
java.io.IOException
-
requestChannelTrileadPing
public void requestChannelTrileadPing(Channel c) throws java.io.IOException
- Throws:
java.io.IOException
-
requestPTY
public void requestPTY(Channel c, java.lang.String term, int term_width_characters, int term_height_characters, int term_width_pixels, int term_height_pixels, byte[] terminal_modes) throws java.io.IOException
- Throws:
java.io.IOException
-
requestX11
public void requestX11(Channel c, boolean singleConnection, java.lang.String x11AuthenticationProtocol, java.lang.String x11AuthenticationCookie, int x11ScreenNumber) throws java.io.IOException
- Throws:
java.io.IOException
-
requestSubSystem
public void requestSubSystem(Channel c, java.lang.String subSystemName) throws java.io.IOException
- Throws:
java.io.IOException
-
requestExecCommand
public void requestExecCommand(Channel c, java.lang.String cmd) throws java.io.IOException
- Throws:
java.io.IOException
-
requestShell
public void requestShell(Channel c) throws java.io.IOException
- Throws:
java.io.IOException
-
msgChannelExtendedData
public void msgChannelExtendedData(byte[] msg, int msglen) throws java.io.IOException- Throws:
java.io.IOException
-
waitForCondition
public int waitForCondition(Channel c, long timeout, int condition_mask) throws java.lang.InterruptedException
Wait until for a condition.- Parameters:
c- Channeltimeout- in ms, 0 means no timeout.condition_mask- minimum event mask- Returns:
- all current events
- Throws:
java.lang.InterruptedException
-
getAvailable
public int getAvailable(Channel c, boolean extended) throws java.io.IOException
- Throws:
java.io.IOException
-
getChannelData
public int getChannelData(Channel c, boolean extended, byte[] target, int off, int len) throws java.io.IOException
- Throws:
java.io.IOException
-
msgChannelData
public void msgChannelData(byte[] msg, int msglen) throws java.io.IOException- Throws:
java.io.IOException
-
msgChannelWindowAdjust
public void msgChannelWindowAdjust(byte[] msg, int msglen) throws java.io.IOException- Throws:
java.io.IOException
-
msgChannelOpen
public void msgChannelOpen(byte[] msg, int msglen) throws java.io.IOException- Throws:
java.io.IOException
-
msgChannelRequest
public void msgChannelRequest(byte[] msg, int msglen) throws java.io.IOException- Throws:
java.io.IOException
-
msgChannelEOF
public void msgChannelEOF(byte[] msg, int msglen) throws java.io.IOException- Throws:
java.io.IOException
-
msgChannelClose
public void msgChannelClose(byte[] msg, int msglen) throws java.io.IOException- Throws:
java.io.IOException
-
msgChannelSuccess
public void msgChannelSuccess(byte[] msg, int msglen) throws java.io.IOException- Throws:
java.io.IOException
-
msgChannelFailure
public void msgChannelFailure(byte[] msg, int msglen) throws java.io.IOException- Throws:
java.io.IOException
-
msgChannelOpenConfirmation
public void msgChannelOpenConfirmation(byte[] msg, int msglen) throws java.io.IOException- Throws:
java.io.IOException
-
msgChannelOpenFailure
public void msgChannelOpenFailure(byte[] msg, int msglen) throws java.io.IOException- Throws:
java.io.IOException
-
msgGlobalRequest
public void msgGlobalRequest(byte[] msg, int msglen) throws java.io.IOException- Throws:
java.io.IOException
-
msgGlobalSuccess
public void msgGlobalSuccess() throws java.io.IOException- Throws:
java.io.IOException
-
msgGlobalFailure
public void msgGlobalFailure() throws java.io.IOException- Throws:
java.io.IOException
-
handleMessage
public void handleMessage(byte[] msg, int msglen) throws java.io.IOException- Specified by:
handleMessagein interfaceMessageHandler- Throws:
java.io.IOException
-
handleEndMessage
public void handleEndMessage(java.lang.Throwable cause) throws java.io.IOExceptionDescription copied from interface:MessageHandlerCalled to inform that no more messages will be delivered.- Specified by:
handleEndMessagein interfaceMessageHandler- Parameters:
cause- For diagnosis, the reason that caused the transport to close down.- Throws:
java.io.IOException
-
ioException
private java.io.IOException ioException(java.lang.String msg, Channel c)
-
-