Commit 3fc2a1a2 authored by Brickner_cp's avatar Brickner_cp

Warnings, Code Analysis and Documentation. 39 warnings left.

parent 19eb654f
...@@ -39,6 +39,9 @@ ...@@ -39,6 +39,9 @@
/// </summary> /// </summary>
public int Lease { get; private set; } public int Lease { get; private set; }
/// <summary>
/// The number of bytes the option data takes.
/// </summary>
public override int DataLength public override int DataLength
{ {
get { return ConstDataLength; } get { return ConstDataLength; }
......
...@@ -40,6 +40,20 @@ namespace PcapDotNet.Packets.Dns ...@@ -40,6 +40,20 @@ namespace PcapDotNet.Packets.Dns
private const int ConstantPartLength = Offset.HostIdentityTag; private const int ConstantPartLength = Offset.HostIdentityTag;
/// <summary>
/// Constructs an instance out of the host identity tag, public key algorithm, public key and rendezvous servers fields.
/// </summary>
/// <param name="hostIdentityTag">Stored as a binary value in network byte order.</param>
/// <param name="publicKeyAlgorithm">Identifies the public key's cryptographic algorithm and determines the format of the public key field.</param>
/// <param name="publicKey">Contains the algorithm-specific portion of the KEY RR RDATA.</param>
/// <param name="rendezvousServers">
/// Indicates one or more domain names of rendezvous server(s).
/// Must not be compressed.
/// The rendezvous server(s) are listed in order of preference (i.e., first rendezvous server(s) are preferred),
/// defining an implicit order amongst rendezvous servers of a single RR.
/// When multiple HIP RRs are present at the same owner name,
/// this implicit order of rendezvous servers within an RR must not be used to infer a preference order between rendezvous servers stored in different RRs.
/// </param>
public DnsResourceDataHostIdentityProtocol(DataSegment hostIdentityTag, DnsPublicKeyAlgorithm publicKeyAlgorithm, DataSegment publicKey, public DnsResourceDataHostIdentityProtocol(DataSegment hostIdentityTag, DnsPublicKeyAlgorithm publicKeyAlgorithm, DataSegment publicKey,
IEnumerable<DnsDomainName> rendezvousServers) IEnumerable<DnsDomainName> rendezvousServers)
{ {
...@@ -85,6 +99,10 @@ namespace PcapDotNet.Packets.Dns ...@@ -85,6 +99,10 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public ReadOnlyCollection<DnsDomainName> RendezvousServers { get; private set; } public ReadOnlyCollection<DnsDomainName> RendezvousServers { get; private set; }
/// <summary>
/// Two DnsResourceDataHostIdentityProtocol are equal iff their host identity tag, public key algorithm, public key and rendezvous servers fields
/// are equal.
/// </summary>
public bool Equals(DnsResourceDataHostIdentityProtocol other) public bool Equals(DnsResourceDataHostIdentityProtocol other)
{ {
return other != null && return other != null &&
...@@ -94,11 +112,18 @@ namespace PcapDotNet.Packets.Dns ...@@ -94,11 +112,18 @@ namespace PcapDotNet.Packets.Dns
RendezvousServers.SequenceEqual(RendezvousServers); RendezvousServers.SequenceEqual(RendezvousServers);
} }
/// <summary>
/// Two DnsResourceDataHostIdentityProtocol are equal iff their host identity tag, public key algorithm, public key and rendezvous servers fields
/// are equal.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataHostIdentityProtocol); return Equals(obj as DnsResourceDataHostIdentityProtocol);
} }
/// <summary>
/// A hash code of the combination of the host identity tag, public key algorithm, public key and rendezvous servers fields.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return Sequence.GetHashCode(HostIdentityTag, PublicKeyAlgorithm, PublicKey) ^ RendezvousServers.SequenceGetHashCode(); return Sequence.GetHashCode(HostIdentityTag, PublicKeyAlgorithm, PublicKey) ^ RendezvousServers.SequenceGetHashCode();
......
...@@ -41,8 +41,69 @@ namespace PcapDotNet.Packets.Dns ...@@ -41,8 +41,69 @@ namespace PcapDotNet.Packets.Dns
private const int ConstantPartLength = Offset.Flags; private const int ConstantPartLength = Offset.Flags;
private const int MinimumLength = ConstantPartLength + StringMinimumLength + StringMinimumLength + StringMinimumLength + DnsDomainName.RootLength; private const int MinimumLength = ConstantPartLength + StringMinimumLength + StringMinimumLength + StringMinimumLength + DnsDomainName.RootLength;
/// <summary>
/// Constructs an instance out of the order, preference, flags, services, regular expression and replacement fields.
/// </summary>
/// <param name="order">
/// A 16-bit unsigned integer specifying the order in which the NAPTR records MUST be processed
/// in order to accurately represent the ordered list of Rules.
/// The ordering is from lowest to highest.
/// If two records have the same order value then they are considered to be the same rule and should be selected
/// based on the combination of the Preference values and Services offered.
/// </param>
/// <param name="preference">
/// Although it is called "preference" in deference to DNS terminology, this field is equivalent to the Priority value in the DDDS Algorithm.
/// It specifies the order in which NAPTR records with equal Order values should be processed, low numbers being processed before high numbers.
/// This is similar to the preference field in an MX record,
/// and is used so domain administrators can direct clients towards more capable hosts or lighter weight protocols.
/// A client may look at records with higher preference values if it has a good reason to do so such
/// as not supporting some protocol or service very well.
/// The important difference between Order and Preference is that once a match is found the client must not consider records
/// with a different Order but they may process records with the same Order but different Preferences.
/// The only exception to this is noted in the second important Note in the DDDS algorithm specification
/// concerning allowing clients to use more complex Service determination between steps 3 and 4 in the algorithm.
/// Preference is used to give communicate a higher quality of service to rules that are considered the same from an authority standpoint
/// but not from a simple load balancing standpoint.
///
/// It is important to note that DNS contains several load balancing mechanisms and if load balancing among otherwise equal services
/// should be needed then methods such as SRV records or multiple A records should be utilized to accomplish load balancing.
/// </param>
/// <param name="flags">
/// Flags to control aspects of the rewriting and interpretation of the fields in the record.
/// Flags are single characters from the set A-Z and 0-9.
/// The case of the alphabetic characters is not significant.
/// The field can be empty.
///
/// It is up to the Application specifying how it is using this Database to define the Flags in this field.
/// It must define which ones are terminal and which ones are not.
/// </param>
/// <param name="services">
/// Specifies the Service Parameters applicable to this this delegation path.
/// It is up to the Application Specification to specify the values found in this field.
/// </param>
/// <param name="regularExpression">
/// A substitution expression that is applied to the original string held by the client in order to construct the next domain name to lookup.
/// See the DDDS Algorithm specification for the syntax of this field.
///
/// As stated in the DDDS algorithm, The regular expressions must not be used in a cumulative fashion,
/// that is, they should only be applied to the original string held by the client, never to the domain name produced by a previous NAPTR rewrite.
/// The latter is tempting in some applications but experience has shown such use to be extremely fault sensitive, very error prone,
/// and extremely difficult to debug.
/// </param>
/// <param name="replacement">
/// The next domain-name to query for depending on the potential values found in the flags field.
/// This field is used when the regular expression is a simple replacement operation.
/// Any value in this field must be a fully qualified domain-name.
/// Name compression is not to be used for this field.
///
/// This field and the Regexp field together make up the Substitution Expression in the DDDS Algorithm.
/// It is simply a historical optimization specifically for DNS compression that this field exists.
/// The fields are also mutually exclusive.
/// If a record is returned that has values for both fields then it is considered to be in error and SHOULD be either ignored or an error returned.
/// </param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "flags")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "flags")]
public DnsResourceDataNamingAuthorityPointer(ushort order, ushort preference, DataSegment flags, DataSegment services, DataSegment regularExpression, DnsDomainName replacement) public DnsResourceDataNamingAuthorityPointer(ushort order, ushort preference, DataSegment flags, DataSegment services, DataSegment regularExpression,
DnsDomainName replacement)
{ {
if (flags == null) if (flags == null)
throw new ArgumentNullException("flags"); throw new ArgumentNullException("flags");
...@@ -67,22 +128,30 @@ namespace PcapDotNet.Packets.Dns ...@@ -67,22 +128,30 @@ namespace PcapDotNet.Packets.Dns
} }
/// <summary> /// <summary>
/// A 16-bit unsigned integer specifying the order in which the NAPTR records MUST be processed in order to accurately represent the ordered list of Rules. /// A 16-bit unsigned integer specifying the order in which the NAPTR records MUST be processed
/// in order to accurately represent the ordered list of Rules.
/// The ordering is from lowest to highest. /// The ordering is from lowest to highest.
/// If two records have the same order value then they are considered to be the same rule and should be selected based on the combination of the Preference values and Services offered. /// If two records have the same order value then they are considered to be the same rule and should be selected
/// based on the combination of the Preference values and Services offered.
/// </summary> /// </summary>
public ushort Order { get; private set; } public ushort Order { get; private set; }
/// <summary> /// <summary>
/// Although it is called "preference" in deference to DNS terminology, this field is equivalent to the Priority value in the DDDS Algorithm. /// Although it is called "preference" in deference to DNS terminology, this field is equivalent to the Priority value in the DDDS Algorithm.
/// It specifies the order in which NAPTR records with equal Order values should be processed, low numbers being processed before high numbers. /// It specifies the order in which NAPTR records with equal Order values should be processed, low numbers being processed before high numbers.
/// This is similar to the preference field in an MX record, and is used so domain administrators can direct clients towards more capable hosts or lighter weight protocols. /// This is similar to the preference field in an MX record,
/// A client may look at records with higher preference values if it has a good reason to do so such as not supporting some protocol or service very well. /// and is used so domain administrators can direct clients towards more capable hosts or lighter weight protocols.
/// The important difference between Order and Preference is that once a match is found the client must not consider records with a different Order but they may process records with the same Order but different Preferences. /// A client may look at records with higher preference values if it has a good reason to do so such
/// The only exception to this is noted in the second important Note in the DDDS algorithm specification concerning allowing clients to use more complex Service determination between steps 3 and 4 in the algorithm. /// as not supporting some protocol or service very well.
/// Preference is used to give communicate a higher quality of service to rules that are considered the same from an authority standpoint but not from a simple load balancing standpoint. /// The important difference between Order and Preference is that once a match is found the client must not consider records
/// with a different Order but they may process records with the same Order but different Preferences.
/// The only exception to this is noted in the second important Note in the DDDS algorithm specification
/// concerning allowing clients to use more complex Service determination between steps 3 and 4 in the algorithm.
/// Preference is used to give communicate a higher quality of service to rules that are considered the same from an authority standpoint
/// but not from a simple load balancing standpoint.
/// ///
/// It is important to note that DNS contains several load balancing mechanisms and if load balancing among otherwise equal services should be needed then methods such as SRV records or multiple A records should be utilized to accomplish load balancing. /// It is important to note that DNS contains several load balancing mechanisms and if load balancing among otherwise equal services
/// should be needed then methods such as SRV records or multiple A records should be utilized to accomplish load balancing.
/// </summary> /// </summary>
public ushort Preference { get; private set; } public ushort Preference { get; private set; }
...@@ -108,8 +177,10 @@ namespace PcapDotNet.Packets.Dns ...@@ -108,8 +177,10 @@ namespace PcapDotNet.Packets.Dns
/// A substitution expression that is applied to the original string held by the client in order to construct the next domain name to lookup. /// A substitution expression that is applied to the original string held by the client in order to construct the next domain name to lookup.
/// See the DDDS Algorithm specification for the syntax of this field. /// See the DDDS Algorithm specification for the syntax of this field.
/// ///
/// As stated in the DDDS algorithm, The regular expressions must not be used in a cumulative fashion, that is, they should only be applied to the original string held by the client, never to the domain name produced by a previous NAPTR rewrite. /// As stated in the DDDS algorithm, The regular expressions must not be used in a cumulative fashion,
/// The latter is tempting in some applications but experience has shown such use to be extremely fault sensitive, very error prone, and extremely difficult to debug. /// that is, they should only be applied to the original string held by the client, never to the domain name produced by a previous NAPTR rewrite.
/// The latter is tempting in some applications but experience has shown such use to be extremely fault sensitive, very error prone,
/// and extremely difficult to debug.
/// </summary> /// </summary>
public DataSegment RegularExpression { get; private set; } public DataSegment RegularExpression { get; private set; }
...@@ -126,6 +197,10 @@ namespace PcapDotNet.Packets.Dns ...@@ -126,6 +197,10 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public DnsDomainName Replacement { get; private set; } public DnsDomainName Replacement { get; private set; }
/// <summary>
/// Two DnsResourceDataNamingAuthorityPointer are equal iff their order, preference, flags, services, regular expression and replacement fields
/// are equal.
/// </summary>
public bool Equals(DnsResourceDataNamingAuthorityPointer other) public bool Equals(DnsResourceDataNamingAuthorityPointer other)
{ {
return other != null && return other != null &&
...@@ -137,11 +212,18 @@ namespace PcapDotNet.Packets.Dns ...@@ -137,11 +212,18 @@ namespace PcapDotNet.Packets.Dns
Replacement.Equals(other.Replacement); Replacement.Equals(other.Replacement);
} }
/// <summary>
/// Two DnsResourceDataNamingAuthorityPointer are equal iff their order, preference, flags, services, regular expression and replacement fields
/// are equal.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataNamingAuthorityPointer); return Equals(obj as DnsResourceDataNamingAuthorityPointer);
} }
/// <summary>
/// A hash code of the combination of the order, preference, flags, services, regular expression and replacement fields.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return Sequence.GetHashCode(BitSequence.Merge(Order, Preference), Flags, Services, RegularExpression, Replacement); return Sequence.GetHashCode(BitSequence.Merge(Order, Preference), Flags, Services, RegularExpression, Replacement);
......
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