Commit 76ba668c authored by Brickner_cp's avatar Brickner_cp

287 warnings left.

parent 0abdb7bc
...@@ -12,12 +12,12 @@ namespace PcapDotNet.Base ...@@ -12,12 +12,12 @@ namespace PcapDotNet.Base
/// </summary> /// </summary>
public static int GetHashCode(object value1, object value2) public static int GetHashCode(object value1, object value2)
{ {
if (value1 == null) int hashCode = 0;
return value2.GetHashCode(); if (value1 != null)
if (value2 == null) hashCode ^= value1.GetHashCode();
return value1.GetHashCode(); if (value2 != null)
hashCode ^= value2.GetHashCode();
return value1.GetHashCode() ^ value2.GetHashCode(); return hashCode;
} }
/// <summary> /// <summary>
......
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
<Word>satnet</Word> <Word>satnet</Word>
<Word>sha</Word> <Word>sha</Word>
<Word>sitara</Word> <Word>sitara</Word>
<Word>sll</Word>
<Word>sna</Word> <Word>sna</Word>
<Word>ssh</Word> <Word>ssh</Word>
<Word>tcf</Word> <Word>tcf</Word>
......
...@@ -52,7 +52,7 @@ namespace PcapDotNet.Core.Test ...@@ -52,7 +52,7 @@ namespace PcapDotNet.Core.Test
StringBuilder quickStartWireshark = new StringBuilder("Quick-Start: "); StringBuilder quickStartWireshark = new StringBuilder("Quick-Start: ");
quickStartWireshark.Append(quickStart.Function == IpV4OptionQuickStartFunction.RateRequest ? "Rate request" : "Rate report"); quickStartWireshark.Append(quickStart.QuickStartFunction == IpV4OptionQuickStartFunction.RateRequest ? "Rate request" : "Rate report");
quickStartWireshark.Append(", "); quickStartWireshark.Append(", ");
...@@ -65,7 +65,7 @@ namespace PcapDotNet.Core.Test ...@@ -65,7 +65,7 @@ namespace PcapDotNet.Core.Test
else else
quickStartWireshark.Append(((double)quickStart.RateKbps / 1000000).ToString(CultureInfo.InvariantCulture) + " Gbit/s"); quickStartWireshark.Append(((double)quickStart.RateKbps / 1000000).ToString(CultureInfo.InvariantCulture) + " Gbit/s");
if (quickStart.Function == IpV4OptionQuickStartFunction.RateRequest) if (quickStart.QuickStartFunction == IpV4OptionQuickStartFunction.RateRequest)
quickStartWireshark.Append(", QS TTL " + quickStart.Ttl); quickStartWireshark.Append(", QS TTL " + quickStart.Ttl);
return quickStartWireshark.ToString(); return quickStartWireshark.ToString();
......
...@@ -114,6 +114,7 @@ namespace PcapDotNet.Core.Test ...@@ -114,6 +114,7 @@ namespace PcapDotNet.Core.Test
protocol == IpV4Protocol.DissimilarGatewayProtocol || protocol == IpV4Protocol.DissimilarGatewayProtocol ||
protocol == IpV4Protocol.SpriteRpc || protocol == IpV4Protocol.SpriteRpc ||
protocol == IpV4Protocol.CombatRadioUserDatagram || protocol == IpV4Protocol.CombatRadioUserDatagram ||
protocol == IpV4Protocol.Gmtp ||
protocol == IpV4Protocol.Shim6 || // TODO: Implement Shim6. protocol == IpV4Protocol.Shim6 || // TODO: Implement Shim6.
protocol == IpV4Protocol.RemoteVirtualDiskProtocol)) protocol == IpV4Protocol.RemoteVirtualDiskProtocol))
return false; return false;
......
...@@ -69,7 +69,7 @@ namespace PcapDotNet.Packets ...@@ -69,7 +69,7 @@ namespace PcapDotNet.Packets
/// <param name="offset">The offset in the array to start taking.</param> /// <param name="offset">The offset in the array to start taking.</param>
/// <param name="length">The number of bytes to take from the array.</param> /// <param name="length">The number of bytes to take from the array.</param>
/// <returns>A new DataSegment that is part of the given array.</returns> /// <returns>A new DataSegment that is part of the given array.</returns>
public static DataSegment SubSegment(this byte[] array, int offset, int length) public static DataSegment Subsegment(this byte[] array, int offset, int length)
{ {
return new DataSegment(array, offset, length); return new DataSegment(array, offset, length);
} }
......
...@@ -11,7 +11,7 @@ namespace PcapDotNet.Packets.Ip ...@@ -11,7 +11,7 @@ namespace PcapDotNet.Packets.Ip
/// <summary> /// <summary>
/// The function of this quick start option. /// The function of this quick start option.
/// </summary> /// </summary>
IpV4OptionQuickStartFunction Function { get; } IpV4OptionQuickStartFunction QuickStartFunction { get; }
/// <summary> /// <summary>
/// If function is request then this field is the rate request. /// If function is request then this field is the rate request.
......
...@@ -29,7 +29,7 @@ namespace PcapDotNet.Packets.Ip ...@@ -29,7 +29,7 @@ namespace PcapDotNet.Packets.Ip
public const byte Rate = 0x0F; public const byte Rate = 0x0F;
} }
internal static void AssertValidParameters(IpV4OptionQuickStartFunction function, byte rate, byte ttl, uint nonce) internal static void AssertValidParameters(IpV4OptionQuickStartFunction function, byte rate, uint nonce)
{ {
if (function != IpV4OptionQuickStartFunction.RateRequest && if (function != IpV4OptionQuickStartFunction.RateRequest &&
function != IpV4OptionQuickStartFunction.RateReport) function != IpV4OptionQuickStartFunction.RateReport)
......
...@@ -123,16 +123,11 @@ namespace PcapDotNet.Packets.Ip ...@@ -123,16 +123,11 @@ namespace PcapDotNet.Packets.Ip
buffer[offset++] = 0; buffer[offset++] = 0;
} }
internal Options(IList<T> options, bool isValid, int? length) internal Options(IList<T> options, bool isValid, int length)
{ {
_options = options.AsReadOnly(); _options = options.AsReadOnly();
IsValid = isValid; IsValid = isValid;
BytesLength = length;
if (length.HasValue)
BytesLength = length.Value;
else
BytesLength = CalculateBytesLength(SumBytesLength(OptionsCollection));
} }
internal static int SumBytesLength(IEnumerable<T> options) internal static int SumBytesLength(IEnumerable<T> options)
...@@ -140,8 +135,6 @@ namespace PcapDotNet.Packets.Ip ...@@ -140,8 +135,6 @@ namespace PcapDotNet.Packets.Ip
return options.Sum(option => option.Length); return options.Sum(option => option.Length);
} }
internal abstract int CalculateBytesLength(int optionsLength);
private readonly ReadOnlyCollection<T> _options; private readonly ReadOnlyCollection<T> _options;
} }
} }
\ No newline at end of file
...@@ -23,7 +23,7 @@ namespace PcapDotNet.Packets.Ip ...@@ -23,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"); throw new ArgumentException("given options take " + BytesLength + " bytes and maximum number of bytes for options is " + maximumBytesLength, "options");
} }
internal sealed override int CalculateBytesLength(int optionsLength) internal static int CalculateBytesLength(int optionsLength)
{ {
if (optionsLength % 4 == 0) if (optionsLength % 4 == 0)
return optionsLength; return optionsLength;
...@@ -36,7 +36,7 @@ namespace PcapDotNet.Packets.Ip ...@@ -36,7 +36,7 @@ namespace PcapDotNet.Packets.Ip
} }
private V4Options(IList<T> options, bool isValid, int? length) private V4Options(IList<T> options, bool isValid, int? length)
:base(options, isValid, length) : base(options, isValid, length ?? CalculateBytesLength(SumBytesLength(options)))
{ {
} }
......
...@@ -56,9 +56,9 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -56,9 +56,9 @@ namespace PcapDotNet.Packets.IpV4
public IpV4OptionQuickStart(IpV4OptionQuickStartFunction function, byte rate, byte ttl, uint nonce) public IpV4OptionQuickStart(IpV4OptionQuickStartFunction function, byte rate, byte ttl, uint nonce)
: base(IpV4OptionType.QuickStart) : base(IpV4OptionType.QuickStart)
{ {
IpOptionQuickStartCommon.AssertValidParameters(function, rate, ttl, nonce); IpOptionQuickStartCommon.AssertValidParameters(function, rate, nonce);
Function = function; QuickStartFunction = function;
Rate = rate; Rate = rate;
Ttl = ttl; Ttl = ttl;
Nonce = nonce; Nonce = nonce;
...@@ -75,7 +75,7 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -75,7 +75,7 @@ namespace PcapDotNet.Packets.IpV4
/// <summary> /// <summary>
/// The function of this quick start option. /// The function of this quick start option.
/// </summary> /// </summary>
public IpV4OptionQuickStartFunction Function { get; private set; } public IpV4OptionQuickStartFunction QuickStartFunction { get; private set; }
/// <summary> /// <summary>
/// If function is request then this field is the rate request. /// If function is request then this field is the rate request.
...@@ -178,7 +178,7 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -178,7 +178,7 @@ namespace PcapDotNet.Packets.IpV4
if (other == null) if (other == null)
return false; return false;
return Function == other.Function && return QuickStartFunction == other.QuickStartFunction &&
Rate == other.Rate && Rate == other.Rate &&
Ttl == other.Ttl && Ttl == other.Ttl &&
Nonce == other.Nonce; Nonce == other.Nonce;
...@@ -216,14 +216,14 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -216,14 +216,14 @@ namespace PcapDotNet.Packets.IpV4
internal override int GetDataHashCode() internal override int GetDataHashCode()
{ {
return Sequence.GetHashCode(BitSequence.Merge((byte)((byte)Function | Rate), Ttl), Nonce); return Sequence.GetHashCode(BitSequence.Merge((byte)((byte)QuickStartFunction | Rate), Ttl), Nonce);
} }
internal override void Write(byte[] buffer, ref int offset) internal override void Write(byte[] buffer, ref int offset)
{ {
base.Write(buffer, ref offset); base.Write(buffer, ref offset);
IpOptionQuickStartCommon.WriteData(buffer, ref offset, Function, Rate, Ttl, Nonce); IpOptionQuickStartCommon.WriteData(buffer, ref offset, QuickStartFunction, Rate, Ttl, Nonce);
} }
} }
} }
\ No newline at end of file
...@@ -253,10 +253,10 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -253,10 +253,10 @@ namespace PcapDotNet.Packets.IpV6
for (int i = 0; i != Addresses.Count - 1; ++i) for (int i = 0; i != Addresses.Count - 1; ++i)
{ {
addressBytes.Write(0, Addresses[i], Endianity.Big); addressBytes.Write(0, Addresses[i], Endianity.Big);
addressBytes.SubSegment(CommonPrefixLengthForNonLastAddresses, IpV6Address.SizeOf - CommonPrefixLengthForNonLastAddresses).Write(buffer, ref addressOffset); addressBytes.Subsegment(CommonPrefixLengthForNonLastAddresses, IpV6Address.SizeOf - CommonPrefixLengthForNonLastAddresses).Write(buffer, ref addressOffset);
} }
addressBytes.Write(0, Addresses[Addresses.Count - 1], Endianity.Big); addressBytes.Write(0, Addresses[Addresses.Count - 1], Endianity.Big);
addressBytes.SubSegment(CommonPrefixLengthForLastAddress, IpV6Address.SizeOf - CommonPrefixLengthForLastAddress).Write(buffer, ref addressOffset); addressBytes.Subsegment(CommonPrefixLengthForLastAddress, IpV6Address.SizeOf - CommonPrefixLengthForLastAddress).Write(buffer, ref addressOffset);
} }
} }
......
...@@ -48,9 +48,9 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -48,9 +48,9 @@ namespace PcapDotNet.Packets.IpV6
public IpV6OptionQuickStart(IpV4OptionQuickStartFunction function, byte rate, byte ttl, uint nonce) public IpV6OptionQuickStart(IpV4OptionQuickStartFunction function, byte rate, byte ttl, uint nonce)
: base(IpV6OptionType.QuickStart) : base(IpV6OptionType.QuickStart)
{ {
IpOptionQuickStartCommon.AssertValidParameters(function, rate, ttl, nonce); IpOptionQuickStartCommon.AssertValidParameters(function, rate, nonce);
Function = function; QuickStartFunction = function;
Rate = rate; Rate = rate;
Ttl = ttl; Ttl = ttl;
Nonce = nonce; Nonce = nonce;
...@@ -59,7 +59,7 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -59,7 +59,7 @@ namespace PcapDotNet.Packets.IpV6
/// <summary> /// <summary>
/// Function field. /// Function field.
/// </summary> /// </summary>
public IpV4OptionQuickStartFunction Function { get; private set; } public IpV4OptionQuickStartFunction QuickStartFunction { get; private set; }
/// <summary> /// <summary>
/// For rate request, this is the Rate Request field. /// For rate request, this is the Rate Request field.
...@@ -123,12 +123,12 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -123,12 +123,12 @@ namespace PcapDotNet.Packets.IpV6
internal override int GetDataHashCode() internal override int GetDataHashCode()
{ {
return Sequence.GetHashCode(BitSequence.Merge((byte)Function, Rate, Ttl), Nonce); return Sequence.GetHashCode(BitSequence.Merge((byte)QuickStartFunction, Rate, Ttl), Nonce);
} }
internal override void WriteData(byte[] buffer, ref int offset) internal override void WriteData(byte[] buffer, ref int offset)
{ {
IpOptionQuickStartCommon.WriteData(buffer, ref offset, Function, Rate, Ttl, Nonce); IpOptionQuickStartCommon.WriteData(buffer, ref offset, QuickStartFunction, Rate, Ttl, Nonce);
} }
private IpV6OptionQuickStart() private IpV6OptionQuickStart()
...@@ -139,7 +139,7 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -139,7 +139,7 @@ namespace PcapDotNet.Packets.IpV6
private bool EqualsData(IpV6OptionQuickStart other) private bool EqualsData(IpV6OptionQuickStart other)
{ {
return other != null && return other != null &&
Function == other.Function && Rate == other.Rate && Ttl == other.Ttl && Nonce == other.Nonce; QuickStartFunction == other.QuickStartFunction && Rate == other.Rate && Ttl == other.Ttl && Nonce == other.Nonce;
} }
} }
} }
\ No newline at end of file
...@@ -22,7 +22,7 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -22,7 +22,7 @@ namespace PcapDotNet.Packets.IpV6
/// </summary> /// </summary>
/// <param name="options">List of options to build the set from.</param> /// <param name="options">List of options to build the set from.</param>
public IpV6Options(IList<IpV6Option> options) public IpV6Options(IList<IpV6Option> options)
: base(options, true, null) : base(options, true, SumBytesLength(options))
{ {
} }
...@@ -98,13 +98,8 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -98,13 +98,8 @@ namespace PcapDotNet.Packets.IpV6
return new Tuple<IList<IpV6Option>, bool>(options, isValid); return new Tuple<IList<IpV6Option>, bool>(options, isValid);
} }
internal override int CalculateBytesLength(int optionsLength)
{
return optionsLength;
}
private IpV6Options(Tuple<IList<IpV6Option>, bool> optionsAndIsValid) private IpV6Options(Tuple<IList<IpV6Option>, bool> optionsAndIsValid)
: base(optionsAndIsValid.Item1, optionsAndIsValid.Item2, null) : base(optionsAndIsValid.Item1, optionsAndIsValid.Item2, SumBytesLength(optionsAndIsValid.Item1))
{ {
} }
......
...@@ -10,14 +10,9 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -10,14 +10,9 @@ namespace PcapDotNet.Packets.IpV6
/// <typeparam name="T">The option concrete type.</typeparam> /// <typeparam name="T">The option concrete type.</typeparam>
public abstract class V6Options<T> : Options<T> where T : Option, IEquatable<T> public abstract class V6Options<T> : Options<T> where T : Option, IEquatable<T>
{ {
internal V6Options(IList<T> options, bool isValid) internal V6Options(IList<T> options, bool isValid)
: base(options, isValid, null) : base(options, isValid, SumBytesLength(options))
{ {
} }
internal sealed override int CalculateBytesLength(int optionsLength)
{
return optionsLength;
}
} }
} }
\ No newline at end of file
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