Example #1
0
        protected void SendMessage(ChannelOpenConfirmationMessage message)
        {
            //  No need to check whether channel is open when trying to open a channel
            this._session.SendMessage(message);

            //  Chanel consider to be open when confirmation message is sent
            this.IsOpen = true;
        }
        //private void OnChannelOpen(object sender, MessageEventArgs<ChannelOpenMessage> e)
        //{
        //    var channelOpenMessage = e.Message;

        //    if (channelOpenMessage.LocalChannelNumber == LocalChannelNumber)
        //    {
        //        _remoteChannelNumber = channelOpenMessage.LocalChannelNumber;
        //        RemoteWindowSize = channelOpenMessage.InitialWindowSize;
        //        _remotePacketSize = channelOpenMessage.MaximumPacketSize;
        //        OnOpen(e.Message.Info);
        //    }
        //}

        protected void SendMessage(ChannelOpenConfirmationMessage message)
        {
            //  No need to check whether channel is open when trying to open a channel
            Session.SendMessage(message);

            //  When we act as server, consider the channel open when we've sent the
            // confirmation message to the peer
            IsOpen = true;
        }
        [Ignore] // placeholder
        public void ChannelOpenConfirmationMessageConstructorTest1()
        {
            uint localChannelNumber  = 0; // TODO: Initialize to an appropriate value
            uint initialWindowSize   = 0; // TODO: Initialize to an appropriate value
            uint maximumPacketSize   = 0; // TODO: Initialize to an appropriate value
            uint remoteChannelNumber = 0; // TODO: Initialize to an appropriate value
            ChannelOpenConfirmationMessage target = new ChannelOpenConfirmationMessage(localChannelNumber, initialWindowSize, maximumPacketSize, remoteChannelNumber);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Example #4
0
        private SessionChannel HandleChannelOpenMessage(ChannelOpenMessage message)
        {
            var channel = new SessionChannel(
                this,
                message.SenderChannel,
                message.InitialWindowSize,
                message.MaximumPacketSize,
                (uint)Interlocked.Increment(ref _serverChannelCounter));

            lock (_locker)
                _channels.Add(channel);

            var msg = new ChannelOpenConfirmationMessage
            {
                RecipientChannel  = channel.ClientChannelId,
                SenderChannel     = channel.ServerChannelId,
                InitialWindowSize = channel.ServerInitialWindowSize,
                MaximumPacketSize = channel.ServerMaxPacketSize
            };

            _session.SendMessage(msg);
            return(channel);
        }
Example #5
0
 private void HandleMessage(ChannelOpenConfirmationMessage message)
 {
 }
Example #6
0
        private void HandlePortForward(ChannelOpenMessage message, string address, uint port, string originationIP, uint originatorPort)
        {
            var channel = new SessionChannel(
                this,
                message.SenderChannel,
                message.InitialWindowSize,
                message.MaximumPacketSize,
                (uint)Interlocked.Increment(ref _serverChannelCounter));

            var readyToAcceptData = false;

            var args = new TcpRequestArgs(
                this._session,
                address,
                port,
                originationIP,
                originatorPort,
                () =>
            {
                return(readyToAcceptData);
            },
                (byte[] data) =>
            {
                if (!channel.ClientClosed && !channel.ServerClosed)
                {
                    channel.SendData(data);
                }
                else
                {
                    throw new IOException("Connection closed");
                }
            },
                () =>
            {
                if (!channel.ClientClosed && !channel.ServerClosed)
                {
                    try
                    {
                        channel.SendClose();
                    }
                    catch
                    {
                    }
                }
            }
                );

            TcpForwardRequest(this, args);

            Action <object, byte[]> eventHandlerForDataReceived = (sender, data) => {
                try
                {
                    args.OnClientData(data);
                }
                catch
                {
                    channel.SendClose();
                }
            };

            channel.DataReceived += (o, ea) => eventHandlerForDataReceived(o, ea);

            lock (_locker)
                _channels.Add(channel);

            // send SSH_MSG_CHANNEL_OPEN_CONFIRMATION
            var msg = new ChannelOpenConfirmationMessage
            {
                RecipientChannel  = channel.ClientChannelId,
                SenderChannel     = channel.ServerChannelId,
                InitialWindowSize = channel.ServerInitialWindowSize,
                MaximumPacketSize = channel.ServerMaxPacketSize
            };

            _session.SendMessage(msg);
            readyToAcceptData = true;
        }
        public void Start()
        {
            var successMessage = new ChannelOpenConfirmationMessage(this.RemoteChannelNumber, this.LocalWindowSize, this.PacketSize, this.LocalChannelNumber);

            this.SendMessage(successMessage);
        }
        [Ignore] // placeholder
        public void ChannelOpenConfirmationMessageConstructorTest()
        {
            ChannelOpenConfirmationMessage target = new ChannelOpenConfirmationMessage();

            Assert.Inconclusive("TODO: Implement code to verify target");
        }