public void Bitmap()
        {
            // From https://tools.ietf.org/html/rfc3845#section-2.3
            var wire = new byte[]
            {
                0x00, 0x06, 0x40, 0x01, 0x00, 0x00, 0x00, 0x03,
                0x04, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x20
            };
            var ms     = new MemoryStream(wire, false);
            var reader = new WireReader(ms);
            var first  = new ushort[] { 1, 15, 46, 47 };
            var second = new ushort[] { 1234 };

            CollectionAssert.AreEqual(first, reader.ReadBitmap());
            CollectionAssert.AreEqual(second, reader.ReadBitmap());

            ms = new MemoryStream();
            var writer = new WireWriter(ms);

            writer.WriteBitmap(new ushort[] { 1, 15, 46, 47, 1234 });
            CollectionAssert.AreEqual(wire, ms.ToArray());
        }
Exemple #2
0
        /// <inheritdoc />
        public override void ReadData(WireReader reader, int length)
        {
            var end = reader.Position + length;

            NextOwnerName = reader.ReadDomainName();
            while (reader.Position < end)
            {
                Types.AddRange(reader.ReadBitmap().Select(t => (DnsType)t));
            }
        }
Exemple #3
0
        /// <inheritdoc />
        public override void ReadData(WireReader reader, int length)
        {
            var end = reader.Position + length;

            HashAlgorithm       = (DigestType)reader.ReadByte();
            Flags               = (NSEC3Flags)reader.ReadByte();
            Iterations          = reader.ReadUInt16();
            Salt                = reader.ReadByteLengthPrefixedBytes();
            NextHashedOwnerName = reader.ReadByteLengthPrefixedBytes();

            while (reader.Position < end)
            {
                Types.AddRange(reader.ReadBitmap().Select(t => (DnsType)t));
            }
        }