/** * transmits channel data */ public override void Transmit(byte[] data, int offset, int length) { SSH1DataWriter wr = new SSH1DataWriter(); if (_type == ChannelType.Shell) { wr.WriteAsString(data, offset, length); SSH1Packet p = SSH1Packet.FromPlainPayload(PacketType.SSH_CMSG_STDIN_DATA, wr.ToByteArray()); Transmit(p); } else { wr.WriteInt32(_remoteID); wr.WriteAsString(data, offset, length); SSH1Packet p = SSH1Packet.FromPlainPayload(PacketType.SSH_MSG_CHANNEL_DATA, wr.ToByteArray()); Transmit(p); } }
/** * creates a packet as the input of shell */ static SSH1Packet AsStdinString(byte[] input) { SSH1DataWriter w = new SSH1DataWriter(); w.WriteAsString(input); SSH1Packet p = SSH1Packet.FromPlainPayload(PacketType.SSH_CMSG_STDIN_DATA, w.ToByteArray()); return(p); }