Source:
public synchronized OpenFuture open() throws IOException { InetSocketAddress src; InetSocketAddress dst; InetSocketAddress loc; Type openType = getTcpipChannelType(); switch (openType) { case Direct: src = (InetSocketAddress) serverSession.getRemoteAddress(); dst = this.remote.toInetSocketAddress(); loc = (InetSocketAddress) serverSession.getLocalAddress(); tunnelEntrance = new SshdSocketAddress(loc.getHostString(), loc.getPort()); tunnelExit = new SshdSocketAddress(dst.getHostString(), dst.getPort()); break; case Forwarded: src = (InetSocketAddress) serverSession.getRemoteAddress(); dst = (InetSocketAddress) serverSession.getLocalAddress(); tunnelEntrance = new SshdSocketAddress(src.getHostString(), src.getPort()); tunnelExit = new SshdSocketAddress(dst.getHostString(), dst.getPort()); break; default: throw new SshException("Unknown client channel type: " + openType); } if (closeFuture.isClosed()) { throw new SshException("Session has been closed"); } openFuture = new DefaultOpenFuture(src, lock); if (log.isDebugEnabled()) { log.debug("open({}) send SSH_MSG_CHANNEL_OPEN", this); } Session session = getSession(); InetAddress srcAddress = src.getAddress(); String srcHost = srcAddress.getHostAddress(); InetAddress dstAddress = dst.getAddress(); String dstHost = dstAddress.getHostAddress(); Window wLocal = getLocalWindow(); String type = getChannelType(); Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN, type.length() + srcHost.length() + dstHost.length() + Long.SIZE); buffer.putString(type); buffer.putInt(getId()); buffer.putInt(wLocal.getSize()); buffer.putInt(wLocal.getPacketSize()); buffer.putString(dstHost); buffer.putInt(dst.getPort()); buffer.putString(srcHost); buffer.putInt(src.getPort()); writePacket(buffer); return openFuture; }

Target:
public synchronized OpenFuture open() throws IOException { InetSocketAddress src; InetSocketAddress dst; Type openType = getTcpipChannelType(); switch (openType) { case Direct: src = (InetSocketAddress) serverSession.getRemoteAddress(); dst = this.remote.toInetSocketAddress(); InetSocketAddress loc = (InetSocketAddress) serverSession.getLocalAddress(); tunnelEntrance = new SshdSocketAddress(loc.getHostString(), loc.getPort()); tunnelExit = new SshdSocketAddress(dst.getHostString(), dst.getPort()); break; case Forwarded: src = (InetSocketAddress) serverSession.getRemoteAddress(); dst = (InetSocketAddress) serverSession.getLocalAddress(); tunnelEntrance = new SshdSocketAddress(src.getHostString(), src.getPort()); tunnelExit = new SshdSocketAddress(dst.getHostString(), dst.getPort()); break; default: throw new SshException("Unknown client channel type: " + openType); } if (closeFuture.isClosed()) { throw new SshException("Session has been closed"); } openFuture = new DefaultOpenFuture(src, lock); if (log.isDebugEnabled()) { log.debug("open({}) send SSH_MSG_CHANNEL_OPEN", this); } Session session = getSession(); InetAddress srcAddress = src.getAddress(); String srcHost = srcAddress.getHostAddress(); InetAddress dstAddress = dst.getAddress(); String dstHost = dstAddress.getHostAddress(); Window wLocal = getLocalWindow(); String type = getChannelType(); Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN, type.length() + srcHost.length() + dstHost.length() + Long.SIZE); buffer.putString(type); buffer.putInt(getId()); buffer.putInt(wLocal.getSize()); buffer.putInt(wLocal.getPacketSize()); buffer.putString(dstHost); buffer.putInt(dst.getPort()); buffer.putString(srcHost); buffer.putInt(src.getPort()); writePacket(buffer); return openFuture; }