• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IO.DataFragment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Granados.IO.DataFragment的典型用法代码示例。如果您正苦于以下问题:C# DataFragment类的具体用法?C# DataFragment怎么用?C# DataFragment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DataFragment类属于Granados.IO命名空间,在下文中一共展示了DataFragment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Close

        public void Close(Cipher cipher, Random rnd, MAC mac, int sequence, DataFragment result) {
            if(!_is_open) throw new SSHException("internal state error");
            
            int blocksize = cipher==null? 8 : cipher.BlockSize;
            int payload_length = _writer.Length - (SEQUENCE_MARGIN + LENGTH_MARGIN + PADDING_MARGIN);
            int r = 11 - payload_length % blocksize;
            while(r < 4) r += blocksize;
            _paddingLength = r;
            _packetLength = PADDING_MARGIN + payload_length + _paddingLength;
            int image_length = _packetLength + LENGTH_MARGIN;

            //fill padding
            for(int i=0; i<_paddingLength; i+=4)
                _writer.Write(rnd.Next());

            //manipulate stream
            byte[] rawbuf = _writer.UnderlyingBuffer;
            SSHUtil.WriteIntToByteArray(rawbuf, 0, sequence);
            SSHUtil.WriteIntToByteArray(rawbuf, SEQUENCE_MARGIN, _packetLength);
            rawbuf[SEQUENCE_MARGIN + LENGTH_MARGIN] = (byte)_paddingLength;

            //mac
            if(mac!=null) {
                _mac = mac.ComputeHash(rawbuf, 0, _packetLength+LENGTH_MARGIN+SEQUENCE_MARGIN);
                Array.Copy(_mac, 0, rawbuf, _packetLength+LENGTH_MARGIN+SEQUENCE_MARGIN, _mac.Length);
                image_length += _mac.Length;
            }

            //encrypt
            if(cipher!=null)
                cipher.Encrypt(rawbuf, SEQUENCE_MARGIN, _packetLength+LENGTH_MARGIN, rawbuf, SEQUENCE_MARGIN);

            result.Init(rawbuf, SEQUENCE_MARGIN, image_length);
            _is_open = false;
        }
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:35,代码来源:SSH2Packet.cs


示例2: SSH2Connection

        private int _requiredResponseCount; //for keyboard-interactive authentication

        internal SSH2Connection(SSHConnectionParameter param, AbstractGranadosSocket strm, ISSHConnectionEventReceiver r, string serverversion, string clientversion) : base(param, strm, r) {
            _cInfo = new SSH2ConnectionInfo();
            _cInfo._serverVersionString = serverversion;
            _cInfo._clientVersionString = clientversion;
            
            _packetReceiver = new SynchronizedPacketReceiver(this);
            _packetBuilder = new SSH2PacketBuilder(_packetReceiver);
            _transmissionPacket = new SSH2TransmissionPacket();
            _transmissionImage = new DataFragment(null, 0, 0);
        }
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:12,代码来源:SSH2Connection.cs


示例3: Append

		public void Append(DataFragment data) {
			if(_length==0) {
    			AssureCapacity(RoundUp(data.Length));
    			Array.Copy(data.Data, data.Offset, _data, 0, data.Length);
                _offset = 0;
				_length = data.Length;
			}
			else {
				Append(data.Data, data.Offset, data.Length);
			}
		}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:11,代码来源:DataFragment.cs


示例4: Init

 private void Init(DataFragment data)
 {
     _data = data.Data;
     _offset = data.Offset;
     _limit = _offset + data.Length;
 }
开发者ID:FNKGino,项目名称:poderosa,代码行数:6,代码来源:ReaderWriter.cs


示例5: OnData

 public void OnData(DataFragment data)
 {
     _connection.AsyncReceivePacket(data);
 }
开发者ID:FNKGino,项目名称:poderosa,代码行数:4,代码来源:SSH1Packet.cs


示例6: SneakPacketType

 private SSH1PacketType SneakPacketType(DataFragment data)
 {
     return (SSH1PacketType)data[0];
 }
开发者ID:yiyi99,项目名称:poderosa,代码行数:4,代码来源:SSH1Connection.cs


示例7: StartReceivingThread

        public void StartReceivingThread(Action<DataFragment> onDataCallback, Action onClosedCallback)
        {
            if (_socket == null || _receivingThread != null) {
                return;
            }

            _receivingThread = new Thread(() => {
                byte[] buffer = new byte[0x20000];
                DataFragment dataFrag = new DataFragment(buffer, 0, 0);

                try {
                    while (true) {
                        int received = _socket.Receive(buffer, 0, buffer.Length, SocketFlags.None);
                        if (received > 0) {
                            dataFrag.SetLength(0, received);
                            onDataCallback(dataFrag);
                        }
                    }
                }
                catch (Exception e) {
                    if (!_shutdown) {
                        System.Diagnostics.Debug.WriteLine(e.Message);
                        System.Diagnostics.Debug.WriteLine(e.StackTrace);
                    }

                    if (!_socket.Connected && !_shutdown) {
                        // closed by the peer
                        onClosedCallback();
                    }
                }
            });
            _receivingThread.Start();
        }
