Commit 76ba668c authored by Brickner_cp's avatar Brickner_cp

287 warnings left.

parent 0abdb7bc
......@@ -12,12 +12,12 @@ namespace PcapDotNet.Base
/// </summary>
public static int GetHashCode(object value1, object value2)
{
if (value1 == null)
return value2.GetHashCode();
if (value2 == null)
return value1.GetHashCode();
return value1.GetHashCode() ^ value2.GetHashCode();
int hashCode = 0;
if (value1 != null)
hashCode ^= value1.GetHashCode();
if (value2 != null)
hashCode ^= value2.GetHashCode();
return hashCode;
}
/// <summary>
......
......@@ -75,6 +75,7 @@
<Word>satnet</Word>
<Word>sha</Word>
<Word>sitara</Word>
<Word>sll</Word>
<Word>sna</Word>
<Word>ssh</Word>
<Word>tcf</Word>
......
......@@ -52,7 +52,7 @@ namespace PcapDotNet.Core.Test
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(", ");
......@@ -65,7 +65,7 @@ namespace PcapDotNet.Core.Test
else
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);
return quickStartWireshark.ToString();
......
......@@ -114,6 +114,7 @@ namespace PcapDotNet.Core.Test
protocol == IpV4Protocol.DissimilarGatewayProtocol ||
protocol == IpV4Protocol.SpriteRpc ||
protocol == IpV4Protocol.CombatRadioUserDatagram ||
protocol == IpV4Protocol.Gmtp ||
protocol == IpV4Protocol.Shim6 || // TODO: Implement Shim6.
protocol == IpV4Protocol.RemoteVirtualDiskProtocol))
return false;
......
......@@ -69,7 +69,7 @@ namespace PcapDotNet.Packets
/// <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>
/// <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);
}
......
......@@ -11,7 +11,7 @@ namespace PcapDotNet.Packets.Ip
/// <summary>
/// The function of this quick start option.
/// </summary>
IpV4OptionQuickStartFunction Function { get; }
IpV4OptionQuickStartFunction QuickStartFunction { get; }
/// <summary>
/// If function is request then this field is the rate request.
......
......@@ -29,7 +29,7 @@ namespace PcapDotNet.Packets.Ip
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 &&
function != IpV4OptionQuickStartFunction.RateReport)
......
......@@ -123,16 +123,11 @@ namespace PcapDotNet.Packets.Ip
buffer[offset++] = 0;
}
internal Options(IList<T> options, bool isValid, int? length)
internal Options(IList<T> options, bool isValid, int length)
{
_options = options.AsReadOnly();
IsValid = isValid;
if (length.HasValue)
BytesLength = length.Value;
else
BytesLength = CalculateBytesLength(SumBytesLength(OptionsCollection));
BytesLength = length;
}
internal static int SumBytesLength(IEnumerable<T> options)
......@@ -140,8 +135,6 @@ namespace PcapDotNet.Packets.Ip
return options.Sum(option => option.Length);
}
internal abstract int CalculateBytesLength(int optionsLength);
private readonly ReadOnlyCollection<T> _options;
}
}
\ No newline at end of file
......@@ -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");
}
internal sealed override int CalculateBytesLength(int optionsLength)
internal static int CalculateBytesLength(int optionsLength)
{
if (optionsLength % 4 == 0)
return optionsLength;
......@@ -36,7 +36,7 @@ namespace PcapDotNet.Packets.Ip
}
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
public IpV4OptionQuickStart(IpV4OptionQuickStartFunction function, byte rate, byte ttl, uint nonce)
: base(IpV4OptionType.QuickStart)
{
IpOptionQuickStartCommon.AssertValidParameters(function, rate, ttl, nonce);
IpOptionQuickStartCommon.AssertValidParameters(function, rate, nonce);
Function = function;
QuickStartFunction = function;
Rate = rate;
Ttl = ttl;
Nonce = nonce;
......@@ -75,7 +75,7 @@ namespace PcapDotNet.Packets.IpV4
/// <summary>
/// The function of this quick start option.
/// </summary>
public IpV4OptionQuickStartFunction Function { get; private set; }
public IpV4OptionQuickStartFunction QuickStartFunction { get; private set; }
/// <summary>
/// If function is request then this field is the rate request.
......@@ -178,7 +178,7 @@ namespace PcapDotNet.Packets.IpV4
if (other == null)
return false;
return Function == other.Function &&
return QuickStartFunction == other.QuickStartFunction &&
Rate == other.Rate &&
Ttl == other.Ttl &&
Nonce == other.Nonce;
......@@ -216,14 +216,14 @@ namespace PcapDotNet.Packets.IpV4
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)
{
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
for (int i = 0; i != Addresses.Count - 1; ++i)
{
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.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
public IpV6OptionQuickStart(IpV4OptionQuickStartFunction function, byte rate, byte ttl, uint nonce)
: base(IpV6OptionType.QuickStart)
{
IpOptionQuickStartCommon.AssertValidParameters(function, rate, ttl, nonce);
IpOptionQuickStartCommon.AssertValidParameters(function, rate, nonce);
Function = function;
QuickStartFunction = function;
Rate = rate;
Ttl = ttl;
Nonce = nonce;
......@@ -59,7 +59,7 @@ namespace PcapDotNet.Packets.IpV6
/// <summary>
/// Function field.
/// </summary>
public IpV4OptionQuickStartFunction Function { get; private set; }
public IpV4OptionQuickStartFunction QuickStartFunction { get; private set; }
/// <summary>
/// For rate request, this is the Rate Request field.
......@@ -123,12 +123,12 @@ namespace PcapDotNet.Packets.IpV6
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)
{
IpOptionQuickStartCommon.WriteData(buffer, ref offset, Function, Rate, Ttl, Nonce);
IpOptionQuickStartCommon.WriteData(buffer, ref offset, QuickStartFunction, Rate, Ttl, Nonce);
}
private IpV6OptionQuickStart()
......@@ -139,7 +139,7 @@ namespace PcapDotNet.Packets.IpV6
private bool EqualsData(IpV6OptionQuickStart other)
{
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
/// </summary>
/// <param name="options">List of options to build the set from.</param>
public IpV6Options(IList<IpV6Option> options)
: base(options, true, null)
: base(options, true, SumBytesLength(options))
{
}
......@@ -98,13 +98,8 @@ namespace PcapDotNet.Packets.IpV6
return new Tuple<IList<IpV6Option>, bool>(options, isValid);
}
internal override int CalculateBytesLength(int optionsLength)
{
return optionsLength;
}
private IpV6Options(Tuple<IList<IpV6Option>, bool> optionsAndIsValid)
: base(optionsAndIsValid.Item1, optionsAndIsValid.Item2, null)
: base(optionsAndIsValid.Item1, optionsAndIsValid.Item2, SumBytesLength(optionsAndIsValid.Item1))
{
}
......
......@@ -11,13 +11,8 @@ namespace PcapDotNet.Packets.IpV6
public abstract class V6Options<T> : Options<T> where T : Option, IEquatable<T>
{
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