Commit 59688054 authored by Brickner_cp's avatar Brickner_cp

DNS.

Warnings, Code Analysis and Documentation. 199 warnings left.
parent 9c0b2eea
...@@ -376,7 +376,7 @@ namespace PcapDotNet.Core.Test ...@@ -376,7 +376,7 @@ namespace PcapDotNet.Core.Test
switch (dataFieldShowUntilColon) switch (dataFieldShowUntilColon)
{ {
case "Subtype": case "Subtype":
dataField.AssertShow(dataFieldShowUntilColon + ": " + afsDbData.Subtype); dataField.AssertShow(dataFieldShowUntilColon + ": " + (ushort)afsDbData.Subtype);
break; break;
case "Hostname": case "Hostname":
......
...@@ -159,7 +159,7 @@ namespace PcapDotNet.Packets.TestUtils ...@@ -159,7 +159,7 @@ namespace PcapDotNet.Packets.TestUtils
return new DnsResourceDataResponsiblePerson(random.NextDnsDomainName(), random.NextDnsDomainName()); return new DnsResourceDataResponsiblePerson(random.NextDnsDomainName(), random.NextDnsDomainName());
case DnsType.AfsDatabase: case DnsType.AfsDatabase:
return new DnsResourceDataAfsDatabase(random.NextUShort(), random.NextDnsDomainName()); return new DnsResourceDataAfsDatabase(random.NextEnum<DnsAfsDatabaseSubtype>(), random.NextDnsDomainName());
case DnsType.X25: case DnsType.X25:
return new DnsResourceDataString(random.NextDataSegment(random.Next(10))); return new DnsResourceDataString(random.NextDataSegment(random.Next(10)));
......
...@@ -3,6 +3,32 @@ using PcapDotNet.Base; ...@@ -3,6 +3,32 @@ using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
{ {
/// <summary>
/// RFC 1035.
/// A resource record with data.
/// Used for the answers, authorities and additionals sections.
/// For OPT resource records, DnsOptResourceRecord should be used.
/// <pre>
/// +------+-------------------------------------------------+
/// | byte | 0-1 |
/// +------+-------------------------------------------------+
/// | 0 | Name |
/// | ... | |
/// +------+-------------------------------------------------+
/// | | Type |
/// +------+-------------------------------------------------+
/// | | Class |
/// +------+-------------------------------------------------+
/// | | TTL |
/// | | |
/// +------+-------------------------------------------------+
/// | | Resource Data Length |
/// +------+-------------------------------------------------+
/// | | Resource Data |
/// | ... | |
/// +------+-------------------------------------------------+
/// </pre>
/// </summary>
public class DnsDataResourceRecord : DnsResourceRecord, IEquatable<DnsDataResourceRecord> public class DnsDataResourceRecord : DnsResourceRecord, IEquatable<DnsDataResourceRecord>
{ {
private static class OffsetAfterBase private static class OffsetAfterBase
...@@ -14,6 +40,23 @@ namespace PcapDotNet.Packets.Dns ...@@ -14,6 +40,23 @@ namespace PcapDotNet.Packets.Dns
private const int MinimumLengthAfterBase = 6; private const int MinimumLengthAfterBase = 6;
/// <summary>
/// Creates a resource record from domain name, type, class, ttl and data.
/// </summary>
/// <param name="domainName">An owner name, i.e., the name of the node to which this resource record pertains.</param>
/// <param name="type">Two octets containing one of the RR TYPE codes.</param>
/// <param name="dnsClass">Two octets containing one of the RR CLASS codes.</param>
/// <param name="ttl">
/// A 32 bit signed integer that specifies the time interval that the resource record may be cached before the source of the information should again be consulted.
/// Zero values are interpreted to mean that the RR can only be used for the transaction in progress, and should not be cached.
/// For example, SOA records are always distributed with a zero TTL to prohibit caching.
/// Zero values can also be used for extremely volatile data.
/// </param>
/// <param name="data">
/// A variable length string of octets that describes the resource.
/// The format of this information varies according to the TYPE and CLASS of the resource record.
/// For example, the if the TYPE is A and the CLASS is IN, the RDATA field is a 4 octet ARPA Internet address.
/// </param>
public DnsDataResourceRecord(DnsDomainName domainName, DnsType type, DnsClass dnsClass, int ttl, DnsResourceData data) public DnsDataResourceRecord(DnsDomainName domainName, DnsType type, DnsClass dnsClass, int ttl, DnsResourceData data)
: base(domainName, type, dnsClass) : base(domainName, type, dnsClass)
{ {
...@@ -36,9 +79,12 @@ namespace PcapDotNet.Packets.Dns ...@@ -36,9 +79,12 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public override sealed DnsResourceData Data { get; protected set; } public override sealed DnsResourceData Data { get; protected set; }
/// <summary>
/// A string representing the resource record by concatenating its different parts.
/// </summary>
public override string ToString() public override string ToString()
{ {
return base.ToString() + " " + Ttl + " " + Data; return string.Format("{0} {1} {2}", base.ToString(), Ttl, Data);
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
...@@ -49,12 +95,12 @@ namespace PcapDotNet.Packets.Dns ...@@ -49,12 +95,12 @@ namespace PcapDotNet.Packets.Dns
Data.Equals(other.Data); Data.Equals(other.Data);
} }
public override bool Equals(object obj) public override sealed bool Equals(object obj)
{ {
return Equals(obj as DnsDataResourceRecord); return Equals(obj as DnsDataResourceRecord);
} }
public override int GetHashCode() public override sealed int GetHashCode()
{ {
return GetHashCodeBase() ^ Sequence.GetHashCode(Ttl, Data); return GetHashCodeBase() ^ Sequence.GetHashCode(Ttl, Data);
} }
......
...@@ -2,9 +2,19 @@ ...@@ -2,9 +2,19 @@
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
{ {
/// <summary>
/// RFCs 2671, 3225.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags"), Flags] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags"), Flags]
public enum DnsOptFlags : ushort public enum DnsOptFlags : ushort
{ {
/// <summary>
/// RFC 3225.
/// Setting the this bit to one in a query indicates to the server that the resolver is able to accept DNSSEC security RRs.
/// Cleareing (setting to zero) indicates that the resolver is unprepared to handle DNSSEC security RRs
/// and those RRs must not be returned in the response (unless DNSSEC security RRs are explicitly queried for).
/// The bit of the query MUST be copied in the response.
/// </summary>
DnsSecOk = 0x8000, DnsSecOk = 0x8000,
} }
} }
\ No newline at end of file
...@@ -55,9 +55,20 @@ namespace PcapDotNet.Packets.Dns ...@@ -55,9 +55,20 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public DnsOptVersion Version { get { return (DnsOptVersion)(Ttl >> 16); }} public DnsOptVersion Version { get { return (DnsOptVersion)(Ttl >> 16); }}
/// <summary>
/// OPT flags.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags")]
public DnsOptFlags Flags { get { return (DnsOptFlags)Ttl; } } public DnsOptFlags Flags { get { return (DnsOptFlags)Ttl; } }
/// <summary>
/// A string representing the resource record by concatenating its different parts.
/// </summary>
public override string ToString()
{
return string.Format("{0} {1} {2} {3} {4} {5} {6}", DomainName, DnsType, SendersUdpPayloadSize, ExtendedReturnCode, Version, Flags, Data);
}
internal DnsOptResourceRecord(DnsDomainName domainName, DnsClass dnsClass, int ttl, DnsResourceData data) internal DnsOptResourceRecord(DnsDomainName domainName, DnsClass dnsClass, int ttl, DnsResourceData data)
: base(domainName, DnsType.Opt, dnsClass, ttl, data) : base(domainName, DnsType.Opt, dnsClass, ttl, data)
{ {
......
...@@ -2,14 +2,25 @@ ...@@ -2,14 +2,25 @@
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
{ {
public class DnsOptionAnything : DnsOption /// <summary>
/// An option that can hold any data.
/// </summary>
public sealed class DnsOptionAnything : DnsOption
{ {
/// <summary>
/// Constructs the option from a code and data.
/// </summary>
/// <param name="code">The option code.</param>
/// <param name="data">The option data.</param>
public DnsOptionAnything(DnsOptionCode code, DataSegment data) public DnsOptionAnything(DnsOptionCode code, DataSegment data)
: base(code) : base(code)
{ {
Data = data; Data = data;
} }
/// <summary>
/// The option data.
/// </summary>
public DataSegment Data { get; private set; } public DataSegment Data { get; private set; }
public override int DataLength public override int DataLength
......
...@@ -2,35 +2,71 @@ ...@@ -2,35 +2,71 @@
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
{ {
/// <summary>
/// RFC 1035.
/// <pre>
/// +------+-------------------------------------------------+
/// | byte | 0-1 |
/// +------+-------------------------------------------------+
/// | 0 | Name |
/// | ... | |
/// +------+-------------------------------------------------+
/// | | Type |
/// +------+-------------------------------------------------+
/// | | Class |
/// +------+-------------------------------------------------+
/// </pre>
/// </summary>
public sealed class DnsQueryResourceRecord : DnsResourceRecord, IEquatable<DnsQueryResourceRecord> public sealed class DnsQueryResourceRecord : DnsResourceRecord, IEquatable<DnsQueryResourceRecord>
{ {
/// <summary>
/// Creates a DNS query record from a domain name, type and class.
/// </summary>
/// <param name="domainName">An owner name, i.e., the name of the node to which this resource record pertains.</param>
/// <param name="type">Two octets containing one of the RR TYPE codes.</param>
/// <param name="dnsClass">Two octets containing one of the RR CLASS codes.</param>
public DnsQueryResourceRecord(DnsDomainName domainName, DnsType type, DnsClass dnsClass) public DnsQueryResourceRecord(DnsDomainName domainName, DnsType type, DnsClass dnsClass)
: base(domainName, type, dnsClass) : base(domainName, type, dnsClass)
{ {
} }
/// <summary>
/// There's no TTL in a query record.
/// </summary>
public override int Ttl public override int Ttl
{ {
get { throw new InvalidOperationException("No TTL in queries"); } get { throw new InvalidOperationException("No TTL in queries"); }
protected set { throw new InvalidOperationException("No TTL in queries"); } protected set { throw new InvalidOperationException("No TTL in queries"); }
} }
/// <summary>
/// There's no data in a query record.
/// </summary>
public override DnsResourceData Data public override DnsResourceData Data
{ {
get { throw new InvalidOperationException("No Resource Data in queries"); } get { throw new InvalidOperationException("No Resource Data in queries"); }
protected set { throw new InvalidOperationException("No Resource Data in queries"); } protected set { throw new InvalidOperationException("No Resource Data in queries"); }
} }
/// <summary>
/// Two query records are equal if they have the same domain name, type and class.
/// </summary>
public bool Equals(DnsQueryResourceRecord other) public bool Equals(DnsQueryResourceRecord other)
{ {
return EqualsBase(other); return EqualsBase(other);
} }
/// <summary>
/// Two query records are equal if they have the same domain name, type and class.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsQueryResourceRecord); return Equals(obj as DnsQueryResourceRecord);
} }
/// <summary>
/// A hash code based on the query record's domain name, type and class.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return GetHashCodeBase(); return GetHashCodeBase();
......
...@@ -48,6 +48,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -48,6 +48,9 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public DnsType DnsType { get; private set; } public DnsType DnsType { get; private set; }
/// <summary>
/// Two octets containing one of the RR CLASS codes.
/// </summary>
public DnsClass DnsClass { get; private set; } public DnsClass DnsClass { get; private set; }
/// <summary> /// <summary>
...@@ -67,9 +70,12 @@ namespace PcapDotNet.Packets.Dns ...@@ -67,9 +70,12 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public abstract DnsResourceData Data { get; protected set; } public abstract DnsResourceData Data { get; protected set; }
/// <summary>
/// A string representing the resource record by concatenating its different parts.
/// </summary>
public override string ToString() public override string ToString()
{ {
return DomainName + " " + DnsType + " " + DnsClass; return string.Format("{0} {1} {2}", DomainName, DnsType, DnsClass);
} }
protected DnsResourceRecord(DnsDomainName domainName, DnsType type, DnsClass dnsClass) protected DnsResourceRecord(DnsDomainName domainName, DnsType type, DnsClass dnsClass)
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
/// </summary> /// </summary>
public enum DnsType : ushort public enum DnsType : ushort
{ {
/// <summary>
/// Undefined value.
/// </summary>
None = 0, None = 0,
/// <summary> /// <summary>
......
...@@ -18,7 +18,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -18,7 +18,7 @@ namespace PcapDotNet.Packets.Dns
/// +-----+------------------------+ /// +-----+------------------------+
/// </pre> /// </pre>
/// </summary> /// </summary>
public class DnsAddressPrefix : IEquatable<DnsAddressPrefix> public sealed class DnsAddressPrefix : IEquatable<DnsAddressPrefix>
{ {
private static class Offset private static class Offset
{ {
......
namespace PcapDotNet.Packets.Dns
{
/// <summary>
/// RFC 1183.
/// </summary>
public enum DnsAfsDatabaseSubtype : ushort
{
/// <summary>
/// The host has an AFS version 3.0 Volume Location Server for the named AFS cell.
/// </summary>
AfsCell = 1,
/// <summary>
/// The host has an authenticated name server holding the cell-root directory node for the named DCE/NCA cell.
/// </summary>
DceNcaCell = 2,
}
}
\ No newline at end of file
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
{ {
/// <summary>
/// Hallam-Baker.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags"), Flags] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags"), Flags]
public enum DnsCertificationAuthorityAuthorizationFlags : byte public enum DnsCertificationAuthorityAuthorizationFlags : byte
{ {
......
...@@ -6,8 +6,19 @@ ...@@ -6,8 +6,19 @@
/// </summary> /// </summary>
public enum DnsFingerprintPublicKeyAlgorithm : byte public enum DnsFingerprintPublicKeyAlgorithm : byte
{ {
/// <summary>
/// Undefined value.
/// </summary>
None = 0, None = 0,
/// <summary>
/// RSA algorithm.
/// </summary>
Rsa = 1, Rsa = 1,
/// <summary>
/// DSS algorithm.
/// </summary>
Dss = 2, Dss = 2,
} }
} }
\ No newline at end of file
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
/// </summary> /// </summary>
public enum DnsFingerprintType : byte public enum DnsFingerprintType : byte
{ {
/// <summary>
/// Undefined value.
/// </summary>
None = 0, None = 0,
/// <summary> /// <summary>
......
...@@ -32,7 +32,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -32,7 +32,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary> /// <summary>
/// Two gateway representations are equal if they are of the same type and the value is the same. /// Two gateway representations are equal if they are of the same type and the value is the same.
/// </summary> /// </summary>
public override bool Equals(object obj) public override sealed bool Equals(object obj)
{ {
return Equals(obj as DnsGateway); return Equals(obj as DnsGateway);
} }
...@@ -41,7 +41,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -41,7 +41,7 @@ namespace PcapDotNet.Packets.Dns
/// Serves as a hash function for a particular type. /// Serves as a hash function for a particular type.
/// </summary> /// </summary>
/// <returns>A hash code for the current gateway represnetation.</returns> /// <returns>A hash code for the current gateway represnetation.</returns>
public override int GetHashCode() public override sealed int GetHashCode()
{ {
return GatewayType.GetHashCode() ^ DataGetHashCode(); return GatewayType.GetHashCode() ^ DataGetHashCode();
} }
......
...@@ -5,7 +5,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -5,7 +5,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary> /// <summary>
/// A gateway that is represented using a domain name. /// A gateway that is represented using a domain name.
/// </summary> /// </summary>
public class DnsGatewayDomainName : DnsGateway, IEquatable<DnsGatewayDomainName> public sealed class DnsGatewayDomainName : DnsGateway, IEquatable<DnsGatewayDomainName>
{ {
/// <summary> /// <summary>
/// Creates the gateway using the given domain name. /// Creates the gateway using the given domain name.
......
...@@ -6,7 +6,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -6,7 +6,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary> /// <summary>
/// Represents an IPv4 gateway to which an IPsec tunnel may be created in order to reach the entity named by an IPsec resource record. /// Represents an IPv4 gateway to which an IPsec tunnel may be created in order to reach the entity named by an IPsec resource record.
/// </summary> /// </summary>
public class DnsGatewayIpV4 : DnsGateway, IEquatable<DnsGatewayIpV4> public sealed class DnsGatewayIpV4 : DnsGateway, IEquatable<DnsGatewayIpV4>
{ {
/// <summary> /// <summary>
/// Creates a gateway using the given IPv4 address. /// Creates a gateway using the given IPv4 address.
......
...@@ -6,7 +6,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -6,7 +6,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary> /// <summary>
/// Represents an IPv6 gateway to which an IPsec tunnel may be created in order to reach the entity named by an IPsec resource record. /// Represents an IPv6 gateway to which an IPsec tunnel may be created in order to reach the entity named by an IPsec resource record.
/// </summary> /// </summary>
public class DnsGatewayIpV6 : DnsGateway, IEquatable<DnsGatewayIpV6> public sealed class DnsGatewayIpV6 : DnsGateway, IEquatable<DnsGatewayIpV6>
{ {
/// <summary> /// <summary>
/// Creates a gateway using the given IPv6 address. /// Creates a gateway using the given IPv6 address.
......
...@@ -5,7 +5,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -5,7 +5,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary> /// <summary>
/// A gateway representation that represents that no gateway is present. /// A gateway representation that represents that no gateway is present.
/// </summary> /// </summary>
public class DnsGatewayNone : DnsGateway, IEquatable<DnsGatewayNone> public sealed class DnsGatewayNone : DnsGateway, IEquatable<DnsGatewayNone>
{ {
/// <summary> /// <summary>
/// The gateway represnetation type. /// The gateway represnetation type.
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
/// </summary> /// </summary>
public enum DnsKeyProtocol : byte public enum DnsKeyProtocol : byte
{ {
/// <summary>
/// Undefined value.
/// </summary>
None = 0, None = 0,
/// <summary> /// <summary>
......
...@@ -5,9 +5,33 @@ ...@@ -5,9 +5,33 @@
/// </summary> /// </summary>
public enum DnsLongLivedQueryOpCode : ushort public enum DnsLongLivedQueryOpCode : ushort
{ {
/// <summary>
/// Undefined value.
/// </summary>
None = 0, None = 0,
/// <summary>
/// An LLQ is initiated by a client, and is completed via a four-way handshake.
/// This handshake provides resilience to packet loss, demonstrates client reachability, and reduces denial of service attack opportunities.
/// </summary>
Setup = 1, Setup = 1,
/// <summary>
/// If the client desires to maintain the LLQ beyond the duration specified in the LEASE-LIFE field of the Request Acknowledgment,
/// the client must send a Refresh Request.
/// A Refresh Request is identical to an LLQ Challenge Response, but with the LLQ-OPCODE set to LLQ-REFRESH.
/// Unlike a Challenge Response, a Refresh Request returns no answers.
/// </summary>
Refresh = 2, Refresh = 2,
/// <summary>
/// When a change ("event") occurs to a name server's zone, the server must check if the new or deleted resource records answer any LLQs.
/// If so, the resource records must be sent to the LLQ requesters in the form of a gratuitous DNS response sent to the client,
/// with the question(s) being answered in the Question section, and answers to these questions in the Answer section.
/// The response also includes an OPT RR as the last record in the Additional section.
/// This OPT RR contains, in its RDATA, an entry for each LLQ being answered in the message.
/// Entries must include the LLQ-ID. This reduces the potential for spoof events being sent to a client.
/// </summary>
Event = 3, Event = 3,
} }
} }
\ No newline at end of file
...@@ -2,14 +2,35 @@ ...@@ -2,14 +2,35 @@
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
{ {
/// <summary>
/// RFC 2671.
/// A single option.
/// </summary>
public abstract class DnsOption : IEquatable<DnsOption> public abstract class DnsOption : IEquatable<DnsOption>
{ {
/// <summary>
/// The minimum number of bytes an option can take.
/// </summary>
public const int MinimumLength = sizeof(ushort) + sizeof(ushort); public const int MinimumLength = sizeof(ushort) + sizeof(ushort);
/// <summary>
/// The option code.
/// </summary>
public DnsOptionCode Code { get; private set; } public DnsOptionCode Code { get; private set; }
/// <summary>
/// The number of bytes the option takes.
/// </summary>
public int Length { get { return MinimumLength + DataLength; } } public int Length { get { return MinimumLength + DataLength; } }
/// <summary>
/// The number of bytes the option data takes.
/// </summary>
public abstract int DataLength { get; } public abstract int DataLength { get; }
/// <summary>
/// Two options are equal if they are of the same type, have the same code and have equal data.
/// </summary>
public bool Equals(DnsOption other) public bool Equals(DnsOption other)
{ {
return other != null && return other != null &&
...@@ -18,11 +39,17 @@ namespace PcapDotNet.Packets.Dns ...@@ -18,11 +39,17 @@ namespace PcapDotNet.Packets.Dns
EqualsData(other); EqualsData(other);
} }
/// <summary>
/// Two options are equal if they are of the same type, have the same code and have equal data.
/// </summary>
public override sealed bool Equals(object obj) public override sealed bool Equals(object obj)
{ {
return Equals(obj as DnsOption); return Equals(obj as DnsOption);
} }
/// <summary>
/// Returns a hash code based on the option code and data.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return Code.GetHashCode() ^ DataGetHashCode(); return Code.GetHashCode() ^ DataGetHashCode();
...@@ -51,13 +78,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -51,13 +78,9 @@ namespace PcapDotNet.Packets.Dns
switch (code) switch (code)
{ {
case DnsOptionCode.LongLivedQuery: case DnsOptionCode.LongLivedQuery:
if (data.Length < DnsOptionLongLivedQuery.MinimumDataLength)
return null;
return DnsOptionLongLivedQuery.Read(data); return DnsOptionLongLivedQuery.Read(data);
case DnsOptionCode.UpdateLease: case DnsOptionCode.UpdateLease:
if (data.Length < DnsOptionUpdateLease.MinimumDataLength)
return null;
return DnsOptionUpdateLease.Read(data); return DnsOptionUpdateLease.Read(data);
case DnsOptionCode.NameServerIdentifier: case DnsOptionCode.NameServerIdentifier:
......
...@@ -24,7 +24,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -24,7 +24,7 @@ namespace PcapDotNet.Packets.Dns
/// +-----+------------+ /// +-----+------------+
/// </pre> /// </pre>
/// </summary> /// </summary>
public class DnsOptionLongLivedQuery : DnsOption public sealed class DnsOptionLongLivedQuery : DnsOption
{ {
private static class Offset private static class Offset
{ {
...@@ -35,7 +35,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -35,7 +35,7 @@ namespace PcapDotNet.Packets.Dns
public const int LeaseLife = Id + sizeof(ulong); public const int LeaseLife = Id + sizeof(ulong);
} }
public const int MinimumDataLength = Offset.LeaseLife + sizeof(uint); public const int ConstDataLength = Offset.LeaseLife + sizeof(uint);
public DnsOptionLongLivedQuery(ushort version, DnsLongLivedQueryOpCode opCode, DnsLongLivedQueryErrorCode errorCode, ulong id, uint leaseLife) public DnsOptionLongLivedQuery(ushort version, DnsLongLivedQueryOpCode opCode, DnsLongLivedQueryErrorCode errorCode, ulong id, uint leaseLife)
: base(DnsOptionCode.LongLivedQuery) : base(DnsOptionCode.LongLivedQuery)
...@@ -55,7 +55,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -55,7 +55,7 @@ namespace PcapDotNet.Packets.Dns
public override int DataLength public override int DataLength
{ {
get { return MinimumDataLength; } get { return ConstDataLength; }
} }
internal override bool EqualsData(DnsOption other) internal override bool EqualsData(DnsOption other)
...@@ -85,7 +85,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -85,7 +85,7 @@ namespace PcapDotNet.Packets.Dns
internal static DnsOptionLongLivedQuery Read(DataSegment data) internal static DnsOptionLongLivedQuery Read(DataSegment data)
{ {
if (data.Length < MinimumDataLength) if (data.Length != ConstDataLength)
return null; return null;
ushort version = data.ReadUShort(Offset.Version, Endianity.Big); ushort version = data.ReadUShort(Offset.Version, Endianity.Big);
DnsLongLivedQueryOpCode opCode = (DnsLongLivedQueryOpCode)data.ReadUShort(Offset.OpCode, Endianity.Big); DnsLongLivedQueryOpCode opCode = (DnsLongLivedQueryOpCode)data.ReadUShort(Offset.OpCode, Endianity.Big);
......
...@@ -10,10 +10,17 @@ ...@@ -10,10 +10,17 @@
/// +-----+-------+ /// +-----+-------+
/// </pre> /// </pre>
/// </summary> /// </summary>
public class DnsOptionUpdateLease : DnsOption public sealed class DnsOptionUpdateLease : DnsOption
{ {
public const int MinimumDataLength = sizeof(int); /// <summary>
/// The number of bytes this option data can take.
/// </summary>
public const int ConstDataLength = sizeof(int);
/// <summary>
/// Builds
/// </summary>
/// <param name="lease"></param>
public DnsOptionUpdateLease(int lease) public DnsOptionUpdateLease(int lease)
: base(DnsOptionCode.UpdateLease) : base(DnsOptionCode.UpdateLease)
{ {
...@@ -34,7 +41,7 @@ ...@@ -34,7 +41,7 @@
public override int DataLength public override int DataLength
{ {
get { return MinimumDataLength; } get { return ConstDataLength; }
} }
internal override bool EqualsData(DnsOption other) internal override bool EqualsData(DnsOption other)
...@@ -54,7 +61,7 @@ ...@@ -54,7 +61,7 @@
internal static DnsOptionUpdateLease Read(DataSegment data) internal static DnsOptionUpdateLease Read(DataSegment data)
{ {
if (data.Length < MinimumDataLength) if (data.Length < ConstDataLength)
return null; return null;
int lease = data.ReadInt(0, Endianity.Big); int lease = data.ReadInt(0, Endianity.Big);
......
...@@ -6,50 +6,72 @@ using PcapDotNet.Base; ...@@ -6,50 +6,72 @@ using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
{ {
/// <summary>
/// RFC 2671.
/// A set of options.
/// </summary>
public sealed class DnsOptions : IEquatable<DnsOptions> public sealed class DnsOptions : IEquatable<DnsOptions>
{ {
/// <summary>
/// Empty options.
/// </summary>
public static DnsOptions None { get { return _none; } } public static DnsOptions None { get { return _none; } }
/// <summary>
/// Constructs options from the given list of options.
/// The given otpions list should be modified after the call to this constructor.
/// </summary>
public DnsOptions(IList<DnsOption> options) public DnsOptions(IList<DnsOption> options)
{ {
Options = options.AsReadOnly(); Options = options.AsReadOnly();
BytesLength = options.Sum(option => option.Length); BytesLength = options.Sum(option => option.Length);
} }
/// <summary>
/// Constructs options from the given list of options.
/// The given otpions list should be modified after the call to this constructor.
/// </summary>
public DnsOptions(params DnsOption[] options) public DnsOptions(params DnsOption[] options)
: this((IList<DnsOption>)options) : this((IList<DnsOption>)options)
{ {
} }
/// <summary>
/// The list of options.
/// </summary>
public ReadOnlyCollection<DnsOption> Options { get; private set; } public ReadOnlyCollection<DnsOption> Options { get; private set; }
/// <summary>
/// The total number of bytes the options take.
/// </summary>
public int BytesLength { get; private set; } public int BytesLength { get; private set; }
/// <summary>
/// Two options objects are equal if they have the same options in the same order.
/// </summary>
public bool Equals(DnsOptions other) public bool Equals(DnsOptions other)
{ {
return other != null && return other != null &&
Options.SequenceEqual(other.Options); Options.SequenceEqual(other.Options);
} }
/// <summary>
/// Two options objects are equal if they have the same options in the same order.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsOptions); return Equals(obj as DnsOptions);
} }
/// <summary>
/// A hash code based on the list of options.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return Options.SequenceGetHashCode(); return Options.SequenceGetHashCode();
} }
private static readonly DnsOptions _none = new DnsOptions(); internal static DnsOptions Read(DataSegment data)
internal void Write(byte[] buffer, int offset)
{
foreach (DnsOption option in Options)
option.Write(buffer, ref offset);
}
public static DnsOptions Read(DataSegment data)
{ {
List<DnsOption> options = new List<DnsOption>(); List<DnsOption> options = new List<DnsOption>();
while (data.Length != 0) while (data.Length != 0)
...@@ -72,5 +94,13 @@ namespace PcapDotNet.Packets.Dns ...@@ -72,5 +94,13 @@ namespace PcapDotNet.Packets.Dns
return new DnsOptions(options); return new DnsOptions(options);
} }
internal void Write(byte[] buffer, int offset)
{
foreach (DnsOption option in Options)
option.Write(buffer, ref offset);
}
private static readonly DnsOptions _none = new DnsOptions();
} }
} }
\ No newline at end of file
...@@ -8,10 +8,17 @@ using PcapDotNet.Base; ...@@ -8,10 +8,17 @@ using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
{ {
/// <summary>
/// RFC 1035.
/// Represents a resource record data.
/// </summary>
public abstract class DnsResourceData public abstract class DnsResourceData
{ {
internal const int StringMinimumLength = sizeof(byte); internal const int StringMinimumLength = sizeof(byte);
/// <summary>
/// Returns the DnsResourceData concrete type that should be created for the given DnsType.
/// </summary>
public static Type GetDnsResourceDataType(DnsType dnsType) public static Type GetDnsResourceDataType(DnsType dnsType)
{ {
DnsResourceData prototype = TryGetPrototype(dnsType); DnsResourceData prototype = TryGetPrototype(dnsType);
...@@ -88,7 +95,6 @@ namespace PcapDotNet.Packets.Dns ...@@ -88,7 +95,6 @@ namespace PcapDotNet.Packets.Dns
return prototypes.ToDictionary(prototype => prototype.Type, prototype => prototype.Prototype); return prototypes.ToDictionary(prototype => prototype.Type, prototype => prototype.Prototype);
} }
private static readonly Dictionary<DnsType, DnsResourceData> _prototypes = InitializePrototypes(); private static readonly Dictionary<DnsType, DnsResourceData> _prototypes = InitializePrototypes();
} }
} }
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
{ {
/// <summary>
/// A resource record data that contains exactly 2 domain names.
/// </summary>
public abstract class DnsResourceData2DomainNames : DnsResourceDataDomainNames public abstract class DnsResourceData2DomainNames : DnsResourceDataDomainNames
{ {
private const int NumDomains = 2; private const int NumDomains = 2;
......
...@@ -16,13 +16,24 @@ ...@@ -16,13 +16,24 @@
[DnsTypeRegistration(Type = DnsType.AfsDatabase)] [DnsTypeRegistration(Type = DnsType.AfsDatabase)]
public sealed class DnsResourceDataAfsDatabase : DnsResourceDataUShortDomainName public sealed class DnsResourceDataAfsDatabase : DnsResourceDataUShortDomainName
{ {
public DnsResourceDataAfsDatabase(ushort subtype, DnsDomainName hostName) /// <summary>
: base(subtype, hostName) /// Constructs an AFS database resource data from the given subtype and host name.
/// </summary>
/// <param name="subtype">The subtype of the resource data.</param>
/// <param name="hostName">A host that has a server for the cell named by the owner name of the RR.</param>
public DnsResourceDataAfsDatabase(DnsAfsDatabaseSubtype subtype, DnsDomainName hostName)
: base((ushort)subtype, hostName)
{ {
} }
public ushort Subtype { get { return Value; } } /// <summary>
/// The subtype of the resource data.
/// </summary>
public DnsAfsDatabaseSubtype Subtype { get { return (DnsAfsDatabaseSubtype)Value; } }
/// <summary>
/// A host that has a server for the cell named by the owner name of the RR.
/// </summary>
public DnsDomainName HostName { get { return DomainName; } } public DnsDomainName HostName { get { return DomainName; } }
internal DnsResourceDataAfsDatabase() internal DnsResourceDataAfsDatabase()
...@@ -37,7 +48,7 @@ ...@@ -37,7 +48,7 @@
if (!TryRead(out subtype, out hostName, dns, offsetInDns, length)) if (!TryRead(out subtype, out hostName, dns, offsetInDns, length))
return null; return null;
return new DnsResourceDataAfsDatabase(subtype, hostName); return new DnsResourceDataAfsDatabase((DnsAfsDatabaseSubtype)subtype, hostName);
} }
} }
} }
\ No newline at end of file
...@@ -12,28 +12,46 @@ namespace PcapDotNet.Packets.Dns ...@@ -12,28 +12,46 @@ namespace PcapDotNet.Packets.Dns
[DnsTypeRegistration(Type = DnsType.DynamicHostConfigurationId)] [DnsTypeRegistration(Type = DnsType.DynamicHostConfigurationId)]
public sealed class DnsResourceDataAnything : DnsResourceDataSimple, IEquatable<DnsResourceDataAnything> public sealed class DnsResourceDataAnything : DnsResourceDataSimple, IEquatable<DnsResourceDataAnything>
{ {
/// <summary>
/// An empty resource data.
/// </summary>
public DnsResourceDataAnything() public DnsResourceDataAnything()
{ {
Data = DataSegment.Empty; Data = DataSegment.Empty;
} }
/// <summary>
/// Constructs the resource data from the given data.
/// </summary>
public DnsResourceDataAnything(DataSegment data) public DnsResourceDataAnything(DataSegment data)
{ {
Data = data; Data = data;
} }
/// <summary>
/// The data of the resource data.
/// </summary>
public DataSegment Data { get; private set; } public DataSegment Data { get; private set; }
/// <summary>
/// Two resource datas are equal if their data is equal.
/// </summary>
public bool Equals(DnsResourceDataAnything other) public bool Equals(DnsResourceDataAnything other)
{ {
return other != null && Data.Equals(other.Data); return other != null && Data.Equals(other.Data);
} }
/// <summary>
/// Two resource datas are equal if their data is equal.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataAnything); return Equals(obj as DnsResourceDataAnything);
} }
/// <summary>
/// The hash code of the data.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return Data.GetHashCode(); return Data.GetHashCode();
......
...@@ -7,10 +7,13 @@ using PcapDotNet.Base; ...@@ -7,10 +7,13 @@ using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
{ {
/// <summary> /// <summary>
/// A base class for resource records that contain DNS domain names. /// A base class for resource record datas that contain DNS domain names.
/// </summary> /// </summary>
public abstract class DnsResourceDataDomainNames : DnsResourceData, IEquatable<DnsResourceDataDomainNames> public abstract class DnsResourceDataDomainNames : DnsResourceData, IEquatable<DnsResourceDataDomainNames>
{ {
/// <summary>
/// Two domain names resource data are equal if they are of the same type and contain the same domain names in the same order.
/// </summary>
public bool Equals(DnsResourceDataDomainNames other) public bool Equals(DnsResourceDataDomainNames other)
{ {
return other != null && return other != null &&
...@@ -18,12 +21,18 @@ namespace PcapDotNet.Packets.Dns ...@@ -18,12 +21,18 @@ namespace PcapDotNet.Packets.Dns
DomainNames.SequenceEqual(other.DomainNames); DomainNames.SequenceEqual(other.DomainNames);
} }
public sealed override bool Equals(object obj) /// <summary>
/// Two domain names resource data are equal if they are of the same type and contain the same domain names in the same order.
/// </summary>
public override sealed bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataDomainNames); return Equals(obj as DnsResourceDataDomainNames);
} }
public override int GetHashCode() /// <summary>
/// The hash code of the resource data is based on the concrete type and domain names.
/// </summary>
public override sealed int GetHashCode()
{ {
return GetType().GetHashCode() ^ DomainNames.SequenceGetHashCode(); return GetType().GetHashCode() ^ DomainNames.SequenceGetHashCode();
} }
......
...@@ -16,23 +16,38 @@ namespace PcapDotNet.Packets.Dns ...@@ -16,23 +16,38 @@ namespace PcapDotNet.Packets.Dns
[DnsTypeRegistration(Type = DnsType.A)] [DnsTypeRegistration(Type = DnsType.A)]
public sealed class DnsResourceDataIpV4 : DnsResourceDataSimple, IEquatable<DnsResourceDataIpV4> public sealed class DnsResourceDataIpV4 : DnsResourceDataSimple, IEquatable<DnsResourceDataIpV4>
{ {
/// <summary>
/// Constructs an IPv4 resource data from the given IP.
/// </summary>
public DnsResourceDataIpV4(IpV4Address data) public DnsResourceDataIpV4(IpV4Address data)
{ {
Data = data; Data = data;
} }
/// <summary>
/// The IPv4 value.
/// </summary>
public IpV4Address Data { get; private set; } public IpV4Address Data { get; private set; }
/// <summary>
/// Two IPv4 resource datas are equal if their IP is equal.
/// </summary>
public bool Equals(DnsResourceDataIpV4 other) public bool Equals(DnsResourceDataIpV4 other)
{ {
return other != null && Data.Equals(other.Data); return other != null && Data.Equals(other.Data);
} }
/// <summary>
/// Two IPv4 resource datas are equal if their IP is equal.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataIpV4); return Equals(obj as DnsResourceDataIpV4);
} }
/// <summary>
/// Returns the hash code of the IPv4 value.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return Data.GetHashCode(); return Data.GetHashCode();
......
...@@ -16,23 +16,38 @@ namespace PcapDotNet.Packets.Dns ...@@ -16,23 +16,38 @@ namespace PcapDotNet.Packets.Dns
[DnsTypeRegistration(Type = DnsType.Aaaa)] [DnsTypeRegistration(Type = DnsType.Aaaa)]
public sealed class DnsResourceDataIpV6 : DnsResourceDataSimple, IEquatable<DnsResourceDataIpV6> public sealed class DnsResourceDataIpV6 : DnsResourceDataSimple, IEquatable<DnsResourceDataIpV6>
{ {
/// <summary>
/// Constructs an IPv6 resource data from the given IP.
/// </summary>
public DnsResourceDataIpV6(IpV6Address data) public DnsResourceDataIpV6(IpV6Address data)
{ {
Data = data; Data = data;
} }
/// <summary>
/// The IPv6 value.
/// </summary>
public IpV6Address Data { get; private set; } public IpV6Address Data { get; private set; }
/// <summary>
/// Two IPv6 resource datas are equal if their IP is equal.
/// </summary>
public bool Equals(DnsResourceDataIpV6 other) public bool Equals(DnsResourceDataIpV6 other)
{ {
return other != null && Data.Equals(other.Data); return other != null && Data.Equals(other.Data);
} }
/// <summary>
/// Two IPv6 resource datas are equal if their IP is equal.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataIpV6); return Equals(obj as DnsResourceDataIpV6);
} }
/// <summary>
/// Returns the hash code of the IPv6 value.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return Data.GetHashCode(); return Data.GetHashCode();
......
...@@ -16,6 +16,16 @@ ...@@ -16,6 +16,16 @@
[DnsTypeRegistration(Type = DnsType.KeyExchanger)] [DnsTypeRegistration(Type = DnsType.KeyExchanger)]
public sealed class DnsResourceDataKeyExchanger : DnsResourceDataUShortDomainName public sealed class DnsResourceDataKeyExchanger : DnsResourceDataUShortDomainName
{ {
/// <summary>
/// Constructs a key exchanger resource data from the given preference and key exchanger domain.
/// </summary>
/// <param name="preference">
/// Specifies the preference given to this RR among other KX records at the same owner.
/// Lower values are preferred.
/// </param>
/// <param name="keyExchanger">
/// Specifies a host willing to act as a key exchange for the owner name.
/// </param>
public DnsResourceDataKeyExchanger(ushort preference, DnsDomainName keyExchanger) public DnsResourceDataKeyExchanger(ushort preference, DnsDomainName keyExchanger)
: base(preference, keyExchanger) : base(preference, keyExchanger)
{ {
......
...@@ -16,6 +16,16 @@ ...@@ -16,6 +16,16 @@
[DnsTypeRegistration(Type = DnsType.MailExchange)] [DnsTypeRegistration(Type = DnsType.MailExchange)]
public sealed class DnsResourceDataMailExchange : DnsResourceDataUShortDomainName public sealed class DnsResourceDataMailExchange : DnsResourceDataUShortDomainName
{ {
/// <summary>
/// Constructs mail exchange resource data from preference and host.
/// </summary>
/// <param name="preference">
/// Specifies the preference given to this RR among others at the same owner.
/// Lower values are preferred.
/// </param>
/// <param name="mailExchangeHost">
/// Specifies a host willing to act as a mail exchange for the owner name.
/// </param>
public DnsResourceDataMailExchange(ushort preference, DnsDomainName mailExchangeHost) public DnsResourceDataMailExchange(ushort preference, DnsDomainName mailExchangeHost)
: base(preference, mailExchangeHost) : base(preference, mailExchangeHost)
{ {
......
...@@ -13,6 +13,20 @@ ...@@ -13,6 +13,20 @@
[DnsTypeRegistration(Type = DnsType.MInfo)] [DnsTypeRegistration(Type = DnsType.MInfo)]
public sealed class DnsResourceDataMailingListInfo : DnsResourceData2DomainNames public sealed class DnsResourceDataMailingListInfo : DnsResourceData2DomainNames
{ {
/// <summary>
/// Constructs a mailing list info resource data from mailing list and error mailbox.
/// </summary>
/// <param name="mailingList">
/// Specifies a mailbox which is responsible for the mailing list or mailbox.
/// If this domain name names the root, the owner of the MINFO RR is responsible for itself.
/// Note that many existing mailing lists use a mailbox X-request for the RMAILBX field of mailing list X, e.g., Msgroup-request for Msgroup.
/// This field provides a more general mechanism.
/// </param>
/// <param name="errorMailbox">
/// Specifies a mailbox which is to receive error messages related to the mailing list or mailbox specified by the owner of the MINFO RR
/// (similar to the ERRORS-TO: field which has been proposed).
/// If this domain name names the root, errors should be returned to the sender of the message.
/// </param>
public DnsResourceDataMailingListInfo(DnsDomainName mailingList, DnsDomainName errorMailbox) public DnsResourceDataMailingListInfo(DnsDomainName mailingList, DnsDomainName errorMailbox)
: base(mailingList, errorMailbox) : base(mailingList, errorMailbox)
{ {
......
...@@ -13,6 +13,20 @@ ...@@ -13,6 +13,20 @@
[DnsTypeRegistration(Type = DnsType.ResponsiblePerson)] [DnsTypeRegistration(Type = DnsType.ResponsiblePerson)]
public sealed class DnsResourceDataResponsiblePerson : DnsResourceData2DomainNames public sealed class DnsResourceDataResponsiblePerson : DnsResourceData2DomainNames
{ {
/// <summary>
/// Constructs a responsible person resource data from the given mailbox and text domain.
/// </summary>
/// <param name="mailbox">
/// A domain name that specifies the mailbox for the responsible person.
/// Its format in master files uses the DNS convention for mailbox encoding, identical to that used for the RNAME mailbox field in the SOA RR.
/// The root domain name (just ".") may be specified for Mailbox to indicate that no mailbox is available.
/// </param>
/// <param name="textDomain">
/// A domain name for which TXT RR's exist.
/// A subsequent query can be performed to retrieve the associated TXT resource records at TextDomain.
/// This provides a level of indirection so that the entity can be referred to from multiple places in the DNS.
/// The root domain name (just ".") may be specified for TextDomain to indicate that the TXT_DNAME is absent, and no associated TXT RR exists.
/// </param>
public DnsResourceDataResponsiblePerson(DnsDomainName mailbox, DnsDomainName textDomain) public DnsResourceDataResponsiblePerson(DnsDomainName mailbox, DnsDomainName textDomain)
: base(mailbox, textDomain) : base(mailbox, textDomain)
{ {
......
...@@ -16,6 +16,17 @@ ...@@ -16,6 +16,17 @@
[DnsTypeRegistration(Type = DnsType.RouteThrough)] [DnsTypeRegistration(Type = DnsType.RouteThrough)]
public sealed class DnsResourceDataRouteThrough : DnsResourceDataUShortDomainName public sealed class DnsResourceDataRouteThrough : DnsResourceDataUShortDomainName
{ {
/// <summary>
/// Constructs a route through resource data from the given preference and intermediate host.
/// </summary>
/// <param name="preference">
/// Representing the preference of the route.
/// Smaller numbers indicate more preferred routes.
/// </param>
/// <param name="intermediateHost">
/// The domain name of a host which will serve as an intermediate in reaching the host specified by the owner.
/// The DNS RRs associated with IntermediateHost are expected to include at least one A, X25, or ISDN record.
/// </param>
public DnsResourceDataRouteThrough(ushort preference, DnsDomainName intermediateHost) public DnsResourceDataRouteThrough(ushort preference, DnsDomainName intermediateHost)
: base(preference, intermediateHost) : base(preference, intermediateHost)
{ {
......
...@@ -10,24 +10,39 @@ namespace PcapDotNet.Packets.Dns ...@@ -10,24 +10,39 @@ namespace PcapDotNet.Packets.Dns
[DnsTypeRegistration(Type = DnsType.X25)] [DnsTypeRegistration(Type = DnsType.X25)]
public sealed class DnsResourceDataString : DnsResourceDataSimple, IEquatable<DnsResourceDataString> public sealed class DnsResourceDataString : DnsResourceDataSimple, IEquatable<DnsResourceDataString>
{ {
/// <summary>
/// Creates the resource data from the given string.
/// </summary>
public DnsResourceDataString(DataSegment value) public DnsResourceDataString(DataSegment value)
{ {
String = value; String = value;
} }
/// <summary>
/// The value of the data.
/// </summary>
public DataSegment String { get; private set; } public DataSegment String { get; private set; }
/// <summary>
/// Two string resource datas are equals if they have the same string.
/// </summary>
public bool Equals(DnsResourceDataString other) public bool Equals(DnsResourceDataString other)
{ {
return other != null && return other != null &&
String.Equals(other.String); String.Equals(other.String);
} }
/// <summary>
/// Two string resource datas are equals if they have the same string.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataString); return Equals(obj as DnsResourceDataString);
} }
/// <summary>
/// The hash code of the string.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return String.GetHashCode(); return String.GetHashCode();
......
...@@ -13,6 +13,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -13,6 +13,9 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public abstract class DnsResourceDataStrings : DnsResourceDataSimple, IEquatable<DnsResourceDataStrings> public abstract class DnsResourceDataStrings : DnsResourceDataSimple, IEquatable<DnsResourceDataStrings>
{ {
/// <summary>
/// Two strings resources datas are equal if they are of the same concrete type and their strings are equal and in the same order.
/// </summary>
public bool Equals(DnsResourceDataStrings other) public bool Equals(DnsResourceDataStrings other)
{ {
return other != null && return other != null &&
...@@ -20,11 +23,17 @@ namespace PcapDotNet.Packets.Dns ...@@ -20,11 +23,17 @@ namespace PcapDotNet.Packets.Dns
Strings.SequenceEqual(other.Strings); Strings.SequenceEqual(other.Strings);
} }
/// <summary>
/// Two strings resources datas are equal if they are of the same concrete type and their strings are equal and in the same order.
/// </summary>
public sealed override bool Equals(object obj) public sealed override bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataStrings); return Equals(obj as DnsResourceDataStrings);
} }
/// <summary>
/// A hash code based on the concrete type and the strings.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return GetType().GetHashCode() ^ Strings.SequenceGetHashCode(); return GetType().GetHashCode() ^ Strings.SequenceGetHashCode();
......
...@@ -12,11 +12,17 @@ namespace PcapDotNet.Packets.Dns ...@@ -12,11 +12,17 @@ namespace PcapDotNet.Packets.Dns
[DnsTypeRegistration(Type = DnsType.Spf)] [DnsTypeRegistration(Type = DnsType.Spf)]
public sealed class DnsResourceDataText : DnsResourceDataStrings public sealed class DnsResourceDataText : DnsResourceDataStrings
{ {
/// <summary>
/// Constructs the resource data from the given list of strings, each up to 255 bytes.
/// </summary>
public DnsResourceDataText(ReadOnlyCollection<DataSegment> strings) public DnsResourceDataText(ReadOnlyCollection<DataSegment> strings)
: base(strings) : base(strings)
{ {
} }
/// <summary>
/// The list of strings, each up to 255 bytes.
/// </summary>
public ReadOnlyCollection<DataSegment> Text { get { return Strings; } } public ReadOnlyCollection<DataSegment> Text { get { return Strings; } }
internal DnsResourceDataText() internal DnsResourceDataText()
......
...@@ -8,6 +8,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -8,6 +8,9 @@ namespace PcapDotNet.Packets.Dns
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags"), Flags] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags"), Flags]
public enum DnsSecNSec3Flags : byte public enum DnsSecNSec3Flags : byte
{ {
/// <summary>
/// Undefined value.
/// </summary>
None = 0x00, None = 0x00,
/// <summary> /// <summary>
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
/// </summary> /// </summary>
public enum DnsSecNSec3HashAlgorithm : byte public enum DnsSecNSec3HashAlgorithm : byte
{ {
/// <summary>
/// Undefined value.
/// </summary>
None = 0x00, None = 0x00,
/// <summary> /// <summary>
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
/// </summary> /// </summary>
public enum DnsSinkCoding : byte public enum DnsSinkCoding : byte
{ {
/// <summary>
/// Undefined value.
/// </summary>
None = 0x00, None = 0x00,
/// <summary> /// <summary>
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
/// </summary> /// </summary>
public enum DnsSinkCodingSubCoding : ushort public enum DnsSinkCodingSubCoding : ushort
{ {
/// <summary>
/// Undefined value.
/// </summary>
None = 0x0000, None = 0x0000,
/// <summary> /// <summary>
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
/// </summary> /// </summary>
public enum DnsTransactionKeyMode : ushort public enum DnsTransactionKeyMode : ushort
{ {
/// <summary>
/// Undefined value.
/// </summary>
None = 0, None = 0,
/// <summary> /// <summary>
......
...@@ -108,6 +108,7 @@ ...@@ -108,6 +108,7 @@
<Compile Include="Dns\DnsQueryResourceRecord.cs" /> <Compile Include="Dns\DnsQueryResourceRecord.cs" />
<Compile Include="AddressFamily.cs" /> <Compile Include="AddressFamily.cs" />
<Compile Include="Dns\ResourceData\DnsAddressPrefix.cs" /> <Compile Include="Dns\ResourceData\DnsAddressPrefix.cs" />
<Compile Include="Dns\ResourceData\DnsAfsDatabaseSubtype.cs" />
<Compile Include="Dns\ResourceData\DnsAlgorithm.cs" /> <Compile Include="Dns\ResourceData\DnsAlgorithm.cs" />
<Compile Include="Dns\ResourceData\DnsAtmAddressFormat.cs" /> <Compile Include="Dns\ResourceData\DnsAtmAddressFormat.cs" />
<Compile Include="Dns\ResourceData\DnsCertificateType.cs" /> <Compile Include="Dns\ResourceData\DnsCertificateType.cs" />
......
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