Commit 96b7db96 authored by Brickner_cp's avatar Brickner_cp

677 warnings left.

Code Coverage 94.53%.
parent fe832502
......@@ -35,7 +35,7 @@ namespace PcapDotNet.Core.Test
get { return RetryNumber != -1; }
}
private const int RetryNumber = -1;
private const int RetryNumber = 220;
/// <summary>
/// Gets or sets the test context which provides
......
......@@ -5,7 +5,7 @@ namespace PcapDotNet.Core.Test
{
internal abstract class WiresharkDatagramComparerSimple : WiresharkDatagramComparer
{
protected override sealed bool CompareField(XElement field, Datagram parentDatagram, Datagram datagram)
protected sealed override bool CompareField(XElement field, Datagram parentDatagram, Datagram datagram)
{
return CompareField(field, datagram);
}
......
......@@ -86,8 +86,13 @@ namespace PcapDotNet.Packets.Test
Assert.AreEqual(ipV6Layer, packet.Ethernet.IpV6.ExtractLayer(), "IP Layer");
Assert.IsNotNull(ipV6Layer.GetHashCode());
Assert.AreEqual(string.Format("{0} -> {1} ({2})", ipV6Layer.Source, ipV6Layer.CurrentDestination, ipV6Layer.NextHeader), ipV6Layer.ToString());
foreach (IpV6ExtensionHeader extensionHeader in (IEnumerable)packet.Ethernet.IpV6.ExtensionHeaders)
for (int extensionHeaderIndex = 0; extensionHeaderIndex != packet.Ethernet.IpV6.ExtensionHeaders.Headers.Count; ++extensionHeaderIndex)
{
IpV6ExtensionHeader extensionHeader = packet.Ethernet.IpV6.ExtensionHeaders[extensionHeaderIndex];
IpV6ExtensionHeader layerExtensionheader = ipV6Layer.ExtensionHeaders[extensionHeaderIndex];
Assert.AreEqual(extensionHeader, layerExtensionheader);
// TODO: Bring it back.
// Assert.AreEqual(extensionHeader.GetHashCode(), layerExtensionheader.GetHashCode());
IpV6ExtensionHeaderOptions extensionHeaderOptions = extensionHeader as IpV6ExtensionHeaderOptions;
if (extensionHeaderOptions != null)
{
......
......@@ -71,14 +71,14 @@ namespace PcapDotNet.Packets.Dns
/// For example, SOA records are always distributed with a zero TTL to prohibit caching.
/// Zero values can also be used for extremely volatile data.
/// </summary>
public override sealed int Ttl { get; protected set; }
public sealed override int Ttl { get; protected set; }
/// <summary>
/// A variable length string of octets that describes the resource.
/// The format of this information varies according to the TYPE and CLASS of the resource record.
/// For example, the if the TYPE is A and the CLASS is IN, the RDATA field is a 4 octet ARPA Internet address.
/// </summary>
public override sealed DnsResourceData Data { get; protected set; }
public sealed override DnsResourceData Data { get; protected set; }
/// <summary>
/// A string representing the resource record by concatenating its different parts.
......@@ -102,7 +102,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary>
/// Two DnsDataResourceRecord are equal iff their domain name, dns type, dns class, ttl and data fields are equal.
/// </summary>
public override sealed bool Equals(object obj)
public sealed override bool Equals(object obj)
{
return Equals(obj as DnsDataResourceRecord);
}
......@@ -110,7 +110,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary>
/// A hash code of the combination of the domain name, dns type, dns class, ttl and data fields.
/// </summary>
public override sealed int GetHashCode()
public sealed override int GetHashCode()
{
return GetHashCodeBase() ^ Sequence.GetHashCode(Ttl, Data);
}
......
......@@ -32,7 +32,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary>
/// Two gateway representations are equal if they are of the same type and the value is the same.
/// </summary>
public override sealed bool Equals(object obj)
public sealed override bool Equals(object obj)
{
return Equals(obj as DnsGateway);
}
......@@ -41,7 +41,7 @@ namespace PcapDotNet.Packets.Dns
/// Serves as a hash function for a particular type.
/// </summary>
/// <returns>A hash code for the current gateway represnetation.</returns>
public override sealed int GetHashCode()
public sealed override int GetHashCode()
{
return GatewayType.GetHashCode() ^ DataGetHashCode();
}
......
......@@ -42,7 +42,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary>
/// Two options are equal if they are of the same type, have the same code and have equal data.
/// </summary>
public override sealed bool Equals(object obj)
public sealed override bool Equals(object obj)
{
return Equals(obj as DnsOption);
}
......
......@@ -24,7 +24,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary>
/// Two domain names resource data are equal if they are of the same type and contain the same domain names in the same order.
/// </summary>
public override sealed bool Equals(object obj)
public sealed override bool Equals(object obj)
{
return Equals(obj as DnsResourceDataDomainNames);
}
......@@ -32,7 +32,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary>
/// The hash code of the resource data is based on the concrete type and domain names.
/// </summary>
public override sealed int GetHashCode()
public sealed override int GetHashCode()
{
return GetType().GetHashCode() ^ DomainNames.SequenceGetHashCode();
}
......
......@@ -40,7 +40,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary>
/// Two DnsResourceDataUShortDomainName are equal iff their of the same type and their ushort values and domain names are equal.
/// </summary>
public override sealed bool Equals(object obj)
public sealed override bool Equals(object obj)
{
return Equals(obj as DnsResourceDataUShortDomainName);
}
......@@ -48,7 +48,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary>
/// A hash code based on the type, ushort value and domain name.
/// </summary>
public override sealed int GetHashCode()
public sealed override int GetHashCode()
{
return Sequence.GetHashCode(GetType(), Value, DomainName);
}
......
......@@ -2,6 +2,10 @@ using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Ip
{
/// <summary>
/// RFC 4782.
/// Common interface of a quick start option.
/// </summary>
public interface IIpOptionQuickStart
{
/// <summary>
......
......@@ -14,13 +14,24 @@ namespace PcapDotNet.Packets.Ip
/// </summary>
public abstract int Length { get; }
/// <summary>
/// Returns true iff the given object is an equivalent option.
/// </summary>
public sealed override bool Equals(object obj)
{
return Equals(obj as Option);
}
/// <summary>
/// Returns true iff the given option is an equivalent option.
/// </summary>
public abstract bool Equals(Option other);
/// <summary>
/// Returns a hash code for the option.
/// </summary>
public override abstract int GetHashCode();
internal abstract void Write(byte[] buffer, ref int offset);
}
}
\ No newline at end of file
......@@ -77,8 +77,7 @@ namespace PcapDotNet.Packets.Ip
/// </summary>
public sealed override int GetHashCode()
{
return BytesLength.GetHashCode() ^
OptionsCollection.SequenceGetHashCode();
return Sequence.GetHashCode(BytesLength, OptionsCollection.SequenceGetHashCode());
}
public IEnumerator<T> GetEnumerator()
......
namespace PcapDotNet.Packets.Ip
{
/// <summary>
/// Either an IPv4 option or a TCP option.
/// </summary>
public abstract class V4Option : Option
{
/// <summary>
......
......@@ -5,6 +5,10 @@ using PcapDotNet.Base;
namespace PcapDotNet.Packets.Ip
{
/// <summary>
/// Base class for different IPv4 options.
/// </summary>
/// <typeparam name="T">The option concerete type.</typeparam>
public abstract class V4Options<T> : Options<T> where T : V4Option, IEquatable<T>
{
internal V4Options(byte[] buffer, int offset, int length, T end)
......@@ -19,7 +23,7 @@ namespace PcapDotNet.Packets.Ip
throw new ArgumentException("given options take " + BytesLength + " bytes and maximum number of bytes for options is " + maximumBytesLength, "options");
}
internal override sealed int CalculateBytesLength(int optionsLength)
internal sealed override int CalculateBytesLength(int optionsLength)
{
if (optionsLength % 4 == 0)
return optionsLength;
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.Ip;
namespace PcapDotNet.Packets.IpV4
......@@ -67,9 +68,9 @@ namespace PcapDotNet.Packets.IpV4
/// The hash code of the option is the hash code of the option type.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
public sealed override int GetHashCode()
{
return OptionType.GetHashCode();
return Sequence.GetHashCode(OptionType, GetDataHashCode());
}
/// <summary>
......@@ -80,6 +81,8 @@ namespace PcapDotNet.Packets.IpV4
return OptionType.ToString();
}
internal abstract int GetDataHashCode();
internal sealed override V4Option Read(byte[] buffer, ref int offset, int length)
{
int offsetEnd = offset + length;
......
......@@ -174,10 +174,9 @@ namespace PcapDotNet.Packets.IpV4
/// with the hash code of the combination of the classification level, protection authority and length.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
internal override int GetDataHashCode()
{
return base.GetHashCode() ^
BitSequence.Merge((byte)ClassificationLevel, (byte)ProtectionAuthorities,(byte)Length).GetHashCode();
return BitSequence.Merge((byte)ClassificationLevel, (byte)ProtectionAuthorities,(byte)Length).GetHashCode();
}
/// <summary>
......@@ -189,9 +188,6 @@ namespace PcapDotNet.Packets.IpV4
/// <returns>On success - the complex option read. On failure - null.</returns>
Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{
// if (buffer == null)
// throw new ArgumentNullException("buffer");
if (valueLength < OptionValueMinimumLength)
return null;
......
......@@ -192,16 +192,6 @@ namespace PcapDotNet.Packets.IpV4
return Equals(other as IpV4OptionQuickStart);
}
/// <summary>
/// The hash code is the xor of the base class hash code with the following values hash code:
/// The combination of function, rate and ttl and the nonce.
/// </summary>
public override int GetHashCode()
{
return base.GetHashCode() ^
Sequence.GetHashCode(BitSequence.Merge((byte)((byte)Function | Rate), Ttl), Nonce);
}
/// <summary>
/// Tries to read the option from a buffer starting from the option value (after the type and length).
/// </summary>
......@@ -224,6 +214,11 @@ namespace PcapDotNet.Packets.IpV4
return new IpV4OptionQuickStart(function, rate, ttl, nonce);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge((byte)((byte)Function | Rate), Ttl), Nonce);
}
internal override void Write(byte[] buffer, ref int offset)
{
base.Write(buffer, ref offset);
......
......@@ -79,14 +79,9 @@ namespace PcapDotNet.Packets.IpV4
return Equals(other as IpV4OptionRoute);
}
/// <summary>
/// The hash code of the route option is the xor of the following hash codes: base class, pointed address index and all the addresses in the route.
/// </summary>
public sealed override int GetHashCode()
internal override int GetDataHashCode()
{
return base.GetHashCode() ^
PointedAddressIndex.GetHashCode() ^
Route.SequenceGetHashCode();
return Sequence.GetHashCode(PointedAddressIndex, Route.SequenceGetHashCode());
}
internal sealed override void Write(byte[] buffer, ref int offset)
......
......@@ -104,15 +104,6 @@ namespace PcapDotNet.Packets.IpV4
return Equals(other as IpV4OptionRouterAlert);
}
/// <summary>
/// The hash code value is the xor of the base class hash code and the value hash code.
/// </summary>
public override int GetHashCode()
{
return base.GetHashCode() ^
Value.GetHashCode();
}
/// <summary>
/// Tries to read the option from a buffer starting from the option value (after the type and length).
/// </summary>
......@@ -129,6 +120,11 @@ namespace PcapDotNet.Packets.IpV4
return new IpV4OptionRouterAlert(value);
}
internal override int GetDataHashCode()
{
return Value.GetHashCode();
}
internal override void Write(byte[] buffer, ref int offset)
{
base.Write(buffer, ref offset);
......
......@@ -30,5 +30,10 @@ namespace PcapDotNet.Packets.IpV4
: base(optionType)
{
}
internal override int GetDataHashCode()
{
return 0;
}
}
}
\ No newline at end of file
......@@ -84,15 +84,6 @@ namespace PcapDotNet.Packets.IpV4
return Equals(other as IpV4OptionStreamIdentifier);
}
/// <summary>
/// The hash code value is the xor of the base class hash code and the identifier hash code.
/// </summary>
public override int GetHashCode()
{
return base.GetHashCode() ^
Identifier.GetHashCode();
}
/// <summary>
/// Tries to read the option from a buffer starting from the option value (after the type and length).
/// </summary>
......@@ -109,6 +100,11 @@ namespace PcapDotNet.Packets.IpV4
return new IpV4OptionStreamIdentifier(identifier);
}
internal override int GetDataHashCode()
{
return Identifier.GetHashCode();
}
internal override void Write(byte[] buffer, ref int offset)
{
base.Write(buffer, ref offset);
......
......@@ -201,13 +201,9 @@ namespace PcapDotNet.Packets.IpV4
return Equals(other as IpV4OptionTimestamp);
}
/// <summary>
/// The hash code is the xor of the base class hash code, the timestamp and overflow hash code and the pointed index hash code.
/// </summary>
public override int GetHashCode()
internal override int GetDataHashCode()
{
return base.GetHashCode() ^
Sequence.GetHashCode(BitSequence.Merge((byte)TimestampType, Overflow), PointedIndex);
return Sequence.GetHashCode(BitSequence.Merge((byte)TimestampType, Overflow), PointedIndex);
}
internal sealed override void Write(byte[] buffer, ref int offset)
......
......@@ -58,12 +58,9 @@ namespace PcapDotNet.Packets.IpV4
get { return _addressesAndTimestamps; }
}
/// <summary>
/// The hash of this option is the base class hash xored with the hash of each timestamp.
/// </summary>
public override int GetHashCode()
internal override int GetDataHashCode()
{
return base.GetHashCode() ^ TimedRoute.SequenceGetHashCode();
return TimedRoute.SequenceGetHashCode();
}
internal static IpV4OptionTimestampAndAddress Read(IpV4OptionTimestampType timestampType, byte overflow, byte pointedIndex, byte[] buffer, ref int offset, int numValues)
......
......@@ -49,12 +49,9 @@ namespace PcapDotNet.Packets.IpV4
get { return _timestamps; }
}
/// <summary>
/// The hash code of this options is the hash code of the base class xored with the hash code of the timestamps.
/// </summary>
public override int GetHashCode()
internal override int GetDataHashCode()
{
return base.GetHashCode() ^ Timestamps.SequenceGetHashCode();
return Timestamps.SequenceGetHashCode();
}
internal static IpV4OptionTimestampOnly Read(byte overflow, byte pointedIndex, byte[] buffer, ref int offset, int numValues)
......
......@@ -161,17 +161,6 @@ namespace PcapDotNet.Packets.IpV4
return Equals(other as IpV4OptionTraceRoute);
}
/// <summary>
/// The hash code is the xor of the base class hash code with the following values hash code:
/// The identification, the combination of the outbound and return hop count, the originator address.
/// </summary>
public override int GetHashCode()
{
return base.GetHashCode() ^
Sequence.GetHashCode(Identification, BitSequence.Merge(OutboundHopCount, ReturnHopCount), OriginatorIpAddress);
}
/// <summary>
/// Tries to read the option from a buffer starting from the option value (after the type and length).
/// </summary>
......@@ -192,6 +181,11 @@ namespace PcapDotNet.Packets.IpV4
return new IpV4OptionTraceRoute(identification, outboundHopCount, returnHopCount, originatorIpAddress);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(Identification, BitSequence.Merge(OutboundHopCount, ReturnHopCount), OriginatorIpAddress);
}
internal override void Write(byte[] buffer, ref int offset)
{
base.Write(buffer, ref offset);
......
......@@ -80,14 +80,6 @@ namespace PcapDotNet.Packets.IpV4
return Equals(other as IpV4OptionUnknown);
}
/// <summary>
/// The hash code for an unknown option is the hash code for the option type xored with the hash code of the data.
/// </summary>
public override int GetHashCode()
{
return base.GetHashCode() ^ Data.BytesSequenceGetHashCode();
}
/// <summary>
/// Creates an unknown option from its type and by reading a buffer for its value.
/// </summary>
......@@ -108,6 +100,14 @@ namespace PcapDotNet.Packets.IpV4
return new IpV4OptionUnknown(optionType, data);
}
/// <summary>
/// The hash code for an unknown option is the hash code for the option type xored with the hash code of the data.
/// </summary>
internal override int GetDataHashCode()
{
return Data.BytesSequenceGetHashCode();
}
internal override void Write(byte[] buffer, ref int offset)
{
base.Write(buffer, ref offset);
......
......@@ -9,7 +9,7 @@ namespace PcapDotNet.Packets.IpV4
/// They must be implemented by all IP modules (host and gateways).
/// What is optional is their transmission in any particular datagram, not their implementation.
/// </summary>
public class IpV4Options : V4Options<IpV4Option>
public sealed class IpV4Options : V4Options<IpV4Option>
{
/// <summary>
/// The maximum number of bytes the options may take.
......
......@@ -25,7 +25,7 @@ namespace PcapDotNet.Packets.IpV6
public abstract bool IsValid { get; }
public override sealed bool Equals(object obj)
public sealed override bool Equals(object obj)
{
return Equals(obj as IpV6ExtensionHeader);
}
......
......@@ -21,12 +21,12 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
public abstract class IpV6ExtensionHeaderMobility : IpV6ExtensionHeaderStandard
{
public override sealed IpV4Protocol Protocol
public sealed override IpV4Protocol Protocol
{
get { return IpV4Protocol.MobilityHeader; }
}
public override sealed bool IsValid
public sealed override bool IsValid
{
get { return MobilityOptions.IsValid; }
}
......@@ -164,7 +164,7 @@ namespace PcapDotNet.Packets.IpV6
}
}
internal override sealed void WriteData(byte[] buffer, int offset)
internal sealed override void WriteData(byte[] buffer, int offset)
{
buffer.Write(offset + DataOffset.MobilityHeaderType, (byte)MobilityHeaderType);
buffer.Write(offset + DataOffset.Checksum, Checksum, Endianity.Big);
......@@ -173,14 +173,14 @@ namespace PcapDotNet.Packets.IpV6
internal abstract void WriteMessageData(byte[] buffer, int offset);
internal override sealed int DataLength
internal sealed override int DataLength
{
get { return MinimumDataLength + MessageDataLength; }
}
internal abstract int MessageDataLength { get; }
internal override sealed bool EqualsData(IpV6ExtensionHeader other)
internal sealed override bool EqualsData(IpV6ExtensionHeader other)
{
return EqualsData(other as IpV6ExtensionHeaderMobility);
}
......
......@@ -125,7 +125,7 @@ namespace PcapDotNet.Packets.IpV6
return true;
}
internal override sealed void WriteMessageData(byte[] buffer, int offset)
internal sealed override void WriteMessageData(byte[] buffer, int offset)
{
buffer.Write(offset + MessageDataOffset.Status, (byte)Status);
if (KeyManagementMobilityCapability)
......
......@@ -39,7 +39,7 @@ namespace PcapDotNet.Packets.IpV6
/// <summary>
/// Defines the type of the Binding Revocation Message.
/// </summary>
public override sealed IpV6MobilityBindingRevocationType BindingRevocationType
public sealed override IpV6MobilityBindingRevocationType BindingRevocationType
{
get { return IpV6MobilityBindingRevocationType.BindingRevocationAcknowledgement; }
}
......
......@@ -61,7 +61,7 @@ namespace PcapDotNet.Packets.IpV6
/// Identifies the particular mobility message in question.
/// An unrecognized MH Type field causes an error indication to be sent.
/// </summary>
public override sealed IpV6MobilityHeaderType MobilityHeaderType
public sealed override IpV6MobilityHeaderType MobilityHeaderType
{
get { return IpV6MobilityHeaderType.BindingRevocationMessage; }
}
......@@ -144,7 +144,7 @@ namespace PcapDotNet.Packets.IpV6
}
}
internal override sealed void WriteMessageData(byte[] buffer, int offset)
internal sealed override void WriteMessageData(byte[] buffer, int offset)
{
buffer.Write(offset + MessageDataOffset.BindingRevocationType, (byte)BindingRevocationType);
buffer.Write(offset + MessageDataOffset.RevocationTriggerOrStatus, RevocationTriggerOrStatus);
......
......@@ -69,7 +69,7 @@ namespace PcapDotNet.Packets.IpV6
get { return MinimumMessageDataLength + MobilityOptions.BytesLength; }
}
internal override sealed bool EqualsMessageData(IpV6ExtensionHeaderMobility other)
internal sealed override bool EqualsMessageData(IpV6ExtensionHeaderMobility other)
{
return EqualsMessageData(other as IpV6ExtensionHeaderMobilityLocalizedRouting);
}
......@@ -92,7 +92,7 @@ namespace PcapDotNet.Packets.IpV6
return true;
}
internal override sealed void WriteMessageData(byte[] buffer, int offset)
internal sealed override void WriteMessageData(byte[] buffer, int offset)
{
buffer.Write(offset + MessageDataOffset.SequenceNumber, SequenceNumber, Endianity.Big);
WriteMessageDataBetweenSequenceNumberAndLifetime(buffer, offset);
......
......@@ -20,17 +20,17 @@ namespace PcapDotNet.Packets.IpV6
{
public IpV6Options Options { get; private set; }
public override sealed bool IsValid
public sealed override bool IsValid
{
get { return Options.IsValid; }
}
internal override sealed int DataLength
internal sealed override int DataLength
{
get { return Options.BytesLength; }
}
internal override sealed bool EqualsData(IpV6ExtensionHeader other)
internal sealed override bool EqualsData(IpV6ExtensionHeader other)
{
return EqualsData(other as IpV6ExtensionHeaderOptions);
}
......
......@@ -52,14 +52,14 @@ namespace PcapDotNet.Packets.IpV6
SegmentsLeft = segmentsLeft;
}
internal override sealed int DataLength
internal sealed override int DataLength
{
get { return DataMinimumLength + RoutingDataLength; }
}
internal abstract int RoutingDataLength { get; }
internal override sealed bool EqualsData(IpV6ExtensionHeader other)
internal sealed override bool EqualsData(IpV6ExtensionHeader other)
{
return EqualsData(other as IpV6ExtensionHeaderRouting);
}
......@@ -93,7 +93,7 @@ namespace PcapDotNet.Packets.IpV6
}
}
internal override sealed void WriteData(byte[] buffer, int offset)
internal sealed override void WriteData(byte[] buffer, int offset)
{
buffer.Write(offset + DataOffset.RoutingType, (byte)RoutingType);
buffer.Write(offset + DataOffset.SegmentsLeft, SegmentsLeft);
......
......@@ -29,7 +29,7 @@ namespace PcapDotNet.Packets.IpV6
public const int MinimumLength = 8;
public override sealed bool Equals(IpV6ExtensionHeader other)
public sealed override bool Equals(IpV6ExtensionHeader other)
{
return other != null &&
Protocol == other.Protocol && NextHeader == other.NextHeader && EqualsData(other);
......@@ -42,7 +42,7 @@ namespace PcapDotNet.Packets.IpV6
{
}
internal override sealed void Write(byte[] buffer, ref int offset)
internal sealed override void Write(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.NextHeader, (byte)NextHeader);
int length = Length;
......@@ -53,7 +53,7 @@ namespace PcapDotNet.Packets.IpV6
internal abstract void WriteData(byte[] buffer, int offset);
public override sealed int Length { get { return Offset.Data + DataLength; } }
public sealed override int Length { get { return Offset.Data + DataLength; } }
internal abstract int DataLength { get; }
internal static bool IsStandard(IpV4Protocol nextHeader)
{
......
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
/// IPv6 Routing Type.
/// Used in Routing Extension Header.
/// </summary>
public enum IpV6RoutingType : byte
{
/// <summary>
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.Ip;
namespace PcapDotNet.Packets.IpV6
......@@ -20,7 +21,7 @@ namespace PcapDotNet.Packets.IpV6
OptionType = type;
}
public override sealed int Length
public sealed override int Length
{
get { return sizeof(byte) + sizeof(byte) + DataLength; }
}
......@@ -31,15 +32,22 @@ namespace PcapDotNet.Packets.IpV6
OptionType == other.OptionType && Length == other.Length && EqualsData(other);
}
public override sealed bool Equals(Option other)
public sealed override bool Equals(Option other)
{
return Equals(other as IpV6AccessNetworkIdentifierSubOption);
}
public override int GetHashCode()
{
return Sequence.GetHashCode(OptionType, GetDataHashCode());
}
internal abstract int DataLength { get; }
internal abstract bool EqualsData(IpV6AccessNetworkIdentifierSubOption other);
internal abstract int GetDataHashCode();
internal override void Write(byte[] buffer, ref int offset)
{
buffer[offset++] = (byte)OptionType;
......
......@@ -111,6 +111,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6AccessNetworkIdentifierSubOptionGeoLocation);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(LongitudeDegrees, LatitudeDegrees);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.LatitudeDegrees, LatitudeDegrees, Endianity.Big);
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
......@@ -119,6 +120,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6AccessNetworkIdentifierSubOptionNetworkIdentifier);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(IsNetworkNameUtf8, NetworkName, AccessPointName);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
if (IsNetworkNameUtf8)
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -67,6 +69,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6AccessNetworkIdentifierSubOptionOperatorIdentifier);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(IdentifierType, Identifier);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.IdentifierType, (byte)IdentifierType);
......
......@@ -40,6 +40,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6AccessNetworkIdentifierSubOptionUnknown);
}
internal override int GetDataHashCode()
{
return Data.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, Data);
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.Ip;
namespace PcapDotNet.Packets.IpV6
......@@ -25,7 +26,7 @@ namespace PcapDotNet.Packets.IpV6
OptionType = type;
}
public override sealed bool Equals(Option other)
public sealed override bool Equals(Option other)
{
return Equals(other as IpV6FlowIdentificationSubOption);
}
......@@ -36,8 +37,15 @@ namespace PcapDotNet.Packets.IpV6
OptionType == other.OptionType && Length == other.Length && EqualsData(other);
}
public sealed override int GetHashCode()
{
return Sequence.GetHashCode(OptionType, GetDataHashCode());
}
internal abstract bool EqualsData(IpV6FlowIdentificationSubOption other);
internal abstract object GetDataHashCode();
internal override void Write(byte[] buffer, ref int offset)
{
buffer[offset++] = (byte)OptionType;
......
......@@ -69,6 +69,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6FlowIdentificationSubOptionBindingReference);
}
internal override object GetDataHashCode()
{
return BindingIds.UShortsSequenceGetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
foreach (ushort bindingId in BindingIds)
......
......@@ -20,14 +20,14 @@ namespace PcapDotNet.Packets.IpV6
{
}
public override sealed int Length
public sealed override int Length
{
get { return base.Length + sizeof(byte) + DataLength; }
}
internal abstract int DataLength { get; }
internal override sealed void Write(byte[] buffer, ref int offset)
internal sealed override void Write(byte[] buffer, ref int offset)
{
base.Write(buffer, ref offset);
buffer[offset++] = (byte)DataLength;
......
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
/// RFC 6089.
/// </summary>
public sealed class IpV6FlowIdentificationSubOptionPad1 : IpV6FlowIdentificationSubOptionSimple
{
/// <summary>
/// The number of bytes this option take.
/// </summary>
public const int OptionLength = sizeof(byte);
/// <summary>
/// Constructs the option.
/// </summary>
public IpV6FlowIdentificationSubOptionPad1()
: base(IpV6FlowIdentificationSubOptionType.Pad1)
{
......
......@@ -38,7 +38,12 @@ namespace PcapDotNet.Packets.IpV6
internal override bool EqualsData(IpV6FlowIdentificationSubOption other)
{
return true;
return EqualsData(other as IpV6FlowIdentificationSubOptionPadN);
}
internal override object GetDataHashCode()
{
return PaddingDataLength.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
......@@ -50,5 +55,11 @@ namespace PcapDotNet.Packets.IpV6
: this(0)
{
}
private bool EqualsData(IpV6FlowIdentificationSubOptionPadN other)
{
return other != null &&
PaddingDataLength == other.PaddingDataLength;
}
}
}
\ No newline at end of file
......@@ -19,22 +19,27 @@ namespace PcapDotNet.Packets.IpV6
{
}
public override sealed int Length
public sealed override int Length
{
get { return base.Length; }
}
internal override sealed bool EqualsData(IpV6FlowIdentificationSubOption other)
internal sealed override bool EqualsData(IpV6FlowIdentificationSubOption other)
{
return true;
}
internal override sealed void Write(byte[] buffer, ref int offset)
internal override object GetDataHashCode()
{
return 0;
}
internal sealed override void Write(byte[] buffer, ref int offset)
{
base.Write(buffer, ref offset);
}
internal override sealed IpV6FlowIdentificationSubOption CreateInstance(DataSegment data)
internal sealed override IpV6FlowIdentificationSubOption CreateInstance(DataSegment data)
{
throw new InvalidOperationException("Simple options shouldn't be registered.");
}
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -63,6 +65,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6FlowIdentificationSubOptionTrafficSelector);
}
internal override object GetDataHashCode()
{
return Sequence.GetHashCode(TrafficSelectorFormat, TrafficSelector);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.TrafficSelectorFormat, (byte)TrafficSelectorFormat);
......
......@@ -40,6 +40,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6FlowIdentificationSubOptionUnknown);
}
internal override object GetDataHashCode()
{
return Data.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, Data);
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.Ip;
namespace PcapDotNet.Packets.IpV6
......@@ -39,6 +40,11 @@ namespace PcapDotNet.Packets.IpV6
OptionType == other.OptionType && Length == other.Length && EqualsData(other);
}
public sealed override int GetHashCode()
{
return Sequence.GetHashCode(OptionType, GetDataHashCode());
}
public virtual bool IsValid { get { return true; } }
protected IpV6MobilityOption(IpV6MobilityOptionType type)
......@@ -46,6 +52,8 @@ namespace PcapDotNet.Packets.IpV6
OptionType = type;
}
internal abstract int GetDataHashCode();
internal abstract IpV6MobilityOption CreateInstance(DataSegment data);
internal override void Write(byte[] buffer, ref int offset)
......
......@@ -51,6 +51,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionAccessNetworkIdentifier);
}
internal override int GetDataHashCode()
{
return SubOptions.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
SubOptions.Write(buffer, offset);
......
......@@ -50,6 +50,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionAlternateIpV4CareOfAddress);
}
internal override int GetDataHashCode()
{
return AlternateCareOfAddress.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, AlternateCareOfAddress, Endianity.Big);
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -80,6 +82,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionAuthentication);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(Subtype, MobilitySecurityParameterIndex, AuthenticationData);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.Subtype, (byte)Subtype);
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -100,6 +102,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionBindingAuthorizationDataForFmIpV6);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(SecurityParameterIndex, Authenticator);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.SecurityParameterIndex, SecurityParameterIndex, Endianity.Big);
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.IpV6
......@@ -155,6 +156,12 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionBindingIdentifier);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge((byte)Status, Priority, BindingId), SimultaneousHomeAndForeignBinding, IpV4CareOfAddress,
IpV6CareOfAddress);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.BindingId, BindingId, Endianity.Big);
......
......@@ -47,6 +47,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionBindingRefreshAdvice);
}
internal override int GetDataHashCode()
{
return RefreshInterval.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, RefreshInterval, Endianity.Big);
......
......@@ -22,7 +22,7 @@ namespace PcapDotNet.Packets.IpV6
{
}
public override sealed int Length
public sealed override int Length
{
get { return base.Length + sizeof(byte) + DataLength; }
}
......@@ -31,7 +31,7 @@ namespace PcapDotNet.Packets.IpV6
internal abstract int DataLength { get; }
internal override sealed void Write(byte[] buffer, ref int offset)
internal sealed override void Write(byte[] buffer, ref int offset)
{
base.Write(buffer, ref offset);
buffer[offset++] = (byte)DataLength;
......
......@@ -82,6 +82,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionContextRequest);
}
internal override int GetDataHashCode()
{
return Requests.SequenceGetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
foreach (var request in Requests)
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -82,6 +84,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionDnsUpdate);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge((byte)Status, Remove.ToByte()), MobileNodeIdentity);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.Status, (byte)Status);
......
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
/// An IPv6 Mobility option with an empty data.
/// </summary>
public abstract class IpV6MobilityOptionEmpty : IpV6MobilityOptionComplex
{
/// <summary>
/// The number of bytes this option data takes.
/// </summary>
public const int OptionDataLength = 0;
public IpV6MobilityOptionEmpty(IpV6MobilityOptionType type)
internal IpV6MobilityOptionEmpty(IpV6MobilityOptionType type)
: base(type)
{
}
internal override sealed int DataLength
internal sealed override int DataLength
{
get { return OptionDataLength; }
}
internal override sealed bool EqualsData(IpV6MobilityOption other)
internal sealed override bool EqualsData(IpV6MobilityOption other)
{
return true;
}
internal override sealed void WriteData(byte[] buffer, ref int offset)
internal override int GetDataHashCode()
{
return 0;
}
internal sealed override void WriteData(byte[] buffer, ref int offset)
{
}
}
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
......@@ -110,6 +111,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionFlowIdentification);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge(FlowIdentifier, Priority), Status, SubOptions);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.FlowIdentifier, FlowIdentifier, Endianity.Big);
......
......@@ -74,6 +74,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionFlowSummary);
}
internal override int GetDataHashCode()
{
return FlowIdentifiers.SequenceGetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
foreach (ushort flowIdentifier in FlowIdentifiers)
......
......@@ -57,6 +57,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionGreKey);
}
internal override int GetDataHashCode()
{
return GreKeyIdentifier.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.GreKeyIdentifier, GreKeyIdentifier, Endianity.Big);
......
......@@ -46,7 +46,7 @@ namespace PcapDotNet.Packets.IpV6
return true;
}
internal override sealed int DataLength
internal sealed override int DataLength
{
get { return OptionDataLength; }
}
......@@ -56,7 +56,12 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionIpV4Address);
}
internal override sealed void WriteData(byte[] buffer, ref int offset)
internal override int GetDataHashCode()
{
return Address.GetHashCode();
}
internal sealed override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.Address, Address, Endianity.Big);
offset += OptionDataLength;
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.IpV6
......@@ -97,6 +98,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionIpV4AddressAcknowledgement);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge((byte)Status, PrefixLength), HomeAddress);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.Status, (byte)Status);
......
......@@ -59,6 +59,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionIpV4DhcpSupportMode);
}
internal override int GetDataHashCode()
{
return IsServer.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
if (IsServer)
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.IpV6
......@@ -101,6 +102,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionIpV4HomeAddress);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge(PrefixLength, RequestPrefix.ToByte()), HomeAddress);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
byte prefixLengthAndRequestPrefix = (byte)(PrefixLength << Shift.PrefixLength);
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.IpV6
......@@ -91,6 +92,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionIpV4HomeAddressReply);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge((byte)Status, PrefixLength), HomeAddress);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.Status, (byte)Status);
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.IpV6
......@@ -91,6 +92,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionIpV4HomeAddressRequest);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(PrefixLength, HomeAddress);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.PrefixLength, (byte)(PrefixLength << Shift.PrefixLength));
......
......@@ -42,17 +42,22 @@ namespace PcapDotNet.Packets.IpV6
return true;
}
internal override sealed int DataLength
internal sealed override int DataLength
{
get { return OptionDataLength; }
}
internal override sealed bool EqualsData(IpV6MobilityOption other)
internal sealed override bool EqualsData(IpV6MobilityOption other)
{
return EqualsData(other as IpV6MobilityOptionIpV6Address);
}
internal override sealed void WriteData(byte[] buffer, ref int offset)
internal sealed override int GetDataHashCode()
{
return Address.GetHashCode();
}
internal sealed override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, Address, Endianity.Big);
}
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
......@@ -85,6 +86,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionIpV6AddressPrefix);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(BitSequence.Merge((byte)Code, PrefixLength), AddressOrPrefix);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.Code, (byte)Code);
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -63,6 +65,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionLinkLayerAddress);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(Code, LinkLayerAddress);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.OptionCode, (byte)Code);
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -94,6 +96,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionLoadInformation);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(Priority, SessionsInUse, MaximumSessions, UsedCapacity, MaximumCapacity);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.Priority, Priority, Endianity.Big);
......
using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.IpV6
......@@ -108,6 +109,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionLocalMobilityAnchorAddress);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(Code, LocalMobilityAnchorAddressIpV4, LocalMobilityAnchorAddressIpV6);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.Code, (byte)Code);
......
......@@ -66,6 +66,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionMobileAccessGatewayIpV6Address);
}
internal override int GetDataHashCode()
{
return Address.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.AddressLength, AddressLength);
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -67,6 +69,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionMobileNodeGroupIdentifier);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(SubType, MobileNodeGroupIdentifier);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.SubType, (byte)SubType);
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
......@@ -76,6 +77,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionMobileNodeIdentifier);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(Subtype, Identifier);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.Subtype, (byte)Subtype);
......
......@@ -55,6 +55,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionMobileNodeLinkLayerIdentifier);
}
internal override int GetDataHashCode()
{
return LinkLayerIdentifier.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.LinkLayerIdentifier, LinkLayerIdentifier);
......
......@@ -57,6 +57,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionMobileNodeLinkLocalAddressInterfaceIdentifier);
}
internal override int GetDataHashCode()
{
return InterfaceIdentifier.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.InterfaceIdentifier, InterfaceIdentifier, Endianity.Big);
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -76,6 +78,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionNatDetection);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(UdpEncapsulationRequired, RefreshTime);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
byte udpEncapsulationRequired = 0;
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -48,17 +50,22 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
public IpV6Address NetworkPrefix { get; private set; }
internal override sealed int DataLength
internal sealed override int DataLength
{
get { return OptionDataLength; }
}
internal override sealed bool EqualsData(IpV6MobilityOption other)
internal sealed override bool EqualsData(IpV6MobilityOption other)
{
return EqualsData(other as IpV6MobilityOptionNetworkPrefix);
}
internal override sealed void WriteData(byte[] buffer, ref int offset)
internal sealed override int GetDataHashCode()
{
return Sequence.GetHashCode(PrefixLength, NetworkPrefix);
}
internal sealed override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.PrefixLength, PrefixLength);
buffer.Write(offset + Offset.NetworkPrefix, NetworkPrefix, Endianity.Big);
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -64,6 +66,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionNonceIndices);
}
internal override int GetDataHashCode()
{
return BitSequence.Merge(HomeNonceIndex, CareOfNonceIndex).GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, HomeNonceIndex, Endianity.Big);
......
using System;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -38,7 +40,12 @@ namespace PcapDotNet.Packets.IpV6
internal override bool EqualsData(IpV6MobilityOption other)
{
return true;
return EqualsData(other as IpV6MobilityOptionPadN);
}
internal override int GetDataHashCode()
{
return PaddingDataLength.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
......@@ -50,5 +57,11 @@ namespace PcapDotNet.Packets.IpV6
: this(0)
{
}
private bool EqualsData(IpV6MobilityOptionPadN other)
{
return other != null &&
PaddingDataLength == other.PaddingDataLength;
}
}
}
\ No newline at end of file
using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.IpV6
......@@ -99,6 +100,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionRedirect);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(LocalMobilityAddressIpV4, LocalMobilityAddressIpV6);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
if (LocalMobilityAddressIpV4.HasValue)
......
......@@ -40,6 +40,11 @@ namespace PcapDotNet.Packets.IpV6
return true;
}
internal override int GetDataHashCode()
{
return 0;
}
internal override void WriteData(byte[] buffer, ref int offset)
{
offset += DataLength;
......
......@@ -41,7 +41,7 @@ namespace PcapDotNet.Packets.IpV6
return true;
}
internal override sealed int DataLength
internal sealed override int DataLength
{
get { return OptionDataLength; }
}
......@@ -51,7 +51,12 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionReservedByteValueByte);
}
internal override sealed void WriteData(byte[] buffer, ref int offset)
internal sealed override int GetDataHashCode()
{
return Value.GetHashCode();
}
internal sealed override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.Value, Value);
offset += DataLength;
......
......@@ -48,6 +48,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionRestartCounter);
}
internal override int GetDataHashCode()
{
return RestartCounter.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, RestartCounter, Endianity.Big);
......
......@@ -22,17 +22,22 @@ namespace PcapDotNet.Packets.IpV6
internal DataSegment Value { get; private set; }
internal override sealed int DataLength
internal sealed override int DataLength
{
get { return Value.Length; }
}
internal override sealed bool EqualsData(IpV6MobilityOption other)
internal sealed override bool EqualsData(IpV6MobilityOption other)
{
return EqualsData(other as IpV6MobilityOptionSingleDataSegmentField);
}
internal override sealed void WriteData(byte[] buffer, ref int offset)
internal sealed override int GetDataHashCode()
{
return Value.GetHashCode();
}
internal sealed override void WriteData(byte[] buffer, ref int offset)
{
Value.Write(buffer, ref offset);
}
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -67,6 +69,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6MobilityOptionTransientBinding);
}
internal override int GetDataHashCode()
{
return BitSequence.Merge(LatePathSwitch.ToByte(), Lifetime).GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
if (LatePathSwitch)
......
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
/// Type of an IPv6 Mobility option.
/// </summary>
public enum IpV6MobilityOptionType : byte
{
/// <summary>
......
......@@ -38,17 +38,22 @@ namespace PcapDotNet.Packets.IpV6
return true;
}
internal override sealed int DataLength
internal sealed override int DataLength
{
get { return OptionDataLength; }
}
internal override sealed bool EqualsData(IpV6MobilityOption other)
internal sealed override bool EqualsData(IpV6MobilityOption other)
{
return EqualsData(other as IpV6MobilityOptionULong);
}
internal override sealed void WriteData(byte[] buffer, ref int offset)
internal sealed override int GetDataHashCode()
{
return Value.GetHashCode();
}
internal sealed override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, Value, Endianity.Big);
}
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -75,11 +77,16 @@ namespace PcapDotNet.Packets.IpV6
get { return OptionDataMinimumLength + Data.Length; }
}
internal sealed override bool EqualsData(IpV6MobilityOption other)
internal override bool EqualsData(IpV6MobilityOption other)
{
return EqualsData(other as IpV6MobilityOptionVendorSpecific);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(VendorId, SubType, Data);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(offset + Offset.VendorId, VendorId, Endianity.Big);
......
......@@ -6,6 +6,9 @@ using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
/// Set of Mobility options for IPv6 Mobility Extension Header.
/// </summary>
public class IpV6MobilityOptions : V6Options<IpV6MobilityOption>
{
/// <summary>
......
using System;
using PcapDotNet.Base;
using PcapDotNet.Packets.Ip;
namespace PcapDotNet.Packets.IpV6
......@@ -39,8 +40,15 @@ namespace PcapDotNet.Packets.IpV6
OptionType == other.OptionType && Length == other.Length && EqualsData(other);
}
public sealed override int GetHashCode()
{
return Sequence.GetHashCode(OptionType, GetDataHashCode());
}
internal abstract bool EqualsData(IpV6Option other);
internal abstract int GetDataHashCode();
internal override void Write(byte[] buffer, ref int offset)
{
buffer[offset++] = (byte)OptionType;
......
......@@ -160,6 +160,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6OptionCalipso);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(DomainOfInterpretation, BitSequence.Merge(CompartmentLength, SensitivityLevel, Checksum), CompartmentBitmap);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, (uint)DomainOfInterpretation, Endianity.Big);
......
......@@ -22,14 +22,14 @@ namespace PcapDotNet.Packets.IpV6
{
}
public override sealed int Length
public sealed override int Length
{
get { return sizeof(byte) + sizeof (byte) + DataLength; }
}
internal abstract int DataLength { get; }
internal override sealed void Write(byte[] buffer, ref int offset)
internal sealed override void Write(byte[] buffer, ref int offset)
{
base.Write(buffer, ref offset);
buffer[offset++] = (byte)DataLength;
......
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
......@@ -69,6 +71,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6OptionEndpointIdentification);
}
internal override int GetDataHashCode()
{
return Sequence.GetHashCode(SourceEndpointIdentifier, DestinationEndpointIdentifier);
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, (byte)SourceEndpointIdentifier.Length);
......
......@@ -55,6 +55,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6OptionHomeAddress);
}
internal override int GetDataHashCode()
{
return HomeAddress.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, HomeAddress, Endianity.Big);
......
......@@ -44,6 +44,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6OptionIlnpNonce);
}
internal override int GetDataHashCode()
{
return Nonce.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, Nonce);
......
......@@ -47,6 +47,11 @@ namespace PcapDotNet.Packets.IpV6
return EqualsData(other as IpV6OptionJumboPayload);
}
internal override int GetDataHashCode()
{
return JumboPayloadLength.GetHashCode();
}
internal override void WriteData(byte[] buffer, ref int offset)
{
buffer.Write(ref offset, JumboPayloadLength, Endianity.Big);
......
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