/* * https://www.rfc-editor.org/rfc/rfc4034.html NSEC RDATA Wire Format The RDATA of the NSEC RR is as shown below: 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / Next Domain Name / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / Type Bit Maps / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ using MailSharp.DNS.Records; namespace MailSharp.DNS.Records; public record RecordNSEC : DnsRecord { public string NextDomainName { get;init; } public List TypeBitMaps { get; init; } = []; public RecordNSEC(RecordReader rr) : base(rr) { // re-read length ushort rdLength = rr.ReadUInt16(-2); NextDomainName = rr.ReadDomainName(); while (rr.Position < rdLength) { byte windowBlock = rr.ReadByte();// 0–255 byte bitmapLength = rr.ReadByte();// 1–32 for (int i = 0; i < bitmapLength * 8; i++) { if ((rr.ReadByte() & (0x80 >> (i % 8))) != 0) { TypeBitMaps.Add((DnsType)(windowBlock * 256 + i)); } } } } public override string ToString() { if (TypeBitMaps.Count == 0) return $"{NextDomainName}"; // Sorteer op type-nummer (verplicht in presentatieformaat) var sorted = TypeBitMaps.OrderBy(t => (ushort)t); return $"{NextDomainName} {string.Join(" ", sorted)}"; } }