Commit 6e11b029 authored by Brickner_cp's avatar Brickner_cp

Warnings, Code Analysis and Documentation. 8 warnings left.

parent 3fc2a1a2
...@@ -87,6 +87,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -87,6 +87,9 @@ namespace PcapDotNet.Packets.Dns
return string.Format("{0} {1} {2}", base.ToString(), Ttl, Data); return string.Format("{0} {1} {2}", base.ToString(), Ttl, Data);
} }
/// <summary>
/// Two DnsDataResourceRecord are equal iff their domain name, dns type, dns class, ttl and data fields are equal.
/// </summary>
[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")]
public bool Equals(DnsDataResourceRecord other) public bool Equals(DnsDataResourceRecord other)
{ {
...@@ -95,11 +98,17 @@ namespace PcapDotNet.Packets.Dns ...@@ -95,11 +98,17 @@ namespace PcapDotNet.Packets.Dns
Data.Equals(other.Data); Data.Equals(other.Data);
} }
/// <summary>
/// Two DnsDataResourceRecord are equal iff their domain name, dns type, dns class, ttl and data fields are equal.
/// </summary>
public override sealed bool Equals(object obj) public override sealed bool Equals(object obj)
{ {
return Equals(obj as DnsDataResourceRecord); return Equals(obj as DnsDataResourceRecord);
} }
/// <summary>
/// A hash code of the combination of the domain name, dns type, dns class, ttl and data fields.
/// </summary>
public override sealed int GetHashCode() public override sealed int GetHashCode()
{ {
return GetHashCodeBase() ^ Sequence.GetHashCode(Ttl, Data); return GetHashCodeBase() ^ Sequence.GetHashCode(Ttl, Data);
......
...@@ -78,7 +78,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -78,7 +78,7 @@ namespace PcapDotNet.Packets.Dns
return string.Format("{0} {1} {2}", DomainName, DnsType, DnsClass); return string.Format("{0} {1} {2}", DomainName, DnsType, DnsClass);
} }
protected DnsResourceRecord(DnsDomainName domainName, DnsType type, DnsClass dnsClass) internal DnsResourceRecord(DnsDomainName domainName, DnsType type, DnsClass dnsClass)
{ {
DomainName = domainName; DomainName = domainName;
DnsType = type; DnsType = type;
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
/// </summary> /// </summary>
public enum DnsAfsDatabaseSubtype : ushort public enum DnsAfsDatabaseSubtype : ushort
{ {
/// <summary>
/// An invalid value.
/// </summary>
None = 0,
/// <summary> /// <summary>
/// The host has an AFS version 3.0 Volume Location Server for the named AFS cell. /// The host has an AFS version 3.0 Volume Location Server for the named AFS cell.
/// </summary> /// </summary>
......
...@@ -56,10 +56,61 @@ namespace PcapDotNet.Packets.Dns ...@@ -56,10 +56,61 @@ namespace PcapDotNet.Packets.Dns
private const int ConstantPartLength = Offset.FlagsExtension; private const int ConstantPartLength = Offset.FlagsExtension;
/// <summary>
/// Constructs an instance out of the authentication prohibited, confidentiality prohibited, experimental, user associated, IPSec, email, name type,
/// signatory, protocol, algorithm, flags extension and public key fields.
/// </summary>
/// <param name="authenticationProhibited">Use of the key is prohibited for authentication.</param>
/// <param name="confidentialityProhibited">Use of the key is prohibited for confidentiality.</param>
/// <param name="experimental">
/// Ignored if the type field indicates "no key" and the following description assumes that type field to be non-zero.
/// Keys may be associated with zones, entities, or users for experimental, trial, or optional use, in which case this bit will be one.
/// If this bit is a zero, it means that the use or availability of security based on the key is "mandatory".
/// Thus, if this bit is off for a zone key, the zone should be assumed secured by SIG RRs and any responses indicating the zone is not secured should be considered bogus.
/// If this bit is a one for a host or end entity, it might sometimes operate in a secure mode and at other times operate without security.
/// The experimental bit, like all other aspects of the KEY RR, is only effective if the KEY RR is appropriately signed by a SIG RR.
/// The experimental bit must be zero for safe secure operation and should only be a one for a minimal transition period.
/// </param>
/// <param name="userAssociated">
/// Indicates that this is a key associated with a "user" or "account" at an end entity, usually a host.
/// The coding of the owner name is that used for the responsible individual mailbox in the SOA and RP RRs:
/// The owner name is the user name as the name of a node under the entity name.
/// For example, "j.random_user" on host.subdomain.domain could have a public key associated through a KEY RR
/// with name j\.random_user.host.subdomain.domain and the user bit a one.
/// It could be used in an security protocol where authentication of a user was desired.
/// This key might be useful in IP or other security for a user level service such a telnet, ftp, rlogin, etc.
/// </param>
/// <param name="ipSec">
/// Indicates that this key is valid for use in conjunction with that security standard.
/// This key could be used in connection with secured communication on behalf of an end entity or user whose name is the owner name of the KEY RR
/// if the entity or user bits are on.
/// The presence of a KEY resource with the IPSEC and entity bits on and experimental and no-key bits off is an assertion that the host speaks IPSEC.
/// </param>
/// <param name="email">
/// Indicates that this key is valid for use in conjunction with MIME security multiparts.
/// This key could be used in connection with secured communication on behalf of an end entity or user
/// whose name is the owner name of the KEY RR if the entity or user bits are on.
/// </param>
/// <param name="nameType">The name type.</param>
/// <param name="signatory">
/// If non-zero, indicates that the key can validly sign things as specified in DNS dynamic update.
/// Note that zone keys always have authority to sign any RRs in the zone regardless of the value of the signatory field.
/// </param>
/// <param name="protocol">
/// It is anticipated that keys stored in DNS will be used in conjunction with a variety of Internet protocols.
/// It is intended that the protocol octet and possibly some of the currently unused (must be zero) bits in the KEY RR flags
/// as specified in the future will be used to indicate a key's validity for different protocols.
/// </param>
/// <param name="algorithm">The key algorithm parallel to the same field for the SIG resource.</param>
/// <param name="flagsExtension">
/// Optional second 16 bit flag field after the algorithm octet and before the key data.
/// Must not be non-null unless one or more such additional bits have been defined and are non-zero.
/// </param>
/// <param name="publicKey">The public key value.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "flags")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "flags")]
public DnsResourceDataKey(bool authenticationProhibited, bool confidentialityProhibited, bool experimental, bool userAssociated, bool ipSec, bool email, public DnsResourceDataKey(bool authenticationProhibited, bool confidentialityProhibited, bool experimental, bool userAssociated, bool ipSec,
DnsKeyNameType nameType, DnsKeySignatoryAttributes signatory, DnsKeyProtocol protocol, DnsAlgorithm algorithm, ushort? flagsExtension, bool email, DnsKeyNameType nameType, DnsKeySignatoryAttributes signatory, DnsKeyProtocol protocol, DnsAlgorithm algorithm,
DataSegment publicKey) ushort? flagsExtension, DataSegment publicKey)
{ {
AuthenticationProhibited = authenticationProhibited; AuthenticationProhibited = authenticationProhibited;
ConfidentialityProhibited = confidentialityProhibited; ConfidentialityProhibited = confidentialityProhibited;
...@@ -135,7 +186,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -135,7 +186,8 @@ namespace PcapDotNet.Packets.Dns
/// <summary> /// <summary>
/// It is anticipated that keys stored in DNS will be used in conjunction with a variety of Internet protocols. /// It is anticipated that keys stored in DNS will be used in conjunction with a variety of Internet protocols.
/// It is intended that the protocol octet and possibly some of the currently unused (must be zero) bits in the KEY RR flags as specified in the future will be used to indicate a key's validity for different protocols. /// It is intended that the protocol octet and possibly some of the currently unused (must be zero) bits in the KEY RR flags
/// as specified in the future will be used to indicate a key's validity for different protocols.
/// </summary> /// </summary>
public DnsKeyProtocol Protocol { get; private set; } public DnsKeyProtocol Protocol { get; private set; }
...@@ -156,6 +208,10 @@ namespace PcapDotNet.Packets.Dns ...@@ -156,6 +208,10 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public DataSegment PublicKey { get; private set; } public DataSegment PublicKey { get; private set; }
/// <summary>
/// Two DnsResourceDataKey are equal iff their authentication prohibited, confidentiality prohibited, experimental, user associated, IPSec, email,
/// name type, signatory, protocol, algorithm, flags extension and public key fields are equal.
/// </summary>
public bool Equals(DnsResourceDataKey other) public bool Equals(DnsResourceDataKey other)
{ {
return other != null && return other != null &&
...@@ -175,11 +231,19 @@ namespace PcapDotNet.Packets.Dns ...@@ -175,11 +231,19 @@ namespace PcapDotNet.Packets.Dns
PublicKey.Equals(other.PublicKey); PublicKey.Equals(other.PublicKey);
} }
/// <summary>
/// Two DnsResourceDataKey are equal iff their authentication prohibited, confidentiality prohibited, experimental, user associated, IPSec, email,
/// name type, signatory, protocol, algorithm, flags extension and public key fields are equal.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataKey); return Equals(obj as DnsResourceDataKey);
} }
/// <summary>
/// A hash code out of the combination of the authentication prohibited, confidentiality prohibited, experimental, user associated, IPSec, email,
/// name type, signatory, protocol, algorithm, flags extension and public key fields.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return Sequence.GetHashCode( return Sequence.GetHashCode(
......
...@@ -41,6 +41,16 @@ namespace PcapDotNet.Packets.Dns ...@@ -41,6 +41,16 @@ namespace PcapDotNet.Packets.Dns
private const int ConstantPartLength = MinAreaAddressLength + OffsetAfterArea.Selector + sizeof(byte); private const int ConstantPartLength = MinAreaAddressLength + OffsetAfterArea.Selector + sizeof(byte);
/// <summary>
/// Constructs an instance out of the area address, system identifier and selector fields.
/// </summary>
/// <param name="areaAddress">
/// The combination of [IDP, HO-DSP] identify both the routing domain and the area within the routing domain.
/// Hence the combination [IDP, HO-DSP] is called the "Area Address".
/// All nodes within the area must have same Area address.
/// </param>
/// <param name="systemIdentifier">System Identifier.</param>
/// <param name="selector">NSAP Selector.</param>
public DnsResourceDataNetworkServiceAccessPoint(DataSegment areaAddress, UInt48 systemIdentifier, byte selector) public DnsResourceDataNetworkServiceAccessPoint(DataSegment areaAddress, UInt48 systemIdentifier, byte selector)
{ {
if (areaAddress == null) if (areaAddress == null)
...@@ -73,10 +83,13 @@ namespace PcapDotNet.Packets.Dns ...@@ -73,10 +83,13 @@ namespace PcapDotNet.Packets.Dns
public UInt48 SystemIdentifier { get; private set; } public UInt48 SystemIdentifier { get; private set; }
/// <summary> /// <summary>
/// NSAP Selector /// NSAP Selector.
/// </summary> /// </summary>
public byte Selector { get; private set; } public byte Selector { get; private set; }
/// <summary>
/// Two DnsResourceDataNetworkServiceAccessPoint are iff their area address, system identifier and selector fields are equal.
/// </summary>
public bool Equals(DnsResourceDataNetworkServiceAccessPoint other) public bool Equals(DnsResourceDataNetworkServiceAccessPoint other)
{ {
return other != null && return other != null &&
...@@ -85,11 +98,17 @@ namespace PcapDotNet.Packets.Dns ...@@ -85,11 +98,17 @@ namespace PcapDotNet.Packets.Dns
Selector.Equals(other.Selector); Selector.Equals(other.Selector);
} }
/// <summary>
/// Two DnsResourceDataNetworkServiceAccessPoint are iff their area address, system identifier and selector fields are equal.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataNetworkServiceAccessPoint); return Equals(obj as DnsResourceDataNetworkServiceAccessPoint);
} }
/// <summary>
/// A hash code of the combination of the area address, system identifier and selector fields.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return Sequence.GetHashCode(AreaAddress, SystemIdentifier, Selector); return Sequence.GetHashCode(AreaAddress, SystemIdentifier, Selector);
......
...@@ -44,6 +44,71 @@ namespace PcapDotNet.Packets.Dns ...@@ -44,6 +44,71 @@ namespace PcapDotNet.Packets.Dns
private const int ConstantPartLength = Offset.SignersName; private const int ConstantPartLength = Offset.SignersName;
/// <summary>
/// Constructs an instance out of the type covered, algorithm, labels, original TTL, signature expiration, signature inception, key tag,
/// signer's name and signature fields.
/// </summary>
/// <param name="typeCovered">The type of the other RRs covered by this SIG.</param>
/// <param name="algorithm">The key algorithm.</param>
/// <param name="labels">
/// An unsigned count of how many labels there are in the original SIG RR owner name not counting the null label for root and not counting any initial "*" for a wildcard.
/// If a secured retrieval is the result of wild card substitution, it is necessary for the resolver to use the original form of the name in verifying the digital signature.
/// This field makes it easy to determine the original form.
///
/// If, on retrieval, the RR appears to have a longer name than indicated by "labels", the resolver can tell it is the result of wildcard substitution.
/// If the RR owner name appears to be shorter than the labels count, the SIG RR must be considered corrupt and ignored.
/// The maximum number of labels allowed in the current DNS is 127 but the entire octet is reserved and would be required should DNS names ever be expanded to 255 labels.
/// </param>
/// <param name="originalTtl">
/// The "original TTL" field is included in the RDATA portion to avoid
/// (1) authentication problems that caching servers would otherwise cause by decrementing the real TTL field and
/// (2) security problems that unscrupulous servers could otherwise cause by manipulating the real TTL field.
/// This original TTL is protected by the signature while the current TTL field is not.
///
/// NOTE: The "original TTL" must be restored into the covered RRs when the signature is verified.
/// This generaly implies that all RRs for a particular type, name, and class, that is, all the RRs in any particular RRset, must have the same TTL to start with.
/// </param>
/// <param name="signatureExpiration">
/// The last time the signature is valid.
/// Numbers of seconds since the start of 1 January 1970, GMT, ignoring leap seconds.
/// Ring arithmetic is used.
/// This time can never be more than about 68 years after the inception.
/// </param>
/// <param name="signatureInception">
/// The first time the signature is valid.
/// Numbers of seconds since the start of 1 January 1970, GMT, ignoring leap seconds.
/// Ring arithmetic is used.
/// This time can never be more than about 68 years before the expiration.
/// </param>
/// <param name="keyTag">
/// Used to efficiently select between multiple keys which may be applicable and thus check that a public key about to be used
/// for the computationally expensive effort to check the signature is possibly valid.
/// For algorithm 1 (MD5/RSA) as defined in RFC 2537,
/// it is the next to the bottom two octets of the public key modulus needed to decode the signature field.
/// That is to say, the most significant 16 of the least significant 24 bits of the modulus in network (big endian) order.
/// For all other algorithms, including private algorithms, it is calculated as a simple checksum of the KEY RR.
/// </param>
/// <param name="signersName">
/// The domain name of the signer generating the SIG RR.
/// This is the owner name of the public KEY RR that can be used to verify the signature.
/// It is frequently the zone which contained the RRset being authenticated.
/// Which signers should be authorized to sign what is a significant resolver policy question.
/// The signer's name may be compressed with standard DNS name compression when being transmitted over the network.
/// </param>
/// <param name="signature">
/// The actual signature portion of the SIG RR binds the other RDATA fields to the RRset of the "type covered" RRs with that owner name and class.
/// This covered RRset is thereby authenticated.
/// To accomplish this, a data sequence is constructed as follows:
///
/// data = RDATA | RR(s)...
///
/// where "|" is concatenation,
///
/// RDATA is the wire format of all the RDATA fields in the SIG RR itself (including the canonical form of the signer's name) before but not including the signature,
/// and RR(s) is the RRset of the RR(s) of the type covered with the same owner name and class as the SIG RR in canonical form and order.
///
/// How this data sequence is processed into the signature is algorithm dependent.
/// </param>
public DnsResourceDataSignature(DnsType typeCovered, DnsAlgorithm algorithm, byte labels, uint originalTtl, SerialNumber32 signatureExpiration, public DnsResourceDataSignature(DnsType typeCovered, DnsAlgorithm algorithm, byte labels, uint originalTtl, SerialNumber32 signatureExpiration,
SerialNumber32 signatureInception, ushort keyTag, DnsDomainName signersName, DataSegment signature) SerialNumber32 signatureInception, ushort keyTag, DnsDomainName signersName, DataSegment signature)
{ {
...@@ -107,8 +172,10 @@ namespace PcapDotNet.Packets.Dns ...@@ -107,8 +172,10 @@ namespace PcapDotNet.Packets.Dns
public SerialNumber32 SignatureInception { get; private set; } public SerialNumber32 SignatureInception { get; private set; }
/// <summary> /// <summary>
/// Used to efficiently select between multiple keys which may be applicable and thus check that a public key about to be used for the computationally expensive effort to check the signature is possibly valid. /// Used to efficiently select between multiple keys which may be applicable and thus check that a public key about to be used
/// For algorithm 1 (MD5/RSA) as defined in RFC 2537, it is the next to the bottom two octets of the public key modulus needed to decode the signature field. /// for the computationally expensive effort to check the signature is possibly valid.
/// For algorithm 1 (MD5/RSA) as defined in RFC 2537,
/// it is the next to the bottom two octets of the public key modulus needed to decode the signature field.
/// That is to say, the most significant 16 of the least significant 24 bits of the modulus in network (big endian) order. /// That is to say, the most significant 16 of the least significant 24 bits of the modulus in network (big endian) order.
/// For all other algorithms, including private algorithms, it is calculated as a simple checksum of the KEY RR. /// For all other algorithms, including private algorithms, it is calculated as a simple checksum of the KEY RR.
/// </summary> /// </summary>
...@@ -139,6 +206,10 @@ namespace PcapDotNet.Packets.Dns ...@@ -139,6 +206,10 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public DataSegment Signature { get; private set; } public DataSegment Signature { get; private set; }
/// <summary>
/// Two DnsResourceDataSignature are equal iff their type covered, algorithm, labels, original TTL, signature expiration, signature inception, key tag,
/// signer's name and signature fields are equal.
/// </summary>
public bool Equals(DnsResourceDataSignature other) public bool Equals(DnsResourceDataSignature other)
{ {
return other != null && return other != null &&
...@@ -153,15 +224,23 @@ namespace PcapDotNet.Packets.Dns ...@@ -153,15 +224,23 @@ namespace PcapDotNet.Packets.Dns
Signature.Equals(other.Signature); Signature.Equals(other.Signature);
} }
public override int GetHashCode() /// <summary>
/// Two DnsResourceDataSignature are equal iff their type covered, algorithm, labels, original TTL, signature expiration, signature inception, key tag,
/// signer's name and signature fields are equal.
/// </summary>
public override bool Equals(object obj)
{ {
return Sequence.GetHashCode(BitSequence.Merge((ushort)TypeCovered, (byte)Algorithm, Labels), OriginalTtl, SignatureExpiration, SignatureInception, return Equals(obj as DnsResourceDataSignature);
KeyTag, SignersName, Signature);
} }
public override bool Equals(object obj) /// <summary>
/// A hash code of the combination of the type covered, algorithm, labels, original TTL, signature expiration, signature inception, key tag,
/// signer's name and signature fields
/// </summary>
public override int GetHashCode()
{ {
return Equals(obj as DnsResourceDataSignature); return Sequence.GetHashCode(BitSequence.Merge((ushort)TypeCovered, (byte)Algorithm, Labels), OriginalTtl, SignatureExpiration, SignatureInception,
KeyTag, SignersName, Signature);
} }
internal DnsResourceDataSignature() internal DnsResourceDataSignature()
......
...@@ -41,6 +41,12 @@ namespace PcapDotNet.Packets.Dns ...@@ -41,6 +41,12 @@ namespace PcapDotNet.Packets.Dns
{ {
} }
/// <summary>
/// Constructs an instance out of the coding, subcoding and data fields.
/// </summary>
/// <param name="coding">Gives the general structure of the data.</param>
/// <param name="subCoding">Provides additional information depending on the value of the coding.</param>
/// <param name="data">Variable length and could be null in some cases.</param>
public DnsResourceDataSink(DnsSinkCoding coding, byte subCoding, DataSegment data) public DnsResourceDataSink(DnsSinkCoding coding, byte subCoding, DataSegment data)
{ {
Coding = coding; Coding = coding;
......
...@@ -41,6 +41,22 @@ namespace PcapDotNet.Packets.Dns ...@@ -41,6 +41,22 @@ namespace PcapDotNet.Packets.Dns
private const int ConstantPartLength = Offset.MinimumTtl + sizeof(uint); private const int ConstantPartLength = Offset.MinimumTtl + sizeof(uint);
/// <summary>
/// Constructs an instance out of the main name server, responsible mailbox, serial, refresh, retry, expire and minimum TTL fields.
/// </summary>
/// <param name="mainNameServer">The domain-name of the name server that was the original or primary source of data for this zone.</param>
/// <param name="responsibleMailbox">A domain-name which specifies the mailbox of the person responsible for this zone.</param>
/// <param name="serial">
/// The unsigned 32 bit version number of the original copy of the zone.
/// Zone transfers preserve this value.
/// This value wraps and should be compared using sequence space arithmetic.
/// </param>
/// <param name="refresh">A 32 bit time interval before the zone should be refreshed.</param>
/// <param name="retry">A 32 bit time interval that should elapse before a failed refresh should be retried.</param>
/// <param name="expire">
/// A 32 bit time value that specifies the upper limit on the time interval that can elapse before the zone is no longer authoritative.
/// </param>
/// <param name="minimumTtl">The unsigned 32 bit minimum TTL field that should be exported with any RR from this zone.</param>
public DnsResourceDataStartOfAuthority(DnsDomainName mainNameServer, DnsDomainName responsibleMailbox, public DnsResourceDataStartOfAuthority(DnsDomainName mainNameServer, DnsDomainName responsibleMailbox,
SerialNumber32 serial, uint refresh, uint retry, uint expire, uint minimumTtl) SerialNumber32 serial, uint refresh, uint retry, uint expire, uint minimumTtl)
{ {
...@@ -90,6 +106,10 @@ namespace PcapDotNet.Packets.Dns ...@@ -90,6 +106,10 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public uint MinimumTtl { get; private set; } public uint MinimumTtl { get; private set; }
/// <summary>
/// Two DnsResourceDataStartOfAuthority are equal iff their main name server, responsible mailbox, serial, refresh, retry, expire
/// and minimum TTL fields are equal.
/// </summary>
public bool Equals(DnsResourceDataStartOfAuthority other) public bool Equals(DnsResourceDataStartOfAuthority other)
{ {
return other != null && return other != null &&
...@@ -102,14 +122,21 @@ namespace PcapDotNet.Packets.Dns ...@@ -102,14 +122,21 @@ namespace PcapDotNet.Packets.Dns
MinimumTtl.Equals(other.MinimumTtl); MinimumTtl.Equals(other.MinimumTtl);
} }
public override int GetHashCode() /// <summary>
/// Two DnsResourceDataStartOfAuthority are equal iff their main name server, responsible mailbox, serial, refresh, retry, expire
/// and minimum TTL fields are equal.
/// </summary>
public override bool Equals(object obj)
{ {
return Sequence.GetHashCode(MainNameServer, ResponsibleMailbox, Serial, Refresh, Retry, Expire, MinimumTtl); return Equals(obj as DnsResourceDataStartOfAuthority);
} }
public override bool Equals(object obj) /// <summary>
/// A hash code based on the main name server, responsible mailbox, serial, refresh, retry, expire and minimum TTL fields
/// </summary>
public override int GetHashCode()
{ {
return Equals(obj as DnsResourceDataStartOfAuthority); return Sequence.GetHashCode(MainNameServer, ResponsibleMailbox, Serial, Refresh, Retry, Expire, MinimumTtl);
} }
internal DnsResourceDataStartOfAuthority() internal DnsResourceDataStartOfAuthority()
......
...@@ -44,6 +44,46 @@ namespace PcapDotNet.Packets.Dns ...@@ -44,6 +44,46 @@ namespace PcapDotNet.Packets.Dns
private const int ConstantPartLength = OffsetAfterAlgorithm.KeyData + sizeof(ushort); private const int ConstantPartLength = OffsetAfterAlgorithm.KeyData + sizeof(ushort);
/// <summary>
/// Constructs an instance out of the algorithm, inception, expiration, mode, error, key and other fields.
/// </summary>
/// <param name="algorithm">
/// Name of the algorithm in domain name syntax.
/// The algorithm determines how the secret keying material agreed to using the TKEY RR is actually used to derive the algorithm specific key.
/// </param>
/// <param name="inception">
/// Number of seconds since the beginning of 1 January 1970 GMT ignoring leap seconds treated as modulo 2**32 using ring arithmetic.
/// In messages between a DNS resolver and a DNS server where this field is meaningful,
/// it is either the requested validity interval start for the keying material asked for or
/// specify the validity interval start of keying material provided.
///
/// To avoid different interpretations of the inception time in TKEY RRs,
/// resolvers and servers exchanging them must have the same idea of what time it is.
/// One way of doing this is with the NTP protocol [RFC 2030] but that or any other time synchronization used for this purpose must be done securely.
/// </param>
/// <param name="expiration">
/// Number of seconds since the beginning of 1 January 1970 GMT ignoring leap seconds treated as modulo 2**32 using ring arithmetic.
/// In messages between a DNS resolver and a DNS server where this field is meaningful,
/// it is either the requested validity interval end for the keying material asked for or
/// specify the validity interval end of keying material provided.
///
/// To avoid different interpretations of the expiration time in TKEY RRs,
/// resolvers and servers exchanging them must have the same idea of what time it is.
/// One way of doing this is with the NTP protocol [RFC 2030] but that or any other time synchronization used for this purpose must be done securely.
/// </param>
/// <param name="mode">
/// Specifies the general scheme for key agreement or the purpose of the TKEY DNS message.
/// Servers and resolvers supporting this specification must implement the Diffie-Hellman key agreement mode and the key deletion mode for queries.
/// All other modes are optional.
/// A server supporting TKEY that receives a TKEY request with a mode it does not support returns the BADMODE error.
/// </param>
/// <param name="error">
/// When the TKEY Error Field is non-zero in a response to a TKEY query, the DNS header RCODE field indicates no error.
/// However, it is possible if a TKEY is spontaneously included in a response the TKEY RR and DNS header error field
/// could have unrelated non-zero error codes.
/// </param>
/// <param name="key">The key exchange data. The meaning of this data depends on the mode.</param>
/// <param name="other">May be used in future extensions.</param>
public DnsResourceDataTransactionKey(DnsDomainName algorithm, SerialNumber32 inception, SerialNumber32 expiration, DnsTransactionKeyMode mode, public DnsResourceDataTransactionKey(DnsDomainName algorithm, SerialNumber32 inception, SerialNumber32 expiration, DnsTransactionKeyMode mode,
DnsResponseCode error, DataSegment key, DataSegment other) DnsResponseCode error, DataSegment key, DataSegment other)
{ {
...@@ -108,7 +148,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -108,7 +148,8 @@ namespace PcapDotNet.Packets.Dns
/// <summary> /// <summary>
/// When the TKEY Error Field is non-zero in a response to a TKEY query, the DNS header RCODE field indicates no error. /// When the TKEY Error Field is non-zero in a response to a TKEY query, the DNS header RCODE field indicates no error.
/// However, it is possible if a TKEY is spontaneously included in a response the TKEY RR and DNS header error field could have unrelated non-zero error codes. /// However, it is possible if a TKEY is spontaneously included in a response the TKEY RR and DNS header error field
/// could have unrelated non-zero error codes.
/// </summary> /// </summary>
public DnsResponseCode Error { get; private set; } public DnsResponseCode Error { get; private set; }
...@@ -123,6 +164,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -123,6 +164,9 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public DataSegment Other { get; private set; } public DataSegment Other { get; private set; }
/// <summary>
/// Two DnsResourceDataTransactionKey are equal iff their algorithm, inception, expiration, mode, error, key and other fields are equal.
/// </summary>
public bool Equals(DnsResourceDataTransactionKey other) public bool Equals(DnsResourceDataTransactionKey other)
{ {
return other != null && return other != null &&
...@@ -135,11 +179,17 @@ namespace PcapDotNet.Packets.Dns ...@@ -135,11 +179,17 @@ namespace PcapDotNet.Packets.Dns
Other.Equals(other.Other); Other.Equals(other.Other);
} }
/// <summary>
/// Two DnsResourceDataTransactionKey are equal iff their algorithm, inception, expiration, mode, error, key and other fields are equal.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataTransactionKey); return Equals(obj as DnsResourceDataTransactionKey);
} }
/// <summary>
/// A hash code of the combination of the algorithm, inception, expiration, mode, error, key and other fields.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return Sequence.GetHashCode(Algorithm, Inception, Expiration, BitSequence.Merge((ushort)Mode, (ushort)Error), Key, Other); return Sequence.GetHashCode(Algorithm, Inception, Expiration, BitSequence.Merge((ushort)Mode, (ushort)Error), Key, Other);
......
...@@ -47,6 +47,16 @@ namespace PcapDotNet.Packets.Dns ...@@ -47,6 +47,16 @@ namespace PcapDotNet.Packets.Dns
private const int ConstantPartLength = OffsetAfterAlgorithm.MessageAuthenticationCode + OffsetAfterMessageAuthenticationCode.OtherData; private const int ConstantPartLength = OffsetAfterAlgorithm.MessageAuthenticationCode + OffsetAfterMessageAuthenticationCode.OtherData;
/// <summary>
/// Constructs an instance out of the algorithm time signed, fudge, message authentication code, original ID, error and other fields.
/// </summary>
/// <param name="algorithm">Name of the algorithm in domain name syntax.</param>
/// <param name="timeSigned">Seconds since 1-Jan-70 UTC.</param>
/// <param name="fudge">Seconds of error permitted in Time Signed.</param>
/// <param name="messageAuthenticationCode">Defined by Algorithm Name.</param>
/// <param name="originalId">Original message ID.</param>
/// <param name="error">RCODE covering TSIG processing.</param>
/// <param name="other">Empty unless Error == BADTIME.</param>
public DnsResourceDataTransactionSignature(DnsDomainName algorithm, UInt48 timeSigned, ushort fudge, DataSegment messageAuthenticationCode, public DnsResourceDataTransactionSignature(DnsDomainName algorithm, UInt48 timeSigned, ushort fudge, DataSegment messageAuthenticationCode,
ushort originalId, DnsResponseCode error, DataSegment other) ushort originalId, DnsResponseCode error, DataSegment other)
{ {
...@@ -106,6 +116,10 @@ namespace PcapDotNet.Packets.Dns ...@@ -106,6 +116,10 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public DataSegment Other { get; private set; } public DataSegment Other { get; private set; }
/// <summary>
/// Two DnsResourceDataTransactionSignature are equal iff their algorithm time signed, fudge, message authentication code, original ID, error
/// and other fields are equal.
/// </summary>
public bool Equals(DnsResourceDataTransactionSignature other) public bool Equals(DnsResourceDataTransactionSignature other)
{ {
return other != null && return other != null &&
...@@ -118,11 +132,18 @@ namespace PcapDotNet.Packets.Dns ...@@ -118,11 +132,18 @@ namespace PcapDotNet.Packets.Dns
Other.Equals(other.Other); Other.Equals(other.Other);
} }
/// <summary>
/// Two DnsResourceDataTransactionSignature are equal iff their algorithm time signed, fudge, message authentication code, original ID, error
/// and other fields are equal.
/// </summary>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return Equals(obj as DnsResourceDataTransactionSignature); return Equals(obj as DnsResourceDataTransactionSignature);
} }
/// <summary>
/// A hash code of the combination of the algorithm time signed, fudge, message authentication code, original ID, error and other fields.
/// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return Sequence.GetHashCode(Algorithm, TimeSigned, BitSequence.Merge(Fudge, OriginalId), MessageAuthenticationCode, Error, Other); return Sequence.GetHashCode(Algorithm, TimeSigned, BitSequence.Merge(Fudge, OriginalId), MessageAuthenticationCode, Error, Other);
......
...@@ -106,6 +106,10 @@ namespace PcapDotNet.Packets.Transport ...@@ -106,6 +106,10 @@ namespace PcapDotNet.Packets.Transport
get { return Math.Min(HeaderLength, Length); } get { return Math.Min(HeaderLength, Length); }
} }
/// <summary>
/// Reserved for future use.
/// Must be zero.
/// </summary>
public byte Reserved public byte Reserved
{ {
get { return (byte)((this[Offset.HeaderLengthAndFlags] & Mask.Reserved) >> Shift.Reserved); } get { return (byte)((this[Offset.HeaderLengthAndFlags] & Mask.Reserved) >> Shift.Reserved); }
......
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