Commit e8a62a93 authored by Brickner_cp's avatar Brickner_cp

Warnings, Code Analysis and Documentation. 544 warnings left.

parent bb3f755e
using System;
namespace PcapDotNet.Base namespace PcapDotNet.Base
{ {
public static class BitSequence public static class BitSequence
...@@ -17,26 +19,31 @@ namespace PcapDotNet.Base ...@@ -17,26 +19,31 @@ namespace PcapDotNet.Base
return (byte)((Merge(value1, value2) << 1) | value3.ToByte()); return (byte)((Merge(value1, value2) << 1) | value3.ToByte());
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1025:ReplaceRepetitiveArgumentsWithParamsArray")]
public static byte Merge(bool value1, bool value2, bool value3, bool value4) public static byte Merge(bool value1, bool value2, bool value3, bool value4)
{ {
return (byte)((Merge(value1, value2, value3) << 1) | value4.ToByte()); return (byte)((Merge(value1, value2, value3) << 1) | value4.ToByte());
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1025:ReplaceRepetitiveArgumentsWithParamsArray")]
public static byte Merge(bool value1, bool value2, bool value3, bool value4, bool value5) public static byte Merge(bool value1, bool value2, bool value3, bool value4, bool value5)
{ {
return (byte)((Merge(value1, value2, value3, value4) << 1) | value5.ToByte()); return (byte)((Merge(value1, value2, value3, value4) << 1) | value5.ToByte());
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1025:ReplaceRepetitiveArgumentsWithParamsArray")]
public static byte Merge(bool value1, bool value2, bool value3, bool value4, bool value5, bool value6) public static byte Merge(bool value1, bool value2, bool value3, bool value4, bool value5, bool value6)
{ {
return (byte)((Merge(value1, value2, value3, value4, value5) << 1) | value6.ToByte()); return (byte)((Merge(value1, value2, value3, value4, value5) << 1) | value6.ToByte());
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1025:ReplaceRepetitiveArgumentsWithParamsArray")]
public static byte Merge(bool value1, bool value2, bool value3, bool value4, bool value5, bool value6, bool value7) public static byte Merge(bool value1, bool value2, bool value3, bool value4, bool value5, bool value6, bool value7)
{ {
return (byte)((Merge(value1, value2, value3, value4, value5, value6) << 1) | value7.ToByte()); return (byte)((Merge(value1, value2, value3, value4, value5, value6) << 1) | value7.ToByte());
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1025:ReplaceRepetitiveArgumentsWithParamsArray")]
public static byte Merge(bool value1, bool value2, bool value3, bool value4, bool value5, bool value6, bool value7, bool value8) public static byte Merge(bool value1, bool value2, bool value3, bool value4, bool value5, bool value6, bool value7, bool value8)
{ {
return (byte)((Merge(value1, value2, value3, value4, value5, value6, value7) << 1) | value8.ToByte()); return (byte)((Merge(value1, value2, value3, value4, value5, value6, value7) << 1) | value8.ToByte());
...@@ -52,16 +59,19 @@ namespace PcapDotNet.Base ...@@ -52,16 +59,19 @@ namespace PcapDotNet.Base
return (UInt24)Merge(0, value1, value2, value3); return (UInt24)Merge(0, value1, value2, value3);
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1025:ReplaceRepetitiveArgumentsWithParamsArray")]
public static uint Merge(byte value1, byte value2, byte value3, byte value4) public static uint Merge(byte value1, byte value2, byte value3, byte value4)
{ {
return Merge(Merge(value1, value2), Merge(value3, value4)); return Merge(Merge(value1, value2), Merge(value3, value4));
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1025:ReplaceRepetitiveArgumentsWithParamsArray")]
public static UInt48 Merge(byte value1, byte value2, byte value3, byte value4, byte value5, byte value6) public static UInt48 Merge(byte value1, byte value2, byte value3, byte value4, byte value5, byte value6)
{ {
return (UInt48)Merge(0, 0, value1, value2, value3, value4, value5, value6); return (UInt48)Merge(0, 0, value1, value2, value3, value4, value5, value6);
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1025:ReplaceRepetitiveArgumentsWithParamsArray")]
public static ulong Merge(byte value1, byte value2, byte value3, byte value4, byte value5, byte value6, byte value7, byte value8) public static ulong Merge(byte value1, byte value2, byte value3, byte value4, byte value5, byte value6, byte value7, byte value8)
{ {
return Merge(Merge(value1, value2, value3, value4), Merge(value5, value6, value7, value8)); return Merge(Merge(value1, value2, value3, value4), Merge(value5, value6, value7, value8));
......
using System; using System;
using System.Globalization;
namespace PcapDotNet.Base namespace PcapDotNet.Base
{ {
...@@ -19,14 +20,14 @@ namespace PcapDotNet.Base ...@@ -19,14 +20,14 @@ namespace PcapDotNet.Base
if (value > MaxValue) if (value > MaxValue)
{ {
throw new ArgumentOutOfRangeException("value", value, throw new ArgumentOutOfRangeException("value", value,
string.Format("Value cannot be bigger than {0}", MaxValue)); string.Format(CultureInfo.InvariantCulture, "Value cannot be bigger than {0}", MaxValue));
} }
const long MinValue = long.MinValue / TimeSpanExtensions.TicksPerMicrosecond; const long MinValue = long.MinValue / TimeSpanExtensions.TicksPerMicrosecond;
if (value < MinValue) if (value < MinValue)
{ {
throw new ArgumentOutOfRangeException("value", value, throw new ArgumentOutOfRangeException("value", value,
string.Format("Value cannot be smaller than {0}", MinValue)); string.Format(CultureInfo.InvariantCulture, "Value cannot be smaller than {0}", MinValue));
} }
long roundedValue = (long)Math.Round(value); long roundedValue = (long)Math.Round(value);
......
...@@ -235,6 +235,9 @@ namespace PcapDotNet.Base ...@@ -235,6 +235,9 @@ namespace PcapDotNet.Base
public static bool IsStrictOrdered<T, TKey>(this IEnumerable<T> sequence, Func<T, TKey> keySelector, IComparer<TKey> comparer) public static bool IsStrictOrdered<T, TKey>(this IEnumerable<T> sequence, Func<T, TKey> keySelector, IComparer<TKey> comparer)
{ {
if (comparer == null)
throw new ArgumentNullException("comparer");
if (!sequence.Any()) if (!sequence.Any())
return true; return true;
......
using System;
namespace PcapDotNet.Base namespace PcapDotNet.Base
{ {
public static class Sequence public static class Sequence
{ {
public static int GetHashCode(object value1, object value2) public static int GetHashCode(object value1, object value2)
{ {
if (value1 == null)
throw new ArgumentNullException("value1");
if (value2 == null)
throw new ArgumentNullException("value2");
return value1.GetHashCode() ^ value2.GetHashCode(); return value1.GetHashCode() ^ value2.GetHashCode();
} }
public static int GetHashCode(object value1, object value2, object value3) public static int GetHashCode(object value1, object value2, object value3)
{ {
return GetHashCode(value1, value2) ^ value3.GetHashCode(); if (value3 == null)
} throw new ArgumentNullException("value3");
public static int GetHashCode(object value1, object value2, object value3, object value4) return GetHashCode(value1, value2) ^ value3.GetHashCode();
{
return GetHashCode(value1, value2, value3) ^ value4.GetHashCode();
} }
public static int GetHashCode(object value1, object value2, object value3, object value4, object value5) public static int GetHashCode(params object[] values)
{ {
return GetHashCode(value1, value2, value3, value4) ^ value5.GetHashCode(); if (values == null)
} throw new ArgumentNullException("values");
public static int GetHashCode(object value1, object value2, object value3, object value4, object value5, object value6) int result = 0;
{ for (int i = 0; i != values.Length; ++i)
return GetHashCode(value1, value2, value3, value4, value5) ^ value6.GetHashCode(); result ^= values[i].GetHashCode();
}
public static int GetHashCode(object value1, object value2, object value3, object value4, object value5, object value6, object value7) return result;
{
return GetHashCode(value1, value2, value3, value4, value5, value6) ^ value7.GetHashCode();
} }
} }
} }
\ No newline at end of file
using System; using System;
using System.Globalization;
namespace PcapDotNet.Base namespace PcapDotNet.Base
{ {
...@@ -18,7 +19,8 @@ namespace PcapDotNet.Base ...@@ -18,7 +19,8 @@ namespace PcapDotNet.Base
public SerialNumber32 Add(uint value) public SerialNumber32 Add(uint value)
{ {
if (value > MaxAdditiveNumber) if (value > MaxAdditiveNumber)
throw new ArgumentOutOfRangeException("value", value, string.Format("Cannot add a number bigger than {0}", MaxAdditiveNumber)); throw new ArgumentOutOfRangeException("value", value,
string.Format(CultureInfo.InvariantCulture, "Cannot add a number bigger than {0}", MaxAdditiveNumber));
return _value + value; return _value + value;
} }
...@@ -51,7 +53,12 @@ namespace PcapDotNet.Base ...@@ -51,7 +53,12 @@ namespace PcapDotNet.Base
public override string ToString() public override string ToString()
{ {
return Value.ToString(); return ToString(CultureInfo.InvariantCulture);
}
public string ToString(IFormatProvider provider)
{
return Value.ToString(provider);
} }
public static implicit operator SerialNumber32(uint value) public static implicit operator SerialNumber32(uint value)
...@@ -59,6 +66,26 @@ namespace PcapDotNet.Base ...@@ -59,6 +66,26 @@ namespace PcapDotNet.Base
return new SerialNumber32(value); return new SerialNumber32(value);
} }
public static bool operator ==(SerialNumber32 value1, SerialNumber32 value2)
{
return value1.Equals(value2);
}
public static bool operator !=(SerialNumber32 value1, SerialNumber32 value2)
{
return !(value1 == value2);
}
public static bool operator <(SerialNumber32 value1, SerialNumber32 value2)
{
return value1.CompareTo(value2) < 0;
}
public static bool operator >(SerialNumber32 value1, SerialNumber32 value2)
{
return value1.CompareTo(value2) > 0;
}
private readonly uint _value; private readonly uint _value;
} }
} }
\ No newline at end of file
...@@ -16,12 +16,4 @@ namespace PcapDotNet.Base ...@@ -16,12 +16,4 @@ namespace PcapDotNet.Base
return (IEnumerable<T>)Enum.GetValues(type); return (IEnumerable<T>)Enum.GetValues(type);
} }
} }
public static class ObjectExtensions
{
public static bool IsDefinedEnumValue<T>(this Object enumValue)
{
return Enum.IsDefined(typeof(T), enumValue);
}
}
} }
\ No newline at end of file
...@@ -500,10 +500,10 @@ namespace PcapDotNet.Base ...@@ -500,10 +500,10 @@ namespace PcapDotNet.Base
public static UInt128 operator -(UInt128 value1, UInt128 value2) public static UInt128 operator -(UInt128 value1, UInt128 value2)
{ {
return Substract(value1, value2); return Subtract(value1, value2);
} }
public static UInt128 Substract(UInt128 value1, UInt128 value2) public static UInt128 Subtract(UInt128 value1, UInt128 value2)
{ {
ulong leastSignificant = value1._leastSignificant - value2._leastSignificant; ulong leastSignificant = value1._leastSignificant - value2._leastSignificant;
bool overflow = (leastSignificant > value1._leastSignificant); bool overflow = (leastSignificant > value1._leastSignificant);
......
...@@ -556,7 +556,12 @@ namespace PcapDotNet.Base ...@@ -556,7 +556,12 @@ namespace PcapDotNet.Base
public string ToString(string format) public string ToString(string format)
{ {
return ((long)this).ToString(format); return ToString(format, CultureInfo.InvariantCulture);
}
public string ToString(string format, IFormatProvider provider)
{
return ((long)this).ToString(format, provider);
} }
private UInt48(long value) private UInt48(long value)
......
...@@ -5,12 +5,18 @@ ...@@ -5,12 +5,18 @@
<!--Word>cb</Word--> <!--Word>cb</Word-->
</Unrecognized> </Unrecognized>
<Recognized> <Recognized>
<Word>aaaa</Word>
<Word>ack</Word> <Word>ack</Word>
<Word>additionals</Word>
<Word>afi</Word>
<Word>afs</Word>
<Word>aris</Word> <Word>aris</Word>
<Word>arp</Word> <Word>arp</Word>
<Word>asn</Word>
<Word>autonet</Word> <Word>autonet</Word>
<Word>avb</Word> <Word>avb</Word>
<Word>ax</Word> <Word>ax</Word>
<Word>axfr</Word>
<Word>bbn</Word> <!-- Probably BBN Technologies (originally Bolt, Beranek and Newman) --> <Word>bbn</Word> <!-- Probably BBN Technologies (originally Bolt, Beranek and Newman) -->
<Word>cbt</Word> <Word>cbt</Word>
<Word>ccitt</Word> <Word>ccitt</Word>
...@@ -20,6 +26,7 @@ ...@@ -20,6 +26,7 @@
<Word>datakit</Word> <Word>datakit</Word>
<Word>dcn</Word> <Word>dcn</Word>
<Word>docsis</Word> <Word>docsis</Word>
<Word>dss</Word>
<Word>emcon</Word> <Word>emcon</Word>
<Word>endianity</Word> <Word>endianity</Word>
<Word>enqueueing</Word> <Word>enqueueing</Word>
...@@ -28,7 +35,10 @@ ...@@ -28,7 +35,10 @@
<Word>fibre</Word> <Word>fibre</Word>
<Word>firefox</Word> <Word>firefox</Word>
<Word>genser</Word> <Word>genser</Word>
<Word>gid</Word>
<Word>gmtp</Word> <Word>gmtp</Word>
<Word>gost</Word>
<Word>gss</Word>
<Word>hiparp</Word> <Word>hiparp</Word>
<Word>iclfxbm</Word> <Word>iclfxbm</Word>
<Word>icmp</Word> <Word>icmp</Word>
...@@ -36,11 +46,14 @@ ...@@ -36,11 +46,14 @@
<Word>infini</Word> <Word>infini</Word>
<Word>internetwork</Word> <Word>internetwork</Word>
<Word>internodal</Word> <Word>internodal</Word>
<Word>ipgp</Word>
<Word>iplt</Word> <Word>iplt</Word>
<Word>ipsilon</Word> <!-- As in Ipsilon Networks --> <Word>ipsilon</Word> <!-- As in Ipsilon Networks -->
<Word>ipx</Word> <Word>ipx</Word>
<Word>ixfr</Word>
<Word>kryptolan</Word> <Word>kryptolan</Word>
<Word>lite</Word> <Word>lite</Word>
<Word>llq</Word>
<Word>md</Word> <Word>md</Word>
<Word>metricom</Word> <Word>metricom</Word>
<Word>multimegabit</Word> <Word>multimegabit</Word>
...@@ -49,22 +62,30 @@ ...@@ -49,22 +62,30 @@
<Word>nsa</Word> <Word>nsa</Word>
<Word>osi</Word> <Word>osi</Word>
<Word>pcap</Word> <Word>pcap</Word>
<Word>pgp</Word>
<Word>pkix</Word>
<Word>prespecified</Word> <Word>prespecified</Word>
<Word>proteon</Word> <Word>proteon</Word>
<Word>qnx</Word> <!-- www.qnx.com --> <Word>qnx</Word> <!-- www.qnx.com -->
<Word>rcc</Word> <Word>rcc</Word>
<Word>rpcap</Word> <Word>rpcap</Word>
<Word>satnet</Word> <Word>satnet</Word>
<Word>sha</Word>
<Word>sitara</Word> <Word>sitara</Word>
<Word>sna</Word> <Word>sna</Word>
<Word>ssh</Word>
<Word>tcf</Word> <Word>tcf</Word>
<Word>tcn</Word> <Word>tcn</Word>
<Word>ttl</Word> <Word>ttl</Word>
<Word>ttp</Word> <Word>ttp</Word>
<Word>twinaxial</Word> <Word>twinaxial</Word>
<Word>uid</Word>
<Word>unicast</Word> <Word>unicast</Word>
<Word>uti</Word> <Word>uti</Word>
<Word>vpn</Word>
<Word>wiegand</Word> <Word>wiegand</Word>
<Word>xtp</Word>
<Word>yx</Word> <!--Yet exists?-->
</Recognized> </Recognized>
<Deprecated> <Deprecated>
<!--Term PreferredAlternate="EnterpriseServices">complus</Term--> <!--Term PreferredAlternate="EnterpriseServices">complus</Term-->
...@@ -79,6 +100,7 @@ ...@@ -79,6 +100,7 @@
<Acronyms> <Acronyms>
<CasingExceptions> <CasingExceptions>
<Acronym>Ip</Acronym> <Acronym>Ip</Acronym>
<Acronym>Iv</Acronym>
<Acronym>Ms</Acronym> <Acronym>Ms</Acronym>
<Acronym>Nd</Acronym> <Acronym>Nd</Acronym>
<Acronym>Ns</Acronym> <Acronym>Ns</Acronym>
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
/// </summary> /// </summary>
public enum AddressFamily : ushort public enum AddressFamily : ushort
{ {
None = 0,
/// <summary> /// <summary>
/// IP (IP version 4). /// IP (IP version 4).
/// </summary> /// </summary>
...@@ -16,14 +18,14 @@ ...@@ -16,14 +18,14 @@
IpV6 = 2, IpV6 = 2,
/// <summary> /// <summary>
/// Network Service Access Point. /// NSAP - Network Service Access Point.
/// </summary> /// </summary>
Nsap = 3, NetworkServiceAccessPoint = 3,
/// <summary> /// <summary>
/// High-Level Data Link (8-bit multidrop). /// High-Level Data Link (8-bit multidrop).
/// </summary> /// </summary>
Hdlc = 4, HighLevelDataLink = 4,
/// <summary> /// <summary>
/// BBN Report 1822. /// BBN Report 1822.
...@@ -68,7 +70,7 @@ ...@@ -68,7 +70,7 @@
/// <summary> /// <summary>
/// Decnet IV. /// Decnet IV.
/// </summary> /// </summary>
DecnetIv = 13, DecNetIv = 13,
/// <summary> /// <summary>
/// Banyan Vines. /// Banyan Vines.
...@@ -80,7 +82,7 @@ ...@@ -80,7 +82,7 @@
/// ATM Forum UNI 3.1. October 1995. /// ATM Forum UNI 3.1. October 1995.
/// Andy Malis. /// Andy Malis.
/// </summary> /// </summary>
E164WithNsapFormatSubaddresses = 15, E164WithNetworkServiceAccessPointFormatSubaddresses = 15,
/// <summary> /// <summary>
/// DNS (Domain Name System). /// DNS (Domain Name System).
...@@ -121,19 +123,19 @@ ...@@ -121,19 +123,19 @@
/// Fibre Channel World-Wide Port Name. /// Fibre Channel World-Wide Port Name.
/// Mark Bakke. /// Mark Bakke.
/// </summary> /// </summary>
FibreChannelWorldWidePortName = 22, FibreChannelWorldwidePortName = 22,
/// <summary> /// <summary>
/// Fibre Channel World-Wide Node Name. /// Fibre Channel World-Wide Node Name.
/// Mark Bakke. /// Mark Bakke.
/// </summary> /// </summary>
FibreChannelWorldWideNodeName = 23, FibreChannelWorldwideNodeName = 23,
/// <summary> /// <summary>
/// GWID. /// GWID.
/// Subra Hegde. /// Subra Hegde.
/// </summary> /// </summary>
Gwis = 24, Gwid = 24,
/// <summary> /// <summary>
/// RFCs 4761, 6074. /// RFCs 4761, 6074.
...@@ -145,19 +147,19 @@ ...@@ -145,19 +147,19 @@
/// EIGRP Common Service Family. /// EIGRP Common Service Family.
/// Donnie Savage. /// Donnie Savage.
/// </summary> /// </summary>
EigrpCommonServiceFamily = 16384, EnhancedInteriorGatewayRoutingProtocolCommonServiceFamily = 16384,
/// <summary> /// <summary>
/// EIGRP IPv4 Service Family. /// EIGRP IPv4 Service Family.
/// Donnie Savage. /// Donnie Savage.
/// </summary> /// </summary>
EigrpIpV4ServiceFamily = 16385, EnhancedInteriorGatewayRoutingProtocolIpV4ServiceFamily = 16385,
/// <summary> /// <summary>
/// EIGRP IPv6 Service Family. /// EIGRP IPv6 Service Family.
/// Donnie Savage. /// Donnie Savage.
/// </summary> /// </summary>
EigrpIpV6ServiceFamily = 16386, EnhancedInteriorGatewayRoutingProtocolIpV6ServiceFamily = 16386,
/// <summary> /// <summary>
/// LISP Canonical Address Format (LCAF). /// LISP Canonical Address Format (LCAF).
......
...@@ -350,6 +350,9 @@ namespace PcapDotNet.Packets ...@@ -350,6 +350,9 @@ namespace PcapDotNet.Packets
public static BigInteger ReadUnsignedBigInteger(this byte[] buffer, int offset, int length, Endianity endianity) public static BigInteger ReadUnsignedBigInteger(this byte[] buffer, int offset, int length, Endianity endianity)
{ {
if (buffer == null)
throw new ArgumentNullException("buffer");
BigInteger value = BigInteger.Zero; BigInteger value = BigInteger.Zero;
for (int i = 0; i != length; ++i) for (int i = 0; i != length; ++i)
{ {
...@@ -662,6 +665,9 @@ namespace PcapDotNet.Packets ...@@ -662,6 +665,9 @@ namespace PcapDotNet.Packets
public static void WriteUnsigned(this byte[] buffer, int offset, BigInteger value, int length, Endianity endianity) public static void WriteUnsigned(this byte[] buffer, int offset, BigInteger value, int length, Endianity endianity)
{ {
if (buffer == null)
throw new ArgumentNullException("buffer");
if (value.Sign < 0) if (value.Sign < 0)
throw new ArgumentOutOfRangeException("value", value, "Must be non-negative."); throw new ArgumentOutOfRangeException("value", value, "Must be non-negative.");
for (int i = 0; i != length && value != BigInteger.Zero; ++i, value >>= 8) for (int i = 0; i != length && value != BigInteger.Zero; ++i, value >>= 8)
......
...@@ -57,9 +57,9 @@ namespace PcapDotNet.Packets ...@@ -57,9 +57,9 @@ namespace PcapDotNet.Packets
public byte Last { get { return this[Length - 1]; } } public byte Last { get { return this[Length - 1]; } }
public DataSegment SubSegment(int offset, int length) public DataSegment Subsegment(int offset, int length)
{ {
return SubSegment(ref offset, length); return Subsegment(ref offset, length);
} }
/// <summary> /// <summary>
...@@ -175,7 +175,7 @@ namespace PcapDotNet.Packets ...@@ -175,7 +175,7 @@ namespace PcapDotNet.Packets
return Buffer.ReadBytes(StartOffset + offset, length); return Buffer.ReadBytes(StartOffset + offset, length);
} }
internal DataSegment SubSegment(ref int offset, int length) internal DataSegment Subsegment(ref int offset, int length)
{ {
DataSegment subSegemnt = new DataSegment(Buffer, StartOffset + offset, length); DataSegment subSegemnt = new DataSegment(Buffer, StartOffset + offset, length);
offset += length; offset += length;
......
...@@ -7,23 +7,25 @@ ...@@ -7,23 +7,25 @@
/// </summary> /// </summary>
public enum DnsClass : ushort public enum DnsClass : ushort
{ {
None = 0,
/// <summary> /// <summary>
/// RFC 1035. /// RFC 1035.
/// Internet. /// IN - Internet.
/// </summary> /// </summary>
In = 1, Internet = 1,
/// <summary> /// <summary>
/// Moon 1981 1035. /// Moon 1981 1035.
/// The CHAOS class. /// The CHAOS class.
/// </summary> /// </summary>
Ch = 3, Chaos = 3,
/// <summary> /// <summary>
/// Dyer 87. /// Dyer 87.
/// Hesiod. /// HS - Hesiod.
/// </summary> /// </summary>
Hs = 4, Hesiod = 4,
/// <summary> /// <summary>
/// RFC 2136. /// RFC 2136.
......
...@@ -41,6 +41,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -41,6 +41,7 @@ namespace PcapDotNet.Packets.Dns
return base.ToString() + " " + Ttl + " " + Data; return base.ToString() + " " + Ttl + " " + Data;
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
public bool Equals(DnsDataResourceRecord other) public bool Equals(DnsDataResourceRecord other)
{ {
return EqualsBase(other) && return EqualsBase(other) &&
......
...@@ -50,7 +50,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -50,7 +50,7 @@ namespace PcapDotNet.Packets.Dns
{ {
public const int Id = 0; public const int Id = 0;
public const int IsResponse = 2; public const int IsResponse = 2;
public const int Opcode = 2; public const int OpCode = 2;
public const int IsAuthoritiveAnswer = 2; public const int IsAuthoritiveAnswer = 2;
public const int IsTruncated = 2; public const int IsTruncated = 2;
public const int IsRecusionDesired = 2; public const int IsRecusionDesired = 2;
...@@ -69,11 +69,11 @@ namespace PcapDotNet.Packets.Dns ...@@ -69,11 +69,11 @@ namespace PcapDotNet.Packets.Dns
private static class Mask private static class Mask
{ {
public const byte IsResponse = 0x80; public const byte IsResponse = 0x80;
public const byte Opcode = 0x78; public const byte OpCode = 0x78;
public const byte IsAuthoritiveAnswer = 0x04; public const byte IsAuthoritiveAnswer = 0x04;
public const byte IsTruncated = 0x02; public const byte IsTruncated = 0x02;
public const byte IsRecusionDesired = 0x01; public const byte IsRecusionDesired = 0x01;
public const byte IsRecusionAvailable = 0x80; public const byte IsRecursionAvailable = 0x80;
public const byte FutureUse = 0x40; public const byte FutureUse = 0x40;
public const byte IsAuthenticData = 0x20; public const byte IsAuthenticData = 0x20;
public const byte IsCheckingDisabled = 0x10; public const byte IsCheckingDisabled = 0x10;
...@@ -82,7 +82,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -82,7 +82,7 @@ namespace PcapDotNet.Packets.Dns
private static class Shift private static class Shift
{ {
public const int Opcode = 3; public const int OpCode = 3;
} }
/// <summary> /// <summary>
...@@ -119,9 +119,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -119,9 +119,9 @@ namespace PcapDotNet.Packets.Dns
/// Specifies kind of query in this message. /// Specifies kind of query in this message.
/// This value is set by the originator of a query and copied into the response. /// This value is set by the originator of a query and copied into the response.
/// </summary> /// </summary>
public DnsOpcode Opcode public DnsOpCode OpCode
{ {
get { return (DnsOpcode)((this[Offset.Opcode] & Mask.Opcode) >> Shift.Opcode); } get { return (DnsOpCode)((this[Offset.OpCode] & Mask.OpCode) >> Shift.OpCode); }
} }
/// <summary> /// <summary>
...@@ -129,7 +129,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -129,7 +129,7 @@ namespace PcapDotNet.Packets.Dns
/// Note that the contents of the answer section may have multiple owner names because of aliases. /// Note that the contents of the answer section may have multiple owner names because of aliases.
/// The AA bit corresponds to the name which matches the query name, or the first owner name in the answer section. /// The AA bit corresponds to the name which matches the query name, or the first owner name in the answer section.
/// </summary> /// </summary>
public bool IsAuthoritiveAnswer public bool IsAuthoritativeAnswer
{ {
get { return ReadBool(Offset.IsAuthoritiveAnswer, Mask.IsAuthoritiveAnswer); } get { return ReadBool(Offset.IsAuthoritiveAnswer, Mask.IsAuthoritiveAnswer); }
} }
...@@ -155,9 +155,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -155,9 +155,9 @@ namespace PcapDotNet.Packets.Dns
/// <summary> /// <summary>
/// This be is set or cleared in a response, and denotes whether recursive query support is available in the name server. /// This be is set or cleared in a response, and denotes whether recursive query support is available in the name server.
/// </summary> /// </summary>
public bool IsRecusionAvailable public bool IsRecursionAvailable
{ {
get { return ReadBool(Offset.IsRecusionAvailable, Mask.IsRecusionAvailable); } get { return ReadBool(Offset.IsRecusionAvailable, Mask.IsRecursionAvailable); }
} }
/// <summary> /// <summary>
...@@ -319,11 +319,11 @@ namespace PcapDotNet.Packets.Dns ...@@ -319,11 +319,11 @@ namespace PcapDotNet.Packets.Dns
{ {
Id = Id, Id = Id,
IsQuery = IsQuery, IsQuery = IsQuery,
Opcode = Opcode, OpCode = OpCode,
IsAuthoritiveAnswer = IsAuthoritiveAnswer, IsAuthoritativeAnswer = IsAuthoritativeAnswer,
IsTruncated = IsTruncated, IsTruncated = IsTruncated,
IsRecusionDesired = IsRecusionDesired, IsRecursionDesired = IsRecusionDesired,
IsRecusionAvailable = IsRecusionAvailable, IsRecursionAvailable = IsRecursionAvailable,
FutureUse = FutureUse, FutureUse = FutureUse,
IsAuthenticData = IsAuthenticData, IsAuthenticData = IsAuthenticData,
IsCheckingDisabled = IsCheckingDisabled, IsCheckingDisabled = IsCheckingDisabled,
...@@ -367,17 +367,17 @@ namespace PcapDotNet.Packets.Dns ...@@ -367,17 +367,17 @@ namespace PcapDotNet.Packets.Dns
} }
internal static void Write(byte[] buffer, int offset, internal static void Write(byte[] buffer, int offset,
ushort id, bool isResponse, DnsOpcode opcode, bool isAuthoritiveAnswer, bool isTruncated, ushort id, bool isResponse, DnsOpCode opCode, bool isAuthoritiveAnswer, bool isTruncated,
bool isRecursionDesired, bool isRecursionAvailable, bool futureUse, bool isAuthenticData, bool isCheckingDisabled, bool isRecursionDesired, bool isRecursionAvailable, bool futureUse, bool isAuthenticData, bool isCheckingDisabled,
DnsResponseCode responseCode, List<DnsQueryResourceRecord> queries, List<DnsDataResourceRecord> answers, DnsResponseCode responseCode, IList<DnsQueryResourceRecord> queries, IList<DnsDataResourceRecord> answers,
List<DnsDataResourceRecord> authorities, List<DnsDataResourceRecord> additionals, IList<DnsDataResourceRecord> authorities, IList<DnsDataResourceRecord> additionals,
DnsDomainNameCompressionMode domainNameCompressionMode) DnsDomainNameCompressionMode domainNameCompressionMode)
{ {
buffer.Write(offset + Offset.Id, id, Endianity.Big); buffer.Write(offset + Offset.Id, id, Endianity.Big);
byte flags0 = 0; byte flags0 = 0;
if (isResponse) if (isResponse)
flags0 |= Mask.IsResponse; flags0 |= Mask.IsResponse;
flags0 |= (byte)((((byte)opcode) << Shift.Opcode) & Mask.Opcode); flags0 |= (byte)((((byte)opCode) << Shift.OpCode) & Mask.OpCode);
if (isAuthoritiveAnswer) if (isAuthoritiveAnswer)
flags0 |= Mask.IsAuthoritiveAnswer; flags0 |= Mask.IsAuthoritiveAnswer;
if (isTruncated) if (isTruncated)
...@@ -387,7 +387,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -387,7 +387,7 @@ namespace PcapDotNet.Packets.Dns
buffer.Write(offset + Offset.IsResponse, flags0); buffer.Write(offset + Offset.IsResponse, flags0);
byte flags1 = 0; byte flags1 = 0;
if (isRecursionAvailable) if (isRecursionAvailable)
flags1 |= Mask.IsRecusionAvailable; flags1 |= Mask.IsRecursionAvailable;
if (futureUse) if (futureUse)
flags1 |= Mask.FutureUse; flags1 |= Mask.FutureUse;
if (isAuthenticData) if (isAuthenticData)
......
...@@ -19,13 +19,16 @@ namespace PcapDotNet.Packets.Dns ...@@ -19,13 +19,16 @@ namespace PcapDotNet.Packets.Dns
public DnsDomainName(string domainName) public DnsDomainName(string domainName)
{ {
string[] labels = domainName.ToLowerInvariant().Split(Colon, StringSplitOptions.RemoveEmptyEntries); if (domainName == null)
throw new ArgumentNullException("domainName");
string[] labels = domainName.ToUpperInvariant().Split(Colon, StringSplitOptions.RemoveEmptyEntries);
_labels = labels.Select(label => new DataSegment(Encoding.UTF8.GetBytes(label))).ToList(); _labels = labels.Select(label => new DataSegment(Encoding.UTF8.GetBytes(label))).ToList();
} }
public static DnsDomainName Root { get { return _root; } } public static DnsDomainName Root { get { return _root; } }
public int NumLabels public int LabelsCount
{ {
get get
{ {
...@@ -35,7 +38,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -35,7 +38,7 @@ namespace PcapDotNet.Packets.Dns
public bool IsRoot public bool IsRoot
{ {
get { return NumLabels == 0; } get { return LabelsCount == 0; }
} }
public int NonCompressedLength public int NonCompressedLength
...@@ -55,7 +58,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -55,7 +58,8 @@ namespace PcapDotNet.Packets.Dns
public bool Equals(DnsDomainName other) public bool Equals(DnsDomainName other)
{ {
return _labels.SequenceEqual(other._labels); return other != null &&
_labels.SequenceEqual(other._labels);
} }
public override bool Equals(object obj) public override bool Equals(object obj)
...@@ -71,7 +75,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -71,7 +75,7 @@ namespace PcapDotNet.Packets.Dns
internal int GetLength(DnsDomainNameCompressionData compressionData, int offsetInDns) internal int GetLength(DnsDomainNameCompressionData compressionData, int offsetInDns)
{ {
int length = 0; int length = 0;
for (int i = 0; i != NumLabels; ++i) for (int i = 0; i != LabelsCount; ++i)
{ {
ListSegment<DataSegment> labels = new ListSegment<DataSegment>(_labels, i); ListSegment<DataSegment> labels = new ListSegment<DataSegment>(_labels, i);
if (compressionData.IsAvailable(labels)) if (compressionData.IsAvailable(labels))
...@@ -106,7 +110,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -106,7 +110,7 @@ namespace PcapDotNet.Packets.Dns
internal int Write(byte[] buffer, int dnsOffset, DnsDomainNameCompressionData compressionData, int offsetInDns) internal int Write(byte[] buffer, int dnsOffset, DnsDomainNameCompressionData compressionData, int offsetInDns)
{ {
int length = 0; int length = 0;
for (int i = 0; i != NumLabels; ++i) for (int i = 0; i != LabelsCount; ++i)
{ {
ListSegment<DataSegment> labels = new ListSegment<DataSegment>(_labels, i); ListSegment<DataSegment> labels = new ListSegment<DataSegment>(_labels, i);
int pointerOffset; int pointerOffset;
...@@ -158,7 +162,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -158,7 +162,7 @@ namespace PcapDotNet.Packets.Dns
++offsetInDns; ++offsetInDns;
if (offsetInDns + labelLength >= dns.Length) if (offsetInDns + labelLength >= dns.Length)
return false; // Can't read label. return false; // Can't read label.
labels.Add(dns.SubSegment(offsetInDns, labelLength)); labels.Add(dns.Subsegment(offsetInDns, labelLength));
numBytesRead += labelLength; numBytesRead += labelLength;
offsetInDns += labelLength; offsetInDns += labelLength;
} }
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
...@@ -30,7 +31,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -30,7 +31,8 @@ namespace PcapDotNet.Packets.Dns
offsetInDns = 0; offsetInDns = 0;
return false; return false;
default: default:
throw new InvalidOperationException(string.Format("Invalid DomainNameCompressionMode {0}", DomainNameCompressionMode)); throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Invalid DomainNameCompressionMode {0}",
DomainNameCompressionMode));
} }
} }
...@@ -48,7 +50,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -48,7 +50,8 @@ namespace PcapDotNet.Packets.Dns
case DnsDomainNameCompressionMode.Nothing: case DnsDomainNameCompressionMode.Nothing:
return; return;
default: default:
throw new InvalidOperationException(string.Format("Invalid DomainNameCompressionMode {0}", DomainNameCompressionMode)); throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Invalid DomainNameCompressionMode {0}",
DomainNameCompressionMode));
} }
} }
......
...@@ -20,15 +20,15 @@ namespace PcapDotNet.Packets.Dns ...@@ -20,15 +20,15 @@ namespace PcapDotNet.Packets.Dns
set { IsResponse = !value; } set { IsResponse = !value; }
} }
public DnsOpcode Opcode{ get; set; } public DnsOpCode OpCode{ get; set; }
public bool IsAuthoritiveAnswer { get; set; } public bool IsAuthoritativeAnswer { get; set; }
public bool IsTruncated { get; set; } public bool IsTruncated { get; set; }
public bool IsRecusionDesired { get; set; } public bool IsRecursionDesired { get; set; }
public bool IsRecusionAvailable { get; set;} public bool IsRecursionAvailable { get; set;}
public bool FutureUse { get; set; } public bool FutureUse { get; set; }
...@@ -38,13 +38,13 @@ namespace PcapDotNet.Packets.Dns ...@@ -38,13 +38,13 @@ namespace PcapDotNet.Packets.Dns
public DnsResponseCode ResponseCode { get; set; } public DnsResponseCode ResponseCode { get; set; }
public List<DnsQueryResourceRecord> Queries { get; set; } public IList<DnsQueryResourceRecord> Queries { get; set; }
public List<DnsDataResourceRecord> Answers { get; set; } public IList<DnsDataResourceRecord> Answers { get; set; }
public List<DnsDataResourceRecord> Authorities { get; set; } public IList<DnsDataResourceRecord> Authorities { get; set; }
public List<DnsDataResourceRecord> Additionals { get; set; } public IList<DnsDataResourceRecord> Additionals { get; set; }
public IEnumerable<DnsResourceRecord> Records public IEnumerable<DnsResourceRecord> Records
{ {
...@@ -81,7 +81,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -81,7 +81,7 @@ namespace PcapDotNet.Packets.Dns
protected override void Write(byte[] buffer, int offset) protected override void Write(byte[] buffer, int offset)
{ {
DnsDatagram.Write(buffer, offset, DnsDatagram.Write(buffer, offset,
Id, IsResponse, Opcode, IsAuthoritiveAnswer, IsTruncated, IsRecusionDesired, IsRecusionAvailable, FutureUse, IsAuthenticData, Id, IsResponse, OpCode, IsAuthoritativeAnswer, IsTruncated, IsRecursionDesired, IsRecursionAvailable, FutureUse, IsAuthenticData,
IsCheckingDisabled, ResponseCode, Queries, Answers, Authorities, Additionals, DomainNameCompressionMode); IsCheckingDisabled, ResponseCode, Queries, Answers, Authorities, Additionals, DomainNameCompressionMode);
} }
...@@ -105,11 +105,11 @@ namespace PcapDotNet.Packets.Dns ...@@ -105,11 +105,11 @@ namespace PcapDotNet.Packets.Dns
return other != null && return other != null &&
Id.Equals(other.Id) && Id.Equals(other.Id) &&
IsQuery.Equals(other.IsQuery) && IsQuery.Equals(other.IsQuery) &&
Opcode.Equals(other.Opcode) && OpCode.Equals(other.OpCode) &&
IsAuthoritiveAnswer.Equals(other.IsAuthoritiveAnswer) && IsAuthoritativeAnswer.Equals(other.IsAuthoritativeAnswer) &&
IsTruncated.Equals(other.IsTruncated) && IsTruncated.Equals(other.IsTruncated) &&
IsRecusionDesired.Equals(other.IsRecusionDesired) && IsRecursionDesired.Equals(other.IsRecursionDesired) &&
IsRecusionAvailable.Equals(other.IsRecusionAvailable) && IsRecursionAvailable.Equals(other.IsRecursionAvailable) &&
FutureUse.Equals(other.FutureUse) && FutureUse.Equals(other.FutureUse) &&
IsAuthenticData.Equals(other.IsAuthenticData) && IsAuthenticData.Equals(other.IsAuthenticData) &&
IsCheckingDisabled.Equals(other.IsCheckingDisabled) && IsCheckingDisabled.Equals(other.IsCheckingDisabled) &&
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/// Specifies kind of query in this message. /// Specifies kind of query in this message.
/// This value is set by the originator of a query and copied into the response. /// This value is set by the originator of a query and copied into the response.
/// </summary> /// </summary>
public enum DnsOpcode : byte public enum DnsOpCode : byte
{ {
/// <summary> /// <summary>
/// RFC 1035. /// RFC 1035.
......
...@@ -28,8 +28,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -28,8 +28,8 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public sealed class DnsOptResourceRecord : DnsDataResourceRecord public sealed class DnsOptResourceRecord : DnsDataResourceRecord
{ {
public DnsOptResourceRecord(DnsDomainName domainName, ushort sendersUdpPayloadSize, byte extendedRcode, DnsOptVersion version, DnsOptFlags flags, DnsResourceDataOptions data) public DnsOptResourceRecord(DnsDomainName domainName, ushort sendersUdpPayloadSize, byte extendedReturnCode, DnsOptVersion version, DnsOptFlags flags, DnsResourceDataOptions data)
: this(domainName, (DnsClass)sendersUdpPayloadSize, (int)BitSequence.Merge(extendedRcode, (byte)version, (ushort)flags), data) : this(domainName, (DnsClass)sendersUdpPayloadSize, (int)BitSequence.Merge(extendedReturnCode, (byte)version, (ushort)flags), data)
{ {
} }
...@@ -43,7 +43,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -43,7 +43,7 @@ namespace PcapDotNet.Packets.Dns
/// Forms upper 8 bits of extended 12-bit RCODE. /// Forms upper 8 bits of extended 12-bit RCODE.
/// Note that EXTENDED-RCODE value "0" indicates that an unextended RCODE is in use (values "0" through "15"). /// Note that EXTENDED-RCODE value "0" indicates that an unextended RCODE is in use (values "0" through "15").
/// </summary> /// </summary>
public byte ExtendedRcode { get { return (byte)(Ttl >> 24); } } public byte ExtendedReturnCode { get { return (byte)(Ttl >> 24); } }
/// <summary> /// <summary>
/// Indicates the implementation level of whoever sets it. /// Indicates the implementation level of whoever sets it.
......
...@@ -38,13 +38,6 @@ namespace PcapDotNet.Packets.Dns ...@@ -38,13 +38,6 @@ namespace PcapDotNet.Packets.Dns
private const int MinimumLengthAfterDomainName = 4; private const int MinimumLengthAfterDomainName = 4;
public DnsResourceRecord(DnsDomainName domainName, DnsType type, DnsClass dnsClass)
{
DomainName = domainName;
Type = type;
DnsClass = dnsClass;
}
/// <summary> /// <summary>
/// An owner name, i.e., the name of the node to which this resource record pertains. /// An owner name, i.e., the name of the node to which this resource record pertains.
/// </summary> /// </summary>
...@@ -79,6 +72,13 @@ namespace PcapDotNet.Packets.Dns ...@@ -79,6 +72,13 @@ namespace PcapDotNet.Packets.Dns
return DomainName + " " + Type + " " + DnsClass; return DomainName + " " + Type + " " + DnsClass;
} }
protected DnsResourceRecord(DnsDomainName domainName, DnsType type, DnsClass dnsClass)
{
DomainName = domainName;
Type = type;
DnsClass = dnsClass;
}
internal bool EqualsBase(DnsResourceRecord other) internal bool EqualsBase(DnsResourceRecord other)
{ {
return other != null && return other != null &&
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
/// <summary> /// <summary>
/// RFC 2136. /// RFC 2136.
/// YXDomain. Name Exists when it should not /// YXDomain. Name Exists when it should not.
/// </summary> /// </summary>
YxDomain = 6, YxDomain = 6,
...@@ -58,9 +58,9 @@ ...@@ -58,9 +58,9 @@
/// <summary> /// <summary>
/// RFC 2136. /// RFC 2136.
/// RR Set that should exist does not. /// RR Set that should exist does not (NX).
/// </summary> /// </summary>
NxRrSet = 8, NotExistRrSet = 8,
/// <summary> /// <summary>
/// RFC 2136. /// RFC 2136.
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
/// RFCs 2671, 2845. /// RFCs 2671, 2845.
/// Bad OPT Version or TSIG Signature Failure. /// Bad OPT Version or TSIG Signature Failure.
/// </summary> /// </summary>
BadVersOrBadSig = 16, BadVersionOrBadSignature = 16,
/// <summary> /// <summary>
/// RFC 2845. /// RFC 2845.
...@@ -108,12 +108,12 @@ ...@@ -108,12 +108,12 @@
/// RFC 2930. /// RFC 2930.
/// Algorithm not supported. /// Algorithm not supported.
/// </summary> /// </summary>
BadAlg = 21, BadAlgorithm = 21,
/// <summary> /// <summary>
/// RFC 4635. /// RFC 4635.
/// Bad Truncation. /// BADTRUNC - Bad Truncation.
/// </summary> /// </summary>
BadTrunc = 22, BadTruncaction = 22,
} }
} }
\ No newline at end of file
...@@ -8,11 +8,14 @@ ...@@ -8,11 +8,14 @@
/// </summary> /// </summary>
public enum DnsType : ushort public enum DnsType : ushort
{ {
None = 0,
/// <summary> /// <summary>
/// RFC 1035. /// RFC 1035.
/// A host address. /// A host address.
/// Payload type: DnsResourceDataIpV4. /// Payload type: DnsResourceDataIpV4.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "A")]
A = 1, A = 1,
/// <summary> /// <summary>
...@@ -45,10 +48,10 @@ ...@@ -45,10 +48,10 @@
/// <summary> /// <summary>
/// RFC 1035. /// RFC 1035.
/// Marks the start of a zone of authority. /// SOA - Marks the start of a zone of authority.
/// Payload type: DnsResourceDataStartOfAuthority. /// Payload type: DnsResourceDataStartOfAuthority.
/// </summary> /// </summary>
Soa = 6, StartOfAuthority = 6,
/// <summary> /// <summary>
/// RFC 1035. /// RFC 1035.
...@@ -66,10 +69,10 @@ ...@@ -66,10 +69,10 @@
/// <summary> /// <summary>
/// RFC 1035. /// RFC 1035.
/// A mail rename domain name (EXPERIMENTAL). /// MR - A mail rename domain name (EXPERIMENTAL).
/// Payload type: DnsResourceDataDomainName. /// Payload type: DnsResourceDataDomainName.
/// </summary> /// </summary>
Mr = 9, MailRename = 9,
/// <summary> /// <summary>
/// RFC 1035. /// RFC 1035.
...@@ -108,10 +111,10 @@ ...@@ -108,10 +111,10 @@
/// <summary> /// <summary>
/// RFC 1035. /// RFC 1035.
/// Mail exchange. /// MX - Mail exchange.
/// Payload type: DnsResourceDataMailExchange. /// Payload type: DnsResourceDataMailExchange.
/// </summary> /// </summary>
Mx = 15, MailExchange = 15,
/// <summary> /// <summary>
/// RFC 1035. /// RFC 1035.
...@@ -129,10 +132,10 @@ ...@@ -129,10 +132,10 @@
/// <summary> /// <summary>
/// RFCs 1183, 5864. /// RFCs 1183, 5864.
/// For AFS Data Base location. /// AFSDB - For AFS Data Base location.
/// Payload type: DnsResourceDataAfsDb. /// Payload type: DnsResourceDataAfsDb.
/// </summary> /// </summary>
AfsDb = 18, AfsDatabase = 18,
/// <summary> /// <summary>
/// RFC 1183. /// RFC 1183.
...@@ -150,32 +153,32 @@ ...@@ -150,32 +153,32 @@
/// <summary> /// <summary>
/// RFC 1183. /// RFC 1183.
/// For Route Through. /// RT - For Route Through.
/// Payload type: DnsResourceDataRouteThrough. /// Payload type: DnsResourceDataRouteThrough.
/// </summary> /// </summary>
Rt = 21, RouteThrough = 21,
/// <summary> /// <summary>
/// RFC 1706. /// RFC 1706.
/// Network Service Access Point. /// NSAP - Network Service Access Point.
/// For NSAP address, NSAP style A record. /// For NSAP address, NSAP style A record.
/// Payload type: DnsResourceDataNetworkServiceAccessPoint. /// Payload type: DnsResourceDataNetworkServiceAccessPoint.
/// </summary> /// </summary>
Nsap = 22, NetworkServiceAccessPoint = 22,
/// <summary> /// <summary>
/// RFC 1348. /// RFC 1348.
/// For domain name pointer, NSAP style. /// NSAPPTR - For domain name pointer, NSAP style.
/// Payload type: DnsResourceDataDomainName. /// Payload type: DnsResourceDataDomainName.
/// </summary> /// </summary>
NsapPtr = 23, NetworkServiceAccessPointPointer = 23,
/// <summary> /// <summary>
/// RFCs 2535, 3755, 4034. /// RFCs 2535, 3755, 4034.
/// For security signature. /// SIG - For security signature.
/// Payload type: DnsResourceDataSig. /// Payload type: DnsResourceDataSignature.
/// </summary> /// </summary>
Sig = 24, Signature = 24,
/// <summary> /// <summary>
/// RFCs 2065, 2535, 3755, 4034. /// RFCs 2065, 2535, 3755, 4034.
...@@ -186,10 +189,10 @@ ...@@ -186,10 +189,10 @@
/// <summary> /// <summary>
/// RFC 2163. /// RFC 2163.
/// X.400 mail mapping information. /// PX - X.400 mail mapping information.
/// Payload type: DnsResourceDataX400Pointer. /// Payload type: DnsResourceDataX400Pointer.
/// </summary> /// </summary>
Px = 26, PointerX400 = 26,
/// <summary> /// <summary>
/// RFC 1712. /// RFC 1712.
...@@ -228,17 +231,17 @@ ...@@ -228,17 +231,17 @@
/// <summary> /// <summary>
/// Patton. /// Patton.
/// Nimrod Locator. /// NimLoc - Nimrod Locator.
/// Payload type: DnsResourceDataAnything. /// Payload type: DnsResourceDataAnything.
/// </summary> /// </summary>
NimLoc = 32, NimrodLocator = 32,
/// <summary> /// <summary>
/// RFC 2782. /// RFC 2782.
/// Server Selection. /// SRV - Server Selection.
/// Payload type: DnsResourceDataServerSelection. /// Payload type: DnsResourceDataServerSelection.
/// </summary> /// </summary>
Srv = 33, ServerSelection = 33,
/// <summary> /// <summary>
/// ATMDOC. /// ATMDOC.
...@@ -256,10 +259,10 @@ ...@@ -256,10 +259,10 @@
/// <summary> /// <summary>
/// RFC 2230. /// RFC 2230.
/// Key Exchanger. /// KX - Key Exchanger.
/// Payload type: DnsResourceDataKeyExchanger. /// Payload type: DnsResourceDataKeyExchanger.
/// </summary> /// </summary>
Kx = 36, KeyExchanger = 36,
/// <summary> /// <summary>
/// RFC 4398. /// RFC 4398.
...@@ -305,18 +308,18 @@ ...@@ -305,18 +308,18 @@
/// <summary> /// <summary>
/// RFCs 3658, 4034. /// RFCs 3658, 4034.
/// Delegation Signer. /// DS - Delegation Signer.
/// Payload type: DnsResourceDataDelegationSigner. /// Payload type: DnsResourceDataDelegationSigner.
/// </summary> /// </summary>
Ds = 43, DelegationSigner = 43,
/// <summary> /// <summary>
/// RFC 4255. /// RFC 4255.
/// SSH Key Fingerprint. /// SSHFP - SSH Key Fingerprint.
/// Used to store a fingerprint of an SSH public host key that is associated with a Domain Name System (DNS) name. /// Used to store a fingerprint of an SSH public host key that is associated with a Domain Name System (DNS) name.
/// Payload type: DnsResourceDataSshFingerprint. /// Payload type: DnsResourceDataSshFingerprint.
/// </summary> /// </summary>
SshFp = 44, SshFingerprint = 44,
/// <summary> /// <summary>
/// RFC 4025. /// RFC 4025.
...@@ -328,9 +331,9 @@ ...@@ -328,9 +331,9 @@
/// <summary> /// <summary>
/// RFCs 3755, 4034. /// RFCs 3755, 4034.
/// RRSIG. /// RRSIG.
/// Payload type: DnsResourceDataSig. /// Payload type: DnsResourceDataSignature.
/// </summary> /// </summary>
RrSig = 46, RrSignature = 46,
/// <summary> /// <summary>
/// RFCs 3755, 4034. /// RFCs 3755, 4034.
...@@ -353,7 +356,7 @@ ...@@ -353,7 +356,7 @@
/// Dynamic Host Configuration Information. /// Dynamic Host Configuration Information.
/// Payload type: DnsResourceDataAnything. /// Payload type: DnsResourceDataAnything.
/// </summary> /// </summary>
Dhcid = 49, DynamicHostConfigurationId = 49,
/// <summary> /// <summary>
/// RFC 5155. /// RFC 5155.
...@@ -367,7 +370,7 @@ ...@@ -367,7 +370,7 @@
/// NSEC3PARAM. /// NSEC3PARAM.
/// Payload type: DnsResourceDataNextDomainSecure3Parameters. /// Payload type: DnsResourceDataNextDomainSecure3Parameters.
/// </summary> /// </summary>
NSec3Param = 51, NSec3Parameters = 51,
/// <summary> /// <summary>
/// RFC 5205. /// RFC 5205.
...@@ -445,10 +448,10 @@ ...@@ -445,10 +448,10 @@
/// <summary> /// <summary>
/// RFC 2845. /// RFC 2845.
/// Transaction Signature. /// TSIG - Transaction Signature.
/// Payload type: DnsResourceDataTransactionSignature. /// Payload type: DnsResourceDataTransactionSignature.
/// </summary> /// </summary>
TSig = 250, TransactionSignature = 250,
/// <summary> /// <summary>
/// RFC 1995. /// RFC 1995.
...@@ -494,10 +497,10 @@ ...@@ -494,10 +497,10 @@
/// <summary> /// <summary>
/// Hallam-Baker. /// Hallam-Baker.
/// Certification Authority Authorization. /// CAA - Certification Authority Authorization.
/// Payload type: DnsResourceDataCertificationAuthorityAuthorization. /// Payload type: DnsResourceDataCertificationAuthorityAuthorization.
/// </summary> /// </summary>
Caa = 257, CertificationAuthorityAuthorization = 257,
/// <summary> /// <summary>
/// Weiler. 2005-12-13. /// Weiler. 2005-12-13.
...@@ -508,9 +511,9 @@ ...@@ -508,9 +511,9 @@
/// <summary> /// <summary>
/// RFC 4431. /// RFC 4431.
/// DNSSEC Lookaside Validation. /// DLV - DNSSEC Lookaside Validation.
/// Payload type: DnsResourceDataDelegationSigner. /// Payload type: DnsResourceDataDelegationSigner.
/// </summary> /// </summary>
Dlv = 32769, DnsSecLookasideValidation = 32769,
} }
} }
\ No newline at end of file
...@@ -42,6 +42,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -42,6 +42,9 @@ namespace PcapDotNet.Packets.Dns
public DnsAddressPrefix(AddressFamily addressFamily, byte prefixLength, bool negation, DataSegment addressFamilyDependentPart) public DnsAddressPrefix(AddressFamily addressFamily, byte prefixLength, bool negation, DataSegment addressFamilyDependentPart)
{ {
if (addressFamilyDependentPart == null)
throw new ArgumentNullException("addressFamilyDependentPart");
if (addressFamilyDependentPart.Length > AddressFamilyDependentPartMaxLength) if (addressFamilyDependentPart.Length > AddressFamilyDependentPartMaxLength)
throw new ArgumentOutOfRangeException("addressFamilyDependentPart", addressFamilyDependentPart, "Cannot be longer than " + AddressFamilyDependentPartMaxLength); throw new ArgumentOutOfRangeException("addressFamilyDependentPart", addressFamilyDependentPart, "Cannot be longer than " + AddressFamilyDependentPartMaxLength);
...@@ -115,6 +118,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -115,6 +118,9 @@ namespace PcapDotNet.Packets.Dns
public static DnsAddressPrefix Read(DataSegment data) public static DnsAddressPrefix Read(DataSegment data)
{ {
if (data == null)
throw new ArgumentNullException("data");
if (data.Length < MinimumLength) if (data.Length < MinimumLength)
return null; return null;
AddressFamily addressFamily = (AddressFamily)data.ReadUShort(Offset.AddressFamily, Endianity.Big); AddressFamily addressFamily = (AddressFamily)data.ReadUShort(Offset.AddressFamily, Endianity.Big);
...@@ -124,7 +130,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -124,7 +130,7 @@ namespace PcapDotNet.Packets.Dns
if (data.Length < MinimumLength + addressFamilyDependentPartLength) if (data.Length < MinimumLength + addressFamilyDependentPartLength)
return null; return null;
DataSegment addressFamilyDependentPart = data.SubSegment(Offset.AddressFamilyDependentPart, addressFamilyDependentPartLength); DataSegment addressFamilyDependentPart = data.Subsegment(Offset.AddressFamilyDependentPart, addressFamilyDependentPartLength);
return new DnsAddressPrefix(addressFamily, prefixLength, negation, addressFamilyDependentPart); return new DnsAddressPrefix(addressFamily, prefixLength, negation, addressFamilyDependentPart);
} }
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
/// <summary> /// <summary>
/// Reserved for elliptic curve crypto. /// Reserved for elliptic curve crypto.
/// </summary> /// </summary>
Ecc = 4, EllipticCurveCrypto = 4,
/// <summary> /// <summary>
/// RFCs 3110, 3755. /// RFCs 3110, 3755.
...@@ -49,13 +49,13 @@ ...@@ -49,13 +49,13 @@
/// RFC 5155. /// RFC 5155.
/// DSA-NSEC3-SHA1. /// DSA-NSEC3-SHA1.
/// </summary> /// </summary>
DsaNsec3Sha1 = 6, DsaNextSecure3Sha1 = 6,
/// <summary> /// <summary>
/// RFC 5155. /// RFC 5155.
/// RSASHA1-NSEC3-SHA1. /// RSASHA1-NSEC3-SHA1.
/// </summary> /// </summary>
RsaSha1Nsec3Sha1 = 7, RsaSha1NextSecure3Sha1 = 7,
/// <summary> /// <summary>
/// RFC 5702. /// RFC 5702.
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
/// RFC 5933. /// RFC 5933.
/// GOST R 34.10-2001. /// GOST R 34.10-2001.
/// </summary> /// </summary>
EccGost = 12, EllipticCurveCryptoGost = 12,
/// <summary> /// <summary>
/// RFC 4034. /// RFC 4034.
...@@ -91,6 +91,6 @@ ...@@ -91,6 +91,6 @@
/// RFCs 2535, 3755. /// RFCs 2535, 3755.
/// Private algorithms - OID. /// Private algorithms - OID.
/// </summary> /// </summary>
PrivateOid = 254, PrivateObjectIdentifier = 254,
} }
} }
\ No newline at end of file
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
{ {
public enum DnsCertificateType : ushort public enum DnsCertificateType : ushort
{ {
None = 0,
/// <summary> /// <summary>
/// RFC 4398. /// RFC 4398.
/// Indicates an X.509 certificate conforming to the profile defined by the IETF PKIX working group. /// Indicates an X.509 certificate conforming to the profile defined by the IETF PKIX working group.
...@@ -14,11 +16,11 @@ ...@@ -14,11 +16,11 @@
/// RFC 4398. /// RFC 4398.
/// SPKI certificate. /// SPKI certificate.
/// </summary> /// </summary>
Spki = 2, SimplePublicKeyInfrastructure = 2,
/// <summary> /// <summary>
/// RFC 4398. /// RFC 4398.
/// Indicates an OpenPGP packet. /// PGP - Indicates an OpenPGP packet.
/// This is used to transfer public key material and revocation signatures. /// This is used to transfer public key material and revocation signatures.
/// The data is binary and must not be encoded into an ASCII armor. /// The data is binary and must not be encoded into an ASCII armor.
/// An implementation should process transferable public keys, but it may handle additional OpenPGP packets. /// An implementation should process transferable public keys, but it may handle additional OpenPGP packets.
...@@ -35,11 +37,11 @@ ...@@ -35,11 +37,11 @@
/// <summary> /// <summary>
/// RFC 4398. /// RFC 4398.
/// The URL of an SPKI certificate. /// ISPKI - The URL of an SPKI certificate.
/// Must be used when the content is too large to fit in the CERT RR and may be used at the implementer's discretion. /// Must be used when the content is too large to fit in the CERT RR and may be used at the implementer's discretion.
/// Should not be used where the DNS message is 512 octets or smaller and could thus be expected to fit a UDP packet. /// Should not be used where the DNS message is 512 octets or smaller and could thus be expected to fit a UDP packet.
/// </summary> /// </summary>
ISpki = 5, IndirectSimplePublicKeyInfrastructure = 5,
/// <summary> /// <summary>
/// RFC 4398. /// RFC 4398.
...@@ -55,17 +57,17 @@ ...@@ -55,17 +57,17 @@
/// <summary> /// <summary>
/// RFC 4398. /// RFC 4398.
/// Attribute Certificate. /// ACPKIX - Attribute Certificate.
/// </summary> /// </summary>
AcPkix = 7, AttributeCertificatePkix = 7,
/// <summary> /// <summary>
/// RFC 4398. /// RFC 4398.
/// The URL of an Attribute Certificate. /// IAcPkix - The URL of an Attribute Certificate.
/// Must be used when the content is too large to fit in the CERT RR and may be used at the implementer's discretion. /// Must be used when the content is too large to fit in the CERT RR and may be used at the implementer's discretion.
/// Should not be used where the DNS message is 512 octets or smaller and could thus be expected to fit a UDP packet. /// Should not be used where the DNS message is 512 octets or smaller and could thus be expected to fit a UDP packet.
/// </summary> /// </summary>
IAcPkix = 8, IndirectAttributeCertificatePkix = 8,
/// <summary> /// <summary>
/// RFC 4398. /// RFC 4398.
...@@ -84,6 +86,6 @@ ...@@ -84,6 +86,6 @@
/// X.509 certificates that conform to the IETF PKIX profile should be indicated by the PKIX type, not the OID private type. /// X.509 certificates that conform to the IETF PKIX profile should be indicated by the PKIX type, not the OID private type.
/// Recognition of private certificate types need not be based on OID equality but can use various forms of pattern matching such as OID prefix. /// Recognition of private certificate types need not be based on OID equality but can use various forms of pattern matching such as OID prefix.
/// </summary> /// </summary>
Oid = 254, ObjectIdentifier = 254,
} }
} }
\ No newline at end of file
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
{ {
public enum DnsDigestType : byte public enum DnsDigestType : byte
{ {
None = 0,
/// <summary> /// <summary>
/// RFC 3658. /// RFC 3658.
/// SHA-1. /// SHA-1.
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
/// </summary> /// </summary>
public enum DnsFingerprintPublicKeyAlgorithm : byte public enum DnsFingerprintPublicKeyAlgorithm : byte
{ {
None = 0,
Rsa = 1, Rsa = 1,
Dss = 2, Dss = 2,
} }
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
/// </summary> /// </summary>
public enum DnsFingerprintType : byte public enum DnsFingerprintType : byte
{ {
None = 0,
/// <summary> /// <summary>
/// RFC 4255. /// RFC 4255.
/// </summary> /// </summary>
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
/// </summary> /// </summary>
public enum DnsKeyProtocol : byte public enum DnsKeyProtocol : byte
{ {
None = 0,
/// <summary> /// <summary>
/// Connection with TLS. /// Connection with TLS.
/// </summary> /// </summary>
......
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
/// <summary> /// <summary>
/// http://files.dns-sd.org/draft-sekar-dns-llq.txt. /// http://files.dns-sd.org/draft-sekar-dns-llq.txt.
/// </summary> /// </summary>
public enum DnsLongLivedQueryOpcode : ushort public enum DnsLongLivedQueryOpCode : ushort
{ {
None = 0,
Setup = 1, Setup = 1,
Refresh = 2, Refresh = 2,
Event = 3, Event = 3,
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
{ {
public enum DnsOptionCode : ushort public enum DnsOptionCode : ushort
{ {
None = 0,
/// <summary> /// <summary>
/// http://files.dns-sd.org/draft-sekar-dns-llq.txt. /// http://files.dns-sd.org/draft-sekar-dns-llq.txt.
/// LLQ. /// LLQ.
......
...@@ -29,26 +29,26 @@ namespace PcapDotNet.Packets.Dns ...@@ -29,26 +29,26 @@ namespace PcapDotNet.Packets.Dns
private static class Offset private static class Offset
{ {
public const int Version = 0; public const int Version = 0;
public const int Opcode = Version + sizeof(ushort); public const int OpCode = Version + sizeof(ushort);
public const int ErrorCode = Opcode + sizeof(ushort); public const int ErrorCode = OpCode + sizeof(ushort);
public const int Id = ErrorCode + sizeof(ushort); public const int Id = ErrorCode + sizeof(ushort);
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 MinimumDataLength = 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)
{ {
Version = version; Version = version;
Opcode = opcode; OpCode = opCode;
ErrorCode = errorCode; ErrorCode = errorCode;
Id = id; Id = id;
LeaseLife = leaseLife; LeaseLife = leaseLife;
} }
public ushort Version { get; private set; } public ushort Version { get; private set; }
public DnsLongLivedQueryOpcode Opcode { get; private set; } public DnsLongLivedQueryOpCode OpCode { get; private set; }
public DnsLongLivedQueryErrorCode ErrorCode { get; private set; } public DnsLongLivedQueryErrorCode ErrorCode { get; private set; }
public ulong Id { get; private set; } public ulong Id { get; private set; }
public uint LeaseLife { get; private set; } public uint LeaseLife { get; private set; }
...@@ -62,7 +62,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -62,7 +62,7 @@ namespace PcapDotNet.Packets.Dns
{ {
DnsOptionLongLivedQuery castedOther = (DnsOptionLongLivedQuery)other; DnsOptionLongLivedQuery castedOther = (DnsOptionLongLivedQuery)other;
return Version.Equals(castedOther.Version) && return Version.Equals(castedOther.Version) &&
Opcode.Equals(castedOther.Opcode) && OpCode.Equals(castedOther.OpCode) &&
ErrorCode.Equals(castedOther.ErrorCode) && ErrorCode.Equals(castedOther.ErrorCode) &&
Id.Equals(castedOther.Id) && Id.Equals(castedOther.Id) &&
LeaseLife.Equals(castedOther.LeaseLife); LeaseLife.Equals(castedOther.LeaseLife);
...@@ -70,13 +70,13 @@ namespace PcapDotNet.Packets.Dns ...@@ -70,13 +70,13 @@ namespace PcapDotNet.Packets.Dns
internal override int DataGetHashCode() internal override int DataGetHashCode()
{ {
return Sequence.GetHashCode(BitSequence.Merge(Version, (ushort)Opcode), ErrorCode, Id, LeaseLife); return Sequence.GetHashCode(BitSequence.Merge(Version, (ushort)OpCode), ErrorCode, Id, LeaseLife);
} }
internal override void WriteData(byte[] buffer, ref int offset) internal override void WriteData(byte[] buffer, ref int offset)
{ {
buffer.Write(offset + Offset.Version, Version, Endianity.Big); buffer.Write(offset + Offset.Version, Version, Endianity.Big);
buffer.Write(offset + Offset.Opcode, (ushort)Opcode, Endianity.Big); buffer.Write(offset + Offset.OpCode, (ushort)OpCode, Endianity.Big);
buffer.Write(offset + Offset.ErrorCode, (ushort)ErrorCode, Endianity.Big); buffer.Write(offset + Offset.ErrorCode, (ushort)ErrorCode, Endianity.Big);
buffer.Write(offset + Offset.Id, Id, Endianity.Big); buffer.Write(offset + Offset.Id, Id, Endianity.Big);
buffer.Write(offset + Offset.LeaseLife, LeaseLife, Endianity.Big); buffer.Write(offset + Offset.LeaseLife, LeaseLife, Endianity.Big);
...@@ -88,12 +88,12 @@ namespace PcapDotNet.Packets.Dns ...@@ -88,12 +88,12 @@ namespace PcapDotNet.Packets.Dns
if (data.Length < MinimumDataLength) if (data.Length < MinimumDataLength)
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);
DnsLongLivedQueryErrorCode errorCode = (DnsLongLivedQueryErrorCode)data.ReadUShort(Offset.ErrorCode, Endianity.Big); DnsLongLivedQueryErrorCode errorCode = (DnsLongLivedQueryErrorCode)data.ReadUShort(Offset.ErrorCode, Endianity.Big);
ulong id = data.ReadULong(Offset.Id, Endianity.Big); ulong id = data.ReadULong(Offset.Id, Endianity.Big);
uint leaseLife = data.ReadUInt(Offset.LeaseLife, Endianity.Big); uint leaseLife = data.ReadUInt(Offset.LeaseLife, Endianity.Big);
return new DnsOptionLongLivedQuery(version, opcode, errorCode, id, leaseLife); return new DnsOptionLongLivedQuery(version, opCode, errorCode, id, leaseLife);
} }
} }
} }
\ No newline at end of file
...@@ -13,7 +13,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -13,7 +13,7 @@ namespace PcapDotNet.Packets.Dns
public DnsOptions(IList<DnsOption> options) public DnsOptions(IList<DnsOption> options)
{ {
Options = options.AsReadOnly(); Options = options.AsReadOnly();
NumBytes = options.Sum(option => option.Length); BytesLength = options.Sum(option => option.Length);
} }
public DnsOptions(params DnsOption[] options) public DnsOptions(params DnsOption[] options)
...@@ -23,7 +23,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -23,7 +23,7 @@ namespace PcapDotNet.Packets.Dns
public ReadOnlyCollection<DnsOption> Options { get; private set; } public ReadOnlyCollection<DnsOption> Options { get; private set; }
public int NumBytes { get; private set; } public int BytesLength { get; private set; }
public bool Equals(DnsOptions other) public bool Equals(DnsOptions other)
{ {
...@@ -62,12 +62,12 @@ namespace PcapDotNet.Packets.Dns ...@@ -62,12 +62,12 @@ namespace PcapDotNet.Packets.Dns
int optionLength = DnsOption.MinimumLength + optionDataLength; int optionLength = DnsOption.MinimumLength + optionDataLength;
if (data.Length < optionLength) if (data.Length < optionLength)
return null; return null;
DnsOption option = DnsOption.CreateInstance(code, data.SubSegment(DnsOption.MinimumLength, optionDataLength)); DnsOption option = DnsOption.CreateInstance(code, data.Subsegment(DnsOption.MinimumLength, optionDataLength));
if (option == null) if (option == null)
return null; return null;
options.Add(option); options.Add(option);
data = data.SubSegment(optionLength, data.Length - optionLength); data = data.Subsegment(optionLength, data.Length - optionLength);
} }
return new DnsOptions(options); return new DnsOptions(options);
......
...@@ -37,7 +37,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -37,7 +37,7 @@ namespace PcapDotNet.Packets.Dns
DnsResourceData prototype = TryGetPrototype(type); DnsResourceData prototype = TryGetPrototype(type);
if (prototype != null) if (prototype != null)
return prototype.CreateInstance(dns, offsetInDns, length); return prototype.CreateInstance(dns, offsetInDns, length);
return new DnsResourceDataAnything(dns.SubSegment(offsetInDns, length)); return new DnsResourceDataAnything(dns.Subsegment(offsetInDns, length));
} }
internal abstract DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length); internal abstract DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length);
...@@ -54,7 +54,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -54,7 +54,7 @@ namespace PcapDotNet.Packets.Dns
int stringLength = data[offset++]; int stringLength = data[offset++];
if (data.Length < offset + stringLength) if (data.Length < offset + stringLength)
return null; return null;
DataSegment str = data.SubSegment(ref offset, stringLength); DataSegment str = data.Subsegment(ref offset, stringLength);
return str; return str;
} }
......
using System; using System;
using System.Globalization;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.IpV6; using PcapDotNet.Packets.IpV6;
...@@ -40,9 +41,11 @@ namespace PcapDotNet.Packets.Dns ...@@ -40,9 +41,11 @@ namespace PcapDotNet.Packets.Dns
public DnsResourceDataA6(byte prefixLength, IpV6Address addressSuffix, DnsDomainName prefixName) public DnsResourceDataA6(byte prefixLength, IpV6Address addressSuffix, DnsDomainName prefixName)
{ {
if (IsAddressSuffixTooBig(prefixLength, addressSuffix)) if (IsAddressSuffixTooBig(prefixLength, addressSuffix))
throw new ArgumentOutOfRangeException("addressSuffix", string.Format("Value is too small for prefix length {0}", prefixLength)); throw new ArgumentOutOfRangeException("addressSuffix",
string.Format(CultureInfo.InvariantCulture, "Value is too small for prefix length {0}", prefixLength));
if (IsAddressSuffixTooSmall(prefixLength, addressSuffix)) if (IsAddressSuffixTooSmall(prefixLength, addressSuffix))
throw new ArgumentOutOfRangeException("addressSuffix", string.Format("Value is too big for prefix length {0}", prefixLength)); throw new ArgumentOutOfRangeException("addressSuffix",
string.Format(CultureInfo.InvariantCulture, "Value is too big for prefix length {0}", prefixLength));
PrefixLength = prefixLength; PrefixLength = prefixLength;
AddressSuffix = addressSuffix; AddressSuffix = addressSuffix;
......
...@@ -80,7 +80,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -80,7 +80,7 @@ namespace PcapDotNet.Packets.Dns
if (item == null) if (item == null)
return null; return null;
items.Add(item); items.Add(item);
data = data.SubSegment(item.Length, data.Length - item.Length); data = data.Subsegment(item.Length, data.Length - item.Length);
} }
return new DnsResourceDataAddressPrefixList(items); return new DnsResourceDataAddressPrefixList(items);
......
...@@ -13,31 +13,31 @@ ...@@ -13,31 +13,31 @@
/// +-----+----------+ /// +-----+----------+
/// </pre> /// </pre>
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.AfsDb)] [DnsTypeRegistration(Type = DnsType.AfsDatabase)]
public sealed class DnsResourceDataAfsDb : DnsResourceDataUShortDomainName public sealed class DnsResourceDataAfsDatabase : DnsResourceDataUShortDomainName
{ {
public DnsResourceDataAfsDb(ushort subType, DnsDomainName hostname) public DnsResourceDataAfsDatabase(ushort subtype, DnsDomainName hostName)
: base(subType, hostname) : base(subtype, hostName)
{ {
} }
public ushort SubType { get { return Value; } } public ushort Subtype { get { return Value; } }
public DnsDomainName Hostname { get { return DomainName; } } public DnsDomainName HostName { get { return DomainName; } }
internal DnsResourceDataAfsDb() internal DnsResourceDataAfsDatabase()
: this(0, DnsDomainName.Root) : this(0, DnsDomainName.Root)
{ {
} }
internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length) internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
{ {
ushort subType; ushort subtype;
DnsDomainName hostName; DnsDomainName hostName;
if (!TryRead(out subType, out hostName, dns, offsetInDns, length)) if (!TryRead(out subtype, out hostName, dns, offsetInDns, length))
return null; return null;
return new DnsResourceDataAfsDb(subType, hostName); return new DnsResourceDataAfsDatabase(subtype, hostName);
} }
} }
} }
\ No newline at end of file
...@@ -8,8 +8,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -8,8 +8,8 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.Null)] [DnsTypeRegistration(Type = DnsType.Null)]
[DnsTypeRegistration(Type = DnsType.EId)] [DnsTypeRegistration(Type = DnsType.EId)]
[DnsTypeRegistration(Type = DnsType.NimLoc)] [DnsTypeRegistration(Type = DnsType.NimrodLocator)]
[DnsTypeRegistration(Type = DnsType.Dhcid)] [DnsTypeRegistration(Type = DnsType.DynamicHostConfigurationId)]
public sealed class DnsResourceDataAnything : DnsResourceDataSimple, IEquatable<DnsResourceDataAnything> public sealed class DnsResourceDataAnything : DnsResourceDataSimple, IEquatable<DnsResourceDataAnything>
{ {
public DnsResourceDataAnything() public DnsResourceDataAnything()
......
...@@ -86,7 +86,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -86,7 +86,7 @@ namespace PcapDotNet.Packets.Dns
return null; return null;
DnsAtmAddressFormat format = (DnsAtmAddressFormat)data[Offset.Format]; DnsAtmAddressFormat format = (DnsAtmAddressFormat)data[Offset.Format];
DataSegment address = data.SubSegment(Offset.Address, data.Length - ConstantPartLength); DataSegment address = data.Subsegment(Offset.Address, data.Length - ConstantPartLength);
return new DnsResourceDataAtmAddress(format, address); return new DnsResourceDataAtmAddress(format, address);
} }
......
...@@ -112,7 +112,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -112,7 +112,7 @@ namespace PcapDotNet.Packets.Dns
DnsCertificateType type = (DnsCertificateType)data.ReadUShort(Offset.Type, Endianity.Big); DnsCertificateType type = (DnsCertificateType)data.ReadUShort(Offset.Type, Endianity.Big);
ushort keyTag = data.ReadUShort(Offset.KeyTag, Endianity.Big); ushort keyTag = data.ReadUShort(Offset.KeyTag, Endianity.Big);
DnsAlgorithm algorithm = (DnsAlgorithm)data[Offset.Algorithm]; DnsAlgorithm algorithm = (DnsAlgorithm)data[Offset.Algorithm];
DataSegment certificate = data.SubSegment(Offset.Certificate, data.Length - ConstantPartLength); DataSegment certificate = data.Subsegment(Offset.Certificate, data.Length - ConstantPartLength);
return new DnsResourceDataCertificate(type, keyTag, algorithm, certificate); return new DnsResourceDataCertificate(type, keyTag, algorithm, certificate);
} }
......
using System; using System;
using System.Globalization;
using System.Linq; using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
...@@ -19,7 +20,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -19,7 +20,7 @@ namespace PcapDotNet.Packets.Dns
/// +-----+----------------------------------+ /// +-----+----------------------------------+
/// </pre> /// </pre>
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.Caa)] [DnsTypeRegistration(Type = DnsType.CertificationAuthorityAuthorization)]
public sealed class DnsResourceDataCertificationAuthorityAuthorization : DnsResourceDataSimple, IEquatable<DnsResourceDataCertificationAuthorityAuthorization> public sealed class DnsResourceDataCertificationAuthorityAuthorization : DnsResourceDataSimple, IEquatable<DnsResourceDataCertificationAuthorityAuthorization>
{ {
private static class Offset private static class Offset
...@@ -33,8 +34,11 @@ namespace PcapDotNet.Packets.Dns ...@@ -33,8 +34,11 @@ namespace PcapDotNet.Packets.Dns
public DnsResourceDataCertificationAuthorityAuthorization(DnsCertificationAuthorityAuthorizationFlags flags, DataSegment tag, DataSegment value) public DnsResourceDataCertificationAuthorityAuthorization(DnsCertificationAuthorityAuthorizationFlags flags, DataSegment tag, DataSegment value)
{ {
if (tag == null)
throw new ArgumentNullException("tag");
if (tag.Length > byte.MaxValue) if (tag.Length > byte.MaxValue)
throw new ArgumentOutOfRangeException("tag", tag.Length, string.Format("Cannot be longer than {0}", byte.MaxValue)); throw new ArgumentOutOfRangeException("tag", tag.Length, string.Format(CultureInfo.InvariantCulture, "Cannot be longer than {0}", byte.MaxValue));
Flags = flags; Flags = flags;
Tag = tag; Tag = tag;
...@@ -106,8 +110,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -106,8 +110,8 @@ namespace PcapDotNet.Packets.Dns
int valueOffset = ConstantPartLength + tagLength; int valueOffset = ConstantPartLength + tagLength;
if (data.Length < valueOffset) if (data.Length < valueOffset)
return null; return null;
DataSegment tag = data.SubSegment(Offset.Tag, tagLength); DataSegment tag = data.Subsegment(Offset.Tag, tagLength);
DataSegment value = data.SubSegment(valueOffset, data.Length - valueOffset); DataSegment value = data.Subsegment(valueOffset, data.Length - valueOffset);
return new DnsResourceDataCertificationAuthorityAuthorization(flags, tag, value); return new DnsResourceDataCertificationAuthorityAuthorization(flags, tag, value);
} }
......
...@@ -17,13 +17,13 @@ namespace PcapDotNet.Packets.Dns ...@@ -17,13 +17,13 @@ namespace PcapDotNet.Packets.Dns
/// +-----+-----------------------------------+ /// +-----+-----------------------------------+
/// </pre> /// </pre>
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.Ds)] [DnsTypeRegistration(Type = DnsType.DelegationSigner)]
[DnsTypeRegistration(Type = DnsType.Cds)] [DnsTypeRegistration(Type = DnsType.Cds)]
[DnsTypeRegistration(Type = DnsType.Ta)] [DnsTypeRegistration(Type = DnsType.Ta)]
[DnsTypeRegistration(Type = DnsType.Dlv)] [DnsTypeRegistration(Type = DnsType.DnsSecLookasideValidation)]
public sealed class DnsResourceDataDelegationSigner : DnsResourceDataSimple, IEquatable<DnsResourceDataDelegationSigner> public sealed class DnsResourceDataDelegationSigner : DnsResourceDataSimple, IEquatable<DnsResourceDataDelegationSigner>
{ {
public static class Offset private static class Offset
{ {
public const int KeyTag = 0; public const int KeyTag = 0;
public const int Algorithm = KeyTag + sizeof(ushort); public const int Algorithm = KeyTag + sizeof(ushort);
...@@ -35,6 +35,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -35,6 +35,9 @@ namespace PcapDotNet.Packets.Dns
public DnsResourceDataDelegationSigner(ushort keyTag, DnsAlgorithm algorithm, DnsDigestType digestType, DataSegment digest) public DnsResourceDataDelegationSigner(ushort keyTag, DnsAlgorithm algorithm, DnsDigestType digestType, DataSegment digest)
{ {
if (digest == null)
throw new ArgumentNullException("digest");
KeyTag = keyTag; KeyTag = keyTag;
Algorithm = algorithm; Algorithm = algorithm;
DigestType = digestType; DigestType = digestType;
...@@ -53,8 +56,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -53,8 +56,8 @@ namespace PcapDotNet.Packets.Dns
maxDigestLength = int.MaxValue; maxDigestLength = int.MaxValue;
break; break;
} }
Digest = digest.SubSegment(0, Math.Min(digest.Length, maxDigestLength)); Digest = digest.Subsegment(0, Math.Min(digest.Length, maxDigestLength));
ExtraDigest = digest.SubSegment(Digest.Length, digest.Length - Digest.Length); ExtraDigest = digest.Subsegment(Digest.Length, digest.Length - Digest.Length);
} }
/// <summary> /// <summary>
...@@ -129,7 +132,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -129,7 +132,7 @@ namespace PcapDotNet.Packets.Dns
ushort keyTag = data.ReadUShort(Offset.KeyTag, Endianity.Big); ushort keyTag = data.ReadUShort(Offset.KeyTag, Endianity.Big);
DnsAlgorithm algorithm = (DnsAlgorithm)data[Offset.Algorithm]; DnsAlgorithm algorithm = (DnsAlgorithm)data[Offset.Algorithm];
DnsDigestType digestType = (DnsDigestType)data[Offset.DigestType]; DnsDigestType digestType = (DnsDigestType)data[Offset.DigestType];
DataSegment digest = data.SubSegment(Offset.Digest, data.Length - ConstPartLength); DataSegment digest = data.Subsegment(Offset.Digest, data.Length - ConstPartLength);
return new DnsResourceDataDelegationSigner(keyTag, algorithm, digestType, digest); return new DnsResourceDataDelegationSigner(keyTag, algorithm, digestType, digest);
} }
......
...@@ -150,7 +150,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -150,7 +150,7 @@ namespace PcapDotNet.Packets.Dns
bool secureEntryPoint = data.ReadBool(Offset.SecureEntryPoint, Mask.SecureEntryPoint); bool secureEntryPoint = data.ReadBool(Offset.SecureEntryPoint, Mask.SecureEntryPoint);
byte protocol = data[Offset.Protocol]; byte protocol = data[Offset.Protocol];
DnsAlgorithm algorithm = (DnsAlgorithm)data[Offset.Algorithm]; DnsAlgorithm algorithm = (DnsAlgorithm)data[Offset.Algorithm];
DataSegment publicKey = data.SubSegment(Offset.PublicKey, data.Length - ConstantPartLength); DataSegment publicKey = data.Subsegment(Offset.PublicKey, data.Length - ConstantPartLength);
return new DnsResourceDataDnsKey(zoneKey, revoke, secureEntryPoint, protocol, algorithm, publicKey); return new DnsResourceDataDnsKey(zoneKey, revoke, secureEntryPoint, protocol, algorithm, publicKey);
} }
......
...@@ -16,9 +16,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -16,9 +16,9 @@ namespace PcapDotNet.Packets.Dns
[DnsTypeRegistration(Type = DnsType.CName)] [DnsTypeRegistration(Type = DnsType.CName)]
[DnsTypeRegistration(Type = DnsType.Mb)] [DnsTypeRegistration(Type = DnsType.Mb)]
[DnsTypeRegistration(Type = DnsType.Mg)] [DnsTypeRegistration(Type = DnsType.Mg)]
[DnsTypeRegistration(Type = DnsType.Mr)] [DnsTypeRegistration(Type = DnsType.MailRename)]
[DnsTypeRegistration(Type = DnsType.Ptr)] [DnsTypeRegistration(Type = DnsType.Ptr)]
[DnsTypeRegistration(Type = DnsType.NsapPtr)] [DnsTypeRegistration(Type = DnsType.NetworkServiceAccessPointPointer)]
[DnsTypeRegistration(Type = DnsType.DName)] [DnsTypeRegistration(Type = DnsType.DName)]
public sealed class DnsResourceDataDomainName : DnsResourceData, IEquatable<DnsResourceDataDomainName> public sealed class DnsResourceDataDomainName : DnsResourceData, IEquatable<DnsResourceDataDomainName>
{ {
......
...@@ -101,19 +101,19 @@ namespace PcapDotNet.Packets.Dns ...@@ -101,19 +101,19 @@ namespace PcapDotNet.Packets.Dns
int longtitudeNumBytes = data[0]; int longtitudeNumBytes = data[0];
if (data.Length < longtitudeNumBytes + 3) if (data.Length < longtitudeNumBytes + 3)
return null; return null;
string longtitude = data.SubSegment(1, longtitudeNumBytes).ToString(Encoding.ASCII); string longtitude = data.Subsegment(1, longtitudeNumBytes).ToString(Encoding.ASCII);
data = data.SubSegment(longtitudeNumBytes + 1, data.Length - longtitudeNumBytes - 1); data = data.Subsegment(longtitudeNumBytes + 1, data.Length - longtitudeNumBytes - 1);
int latitudeNumBytes = data[0]; int latitudeNumBytes = data[0];
if (data.Length < latitudeNumBytes + 2) if (data.Length < latitudeNumBytes + 2)
return null; return null;
string latitude = data.SubSegment(1, latitudeNumBytes).ToString(Encoding.ASCII); string latitude = data.Subsegment(1, latitudeNumBytes).ToString(Encoding.ASCII);
data = data.SubSegment(latitudeNumBytes + 1, data.Length - latitudeNumBytes - 1); data = data.Subsegment(latitudeNumBytes + 1, data.Length - latitudeNumBytes - 1);
int altitudeNumBytes = data[0]; int altitudeNumBytes = data[0];
if (data.Length != altitudeNumBytes + 1) if (data.Length != altitudeNumBytes + 1)
return null; return null;
string altitude = data.SubSegment(1, altitudeNumBytes).ToString(Encoding.ASCII); string altitude = data.Subsegment(1, altitudeNumBytes).ToString(Encoding.ASCII);
return new DnsResourceDataGeographicalPosition(longtitude, latitude, altitude); return new DnsResourceDataGeographicalPosition(longtitude, latitude, altitude);
} }
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq; using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
using IListExtensions = PcapDotNet.Base.IListExtensions; using IListExtensions = PcapDotNet.Base.IListExtensions;
...@@ -42,10 +43,17 @@ namespace PcapDotNet.Packets.Dns ...@@ -42,10 +43,17 @@ namespace PcapDotNet.Packets.Dns
public DnsResourceDataHostIdentityProtocol(DataSegment hostIdentityTag, DnsPublicKeyAlgorithm publicKeyAlgorithm, DataSegment publicKey, public DnsResourceDataHostIdentityProtocol(DataSegment hostIdentityTag, DnsPublicKeyAlgorithm publicKeyAlgorithm, DataSegment publicKey,
IEnumerable<DnsDomainName> rendezvousServers) IEnumerable<DnsDomainName> rendezvousServers)
{ {
if (hostIdentityTag == null)
throw new ArgumentNullException("hostIdentityTag");
if (publicKey == null)
throw new ArgumentNullException("publicKey");
if (hostIdentityTag.Length > byte.MaxValue) if (hostIdentityTag.Length > byte.MaxValue)
throw new ArgumentOutOfRangeException("hostIdentityTag", hostIdentityTag.Length, string.Format("Cannot be bigger than {0}.", byte.MaxValue)); throw new ArgumentOutOfRangeException("hostIdentityTag", hostIdentityTag.Length,
string.Format(CultureInfo.InvariantCulture, "Cannot be bigger than {0}.", byte.MaxValue));
if (publicKey.Length > ushort.MaxValue) if (publicKey.Length > ushort.MaxValue)
throw new ArgumentOutOfRangeException("publicKey", publicKey.Length, string.Format("Cannot be bigger than {0}.", ushort.MaxValue)); throw new ArgumentOutOfRangeException("publicKey", publicKey.Length,
string.Format(CultureInfo.InvariantCulture, "Cannot be bigger than {0}.", ushort.MaxValue));
HostIdentityTag = hostIdentityTag; HostIdentityTag = hostIdentityTag;
PublicKeyAlgorithm = publicKeyAlgorithm; PublicKeyAlgorithm = publicKeyAlgorithm;
PublicKey = publicKey; PublicKey = publicKey;
...@@ -134,9 +142,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -134,9 +142,9 @@ namespace PcapDotNet.Packets.Dns
if (length < ConstantPartLength + hostIdentityTagLength + publicKeyLength) if (length < ConstantPartLength + hostIdentityTagLength + publicKeyLength)
return null; return null;
DataSegment hostIdentityTag = dns.SubSegment(offsetInDns + Offset.HostIdentityTag, hostIdentityTagLength); DataSegment hostIdentityTag = dns.Subsegment(offsetInDns + Offset.HostIdentityTag, hostIdentityTagLength);
int publicKeyOffset = offsetInDns + ConstantPartLength + hostIdentityTagLength; int publicKeyOffset = offsetInDns + ConstantPartLength + hostIdentityTagLength;
DataSegment publicKey = dns.SubSegment(publicKeyOffset, publicKeyLength); DataSegment publicKey = dns.Subsegment(publicKeyOffset, publicKeyLength);
offsetInDns += ConstantPartLength + hostIdentityTagLength + publicKeyLength; offsetInDns += ConstantPartLength + hostIdentityTagLength + publicKeyLength;
length -= ConstantPartLength + hostIdentityTagLength + publicKeyLength; length -= ConstantPartLength + hostIdentityTagLength + publicKeyLength;
......
...@@ -26,7 +26,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -26,7 +26,7 @@ namespace PcapDotNet.Packets.Dns
[DnsTypeRegistration(Type = DnsType.IpSecKey)] [DnsTypeRegistration(Type = DnsType.IpSecKey)]
public sealed class DnsResourceDataIpSecKey : DnsResourceDataNoCompression, IEquatable<DnsResourceDataIpSecKey> public sealed class DnsResourceDataIpSecKey : DnsResourceDataNoCompression, IEquatable<DnsResourceDataIpSecKey>
{ {
public static class Offset private static class Offset
{ {
public const int Precedence = 0; public const int Precedence = 0;
public const int GatewayType = Precedence + sizeof(byte); public const int GatewayType = Precedence + sizeof(byte);
...@@ -122,7 +122,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -122,7 +122,7 @@ namespace PcapDotNet.Packets.Dns
DnsGateway gateway = DnsGateway.CreateInstance(gatewayType, dns, offsetInDns + Offset.Gateway, length - ConstPartLength); DnsGateway gateway = DnsGateway.CreateInstance(gatewayType, dns, offsetInDns + Offset.Gateway, length - ConstPartLength);
if (gateway == null) if (gateway == null)
return null; return null;
DataSegment publicKey = dns.SubSegment(offsetInDns + ConstPartLength + gateway.Length, length - ConstPartLength - gateway.Length); DataSegment publicKey = dns.Subsegment(offsetInDns + ConstPartLength + gateway.Length, length - ConstPartLength - gateway.Length);
return new DnsResourceDataIpSecKey(precedence, gateway, algorithm, publicKey); return new DnsResourceDataIpSecKey(precedence, gateway, algorithm, publicKey);
} }
......
...@@ -24,8 +24,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -24,8 +24,8 @@ namespace PcapDotNet.Packets.Dns
} }
public DnsResourceDataIsdn(DataSegment isdnAddress, DataSegment subAddress) public DnsResourceDataIsdn(DataSegment isdnAddress, DataSegment subaddress)
: base(isdnAddress, subAddress) : base(isdnAddress, subaddress)
{ {
} }
...@@ -39,7 +39,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -39,7 +39,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary> /// <summary>
/// Specifies the subaddress (SA). /// Specifies the subaddress (SA).
/// </summary> /// </summary>
public DataSegment SubAddress { get { return Strings.Count == MaxNumStrings ? Strings[1] : null; } } public DataSegment Subaddress { get { return Strings.Count == MaxNumStrings ? Strings[1] : null; } }
internal DnsResourceDataIsdn() internal DnsResourceDataIsdn()
: this(DataSegment.Empty) : this(DataSegment.Empty)
......
...@@ -250,7 +250,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -250,7 +250,7 @@ namespace PcapDotNet.Packets.Dns
DnsAlgorithm algorithm = (DnsAlgorithm)data[Offset.Algorithm]; DnsAlgorithm algorithm = (DnsAlgorithm)data[Offset.Algorithm];
ushort? flagsExtension = (isFlagsExtension ? ((ushort?)data.ReadUShort(Offset.FlagsExtension, Endianity.Big)) : null); ushort? flagsExtension = (isFlagsExtension ? ((ushort?)data.ReadUShort(Offset.FlagsExtension, Endianity.Big)) : null);
int publicKeyOffset = Offset.FlagsExtension + (isFlagsExtension ? sizeof(ushort) : 0); int publicKeyOffset = Offset.FlagsExtension + (isFlagsExtension ? sizeof(ushort) : 0);
DataSegment publicKey = data.SubSegment(publicKeyOffset, data.Length - publicKeyOffset); DataSegment publicKey = data.Subsegment(publicKeyOffset, data.Length - publicKeyOffset);
return new DnsResourceDataKey(authenticationProhibited, confidentialityProhibited, experimental, userAssociated, ipSec, email, nameType, signatory, return new DnsResourceDataKey(authenticationProhibited, confidentialityProhibited, experimental, userAssociated, ipSec, email, nameType, signatory,
protocol, algorithm, flagsExtension, publicKey); protocol, algorithm, flagsExtension, publicKey);
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
/// +-----+-------------------+ /// +-----+-------------------+
/// </pre> /// </pre>
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.Kx)] [DnsTypeRegistration(Type = DnsType.KeyExchanger)]
public sealed class DnsResourceDataKeyExchanger : DnsResourceDataUShortDomainName public sealed class DnsResourceDataKeyExchanger : DnsResourceDataUShortDomainName
{ {
public DnsResourceDataKeyExchanger(ushort preference, DnsDomainName keyExchanger) public DnsResourceDataKeyExchanger(ushort preference, DnsDomainName keyExchanger)
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
/// +-----+------------+ /// +-----+------------+
/// </pre> /// </pre>
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.Mx)] [DnsTypeRegistration(Type = DnsType.MailExchange)]
public sealed class DnsResourceDataMailExchange : DnsResourceDataUShortDomainName public sealed class DnsResourceDataMailExchange : DnsResourceDataUShortDomainName
{ {
public DnsResourceDataMailExchange(ushort preference, DnsDomainName mailExchangeHost) public DnsResourceDataMailExchange(ushort preference, DnsDomainName mailExchangeHost)
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
[DnsTypeRegistration(Type = DnsType.MInfo)] [DnsTypeRegistration(Type = DnsType.MInfo)]
public sealed class DnsResourceDataMailingListInfo : DnsResourceData2DomainNames public sealed class DnsResourceDataMailingListInfo : DnsResourceData2DomainNames
{ {
public DnsResourceDataMailingListInfo(DnsDomainName mailingList, DnsDomainName errorMailBox) public DnsResourceDataMailingListInfo(DnsDomainName mailingList, DnsDomainName errorMailbox)
: base(mailingList, errorMailBox) : base(mailingList, errorMailbox)
{ {
} }
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
/// (similar to the ERRORS-TO: field which has been proposed). /// (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. /// If this domain name names the root, errors should be returned to the sender of the message.
/// </summary> /// </summary>
public DnsDomainName ErrorMailBox { get { return Second; } } public DnsDomainName ErrorMailbox { get { return Second; } }
internal DnsResourceDataMailingListInfo() internal DnsResourceDataMailingListInfo()
: this(DnsDomainName.Root, DnsDomainName.Root) : this(DnsDomainName.Root, DnsDomainName.Root)
...@@ -41,11 +41,11 @@ ...@@ -41,11 +41,11 @@
internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length) internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
{ {
DnsDomainName mailingList; DnsDomainName mailingList;
DnsDomainName errorMailBox; DnsDomainName errorMailbox;
if (!TryRead(out mailingList, out errorMailBox, dns, offsetInDns, length)) if (!TryRead(out mailingList, out errorMailbox, dns, offsetInDns, length))
return null; return null;
return new DnsResourceDataMailingListInfo(mailingList, errorMailBox); return new DnsResourceDataMailingListInfo(mailingList, errorMailbox);
} }
} }
} }
\ No newline at end of file
...@@ -21,6 +21,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -21,6 +21,9 @@ namespace PcapDotNet.Packets.Dns
public DnsResourceDataNInfo(ReadOnlyCollection<DataSegment> strings) public DnsResourceDataNInfo(ReadOnlyCollection<DataSegment> strings)
: base(strings) : base(strings)
{ {
if (strings == null)
throw new ArgumentNullException("strings");
if (strings.Count < MinNumStrings) if (strings.Count < MinNumStrings)
throw new ArgumentOutOfRangeException("strings", strings.Count, "There must be at least one string."); throw new ArgumentOutOfRangeException("strings", strings.Count, "There must be at least one string.");
} }
......
using System; using System;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using PcapDotNet.Base; using PcapDotNet.Base;
...@@ -40,12 +41,15 @@ namespace PcapDotNet.Packets.Dns ...@@ -40,12 +41,15 @@ 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;
public DnsResourceDataNamingAuthorityPointer(ushort order, ushort preference, DataSegment flags, DataSegment services, DataSegment regexp, DnsDomainName replacement) public DnsResourceDataNamingAuthorityPointer(ushort order, ushort preference, DataSegment flags, DataSegment services, DataSegment regularExpression, DnsDomainName replacement)
{ {
if (flags == null)
throw new ArgumentNullException("flags");
if (!IsLegalFlags(flags)) if (!IsLegalFlags(flags))
{ {
throw new ArgumentException( throw new ArgumentException(
string.Format("Flags ({0}) contain a non [a-zA-Z0-9] character.", string.Format(CultureInfo.InvariantCulture, "Flags ({0}) contain a non [a-zA-Z0-9] character.",
Encoding.ASCII.GetString(flags.Buffer, flags.StartOffset, flags.Length)), Encoding.ASCII.GetString(flags.Buffer, flags.StartOffset, flags.Length)),
"flags"); "flags");
} }
...@@ -57,7 +61,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -57,7 +61,7 @@ namespace PcapDotNet.Packets.Dns
: new DataSegment(flags.Select(flag => flag >= 'a' && flag <= 'z' ? (byte)(flag + 'A' - 'a') : flag) : new DataSegment(flags.Select(flag => flag >= 'a' && flag <= 'z' ? (byte)(flag + 'A' - 'a') : flag)
.Distinct().OrderBy(flag => flag).ToArray()); .Distinct().OrderBy(flag => flag).ToArray());
Services = services; Services = services;
Regexp = regexp; RegularExpression = regularExpression;
Replacement = replacement; Replacement = replacement;
} }
...@@ -105,7 +109,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -105,7 +109,7 @@ namespace PcapDotNet.Packets.Dns
/// 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, 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. /// 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 Regexp { get; private set; } public DataSegment RegularExpression { get; private set; }
/// <summary> /// <summary>
/// The next domain-name to query for depending on the potential values found in the flags field. /// The next domain-name to query for depending on the potential values found in the flags field.
...@@ -127,7 +131,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -127,7 +131,7 @@ namespace PcapDotNet.Packets.Dns
Preference.Equals(other.Preference) && Preference.Equals(other.Preference) &&
Flags.Equals(other.Flags) && Flags.Equals(other.Flags) &&
Services.Equals(other.Services) && Services.Equals(other.Services) &&
Regexp.Equals(other.Regexp) && RegularExpression.Equals(other.RegularExpression) &&
Replacement.Equals(other.Replacement); Replacement.Equals(other.Replacement);
} }
...@@ -138,7 +142,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -138,7 +142,7 @@ namespace PcapDotNet.Packets.Dns
public override int GetHashCode() public override int GetHashCode()
{ {
return Sequence.GetHashCode(BitSequence.Merge(Order, Preference), Flags, Services, Regexp, Replacement); return Sequence.GetHashCode(BitSequence.Merge(Order, Preference), Flags, Services, RegularExpression, Replacement);
} }
internal DnsResourceDataNamingAuthorityPointer() internal DnsResourceDataNamingAuthorityPointer()
...@@ -148,7 +152,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -148,7 +152,7 @@ namespace PcapDotNet.Packets.Dns
internal override int GetLength() internal override int GetLength()
{ {
return ConstantPartLength + GetStringLength(Flags) + GetStringLength(Services) + GetStringLength(Regexp) + Replacement.NonCompressedLength; return ConstantPartLength + GetStringLength(Flags) + GetStringLength(Services) + GetStringLength(RegularExpression) + Replacement.NonCompressedLength;
} }
internal override int WriteData(byte[] buffer, int offset) internal override int WriteData(byte[] buffer, int offset)
...@@ -158,7 +162,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -158,7 +162,7 @@ namespace PcapDotNet.Packets.Dns
offset += Offset.Flags; offset += Offset.Flags;
WriteString(buffer, ref offset, Flags); WriteString(buffer, ref offset, Flags);
WriteString(buffer, ref offset, Services); WriteString(buffer, ref offset, Services);
WriteString(buffer, ref offset, Regexp); WriteString(buffer, ref offset, RegularExpression);
Replacement.WriteUncompressed(buffer, offset); Replacement.WriteUncompressed(buffer, offset);
return GetLength(); return GetLength();
...@@ -172,7 +176,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -172,7 +176,7 @@ namespace PcapDotNet.Packets.Dns
ushort order = dns.ReadUShort(offsetInDns + Offset.Order, Endianity.Big); ushort order = dns.ReadUShort(offsetInDns + Offset.Order, Endianity.Big);
ushort preference = dns.ReadUShort(offsetInDns + Offset.Preference, Endianity.Big); ushort preference = dns.ReadUShort(offsetInDns + Offset.Preference, Endianity.Big);
DataSegment data = dns.SubSegment(offsetInDns + ConstantPartLength, length - ConstantPartLength); DataSegment data = dns.Subsegment(offsetInDns + ConstantPartLength, length - ConstantPartLength);
int dataOffset = 0; int dataOffset = 0;
DataSegment flags = ReadString(data, ref dataOffset); DataSegment flags = ReadString(data, ref dataOffset);
......
using System; using System;
using System.Globalization;
using PcapDotNet.Base; using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
...@@ -22,7 +23,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -22,7 +23,7 @@ namespace PcapDotNet.Packets.Dns
/// DSP is Domain Specific Part. /// DSP is Domain Specific Part.
/// HO-DSP may use any format as defined by the authority identified by IDP. /// HO-DSP may use any format as defined by the authority identified by IDP.
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.Nsap)] [DnsTypeRegistration(Type = DnsType.NetworkServiceAccessPoint)]
public sealed class DnsResourceDataNetworkServiceAccessPoint : DnsResourceDataSimple, IEquatable<DnsResourceDataNetworkServiceAccessPoint> public sealed class DnsResourceDataNetworkServiceAccessPoint : DnsResourceDataSimple, IEquatable<DnsResourceDataNetworkServiceAccessPoint>
{ {
private static class Offset private static class Offset
...@@ -42,9 +43,13 @@ namespace PcapDotNet.Packets.Dns ...@@ -42,9 +43,13 @@ namespace PcapDotNet.Packets.Dns
public DnsResourceDataNetworkServiceAccessPoint(DataSegment areaAddress, UInt48 systemIdentifier, byte selector) public DnsResourceDataNetworkServiceAccessPoint(DataSegment areaAddress, UInt48 systemIdentifier, byte selector)
{ {
if (areaAddress == null)
throw new ArgumentNullException("areaAddress");
if (areaAddress.Length < MinAreaAddressLength) if (areaAddress.Length < MinAreaAddressLength)
throw new ArgumentOutOfRangeException("areaAddress", areaAddress.Length, throw new ArgumentOutOfRangeException("areaAddress", areaAddress.Length,
string.Format("Area Address length must be at least {0}.", MinAreaAddressLength)); string.Format(CultureInfo.InvariantCulture, "Area Address length must be at least {0}.",
MinAreaAddressLength));
AreaAddress = areaAddress; AreaAddress = areaAddress;
SystemIdentifier = systemIdentifier; SystemIdentifier = systemIdentifier;
Selector = selector; Selector = selector;
...@@ -114,7 +119,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -114,7 +119,7 @@ namespace PcapDotNet.Packets.Dns
if (data.Length < ConstantPartLength) if (data.Length < ConstantPartLength)
return null; return null;
DataSegment areaAddress = data.SubSegment(Offset.AreaAddress, MinAreaAddressLength + data.Length - ConstantPartLength); DataSegment areaAddress = data.Subsegment(Offset.AreaAddress, MinAreaAddressLength + data.Length - ConstantPartLength);
int afterAreaOffset = areaAddress.Length; int afterAreaOffset = areaAddress.Length;
UInt48 systemIdentifier = data.ReadUInt48(afterAreaOffset + OffsetAfterArea.SystemIdentifier, Endianity.Big); UInt48 systemIdentifier = data.ReadUInt48(afterAreaOffset + OffsetAfterArea.SystemIdentifier, Endianity.Big);
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
...@@ -20,18 +21,22 @@ namespace PcapDotNet.Packets.Dns ...@@ -20,18 +21,22 @@ namespace PcapDotNet.Packets.Dns
[DnsTypeRegistration(Type = DnsType.Nxt)] [DnsTypeRegistration(Type = DnsType.Nxt)]
public sealed class DnsResourceDataNextDomain : DnsResourceData, IEquatable<DnsResourceDataNextDomain> public sealed class DnsResourceDataNextDomain : DnsResourceData, IEquatable<DnsResourceDataNextDomain>
{ {
public const int MaxTypeBitMapLength = 16; public const int MaxTypeBitmapLength = 16;
public const DnsType MaxTypeBitMapDnsType = (DnsType)(8 * MaxTypeBitMapLength); public const DnsType MaxTypeBitmapDnsType = (DnsType)(8 * MaxTypeBitmapLength);
public DnsResourceDataNextDomain(DnsDomainName nextDomainName, DataSegment typeBitMap) public DnsResourceDataNextDomain(DnsDomainName nextDomainName, DataSegment typeBitmap)
{ {
if (typeBitMap.Length > MaxTypeBitMapLength) if (typeBitmap == null)
throw new ArgumentOutOfRangeException("typeBitMap", typeBitMap.Length, string.Format("Cannot be longer than {0} bytes.", MaxTypeBitMapLength)); throw new ArgumentNullException("typeBitmap");
if (typeBitMap.Length > 0 && typeBitMap.Last == 0)
throw new ArgumentOutOfRangeException("typeBitMap", typeBitMap, "Last byte cannot be 0x00"); if (typeBitmap.Length > MaxTypeBitmapLength)
throw new ArgumentOutOfRangeException("typeBitmap", typeBitmap.Length,
string.Format(CultureInfo.InvariantCulture, "Cannot be longer than {0} bytes.", MaxTypeBitmapLength));
if (typeBitmap.Length > 0 && typeBitmap.Last == 0)
throw new ArgumentOutOfRangeException("typeBitmap", typeBitmap, "Last byte cannot be 0x00");
NextDomainName = nextDomainName; NextDomainName = nextDomainName;
TypeBitMap = typeBitMap; TypeBitmap = typeBitmap;
} }
/// <summary> /// <summary>
...@@ -50,19 +55,19 @@ namespace PcapDotNet.Packets.Dns ...@@ -50,19 +55,19 @@ namespace PcapDotNet.Packets.Dns
/// This format is not used if there exists an RR with a type number greater than 127. /// This format is not used if there exists an RR with a type number greater than 127.
/// If the zero bit of the type bit map is a one, it indicates that a different format is being used which will always be the case if a type number greater than 127 is present. /// If the zero bit of the type bit map is a one, it indicates that a different format is being used which will always be the case if a type number greater than 127 is present.
/// </summary> /// </summary>
public DataSegment TypeBitMap { get; private set; } public DataSegment TypeBitmap { get; private set; }
public IEnumerable<DnsType> TypesExist public IEnumerable<DnsType> TypesExist
{ {
get get
{ {
ushort typeValue = 0; ushort typeValue = 0;
for (int byteOffset = 0; byteOffset != TypeBitMap.Length; ++byteOffset) for (int byteOffset = 0; byteOffset != TypeBitmap.Length; ++byteOffset)
{ {
byte mask = 0x80; byte mask = 0x80;
for (int i = 0; i != 8; ++i) for (int i = 0; i != 8; ++i)
{ {
if (TypeBitMap.ReadBool(byteOffset, mask)) if (TypeBitmap.ReadBool(byteOffset, mask))
yield return (DnsType)typeValue; yield return (DnsType)typeValue;
++typeValue; ++typeValue;
mask >>= 1; mask >>= 1;
...@@ -73,43 +78,47 @@ namespace PcapDotNet.Packets.Dns ...@@ -73,43 +78,47 @@ namespace PcapDotNet.Packets.Dns
public bool IsTypePresentForOwner(DnsType dnsType) public bool IsTypePresentForOwner(DnsType dnsType)
{ {
if (dnsType >= MaxTypeBitMapDnsType) if (dnsType >= MaxTypeBitmapDnsType)
throw new ArgumentOutOfRangeException("dnsType", dnsType, string.Format("Cannot be bigger than {0}.", MaxTypeBitMapDnsType)); throw new ArgumentOutOfRangeException("dnsType", dnsType,
string.Format(CultureInfo.InvariantCulture, "Cannot be bigger than {0}.", MaxTypeBitmapDnsType));
int byteOffset; int byteOffset;
byte mask; byte mask;
DnsTypeToByteOffsetAndMask(out byteOffset, out mask, dnsType); DnsTypeToByteOffsetAndMask(out byteOffset, out mask, dnsType);
if (byteOffset > TypeBitMap.Length) if (byteOffset > TypeBitmap.Length)
return false; return false;
return TypeBitMap.ReadBool(byteOffset, mask); return TypeBitmap.ReadBool(byteOffset, mask);
} }
public static DataSegment CreateTypeBitMap(IEnumerable<DnsType> typesPresentForOwner) public static DataSegment CreateTypeBitmap(IEnumerable<DnsType> typesPresentForOwner)
{ {
if (typesPresentForOwner == null)
throw new ArgumentNullException("typesPresentForOwner");
DnsType maxDnsType = typesPresentForOwner.Max(); DnsType maxDnsType = typesPresentForOwner.Max();
int length = (ushort)(maxDnsType + 7) / 8; int length = (ushort)(maxDnsType + 7) / 8;
if (length == 0) if (length == 0)
return DataSegment.Empty; return DataSegment.Empty;
byte[] typeBitMapBuffer = new byte[length]; byte[] typeBitmapBuffer = new byte[length];
foreach (DnsType dnsType in typesPresentForOwner) foreach (DnsType dnsType in typesPresentForOwner)
{ {
int byteOffset; int byteOffset;
byte mask; byte mask;
DnsTypeToByteOffsetAndMask(out byteOffset, out mask, dnsType); DnsTypeToByteOffsetAndMask(out byteOffset, out mask, dnsType);
typeBitMapBuffer[byteOffset] |= mask; typeBitmapBuffer[byteOffset] |= mask;
} }
return new DataSegment(typeBitMapBuffer); return new DataSegment(typeBitmapBuffer);
} }
public bool Equals(DnsResourceDataNextDomain other) public bool Equals(DnsResourceDataNextDomain other)
{ {
return other != null && return other != null &&
NextDomainName.Equals(other.NextDomainName) && NextDomainName.Equals(other.NextDomainName) &&
TypeBitMap.Equals(other.TypeBitMap); TypeBitmap.Equals(other.TypeBitmap);
} }
public override bool Equals(object other) public override bool Equals(object other)
...@@ -119,7 +128,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -119,7 +128,7 @@ namespace PcapDotNet.Packets.Dns
public override int GetHashCode() public override int GetHashCode()
{ {
return Sequence.GetHashCode(NextDomainName, TypeBitMap); return Sequence.GetHashCode(NextDomainName, TypeBitmap);
} }
internal DnsResourceDataNextDomain() internal DnsResourceDataNextDomain()
...@@ -129,15 +138,15 @@ namespace PcapDotNet.Packets.Dns ...@@ -129,15 +138,15 @@ namespace PcapDotNet.Packets.Dns
internal override int GetLength(DnsDomainNameCompressionData compressionData, int offsetInDns) internal override int GetLength(DnsDomainNameCompressionData compressionData, int offsetInDns)
{ {
return NextDomainName.GetLength(compressionData, offsetInDns) + TypeBitMap.Length; return NextDomainName.GetLength(compressionData, offsetInDns) + TypeBitmap.Length;
} }
internal override int WriteData(byte[] buffer, int dnsOffset, int offsetInDns, DnsDomainNameCompressionData compressionData) internal override int WriteData(byte[] buffer, int dnsOffset, int offsetInDns, DnsDomainNameCompressionData compressionData)
{ {
int numBytesWritten = NextDomainName.Write(buffer, dnsOffset, compressionData, offsetInDns); int numBytesWritten = NextDomainName.Write(buffer, dnsOffset, compressionData, offsetInDns);
TypeBitMap.Write(buffer, dnsOffset + offsetInDns + numBytesWritten); TypeBitmap.Write(buffer, dnsOffset + offsetInDns + numBytesWritten);
return numBytesWritten + TypeBitMap.Length; return numBytesWritten + TypeBitmap.Length;
} }
internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length) internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
...@@ -149,14 +158,14 @@ namespace PcapDotNet.Packets.Dns ...@@ -149,14 +158,14 @@ namespace PcapDotNet.Packets.Dns
offsetInDns += nextDomainNameLength; offsetInDns += nextDomainNameLength;
length -= nextDomainNameLength; length -= nextDomainNameLength;
if (length > MaxTypeBitMapLength) if (length > MaxTypeBitmapLength)
return null; return null;
DataSegment typeBitMap = dns.SubSegment(offsetInDns, length); DataSegment typeBitmap = dns.Subsegment(offsetInDns, length);
if (length != 0 && typeBitMap.Last == 0) if (length != 0 && typeBitmap.Last == 0)
return null; return null;
return new DnsResourceDataNextDomain(nextDomainName, typeBitMap); return new DnsResourceDataNextDomain(nextDomainName, typeBitmap);
} }
private static void DnsTypeToByteOffsetAndMask(out int byteOffset, out byte mask, DnsType dnsType) private static void DnsTypeToByteOffsetAndMask(out int byteOffset, out byte mask, DnsType dnsType)
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Globalization;
using PcapDotNet.Base; using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
...@@ -49,6 +50,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -49,6 +50,7 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public ReadOnlyCollection<DnsType> TypesExist { get { return _typeBitmaps.TypesExist.AsReadOnly(); } } public ReadOnlyCollection<DnsType> TypesExist { get { return _typeBitmaps.TypesExist.AsReadOnly(); } }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
public bool Equals(DnsResourceDataNextDomainSecure3 other) public bool Equals(DnsResourceDataNextDomainSecure3 other)
{ {
return EqualsParameters(other) && return EqualsParameters(other) &&
...@@ -100,7 +102,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -100,7 +102,7 @@ namespace PcapDotNet.Packets.Dns
int nextHashedOwnerNameLength = data[nextHashedOwnerNameLengthOffset]; int nextHashedOwnerNameLength = data[nextHashedOwnerNameLengthOffset];
if (data.Length - nextHashedOwnerNameOffset < nextHashedOwnerNameLength) if (data.Length - nextHashedOwnerNameOffset < nextHashedOwnerNameLength)
return null; return null;
DataSegment nextHashedOwnerName = data.SubSegment(nextHashedOwnerNameOffset, nextHashedOwnerNameLength); DataSegment nextHashedOwnerName = data.Subsegment(nextHashedOwnerNameOffset, nextHashedOwnerNameLength);
int typeBitmapsOffset = nextHashedOwnerNameOffset + nextHashedOwnerNameLength; int typeBitmapsOffset = nextHashedOwnerNameOffset + nextHashedOwnerNameLength;
DnsTypeBitmaps typeBitmaps = DnsTypeBitmaps.CreateInstance(data.Buffer, data.StartOffset + typeBitmapsOffset, data.Length - typeBitmapsOffset); DnsTypeBitmaps typeBitmaps = DnsTypeBitmaps.CreateInstance(data.Buffer, data.StartOffset + typeBitmapsOffset, data.Length - typeBitmapsOffset);
...@@ -115,7 +117,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -115,7 +117,8 @@ namespace PcapDotNet.Packets.Dns
: base(hashAlgorithm, flags, iterations, salt) : base(hashAlgorithm, flags, iterations, salt)
{ {
if (nextHashedOwnerName.Length > byte.MaxValue) if (nextHashedOwnerName.Length > byte.MaxValue)
throw new ArgumentOutOfRangeException("nextHashedOwnerName", nextHashedOwnerName.Length, string.Format("Cannot bigger than {0}.", byte.MaxValue)); throw new ArgumentOutOfRangeException("nextHashedOwnerName", nextHashedOwnerName.Length,
string.Format(CultureInfo.InvariantCulture, "Cannot bigger than {0}.", byte.MaxValue));
NextHashedOwnerName = nextHashedOwnerName; NextHashedOwnerName = nextHashedOwnerName;
_typeBitmaps = typeBitmaps; _typeBitmaps = typeBitmaps;
......
using System; using System;
using System.Globalization;
using PcapDotNet.Base; using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
...@@ -71,7 +72,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -71,7 +72,7 @@ namespace PcapDotNet.Packets.Dns
internal DnsResourceDataNextDomainSecure3Base(DnsSecNSec3HashAlgorithm hashAlgorithm, DnsSecNSec3Flags flags, ushort iterations, DataSegment salt) internal DnsResourceDataNextDomainSecure3Base(DnsSecNSec3HashAlgorithm hashAlgorithm, DnsSecNSec3Flags flags, ushort iterations, DataSegment salt)
{ {
if (salt.Length > byte.MaxValue) if (salt.Length > byte.MaxValue)
throw new ArgumentOutOfRangeException("salt", salt.Length, string.Format("Cannot bigger than {0}.", byte.MaxValue)); throw new ArgumentOutOfRangeException("salt", salt.Length, string.Format(CultureInfo.InvariantCulture, "Cannot bigger than {0}.", byte.MaxValue));
HashAlgorithm = hashAlgorithm; HashAlgorithm = hashAlgorithm;
Flags = flags; Flags = flags;
...@@ -116,7 +117,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -116,7 +117,7 @@ namespace PcapDotNet.Packets.Dns
salt = null; salt = null;
return false; return false;
} }
salt = data.SubSegment(Offset.Salt, saltLength); salt = data.Subsegment(Offset.Salt, saltLength);
return true; return true;
} }
} }
......
...@@ -16,7 +16,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -16,7 +16,7 @@ namespace PcapDotNet.Packets.Dns
/// +-----+----------------------------------------------+ /// +-----+----------------------------------------------+
/// </pre> /// </pre>
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.NSec3Param)] [DnsTypeRegistration(Type = DnsType.NSec3Parameters)]
public sealed class DnsResourceDataNextDomainSecure3Parameters : DnsResourceDataNextDomainSecure3Base, IEquatable<DnsResourceDataNextDomainSecure3Parameters> public sealed class DnsResourceDataNextDomainSecure3Parameters : DnsResourceDataNextDomainSecure3Base, IEquatable<DnsResourceDataNextDomainSecure3Parameters>
{ {
public DnsResourceDataNextDomainSecure3Parameters(DnsSecNSec3HashAlgorithm hashAlgorithm, DnsSecNSec3Flags flags, ushort iterations, DataSegment salt) public DnsResourceDataNextDomainSecure3Parameters(DnsSecNSec3HashAlgorithm hashAlgorithm, DnsSecNSec3Flags flags, ushort iterations, DataSegment salt)
......
...@@ -51,7 +51,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -51,7 +51,7 @@ namespace PcapDotNet.Packets.Dns
internal override int GetLength() internal override int GetLength()
{ {
return Options.NumBytes; return Options.BytesLength;
} }
internal override void WriteDataSimple(byte[] buffer, int offset) internal override void WriteDataSimple(byte[] buffer, int offset)
......
...@@ -102,7 +102,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -102,7 +102,7 @@ namespace PcapDotNet.Packets.Dns
ushort flags = data.ReadUShort(Offset.Flags, Endianity.Big); ushort flags = data.ReadUShort(Offset.Flags, Endianity.Big);
byte protocol = data[Offset.Protocol]; byte protocol = data[Offset.Protocol];
DnsAlgorithm algorithm = (DnsAlgorithm)data[Offset.Algorithm]; DnsAlgorithm algorithm = (DnsAlgorithm)data[Offset.Algorithm];
DataSegment publicKey = data.SubSegment(Offset.PublicKey, data.Length - ConstantPartLength); DataSegment publicKey = data.Subsegment(Offset.PublicKey, data.Length - ConstantPartLength);
return new DnsResourceDataRKey(flags, protocol, algorithm, publicKey); return new DnsResourceDataRKey(flags, protocol, algorithm, publicKey);
} }
......
...@@ -13,17 +13,17 @@ ...@@ -13,17 +13,17 @@
[DnsTypeRegistration(Type = DnsType.Rp)] [DnsTypeRegistration(Type = DnsType.Rp)]
public sealed class DnsResourceDataResponsiblePerson : DnsResourceData2DomainNames public sealed class DnsResourceDataResponsiblePerson : DnsResourceData2DomainNames
{ {
public DnsResourceDataResponsiblePerson(DnsDomainName mailBox, DnsDomainName textDomain) public DnsResourceDataResponsiblePerson(DnsDomainName mailbox, DnsDomainName textDomain)
: base(mailBox, textDomain) : base(mailbox, textDomain)
{ {
} }
/// <summary> /// <summary>
/// A domain name that specifies the mailbox for the responsible person. /// 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. /// 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. /// The root domain name (just ".") may be specified for Mailbox to indicate that no mailbox is available.
/// </summary> /// </summary>
public DnsDomainName MailBox { get { return First; } } public DnsDomainName Mailbox { get { return First; } }
/// <summary> /// <summary>
/// A domain name for which TXT RR's exist. /// A domain name for which TXT RR's exist.
...@@ -40,12 +40,12 @@ ...@@ -40,12 +40,12 @@
internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length) internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
{ {
DnsDomainName mailBox; DnsDomainName mailbox;
DnsDomainName textDomain; DnsDomainName textDomain;
if (!TryRead(out mailBox, out textDomain, dns, offsetInDns, length)) if (!TryRead(out mailbox, out textDomain, dns, offsetInDns, length))
return null; return null;
return new DnsResourceDataResponsiblePerson(mailBox, textDomain); return new DnsResourceDataResponsiblePerson(mailbox, textDomain);
} }
} }
} }
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
/// +-----+-------------------+ /// +-----+-------------------+
/// </pre> /// </pre>
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.Rt)] [DnsTypeRegistration(Type = DnsType.RouteThrough)]
public sealed class DnsResourceDataRouteThrough : DnsResourceDataUShortDomainName public sealed class DnsResourceDataRouteThrough : DnsResourceDataUShortDomainName
{ {
public DnsResourceDataRouteThrough(ushort preference, DnsDomainName intermediateHost) public DnsResourceDataRouteThrough(ushort preference, DnsDomainName intermediateHost)
......
...@@ -20,7 +20,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -20,7 +20,7 @@ namespace PcapDotNet.Packets.Dns
/// +-----+----------+ /// +-----+----------+
/// </pre> /// </pre>
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.Srv)] [DnsTypeRegistration(Type = DnsType.ServerSelection)]
public sealed class DnsResourceDataServerSelection : DnsResourceDataNoCompression, IEquatable<DnsResourceDataServerSelection> public sealed class DnsResourceDataServerSelection : DnsResourceDataNoCompression, IEquatable<DnsResourceDataServerSelection>
{ {
private static class Offset private static class Offset
......
...@@ -26,9 +26,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -26,9 +26,9 @@ namespace PcapDotNet.Packets.Dns
/// +-----+-----------------------------------+ /// +-----+-----------------------------------+
/// </pre> /// </pre>
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.Sig)] [DnsTypeRegistration(Type = DnsType.Signature)]
[DnsTypeRegistration(Type = DnsType.RrSig)] [DnsTypeRegistration(Type = DnsType.RrSignature)]
public sealed class DnsResourceDataSig : DnsResourceData, IEquatable<DnsResourceDataSig> public sealed class DnsResourceDataSignature : DnsResourceData, IEquatable<DnsResourceDataSignature>
{ {
private static class Offset private static class Offset
{ {
...@@ -44,7 +44,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -44,7 +44,7 @@ namespace PcapDotNet.Packets.Dns
private const int ConstantPartLength = Offset.SignersName; private const int ConstantPartLength = Offset.SignersName;
public DnsResourceDataSig(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)
{ {
TypeCovered = typeCovered; TypeCovered = typeCovered;
...@@ -139,7 +139,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -139,7 +139,7 @@ namespace PcapDotNet.Packets.Dns
/// </summary> /// </summary>
public DataSegment Signature { get; private set; } public DataSegment Signature { get; private set; }
public bool Equals(DnsResourceDataSig other) public bool Equals(DnsResourceDataSignature other)
{ {
return other != null && return other != null &&
TypeCovered.Equals(other.TypeCovered) && TypeCovered.Equals(other.TypeCovered) &&
...@@ -161,10 +161,10 @@ namespace PcapDotNet.Packets.Dns ...@@ -161,10 +161,10 @@ namespace PcapDotNet.Packets.Dns
public override bool Equals(object other) public override bool Equals(object other)
{ {
return Equals(other as DnsResourceDataSig); return Equals(other as DnsResourceDataSignature);
} }
internal DnsResourceDataSig() internal DnsResourceDataSignature()
: this(DnsType.A, DnsAlgorithm.None, 0, 0, 0, 0, 0, DnsDomainName.Root, DataSegment.Empty) : this(DnsType.A, DnsAlgorithm.None, 0, 0, 0, 0, 0, DnsDomainName.Root, DataSegment.Empty)
{ {
} }
...@@ -214,9 +214,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -214,9 +214,9 @@ namespace PcapDotNet.Packets.Dns
offsetInDns += signersNameLength; offsetInDns += signersNameLength;
length -= signersNameLength; length -= signersNameLength;
DataSegment signature = dns.SubSegment(offsetInDns, length); DataSegment signature = dns.Subsegment(offsetInDns, length);
return new DnsResourceDataSig(typeCovered, algorithm, labels, originalTtl, signatureExpiration, signatureInception, keyTag, signersName, signature); return new DnsResourceDataSignature(typeCovered, algorithm, labels, originalTtl, signatureExpiration, signatureInception, keyTag, signersName, signature);
} }
} }
} }
\ No newline at end of file
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
internal sealed override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length) internal sealed override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
{ {
return CreateInstance(dns.SubSegment(offsetInDns, length)); return CreateInstance(dns.Subsegment(offsetInDns, length));
} }
internal abstract DnsResourceData CreateInstance(DataSegment data); internal abstract DnsResourceData CreateInstance(DataSegment data);
......
...@@ -28,8 +28,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -28,8 +28,8 @@ namespace PcapDotNet.Packets.Dns
public const int ConstantPartLength = Offset.Data; public const int ConstantPartLength = Offset.Data;
public DnsResourceDataSink(DnsSinkCodingSubcoding codingSubcoding, DataSegment data) public DnsResourceDataSink(DnsSinkCodingSubCoding codingSubCoding, DataSegment data)
: this((DnsSinkCoding)((ushort)codingSubcoding >> 8), (byte)((ushort)codingSubcoding & 0x00FF), data) : this((DnsSinkCoding)((ushort)codingSubCoding >> 8), (byte)((ushort)codingSubCoding & 0x00FF), data)
{ {
} }
...@@ -54,12 +54,12 @@ namespace PcapDotNet.Packets.Dns ...@@ -54,12 +54,12 @@ namespace PcapDotNet.Packets.Dns
/// Returns a combination of coding and subcoding. /// Returns a combination of coding and subcoding.
/// Has a valid enum value if the subcoding is defined specifically for the coding. /// Has a valid enum value if the subcoding is defined specifically for the coding.
/// </summary> /// </summary>
public DnsSinkCodingSubcoding CodingSubcoding public DnsSinkCodingSubCoding CodingSubCoding
{ {
get get
{ {
ushort codingSubcoding = BitSequence.Merge((byte)Coding, Subcoding); ushort codingSubcoding = BitSequence.Merge((byte)Coding, Subcoding);
return (DnsSinkCodingSubcoding)codingSubcoding; return (DnsSinkCodingSubCoding)codingSubcoding;
} }
} }
...@@ -83,11 +83,11 @@ namespace PcapDotNet.Packets.Dns ...@@ -83,11 +83,11 @@ namespace PcapDotNet.Packets.Dns
public override int GetHashCode() public override int GetHashCode()
{ {
return Sequence.GetHashCode(CodingSubcoding, Data); return Sequence.GetHashCode(CodingSubCoding, Data);
} }
internal DnsResourceDataSink() internal DnsResourceDataSink()
: this(DnsSinkCodingSubcoding.Asn1SnmpBer, DataSegment.Empty) : this(DnsSinkCodingSubCoding.Asn1SnmpBasicEncodingRules, DataSegment.Empty)
{ {
} }
...@@ -110,7 +110,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -110,7 +110,7 @@ namespace PcapDotNet.Packets.Dns
DnsSinkCoding coding = (DnsSinkCoding)data[Offset.Coding]; DnsSinkCoding coding = (DnsSinkCoding)data[Offset.Coding];
byte subcoding = data[Offset.Subcoding]; byte subcoding = data[Offset.Subcoding];
DataSegment dataValue = data.SubSegment(Offset.Data, data.Length - ConstantPartLength); DataSegment dataValue = data.Subsegment(Offset.Data, data.Length - ConstantPartLength);
return new DnsResourceDataSink(coding, subcoding, dataValue); return new DnsResourceDataSink(coding, subcoding, dataValue);
} }
......
...@@ -16,10 +16,10 @@ namespace PcapDotNet.Packets.Dns ...@@ -16,10 +16,10 @@ namespace PcapDotNet.Packets.Dns
/// +-----+-----------------------+ /// +-----+-----------------------+
/// </pre> /// </pre>
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.SshFp)] [DnsTypeRegistration(Type = DnsType.SshFingerprint)]
public sealed class DnsResourceDataSshFingerprint : DnsResourceDataSimple, IEquatable<DnsResourceDataSshFingerprint> public sealed class DnsResourceDataSshFingerprint : DnsResourceDataSimple, IEquatable<DnsResourceDataSshFingerprint>
{ {
public static class Offset private static class Offset
{ {
public const int Algorithm = 0; public const int Algorithm = 0;
public const int FingerprintType = Algorithm + sizeof(byte); public const int FingerprintType = Algorithm + sizeof(byte);
...@@ -90,7 +90,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -90,7 +90,7 @@ namespace PcapDotNet.Packets.Dns
{ {
DnsFingerprintPublicKeyAlgorithm algorithm = (DnsFingerprintPublicKeyAlgorithm)data[Offset.Algorithm]; DnsFingerprintPublicKeyAlgorithm algorithm = (DnsFingerprintPublicKeyAlgorithm)data[Offset.Algorithm];
DnsFingerprintType fingerprintType = (DnsFingerprintType)data[Offset.FingerprintType]; DnsFingerprintType fingerprintType = (DnsFingerprintType)data[Offset.FingerprintType];
DataSegment fingerprint = data.SubSegment(Offset.Fingerprint, data.Length - ConstPartLength); DataSegment fingerprint = data.Subsegment(Offset.Fingerprint, data.Length - ConstPartLength);
return new DnsResourceDataSshFingerprint(algorithm, fingerprintType, fingerprint); return new DnsResourceDataSshFingerprint(algorithm, fingerprintType, fingerprint);
} }
......
...@@ -27,7 +27,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -27,7 +27,7 @@ namespace PcapDotNet.Packets.Dns
/// +-------+---------+ /// +-------+---------+
/// </pre> /// </pre>
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.Soa)] [DnsTypeRegistration(Type = DnsType.StartOfAuthority)]
public sealed class DnsResourceDataStartOfAuthority : DnsResourceData, IEquatable<DnsResourceDataStartOfAuthority> public sealed class DnsResourceDataStartOfAuthority : DnsResourceData, IEquatable<DnsResourceDataStartOfAuthority>
{ {
private static class Offset private static class Offset
...@@ -41,11 +41,11 @@ namespace PcapDotNet.Packets.Dns ...@@ -41,11 +41,11 @@ namespace PcapDotNet.Packets.Dns
private const int ConstantPartLength = Offset.MinimumTtl + sizeof(uint); private const int ConstantPartLength = Offset.MinimumTtl + sizeof(uint);
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)
{ {
MainNameServer = mainNameServer; MainNameServer = mainNameServer;
ResponsibleMailBox = responsibleMailBox; ResponsibleMailbox = responsibleMailbox;
Serial = serial; Serial = serial;
Refresh = refresh; Refresh = refresh;
Retry = retry; Retry = retry;
...@@ -61,7 +61,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -61,7 +61,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary> /// <summary>
/// A domain-name which specifies the mailbox of the person responsible for this zone. /// A domain-name which specifies the mailbox of the person responsible for this zone.
/// </summary> /// </summary>
public DnsDomainName ResponsibleMailBox { get; private set; } public DnsDomainName ResponsibleMailbox { get; private set; }
/// <summary> /// <summary>
/// The unsigned 32 bit version number of the original copy of the zone. /// The unsigned 32 bit version number of the original copy of the zone.
...@@ -94,7 +94,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -94,7 +94,7 @@ namespace PcapDotNet.Packets.Dns
{ {
return other != null && return other != null &&
MainNameServer.Equals(other.MainNameServer) && MainNameServer.Equals(other.MainNameServer) &&
ResponsibleMailBox.Equals(other.ResponsibleMailBox) && ResponsibleMailbox.Equals(other.ResponsibleMailbox) &&
Serial.Equals(other.Serial) && Serial.Equals(other.Serial) &&
Refresh.Equals(other.Refresh) && Refresh.Equals(other.Refresh) &&
Retry.Equals(other.Retry) && Retry.Equals(other.Retry) &&
...@@ -104,7 +104,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -104,7 +104,7 @@ namespace PcapDotNet.Packets.Dns
public override int GetHashCode() public override int GetHashCode()
{ {
return Sequence.GetHashCode(MainNameServer, ResponsibleMailBox, Serial, Refresh, Retry, Expire, MinimumTtl); return Sequence.GetHashCode(MainNameServer, ResponsibleMailbox, Serial, Refresh, Retry, Expire, MinimumTtl);
} }
public override bool Equals(object other) public override bool Equals(object other)
...@@ -120,14 +120,14 @@ namespace PcapDotNet.Packets.Dns ...@@ -120,14 +120,14 @@ namespace PcapDotNet.Packets.Dns
internal override int GetLength(DnsDomainNameCompressionData compressionData, int offsetInDns) internal override int GetLength(DnsDomainNameCompressionData compressionData, int offsetInDns)
{ {
return MainNameServer.GetLength(compressionData, offsetInDns) + return MainNameServer.GetLength(compressionData, offsetInDns) +
ResponsibleMailBox.GetLength(compressionData, offsetInDns) + ResponsibleMailbox.GetLength(compressionData, offsetInDns) +
ConstantPartLength; ConstantPartLength;
} }
internal override int WriteData(byte[] buffer, int dnsOffset, int offsetInDns, DnsDomainNameCompressionData compressionData) internal override int WriteData(byte[] buffer, int dnsOffset, int offsetInDns, DnsDomainNameCompressionData compressionData)
{ {
int numBytesWritten = MainNameServer.Write(buffer, dnsOffset, compressionData, offsetInDns); int numBytesWritten = MainNameServer.Write(buffer, dnsOffset, compressionData, offsetInDns);
numBytesWritten += ResponsibleMailBox.Write(buffer, dnsOffset, compressionData, offsetInDns + numBytesWritten); numBytesWritten += ResponsibleMailbox.Write(buffer, dnsOffset, compressionData, offsetInDns + numBytesWritten);
buffer.Write(dnsOffset + offsetInDns + numBytesWritten + Offset.Serial, Serial.Value, Endianity.Big); buffer.Write(dnsOffset + offsetInDns + numBytesWritten + Offset.Serial, Serial.Value, Endianity.Big);
buffer.Write(dnsOffset + offsetInDns + numBytesWritten + Offset.Refresh, Refresh, Endianity.Big); buffer.Write(dnsOffset + offsetInDns + numBytesWritten + Offset.Refresh, Refresh, Endianity.Big);
buffer.Write(dnsOffset + offsetInDns + numBytesWritten + Offset.Retry, Retry, Endianity.Big); buffer.Write(dnsOffset + offsetInDns + numBytesWritten + Offset.Retry, Retry, Endianity.Big);
...@@ -146,8 +146,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -146,8 +146,8 @@ namespace PcapDotNet.Packets.Dns
offsetInDns += domainNameLength; offsetInDns += domainNameLength;
length -= domainNameLength; length -= domainNameLength;
DnsDomainName responsibleMailBox; DnsDomainName responsibleMailbox;
if (!DnsDomainName.TryParse(dns, offsetInDns, length, out responsibleMailBox, out domainNameLength)) if (!DnsDomainName.TryParse(dns, offsetInDns, length, out responsibleMailbox, out domainNameLength))
return null; return null;
offsetInDns += domainNameLength; offsetInDns += domainNameLength;
length -= domainNameLength; length -= domainNameLength;
...@@ -161,7 +161,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -161,7 +161,7 @@ namespace PcapDotNet.Packets.Dns
uint expire = dns.ReadUInt(offsetInDns + Offset.Expire, Endianity.Big); ; uint expire = dns.ReadUInt(offsetInDns + Offset.Expire, Endianity.Big); ;
uint minimumTtl = dns.ReadUInt(offsetInDns + Offset.MinimumTtl, Endianity.Big); ; uint minimumTtl = dns.ReadUInt(offsetInDns + Offset.MinimumTtl, Endianity.Big); ;
return new DnsResourceDataStartOfAuthority(mainNameServer, responsibleMailBox, serial, refresh, retry, expire, minimumTtl); return new DnsResourceDataStartOfAuthority(mainNameServer, responsibleMailbox, serial, refresh, retry, expire, minimumTtl);
} }
} }
} }
\ No newline at end of file
using System; using System;
using System.Globalization;
using PcapDotNet.Base; using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
...@@ -46,10 +47,17 @@ namespace PcapDotNet.Packets.Dns ...@@ -46,10 +47,17 @@ namespace PcapDotNet.Packets.Dns
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)
{ {
if (key == null)
throw new ArgumentNullException("key");
if (other == null)
throw new ArgumentNullException("other");
if (key.Length > ushort.MaxValue) if (key.Length > ushort.MaxValue)
throw new ArgumentOutOfRangeException("key", key.Length, string.Format("Cannot be longer than {0}", ushort.MaxValue)); throw new ArgumentOutOfRangeException("key", key.Length,
string.Format(CultureInfo.InvariantCulture, "Cannot be longer than {0}", ushort.MaxValue));
if (other.Length > ushort.MaxValue) if (other.Length > ushort.MaxValue)
throw new ArgumentOutOfRangeException("other", other.Length, string.Format("Cannot be longer than {0}", ushort.MaxValue)); throw new ArgumentOutOfRangeException("other", other.Length,
string.Format(CultureInfo.InvariantCulture, "Cannot be longer than {0}", ushort.MaxValue));
Algorithm = algorithm; Algorithm = algorithm;
Inception = inception; Inception = inception;
...@@ -188,7 +196,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -188,7 +196,7 @@ namespace PcapDotNet.Packets.Dns
int keySize = dns.ReadUShort(offsetInDns + OffsetAfterAlgorithm.KeySize, Endianity.Big); int keySize = dns.ReadUShort(offsetInDns + OffsetAfterAlgorithm.KeySize, Endianity.Big);
if (length < ConstantPartLength + keySize) if (length < ConstantPartLength + keySize)
return null; return null;
DataSegment key = dns.SubSegment(offsetInDns + OffsetAfterAlgorithm.KeyData, keySize); DataSegment key = dns.Subsegment(offsetInDns + OffsetAfterAlgorithm.KeyData, keySize);
int totalReadAfterAlgorithm = OffsetAfterAlgorithm.KeyData + keySize; int totalReadAfterAlgorithm = OffsetAfterAlgorithm.KeyData + keySize;
offsetInDns += totalReadAfterAlgorithm; offsetInDns += totalReadAfterAlgorithm;
...@@ -196,7 +204,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -196,7 +204,7 @@ namespace PcapDotNet.Packets.Dns
int otherSize = dns.ReadUShort(offsetInDns, Endianity.Big); int otherSize = dns.ReadUShort(offsetInDns, Endianity.Big);
if (length != sizeof(ushort) + otherSize) if (length != sizeof(ushort) + otherSize)
return null; return null;
DataSegment other = dns.SubSegment(offsetInDns + sizeof(ushort), otherSize); DataSegment other = dns.Subsegment(offsetInDns + sizeof(ushort), otherSize);
return new DnsResourceDataTransactionKey(algorithm, inception, expiration, mode, error, key, other); return new DnsResourceDataTransactionKey(algorithm, inception, expiration, mode, error, key, other);
} }
......
using System; using System;
using System.Globalization;
using PcapDotNet.Base; using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns namespace PcapDotNet.Packets.Dns
...@@ -24,9 +25,8 @@ namespace PcapDotNet.Packets.Dns ...@@ -24,9 +25,8 @@ namespace PcapDotNet.Packets.Dns
/// | ... | | /// | ... | |
/// +------+------------------------------------+ /// +------+------------------------------------+
/// </pre> /// </pre>
/// //
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.TSig)] [DnsTypeRegistration(Type = DnsType.TransactionSignature)]
public sealed class DnsResourceDataTransactionSignature : DnsResourceData, IEquatable<DnsResourceDataTransactionSignature> public sealed class DnsResourceDataTransactionSignature : DnsResourceData, IEquatable<DnsResourceDataTransactionSignature>
{ {
private static class OffsetAfterAlgorithm private static class OffsetAfterAlgorithm
...@@ -50,10 +50,17 @@ namespace PcapDotNet.Packets.Dns ...@@ -50,10 +50,17 @@ namespace PcapDotNet.Packets.Dns
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)
{ {
if (messageAuthenticationCode == null)
throw new ArgumentNullException("messageAuthenticationCode");
if (other == null)
throw new ArgumentNullException("other");
if (messageAuthenticationCode.Length > ushort.MaxValue) if (messageAuthenticationCode.Length > ushort.MaxValue)
throw new ArgumentOutOfRangeException("messageAuthenticationCode", messageAuthenticationCode.Length, string.Format("Cannot be longer than {0}", ushort.MaxValue)); throw new ArgumentOutOfRangeException("messageAuthenticationCode", messageAuthenticationCode.Length,
string.Format(CultureInfo.InvariantCulture, "Cannot be longer than {0}", ushort.MaxValue));
if (other.Length > ushort.MaxValue) if (other.Length > ushort.MaxValue)
throw new ArgumentOutOfRangeException("other", other.Length, string.Format("Cannot be longer than {0}", ushort.MaxValue)); throw new ArgumentOutOfRangeException("other", other.Length,
string.Format(CultureInfo.InvariantCulture, "Cannot be longer than {0}", ushort.MaxValue));
Algorithm = algorithm; Algorithm = algorithm;
TimeSigned = timeSigned; TimeSigned = timeSigned;
...@@ -169,7 +176,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -169,7 +176,7 @@ namespace PcapDotNet.Packets.Dns
int messageAuthenticationCodeLength = dns.ReadUShort(offsetInDns + OffsetAfterAlgorithm.MessageAuthenticationCodeSize, Endianity.Big); int messageAuthenticationCodeLength = dns.ReadUShort(offsetInDns + OffsetAfterAlgorithm.MessageAuthenticationCodeSize, Endianity.Big);
if (length < ConstantPartLength + messageAuthenticationCodeLength) if (length < ConstantPartLength + messageAuthenticationCodeLength)
return null; return null;
DataSegment messageAuthenticationCode = dns.SubSegment(offsetInDns + OffsetAfterAlgorithm.MessageAuthenticationCode, messageAuthenticationCodeLength); DataSegment messageAuthenticationCode = dns.Subsegment(offsetInDns + OffsetAfterAlgorithm.MessageAuthenticationCode, messageAuthenticationCodeLength);
int totalReadAfterAlgorithm = OffsetAfterAlgorithm.MessageAuthenticationCode + messageAuthenticationCodeLength; int totalReadAfterAlgorithm = OffsetAfterAlgorithm.MessageAuthenticationCode + messageAuthenticationCodeLength;
offsetInDns += totalReadAfterAlgorithm; offsetInDns += totalReadAfterAlgorithm;
length -= totalReadAfterAlgorithm; length -= totalReadAfterAlgorithm;
...@@ -179,7 +186,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -179,7 +186,7 @@ namespace PcapDotNet.Packets.Dns
int otherLength = dns.ReadUShort(offsetInDns + OffsetAfterMessageAuthenticationCode.OtherLength, Endianity.Big); int otherLength = dns.ReadUShort(offsetInDns + OffsetAfterMessageAuthenticationCode.OtherLength, Endianity.Big);
if (length != OffsetAfterMessageAuthenticationCode.OtherData + otherLength) if (length != OffsetAfterMessageAuthenticationCode.OtherData + otherLength)
return null; return null;
DataSegment other = dns.SubSegment(offsetInDns + OffsetAfterMessageAuthenticationCode.OtherData, otherLength); DataSegment other = dns.Subsegment(offsetInDns + OffsetAfterMessageAuthenticationCode.OtherData, otherLength);
return new DnsResourceDataTransactionSignature(algorithm, timeSigned, fudge, messageAuthenticationCode, originalId, error, other); return new DnsResourceDataTransactionSignature(algorithm, timeSigned, fudge, messageAuthenticationCode, originalId, error, other);
} }
......
...@@ -23,16 +23,16 @@ namespace PcapDotNet.Packets.Dns ...@@ -23,16 +23,16 @@ namespace PcapDotNet.Packets.Dns
{ {
public const int Address = 0; public const int Address = 0;
public const int Protocol = Address + IpV4Address.SizeOf; public const int Protocol = Address + IpV4Address.SizeOf;
public const int BitMap = Protocol + sizeof(byte); public const int Bitmap = Protocol + sizeof(byte);
} }
private const int ConstantPartLength = Offset.BitMap; private const int ConstantPartLength = Offset.Bitmap;
public DnsResourceDataWellKnownService(IpV4Address address, IpV4Protocol protocol, DataSegment bitMap) public DnsResourceDataWellKnownService(IpV4Address address, IpV4Protocol protocol, DataSegment bitmap)
{ {
Address = address; Address = address;
Protocol = protocol; Protocol = protocol;
BitMap = bitMap; Bitmap = bitmap;
} }
/// <summary> /// <summary>
...@@ -48,14 +48,14 @@ namespace PcapDotNet.Packets.Dns ...@@ -48,14 +48,14 @@ namespace PcapDotNet.Packets.Dns
/// <summary> /// <summary>
/// Has one bit per port of the specified protocol. /// Has one bit per port of the specified protocol.
/// </summary> /// </summary>
public DataSegment BitMap { get; private set; } public DataSegment Bitmap { get; private set; }
public bool Equals(DnsResourceDataWellKnownService other) public bool Equals(DnsResourceDataWellKnownService other)
{ {
return other != null && return other != null &&
Address.Equals(other.Address) && Address.Equals(other.Address) &&
Protocol.Equals(other.Protocol) && Protocol.Equals(other.Protocol) &&
BitMap.Equals(other.BitMap); Bitmap.Equals(other.Bitmap);
} }
public override bool Equals(object other) public override bool Equals(object other)
...@@ -65,7 +65,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -65,7 +65,7 @@ namespace PcapDotNet.Packets.Dns
public override int GetHashCode() public override int GetHashCode()
{ {
return Sequence.GetHashCode(Address, Protocol, BitMap); return Sequence.GetHashCode(Address, Protocol, Bitmap);
} }
internal DnsResourceDataWellKnownService() internal DnsResourceDataWellKnownService()
...@@ -75,14 +75,14 @@ namespace PcapDotNet.Packets.Dns ...@@ -75,14 +75,14 @@ namespace PcapDotNet.Packets.Dns
internal override int GetLength() internal override int GetLength()
{ {
return ConstantPartLength + BitMap.Length; return ConstantPartLength + Bitmap.Length;
} }
internal override void WriteDataSimple(byte[] buffer, int offset) internal override void WriteDataSimple(byte[] buffer, int offset)
{ {
buffer.Write(offset + Offset.Address, Address, Endianity.Big); buffer.Write(offset + Offset.Address, Address, Endianity.Big);
buffer.Write(offset + Offset.Protocol, (byte)Protocol); buffer.Write(offset + Offset.Protocol, (byte)Protocol);
BitMap.Write(buffer, offset + Offset.BitMap); Bitmap.Write(buffer, offset + Offset.Bitmap);
} }
internal override DnsResourceData CreateInstance(DataSegment data) internal override DnsResourceData CreateInstance(DataSegment data)
...@@ -92,9 +92,9 @@ namespace PcapDotNet.Packets.Dns ...@@ -92,9 +92,9 @@ namespace PcapDotNet.Packets.Dns
IpV4Address address = data.ReadIpV4Address(Offset.Address, Endianity.Big); IpV4Address address = data.ReadIpV4Address(Offset.Address, Endianity.Big);
IpV4Protocol protocol = (IpV4Protocol)data[Offset.Protocol]; IpV4Protocol protocol = (IpV4Protocol)data[Offset.Protocol];
DataSegment bitMap = data.SubSegment(Offset.BitMap, data.Length - Offset.BitMap); DataSegment bitmap = data.Subsegment(Offset.Bitmap, data.Length - Offset.Bitmap);
return new DnsResourceDataWellKnownService(address, protocol, bitMap); return new DnsResourceDataWellKnownService(address, protocol, bitmap);
} }
} }
} }
\ No newline at end of file
...@@ -19,7 +19,7 @@ namespace PcapDotNet.Packets.Dns ...@@ -19,7 +19,7 @@ namespace PcapDotNet.Packets.Dns
/// +-----+------------+ /// +-----+------------+
/// </pre> /// </pre>
/// </summary> /// </summary>
[DnsTypeRegistration(Type = DnsType.Px)] [DnsTypeRegistration(Type = DnsType.PointerX400)]
public sealed class DnsResourceDataX400Pointer : DnsResourceData, IEquatable<DnsResourceDataX400Pointer> public sealed class DnsResourceDataX400Pointer : DnsResourceData, IEquatable<DnsResourceDataX400Pointer>
{ {
private static class Offset private static class Offset
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
/// </summary> /// </summary>
public enum DnsSecNSec3HashAlgorithm : byte public enum DnsSecNSec3HashAlgorithm : byte
{ {
None = 0x00,
/// <summary> /// <summary>
/// RFC 5155. /// RFC 5155.
/// </summary> /// </summary>
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
/// </summary> /// </summary>
public enum DnsSinkCoding : byte public enum DnsSinkCoding : byte
{ {
None = 0x00,
/// <summary> /// <summary>
/// The SNMP subset of ASN.1. /// The SNMP subset of ASN.1.
/// </summary> /// </summary>
......
...@@ -3,19 +3,21 @@ ...@@ -3,19 +3,21 @@
/// <summary> /// <summary>
/// Eastlake. /// Eastlake.
/// </summary> /// </summary>
public enum DnsSinkCodingSubcoding : ushort public enum DnsSinkCodingSubCoding : ushort
{ {
None = 0x0000,
/// <summary> /// <summary>
/// The SNMP subset of ASN.1. /// The SNMP subset of ASN.1.
/// Basic Encoding Rules. /// Basic Encoding Rules.
/// </summary> /// </summary>
Asn1SnmpBer = 0x0101, Asn1SnmpBasicEncodingRules = 0x0101,
/// <summary> /// <summary>
/// The SNMP subset of ASN.1. /// The SNMP subset of ASN.1.
/// Distinguished Encoding Rules. /// Distinguished Encoding Rules.
/// </summary> /// </summary>
Asn1SnmpDer = 0x0102, Asn1SnmpDistinguishedEncodingRules = 0x0102,
/// <summary> /// <summary>
/// The SNMP subset of ASN.1. /// The SNMP subset of ASN.1.
...@@ -33,7 +35,7 @@ ...@@ -33,7 +35,7 @@
/// The SNMP subset of ASN.1. /// The SNMP subset of ASN.1.
/// Canonical Encoding Rules. /// Canonical Encoding Rules.
/// </summary> /// </summary>
Asn1SnmpCer = 0x0105, Asn1SnmpCanonicalEncodingRules = 0x0105,
/// <summary> /// <summary>
/// The SNMP subset of ASN.1. /// The SNMP subset of ASN.1.
...@@ -45,13 +47,13 @@ ...@@ -45,13 +47,13 @@
/// OSI ASN.1 1990 [ASN.1]. /// OSI ASN.1 1990 [ASN.1].
/// Basic Encoding Rules. /// Basic Encoding Rules.
/// </summary> /// </summary>
Asn1Osi1990Ber = 0x0201, Asn1Osi1990BasicEncodingRules = 0x0201,
/// <summary> /// <summary>
/// OSI ASN.1 1990 [ASN.1]. /// OSI ASN.1 1990 [ASN.1].
/// Distinguished Encoding Rules. /// Distinguished Encoding Rules.
/// </summary> /// </summary>
Asn1Osi1990Der = 0x0202, Asn1Osi1990DistinguishedEncodingRules = 0x0202,
/// <summary> /// <summary>
/// OSI ASN.1 1990 [ASN.1]. /// OSI ASN.1 1990 [ASN.1].
...@@ -69,7 +71,7 @@ ...@@ -69,7 +71,7 @@
/// OSI ASN.1 1990 [ASN.1]. /// OSI ASN.1 1990 [ASN.1].
/// Canonical Encoding Rules. /// Canonical Encoding Rules.
/// </summary> /// </summary>
Asn1Osi1990Cer = 0x0205, Asn1Osi1990CanonicalEncodingRules = 0x0205,
/// <summary> /// <summary>
/// OSI ASN.1 1990 [ASN.1]. /// OSI ASN.1 1990 [ASN.1].
...@@ -81,13 +83,13 @@ ...@@ -81,13 +83,13 @@
/// OSI ASN.1 1994. /// OSI ASN.1 1994.
/// Basic Encoding Rules. /// Basic Encoding Rules.
/// </summary> /// </summary>
Asn1Osi1994Ber = 0x0301, Asn1Osi1994BasicEncodingRules = 0x0301,
/// <summary> /// <summary>
/// OSI ASN.1 1994. /// OSI ASN.1 1994.
/// Distinguished Encoding Rules. /// Distinguished Encoding Rules.
/// </summary> /// </summary>
Asn1Osi1994Der = 0x0302, Asn1Osi1994DistinguishedEncodingRules = 0x0302,
/// <summary> /// <summary>
/// OSI ASN.1 1994. /// OSI ASN.1 1994.
...@@ -105,7 +107,7 @@ ...@@ -105,7 +107,7 @@
/// OSI ASN.1 1994. /// OSI ASN.1 1994.
/// Canonical Encoding Rules. /// Canonical Encoding Rules.
/// </summary> /// </summary>
Asn1Osi1994Cer = 0x0305, Asn1Osi1994CanonicalEncodingRules = 0x0305,
/// <summary> /// <summary>
/// OSI ASN.1 1994. /// OSI ASN.1 1994.
...@@ -119,7 +121,7 @@ ...@@ -119,7 +121,7 @@
/// An OSI Object Identifier (OID) preceded by a one byte unsigned length appears at the beginning of the data area to indicate which private abstract syntax is being used. /// An OSI Object Identifier (OID) preceded by a one byte unsigned length appears at the beginning of the data area to indicate which private abstract syntax is being used.
/// Basic Encoding Rules. /// Basic Encoding Rules.
/// </summary> /// </summary>
AsnPrivateBer = 0x3F01, AsnPrivateBasicEncodingRules = 0x3F01,
/// <summary> /// <summary>
/// Private abstract syntax notations. /// Private abstract syntax notations.
...@@ -127,7 +129,7 @@ ...@@ -127,7 +129,7 @@
/// An OSI Object Identifier (OID) preceded by a one byte unsigned length appears at the beginning of the data area to indicate which private abstract syntax is being used. /// An OSI Object Identifier (OID) preceded by a one byte unsigned length appears at the beginning of the data area to indicate which private abstract syntax is being used.
/// Distinguished Encoding Rules. /// Distinguished Encoding Rules.
/// </summary> /// </summary>
AsnPrivateDer = 0x3F02, AsnPrivateDistinguishedEncodingRules = 0x3F02,
/// <summary> /// <summary>
/// Private abstract syntax notations. /// Private abstract syntax notations.
...@@ -151,7 +153,7 @@ ...@@ -151,7 +153,7 @@
/// An OSI Object Identifier (OID) preceded by a one byte unsigned length appears at the beginning of the data area to indicate which private abstract syntax is being used. /// An OSI Object Identifier (OID) preceded by a one byte unsigned length appears at the beginning of the data area to indicate which private abstract syntax is being used.
/// Canonical Encoding Rules. /// Canonical Encoding Rules.
/// </summary> /// </summary>
AsnPrivateCer = 0x3F05, AsnPrivateCanonicalEncodingRules = 0x3F05,
/// <summary> /// <summary>
/// Private abstract syntax notations. /// Private abstract syntax notations.
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
/// </summary> /// </summary>
public enum DnsTransactionKeyMode : ushort public enum DnsTransactionKeyMode : ushort
{ {
None = 0,
/// <summary> /// <summary>
/// RFC 2930. /// RFC 2930.
/// </summary> /// </summary>
......
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
<Compile Include="Dns\ResourceData\DnsResourceData2DomainNames.cs" /> <Compile Include="Dns\ResourceData\DnsResourceData2DomainNames.cs" />
<Compile Include="Dns\ResourceData\DnsResourceDataA6.cs" /> <Compile Include="Dns\ResourceData\DnsResourceDataA6.cs" />
<Compile Include="Dns\ResourceData\DnsResourceDataAddressPrefixList.cs" /> <Compile Include="Dns\ResourceData\DnsResourceDataAddressPrefixList.cs" />
<Compile Include="Dns\ResourceData\DnsResourceDataAfsDb.cs" /> <Compile Include="Dns\ResourceData\DnsResourceDataAfsDatabase.cs" />
<Compile Include="Dns\ResourceData\DnsResourceDataAnything.cs" /> <Compile Include="Dns\ResourceData\DnsResourceDataAnything.cs" />
<Compile Include="Dns\DnsResourceRecord.cs" /> <Compile Include="Dns\DnsResourceRecord.cs" />
<Compile Include="Dns\DnsResponseCode.cs" /> <Compile Include="Dns\DnsResponseCode.cs" />
...@@ -175,7 +175,7 @@ ...@@ -175,7 +175,7 @@
<Compile Include="Dns\ResourceData\DnsResourceDataRKey.cs" /> <Compile Include="Dns\ResourceData\DnsResourceDataRKey.cs" />
<Compile Include="Dns\ResourceData\DnsResourceDataRouteThrough.cs" /> <Compile Include="Dns\ResourceData\DnsResourceDataRouteThrough.cs" />
<Compile Include="Dns\ResourceData\DnsResourceDataServerSelection.cs" /> <Compile Include="Dns\ResourceData\DnsResourceDataServerSelection.cs" />
<Compile Include="Dns\ResourceData\DnsResourceDataSig.cs" /> <Compile Include="Dns\ResourceData\DnsResourceDataSignature.cs" />
<Compile Include="Dns\ResourceData\DnsResourceDataSimple.cs" /> <Compile Include="Dns\ResourceData\DnsResourceDataSimple.cs" />
<Compile Include="Dns\ResourceData\DnsResourceDataSink.cs" /> <Compile Include="Dns\ResourceData\DnsResourceDataSink.cs" />
<Compile Include="Dns\ResourceData\DnsResourceDataSshFingerprint.cs" /> <Compile Include="Dns\ResourceData\DnsResourceDataSshFingerprint.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