Commit b0b58a33 authored by Brickner_cp's avatar Brickner_cp

Resharper 5.0 inspection fixes.

parent d41fce73
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
<Sharing>SOLUTION</Sharing> <Sharing>SOLUTION</Sharing>
<CSharp> <CSharp>
<FormatSettings> <FormatSettings>
<ANONYMOUS_METHOD_DECLARATION_BRACES>NEXT_LINE</ANONYMOUS_METHOD_DECLARATION_BRACES>
<CASE_BLOCK_BRACES>NEXT_LINE</CASE_BLOCK_BRACES>
<INITIALIZER_BRACES>NEXT_LINE</INITIALIZER_BRACES>
<MODIFIERS_ORDER IsNull="False"> <MODIFIERS_ORDER IsNull="False">
<Item>public</Item> <Item>public</Item>
<Item>protected</Item> <Item>protected</Item>
...@@ -23,6 +26,7 @@ ...@@ -23,6 +26,7 @@
</MODIFIERS_ORDER> </MODIFIERS_ORDER>
<SPACE_AFTER_TYPECAST_PARENTHESES>False</SPACE_AFTER_TYPECAST_PARENTHESES> <SPACE_AFTER_TYPECAST_PARENTHESES>False</SPACE_AFTER_TYPECAST_PARENTHESES>
<SPACE_AROUND_MULTIPLICATIVE_OP>True</SPACE_AROUND_MULTIPLICATIVE_OP> <SPACE_AROUND_MULTIPLICATIVE_OP>True</SPACE_AROUND_MULTIPLICATIVE_OP>
<WRAP_LIMIT>160</WRAP_LIMIT>
</FormatSettings> </FormatSettings>
<UsingsSettings /> <UsingsSettings />
<Naming2> <Naming2>
...@@ -73,14 +77,14 @@ ...@@ -73,14 +77,14 @@
<PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" /> <PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" /> <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" /> <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="LocalConstants" /> <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="LocalConstants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PublicFields" /> <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PublicFields" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" /> <PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" /> <PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" /> <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateConstants" /> <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateConstants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" /> <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateStaticReadonly" /> <PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticReadonly" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" /> <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" /> <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
</Naming2> </Naming2>
......
...@@ -9,17 +9,10 @@ namespace PcapDotNet.Base.Test ...@@ -9,17 +9,10 @@ namespace PcapDotNet.Base.Test
[TestClass] [TestClass]
public class FuncExtensionsTest public class FuncExtensionsTest
{ {
public FuncExtensionsTest()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext { get; set; } public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
......
using System; using System;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.TestUtils;
namespace PcapDotNet.Base.Test namespace PcapDotNet.Base.Test
{ {
...@@ -9,20 +8,15 @@ namespace PcapDotNet.Base.Test ...@@ -9,20 +8,15 @@ namespace PcapDotNet.Base.Test
/// Summary description for IEnumerableExtensionsTests /// Summary description for IEnumerableExtensionsTests
/// </summary> /// </summary>
[TestClass] [TestClass]
// ReSharper disable InconsistentNaming
public class IEnumerableExtensionsTests public class IEnumerableExtensionsTests
// ReSharper restore InconsistentNaming
{ {
public IEnumerableExtensionsTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
......
...@@ -9,17 +9,10 @@ namespace PcapDotNet.Base.Test ...@@ -9,17 +9,10 @@ namespace PcapDotNet.Base.Test
[TestClass] [TestClass]
public class MemberInfoExtensionsTests public class MemberInfoExtensionsTests
{ {
public MemberInfoExtensionsTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext { get; set; } public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
......
...@@ -9,17 +9,10 @@ namespace PcapDotNet.Base.Test ...@@ -9,17 +9,10 @@ namespace PcapDotNet.Base.Test
[TestClass] [TestClass]
public class PropertyInfoExtensionsTests public class PropertyInfoExtensionsTests
{ {
public PropertyInfoExtensionsTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext { get; set; } public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
......
...@@ -11,13 +11,6 @@ namespace PcapDotNet.Base.Test ...@@ -11,13 +11,6 @@ namespace PcapDotNet.Base.Test
[TestClass] [TestClass]
public class UInt128Tests public class UInt128Tests
{ {
public UInt128Tests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
/// Gets or sets the test context which provides /// Gets or sets the test context which provides
/// information about and functionality for the current test run. /// information about and functionality for the current test run.
...@@ -58,8 +51,10 @@ namespace PcapDotNet.Base.Test ...@@ -58,8 +51,10 @@ namespace PcapDotNet.Base.Test
Assert.AreNotEqual(value, string.Empty); Assert.AreNotEqual(value, string.Empty);
Assert.AreNotEqual(value, UInt128.MaxValue); Assert.AreNotEqual(value, UInt128.MaxValue);
Assert.AreNotEqual(value, UInt128.Zero); Assert.AreNotEqual(value, UInt128.Zero);
// ReSharper disable EqualExpressionComparison
Assert.IsTrue(value == value); Assert.IsTrue(value == value);
Assert.IsFalse(value != value); Assert.IsFalse(value != value);
// ReSharper restore EqualExpressionComparison
Assert.IsNotNull(value.GetHashCode()); Assert.IsNotNull(value.GetHashCode());
Assert.AreEqual(value, UInt128.Parse(value.ToString("X32"), NumberStyles.HexNumber, CultureInfo.InvariantCulture)); Assert.AreEqual(value, UInt128.Parse(value.ToString("X32"), NumberStyles.HexNumber, CultureInfo.InvariantCulture));
Assert.AreEqual(value >> 64, UInt128.Parse(((ulong)(value >> 64)).ToString("X16"), NumberStyles.HexNumber, CultureInfo.InvariantCulture)); Assert.AreEqual(value >> 64, UInt128.Parse(((ulong)(value >> 64)).ToString("X16"), NumberStyles.HexNumber, CultureInfo.InvariantCulture));
...@@ -69,13 +64,13 @@ namespace PcapDotNet.Base.Test ...@@ -69,13 +64,13 @@ namespace PcapDotNet.Base.Test
[TestMethod] [TestMethod]
public void ShiftRightTest() public void ShiftRightTest()
{ {
const string valueString = "0123456789ABCDEFFEDCBA9876543210"; const string ValueString = "0123456789ABCDEFFEDCBA9876543210";
UInt128 value = UInt128.Parse(valueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture); UInt128 value = UInt128.Parse(ValueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
Assert.AreEqual(UInt128.Parse(valueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture), value); Assert.AreEqual(UInt128.Parse(ValueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture), value);
for (int i = 0; i <= 124; i += 4) for (int i = 0; i <= 124; i += 4)
{ {
string expectedValueString = new string('0', i / 4) + valueString.Substring(0, valueString.Length - i / 4); string expectedValueString = new string('0', i / 4) + ValueString.Substring(0, ValueString.Length - i / 4);
UInt128 expectedValue = UInt128.Parse(expectedValueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture); UInt128 expectedValue = UInt128.Parse(expectedValueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
Assert.AreEqual(expectedValue, value >> i, i.ToString()); Assert.AreEqual(expectedValue, value >> i, i.ToString());
Assert.AreEqual(expectedValue, value >> (i / 2) >> (i / 2), i.ToString()); Assert.AreEqual(expectedValue, value >> (i / 2) >> (i / 2), i.ToString());
...@@ -86,15 +81,15 @@ namespace PcapDotNet.Base.Test ...@@ -86,15 +81,15 @@ namespace PcapDotNet.Base.Test
[TestMethod] [TestMethod]
public void BitwiseAndTest() public void BitwiseAndTest()
{ {
const string valueString = "0123456789ABCDEFFEDCBA9876543210"; const string ValueString = "0123456789ABCDEFFEDCBA9876543210";
UInt128 value = UInt128.Parse(valueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture); UInt128 value = UInt128.Parse(ValueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
Assert.AreEqual(UInt128.Parse(valueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture), value); Assert.AreEqual(UInt128.Parse(ValueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture), value);
for (int i = 0; i <= 32; ++i) for (int i = 0; i <= 32; ++i)
{ {
string andValueString = new string('0', i) + new string('F', valueString.Length - i); string andValueString = new string('0', i) + new string('F', ValueString.Length - i);
UInt128 andValue = UInt128.Parse(andValueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture); UInt128 andValue = UInt128.Parse(andValueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
string expectedValueString = new string('0', i) + valueString.Substring(i, valueString.Length - i); string expectedValueString = new string('0', i) + ValueString.Substring(i, ValueString.Length - i);
UInt128 expectedValue = UInt128.Parse(expectedValueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture); UInt128 expectedValue = UInt128.Parse(expectedValueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
UInt128 actualValue = value & andValue; UInt128 actualValue = value & andValue;
Assert.AreEqual(expectedValue, actualValue, i.ToString()); Assert.AreEqual(expectedValue, actualValue, i.ToString());
...@@ -112,9 +107,9 @@ namespace PcapDotNet.Base.Test ...@@ -112,9 +107,9 @@ namespace PcapDotNet.Base.Test
[TestMethod] [TestMethod]
public void ToStringTest() public void ToStringTest()
{ {
const string valueString = "0123456789ABCDEFFEDCBA9876543210"; const string ValueString = "0123456789ABCDEFFEDCBA9876543210";
UInt128 value = UInt128.Parse(valueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture); UInt128 value = UInt128.Parse(ValueString, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
Assert.AreEqual(valueString, value.ToString("X32")); Assert.AreEqual(ValueString, value.ToString("X32"));
} }
} }
} }
\ No newline at end of file
using System; using System;
using System.Globalization;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
...@@ -11,18 +10,11 @@ namespace PcapDotNet.Base.Test ...@@ -11,18 +10,11 @@ namespace PcapDotNet.Base.Test
[TestClass] [TestClass]
public class UInt24Tests public class UInt24Tests
{ {
public UInt24Tests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
...@@ -55,11 +47,13 @@ namespace PcapDotNet.Base.Test ...@@ -55,11 +47,13 @@ namespace PcapDotNet.Base.Test
UInt24 value = random.NextUInt24(); UInt24 value = random.NextUInt24();
Assert.AreEqual(value, value); Assert.AreEqual(value, value);
// ReSharper disable EqualExpressionComparison
Assert.IsTrue(value == value); Assert.IsTrue(value == value);
Assert.IsFalse(value != value); Assert.IsFalse(value != value);
// ReSharper restore EqualExpressionComparison
Assert.AreNotEqual(value, "string"); Assert.AreNotEqual(value, "string");
Assert.AreNotEqual(value, (UInt24)(((value & 0x00FFFF) + 1)| value & 0xFF0000)); Assert.AreNotEqual(value, (UInt24)(((value & 0x00FFFF) + 1) | value & 0xFF0000));
Assert.AreNotEqual(value, (UInt24)((value & 0x00FFFF)| ((value & 0xFF0000) + 0x010000))); Assert.AreNotEqual(value, (UInt24)((value & 0x00FFFF) | ((value & 0xFF0000) + 0x010000)));
Assert.IsNotNull(value.GetHashCode()); Assert.IsNotNull(value.GetHashCode());
Assert.AreEqual(((int)value).ToString(), value.ToString()); Assert.AreEqual(((int)value).ToString(), value.ToString());
} }
......
using System; using System;
using System.Globalization; using System.Globalization;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
...@@ -14,18 +11,11 @@ namespace PcapDotNet.Base.Test ...@@ -14,18 +11,11 @@ namespace PcapDotNet.Base.Test
[TestClass] [TestClass]
public class UInt48Tests public class UInt48Tests
{ {
public UInt48Tests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
...@@ -97,8 +87,10 @@ namespace PcapDotNet.Base.Test ...@@ -97,8 +87,10 @@ namespace PcapDotNet.Base.Test
Assert.AreEqual(value, value); Assert.AreEqual(value, value);
Assert.AreNotEqual(value, "1"); Assert.AreNotEqual(value, "1");
// ReSharper disable EqualExpressionComparison
Assert.IsTrue(value == value); Assert.IsTrue(value == value);
Assert.IsFalse(value != value); Assert.IsFalse(value != value);
// ReSharper restore EqualExpressionComparison
Assert.IsNotNull(value.GetHashCode()); Assert.IsNotNull(value.GetHashCode());
if (value < uint.MaxValue) if (value < uint.MaxValue)
......
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace PcapDotNet.Base namespace PcapDotNet.Base
{ {
......
using System; using System;
using System.Collections.ObjectModel;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
...@@ -11,7 +9,9 @@ namespace PcapDotNet.Base ...@@ -11,7 +9,9 @@ namespace PcapDotNet.Base
/// <summary> /// <summary>
/// Extension methods for IEnumerable of type T. /// Extension methods for IEnumerable of type T.
/// </summary> /// </summary>
// ReSharper disable InconsistentNaming
public static class IEnumerableExtensions public static class IEnumerableExtensions
// ReSharper restore InconsistentNaming
{ {
/// <summary> /// <summary>
/// True iff the sequence has no elements. /// True iff the sequence has no elements.
......
...@@ -6,7 +6,9 @@ namespace PcapDotNet.Base ...@@ -6,7 +6,9 @@ namespace PcapDotNet.Base
/// <summary> /// <summary>
/// Extension methods for IList of type T. /// Extension methods for IList of type T.
/// </summary> /// </summary>
// ReSharper disable InconsistentNaming
public static class IListExtensions public static class IListExtensions
// ReSharper restore InconsistentNaming
{ {
/// <summary> /// <summary>
/// Wraps a list with a ReadOnlyCollection. /// Wraps a list with a ReadOnlyCollection.
......
using System; using System;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
......
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace PcapDotNet.Base namespace PcapDotNet.Base
{ {
......
...@@ -78,7 +78,7 @@ namespace PcapDotNet.Base ...@@ -78,7 +78,7 @@ namespace PcapDotNet.Base
throw new NotSupportedException("Only " + NumberStyles.HexNumber + " style is supported"); throw new NotSupportedException("Only " + NumberStyles.HexNumber + " style is supported");
ulong mostSignficantLong = 0; ulong mostSignficantLong = 0;
ulong leastSignficantLong = 0; ulong leastSignficantLong;
if (value.Length > 16) if (value.Length > 16)
{ {
leastSignficantLong = ulong.Parse(value.Substring(value.Length - 16, 16), style, provider); leastSignficantLong = ulong.Parse(value.Substring(value.Length - 16, 16), style, provider);
......
using System; using System.Globalization;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
namespace PcapDotNet.Base namespace PcapDotNet.Base
{ {
......
...@@ -481,7 +481,7 @@ namespace PcapDotNet.Base ...@@ -481,7 +481,7 @@ namespace PcapDotNet.Base
/// <returns>The 8 bit value converted from the 48 bit value.</returns> /// <returns>The 8 bit value converted from the 48 bit value.</returns>
public static explicit operator byte(UInt48 value) public static explicit operator byte(UInt48 value)
{ {
return (byte)value.ToByte(); return value.ToByte();
} }
/// <summary> /// <summary>
......
using System; using System;
using System.Linq;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using PcapDotNet.Base;
using PcapDotNet.Packets; using PcapDotNet.Packets;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
...@@ -24,13 +24,7 @@ namespace PcapDotNet.Core.Extensions ...@@ -24,13 +24,7 @@ namespace PcapDotNet.Core.Extensions
if (livePacketDevice == null) if (livePacketDevice == null)
throw new ArgumentNullException("livePacketDevice"); throw new ArgumentNullException("livePacketDevice");
foreach (NetworkInterface networkInterface in NetworkInterface.GetAllNetworkInterfaces()) return NetworkInterface.GetAllNetworkInterfaces().FirstOrDefault(networkInterface => @"rpcap://\Device\NPF_" + networkInterface.Id == livePacketDevice.Name);
{
if (@"rpcap://\Device\NPF_" + networkInterface.Id == livePacketDevice.Name)
return networkInterface;
}
return null;
} }
/// <summary> /// <summary>
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using PcapDotNet.Packets; using PcapDotNet.Packets;
namespace PcapDotNet.Core.Extensions namespace PcapDotNet.Core.Extensions
......
using System; using System;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
......
...@@ -11,13 +11,6 @@ namespace PcapDotNet.Core.Test ...@@ -11,13 +11,6 @@ namespace PcapDotNet.Core.Test
[TestClass] [TestClass]
public class BerkeleyPacketFilterTests public class BerkeleyPacketFilterTests
{ {
public BerkeleyPacketFilterTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
/// Gets or sets the test context which provides /// Gets or sets the test context which provides
/// information about and functionality for the current test run. /// information about and functionality for the current test run.
...@@ -99,23 +92,23 @@ namespace PcapDotNet.Core.Test ...@@ -99,23 +92,23 @@ namespace PcapDotNet.Core.Test
{ {
const string SourceMac = "11:22:33:44:55:66"; const string SourceMac = "11:22:33:44:55:66";
const string DestinationMac = "77:88:99:AA:BB:CC"; const string DestinationMac = "77:88:99:AA:BB:CC";
const int snapshotLength = 500; const int SnapshotLength = 500;
Random random = new Random(); Random random = new Random();
using (BerkeleyPacketFilter filter = new BerkeleyPacketFilter("ether src " + SourceMac + " and ether dst " + DestinationMac, snapshotLength, DataLinkKind.Ethernet)) using (BerkeleyPacketFilter filter = new BerkeleyPacketFilter("ether src " + SourceMac + " and ether dst " + DestinationMac, SnapshotLength, DataLinkKind.Ethernet))
{ {
Assert.IsTrue(filter.Test(random.NextEthernetPacket(snapshotLength / 2, SourceMac, DestinationMac))); Assert.IsTrue(filter.Test(random.NextEthernetPacket(SnapshotLength / 2, SourceMac, DestinationMac)));
Assert.IsTrue(filter.Test(random.NextEthernetPacket(snapshotLength - 1, SourceMac, DestinationMac))); Assert.IsTrue(filter.Test(random.NextEthernetPacket(SnapshotLength - 1, SourceMac, DestinationMac)));
Assert.IsTrue(filter.Test(random.NextEthernetPacket(snapshotLength, SourceMac, DestinationMac))); Assert.IsTrue(filter.Test(random.NextEthernetPacket(SnapshotLength, SourceMac, DestinationMac)));
Assert.IsTrue(filter.Test(random.NextEthernetPacket(snapshotLength + 1, SourceMac, DestinationMac))); Assert.IsTrue(filter.Test(random.NextEthernetPacket(SnapshotLength + 1, SourceMac, DestinationMac)));
Assert.IsTrue(filter.Test(random.NextEthernetPacket(snapshotLength * 2, SourceMac, DestinationMac))); Assert.IsTrue(filter.Test(random.NextEthernetPacket(SnapshotLength * 2, SourceMac, DestinationMac)));
Assert.IsFalse(filter.Test(random.NextEthernetPacket(snapshotLength / 2, DestinationMac, SourceMac))); Assert.IsFalse(filter.Test(random.NextEthernetPacket(SnapshotLength / 2, DestinationMac, SourceMac)));
int actualSnapshotLength; int actualSnapshotLength;
Assert.IsTrue(filter.Test(out actualSnapshotLength, random.NextEthernetPacket(snapshotLength / 2, SourceMac, DestinationMac))); Assert.IsTrue(filter.Test(out actualSnapshotLength, random.NextEthernetPacket(SnapshotLength / 2, SourceMac, DestinationMac)));
Assert.AreEqual(snapshotLength, actualSnapshotLength); Assert.AreEqual(SnapshotLength, actualSnapshotLength);
} }
} }
......
using System; using System;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Core.Extensions; using PcapDotNet.Core.Extensions;
using PcapDotNet.TestUtils;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
...@@ -11,17 +10,10 @@ namespace PcapDotNet.Core.Test ...@@ -11,17 +10,10 @@ namespace PcapDotNet.Core.Test
[TestClass] [TestClass]
public class LivePacketDeviceExtensionsTests public class LivePacketDeviceExtensionsTests
{ {
public LivePacketDeviceExtensionsTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext { get; set; } public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using PcapDotNet.Core.Extensions; using PcapDotNet.Core.Extensions;
using PcapDotNet.Packets; using PcapDotNet.Packets;
...@@ -29,10 +25,10 @@ namespace PcapDotNet.Core.Test ...@@ -29,10 +25,10 @@ namespace PcapDotNet.Core.Test
} }
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
...@@ -152,7 +148,7 @@ namespace PcapDotNet.Core.Test ...@@ -152,7 +148,7 @@ namespace PcapDotNet.Core.Test
TestReceivePacketsEnumerable(NumPacketsToSend, NumPacketsToSend / 2, int.MaxValue, 2, PacketSize, NumPacketsToSend / 2, 0, 0.032); TestReceivePacketsEnumerable(NumPacketsToSend, NumPacketsToSend / 2, int.MaxValue, 2, PacketSize, NumPacketsToSend / 2, 0, 0.032);
// Wait for more packets // Wait for more packets
TestReceivePacketsEnumerable(NumPacketsToSend, -1, int.MaxValue, 2, PacketSize, NumPacketsToSend, 2, 2.029); TestReceivePacketsEnumerable(NumPacketsToSend, -1, int.MaxValue, 2, PacketSize, NumPacketsToSend, 2, 2.031);
TestReceivePacketsEnumerable(NumPacketsToSend, NumPacketsToSend + 1, int.MaxValue, 2, PacketSize, NumPacketsToSend, 2, 2.13); TestReceivePacketsEnumerable(NumPacketsToSend, NumPacketsToSend + 1, int.MaxValue, 2, PacketSize, NumPacketsToSend, 2, 2.13);
// Break loop // Break loop
...@@ -682,7 +678,7 @@ namespace PcapDotNet.Core.Test ...@@ -682,7 +678,7 @@ namespace PcapDotNet.Core.Test
private static void TestReceiveSomePackets(int numPacketsToSend, int numPacketsToGet, int numPacketsToBreakLoop, int packetSize, bool nonBlocking, private static void TestReceiveSomePackets(int numPacketsToSend, int numPacketsToGet, int numPacketsToBreakLoop, int packetSize, bool nonBlocking,
PacketCommunicatorReceiveResult expectedResult, int expectedNumPackets, double expectedMinSeconds, double expectedMaxSeconds) PacketCommunicatorReceiveResult expectedResult, int expectedNumPackets, double expectedMinSeconds, double expectedMaxSeconds)
{ {
string TestDescription = "NumPacketsToSend=" + numPacketsToSend + ". NumPacketsToGet=" + numPacketsToGet + string testDescription = "NumPacketsToSend=" + numPacketsToSend + ". NumPacketsToGet=" + numPacketsToGet +
". NumPacketsToBreakLoop=" + numPacketsToBreakLoop + ". PacketSize=" + packetSize + ". NumPacketsToBreakLoop=" + numPacketsToBreakLoop + ". PacketSize=" + packetSize +
". NonBlocking=" + nonBlocking; ". NonBlocking=" + nonBlocking;
...@@ -711,9 +707,9 @@ namespace PcapDotNet.Core.Test ...@@ -711,9 +707,9 @@ namespace PcapDotNet.Core.Test
DateTime finishedWaiting = DateTime.Now; DateTime finishedWaiting = DateTime.Now;
Assert.AreEqual(expectedResult, result); Assert.AreEqual(expectedResult, result);
Assert.AreEqual(expectedNumPackets, numPacketsGot, "NumPacketsGot. Test: " + TestDescription); Assert.AreEqual(expectedNumPackets, numPacketsGot, "NumPacketsGot. Test: " + testDescription);
Assert.AreEqual(expectedNumPackets, handler.NumPacketsHandled, "NumPacketsHandled. Test: " + TestDescription); Assert.AreEqual(expectedNumPackets, handler.NumPacketsHandled, "NumPacketsHandled. Test: " + testDescription);
MoreAssert.IsInRange(expectedMinSeconds, expectedMaxSeconds, (finishedWaiting - startWaiting).TotalSeconds, TestDescription); MoreAssert.IsInRange(expectedMinSeconds, expectedMaxSeconds, (finishedWaiting - startWaiting).TotalSeconds, testDescription);
} }
} }
...@@ -721,7 +717,7 @@ namespace PcapDotNet.Core.Test ...@@ -721,7 +717,7 @@ namespace PcapDotNet.Core.Test
PacketCommunicatorReceiveResult expectedResult, int expectedNumPackets, PacketCommunicatorReceiveResult expectedResult, int expectedNumPackets,
double expectedMinSeconds, double expectedMaxSeconds) double expectedMinSeconds, double expectedMaxSeconds)
{ {
string TestDescription = "NumPacketsToSend=" + numPacketsToSend + ". NumPacketsToWait=" + numPacketsToWait + string testDescription = "NumPacketsToSend=" + numPacketsToSend + ". NumPacketsToWait=" + numPacketsToWait +
". NumPacketsToBreakLoop=" + numPacketsToBreakLoop + ". SecondsToWait=" + ". NumPacketsToBreakLoop=" + numPacketsToBreakLoop + ". SecondsToWait=" +
secondsToWait + ". PacketSize=" + packetSize; secondsToWait + ". PacketSize=" + packetSize;
...@@ -756,7 +752,7 @@ namespace PcapDotNet.Core.Test ...@@ -756,7 +752,7 @@ namespace PcapDotNet.Core.Test
thread.Abort(); thread.Abort();
DateTime finishedWaiting = DateTime.Now; DateTime finishedWaiting = DateTime.Now;
Assert.AreEqual(expectedResult, result, TestDescription); Assert.AreEqual(expectedResult, result, testDescription);
Assert.AreEqual(expectedNumPackets, handler.NumPacketsHandled); Assert.AreEqual(expectedNumPackets, handler.NumPacketsHandled);
MoreAssert.IsInRange(expectedMinSeconds, expectedMaxSeconds, (finishedWaiting - startWaiting).TotalSeconds); MoreAssert.IsInRange(expectedMinSeconds, expectedMaxSeconds, (finishedWaiting - startWaiting).TotalSeconds);
} }
...@@ -765,7 +761,7 @@ namespace PcapDotNet.Core.Test ...@@ -765,7 +761,7 @@ namespace PcapDotNet.Core.Test
private static void TestReceivePacketsEnumerable(int numPacketsToSend, int numPacketsToWait, int numPacketsToBreakLoop, double secondsToWait, private static void TestReceivePacketsEnumerable(int numPacketsToSend, int numPacketsToWait, int numPacketsToBreakLoop, double secondsToWait,
int packetSize, int expectedNumPackets, double expectedMinSeconds, double expectedMaxSeconds) int packetSize, int expectedNumPackets, double expectedMinSeconds, double expectedMaxSeconds)
{ {
string TestDescription = "NumPacketsToSend=" + numPacketsToSend + ". NumPacketsToWait=" + numPacketsToWait + string testDescription = "NumPacketsToSend=" + numPacketsToSend + ". NumPacketsToWait=" + numPacketsToWait +
". NumPacketsToBreakLoop=" + numPacketsToBreakLoop + ". SecondsToWait=" + ". NumPacketsToBreakLoop=" + numPacketsToBreakLoop + ". SecondsToWait=" +
secondsToWait + ". PacketSize=" + packetSize; secondsToWait + ". PacketSize=" + packetSize;
...@@ -806,8 +802,8 @@ namespace PcapDotNet.Core.Test ...@@ -806,8 +802,8 @@ namespace PcapDotNet.Core.Test
thread.Abort(); thread.Abort();
DateTime finishedWaiting = DateTime.Now; DateTime finishedWaiting = DateTime.Now;
Assert.AreEqual(expectedNumPackets, actualPacketsReceived, TestDescription); Assert.AreEqual(expectedNumPackets, actualPacketsReceived, testDescription);
MoreAssert.IsInRange(expectedMinSeconds, expectedMaxSeconds, (finishedWaiting - startWaiting).TotalSeconds, TestDescription); MoreAssert.IsInRange(expectedMinSeconds, expectedMaxSeconds, (finishedWaiting - startWaiting).TotalSeconds, testDescription);
} }
} }
...@@ -874,6 +870,6 @@ namespace PcapDotNet.Core.Test ...@@ -874,6 +870,6 @@ namespace PcapDotNet.Core.Test
} }
} }
private static Random _random = new Random(); private static readonly Random _random = new Random();
} }
} }
\ No newline at end of file
...@@ -8,13 +8,6 @@ namespace PcapDotNet.Core.Test ...@@ -8,13 +8,6 @@ namespace PcapDotNet.Core.Test
[TestClass] [TestClass]
public class MarshalingServicesTests public class MarshalingServicesTests
{ {
public MarshalingServicesTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
/// Gets or sets the test context which provides /// Gets or sets the test context which provides
/// information about and functionality for the current test run. /// information about and functionality for the current test run.
......
...@@ -2,7 +2,6 @@ using System; ...@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
...@@ -52,10 +51,7 @@ namespace PcapDotNet.Core.Test ...@@ -52,10 +51,7 @@ namespace PcapDotNet.Core.Test
StringBuilder quickStartWireshark = new StringBuilder("Quick-Start: "); StringBuilder quickStartWireshark = new StringBuilder("Quick-Start: ");
if (quickStart.Function == IpV4OptionQuickStartFunction.RateRequest) quickStartWireshark.Append(quickStart.Function == IpV4OptionQuickStartFunction.RateRequest ? "Rate request" : "Rate report");
quickStartWireshark.Append("Rate request");
else
quickStartWireshark.Append("Rate report");
quickStartWireshark.Append(", "); quickStartWireshark.Append(", ");
...@@ -146,7 +142,9 @@ namespace PcapDotNet.Core.Test ...@@ -146,7 +142,9 @@ namespace PcapDotNet.Core.Test
} }
break; break;
// ReSharper disable RedundantCaseLabel
case IpV4OptionType.BasicSecurity: case IpV4OptionType.BasicSecurity:
// ReSharper restore RedundantCaseLabel
default: default:
if (typeof(IpV4OptionType).GetEnumValues<IpV4OptionType>().Contains(option.OptionType)) if (typeof(IpV4OptionType).GetEnumValues<IpV4OptionType>().Contains(option.OptionType))
throw new InvalidOperationException("Invalid option type " + option.OptionType); throw new InvalidOperationException("Invalid option type " + option.OptionType);
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.Transport; using PcapDotNet.Packets.Transport;
......
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Threading; using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets; using PcapDotNet.Packets;
...@@ -16,18 +14,11 @@ namespace PcapDotNet.Core.Test ...@@ -16,18 +14,11 @@ namespace PcapDotNet.Core.Test
[TestClass] [TestClass]
public class OfflinePacketDeviceTests public class OfflinePacketDeviceTests
{ {
public OfflinePacketDeviceTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
...@@ -156,7 +147,7 @@ namespace PcapDotNet.Core.Test ...@@ -156,7 +147,7 @@ namespace PcapDotNet.Core.Test
[ExpectedException(typeof(InvalidOperationException))] [ExpectedException(typeof(InvalidOperationException))]
public void OpenInvalidFileTest() public void OpenInvalidFileTest()
{ {
using (PacketCommunicator communicator = new OfflinePacketDevice("myinvalidfile").Open()) using (new OfflinePacketDevice("myinvalidfile").Open())
{ {
} }
} }
...@@ -256,7 +247,7 @@ namespace PcapDotNet.Core.Test ...@@ -256,7 +247,7 @@ namespace PcapDotNet.Core.Test
PacketCommunicatorReceiveResult expectedResult, int expectedNumPackets, PacketCommunicatorReceiveResult expectedResult, int expectedNumPackets,
double expectedMinSeconds, double expectedMaxSeconds) double expectedMinSeconds, double expectedMaxSeconds)
{ {
string TestDescription = "NumPacketsToSend=" + numPacketsToSend + ". NumPacketsToGet=" + numPacketsToGet + string testDescription = "NumPacketsToSend=" + numPacketsToSend + ". NumPacketsToGet=" + numPacketsToGet +
". NumPacketsToBreakLoop=" + numPacketsToBreakLoop; ". NumPacketsToBreakLoop=" + numPacketsToBreakLoop;
const string SourceMac = "11:22:33:44:55:66"; const string SourceMac = "11:22:33:44:55:66";
...@@ -275,8 +266,8 @@ namespace PcapDotNet.Core.Test ...@@ -275,8 +266,8 @@ namespace PcapDotNet.Core.Test
int numPacketsGot; int numPacketsGot;
PacketCommunicatorReceiveResult result = communicator.ReceiveSomePackets(out numPacketsGot, numPacketsToGet, handler.Handle); PacketCommunicatorReceiveResult result = communicator.ReceiveSomePackets(out numPacketsGot, numPacketsToGet, handler.Handle);
Assert.AreEqual(expectedResult, result); Assert.AreEqual(expectedResult, result);
Assert.AreEqual(expectedNumPackets, numPacketsGot, "NumPacketsGot. Test: " + TestDescription); Assert.AreEqual(expectedNumPackets, numPacketsGot, "NumPacketsGot. Test: " + testDescription);
Assert.AreEqual(expectedNumPackets, handler.NumPacketsHandled, "NumPacketsHandled. Test: " + TestDescription); Assert.AreEqual(expectedNumPackets, handler.NumPacketsHandled, "NumPacketsHandled. Test: " + testDescription);
} }
} }
...@@ -284,7 +275,7 @@ namespace PcapDotNet.Core.Test ...@@ -284,7 +275,7 @@ namespace PcapDotNet.Core.Test
PacketCommunicatorReceiveResult expectedResult, int expectedNumPackets, PacketCommunicatorReceiveResult expectedResult, int expectedNumPackets,
double expectedMinSeconds, double expectedMaxSeconds) double expectedMinSeconds, double expectedMaxSeconds)
{ {
string TestDescription = "NumPacketsToSend=" + numPacketsToSend + ". NumPacketsToGet=" + numPacketsToGet + string testDescription = "NumPacketsToSend=" + numPacketsToSend + ". NumPacketsToGet=" + numPacketsToGet +
". NumPacketsToBreakLoop=" + numPacketsToBreakLoop; ". NumPacketsToBreakLoop=" + numPacketsToBreakLoop;
const string SourceMac = "11:22:33:44:55:66"; const string SourceMac = "11:22:33:44:55:66";
...@@ -312,7 +303,7 @@ namespace PcapDotNet.Core.Test ...@@ -312,7 +303,7 @@ namespace PcapDotNet.Core.Test
thread.Abort(); thread.Abort();
} }
Assert.AreEqual(expectedResult, result, TestDescription); Assert.AreEqual(expectedResult, result, testDescription);
Assert.AreEqual(expectedNumPackets, handler.NumPacketsHandled); Assert.AreEqual(expectedNumPackets, handler.NumPacketsHandled);
} }
} }
...@@ -383,6 +374,6 @@ namespace PcapDotNet.Core.Test ...@@ -383,6 +374,6 @@ namespace PcapDotNet.Core.Test
} }
} }
private static Random _random = new Random(); private static readonly Random _random = new Random();
} }
} }
\ No newline at end of file
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets; using PcapDotNet.Packets;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.Icmp;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
...@@ -15,18 +12,11 @@ namespace PcapDotNet.Core.Test ...@@ -15,18 +12,11 @@ namespace PcapDotNet.Core.Test
[TestClass] [TestClass]
public class PacketDumpFileTests public class PacketDumpFileTests
{ {
public PacketDumpFileTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
...@@ -56,16 +46,16 @@ namespace PcapDotNet.Core.Test ...@@ -56,16 +46,16 @@ namespace PcapDotNet.Core.Test
string filename = Path.GetTempPath() + @"dump.pcap"; string filename = Path.GetTempPath() + @"dump.pcap";
Packet expectedPacket = PacketBuilder.Build(DateTime.Now, Packet expectedPacket = PacketBuilder.Build(DateTime.Now,
new EthernetLayer new EthernetLayer
{ {
Source = new MacAddress(1), Source = new MacAddress(1),
Destination = new MacAddress(2), Destination = new MacAddress(2),
EtherType = EthernetType.QInQ, EtherType = EthernetType.QInQ,
}, },
new PayloadLayer new PayloadLayer
{ {
Data = new Datagram(new byte[] {1, 2, 3}) Data = new Datagram(new byte[] {1, 2, 3})
}); });
PacketDumpFile.Dump(filename, new PcapDataLink(DataLinkKind.Ethernet), PacketDevice.DefaultSnapshotLength, PacketDumpFile.Dump(filename, new PcapDataLink(DataLinkKind.Ethernet), PacketDevice.DefaultSnapshotLength,
new[] {expectedPacket}); new[] {expectedPacket});
......
...@@ -13,18 +13,11 @@ namespace PcapDotNet.Core.Test ...@@ -13,18 +13,11 @@ namespace PcapDotNet.Core.Test
[TestClass] [TestClass]
public class PacketSendQueueTests public class PacketSendQueueTests
{ {
public PacketSendQueueTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
...@@ -153,6 +146,6 @@ namespace PcapDotNet.Core.Test ...@@ -153,6 +146,6 @@ namespace PcapDotNet.Core.Test
return queue; return queue;
} }
private static Random _random = new Random(); private static readonly Random _random = new Random();
} }
} }
\ No newline at end of file
using System; using System;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
...@@ -10,18 +9,11 @@ namespace PcapDotNet.Core.Test ...@@ -10,18 +9,11 @@ namespace PcapDotNet.Core.Test
[TestClass] [TestClass]
public class PcapDataLinkTests public class PcapDataLinkTests
{ {
public PcapDataLinkTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
...@@ -109,10 +101,9 @@ namespace PcapDotNet.Core.Test ...@@ -109,10 +101,9 @@ namespace PcapDotNet.Core.Test
for (int i = 0; i != 1000; ++i) for (int i = 0; i != 1000; ++i)
{ {
PcapDataLink dataLink = new PcapDataLink(i); PcapDataLink dataLink = new PcapDataLink(i);
string dataLinkName;
try try
{ {
dataLinkName = dataLink.Name; string dataLinkName = dataLink.Name;
Assert.IsNotNull(dataLinkName); Assert.IsNotNull(dataLinkName);
} }
catch (InvalidOperationException) catch (InvalidOperationException)
......
using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
...@@ -13,18 +9,11 @@ namespace PcapDotNet.Core.Test ...@@ -13,18 +9,11 @@ namespace PcapDotNet.Core.Test
[TestClass] [TestClass]
public class PcapLibTests public class PcapLibTests
{ {
public PcapLibTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
......
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
......
...@@ -31,18 +31,11 @@ namespace PcapDotNet.Core.Test ...@@ -31,18 +31,11 @@ namespace PcapDotNet.Core.Test
private const string WiresharkDiretory = @"C:\Program Files\Wireshark\"; private const string WiresharkDiretory = @"C:\Program Files\Wireshark\";
private const string WiresharkTsharkPath = WiresharkDiretory + @"tshark.exe"; private const string WiresharkTsharkPath = WiresharkDiretory + @"tshark.exe";
public WiresharkCompareTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
...@@ -82,8 +75,8 @@ namespace PcapDotNet.Core.Test ...@@ -82,8 +75,8 @@ namespace PcapDotNet.Core.Test
[TestMethod] [TestMethod]
public void CompareTimestampPacketsToWiresharkTest() public void CompareTimestampPacketsToWiresharkTest()
{ {
const long ticks = 633737178954260865; const long Ticks = 633737178954260865;
DateTime timestamp = new DateTime(ticks).ToUniversalTime().ToLocalTime(); DateTime timestamp = new DateTime(Ticks).ToUniversalTime().ToLocalTime();
// Create packet // Create packet
Packet packet = new Packet(new byte[14], timestamp, DataLinkKind.Ethernet); Packet packet = new Packet(new byte[14], timestamp, DataLinkKind.Ethernet);
...@@ -180,19 +173,25 @@ namespace PcapDotNet.Core.Test ...@@ -180,19 +173,25 @@ namespace PcapDotNet.Core.Test
{ {
string pcapFilename = Path.GetTempPath() + "temp." + new Random().NextByte() + ".pcap"; string pcapFilename = Path.GetTempPath() + "temp." + new Random().NextByte() + ".pcap";
// const bool isRetry = true; // const bool isRetry = true;
const bool isRetry = false; const bool IsRetry = false;
if (!isRetry) #pragma warning disable 162
// ReSharper disable ConditionIsAlwaysTrueOrFalse
// ReSharper disable HeuristicUnreachableCode
if (!IsRetry)
{ {
PacketDumpFile.Dump(pcapFilename, new PcapDataLink(DataLinkKind.Ethernet), PacketDevice.DefaultSnapshotLength, packets); PacketDumpFile.Dump(pcapFilename, new PcapDataLink(DataLinkKind.Ethernet), PacketDevice.DefaultSnapshotLength, packets);
} }
else else
{ {
const byte retryNumber = 55; const byte RetryNumber = 55;
pcapFilename = Path.GetTempPath() + "temp." + retryNumber + ".pcap"; pcapFilename = Path.GetTempPath() + "temp." + RetryNumber + ".pcap";
List<Packet> packetsList = new List<Packet>(); List<Packet> packetsList = new List<Packet>();
new OfflinePacketDevice(pcapFilename).Open().ReceivePackets(1000, packetsList.Add); new OfflinePacketDevice(pcapFilename).Open().ReceivePackets(1000, packetsList.Add);
packets = packetsList; packets = packetsList;
} }
// ReSharper restore HeuristicUnreachableCode
// ReSharper restore ConditionIsAlwaysTrueOrFalse
#pragma warning restore 162
// Create pdml file // Create pdml file
string documentFilename = pcapFilename + ".pdml"; string documentFilename = pcapFilename + ".pdml";
......
...@@ -5,7 +5,6 @@ using PcapDotNet.Packets.Arp; ...@@ -5,7 +5,6 @@ using PcapDotNet.Packets.Arp;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
using PcapDotNet.Packets.TestUtils; using PcapDotNet.Packets.TestUtils;
using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.Test namespace PcapDotNet.Packets.Test
{ {
...@@ -15,17 +14,10 @@ namespace PcapDotNet.Packets.Test ...@@ -15,17 +14,10 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class ArpTests public class ArpTests
{ {
public ArpTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext { get; set; } public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
......
...@@ -10,17 +10,10 @@ namespace PcapDotNet.Packets.Test ...@@ -10,17 +10,10 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class ByteArrayExtensionsTests public class ByteArrayExtensionsTests
{ {
public ByteArrayExtensionsTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext { get; set; } public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
......
...@@ -8,18 +8,11 @@ namespace PcapDotNet.Packets.Test ...@@ -8,18 +8,11 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class DataLinkTests public class DataLinkTests
{ {
public DataLinkTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
...@@ -50,8 +43,10 @@ namespace PcapDotNet.Packets.Test ...@@ -50,8 +43,10 @@ namespace PcapDotNet.Packets.Test
Assert.AreNotEqual(DataLink.Ethernet, 2); Assert.AreNotEqual(DataLink.Ethernet, 2);
Assert.AreEqual(DataLinkKind.Ethernet.ToString(), DataLink.Ethernet.ToString()); Assert.AreEqual(DataLinkKind.Ethernet.ToString(), DataLink.Ethernet.ToString());
Assert.AreEqual(DataLink.Ethernet.GetHashCode(), DataLink.Ethernet.GetHashCode()); Assert.AreEqual(DataLink.Ethernet.GetHashCode(), DataLink.Ethernet.GetHashCode());
// ReSharper disable EqualExpressionComparison
Assert.IsTrue(DataLink.Ethernet == DataLink.Ethernet); Assert.IsTrue(DataLink.Ethernet == DataLink.Ethernet);
Assert.IsFalse(DataLink.Ethernet != DataLink.Ethernet); Assert.IsFalse(DataLink.Ethernet != DataLink.Ethernet);
// ReSharper restore EqualExpressionComparison
} }
} }
} }
\ No newline at end of file
...@@ -16,18 +16,11 @@ namespace PcapDotNet.Packets.Test ...@@ -16,18 +16,11 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class DatagramTests public class DatagramTests
{ {
public DatagramTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
......
...@@ -9,18 +9,11 @@ namespace PcapDotNet.Packets.Test ...@@ -9,18 +9,11 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class EndianitiyTests public class EndianitiyTests
{ {
public EndianitiyTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
...@@ -119,18 +112,18 @@ namespace PcapDotNet.Packets.Test ...@@ -119,18 +112,18 @@ namespace PcapDotNet.Packets.Test
[TestMethod] [TestMethod]
public void UIntTest() public void UIntTest()
{ {
const uint value = 0x01020304; const uint Value = 0x01020304;
byte[] buffer = new byte[sizeof(uint)]; byte[] buffer = new byte[sizeof(uint)];
buffer.Write(0, value, Endianity.Big); buffer.Write(0, Value, Endianity.Big);
Assert.AreEqual(value, buffer.ReadUInt(0, Endianity.Big)); Assert.AreEqual(Value, buffer.ReadUInt(0, Endianity.Big));
Assert.AreEqual(0x01, buffer[0]); Assert.AreEqual(0x01, buffer[0]);
Assert.AreEqual(0x02, buffer[1]); Assert.AreEqual(0x02, buffer[1]);
Assert.AreEqual(0x03, buffer[2]); Assert.AreEqual(0x03, buffer[2]);
Assert.AreEqual(0x04, buffer[3]); Assert.AreEqual(0x04, buffer[3]);
buffer.Write(0, value, Endianity.Small); buffer.Write(0, Value, Endianity.Small);
Assert.AreEqual(value, buffer.ReadUInt(0, Endianity.Small)); Assert.AreEqual(Value, buffer.ReadUInt(0, Endianity.Small));
Assert.AreEqual(0x04, buffer[0]); Assert.AreEqual(0x04, buffer[0]);
Assert.AreEqual(0x03, buffer[1]); Assert.AreEqual(0x03, buffer[1]);
Assert.AreEqual(0x02, buffer[2]); Assert.AreEqual(0x02, buffer[2]);
......
...@@ -13,18 +13,11 @@ namespace PcapDotNet.Packets.Test ...@@ -13,18 +13,11 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class EthernetTests public class EthernetTests
{ {
public EthernetTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Base;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.Gre; using PcapDotNet.Packets.Gre;
using PcapDotNet.Packets.Icmp; using PcapDotNet.Packets.Icmp;
...@@ -19,13 +17,6 @@ namespace PcapDotNet.Packets.Test ...@@ -19,13 +17,6 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class GreTests public class GreTests
{ {
public GreTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
/// Gets or sets the test context which provides /// Gets or sets the test context which provides
/// information about and functionality for the current test run. /// information about and functionality for the current test run.
......
...@@ -2,10 +2,8 @@ using System; ...@@ -2,10 +2,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Base;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.Icmp; using PcapDotNet.Packets.Icmp;
using PcapDotNet.Packets.Igmp;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
using PcapDotNet.Packets.TestUtils; using PcapDotNet.Packets.TestUtils;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
...@@ -18,18 +16,11 @@ namespace PcapDotNet.Packets.Test ...@@ -18,18 +16,11 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class IcmpTests public class IcmpTests
{ {
public IcmpTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
/// Gets or sets the test context which provides /// Gets or sets the test context which provides
/// information about and functionality for the current test run. /// information about and functionality for the current test run.
/// </summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.Igmp; using PcapDotNet.Packets.Igmp;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
using PcapDotNet.Packets.TestUtils; using PcapDotNet.Packets.TestUtils;
using PcapDotNet.Packets.Transport;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.Test namespace PcapDotNet.Packets.Test
...@@ -18,18 +16,11 @@ namespace PcapDotNet.Packets.Test ...@@ -18,18 +16,11 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class IgmpTests public class IgmpTests
{ {
public IgmpTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
......
using System; using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
using PcapDotNet.Packets.TestUtils; using PcapDotNet.Packets.TestUtils;
...@@ -14,22 +11,11 @@ namespace PcapDotNet.Packets.Test ...@@ -14,22 +11,11 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class IpV4AddressTests public class IpV4AddressTests
{ {
public IpV4AddressTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext public TestContext TestContext { get; set; }
{
get;
set;
}
#region Additional test attributes #region Additional test attributes
// //
......
using System; using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Base;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
using PcapDotNet.Packets.TestUtils; using PcapDotNet.Packets.TestUtils;
...@@ -17,18 +14,11 @@ namespace PcapDotNet.Packets.Test ...@@ -17,18 +14,11 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class IpV4Tests public class IpV4Tests
{ {
public IpV4Tests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
...@@ -90,13 +80,13 @@ namespace PcapDotNet.Packets.Test ...@@ -90,13 +80,13 @@ namespace PcapDotNet.Packets.Test
{ {
MacAddress ethernetSource = new MacAddress("00:01:02:03:04:05"); MacAddress ethernetSource = new MacAddress("00:01:02:03:04:05");
MacAddress ethernetDestination = new MacAddress("A0:A1:A2:A3:A4:A5"); MacAddress ethernetDestination = new MacAddress("A0:A1:A2:A3:A4:A5");
const EthernetType ethernetType = EthernetType.IpV4; const EthernetType EthernetType = EthernetType.IpV4;
EthernetLayer ethernetLayer = new EthernetLayer EthernetLayer ethernetLayer = new EthernetLayer
{ {
Source = ethernetSource, Source = ethernetSource,
Destination = ethernetDestination, Destination = ethernetDestination,
EtherType = ethernetType EtherType = EthernetType
}; };
Random random = new Random(); Random random = new Random();
...@@ -237,7 +227,7 @@ namespace PcapDotNet.Packets.Test ...@@ -237,7 +227,7 @@ namespace PcapDotNet.Packets.Test
public void IpV4OptionRoutePointedAddressIndexErrorTest() public void IpV4OptionRoutePointedAddressIndexErrorTest()
{ {
Random random = new Random(); Random random = new Random();
IpV4Option option = new IpV4OptionRecordRoute(random.NextByte(IpV4OptionRecordRoute.PointedAddressIndexMaxValue + 1, byte.MaxValue + 1)); IpV4Option option = new IpV4OptionRecordRoute(random.NextByte(IpV4OptionRoute.PointedAddressIndexMaxValue + 1, byte.MaxValue + 1));
Assert.IsNotNull(option); Assert.IsNotNull(option);
Assert.Fail(); Assert.Fail();
} }
...@@ -327,8 +317,10 @@ namespace PcapDotNet.Packets.Test ...@@ -327,8 +317,10 @@ namespace PcapDotNet.Packets.Test
IpV4TimeOfDay timeSinceMidnight = new IpV4TimeOfDay(timeOfDay); IpV4TimeOfDay timeSinceMidnight = new IpV4TimeOfDay(timeOfDay);
Assert.AreEqual(timeOfDay, timeSinceMidnight.TimeSinceMidnightUniversalTime); Assert.AreEqual(timeOfDay, timeSinceMidnight.TimeSinceMidnightUniversalTime);
Assert.AreEqual<object>(timeSinceMidnight, timeSinceMidnight); Assert.AreEqual<object>(timeSinceMidnight, timeSinceMidnight);
// ReSharper disable EqualExpressionComparison
Assert.IsTrue(timeSinceMidnight == timeSinceMidnight); Assert.IsTrue(timeSinceMidnight == timeSinceMidnight);
Assert.IsFalse(timeSinceMidnight != timeSinceMidnight); Assert.IsFalse(timeSinceMidnight != timeSinceMidnight);
// ReSharper restore EqualExpressionComparison
} }
[TestMethod] [TestMethod]
......
using System; using System;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.IpV4;
using PcapDotNet.Packets.IpV6; using PcapDotNet.Packets.IpV6;
using PcapDotNet.Packets.TestUtils; using PcapDotNet.Packets.TestUtils;
...@@ -12,13 +11,6 @@ namespace PcapDotNet.Packets.Test ...@@ -12,13 +11,6 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class IpV6AddressTests public class IpV6AddressTests
{ {
public IpV6AddressTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
/// Gets or sets the test context which provides /// Gets or sets the test context which provides
/// information about and functionality for the current test run. /// information about and functionality for the current test run.
......
...@@ -11,18 +11,11 @@ namespace PcapDotNet.Packets.Test ...@@ -11,18 +11,11 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class MacAddressTests public class MacAddressTests
{ {
public MacAddressTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
......
...@@ -10,17 +10,10 @@ namespace PcapDotNet.Packets.Test ...@@ -10,17 +10,10 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class PacketBuilderTests public class PacketBuilderTests
{ {
public PacketBuilderTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext { get; set; } public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
......
...@@ -14,18 +14,11 @@ namespace PcapDotNet.Packets.Test ...@@ -14,18 +14,11 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class PacketTests public class PacketTests
{ {
public PacketTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
......
...@@ -12,17 +12,10 @@ namespace PcapDotNet.Packets.Test ...@@ -12,17 +12,10 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class PayloadLayerTests public class PayloadLayerTests
{ {
public PayloadLayerTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext { get; set;} public TestContext TestContext { get; set;}
#region Additional test attributes #region Additional test attributes
......
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
......
using System; using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
using PcapDotNet.Packets.TestUtils; using PcapDotNet.Packets.TestUtils;
using PcapDotNet.Packets.Transport; using PcapDotNet.Packets.Transport;
using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.Test namespace PcapDotNet.Packets.Test
{ {
...@@ -15,18 +13,11 @@ namespace PcapDotNet.Packets.Test ...@@ -15,18 +13,11 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class TcpTests public class TcpTests
{ {
public TcpTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
......
...@@ -4,7 +4,6 @@ using PcapDotNet.Packets.Ethernet; ...@@ -4,7 +4,6 @@ using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
using PcapDotNet.Packets.TestUtils; using PcapDotNet.Packets.TestUtils;
using PcapDotNet.Packets.Transport; using PcapDotNet.Packets.Transport;
using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.Test namespace PcapDotNet.Packets.Test
{ {
...@@ -14,18 +13,11 @@ namespace PcapDotNet.Packets.Test ...@@ -14,18 +13,11 @@ namespace PcapDotNet.Packets.Test
[TestClass] [TestClass]
public class UdpTests public class UdpTests
{ {
public UdpTests()
{
//
// TODO: Add constructor logic here
//
}
/// <summary> /// <summary>
///Gets or sets the test context which provides /// Gets or sets the test context which provides
///information about and functionality for the current test run. /// information about and functionality for the current test run.
///</summary> /// </summary>
public TestContext TestContext{ get; set;} public TestContext TestContext { get; set; }
#region Additional test attributes #region Additional test attributes
// //
......
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets;
using PcapDotNet.Packets.Arp; using PcapDotNet.Packets.Arp;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.Gre; using PcapDotNet.Packets.Gre;
...@@ -511,11 +508,11 @@ namespace PcapDotNet.Packets.TestUtils ...@@ -511,11 +508,11 @@ namespace PcapDotNet.Packets.TestUtils
IgmpQueryVersion igmpQueryVersion = IgmpQueryVersion.None; IgmpQueryVersion igmpQueryVersion = IgmpQueryVersion.None;
TimeSpan igmpMaxResponseTime = random.NextTimeSpan(TimeSpan.FromSeconds(0.1), TimeSpan.FromSeconds(256 * 0.1) - TimeSpan.FromTicks(1)); TimeSpan igmpMaxResponseTime = random.NextTimeSpan(TimeSpan.FromSeconds(0.1), TimeSpan.FromSeconds(256 * 0.1) - TimeSpan.FromTicks(1));
IpV4Address igmpGroupAddress = random.NextIpV4Address(); IpV4Address igmpGroupAddress = random.NextIpV4Address();
bool? igmpIsSuppressRouterSideProcessing = null; bool? igmpIsSuppressRouterSideProcessing;
byte? igmpQueryRobustnessVariable = null; byte? igmpQueryRobustnessVariable;
TimeSpan? igmpQueryInterval = null; TimeSpan? igmpQueryInterval;
IpV4Address[] igmpSourceAddresses = null; IpV4Address[] igmpSourceAddresses;
IgmpGroupRecord[] igmpGroupRecords = null; IgmpGroupRecord[] igmpGroupRecords;
switch (igmpMessageType) switch (igmpMessageType)
{ {
...@@ -870,10 +867,6 @@ namespace PcapDotNet.Packets.TestUtils ...@@ -870,10 +867,6 @@ namespace PcapDotNet.Packets.TestUtils
icmpPayloadLayers = icmpPayloadLayers.Concat(random.NextIpV4Layer(), random.NextPayloadLayer(IcmpIpV4HeaderPlus64BitsPayloadDatagram.OriginalDatagramPayloadLength)); icmpPayloadLayers = icmpPayloadLayers.Concat(random.NextIpV4Layer(), random.NextPayloadLayer(IcmpIpV4HeaderPlus64BitsPayloadDatagram.OriginalDatagramPayloadLength));
break; break;
case IcmpMessageType.ConversionFailed: case IcmpMessageType.ConversionFailed:
IpV4Protocol icmpIpV4Protocol = random.NextBool()
? random.NextValue(new[] {IpV4Protocol.Udp, IpV4Protocol.Tcp})
: random.NextEnum<IpV4Protocol>();
IpV4Layer icmpIpV4Layer = random.NextIpV4Layer(); IpV4Layer icmpIpV4Layer = random.NextIpV4Layer();
icmpPayloadLayers = icmpPayloadLayers.Concat(icmpIpV4Layer); icmpPayloadLayers = icmpPayloadLayers.Concat(icmpIpV4Layer);
if (icmpLayer.MessageTypeAndCode == IcmpMessageTypeAndCode.ConversionFailedUnsupportedTransportProtocol) if (icmpLayer.MessageTypeAndCode == IcmpMessageTypeAndCode.ConversionFailedUnsupportedTransportProtocol)
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
......
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Xml.Serialization;
using PcapDotNet.Base;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
namespace PcapDotNet.Packets.Arp namespace PcapDotNet.Packets.Arp
...@@ -13,13 +10,6 @@ namespace PcapDotNet.Packets.Arp ...@@ -13,13 +10,6 @@ namespace PcapDotNet.Packets.Arp
/// </summary> /// </summary>
public class ArpLayer : Layer, IEthernetNextLayer public class ArpLayer : Layer, IEthernetNextLayer
{ {
/// <summary>
/// Create an ARP layer.
/// </summary>
public ArpLayer()
{
}
/// <summary> /// <summary>
/// Each protocol is assigned a number used in this field. /// Each protocol is assigned a number used in this field.
/// </summary> /// </summary>
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Net; using System.Net;
using System.Text;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
......
...@@ -2,7 +2,6 @@ using System; ...@@ -2,7 +2,6 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
......
...@@ -79,12 +79,12 @@ namespace PcapDotNet.Packets.Ethernet ...@@ -79,12 +79,12 @@ namespace PcapDotNet.Packets.Ethernet
/// </summary> /// </summary>
public override ILayer ExtractLayer() public override ILayer ExtractLayer()
{ {
return new EthernetLayer() return new EthernetLayer
{ {
Source = Source, Source = Source,
Destination = Destination, Destination = Destination,
EtherType = EtherType, EtherType = EtherType,
}; };
} }
/// <summary> /// <summary>
...@@ -138,13 +138,10 @@ namespace PcapDotNet.Packets.Ethernet ...@@ -138,13 +138,10 @@ namespace PcapDotNet.Packets.Ethernet
{ {
get get
{ {
if (_payloadDatagrams == null) return _payloadDatagrams ?? (_payloadDatagrams = new EthernetPayloadDatagrams(Length >= HeaderLength
{ ? new Datagram(Buffer, StartOffset + HeaderLength,
_payloadDatagrams = new EthernetPayloadDatagrams(Length >= HeaderLength Length - HeaderLength)
? new Datagram(Buffer, StartOffset + HeaderLength, Length - HeaderLength) : null));
: null);
}
return _payloadDatagrams;
} }
} }
......
...@@ -380,14 +380,14 @@ namespace PcapDotNet.Packets.Gre ...@@ -380,14 +380,14 @@ namespace PcapDotNet.Packets.Gre
ReadOnlyCollection<GreSourceRouteEntry> routing, ushort? routingOffset, bool strictSourceRoute) ReadOnlyCollection<GreSourceRouteEntry> routing, ushort? routingOffset, bool strictSourceRoute)
{ {
buffer.Write(offset + Offset.ChecksumPresent, buffer.Write(offset + Offset.ChecksumPresent,
(byte)((checksumPresent ? Mask.ChecksumPresent : (byte)0) | (byte)((checksumPresent ? Mask.ChecksumPresent : 0) |
(routing != null ? Mask.RoutingPresent : (byte)0) | (routing != null ? Mask.RoutingPresent : 0) |
(key != null ? Mask.KeyPresent : (byte)0) | (key != null ? Mask.KeyPresent : 0) |
(sequenceNumber != null ? Mask.SequenceNumberPresent : (byte)0) | (sequenceNumber != null ? Mask.SequenceNumberPresent : 0) |
(strictSourceRoute ? Mask.StrictSourceRoute : (byte)0) | (strictSourceRoute ? Mask.StrictSourceRoute : 0) |
(recursionControl & Mask.RecursionControl))); (recursionControl & Mask.RecursionControl)));
buffer.Write(offset + Offset.FutureUseBits, (byte)((acknowledgmentSequenceNumber != null ? Mask.AcknowledgmentSequenceNumberPresent : (byte)0) | buffer.Write(offset + Offset.FutureUseBits, (byte)((acknowledgmentSequenceNumber != null ? Mask.AcknowledgmentSequenceNumberPresent : 0) |
((flags << Shift.FutureUseBits) & Mask.FutureUseBits) | ((flags << Shift.FutureUseBits) & Mask.FutureUseBits) |
((byte)version & Mask.Version))); ((byte)version & Mask.Version)));
...@@ -515,13 +515,10 @@ namespace PcapDotNet.Packets.Gre ...@@ -515,13 +515,10 @@ namespace PcapDotNet.Packets.Gre
{ {
get get
{ {
if (_payloadDatagrams == null) return _payloadDatagrams ?? (_payloadDatagrams = new EthernetPayloadDatagrams(Length >= HeaderLength
{ ? new Datagram(Buffer, StartOffset + HeaderLength,
_payloadDatagrams = new EthernetPayloadDatagrams(Length >= HeaderLength Length - HeaderLength)
? new Datagram(Buffer, StartOffset + HeaderLength, Length - HeaderLength) : null));
: null);
}
return _payloadDatagrams;
} }
} }
......
...@@ -133,7 +133,7 @@ namespace PcapDotNet.Packets.Gre ...@@ -133,7 +133,7 @@ namespace PcapDotNet.Packets.Gre
{ {
buffer.Write(offset + Offset.AddressFamily, (ushort)AddressFamily, Endianity.Big); buffer.Write(offset + Offset.AddressFamily, (ushort)AddressFamily, Endianity.Big);
buffer.Write(offset + Offset.SreOffset, PayloadOffset); buffer.Write(offset + Offset.SreOffset, PayloadOffset);
buffer.Write(offset + Offset.SreLength, (byte)PayloadLength); buffer.Write(offset + Offset.SreLength, PayloadLength);
WritePayload(buffer, offset + HeaderLength); WritePayload(buffer, offset + HeaderLength);
offset += Length; offset += Length;
} }
......
...@@ -4,7 +4,7 @@ namespace PcapDotNet.Packets ...@@ -4,7 +4,7 @@ namespace PcapDotNet.Packets
/// A factory interface for an unknown option. /// A factory interface for an unknown option.
/// </summary> /// </summary>
/// <typeparam name="TOptionType">The option type enum type.</typeparam> /// <typeparam name="TOptionType">The option type enum type.</typeparam>
public interface IOptionUnknownFactory<TOptionType> public interface IOptionUnknownFactory<in TOptionType>
{ {
/// <summary> /// <summary>
/// Creates an unknown option from its type and by reading a buffer for its value. /// Creates an unknown option from its type and by reading a buffer for its value.
......
using System;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Icmp namespace PcapDotNet.Packets.Icmp
......
using System;
using System.Linq; using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using PcapDotNet.Packets.IpV4;
using PcapDotNet.Base; using PcapDotNet.Base;
namespace PcapDotNet.Packets.Icmp namespace PcapDotNet.Packets.Icmp
......
using System;
using System.Linq; using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
......
using System;
namespace PcapDotNet.Packets.Icmp namespace PcapDotNet.Packets.Icmp
{ {
/// <summary> /// <summary>
......
using System;
namespace PcapDotNet.Packets.Icmp namespace PcapDotNet.Packets.Icmp
{ {
/// <summary> /// <summary>
......
using System;
namespace PcapDotNet.Packets.Icmp namespace PcapDotNet.Packets.Icmp
{ {
/// <summary> /// <summary>
......
using System;
namespace PcapDotNet.Packets.Icmp namespace PcapDotNet.Packets.Icmp
{ {
/// <summary> /// <summary>
......
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Icmp namespace PcapDotNet.Packets.Icmp
{ {
/// <summary> /// <summary>
......
using System;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Icmp namespace PcapDotNet.Packets.Icmp
......
using System;
namespace PcapDotNet.Packets.Icmp namespace PcapDotNet.Packets.Icmp
{ {
/// <summary> /// <summary>
......
using System;
using System.Linq; using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
......
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
...@@ -12,13 +11,6 @@ namespace PcapDotNet.Packets.Icmp ...@@ -12,13 +11,6 @@ namespace PcapDotNet.Packets.Icmp
/// </summary> /// </summary>
public class IcmpRouterAdvertisementLayer : IcmpLayer public class IcmpRouterAdvertisementLayer : IcmpLayer
{ {
/// <summary>
/// Creates an ICMP layer instance.
/// </summary>
public IcmpRouterAdvertisementLayer()
{
}
/// <summary> /// <summary>
/// The maximum time that the router addresses may be considered valid. /// The maximum time that the router addresses may be considered valid.
/// </summary> /// </summary>
......
using System;
namespace PcapDotNet.Packets.Icmp namespace PcapDotNet.Packets.Icmp
{ {
/// <summary> /// <summary>
......
using System;
using System.Linq; using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
......
using System;
namespace PcapDotNet.Packets.Icmp namespace PcapDotNet.Packets.Icmp
{ {
/// <summary> /// <summary>
......
using System;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Icmp namespace PcapDotNet.Packets.Icmp
......
using System;
using System.Linq; using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
......
using System;
namespace PcapDotNet.Packets.Icmp namespace PcapDotNet.Packets.Icmp
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
......
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
......
using System; using System;
using System.Collections;
using System.Linq;
using System.Text;
using PcapDotNet.Packets.Gre; using PcapDotNet.Packets.Gre;
using PcapDotNet.Packets.Icmp; using PcapDotNet.Packets.Icmp;
using PcapDotNet.Packets.Igmp; using PcapDotNet.Packets.Igmp;
...@@ -180,12 +177,7 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -180,12 +177,7 @@ namespace PcapDotNet.Packets.IpV4
/// </summary> /// </summary>
public IpV4Options Options public IpV4Options Options
{ {
get get { return _options ?? (_options = new IpV4Options(Buffer, StartOffset + Offset.Options, RealHeaderLength - HeaderMinimumLength)); }
{
if (_options == null)
_options = new IpV4Options(Buffer, StartOffset + Offset.Options, RealHeaderLength - HeaderMinimumLength);
return _options;
}
} }
/// <summary> /// <summary>
......
using System; using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV4 namespace PcapDotNet.Packets.IpV4
{ {
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace PcapDotNet.Packets.IpV4 namespace PcapDotNet.Packets.IpV4
{ {
/// <summary> /// <summary>
......
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV4 namespace PcapDotNet.Packets.IpV4
{ {
......
using System.Collections.Generic; using System.Collections.Generic;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV4 namespace PcapDotNet.Packets.IpV4
{ {
......
using System.Collections.Generic; using System.Collections.Generic;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV4 namespace PcapDotNet.Packets.IpV4
{ {
......
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
......
using System;
namespace PcapDotNet.Packets.IpV4 namespace PcapDotNet.Packets.IpV4
{ {
/// <summary> /// <summary>
......
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.IpV4 namespace PcapDotNet.Packets.IpV4
{ {
......
using System;
namespace PcapDotNet.Packets namespace PcapDotNet.Packets
{ {
/// <summary> /// <summary>
...@@ -7,7 +9,7 @@ namespace PcapDotNet.Packets ...@@ -7,7 +9,7 @@ namespace PcapDotNet.Packets
/// A packet can be according to a sequence of layers. /// A packet can be according to a sequence of layers.
/// <seealso cref="PacketBuilder"/> /// <seealso cref="PacketBuilder"/>
/// </summary> /// </summary>
public abstract class Layer : ILayer public abstract class Layer : ILayer, IEquatable<Layer>
{ {
/// <summary> /// <summary>
/// The number of bytes this layer will take. /// The number of bytes this layer will take.
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using PcapDotNet.Base; using PcapDotNet.Base;
...@@ -25,7 +24,7 @@ namespace PcapDotNet.Packets ...@@ -25,7 +24,7 @@ namespace PcapDotNet.Packets
IOptionComplexFactory prototype; IOptionComplexFactory prototype;
if (!_complexOptions.TryGetValue(optionType, out prototype)) if (!_complexOptions.TryGetValue(optionType, out prototype))
return UnknownFactoryOptionPrototype.CreateInstance(optionType, buffer, ref offset, optionValueLength); return _unknownFactoryOptionPrototype.CreateInstance(optionType, buffer, ref offset, optionValueLength);
return prototype.CreateInstance(buffer, ref offset, optionValueLength); return prototype.CreateInstance(buffer, ref offset, optionValueLength);
} }
...@@ -72,6 +71,6 @@ namespace PcapDotNet.Packets ...@@ -72,6 +71,6 @@ namespace PcapDotNet.Packets
} }
private static readonly Dictionary<TOptionType, IOptionComplexFactory> _complexOptions = InitializeComplexOptions(); private static readonly Dictionary<TOptionType, IOptionComplexFactory> _complexOptions = InitializeComplexOptions();
private static readonly IOptionUnknownFactory<TOptionType> UnknownFactoryOptionPrototype = InitializeUnknownOptionPrototype(); private static readonly IOptionUnknownFactory<TOptionType> _unknownFactoryOptionPrototype = InitializeUnknownOptionPrototype();
} }
} }
\ No newline at end of file
using System;
using System.Diagnostics;
namespace PcapDotNet.Packets
{
// internal static class OptionComplexFactoryBase
// {
// /// <summary>
// /// The header length in bytes for the option (type and size).
// /// </summary>
// public const int OptionHeaderLength = 2;
//
//// [DebuggerHidden]
//// protected OptionComplexFactoryBase()
//// {
//// throw new NotImplementedException();
//// }
// }
}
\ No newline at end of file
...@@ -252,12 +252,7 @@ namespace PcapDotNet.Packets ...@@ -252,12 +252,7 @@ namespace PcapDotNet.Packets
/// </summary> /// </summary>
public EthernetDatagram Ethernet public EthernetDatagram Ethernet
{ {
get get { return _ethernet ?? (_ethernet = new EthernetDatagram(Buffer, 0, Length)); }
{
if (_ethernet == null)
_ethernet = new EthernetDatagram(Buffer, 0, Length);
return _ethernet;
}
} }
private bool CalculateIsValid() private bool CalculateIsValid()
......
...@@ -223,7 +223,6 @@ ...@@ -223,7 +223,6 @@
<Compile Include="IpV4\IpV4Protocol.cs" /> <Compile Include="IpV4\IpV4Protocol.cs" />
<Compile Include="ByteArrayExtensions.cs" /> <Compile Include="ByteArrayExtensions.cs" />
<Compile Include="OptionComplexFactory.cs" /> <Compile Include="OptionComplexFactory.cs" />
<Compile Include="OptionComplexFactoryBase.cs" />
<Compile Include="Options.cs" /> <Compile Include="Options.cs" />
<Compile Include="OptionTypeRegistrationAttribute.cs" /> <Compile Include="OptionTypeRegistrationAttribute.cs" />
<Compile Include="Packet.cs" /> <Compile Include="Packet.cs" />
......
using System; using System;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
......
...@@ -159,12 +159,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -159,12 +159,7 @@ namespace PcapDotNet.Packets.Transport
/// </summary> /// </summary>
public TcpOptions Options public TcpOptions Options
{ {
get get { return _options ?? (_options = new TcpOptions(Buffer, StartOffset + Offset.Options, RealHeaderLength - HeaderMinimumLength)); }
{
if (_options == null)
_options = new TcpOptions(Buffer, StartOffset + Offset.Options, RealHeaderLength - HeaderMinimumLength);
return _options;
}
} }
/// <summary> /// <summary>
......
using System;
namespace PcapDotNet.Packets.Transport namespace PcapDotNet.Packets.Transport
{ {
/// <summary> /// <summary>
/// Represents a block to ack when using the selective ack option. /// Represents a block to ack when using the selective ack option.
/// </summary> /// </summary>
public struct TcpOptionSelectiveAcknowledgmentBlock public struct TcpOptionSelectiveAcknowledgmentBlock : IEquatable<TcpOptionSelectiveAcknowledgmentBlock>
{ {
/// <summary> /// <summary>
/// The number of bytes this struct take. /// The number of bytes this struct take.
......
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace PcapDotNet.Packets.Transport namespace PcapDotNet.Packets.Transport
......
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