예제 #1
0
        /// <summary>
        /// Send control packet
        /// </summary>
        /// <param name="flags">SMUX header flags</param>
        private void SendControlPacket(SNISMUXFlags flags)
        {
            Span <byte> headerBytes = stackalloc byte[SNISMUXHeader.HEADER_LENGTH];

            lock (this)
            {
                GetSMUXHeaderBytes(0, flags, headerBytes);
            }

            SNIPacket packet = new SNIPacket(SNISMUXHeader.HEADER_LENGTH);

            packet.AppendData(headerBytes);

            _connection.Send(packet);
        }
예제 #2
0
        /// <summary>
        /// Generate a packet with SMUX header
        /// </summary>
        /// <param name="packet">SNI packet</param>
        /// <returns>Encapsulated SNI packet</returns>
        private SNIPacket GetSMUXEncapsulatedPacket(SNIPacket packet)
        {
            uint        xSequenceNumber = _sequenceNumber;
            Span <byte> header          = stackalloc byte[SNISMUXHeader.HEADER_LENGTH];

            GetSMUXHeaderBytes(packet.Length, SNISMUXFlags.SMUX_DATA, header);

            SNIPacket smuxPacket = new SNIPacket(SNISMUXHeader.HEADER_LENGTH + packet.Length);

            smuxPacket.AppendData(header);
            smuxPacket.AppendPacket(packet);
            packet.Dispose();

            return(smuxPacket);
        }
예제 #3
0
 /// <summary>
 /// Set packet data
 /// </summary>
 /// <param name="packet">SNI packet</param>
 /// <param name="data">Data</param>
 /// <param name="length">Length</param>
 internal void PacketSetData(SNIPacket packet, byte[] data, int length)
 {
     packet.AppendData(data, length);
 }