开发者ID:poderosaproject,项目名称:poderosa,代码行数:33,代码来源:X11Socket.cs


示例8: SSH2MsgNewKeys

 public SSH2MsgNewKeys(DataFragment data, Handler onDequeued)
     : base(data.Data, data.Offset, data.Length)
 {
     _onDequeued = onDequeued;
 }
开发者ID:FNKGino,项目名称:poderosa,代码行数:5,代码来源:SSH2Packet.cs


示例9: IsMsgNewKeys

 private bool IsMsgNewKeys(DataFragment packet)
 {
     return packet.Length >= 1 && packet.ByteAt(0) == (byte)PacketType.SSH_MSG_NEWKEYS;
 }
开发者ID:FNKGino,项目名称:poderosa,代码行数:4,代码来源:SSH2Packet.cs


示例10: FilterData

 /// <summary>
 /// Handle data instead of the core handler.
 /// </summary>
 /// <param name="data">data</param>
 protected abstract void FilterData(DataFragment data);
开发者ID:poderosaproject,项目名称:poderosa,代码行数:5,代码来源:Socket.cs


示例11: OnData

 /// <summary>
 /// Implements <see cref="IDataHandler"/>
 /// </summary>
 /// <param name="data"></param>
 public void OnData(DataFragment data)
 {
     FilterData(data);
 }
开发者ID:poderosaproject,项目名称:poderosa,代码行数:8,代码来源:Socket.cs


示例12: Write

 public void Write(DataFragment data)
 {
     Write(data.Data, data.Offset, data.Length);
 }
开发者ID:yiyi99,项目名称:poderosa,代码行数:4,代码来源:DataFragment.cs


示例13: MakeView

 /// <summary>
 /// Make another view of this instance.
 /// </summary>
 /// <param name="startIndex">start index for the new view.</param>
 public DataFragment MakeView(int startIndex)
 {
     if (startIndex < 0 || startIndex > _length) {
         throw new ArgumentOutOfRangeException();
     }
     DataFragment newInstance = new DataFragment(_data, _offset + startIndex, _length - startIndex);
     return newInstance;
 }
开发者ID:yiyi99,项目名称:poderosa,代码行数:12,代码来源:DataFragment.cs


示例14: Dump

 // for debug
 private void Dump(string caption, DataFragment data)
 {
     Dump(caption, data.Data, data.Offset, data.Length);
 }
开发者ID:poderosaproject,项目名称:poderosa,代码行数:5,代码来源:SCPChannelStream.cs


示例15: OnData

 public override void OnData(DataFragment data)
 {
     #if DUMP_PACKET
     Dump("SCP: OnData", data);
     #endif
     if (_dataHandler != null) {
         _dataHandler(data);
     }
 }
开发者ID:poderosaproject,项目名称:poderosa,代码行数:9,代码来源:SCPChannelStream.cs


示例16: SSH2PacketBuilder

 public SSH2PacketBuilder(IDataHandler handler)
     : base(handler)
 {
     _buffer = new DataFragment(0x1000);
     _packet = new DataFragment(_buffer.Capacity);
     _sequence = 0;
     _cipher = null;
     _mac = null;
     _head = null;
 }
开发者ID:FNKGino,项目名称:poderosa,代码行数:10,代码来源:SSH2Packet.cs


示例17: OnData

        public override void OnData(DataFragment data)
        {
            lock (_cipherSync) {
                try {
                    if (!_keyError) {
                        // key error detection
                        if (_pending && DateTime.UtcNow > _keyErrorDetectionTimeout) {
                            _keyError = true;   // disable accepting data any more
                            return;
                        }

                        _buffer.Append(data);

                        if (!_pending) {
                            ProcessBuffer();
                        }
                    }
                } catch (Exception ex) {
                    OnError(ex);
                }
            }
        }
开发者ID:FNKGino,项目名称:poderosa,代码行数:22,代码来源:SSH2Packet.cs


示例18: OnDataInternal

 /// <summary>
 /// Call OnData() of a core handler
 /// </summary>
 /// <param name="data"></param>
 protected void OnDataInternal(DataFragment data)
 {
     _innerHandler.OnData(data);
 }
开发者ID:poderosaproject,项目名称:poderosa,代码行数:8,代码来源:Socket.cs


示例19: SSH2TransmissionPacket

 public SSH2TransmissionPacket()
 {
     _writer = new SSH2DataWriter();
     _dataFragment = new DataFragment(null, 0, 0);
     _isOpen = false;
 }
开发者ID:FNKGino,项目名称:poderosa,代码行数:6,代码来源:SSH2Packet.cs


示例20: Write

 /// <summary>
 /// Write data to the socket
 /// </summary>
 /// <param name="sock">socket object</param>
 /// <param name="data">data to write</param>
 public static void Write(this IGranadosSocket sock, DataFragment data)
 {
     if (data.Length > 0) {
         sock.Write(data.Data, data.Offset, data.Length);
     }
 }
开发者ID:poderosaproject,项目名称:poderosa,代码行数:11,代码来源:Socket.cs



注:本文中的Granados.IO.DataFragment类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Math.BigInteger类代码示例发布时间:2022-05-26
下一篇:
C# Granados.BigInteger类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap