buffer.putString("");
writePacket(buffer);
return;
}
ServerChannel channel = null;
for (NamedFactory<ServerChannel> factory : getServerFactoryManager().getChannelFactories()) {
if (factory.getName().equals(type)) {
channel = factory.create();
break;
}
}
if (channel == null) {
buffer = createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN_FAILURE);
buffer.putInt(id);
buffer.putInt(SshConstants.SSH_OPEN_UNKNOWN_CHANNEL_TYPE);
buffer.putString("Unsupported channel type: " + type);
buffer.putString("");
writePacket(buffer);
return;
}
int channelId;
synchronized (channels) {
channelId = nextChannelId++;
}
channels.put(channelId, channel);
channel.init(this, channelId, id, rwsize, rmpsize);
buffer = createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN_CONFIRMATION);
buffer.putInt(id);
buffer.putInt(channelId);
buffer.putInt(channel.getLocalWindow().getSize());
buffer.putInt(channel.getLocalWindow().getPacketSize());
writePacket(buffer);
}