Exemple #1
0
        /// <summary>
        /// Parse a DTLS record from wire format
        /// </summary>
        /// <returns>True if we successfully parse the record header. Otherwise false</returns>
        public static bool Parse(out Record record, ByteSpan span)
        {
            record = new Record();

            if (span.Length < Size)
            {
                return(false);
            }

            record.ContentType = (ContentType)span[0];
            ProtocolVersion version = (ProtocolVersion)span.ReadBigEndian16(1);

            record.Epoch          = span.ReadBigEndian16(3);
            record.SequenceNumber = span.ReadBigEndian48(5);
            record.Length         = span.ReadBigEndian16(11);

            if (version != ProtocolVersion.DTLS1_2)
            {
                return(false);
            }

            return(true);
        }