MailSharp / MailSharp.DNS / Records / RecordDHCID.cs
Code · 37 lines · 1268 bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37/*
https://www.rfc-editor.org/rfc/rfc4701.html
The RDATA section of a DHCID RR in transmission contains RDLENGTH
   octets of binary data.  The format of this data and its
   interpretation by DHCP servers and clients are described below.

   DNS software should consider the RDATA section to be opaque.  DHCP
   clients or servers use the DHCID RR to associate a DHCP client's
   identity with a DNS name, so that multiple DHCP clients and servers
   may deterministically perform dynamic DNS updates to the same zone.
   From the updater's perspective, the DHCID resource record RDATA
   consists of a 2-octet identifier type, in network byte order,
   followed by a 1-octet digest type, followed by one or more octets
   representing the actual identifier:

           < 2 octets >    Identifier type code
           < 1 octet >     Digest type code
           < n octets >    Digest (length depends on digest type)
 */

using MailSharp.DNS.Records;

namespace MailSharp.DNS.Records;

public record RecordDHCID : DnsRecord
{
	public byte[] Data { get; init; } = [];

	public RecordDHCID(RecordReader rr) : base(rr)
	{
		ushort rdLength = rr.ReadUInt16(-2);
		Data = rr.ReadBytes(rdLength);
	}

	public override string ToString() =>
		Convert.ToBase64String(Data);
}