Commit 7eb998ba authored by Brickner_cp's avatar Brickner_cp

DNS

parent 6ceb7ab8
......@@ -186,6 +186,9 @@ namespace PcapDotNet.Packets.TestUtils
random.NextDataSegment(random.Next(100)), random.NextDataSegment(random.Next(100)),
random.NextDnsDomainName());
case DnsType.Kx:
return new DnsResourceDataKeyExchanger(random.NextUShort(), random.NextDnsDomainName());
default:
return new DnsResourceDataAnything(random.NextDataSegment(random.Next(100)));
}
......
......@@ -883,8 +883,15 @@ namespace PcapDotNet.Packets.Dns
{
}
/// <summary>
/// Specifies the preference given to this RR among others at the same owner.
/// Lower values are preferred.
/// </summary>
public ushort Preference { get { return Value; } }
/// <summary>
/// Specifies a host willing to act as a mail exchange for the owner name.
/// </summary>
public DnsDomainName MailExchangeHost { get { return DomainName; } }
internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
......@@ -2871,4 +2878,51 @@ namespace PcapDotNet.Packets.Dns
return flags.All(flag => (flag >= '0' && flag <= '9' || flag >= 'A' && flag <= 'Z' || flag >= 'a' && flag <= 'z'));
}
}
/// <summary>
/// <pre>
/// +-----+-------------------+
/// | bit | 0-15 |
/// +-----+-------------------+
/// | 0 | PREFERENCE |
/// +-----+-------------------+
/// | 16 | EXCHANGER |
/// | | |
/// +-----+-------------------+
/// </pre>
/// </summary>
[DnsTypeRegistration(Type = DnsType.Kx)]
public sealed class DnsResourceDataKeyExchanger : DnsResourceDataUShortDomainName
{
public DnsResourceDataKeyExchanger()
: this(0, DnsDomainName.Root)
{
}
public DnsResourceDataKeyExchanger(ushort preference, DnsDomainName keyExchanger)
: base(preference, keyExchanger)
{
}
/// <summary>
/// Specifies the preference given to this RR among other KX records at the same owner.
/// Lower values are preferred.
/// </summary>
public ushort Preference { get { return Value; } }
/// <summary>
/// Specifies a host willing to act as a key exchange for the owner name.
/// </summary>
public DnsDomainName KeyExchangeHost { get { return DomainName; } }
internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
{
ushort preference;
DnsDomainName keyExchangeHost;
if (!TryRead(out preference, out keyExchangeHost, dns, offsetInDns, length))
return null;
return new DnsResourceDataKeyExchanger(preference, keyExchangeHost);
}
}
}
......@@ -257,6 +257,7 @@
/// <summary>
/// RFC 2230.
/// Key Exchanger.
/// Payload type: DnsResourceDataKeyExchanger.
/// </summary>
Kx = 36,
......@@ -430,13 +431,13 @@
Axft = 252,
/// <summary>
/// RFC 1035].
/// RFC 1035.
/// Mailbox-related RRs (MB, MG or MR).
/// </summary>
MailB = 253,
/// <summary>
/// RFC 1035].
/// RFC 1035.
/// Mail agent RRs (Obsolete - see MX).
/// </summary>
MailA = 254,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment