Commit bb3f755e authored by Brickner_cp's avatar Brickner_cp

Warnings, Code Analysis and Documentation. 815 warnings left.

parent 6dbe3788
......@@ -53,7 +53,7 @@ namespace PcapDotNet.Base.Test
{
int[] sequence = new[]{1,2,3,4,5};
Assert.AreEqual(1.GetHashCode() ^ 2.GetHashCode() ^ 3.GetHashCode() ^ 4.GetHashCode() ^ 5.GetHashCode(),sequence.SequenceGetHashCode());
Assert.AreEqual(1.GetHashCode() ^ 2.GetHashCode() ^ 3.GetHashCode() ^ 4.GetHashCode() ^ 5.GetHashCode(), sequence.SequenceGetHashCode());
}
[TestMethod]
......@@ -61,7 +61,7 @@ namespace PcapDotNet.Base.Test
{
byte[] sequence = new byte[] { 1, 2, 3, 4, 5 };
Assert.AreEqual(1 ^ (2 << 8) ^ (3 << 16) ^ (4 << 24) ^ 5, sequence.BytesSequenceGetHashCode());
Assert.AreEqual((int)BitSequence.Merge(4, 3, 2, 1) ^ 5, sequence.BytesSequenceGetHashCode());
}
[TestMethod]
......
namespace PcapDotNet.Base
{
public static class BitSequence
{
public static byte ToByte(this bool value)
{
return value ? (byte)1 : (byte)0;
}
public static byte Merge(bool value1, bool value2)
{
return (byte)((value1.ToByte() << 1) | value2.ToByte());
}
public static byte Merge(bool value1, bool value2, bool value3)
{
return (byte)((Merge(value1, value2) << 1) | value3.ToByte());
}
public static byte Merge(bool value1, bool value2, bool value3, bool value4)
{
return (byte)((Merge(value1, value2, value3) << 1) | value4.ToByte());
}
public static byte Merge(bool value1, bool value2, bool value3, bool value4, bool value5)
{
return (byte)((Merge(value1, value2, value3, value4) << 1) | value5.ToByte());
}
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());
}
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());
}
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());
}
public static ushort Merge(byte value1, byte value2)
{
return (ushort)((value1 << 8) | value2);
}
public static UInt24 Merge(byte value1, byte value2, byte value3)
{
return (UInt24)Merge(0, value1, value2, value3);
}
public static uint Merge(byte value1, byte value2, byte value3, byte value4)
{
return Merge(Merge(value1, value2), Merge(value3, value4));
}
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);
}
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));
}
public static uint Merge(ushort value1, ushort value2)
{
return (uint)((value1 << 16) | value2);
}
public static UInt24 Merge(byte value1, ushort value2)
{
return (UInt24)Merge(0, value1, value2);
}
public static uint Merge(ushort value1, byte value2, byte value3)
{
return Merge(value1, Merge(value2, value3));
}
public static uint Merge(byte value1, ushort value2, byte value3)
{
return (uint)((value1 << 24) | (value2 << 8) | value3);
}
public static uint Merge(byte value1, byte value2, ushort value3)
{
return Merge(Merge(value1, value2), value3);
}
public static ulong Merge(uint value1, uint value2)
{
return (((ulong)value1) << 32) | value2;
}
}
}
\ No newline at end of file
......@@ -7,21 +7,21 @@ namespace PcapDotNet.Base
{
public InlineEqualityComparer(Func<T, T, bool> equals, Func<T,int> getHashCode)
{
Equals = equals;
GetHashCode = getHashCode;
EqualsFunc = equals;
GetHashCodeFunc = getHashCode;
}
bool IEqualityComparer<T>.Equals(T x, T y)
{
return Equals(x, y);
return EqualsFunc(x, y);
}
int IEqualityComparer<T>.GetHashCode(T obj)
{
return GetHashCode(obj);
return GetHashCodeFunc(obj);
}
private Func<T, T, bool> Equals { get; set; }
private Func<T, int> GetHashCode { get; set; }
private Func<T, T, bool> EqualsFunc { get; set; }
private Func<T, int> GetHashCodeFunc { get; set; }
}
}
\ No newline at end of file
......@@ -85,6 +85,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BitSequence.cs" />
<Compile Include="CharExtensions.cs" />
<Compile Include="DateTimeExtensions.cs" />
<Compile Include="EncodingExtensions.cs" />
......@@ -96,6 +97,7 @@
<Compile Include="MatchExtensions.cs" />
<Compile Include="MemberInfoExtensions.cs" />
<Compile Include="PropertyInfoExtensions.cs" />
<Compile Include="Sequence.cs" />
<Compile Include="SerialNumber32.cs" />
<Compile Include="TimeSpanExtensions.cs" />
<Compile Include="TypeExtensions.cs" />
......
namespace PcapDotNet.Base
{
public static class Sequence
{
public static int GetHashCode(object value1, object value2)
{
return value1.GetHashCode() ^ value2.GetHashCode();
}
public static int GetHashCode(object value1, object value2, object value3)
{
return GetHashCode(value1, value2) ^ value3.GetHashCode();
}
public static int GetHashCode(object value1, object value2, object value3, object value4)
{
return GetHashCode(value1, value2, value3) ^ value4.GetHashCode();
}
public static int GetHashCode(object value1, object value2, object value3, object value4, object value5)
{
return GetHashCode(value1, value2, value3, value4) ^ value5.GetHashCode();
}
public static int GetHashCode(object value1, object value2, object value3, object value4, object value5, object value6)
{
return GetHashCode(value1, value2, value3, value4, value5) ^ value6.GetHashCode();
}
public static int GetHashCode(object value1, object value2, object value3, object value4, object value5, object value6, object value7)
{
return GetHashCode(value1, value2, value3, value4, value5, value6) ^ value7.GetHashCode();
}
}
}
\ No newline at end of file
......@@ -34,6 +34,11 @@ namespace PcapDotNet.Base
Equals((SerialNumber32)obj);
}
public override int GetHashCode()
{
return Value.GetHashCode();
}
public int CompareTo(SerialNumber32 other)
{
if (Equals(other))
......
......@@ -519,7 +519,7 @@ namespace PcapDotNet.Base
/// <filterpriority>2</filterpriority>
public override int GetHashCode()
{
return _mostSignificant.GetHashCode() ^ _leastSignificant.GetHashCode();
return Sequence.GetHashCode(_mostSignificant, _leastSignificant);
}
/// <summary>
......
......@@ -29,6 +29,11 @@ namespace PcapDotNet.Base
return new UInt24(value);
}
public static explicit operator UInt24(uint value)
{
return new UInt24((int)value);
}
/// <summary>
/// Converts the 24 bits unsigned integer to a 32 bits signed integer.
/// </summary>
......
......@@ -109,6 +109,7 @@ namespace PcapDotNet.Core.Test
private static void CompareIgmpGroupRecord(XElement groupRecord, IgmpGroupRecordDatagram groupRecordDatagram)
{
Console.WriteLine(groupRecordDatagram.AuxiliaryData);
int sourceAddressIndex = 0;
foreach (var field in groupRecord.Fields())
{
......
using System;
using System.Collections.ObjectModel;
using System.Linq;
using PcapDotNet.Base;
using PcapDotNet.Packets.Ethernet;
namespace PcapDotNet.Packets.Arp
......@@ -135,7 +136,7 @@ namespace PcapDotNet.Packets.Arp
public override int GetHashCode()
{
return base.GetHashCode() ^
(((ushort)ProtocolType << 16) + (ushort)Operation);
BitSequence.Merge((ushort)ProtocolType, (ushort)Operation).GetHashCode();
}
}
}
\ No newline at end of file
......@@ -33,7 +33,7 @@ namespace PcapDotNet.Packets
/// An empty datagram.
/// Useful for empty payloads.
/// </summary>
public static Datagram Empty
public new static Datagram Empty
{
get { return _empty; }
}
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -52,6 +53,11 @@ namespace PcapDotNet.Packets.Dns
return Equals(obj as DnsDataResourceRecord);
}
public override int GetHashCode()
{
return GetHashCodeBase() ^ Sequence.GetHashCode(Ttl, Data);
}
internal static DnsDataResourceRecord Parse(DnsDatagram dns, int offsetInDns, out int numBytesRead)
{
DnsDomainName domainName;
......
......@@ -63,6 +63,11 @@ namespace PcapDotNet.Packets.Dns
return Equals(obj as DnsDomainName);
}
public override int GetHashCode()
{
return _labels.SequenceGetHashCode();
}
internal int GetLength(DnsDomainNameCompressionData compressionData, int offsetInDns)
{
int length = 0;
......
namespace PcapDotNet.Packets.Dns
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
/// <summary>
/// RFC 2671.
......@@ -27,7 +29,7 @@
public sealed class DnsOptResourceRecord : DnsDataResourceRecord
{
public DnsOptResourceRecord(DnsDomainName domainName, ushort sendersUdpPayloadSize, byte extendedRcode, DnsOptVersion version, DnsOptFlags flags, DnsResourceDataOptions data)
: this(domainName, (DnsClass)sendersUdpPayloadSize, (extendedRcode << 24) | ((byte)version << 16) | (ushort)flags, data)
: this(domainName, (DnsClass)sendersUdpPayloadSize, (int)BitSequence.Merge(extendedRcode, (byte)version, (ushort)flags), data)
{
}
......
......@@ -22,6 +22,11 @@ namespace PcapDotNet.Packets.Dns
return Data.Equals(((DnsOptionAnything)other).Data);
}
internal override int DataGetHashCode()
{
return Data.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
Data.Write(buffer, ref offset);
......
......@@ -31,6 +31,11 @@ namespace PcapDotNet.Packets.Dns
return Equals(obj as DnsQueryResourceRecord);
}
public override int GetHashCode()
{
return GetHashCodeBase();
}
internal static DnsQueryResourceRecord Parse(DnsDatagram dns, int offsetInDns, out int numBytesRead)
{
DnsDomainName domainName;
......
using System;
using System.Collections.Generic;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -86,6 +87,11 @@ namespace PcapDotNet.Packets.Dns
DnsClass.Equals(other.DnsClass);
}
internal int GetHashCodeBase()
{
return Sequence.GetHashCode(DomainName, BitSequence.Merge((ushort)Type, (ushort)DnsClass));
}
internal static bool TryParseBase(DnsDatagram dns, int offsetInDns,
out DnsDomainName domainName, out DnsType type, out DnsClass dnsClass, out int numBytesRead)
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -106,6 +107,12 @@ namespace PcapDotNet.Packets.Dns
return Equals(obj as DnsAddressPrefix);
}
public override int GetHashCode()
{
return BitSequence.Merge((ushort)AddressFamily, PrefixLength, (byte)(((Negation ? 1 : 0) << 7) | AddressFamilyDependentPart.Length)).GetHashCode() ^
AddressFamilyDependentPart.BytesSequenceGetHashCode();
}
public static DnsAddressPrefix Read(DataSegment data)
{
if (data.Length < MinimumLength)
......
......@@ -19,6 +19,13 @@ namespace PcapDotNet.Packets.Dns
return Equals(obj as DnsGateway);
}
public override int GetHashCode()
{
return Type.GetHashCode() ^ DataGetHashCode();
}
internal abstract int DataGetHashCode();
internal abstract void Write(byte[] buffer, int offset);
internal static DnsGateway CreateInstance(DnsGatewayType gatewayType, DnsDatagram dns, int offsetInDns, int length)
......
......@@ -32,6 +32,11 @@ namespace PcapDotNet.Packets.Dns
return Equals(other as DnsGatewayDomainName);
}
internal override int DataGetHashCode()
{
return Value.GetHashCode();
}
internal override void Write(byte[] buffer, int offset)
{
Value.WriteUncompressed(buffer, offset);
......
......@@ -33,6 +33,11 @@ namespace PcapDotNet.Packets.Dns
return Equals(other as DnsGatewayIpV4);
}
internal override int DataGetHashCode()
{
return Value.GetHashCode();
}
internal override void Write(byte[] buffer, int offset)
{
buffer.Write(offset, Value, Endianity.Big);
......
......@@ -33,6 +33,11 @@ namespace PcapDotNet.Packets.Dns
return Equals(other as DnsGatewayIpV6);
}
internal override int DataGetHashCode()
{
return Value.GetHashCode();
}
internal override void Write(byte[] buffer, int offset)
{
buffer.Write(offset, Value, Endianity.Big);
......
......@@ -24,6 +24,11 @@ namespace PcapDotNet.Packets.Dns
return Equals(other as DnsGatewayNone);
}
internal override int DataGetHashCode()
{
return 0;
}
internal DnsGatewayNone()
{
}
......
......@@ -23,6 +23,11 @@ namespace PcapDotNet.Packets.Dns
return Equals(obj as DnsOption);
}
public override int GetHashCode()
{
return Code.GetHashCode() ^ DataGetHashCode();
}
internal DnsOption(DnsOptionCode code)
{
Code = code;
......@@ -30,6 +35,8 @@ namespace PcapDotNet.Packets.Dns
internal abstract bool EqualsData(DnsOption other);
internal abstract int DataGetHashCode();
internal void Write(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, (ushort)Code, Endianity.Big);
......
namespace PcapDotNet.Packets.Dns
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
/// <summary>
/// http://files.dns-sd.org/draft-sekar-dns-llq.txt.
......@@ -66,6 +68,11 @@
LeaseLife.Equals(castedOther.LeaseLife);
}
internal override int DataGetHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge(Version, (ushort)Opcode), ErrorCode, Id, LeaseLife);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.Version, Version, Endianity.Big);
......
......@@ -42,6 +42,11 @@
return Lease.Equals(((DnsOptionUpdateLease)other).Lease);
}
internal override int DataGetHashCode()
{
return Lease.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, Lease, Endianity.Big);
......
......@@ -36,6 +36,11 @@ namespace PcapDotNet.Packets.Dns
return Equals(obj as DnsOptions);
}
public override int GetHashCode()
{
return Options.SequenceGetHashCode();
}
private static readonly DnsOptions _none = new DnsOptions();
internal void Write(byte[] buffer, int offset)
......
......@@ -8,7 +8,7 @@ using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
public abstract class DnsResourceData : IEquatable<DnsResourceData>
public abstract class DnsResourceData
{
internal const int StringMinimumLength = sizeof(byte);
......@@ -20,13 +20,6 @@ namespace PcapDotNet.Packets.Dns
return prototype.GetType();
}
public abstract bool Equals(DnsResourceData other);
public sealed override bool Equals(object obj)
{
return Equals(obj as DnsResourceData);
}
internal abstract int GetLength(DnsDomainNameCompressionData compressionData, int offsetInDns);
internal int Write(byte[] buffer, int dnsOffset, int offsetInDns, DnsDomainNameCompressionData compressionData)
......
......@@ -80,11 +80,16 @@ namespace PcapDotNet.Packets.Dns
PrefixName.Equals(other.PrefixName);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataA6);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(PrefixLength, AddressSuffix, PrefixName);
}
internal DnsResourceDataA6()
: this(0, IpV6Address.MaxValue, DnsDomainName.Root)
{
......
......@@ -45,11 +45,16 @@ namespace PcapDotNet.Packets.Dns
Items.SequenceEqual(other.Items);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataAddressPrefixList);
}
public override int GetHashCode()
{
return Items.SequenceGetHashCode();
}
internal DnsResourceDataAddressPrefixList()
: this(new DnsAddressPrefix[0])
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -28,11 +29,16 @@ namespace PcapDotNet.Packets.Dns
return other != null && Data.Equals(other.Data);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataAnything);
}
public override int GetHashCode()
{
return Data.GetHashCode();
}
internal override int GetLength()
{
return Data.Length;
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -53,11 +54,16 @@ namespace PcapDotNet.Packets.Dns
Address.Equals(other.Address);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataAtmAddress);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(Format, Address);
}
internal DnsResourceDataAtmAddress()
: this(DnsAtmAddressFormat.AtmEndSystemAddress, DataSegment.Empty)
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -75,11 +76,16 @@ namespace PcapDotNet.Packets.Dns
Certificate.Equals(other.Certificate);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataCertificate);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge((ushort)CertificateType, KeyTag), Algorithm, Certificate);
}
internal DnsResourceDataCertificate()
: this(DnsCertificateType.Pkix, 0, DnsAlgorithm.None, DataSegment.Empty)
{
......
using System;
using System.Linq;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -67,11 +68,16 @@ namespace PcapDotNet.Packets.Dns
Value.SequenceEqual(other.Value);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataCertificationAuthorityAuthorization);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(Flags, Tag, Value);
}
internal DnsResourceDataCertificationAuthorityAuthorization()
: this(0, DataSegment.Empty, DataSegment.Empty)
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -95,11 +96,16 @@ namespace PcapDotNet.Packets.Dns
Digest.Equals(other.Digest);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataDelegationSigner);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge(KeyTag, (byte)Algorithm, (byte)DigestType), Digest);
}
internal DnsResourceDataDelegationSigner()
: this(0, DnsAlgorithm.None, DnsDigestType.Sha1, DataSegment.Empty)
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -100,11 +101,16 @@ namespace PcapDotNet.Packets.Dns
PublicKey.Equals(other.PublicKey);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataDnsKey);
}
public override int GetHashCode()
{
return BitSequence.Merge(BitSequence.Merge(ZoneKey, Revoke, SecureEntryPoint), Protocol, (byte)Algorithm).GetHashCode();
}
internal DnsResourceDataDnsKey()
: this(false, false, false, ProtocolValue, DnsAlgorithm.None, DataSegment.Empty)
{
......
......@@ -34,11 +34,16 @@ namespace PcapDotNet.Packets.Dns
return other != null && Data.Equals(other.Data);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataDomainName);
}
public override int GetHashCode()
{
return Data.GetHashCode();
}
internal DnsResourceDataDomainName()
: this(DnsDomainName.Root)
{
......
......@@ -18,11 +18,16 @@ namespace PcapDotNet.Packets.Dns
DomainNames.SequenceEqual(other.DomainNames);
}
public sealed override bool Equals(DnsResourceData other)
public sealed override bool Equals(object other)
{
return Equals(other as DnsResourceDataDomainNames);
}
public override int GetHashCode()
{
return GetType().GetHashCode() ^ DomainNames.SequenceGetHashCode();
}
internal DnsResourceDataDomainNames(ReadOnlyCollection<DnsDomainName> domainNames)
{
DomainNames = domainNames;
......
using System;
using System.Text;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -55,11 +56,16 @@ namespace PcapDotNet.Packets.Dns
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataGeographicalPosition);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(Longitude, Latitude, Altitude);
}
internal DnsResourceDataGeographicalPosition()
: this(string.Empty, string.Empty, string.Empty)
{
......
......@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using PcapDotNet.Base;
using IListExtensions = PcapDotNet.Base.IListExtensions;
namespace PcapDotNet.Packets.Dns
......@@ -85,11 +86,16 @@ namespace PcapDotNet.Packets.Dns
RendezvousServers.SequenceEqual(RendezvousServers);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataHostIdentityProtocol);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(HostIdentityTag, PublicKeyAlgorithm, PublicKey) ^ RendezvousServers.SequenceGetHashCode();
}
internal DnsResourceDataHostIdentityProtocol()
: this(DataSegment.Empty, DnsPublicKeyAlgorithm.None, DataSegment.Empty, new DnsDomainName[0])
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -79,11 +80,16 @@ namespace PcapDotNet.Packets.Dns
PublicKey.Equals(other.PublicKey);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataIpSecKey);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge(Precedence, (byte)Algorithm), Gateway, PublicKey);
}
internal DnsResourceDataIpSecKey()
: this(0, DnsGateway.None, DnsPublicKeyAlgorithm.None, DataSegment.Empty)
{
......
......@@ -28,11 +28,16 @@ namespace PcapDotNet.Packets.Dns
return other != null && Data.Equals(other.Data);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataIpV4);
}
public override int GetHashCode()
{
return Data.GetHashCode();
}
internal DnsResourceDataIpV4()
: this(IpV4Address.Zero)
{
......
......@@ -28,11 +28,16 @@ namespace PcapDotNet.Packets.Dns
return other != null && Data.Equals(other.Data);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataIpV6);
}
public override int GetHashCode()
{
return Data.GetHashCode();
}
internal DnsResourceDataIpV6()
: this(IpV6Address.Zero)
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -172,11 +173,21 @@ namespace PcapDotNet.Packets.Dns
PublicKey.Equals(other.PublicKey);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataKey);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(
BitSequence.Merge(BitSequence.Merge(AuthenticationProhibited, ConfidentialityProhibited, Experimental, UserAssociated, IpSec, Email),
(byte)NameType, (byte)Signatory, (byte)Protocol),
BitSequence.Merge((byte)Algorithm, (ushort)(FlagsExtension.HasValue ? FlagsExtension.Value : 0)),
PublicKey);
}
internal DnsResourceDataKey()
: this(false, false, false, false, false, false, DnsKeyNameType.ZoneKey, DnsKeySignatory.Zone, DnsKeyProtocol.All, DnsAlgorithm.None, null,
DataSegment.Empty)
......
using System;
using System.Linq;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -128,11 +130,16 @@ namespace PcapDotNet.Packets.Dns
Altitude.Equals(other.Altitude);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataLocationInformation);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(Version, Size, HorizontalPrecision, VerticalPrecision, Latitude, Longitude, Altitude);
}
internal DnsResourceDataLocationInformation()
: this(0, 0, 0, 0, 0, 0, 0)
{
......
......@@ -131,11 +131,16 @@ namespace PcapDotNet.Packets.Dns
Replacement.Equals(other.Replacement);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataNamingAuthorityPointer);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge(Order, Preference), Flags, Services, Regexp, Replacement);
}
internal DnsResourceDataNamingAuthorityPointer()
: this(0, 0, DataSegment.Empty, DataSegment.Empty, DataSegment.Empty, DnsDomainName.Root)
{
......
......@@ -80,11 +80,16 @@ namespace PcapDotNet.Packets.Dns
Selector.Equals(other.Selector);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataNetworkServiceAccessPoint);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(AreaAddress, SystemIdentifier, Selector);
}
internal DnsResourceDataNetworkServiceAccessPoint()
: this(new DataSegment(new byte[MinAreaAddressLength]), 0, 0)
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -111,11 +112,16 @@ namespace PcapDotNet.Packets.Dns
TypeBitMap.Equals(other.TypeBitMap);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataNextDomain);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(NextDomainName, TypeBitMap);
}
internal DnsResourceDataNextDomain()
: this(DnsDomainName.Root, DataSegment.Empty)
{
......
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -52,11 +53,16 @@ namespace PcapDotNet.Packets.Dns
_typeBitmaps.Equals(other._typeBitmaps);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataNextDomainSecure);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(NextDomainName, _typeBitmaps);
}
internal DnsResourceDataNextDomainSecure()
: this(DnsDomainName.Root, new DnsType[0])
{
......
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -55,11 +56,16 @@ namespace PcapDotNet.Packets.Dns
_typeBitmaps.Equals(other._typeBitmaps);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataNextDomainSecure3);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(NextHashedOwnerName, _typeBitmaps);
}
internal DnsResourceDataNextDomainSecure3()
: this(DnsSecNSec3HashAlgorithm.Sha1, DnsSecNSec3Flags.None, 0, DataSegment.Empty, DataSegment.Empty, new DnsType[0])
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -62,6 +63,11 @@ namespace PcapDotNet.Packets.Dns
Salt.Equals(other.Salt);
}
internal int GetHashCodeParameters()
{
return Sequence.GetHashCode(BitSequence.Merge(Iterations, (byte)HashAlgorithm, (byte)Flags), Salt);
}
internal DnsResourceDataNextDomainSecure3Base(DnsSecNSec3HashAlgorithm hashAlgorithm, DnsSecNSec3Flags flags, ushort iterations, DataSegment salt)
{
if (salt.Length > byte.MaxValue)
......
......@@ -29,11 +29,16 @@ namespace PcapDotNet.Packets.Dns
return EqualsParameters(other);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataNextDomainSecure3Parameters);
}
public override int GetHashCode()
{
return GetHashCodeParameters();
}
internal DnsResourceDataNextDomainSecure3Parameters()
: this(DnsSecNSec3HashAlgorithm.Sha1, DnsSecNSec3Flags.None, 0, DataSegment.Empty)
{
......
......@@ -34,11 +34,16 @@ namespace PcapDotNet.Packets.Dns
Options.Equals(other.Options);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataOptions);
}
public override int GetHashCode()
{
return Options.GetHashCode();
}
internal DnsResourceDataOptions()
: this(DnsOptions.None)
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -65,11 +66,16 @@ namespace PcapDotNet.Packets.Dns
PublicKey.Equals(other.PublicKey);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataRKey);
}
public override int GetHashCode()
{
return BitSequence.Merge(Flags, Protocol, (byte)Algorithm).GetHashCode();
}
internal DnsResourceDataRKey()
: this(0, 1, DnsAlgorithm.None, DataSegment.Empty)
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -92,7 +93,12 @@ namespace PcapDotNet.Packets.Dns
Target.Equals(other.Target);
}
public override bool Equals(DnsResourceData other)
public override int GetHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge(Priority, Weight), Port, Target);
}
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataServerSelection);
}
......
......@@ -153,7 +153,13 @@ namespace PcapDotNet.Packets.Dns
Signature.Equals(other.Signature);
}
public override bool Equals(DnsResourceData other)
public override int GetHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge((ushort)TypeCovered, (byte)Algorithm, Labels), OriginalTtl, SignatureExpiration, SignatureInception,
KeyTag, SignersName, Signature);
}
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataSig);
}
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -57,7 +58,7 @@ namespace PcapDotNet.Packets.Dns
{
get
{
ushort codingSubcoding = (ushort)(((ushort)Coding << 8) | Subcoding);
ushort codingSubcoding = BitSequence.Merge((byte)Coding, Subcoding);
return (DnsSinkCodingSubcoding)codingSubcoding;
}
}
......@@ -75,11 +76,16 @@ namespace PcapDotNet.Packets.Dns
Data.Equals(other.Data);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataSink);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(CodingSubcoding, Data);
}
internal DnsResourceDataSink()
: this(DnsSinkCodingSubcoding.Asn1SnmpBer, DataSegment.Empty)
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -58,11 +59,16 @@ namespace PcapDotNet.Packets.Dns
Fingerprint.Equals(other.Fingerprint);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataSshFingerprint);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge((byte)Algorithm, (byte)FingerprintType), Fingerprint);
}
internal DnsResourceDataSshFingerprint()
: this(DnsFingerprintPublicKeyAlgorithm.Rsa, DnsFingerprintType.Sha1, DataSegment.Empty)
{
......
......@@ -102,7 +102,12 @@ namespace PcapDotNet.Packets.Dns
MinimumTtl.Equals(other.MinimumTtl);
}
public override bool Equals(DnsResourceData other)
public override int GetHashCode()
{
return Sequence.GetHashCode(MainNameServer, ResponsibleMailBox, Serial, Refresh, Retry, Expire, MinimumTtl);
}
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataStartOfAuthority);
}
......
......@@ -23,11 +23,16 @@ namespace PcapDotNet.Packets.Dns
String.Equals(other.String);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataString);
}
public override int GetHashCode()
{
return String.GetHashCode();
}
internal DnsResourceDataString()
: this(DataSegment.Empty)
{
......
......@@ -20,11 +20,16 @@ namespace PcapDotNet.Packets.Dns
Strings.SequenceEqual(other.Strings);
}
public sealed override bool Equals(DnsResourceData other)
public sealed override bool Equals(object other)
{
return Equals(other as DnsResourceDataStrings);
}
public override int GetHashCode()
{
return GetType().GetHashCode() ^ Strings.SequenceGetHashCode();
}
internal DnsResourceDataStrings(ReadOnlyCollection<DataSegment> strings)
{
Strings = strings;
......
......@@ -127,11 +127,16 @@ namespace PcapDotNet.Packets.Dns
Other.Equals(other.Other);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataTransactionKey);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(Algorithm, Inception, Expiration, BitSequence.Merge((ushort)Mode, (ushort)Error), Key, Other);
}
internal DnsResourceDataTransactionKey()
: this(DnsDomainName.Root, 0, 0, DnsTransactionKeyMode.DiffieHellmanExchange, DnsResponseCode.NoError, DataSegment.Empty, DataSegment.Empty)
{
......
......@@ -111,11 +111,16 @@ namespace PcapDotNet.Packets.Dns
Other.Equals(other.Other);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataTransactionSignature);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(Algorithm, TimeSigned, BitSequence.Merge(Fudge, OriginalId), MessageAuthenticationCode, Error, Other);
}
internal DnsResourceDataTransactionSignature()
: this(DnsDomainName.Root, 0, 0, DataSegment.Empty, 0, DnsResponseCode.NoError, DataSegment.Empty)
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -40,11 +41,16 @@ namespace PcapDotNet.Packets.Dns
Next.Equals(other.Next);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataTrustAnchorLink);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(Previous, Next);
}
internal DnsResourceDataTrustAnchorLink()
: this(DnsDomainName.Root, DnsDomainName.Root)
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -33,11 +34,16 @@ namespace PcapDotNet.Packets.Dns
DomainName.Equals(other.DomainName);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataUShortDomainName);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(GetType(), Value, DomainName);
}
internal DnsResourceDataUShortDomainName(ushort value, DnsDomainName domainName)
{
Value = value;
......
......@@ -66,11 +66,16 @@ namespace PcapDotNet.Packets.Dns
Target.SequenceEqual(other.Target);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataUri);
}
public override int GetHashCode()
{
return BitSequence.Merge(Priority, Weight).GetHashCode() ^ Target.SequenceGetHashCode();
}
internal DnsResourceDataUri()
: this(0, 0, new DataSegment[0])
{
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Dns
......@@ -57,11 +58,16 @@ namespace PcapDotNet.Packets.Dns
BitMap.Equals(other.BitMap);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataWellKnownService);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(Address, Protocol, BitMap);
}
internal DnsResourceDataWellKnownService()
: this(IpV4Address.Zero, IpV4Protocol.Ip, DataSegment.Empty)
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -61,11 +62,16 @@ namespace PcapDotNet.Packets.Dns
MapX400.Equals(other.MapX400);
}
public override bool Equals(DnsResourceData other)
public override bool Equals(object other)
{
return Equals(other as DnsResourceDataX400Pointer);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(Preference, Map822, MapX400);
}
internal DnsResourceDataX400Pointer()
: this(0, DnsDomainName.Root, DnsDomainName.Root)
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Dns
{
......@@ -35,6 +36,11 @@ namespace PcapDotNet.Packets.Dns
return Equals(obj as DnsTypeBitmaps);
}
public override int GetHashCode()
{
return TypesExist.SequenceGetHashCode();
}
public int GetLength()
{
int length = 0;
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.Arp;
namespace PcapDotNet.Packets.Ethernet
......@@ -114,7 +115,7 @@ namespace PcapDotNet.Packets.Ethernet
public override int GetHashCode()
{
return base.GetHashCode() ^
Source.GetHashCode() ^ Destination.GetHashCode() ^ EtherType.GetHashCode();
Sequence.GetHashCode(Source, Destination, EtherType);
}
/// <summary>
......
......@@ -44,12 +44,8 @@ namespace PcapDotNet.Packets.Ethernet
if (hexes.Length != 6)
throw new ArgumentException("Failed parsing " + address + " as mac address. Expected 6 hexes and got " + hexes.Length + " hexes", "address");
_value = (UInt48)(((long)Convert.ToByte(hexes[0], 16) << 40) |
((long)Convert.ToByte(hexes[1], 16) << 32) |
((long)Convert.ToByte(hexes[2], 16) << 24) |
((long)Convert.ToByte(hexes[3], 16) << 16) |
((long)Convert.ToByte(hexes[4], 16) << 8) |
Convert.ToByte(hexes[5], 16));
_value = BitSequence.Merge(Convert.ToByte(hexes[0], 16), Convert.ToByte(hexes[1], 16), Convert.ToByte(hexes[2], 16),
Convert.ToByte(hexes[3], 16), Convert.ToByte(hexes[4], 16), Convert.ToByte(hexes[5], 16));
}
/// <summary>
......
using System;
using System.Collections.ObjectModel;
using System.Linq;
using PcapDotNet.Base;
using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.IpV4;
......@@ -80,7 +81,7 @@ namespace PcapDotNet.Packets.Gre
/// <param name="keyCallId">(Low 2 octets of Key) Contains the Peer's Call ID for the session to which this packet belongs.</param>
public void SetKey(ushort keyPayloadLength, ushort keyCallId)
{
Key = (uint)((keyPayloadLength << 16) | keyCallId);
Key = BitSequence.Merge(keyPayloadLength, keyCallId);
}
/// <summary>
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Gre
......@@ -78,7 +79,7 @@ namespace PcapDotNet.Packets.Gre
/// </summary>
public sealed override int GetHashCode()
{
return AddressFamily.GetHashCode() ^ Length.GetHashCode() ^ PayloadOffset.GetHashCode() ^ PayloadHashCode;
return Sequence.GetHashCode(AddressFamily, Length, PayloadOffset) ^ PayloadHashCode;
}
/// <summary>
......
......@@ -91,7 +91,7 @@ namespace PcapDotNet.Packets.Http
{
return
_parameters.Select(pair => new KeyValuePair<string, string>(pair.Key.ToUpperInvariant(), pair.Value))
.Xor(pair => pair.Key.GetHashCode() ^ pair.Value.GetHashCode());
.Xor(pair => Sequence.GetHashCode(pair.Key, pair.Value));
}
/// <summary>
......
......@@ -82,7 +82,7 @@ namespace PcapDotNet.Packets.Http
/// </summary>
public override int GetHashCode()
{
return Minor.GetHashCode() ^ Major.GetHashCode();
return Sequence.GetHashCode(Minor, Major);
}
internal void Write(byte[] buffer, ref int offset)
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Icmp
{
/// <summary>
......@@ -20,7 +22,7 @@ namespace PcapDotNet.Packets.Icmp
/// </summary>
protected sealed override uint Variable
{
get { return (uint)((Identifier << 16) | SequenceNumber); }
get { return BitSequence.Merge(Identifier, SequenceNumber); }
}
}
}
\ No newline at end of file
using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Icmp
......@@ -27,7 +28,7 @@ namespace PcapDotNet.Packets.Icmp
/// </summary>
public IcmpMessageTypeAndCode MessageTypeAndCode
{
get { return (IcmpMessageTypeAndCode)(((ushort)MessageType << 8) | CodeValue); }
get { return (IcmpMessageTypeAndCode)BitSequence.Merge((byte)MessageType, CodeValue); }
}
/// <summary>
......@@ -133,7 +134,7 @@ namespace PcapDotNet.Packets.Icmp
public sealed override int GetHashCode()
{
return base.GetHashCode() ^
MessageTypeAndCode.GetHashCode() ^ Checksum.GetHashCode() ^ Variable.GetHashCode();
Sequence.GetHashCode(MessageTypeAndCode, Variable) ^ Checksum.GetHashCode();
}
/// <summary>
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Icmp
......@@ -59,7 +60,7 @@ namespace PcapDotNet.Packets.Icmp
/// </summary>
public override int GetHashCode()
{
return RouterAddress.GetHashCode() ^ RouterAddressPreference.GetHashCode();
return Sequence.GetHashCode(RouterAddress, RouterAddressPreference);
}
private readonly IpV4Address _routerAddress;
......
......@@ -136,8 +136,7 @@ namespace PcapDotNet.Packets.Igmp
/// </summary>
public override int GetHashCode()
{
return RecordType.GetHashCode() ^ MulticastAddress.GetHashCode() ^ SourceAddresses.SequenceGetHashCode() ^
AuxiliaryData.BytesSequenceGetHashCode();
return Sequence.GetHashCode(RecordType, MulticastAddress) ^ SourceAddresses.SequenceGetHashCode() ^ AuxiliaryData.BytesSequenceGetHashCode();
}
}
}
\ No newline at end of file
......@@ -63,7 +63,7 @@ namespace PcapDotNet.Packets.Igmp
public override int GetHashCode()
{
return base.GetHashCode() ^
MessageType.GetHashCode() ^ QueryVersion.GetHashCode();
Sequence.GetHashCode(MessageType, QueryVersion);
}
/// <summary>
......
......@@ -114,8 +114,7 @@ namespace PcapDotNet.Packets.Igmp
public override int GetHashCode()
{
return base.GetHashCode() ^
GroupAddress.GetHashCode() ^
((IsSuppressRouterSideProcessing ? 0 : (1 << 8)) + QueryRobustnessVariable) ^
Sequence.GetHashCode(GroupAddress, BitSequence.Merge(IsSuppressRouterSideProcessing.ToByte(), QueryRobustnessVariable)) ^
SourceAddresses.SequenceGetHashCode();
}
......
using System;
using System.Globalization;
using System.Text;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV4
{
......@@ -52,10 +53,10 @@ namespace PcapDotNet.Packets.IpV4
throw new ArgumentNullException("value");
string[] values = value.Split('.');
_value = (uint)((byte.Parse(values[0], CultureInfo.InvariantCulture) << 24) +
(byte.Parse(values[1], CultureInfo.InvariantCulture) << 16) +
(byte.Parse(values[2], CultureInfo.InvariantCulture) << 8) +
(byte.Parse(values[3], CultureInfo.InvariantCulture)));
_value = BitSequence.Merge(byte.Parse(values[0], CultureInfo.InvariantCulture),
byte.Parse(values[1], CultureInfo.InvariantCulture),
byte.Parse(values[2], CultureInfo.InvariantCulture),
byte.Parse(values[3], CultureInfo.InvariantCulture));
}
/// <summary>
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.Ethernet;
namespace PcapDotNet.Packets.IpV4
......@@ -183,13 +184,8 @@ namespace PcapDotNet.Packets.IpV4
public override int GetHashCode()
{
return base.GetHashCode() ^
((TypeOfService << 24) + (Identification << 8) + Ttl) ^
Fragmentation.GetHashCode() ^
Protocol.GetHashCode() ^
HeaderChecksum.GetHashCode() ^
Source.GetHashCode() ^ Destination.GetHashCode() ^
Options.GetHashCode();
Sequence.GetHashCode(BitSequence.Merge(TypeOfService, Identification, Ttl),
Fragmentation, Source, Destination, Options) ^ Protocol.GetHashCode() ^ HeaderChecksum.GetHashCode();
}
/// <summary>
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV4
{
......@@ -175,7 +176,7 @@ namespace PcapDotNet.Packets.IpV4
public override int GetHashCode()
{
return base.GetHashCode() ^
((((byte)ClassificationLevel) << 16) | (((byte)ProtectionAuthorities) << 8) | Length).GetHashCode();
BitSequence.Merge((byte)ClassificationLevel, (byte)ProtectionAuthorities,(byte)Length).GetHashCode();
}
/// <summary>
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV4
{
......@@ -225,8 +226,7 @@ namespace PcapDotNet.Packets.IpV4
public override int GetHashCode()
{
return base.GetHashCode() ^
((((byte)Function | Rate) << 8) | Ttl).GetHashCode() ^
Nonce.GetHashCode();
Sequence.GetHashCode(BitSequence.Merge((byte)((byte)Function | Rate), Ttl), Nonce);
}
/// <summary>
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV4
{
......@@ -73,8 +74,7 @@ namespace PcapDotNet.Packets.IpV4
/// </summary>
public override int GetHashCode()
{
return _address.GetHashCode() ^
_timeOfDay.GetHashCode();
return Sequence.GetHashCode(_address, _timeOfDay);
}
private readonly IpV4Address _address;
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV4
{
......@@ -205,8 +206,7 @@ namespace PcapDotNet.Packets.IpV4
public override int GetHashCode()
{
return base.GetHashCode() ^
(((byte)TimestampType << 16) | (Overflow << 8)).GetHashCode() ^
PointedIndex.GetHashCode();
Sequence.GetHashCode(BitSequence.Merge((byte)TimestampType, Overflow), PointedIndex);
}
internal sealed override void Write(byte[] buffer, ref int offset)
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV4
{
......@@ -166,9 +167,7 @@ namespace PcapDotNet.Packets.IpV4
public override int GetHashCode()
{
return base.GetHashCode() ^
Identification.GetHashCode() ^
((OutboundHopCount << 16) | (ReturnHopCount << 16)).GetHashCode() ^
OriginatorIpAddress.GetHashCode();
Sequence.GetHashCode(Identification, BitSequence.Merge(OutboundHopCount, ReturnHopCount), OriginatorIpAddress);
}
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets
{
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Transport
{
......@@ -108,7 +109,7 @@ namespace PcapDotNet.Packets.Transport
/// </summary>
public override int GetHashCode()
{
return base.GetHashCode() ^ ((IsStart ? 1 : 0) << 1) ^ (IsEnd ? 1 : 0);
return base.GetHashCode() ^ BitSequence.Merge(IsStart, IsEnd).GetHashCode();
}
/// <summary>
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Transport
{
......@@ -89,7 +90,7 @@ namespace PcapDotNet.Packets.Transport
/// </summary>
public override int GetHashCode()
{
return LeftEdge.GetHashCode() ^ RightEdge.GetHashCode();
return Sequence.GetHashCode(LeftEdge, RightEdge);
}
}
}
\ No newline at end of file
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Transport
......@@ -81,8 +82,7 @@ namespace PcapDotNet.Packets.Transport
public sealed override int GetHashCode()
{
return base.GetHashCode() ^
Checksum.GetHashCode() ^
((SourcePort << 16) + DestinationPort);
Checksum.GetHashCode() ^ BitSequence.Merge(SourcePort, DestinationPort).GetHashCode();
}
/// <summary>
......
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