Used to open "forwarded-tcpip" channel type
상속: Renci.SshNet.Messages.Connection.ChannelOpenInfo
예제 #1
0
        /// <summary>
        /// Called when type specific data need to be loaded.
        /// </summary>
        protected override void LoadData()
        {
            ChannelType        = ReadBinary();
            LocalChannelNumber = ReadUInt32();
            InitialWindowSize  = ReadUInt32();
            MaximumPacketSize  = ReadUInt32();
            _infoBytes         = ReadBytes();

            var channelName = Ascii.GetString(ChannelType, 0, ChannelType.Length);

            switch (channelName)
            {
            case SessionChannelOpenInfo.Name:
                Info = new SessionChannelOpenInfo(_infoBytes);
                break;

            case X11ChannelOpenInfo.Name:
                Info = new X11ChannelOpenInfo(_infoBytes);
                break;

            case DirectTcpipChannelInfo.Name:
                Info = new DirectTcpipChannelInfo(_infoBytes);
                break;

            case ForwardedTcpipChannelInfo.Name:
                Info = new ForwardedTcpipChannelInfo(_infoBytes);
                break;

            default:
                throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Channel type '{0}' is not supported.", channelName));
            }
        }
예제 #2
0
        /// <summary>
        /// Called when type specific data need to be loaded.
        /// </summary>
        protected override void LoadData()
        {
#if TUNING
            ChannelType = ReadBinary();
#else
            var channelName = ReadAsciiString();
#endif
            LocalChannelNumber = ReadUInt32();
            InitialWindowSize = ReadUInt32();
            MaximumPacketSize = ReadUInt32();
#if TUNING
            _infoBytes = ReadBytes();

            var channelName = Ascii.GetString(ChannelType, 0, ChannelType.Length);
#else
            var _infoBytes = ReadBytes();
#endif

            switch (channelName)
            {
                case SessionChannelOpenInfo.NAME:
                    Info = new SessionChannelOpenInfo(_infoBytes);
                    break;
                case X11ChannelOpenInfo.NAME:
                    Info = new X11ChannelOpenInfo(_infoBytes);
                    break;
                case DirectTcpipChannelInfo.NAME:
                    Info = new DirectTcpipChannelInfo(_infoBytes);
                    break;
                case ForwardedTcpipChannelInfo.NAME:
                    Info = new ForwardedTcpipChannelInfo(_infoBytes);
                    break;
                default:
                    throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Channel type '{0}' is not supported.", channelName));
            }
        }
예제 #3
0
        public void Load_ForwardedTcpipChannelInfo()
        {
            var localChannelNumber = (uint)_random.Next(0, int.MaxValue);
            var initialWindowSize = (uint)_random.Next(0, int.MaxValue);
            var maximumPacketSize = (uint)_random.Next(0, int.MaxValue);
            var info = new ForwardedTcpipChannelInfo("connected", 25, "originator", 21);
            var target = new ChannelOpenMessage(localChannelNumber, initialWindowSize, maximumPacketSize, info);
            var bytes = target.GetBytes();

            target.Load(bytes);

            Assert.AreEqual(info.ChannelType, _ascii.GetString(target.ChannelType));
            Assert.IsNotNull(target.Info);
            Assert.AreEqual(initialWindowSize, target.InitialWindowSize);
            Assert.AreEqual(localChannelNumber, target.LocalChannelNumber);
            Assert.AreEqual(maximumPacketSize, target.MaximumPacketSize);

            var forwardedTcpipChannelInfo = target.Info as ForwardedTcpipChannelInfo;
            Assert.IsNotNull(forwardedTcpipChannelInfo);
            Assert.AreEqual(info.ChannelType, forwardedTcpipChannelInfo.ChannelType);
            Assert.AreEqual(info.ConnectedAddress, forwardedTcpipChannelInfo.ConnectedAddress);
            Assert.AreEqual(info.ConnectedPort, forwardedTcpipChannelInfo.ConnectedPort);
            Assert.AreEqual(info.OriginatorAddress, forwardedTcpipChannelInfo.OriginatorAddress);
            Assert.AreEqual(info.OriginatorPort, forwardedTcpipChannelInfo.OriginatorPort);
        }