Commit 7eb998ba authored by Brickner_cp's avatar Brickner_cp

DNS

parent 6ceb7ab8
...@@ -186,6 +186,9 @@ namespace PcapDotNet.Packets.TestUtils ...@@ -186,6 +186,9 @@ namespace PcapDotNet.Packets.TestUtils
random.NextDataSegment(random.Next(100)), random.NextDataSegment(random.Next(100)), random.NextDataSegment(random.Next(100)), random.NextDataSegment(random.Next(100)),
random.NextDnsDomainName()); random.NextDnsDomainName());
case DnsType.Kx:
return new DnsResourceDataKeyExchanger(random.NextUShort(), random.NextDnsDomainName());
default: default:
return new DnsResourceDataAnything(random.NextDataSegment(random.Next(100))); return new DnsResourceDataAnything(random.NextDataSegment(random.Next(100)));
} }
......
...@@ -883,8 +883,15 @@ namespace PcapDotNet.Packets.Dns ...@@ -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; } } 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; } } public DnsDomainName MailExchangeHost { get { return DomainName; } }
internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length) internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
...@@ -2871,4 +2878,51 @@ namespace PcapDotNet.Packets.Dns ...@@ -2871,4 +2878,51 @@ namespace PcapDotNet.Packets.Dns
return flags.All(flag => (flag >= '0' && flag <= '9' || flag >= 'A' && flag <= 'Z' || flag >= 'a' && flag <= 'z')); 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 @@ ...@@ -257,6 +257,7 @@
/// <summary> /// <summary>
/// RFC 2230. /// RFC 2230.
/// Key Exchanger. /// Key Exchanger.
/// Payload type: DnsResourceDataKeyExchanger.
/// </summary> /// </summary>
Kx = 36, Kx = 36,
...@@ -430,13 +431,13 @@ ...@@ -430,13 +431,13 @@
Axft = 252, Axft = 252,
/// <summary> /// <summary>
/// RFC 1035]. /// RFC 1035.
/// Mailbox-related RRs (MB, MG or MR). /// Mailbox-related RRs (MB, MG or MR).
/// </summary> /// </summary>
MailB = 253, MailB = 253,
/// <summary> /// <summary>
/// RFC 1035]. /// RFC 1035.
/// Mail agent RRs (Obsolete - see MX). /// Mail agent RRs (Obsolete - see MX).
/// </summary> /// </summary>
MailA = 254, 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