Commit 1b3a8cb3 authored by Boaz Brickner's avatar Boaz Brickner

Merge pull request #65 from bricknerb/master

IGMP version 0.
parents 6f651f0d 2b2d06b7
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
...@@ -8,6 +9,7 @@ namespace PcapDotNet.Base.Test ...@@ -8,6 +9,7 @@ namespace PcapDotNet.Base.Test
/// Summary description for BitSequenceTest /// Summary description for BitSequenceTest
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class BitSequenceTest public class BitSequenceTest
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PcapDotNet.Base.Test namespace PcapDotNet.Base.Test
...@@ -7,6 +8,7 @@ namespace PcapDotNet.Base.Test ...@@ -7,6 +8,7 @@ namespace PcapDotNet.Base.Test
/// Summary description for DateTimeExtensionsTest /// Summary description for DateTimeExtensionsTest
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class DateTimeExtensionsTest public class DateTimeExtensionsTest
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PcapDotNet.Base.Test namespace PcapDotNet.Base.Test
...@@ -7,6 +8,7 @@ namespace PcapDotNet.Base.Test ...@@ -7,6 +8,7 @@ namespace PcapDotNet.Base.Test
/// Summary description for FuncExtensionsTest /// Summary description for FuncExtensionsTest
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class FuncExtensionsTest public class FuncExtensionsTest
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
...@@ -8,6 +9,7 @@ namespace PcapDotNet.Base.Test ...@@ -8,6 +9,7 @@ namespace PcapDotNet.Base.Test
/// Summary description for DictionaryExtensionsTests /// Summary description for DictionaryExtensionsTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
public class IDictionaryExtensionsTests public class IDictionaryExtensionsTests
// ReSharper restore InconsistentNaming // ReSharper restore InconsistentNaming
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
...@@ -9,7 +10,8 @@ namespace PcapDotNet.Base.Test ...@@ -9,7 +10,8 @@ namespace PcapDotNet.Base.Test
/// Summary description for IEnumerableExtensionsTests /// Summary description for IEnumerableExtensionsTests
/// </summary> /// </summary>
[TestClass] [TestClass]
// ReSharper disable InconsistentNaming [ExcludeFromCodeCoverage]
// ReSharper disable InconsistentNaming
public class IEnumerableExtensionsTests public class IEnumerableExtensionsTests
// ReSharper restore InconsistentNaming // ReSharper restore InconsistentNaming
{ {
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
...@@ -8,6 +9,7 @@ namespace PcapDotNet.Base.Test ...@@ -8,6 +9,7 @@ namespace PcapDotNet.Base.Test
/// Summary description for MatchExtensionsTest /// Summary description for MatchExtensionsTest
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class MatchExtensionsTest public class MatchExtensionsTest
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PcapDotNet.Base.Test namespace PcapDotNet.Base.Test
...@@ -7,6 +8,7 @@ namespace PcapDotNet.Base.Test ...@@ -7,6 +8,7 @@ namespace PcapDotNet.Base.Test
/// Summary description for PropertyInfoExtensionsTests /// Summary description for PropertyInfoExtensionsTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class PropertyInfoExtensionsTests public class PropertyInfoExtensionsTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PcapDotNet.Base.Test namespace PcapDotNet.Base.Test
...@@ -7,6 +8,7 @@ namespace PcapDotNet.Base.Test ...@@ -7,6 +8,7 @@ namespace PcapDotNet.Base.Test
/// Summary description for SequenceTest /// Summary description for SequenceTest
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class SequenceTest public class SequenceTest
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
...@@ -8,6 +9,7 @@ namespace PcapDotNet.Base.Test ...@@ -8,6 +9,7 @@ namespace PcapDotNet.Base.Test
/// Summary description for SerialNumber32Test /// Summary description for SerialNumber32Test
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class SerialNumber32Test public class SerialNumber32Test
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System.Numerics; using System.Numerics;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
...@@ -10,6 +11,7 @@ namespace PcapDotNet.Base.Test ...@@ -10,6 +11,7 @@ namespace PcapDotNet.Base.Test
/// Summary description for UInt128Tests /// Summary description for UInt128Tests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class UInt128Tests public class UInt128Tests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
...@@ -8,6 +9,7 @@ namespace PcapDotNet.Base.Test ...@@ -8,6 +9,7 @@ namespace PcapDotNet.Base.Test
/// Summary description for UInt24Tests /// Summary description for UInt24Tests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class UInt24Tests public class UInt24Tests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
...@@ -9,6 +10,7 @@ namespace PcapDotNet.Base.Test ...@@ -9,6 +10,7 @@ namespace PcapDotNet.Base.Test
/// Summary description for UInt48Tests /// Summary description for UInt48Tests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class UInt48Tests public class UInt48Tests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets; using PcapDotNet.Packets;
using PcapDotNet.Packets.TestUtils; using PcapDotNet.Packets.TestUtils;
...@@ -9,6 +10,7 @@ namespace PcapDotNet.Core.Test ...@@ -9,6 +10,7 @@ namespace PcapDotNet.Core.Test
/// Summary description for BerkeleyPacketFilterTests /// Summary description for BerkeleyPacketFilterTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class BerkeleyPacketFilterTests public class BerkeleyPacketFilterTests
{ {
/// <summary> /// <summary>
......
using System.Diagnostics.CodeAnalysis;
using PcapDotNet.Packets.IpV6; using PcapDotNet.Packets.IpV6;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal static class IpV6AddressExtensions internal static class IpV6AddressExtensions
{ {
public static string GetWiresharkString(this IpV6Address address) public static string GetWiresharkString(this IpV6Address address)
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Core.Extensions; using PcapDotNet.Core.Extensions;
...@@ -8,6 +9,7 @@ namespace PcapDotNet.Core.Test ...@@ -8,6 +9,7 @@ namespace PcapDotNet.Core.Test
/// Summary description for LivePacketDeviceExtensionsTests /// Summary description for LivePacketDeviceExtensionsTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class LivePacketDeviceExtensionsTests public class LivePacketDeviceExtensionsTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.Threading; using System.Threading;
...@@ -18,6 +19,7 @@ namespace PcapDotNet.Core.Test ...@@ -18,6 +19,7 @@ namespace PcapDotNet.Core.Test
/// Summary description for LivePacketDeviceTests /// Summary description for LivePacketDeviceTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class LivePacketDeviceTests public class LivePacketDeviceTests
{ {
public LivePacketDeviceTests() public LivePacketDeviceTests()
......
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
...@@ -6,6 +7,7 @@ namespace PcapDotNet.Core.Test ...@@ -6,6 +7,7 @@ namespace PcapDotNet.Core.Test
/// Summary description for MarshalingServicesTests /// Summary description for MarshalingServicesTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class MarshalingServicesTests public class MarshalingServicesTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Core.Extensions; using PcapDotNet.Core.Extensions;
...@@ -10,6 +11,7 @@ namespace PcapDotNet.Core.Test ...@@ -10,6 +11,7 @@ namespace PcapDotNet.Core.Test
/// Summary description for NetworkInterfaceExtensionsTests. /// Summary description for NetworkInterfaceExtensionsTests.
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class NetworkInterfaceExtensionsTests public class NetworkInterfaceExtensionsTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
...@@ -14,6 +15,7 @@ namespace PcapDotNet.Core.Test ...@@ -14,6 +15,7 @@ namespace PcapDotNet.Core.Test
/// Summary description for OfflinePacketDeviceTests /// Summary description for OfflinePacketDeviceTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class OfflinePacketDeviceTests public class OfflinePacketDeviceTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Base; using PcapDotNet.Base;
...@@ -12,6 +13,7 @@ namespace PcapDotNet.Core.Test ...@@ -12,6 +13,7 @@ namespace PcapDotNet.Core.Test
/// Summary description for PacketDumpFileTests /// Summary description for PacketDumpFileTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class PacketDumpFileTests public class PacketDumpFileTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets; using PcapDotNet.Packets;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class PacketHandler internal class PacketHandler
{ {
public PacketHandler(Packet expectedPacket, DateTime expectedMinTimestamp, DateTime expectedMaxTimestamp, public PacketHandler(Packet expectedPacket, DateTime expectedMinTimestamp, DateTime expectedMaxTimestamp,
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets; using PcapDotNet.Packets;
using PcapDotNet.Packets.TestUtils; using PcapDotNet.Packets.TestUtils;
...@@ -11,6 +12,7 @@ namespace PcapDotNet.Core.Test ...@@ -11,6 +12,7 @@ namespace PcapDotNet.Core.Test
/// Summary description for PacketSendQueueTests /// Summary description for PacketSendQueueTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class PacketSendQueueTests public class PacketSendQueueTests
{ {
/// <summary> /// <summary>
......
using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
...@@ -7,6 +8,7 @@ namespace PcapDotNet.Core.Test ...@@ -7,6 +8,7 @@ namespace PcapDotNet.Core.Test
/// Summary description for PacketTimestampTests. /// Summary description for PacketTimestampTests.
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class PacketTimestampTests public class PacketTimestampTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets; using PcapDotNet.Packets;
...@@ -8,6 +9,7 @@ namespace PcapDotNet.Core.Test ...@@ -8,6 +9,7 @@ namespace PcapDotNet.Core.Test
/// Summary description for PcapDataLinkTests /// Summary description for PcapDataLinkTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class PcapDataLinkTests public class PcapDataLinkTests
{ {
/// <summary> /// <summary>
......
using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
...@@ -7,6 +8,7 @@ namespace PcapDotNet.Core.Test ...@@ -7,6 +8,7 @@ namespace PcapDotNet.Core.Test
/// Summary description for PcapLibTests. /// Summary description for PcapLibTests.
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class PcapLibTests public class PcapLibTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
...@@ -25,6 +26,7 @@ namespace PcapDotNet.Core.Test ...@@ -25,6 +26,7 @@ namespace PcapDotNet.Core.Test
/// Summary description for WiresharkCompareTests /// Summary description for WiresharkCompareTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class WiresharkCompareTests public class WiresharkCompareTests
{ {
private const string WiresharkDiretory = @"C:\Program Files\Wireshark\"; private const string WiresharkDiretory = @"C:\Program Files\Wireshark\";
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection; using System.Reflection;
using System.Xml.Linq; using System.Xml.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
...@@ -6,6 +7,7 @@ using PcapDotNet.Packets; ...@@ -6,6 +7,7 @@ using PcapDotNet.Packets;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal abstract class WiresharkDatagramComparer internal abstract class WiresharkDatagramComparer
{ {
public Datagram Compare(XElement layer, object datagramParent) public Datagram Compare(XElement layer, object datagramParent)
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Xml.Linq; using System.Xml.Linq;
using PcapDotNet.Packets; using PcapDotNet.Packets;
using PcapDotNet.Packets.Arp; using PcapDotNet.Packets.Arp;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class WiresharkDatagramComparerArp : WiresharkDatagramComparerSimple internal class WiresharkDatagramComparerArp : WiresharkDatagramComparerSimple
{ {
protected override string PropertyName protected override string PropertyName
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
...@@ -14,6 +15,7 @@ using PcapDotNet.TestUtils; ...@@ -14,6 +15,7 @@ using PcapDotNet.TestUtils;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class WiresharkDatagramComparerDns : WiresharkDatagramComparerSimple internal class WiresharkDatagramComparerDns : WiresharkDatagramComparerSimple
{ {
protected override string PropertyName protected override string PropertyName
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Xml.Linq; using System.Xml.Linq;
using PcapDotNet.Packets; using PcapDotNet.Packets;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class WiresharkDatagramComparerEthernet : WiresharkDatagramComparerSimple internal class WiresharkDatagramComparerEthernet : WiresharkDatagramComparerSimple
{ {
protected override string PropertyName protected override string PropertyName
......
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
...@@ -10,6 +11,7 @@ using PcapDotNet.TestUtils; ...@@ -10,6 +11,7 @@ using PcapDotNet.TestUtils;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class WiresharkDatagramComparerGre : WiresharkDatagramComparerSimple internal class WiresharkDatagramComparerGre : WiresharkDatagramComparerSimple
{ {
protected override string PropertyName protected override string PropertyName
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
...@@ -11,6 +12,7 @@ using PcapDotNet.TestUtils; ...@@ -11,6 +12,7 @@ using PcapDotNet.TestUtils;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class WiresharkDatagramComparerHttp : WiresharkDatagramComparerSimple internal class WiresharkDatagramComparerHttp : WiresharkDatagramComparerSimple
{ {
protected override string PropertyName protected override string PropertyName
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Text; using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
...@@ -9,6 +10,7 @@ using System.Linq; ...@@ -9,6 +10,7 @@ using System.Linq;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class WiresharkDatagramComparerIcmp : WiresharkDatagramComparerSimple internal class WiresharkDatagramComparerIcmp : WiresharkDatagramComparerSimple
{ {
protected override string PropertyName protected override string PropertyName
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
...@@ -8,6 +9,7 @@ using PcapDotNet.Packets.Igmp; ...@@ -8,6 +9,7 @@ using PcapDotNet.Packets.Igmp;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class WiresharkDatagramComparerIgmp : WiresharkDatagramComparerSimple internal class WiresharkDatagramComparerIgmp : WiresharkDatagramComparerSimple
{ {
protected override string PropertyName protected override string PropertyName
...@@ -21,10 +23,7 @@ namespace PcapDotNet.Core.Test ...@@ -21,10 +23,7 @@ namespace PcapDotNet.Core.Test
switch (field.Name()) switch (field.Name())
{ {
case "igmp.version": case "igmp.version":
if (field.Show() == "0") field.AssertShowDecimal(Math.Max(igmpDatagram.Version, 0));
return false; // TODO: support IGMP version 0.
field.AssertShowDecimal(igmpDatagram.Version);
break; break;
case "igmp.type": case "igmp.type":
...@@ -68,11 +67,21 @@ namespace PcapDotNet.Core.Test ...@@ -68,11 +67,21 @@ namespace PcapDotNet.Core.Test
break; break;
default: default:
if (typeof(IgmpMessageType).GetEnumValues<IgmpMessageType>().Contains(igmpDatagram.MessageType)) switch (field.Show())
throw new InvalidOperationException("Invalid message type " + igmpDatagram.MessageType); {
case "Data":
field.AssertValue(igmpDatagram.Skip(1)); if (field.Value().Length > 0)
// field.AssertShow(igmpDatagram.Skip(1)); {
// TODO: Change following https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=11582
field.AssertValue(field.Value().Length / 2 == igmpDatagram.Length - 21 ? igmpDatagram.Skip(21) : igmpDatagram.Skip(1));
}
break;
default:
if (typeof(IgmpMessageType).GetEnumValues<IgmpMessageType>().Contains(igmpDatagram.MessageType))
throw new InvalidOperationException("Invalid message type " + igmpDatagram.MessageType);
break;
}
break; break;
} }
...@@ -99,7 +108,23 @@ namespace PcapDotNet.Core.Test ...@@ -99,7 +108,23 @@ namespace PcapDotNet.Core.Test
break; break;
case "igmp.identifier": case "igmp.identifier":
// todo support IGMP version 0 and IGMP identifier. field.AssertShowDecimal(igmpDatagram.Identifier);
break;
case "igmp.access_key":
field.AssertValue(igmpDatagram.AccessKey);
break;
case "igmp.reply":
field.AssertShowDecimal((byte)igmpDatagram.ReplyCode);
break;
case "igmp.reply.pending":
field.AssertShowDecimal(igmpDatagram.RetryInThisManySeconds);
break;
case "igmp.group_type":
field.AssertShowDecimal(igmpDatagram.IsPrivate);
break; break;
case "igmp.mtrace.max_hops": case "igmp.mtrace.max_hops":
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
...@@ -10,6 +11,7 @@ using PcapDotNet.TestUtils; ...@@ -10,6 +11,7 @@ using PcapDotNet.TestUtils;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class WiresharkDatagramComparerIpV4 : WiresharkDatagramComparerSimple internal class WiresharkDatagramComparerIpV4 : WiresharkDatagramComparerSimple
{ {
protected override string PropertyName protected override string PropertyName
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
...@@ -11,6 +12,7 @@ using PcapDotNet.TestUtils; ...@@ -11,6 +12,7 @@ using PcapDotNet.TestUtils;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class WiresharkDatagramComparerIpV6 : WiresharkDatagramComparerSimple internal class WiresharkDatagramComparerIpV6 : WiresharkDatagramComparerSimple
{ {
public WiresharkDatagramComparerIpV6() public WiresharkDatagramComparerIpV6()
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Xml.Linq; using System.Xml.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets; using PcapDotNet.Packets;
...@@ -7,6 +8,7 @@ using PcapDotNet.Packets.IpV6; ...@@ -7,6 +8,7 @@ using PcapDotNet.Packets.IpV6;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class WiresharkDatagramComparerIpV6AuthenticationHeader : WiresharkDatagramComparerSimple internal class WiresharkDatagramComparerIpV6AuthenticationHeader : WiresharkDatagramComparerSimple
{ {
public WiresharkDatagramComparerIpV6AuthenticationHeader(int count) public WiresharkDatagramComparerIpV6AuthenticationHeader(int count)
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
...@@ -9,6 +10,7 @@ using PcapDotNet.Packets.IpV6; ...@@ -9,6 +10,7 @@ using PcapDotNet.Packets.IpV6;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class WiresharkDatagramComparerIpV6MobilityHeader : WiresharkDatagramComparerSimple internal class WiresharkDatagramComparerIpV6MobilityHeader : WiresharkDatagramComparerSimple
{ {
public WiresharkDatagramComparerIpV6MobilityHeader() public WiresharkDatagramComparerIpV6MobilityHeader()
......
using System.Xml.Linq; using System.Diagnostics.CodeAnalysis;
using System.Xml.Linq;
using PcapDotNet.Packets; using PcapDotNet.Packets;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal abstract class WiresharkDatagramComparerSimple : WiresharkDatagramComparer internal abstract class WiresharkDatagramComparerSimple : WiresharkDatagramComparer
{ {
protected sealed override bool CompareField(XElement field, Datagram parentDatagram, Datagram datagram) protected sealed override bool CompareField(XElement field, Datagram parentDatagram, Datagram datagram)
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
...@@ -13,6 +14,7 @@ using PcapDotNet.TestUtils; ...@@ -13,6 +14,7 @@ using PcapDotNet.TestUtils;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class WiresharkDatagramComparerTcp : WiresharkDatagramComparer internal class WiresharkDatagramComparerTcp : WiresharkDatagramComparer
{ {
protected override string PropertyName protected override string PropertyName
...@@ -28,7 +30,7 @@ namespace PcapDotNet.Core.Test ...@@ -28,7 +30,7 @@ namespace PcapDotNet.Core.Test
switch (field.Name()) switch (field.Name())
{ {
case "tcp.len": case "tcp.len":
field.AssertShowDecimal(tcpDatagram.Payload.Length); field.AssertShowDecimal(tcpDatagram.Length - tcpDatagram.HeaderLength);
field.AssertNoFields(); field.AssertNoFields();
break; break;
...@@ -266,6 +268,7 @@ namespace PcapDotNet.Core.Test ...@@ -266,6 +268,7 @@ namespace PcapDotNet.Core.Test
field.Show().StartsWith("Unknown (0x0a) ") || // Unknown in Wireshark but known (and invalid) in Pcap.Net. field.Show().StartsWith("Unknown (0x0a) ") || // Unknown in Wireshark but known (and invalid) in Pcap.Net.
field.Show().StartsWith("Unknown (0x19) ") || // Unknown in Wireshark but known (and invalid) in Pcap.Net. field.Show().StartsWith("Unknown (0x19) ") || // Unknown in Wireshark but known (and invalid) in Pcap.Net.
field.Show().StartsWith("Unknown (0x2d) ") || // Unknown in Wireshark and unknown and invalid in Pcap.Net. field.Show().StartsWith("Unknown (0x2d) ") || // Unknown in Wireshark and unknown and invalid in Pcap.Net.
field.Show().StartsWith("Unknown (0xa9) ") || // Unknown in Wireshark and unknown and invalid in Pcap.Net.
field.Show().StartsWith("Echo reply (with option length = ") || field.Show().StartsWith("Echo reply (with option length = ") ||
field.Show().Contains("bytes says option goes past end of options") || field.Show().Contains("bytes says option goes past end of options") ||
field.Show().Contains(") (with too-short option length = ") || field.Show().Contains(") (with too-short option length = ") ||
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Xml.Linq; using System.Xml.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets; using PcapDotNet.Packets;
...@@ -8,6 +9,7 @@ using PcapDotNet.Packets.Transport; ...@@ -8,6 +9,7 @@ using PcapDotNet.Packets.Transport;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class WiresharkDatagramComparerUdp : WiresharkDatagramComparer internal class WiresharkDatagramComparerUdp : WiresharkDatagramComparer
{ {
protected override string PropertyName protected override string PropertyName
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
using PcapDotNet.Packets; using PcapDotNet.Packets;
...@@ -6,6 +7,7 @@ using PcapDotNet.Packets.Ethernet; ...@@ -6,6 +7,7 @@ using PcapDotNet.Packets.Ethernet;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal class WiresharkDatagramComparerVLanTaggedFrame : WiresharkDatagramComparerSimple internal class WiresharkDatagramComparerVLanTaggedFrame : WiresharkDatagramComparerSimple
{ {
protected override string PropertyName protected override string PropertyName
......
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
public static class WiresharkStringExtensions public static class WiresharkStringExtensions
{ {
public static string ToWiresharkLiteral(this string value, bool putLeadingZerosInHexAndBackslashesBeforeSpecialCharacters = true, bool escapeSpecialChars = true) public static string ToWiresharkLiteral(this string value, bool putLeadingZerosInHexAndBackslashesBeforeSpecialCharacters = true, bool escapeSpecialChars = true)
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
...@@ -11,6 +12,7 @@ using PcapDotNet.TestUtils; ...@@ -11,6 +12,7 @@ using PcapDotNet.TestUtils;
namespace PcapDotNet.Core.Test namespace PcapDotNet.Core.Test
{ {
[ExcludeFromCodeCoverage]
internal static class XElementExtensions internal static class XElementExtensions
{ {
public static IEnumerable<XElement> Fields(this XElement element) public static IEnumerable<XElement> Fields(this XElement element)
......
...@@ -201,11 +201,11 @@ ...@@ -201,11 +201,11 @@
<RunCodeAnalysis Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</RunCodeAnalysis> <RunCodeAnalysis Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</RunCodeAnalysis>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\PcapDotNetCPP.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\PcapDotNetCPP.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" /> <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\PcapDotNet.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\PcapDotNetCPP.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" /> <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\PcapDotNet.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\PcapDotNetCPP.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" /> <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\PcapDotNet.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\PcapDotNetCPP.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" /> <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</PostBuildEventUseInBuild> <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</PostBuildEventUseInBuild>
<PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</PostBuildEventUseInBuild> <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</PostBuildEventUseInBuild>
...@@ -280,7 +280,7 @@ ...@@ -280,7 +280,7 @@
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ForcedIncludeFiles>CodeAnalysis\SourceAnnotations.h;%(ForcedIncludeFiles)</ForcedIncludeFiles> <ForcedIncludeFiles>CodeAnalysis\SourceAnnotations.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<EnablePREfast>false</EnablePREfast> <EnablePREfast>true</EnablePREfast>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>wpcap.lib</AdditionalDependencies> <AdditionalDependencies>wpcap.lib</AdditionalDependencies>
...@@ -316,7 +316,7 @@ ...@@ -316,7 +316,7 @@
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ForcedIncludeFiles>CodeAnalysis\SourceAnnotations.h;%(ForcedIncludeFiles)</ForcedIncludeFiles> <ForcedIncludeFiles>CodeAnalysis\SourceAnnotations.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<EnablePREfast>false</EnablePREfast> <EnablePREfast>true</EnablePREfast>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>wpcap.lib</AdditionalDependencies> <AdditionalDependencies>wpcap.lib</AdditionalDependencies>
...@@ -354,7 +354,7 @@ ...@@ -354,7 +354,7 @@
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ForcedIncludeFiles>CodeAnalysis\SourceAnnotations.h;%(ForcedIncludeFiles)</ForcedIncludeFiles> <ForcedIncludeFiles>CodeAnalysis\SourceAnnotations.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<EnablePREfast>false</EnablePREfast> <EnablePREfast>true</EnablePREfast>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>wpcap.lib</AdditionalDependencies> <AdditionalDependencies>wpcap.lib</AdditionalDependencies>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.Arp; using PcapDotNet.Packets.Arp;
...@@ -12,6 +13,7 @@ namespace PcapDotNet.Packets.Test ...@@ -12,6 +13,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for ArpTests /// Summary description for ArpTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class ArpTests public class ArpTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Numerics; using System.Numerics;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
...@@ -9,6 +10,7 @@ namespace PcapDotNet.Packets.Test ...@@ -9,6 +10,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for ByteArrayExtensionsTests /// Summary description for ByteArrayExtensionsTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class ByteArrayExtensionsTests public class ByteArrayExtensionsTests
{ {
/// <summary> /// <summary>
......
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PcapDotNet.Packets.Test namespace PcapDotNet.Packets.Test
...@@ -6,6 +7,7 @@ namespace PcapDotNet.Packets.Test ...@@ -6,6 +7,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for DataLinkTests /// Summary description for DataLinkTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class DataLinkTests public class DataLinkTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Base; using PcapDotNet.Base;
...@@ -15,6 +16,7 @@ namespace PcapDotNet.Packets.Test ...@@ -15,6 +16,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for DataSegmentTests. /// Summary description for DataSegmentTests.
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class DataSegmentTests public class DataSegmentTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
...@@ -14,6 +15,7 @@ namespace PcapDotNet.Packets.Test ...@@ -14,6 +15,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for DatagramTests. /// Summary description for DatagramTests.
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class DatagramTests public class DatagramTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
...@@ -18,6 +19,7 @@ namespace PcapDotNet.Packets.Test ...@@ -18,6 +19,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for DnsTests /// Summary description for DnsTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class DnsTests public class DnsTests
{ {
/// <summary> /// <summary>
......
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Base; using PcapDotNet.Base;
...@@ -7,6 +8,7 @@ namespace PcapDotNet.Packets.Test ...@@ -7,6 +8,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for EndianitiyTests /// Summary description for EndianitiyTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class EndianitiyTests public class EndianitiyTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
...@@ -13,6 +14,7 @@ namespace PcapDotNet.Packets.Test ...@@ -13,6 +14,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for EthernetTests. /// Summary description for EthernetTests.
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class EthernetTests public class EthernetTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
...@@ -15,6 +16,7 @@ namespace PcapDotNet.Packets.Test ...@@ -15,6 +16,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for GreTests /// Summary description for GreTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class GreTests public class GreTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
...@@ -19,6 +20,7 @@ namespace PcapDotNet.Packets.Test ...@@ -19,6 +20,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for HttpTests /// Summary description for HttpTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class HttpTests public class HttpTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
...@@ -14,6 +15,7 @@ namespace PcapDotNet.Packets.Test ...@@ -14,6 +15,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for IcmpTests /// Summary description for IcmpTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class IcmpTests public class IcmpTests
{ {
/// <summary> /// <summary>
...@@ -147,7 +149,8 @@ namespace PcapDotNet.Packets.Test ...@@ -147,7 +149,8 @@ namespace PcapDotNet.Packets.Test
if (actualIcmpLayer.MessageType != IcmpMessageType.RouterSolicitation) if (actualIcmpLayer.MessageType != IcmpMessageType.RouterSolicitation)
{ {
Assert.AreNotEqual(random.NextIcmpLayer(), actualIcmpLayer); Assert.AreNotEqual(random.NextIcmpLayer(), actualIcmpLayer);
Assert.AreNotEqual(random.NextIcmpLayer().GetHashCode(), actualIcmpLayer.GetHashCode()); IcmpLayer otherIcmpLayer = random.NextIcmpLayer();
Assert.AreNotEqual(otherIcmpLayer.GetHashCode(), actualIcmpLayer.GetHashCode());
} }
Assert.IsTrue(actualIcmp.IsChecksumCorrect); Assert.IsTrue(actualIcmp.IsChecksumCorrect);
Assert.AreEqual(icmpLayer.MessageType, actualIcmp.MessageType); Assert.AreEqual(icmpLayer.MessageType, actualIcmp.MessageType);
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
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;
...@@ -14,6 +16,7 @@ namespace PcapDotNet.Packets.Test ...@@ -14,6 +16,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for IgmpTests /// Summary description for IgmpTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class IgmpTests public class IgmpTests
{ {
/// <summary> /// <summary>
...@@ -100,8 +103,40 @@ namespace PcapDotNet.Packets.Test ...@@ -100,8 +103,40 @@ namespace PcapDotNet.Packets.Test
MoreAssert.IsSmallerOrEqual(IgmpDatagram.MaxMaxResponseTime, packet.Ethernet.Ip.Igmp.MaxResponseTime); MoreAssert.IsSmallerOrEqual(IgmpDatagram.MaxMaxResponseTime, packet.Ethernet.Ip.Igmp.MaxResponseTime);
if (packet.Ethernet.Ip.Igmp.MessageType != IgmpMessageType.MembershipQuery) if (packet.Ethernet.Ip.Igmp.MessageType != IgmpMessageType.MembershipQuery)
Assert.AreEqual(IgmpQueryVersion.None, packet.Ethernet.Ip.Igmp.QueryVersion); Assert.AreEqual(IgmpQueryVersion.None, packet.Ethernet.Ip.Igmp.QueryVersion);
switch (igmpLayer.MessageType) switch (igmpLayer.MessageTypeValue)
{ {
case IgmpMessageType.CreateGroupRequestVersion0:
case IgmpMessageType.CreateGroupReplyVersion0:
case IgmpMessageType.JoinGroupRequestVersion0:
case IgmpMessageType.JoinGroupReplyVersion0:
case IgmpMessageType.LeaveGroupRequestVersion0:
case IgmpMessageType.LeaveGroupReplyVersion0:
case IgmpMessageType.ConfirmGroupRequestVersion0:
case IgmpMessageType.ConfirmGroupReplyVersion0:
Assert.AreEqual(0, packet.Ethernet.Ip.Igmp.Version);
IgmpVersion0Layer igmpVersion0Layer = (IgmpVersion0Layer)igmpLayer;
Assert.AreEqual(igmpVersion0Layer.IdentifierValue, packet.Ethernet.Ip.Igmp.Identifier);
Assert.AreEqual(igmpVersion0Layer.AccessKeyValue, packet.Ethernet.Ip.Igmp.AccessKey);
switch (igmpLayer.MessageTypeValue)
{
case IgmpMessageType.CreateGroupRequestVersion0:
Assert.AreEqual(((IgmpCreateGroupRequestVersion0Layer)igmpLayer).IsPrivate, packet.Ethernet.Ip.Igmp.IsPrivate);
break;
case IgmpMessageType.CreateGroupReplyVersion0:
case IgmpMessageType.JoinGroupReplyVersion0:
case IgmpMessageType.LeaveGroupReplyVersion0:
case IgmpMessageType.ConfirmGroupReplyVersion0:
IgmpReplyVersion0Layer igmpReplyVersion0Layer = (IgmpReplyVersion0Layer)igmpVersion0Layer;
Assert.AreEqual(igmpReplyVersion0Layer.Code, packet.Ethernet.Ip.Igmp.ReplyCode);
if (packet.Ethernet.Ip.Igmp.ReplyCode == IgmpVersion0ReplyCode.RequestPendingRetryInThisManySeconds)
Assert.AreEqual(igmpReplyVersion0Layer.RetryInThisManySeconds, packet.Ethernet.Ip.Igmp.RetryInThisManySeconds);
break;
}
break;
case IgmpMessageType.MembershipQuery: case IgmpMessageType.MembershipQuery:
switch (igmpLayer.QueryVersion) switch (igmpLayer.QueryVersion)
{ {
...@@ -137,7 +172,7 @@ namespace PcapDotNet.Packets.Test ...@@ -137,7 +172,7 @@ namespace PcapDotNet.Packets.Test
break; break;
default: default:
Assert.Fail(igmpLayer.MessageType.ToString()); Assert.Fail(igmpLayer.MessageTypeValue.ToString());
break; break;
} }
foreach (IgmpGroupRecordDatagram groupRecord in packet.Ethernet.Ip.Igmp.GroupRecords) foreach (IgmpGroupRecordDatagram groupRecord in packet.Ethernet.Ip.Igmp.GroupRecords)
...@@ -358,7 +393,6 @@ namespace PcapDotNet.Packets.Test ...@@ -358,7 +393,6 @@ namespace PcapDotNet.Packets.Test
} }
[TestMethod] [TestMethod]
[ExpectedException(typeof(InvalidOperationException), AllowDerivedTypes = false)]
public void IgmpIllegalReportVersionTest() public void IgmpIllegalReportVersionTest()
{ {
Packet packet = PacketBuilder.Build(DateTime.Now, new EthernetLayer(), new IpV4Layer(), new IgmpReportVersion1Layer()); Packet packet = PacketBuilder.Build(DateTime.Now, new EthernetLayer(), new IpV4Layer(), new IgmpReportVersion1Layer());
...@@ -371,8 +405,7 @@ namespace PcapDotNet.Packets.Test ...@@ -371,8 +405,7 @@ namespace PcapDotNet.Packets.Test
buffer.Write(EthernetDatagram.HeaderLengthValue + IpV4Datagram.HeaderMinimumLength, 0); buffer.Write(EthernetDatagram.HeaderLengthValue + IpV4Datagram.HeaderMinimumLength, 0);
Packet illegalPacket = new Packet(buffer, packet.Timestamp, packet.DataLink); Packet illegalPacket = new Packet(buffer, packet.Timestamp, packet.DataLink);
Assert.IsFalse(illegalPacket.IsValid); Assert.IsFalse(illegalPacket.IsValid);
Assert.IsNull(illegalPacket.Ethernet.IpV4.Igmp.Version); Assert.AreEqual(-1, illegalPacket.Ethernet.IpV4.Igmp.Version);
Assert.Fail();
} }
[TestMethod] [TestMethod]
...@@ -445,11 +478,11 @@ namespace PcapDotNet.Packets.Test ...@@ -445,11 +478,11 @@ namespace PcapDotNet.Packets.Test
[TestMethod] [TestMethod]
public void DifferentIgmpSimpleLayersTest() public void DifferentIgmpSimpleLayersTest()
{ {
IgmpSimpleLayer layer1 = new IgmpQueryVersion1Layer IgmpVersion1PlusSimpleLayer layer1 = new IgmpQueryVersion1Layer
{ {
GroupAddress = new IpV4Address("1.2.3.4") GroupAddress = new IpV4Address("1.2.3.4")
}; };
IgmpSimpleLayer layer2 = new IgmpQueryVersion2Layer IgmpVersion1PlusSimpleLayer layer2 = new IgmpQueryVersion2Layer
{ {
GroupAddress = new IpV4Address("1.2.3.4"), GroupAddress = new IpV4Address("1.2.3.4"),
MaxResponseTime = TimeSpan.FromMinutes(55) MaxResponseTime = TimeSpan.FromMinutes(55)
...@@ -464,5 +497,61 @@ namespace PcapDotNet.Packets.Test ...@@ -464,5 +497,61 @@ namespace PcapDotNet.Packets.Test
Assert.IsNotNull(new IgmpGroupRecord(IgmpRecordType.FilterModeChangeToExclude, IpV4Address.Zero, new IpV4Address[0], null)); Assert.IsNotNull(new IgmpGroupRecord(IgmpRecordType.FilterModeChangeToExclude, IpV4Address.Zero, new IpV4Address[0], null));
Assert.Fail(); Assert.Fail();
} }
[TestMethod]
public void IgmpTooLong()
{
Packet packet = PacketBuilder.Build(DateTime.Now, new EthernetLayer(), new IpV4Layer(), new IgmpQueryVersion1Layer());
Assert.IsTrue(packet.IsValid);
byte[] invalidPacketBuffer = packet.Buffer.ToArray();
invalidPacketBuffer[EthernetDatagram.HeaderLengthValue + IpV4Datagram.HeaderMinimumLength] = (byte)IgmpMessageType.MulticastTraceRoute;
const ushort newCheckSum = 57599;
invalidPacketBuffer[EthernetDatagram.HeaderLengthValue + IpV4Datagram.HeaderMinimumLength + sizeof(ushort)] = newCheckSum >> 8;
invalidPacketBuffer[EthernetDatagram.HeaderLengthValue + IpV4Datagram.HeaderMinimumLength + sizeof(ushort) + sizeof(byte)] = newCheckSum & 0xFF;
Packet invalidPacket = new Packet(invalidPacketBuffer, DateTime.Now, DataLinkKind.Ethernet);
Assert.IsFalse(invalidPacket.IsValid);
}
[TestMethod]
[ExpectedException(typeof(InvalidOperationException), AllowDerivedTypes = false)]
public void IgmpDatagramIsPrivateForNotCreateGroupRequestVersion0()
{
Packet packet = PacketBuilder.Build(DateTime.Now, new EthernetLayer(), new IpV4Layer(), new IgmpQueryVersion1Layer());
Assert.IsTrue(packet.IsValid);
Assert.IsFalse(packet.Ethernet.IpV4.Igmp.IsPrivate);
}
[TestMethod]
[ExpectedException(typeof(InvalidOperationException), AllowDerivedTypes = false)]
public void IgmpDatagramReplyCodeVersion0Reply()
{
Packet packet = PacketBuilder.Build(DateTime.Now, new EthernetLayer(), new IpV4Layer(), new IgmpQueryVersion1Layer());
Assert.IsTrue(packet.IsValid);
Assert.IsNotNull(packet.Ethernet.IpV4.Igmp.ReplyCode);
}
[TestMethod]
[ExpectedException(typeof(InvalidOperationException), AllowDerivedTypes = false)]
public void IgmpDatagramRetryInThisManySecondsForReplyCodeThatIsNotRequestPendingRetryInThisManySeconds()
{
Packet packet = PacketBuilder.Build(DateTime.Now, new EthernetLayer(), new IpV4Layer(), new IgmpReplyVersion0Layer());
Assert.IsTrue(packet.IsValid);
Assert.IsNotNull(packet.Ethernet.IpV4.Igmp.RetryInThisManySeconds);
}
[TestMethod]
[ExpectedException(typeof(ArgumentOutOfRangeException), AllowDerivedTypes = false)]
public void IgmpReplyVersion0LayerSetInvalidType()
{
Assert.IsNotNull(new IgmpReplyVersion0Layer {MessageType = IgmpMessageType.LeaveGroupVersion2});
}
[TestMethod]
[ExpectedException(typeof(ArgumentOutOfRangeException), AllowDerivedTypes = false)]
public void IgmpRequestVersion0LayerSetInvalidType()
{
Assert.IsNotNull(new IgmpRequestVersion0Layer { MessageType = IgmpMessageType.LeaveGroupVersion2 });
}
} }
} }
\ No newline at end of file
using System; using System;
using System.Diagnostics.CodeAnalysis;
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;
...@@ -9,6 +10,7 @@ namespace PcapDotNet.Packets.Test ...@@ -9,6 +10,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for IpV4AddressTests /// Summary description for IpV4AddressTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class IpV4AddressTests public class IpV4AddressTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
...@@ -15,6 +16,7 @@ namespace PcapDotNet.Packets.Test ...@@ -15,6 +16,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for IpV4Tests /// Summary description for IpV4Tests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class IpV4Tests public class IpV4Tests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.IpV6; using PcapDotNet.Packets.IpV6;
using PcapDotNet.Packets.TestUtils; using PcapDotNet.Packets.TestUtils;
...@@ -9,6 +10,7 @@ namespace PcapDotNet.Packets.Test ...@@ -9,6 +10,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for IpV6AddressTests /// Summary description for IpV6AddressTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class IpV6AddressTests public class IpV6AddressTests
{ {
/// <summary> /// <summary>
......
...@@ -2,6 +2,7 @@ using System; ...@@ -2,6 +2,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Base; using PcapDotNet.Base;
...@@ -18,6 +19,7 @@ namespace PcapDotNet.Packets.Test ...@@ -18,6 +19,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for IpV6Tests /// Summary description for IpV6Tests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class IpV6Tests public class IpV6Tests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.TestUtils; using PcapDotNet.Packets.TestUtils;
...@@ -9,6 +10,7 @@ namespace PcapDotNet.Packets.Test ...@@ -9,6 +10,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for MacAddressTests /// Summary description for MacAddressTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class MacAddressTests public class MacAddressTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.Transport; using PcapDotNet.Packets.Transport;
...@@ -8,6 +9,7 @@ namespace PcapDotNet.Packets.Test ...@@ -8,6 +9,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for PacketBuilderTests /// Summary description for PacketBuilderTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class PacketBuilderTests public class PacketBuilderTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
...@@ -12,6 +13,7 @@ namespace PcapDotNet.Packets.Test ...@@ -12,6 +13,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for PacketTests /// Summary description for PacketTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class PacketTests public class PacketTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Base; using PcapDotNet.Base;
...@@ -10,6 +11,7 @@ namespace PcapDotNet.Packets.Test ...@@ -10,6 +11,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for PayloadLayerTests /// Summary description for PayloadLayerTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class PayloadLayerTests public class PayloadLayerTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.IpV6; using PcapDotNet.Packets.IpV6;
using PcapDotNet.Packets.TestUtils; using PcapDotNet.Packets.TestUtils;
...@@ -9,6 +10,7 @@ namespace PcapDotNet.Packets.Test ...@@ -9,6 +10,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for PppFrameCheckSequenceCalculatorTests /// Summary description for PppFrameCheckSequenceCalculatorTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class PppFrameCheckSequenceCalculatorTests public class PppFrameCheckSequenceCalculatorTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
...@@ -14,6 +15,7 @@ namespace PcapDotNet.Packets.Test ...@@ -14,6 +15,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for TcpTests /// Summary description for TcpTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class TcpTests public class TcpTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
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;
...@@ -13,6 +14,7 @@ namespace PcapDotNet.Packets.Test ...@@ -13,6 +14,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for UdpTests /// Summary description for UdpTests
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class UdpTests public class UdpTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
...@@ -12,6 +13,7 @@ namespace PcapDotNet.Packets.Test ...@@ -12,6 +13,7 @@ namespace PcapDotNet.Packets.Test
/// Summary description for VLanTaggedFrameTests. /// Summary description for VLanTaggedFrameTests.
/// </summary> /// </summary>
[TestClass] [TestClass]
[ExcludeFromCodeCoverage]
public class VLanTaggedFrameTests public class VLanTaggedFrameTests
{ {
/// <summary> /// <summary>
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using PcapDotNet.Base; using PcapDotNet.Base;
namespace PcapDotNet.Packets.TestUtils namespace PcapDotNet.Packets.TestUtils
{ {
[ExcludeFromCodeCoverage]
public sealed class HexEncoding : Encoding public sealed class HexEncoding : Encoding
{ {
public static HexEncoding Instance { get { return _instance; } } public static HexEncoding Instance { get { return _instance; } }
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.Arp; using PcapDotNet.Packets.Arp;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
...@@ -6,6 +7,7 @@ using PcapDotNet.TestUtils; ...@@ -6,6 +7,7 @@ using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.TestUtils namespace PcapDotNet.Packets.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class RandomArpExtensions public static class RandomArpExtensions
{ {
public static ArpLayer NextArpLayer(this Random random) public static ArpLayer NextArpLayer(this Random random)
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using PcapDotNet.Base; using PcapDotNet.Base;
...@@ -10,6 +11,7 @@ using PcapDotNet.TestUtils; ...@@ -10,6 +11,7 @@ using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.TestUtils namespace PcapDotNet.Packets.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class RandomDnsExtensions public static class RandomDnsExtensions
{ {
public static DnsLayer NextDnsLayer(this Random random) public static DnsLayer NextDnsLayer(this Random random)
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.TestUtils namespace PcapDotNet.Packets.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class RandomEthernetExtensions public static class RandomEthernetExtensions
{ {
public static EthernetLayer NextEthernetLayer(this Random random, EthernetType etherType) public static EthernetLayer NextEthernetLayer(this Random random, EthernetType etherType)
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
...@@ -8,6 +9,7 @@ using PcapDotNet.TestUtils; ...@@ -8,6 +9,7 @@ using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.TestUtils namespace PcapDotNet.Packets.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class RandomGreExtensions public static class RandomGreExtensions
{ {
public static GreLayer NextGreLayer(this Random random) public static GreLayer NextGreLayer(this Random random)
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using PcapDotNet.Base; using PcapDotNet.Base;
...@@ -8,6 +9,7 @@ using PcapDotNet.TestUtils; ...@@ -8,6 +9,7 @@ using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.TestUtils namespace PcapDotNet.Packets.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class RandomHttpExtensions public static class RandomHttpExtensions
{ {
public static HttpLayer NextHttpLayer(this Random random) public static HttpLayer NextHttpLayer(this Random random)
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using PcapDotNet.Packets.Icmp; using PcapDotNet.Packets.Icmp;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
...@@ -8,6 +9,7 @@ using IEnumerableExtensions = PcapDotNet.Base.IEnumerableExtensions; ...@@ -8,6 +9,7 @@ using IEnumerableExtensions = PcapDotNet.Base.IEnumerableExtensions;
namespace PcapDotNet.Packets.TestUtils namespace PcapDotNet.Packets.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class RandomIcmpExtensions public static class RandomIcmpExtensions
{ {
public static IcmpLayer NextIcmpLayer(this Random random) public static IcmpLayer NextIcmpLayer(this Random random)
...@@ -22,7 +24,8 @@ namespace PcapDotNet.Packets.TestUtils ...@@ -22,7 +24,8 @@ namespace PcapDotNet.Packets.TestUtils
{ {
Code = random.NextEnum<IcmpCodeDestinationUnreachable>(), Code = random.NextEnum<IcmpCodeDestinationUnreachable>(),
Checksum = checksum, Checksum = checksum,
NextHopMaximumTransmissionUnit = random.NextUShort(), NextHopMaximumTransmissionUnit =
random.NextUShort(IcmpDestinationUnreachableDatagram.MinimumMaximumTransmissionUnit, ushort.MaxValue),
}; };
case IcmpMessageType.TimeExceeded: case IcmpMessageType.TimeExceeded:
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.Igmp; using PcapDotNet.Packets.Igmp;
...@@ -7,6 +8,7 @@ using PcapDotNet.TestUtils; ...@@ -7,6 +8,7 @@ using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.TestUtils namespace PcapDotNet.Packets.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class RandomIgmpExtensions public static class RandomIgmpExtensions
{ {
public static IgmpGroupRecord NextIgmpGroupRecord(this Random random) public static IgmpGroupRecord NextIgmpGroupRecord(this Random random)
...@@ -22,25 +24,56 @@ namespace PcapDotNet.Packets.TestUtils ...@@ -22,25 +24,56 @@ namespace PcapDotNet.Packets.TestUtils
public static IgmpLayer NextIgmpLayer(this Random random) public static IgmpLayer NextIgmpLayer(this Random random)
{ {
IgmpMessageType igmpMessageType = random.NextEnum(IgmpMessageType.None, IgmpMessageType.CreateGroupRequestVersion0, IgmpMessageType igmpMessageType = random.NextEnum(IgmpMessageType.None,
IgmpMessageType.CreateGroupReplyVersion0, IgmpMessageType.JoinGroupRequestVersion0,
IgmpMessageType.JoinGroupReplyVersion0, IgmpMessageType.LeaveGroupRequestVersion0,
IgmpMessageType.LeaveGroupReplyVersion0, IgmpMessageType.ConfirmGroupRequestVersion0,
IgmpMessageType.ConfirmGroupReplyVersion0,
IgmpMessageType.MulticastTraceRouteResponse, IgmpMessageType.MulticastTraceRoute); // todo support IGMP traceroute http://www.ietf.org/proceedings/48/I-D/idmr-traceroute-ipm-07.txt. IgmpMessageType.MulticastTraceRouteResponse, IgmpMessageType.MulticastTraceRoute); // todo support IGMP traceroute http://www.ietf.org/proceedings/48/I-D/idmr-traceroute-ipm-07.txt.
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; ulong accessKey = random.NextULong();
byte? igmpQueryRobustnessVariable; uint identifier = random.NextUInt();
TimeSpan? igmpQueryInterval;
IpV4Address[] igmpSourceAddresses;
IgmpGroupRecord[] igmpGroupRecords;
switch (igmpMessageType) switch (igmpMessageType)
{ {
case IgmpMessageType.CreateGroupRequestVersion0:
return new IgmpCreateGroupRequestVersion0Layer
{
IsPrivate = random.NextBool(),
Identifier = identifier,
};
case IgmpMessageType.CreateGroupReplyVersion0:
case IgmpMessageType.JoinGroupReplyVersion0:
case IgmpMessageType.LeaveGroupReplyVersion0:
case IgmpMessageType.ConfirmGroupReplyVersion0:
IgmpVersion0ReplyCode code = random.NextEnum<IgmpVersion0ReplyCode>();
return new IgmpReplyVersion0Layer
{
MessageType = igmpMessageType,
Code = code,
RetryInThisManySeconds = (byte)(code == IgmpVersion0ReplyCode.RequestPendingRetryInThisManySeconds? random.NextByte((byte)IgmpVersion0ReplyCode.RequestPendingRetryInThisManySeconds, byte.MaxValue) : 0),
Identifier = identifier,
GroupAddress = igmpGroupAddress,
AccessKey = accessKey,
};
case IgmpMessageType.JoinGroupRequestVersion0:
case IgmpMessageType.LeaveGroupRequestVersion0:
return new IgmpRequestVersion0Layer
{
MessageType = igmpMessageType,
Identifier = identifier,
GroupAddress = igmpGroupAddress,
AccessKey = accessKey,
};
case IgmpMessageType.ConfirmGroupRequestVersion0:
return new IgmpConfirmGroupRequestVersion0Layer
{
GroupAddress = igmpGroupAddress,
AccessKey = accessKey,
};
case IgmpMessageType.MembershipQuery: case IgmpMessageType.MembershipQuery:
igmpQueryVersion = random.NextEnum(IgmpQueryVersion.None, IgmpQueryVersion.Unknown); IgmpQueryVersion igmpQueryVersion = random.NextEnum(IgmpQueryVersion.None, IgmpQueryVersion.Unknown);
switch (igmpQueryVersion) switch (igmpQueryVersion)
{ {
case IgmpQueryVersion.Version1: case IgmpQueryVersion.Version1:
...@@ -57,20 +90,20 @@ namespace PcapDotNet.Packets.TestUtils ...@@ -57,20 +90,20 @@ namespace PcapDotNet.Packets.TestUtils
}; };
case IgmpQueryVersion.Version3: case IgmpQueryVersion.Version3:
igmpIsSuppressRouterSideProcessing = random.NextBool(); bool igmpIsSuppressRouterSideProcessing = random.NextBool();
igmpQueryRobustnessVariable = random.NextByte(8); byte igmpQueryRobustnessVariable = random.NextByte(8);
igmpMaxResponseTime = random.NextTimeSpan(TimeSpan.FromSeconds(0.1), igmpMaxResponseTime = random.NextTimeSpan(TimeSpan.FromSeconds(0.1),
IgmpDatagram.MaxVersion3MaxResponseTime - TimeSpan.FromTicks(1)); IgmpDatagram.MaxVersion3MaxResponseTime - TimeSpan.FromTicks(1));
igmpQueryInterval = random.NextTimeSpan(TimeSpan.Zero, IgmpDatagram.MaxQueryInterval - TimeSpan.FromTicks(1)); TimeSpan igmpQueryInterval = random.NextTimeSpan(TimeSpan.Zero, IgmpDatagram.MaxQueryInterval - TimeSpan.FromTicks(1));
igmpSourceAddresses = random.NextIpV4Addresses(random.Next(1000)); IpV4Address[] igmpSourceAddresses = random.NextIpV4Addresses(random.Next(1000));
return new IgmpQueryVersion3Layer return new IgmpQueryVersion3Layer
{ {
SourceAddresses = igmpSourceAddresses.AsReadOnly(), SourceAddresses = igmpSourceAddresses.AsReadOnly(),
MaxResponseTime = igmpMaxResponseTime, MaxResponseTime = igmpMaxResponseTime,
GroupAddress = igmpGroupAddress, GroupAddress = igmpGroupAddress,
IsSuppressRouterSideProcessing = igmpIsSuppressRouterSideProcessing.Value, IsSuppressRouterSideProcessing = igmpIsSuppressRouterSideProcessing,
QueryRobustnessVariable = igmpQueryRobustnessVariable.Value, QueryRobustnessVariable = igmpQueryRobustnessVariable,
QueryInterval = igmpQueryInterval.Value, QueryInterval = igmpQueryInterval,
}; };
default: default:
...@@ -98,8 +131,8 @@ namespace PcapDotNet.Packets.TestUtils ...@@ -98,8 +131,8 @@ namespace PcapDotNet.Packets.TestUtils
}; };
case IgmpMessageType.MembershipReportVersion3: case IgmpMessageType.MembershipReportVersion3:
igmpGroupRecords = random.NextIgmpGroupRecords(random.Next(100)); IgmpGroupRecord[] igmpGroupRecords = random.NextIgmpGroupRecords(random.Next(100));
if (igmpGroupRecords.Count() == 0 && random.NextBool()) if (!igmpGroupRecords.Any() && random.NextBool())
return new IgmpReportVersion3Layer(); return new IgmpReportVersion3Layer();
return new IgmpReportVersion3Layer return new IgmpReportVersion3Layer
{ {
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.TestUtils namespace PcapDotNet.Packets.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class RandomIpV4Extensions public static class RandomIpV4Extensions
{ {
public static IpV4Layer NextIpV4Layer(this Random random, IpV4Protocol? protocol) public static IpV4Layer NextIpV4Layer(this Random random, IpV4Protocol? protocol)
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.Ip; using PcapDotNet.Packets.Ip;
...@@ -9,6 +10,7 @@ using PcapDotNet.TestUtils; ...@@ -9,6 +10,7 @@ using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.TestUtils namespace PcapDotNet.Packets.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class RandomIpV6Extensions public static class RandomIpV6Extensions
{ {
public static IpV6Address NextIpV6Address(this Random random) public static IpV6Address NextIpV6Address(this Random random)
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.TestUtils namespace PcapDotNet.Packets.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class RandomPacketsExtensions public static class RandomPacketsExtensions
{ {
public static Datagram NextDatagram(this Random random, int length) public static Datagram NextDatagram(this Random random, int length)
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using PcapDotNet.Packets.Transport; using PcapDotNet.Packets.Transport;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.TestUtils namespace PcapDotNet.Packets.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class RandomTcpExtensions public static class RandomTcpExtensions
{ {
public static TcpLayer NextTcpLayer(this Random random) public static TcpLayer NextTcpLayer(this Random random)
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using PcapDotNet.Packets.Transport; using PcapDotNet.Packets.Transport;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.TestUtils namespace PcapDotNet.Packets.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class RandomUdpExtensions public static class RandomUdpExtensions
{ {
public static UdpLayer NextUdpLayer(this Random random) public static UdpLayer NextUdpLayer(this Random random)
......
using System; using System;
using System.Diagnostics.CodeAnalysis;
using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Ethernet;
using PcapDotNet.TestUtils; using PcapDotNet.TestUtils;
namespace PcapDotNet.Packets.TestUtils namespace PcapDotNet.Packets.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class RandomVLanTaggedFrameExtensions public static class RandomVLanTaggedFrameExtensions
{ {
public static VLanTaggedFrameLayer NextVLanTaggedFrameLayer(this Random random, EthernetType etherType) public static VLanTaggedFrameLayer NextVLanTaggedFrameLayer(this Random random, EthernetType etherType)
......
...@@ -134,7 +134,7 @@ namespace PcapDotNet.Packets.Icmp ...@@ -134,7 +134,7 @@ namespace PcapDotNet.Packets.Icmp
public sealed override int GetHashCode() public sealed override int GetHashCode()
{ {
return base.GetHashCode() ^ return base.GetHashCode() ^
Sequence.GetHashCode(MessageTypeAndCode, Variable) ^ Checksum.GetHashCode(); Sequence.GetHashCode(BitSequence.Merge((ushort)MessageTypeAndCode, Checksum ?? 0), Variable);
} }
/// <summary> /// <summary>
......
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Igmp
{
/// <summary>
/// RFC 988.
/// </summary>
public sealed class IgmpConfirmGroupRequestVersion0Layer : IgmpVersion0Layer
{
/// <summary>
/// The type of the IGMP message of concern to the host-router interaction.
/// </summary>
public override IgmpMessageType MessageTypeValue
{
get { return IgmpMessageType.ConfirmGroupRequestVersion0; }
}
/// <summary>
/// Zero.
/// </summary>
public override uint IdentifierValue
{
get { return 0; }
}
/// <summary>
/// Contains a host group address.
/// </summary>
public IpV4Address GroupAddress { get; set; }
/// <summary>
/// Contains the access key assigned to the host group identified in the Group Address field (zero for public groups).
/// </summary>
public ulong AccessKey { get; set; }
/// <summary>
/// Contains the access key assigned to the host group identified in the Group Address field (zero for public groups).
/// </summary>
public override ulong AccessKeyValue
{
get { return AccessKey; }
}
internal override byte CodeValue
{
get { return 0; }
}
internal override IpV4Address GroupAddressValue
{
get { return GroupAddress; }
}
}
}
\ No newline at end of file
using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Igmp
{
/// <summary>
/// RFC 988.
/// </summary>
public sealed class IgmpCreateGroupRequestVersion0Layer : IgmpVersion0Layer
{
/// <summary>
/// The type of the IGMP message of concern to the host-router interaction.
/// </summary>
public override IgmpMessageType MessageTypeValue
{
get { return IgmpMessageType.CreateGroupRequestVersion0; }
}
/// <summary>
/// Indicates if the new host group is to be private or public.
/// </summary>
public bool IsPrivate { get; set; }
/// <summary>
/// Contains a value to distinguish the request from other requests by the same host.
/// </summary>
public uint Identifier { get; set; }
/// <summary>
/// Contains a value to distinguish the request from other requests by the same host.
/// </summary>
public override uint IdentifierValue
{
get { return Identifier; }
}
/// <summary>
/// Zero.
/// </summary>
public override ulong AccessKeyValue
{
get { return 0; }
}
internal override byte CodeValue
{
get { return IsPrivate.ToByte(); }
}
internal override IpV4Address GroupAddressValue
{
get { return IpV4Address.Zero; }
}
}
}
\ No newline at end of file
using System;
using PcapDotNet.Base; using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4; using PcapDotNet.Packets.IpV4;
...@@ -13,7 +12,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -13,7 +12,7 @@ namespace PcapDotNet.Packets.Igmp
/// <summary> /// <summary>
/// The type of the IGMP message of concern to the host-router interaction. /// The type of the IGMP message of concern to the host-router interaction.
/// </summary> /// </summary>
public abstract IgmpMessageType MessageType { get; } public abstract IgmpMessageType MessageTypeValue { get; }
/// <summary> /// <summary>
/// The IGMP version of a Membership Query message. /// The IGMP version of a Membership Query message.
...@@ -24,10 +23,6 @@ namespace PcapDotNet.Packets.Igmp ...@@ -24,10 +23,6 @@ namespace PcapDotNet.Packets.Igmp
get { return IgmpQueryVersion.None; } get { return IgmpQueryVersion.None; }
} }
/// <summary>
/// The actual time allowed, called the Max Resp Time.
/// </summary>
public abstract TimeSpan MaxResponseTimeValue { get; }
/// <summary> /// <summary>
/// The protocol that should be written in the previous (IPv4) layer. /// The protocol that should be written in the previous (IPv4) layer.
...@@ -43,10 +38,9 @@ namespace PcapDotNet.Packets.Igmp ...@@ -43,10 +38,9 @@ namespace PcapDotNet.Packets.Igmp
public bool Equals(IgmpLayer other) public bool Equals(IgmpLayer other)
{ {
return other != null && return other != null &&
MessageType == other.MessageType && MessageTypeValue == other.MessageTypeValue &&
QueryVersion == other.QueryVersion && QueryVersion == other.QueryVersion &&
EqualMaxResponseTime(MaxResponseTimeValue, other.MaxResponseTimeValue) && EqualsVersionSpecific(other);
EqualFields(other);
} }
/// <summary> /// <summary>
...@@ -63,17 +57,12 @@ namespace PcapDotNet.Packets.Igmp ...@@ -63,17 +57,12 @@ namespace PcapDotNet.Packets.Igmp
public override int GetHashCode() public override int GetHashCode()
{ {
return base.GetHashCode() ^ return base.GetHashCode() ^
Sequence.GetHashCode(MessageType, QueryVersion); Sequence.GetHashCode(MessageTypeValue, QueryVersion);
} }
/// <summary> /// <summary>
/// true iff the fields that are not mutual to all IGMP layers are equal. /// true iff the fields that are not mutual to all IGMP layers are equal.
/// </summary> /// </summary>
protected abstract bool EqualFields(IgmpLayer other); protected abstract bool EqualsVersionSpecific(IgmpLayer other);
private static bool EqualMaxResponseTime(TimeSpan value1, TimeSpan value2)
{
return value1.Divide(2) <= value2 && value1.Multiply(2) >= value2;
}
} }
} }
\ No newline at end of file
...@@ -8,7 +8,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -8,7 +8,7 @@ namespace PcapDotNet.Packets.Igmp
/// <summary> /// <summary>
/// The type of the IGMP message of concern to the host-router interaction. /// The type of the IGMP message of concern to the host-router interaction.
/// </summary> /// </summary>
public override IgmpMessageType MessageType public override IgmpMessageType MessageTypeValue
{ {
get { return IgmpMessageType.LeaveGroupVersion2; } get { return IgmpMessageType.LeaveGroupVersion2; }
} }
......
using System.Runtime.InteropServices;
namespace PcapDotNet.Packets.Igmp namespace PcapDotNet.Packets.Igmp
{ {
/// <summary> /// <summary>
...@@ -8,7 +10,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -8,7 +10,7 @@ namespace PcapDotNet.Packets.Igmp
/// <summary> /// <summary>
/// The type of the IGMP message of concern to the host-router interaction. /// The type of the IGMP message of concern to the host-router interaction.
/// </summary> /// </summary>
public override IgmpMessageType MessageType public override IgmpMessageType MessageTypeValue
{ {
get { return IgmpMessageType.MembershipQuery; } get { return IgmpMessageType.MembershipQuery; }
} }
......
...@@ -8,7 +8,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -8,7 +8,7 @@ namespace PcapDotNet.Packets.Igmp
/// <summary> /// <summary>
/// The type of the IGMP message of concern to the host-router interaction. /// The type of the IGMP message of concern to the host-router interaction.
/// </summary> /// </summary>
public override IgmpMessageType MessageType public override IgmpMessageType MessageTypeValue
{ {
get { return IgmpMessageType.MembershipQuery; } get { return IgmpMessageType.MembershipQuery; }
} }
......
...@@ -11,7 +11,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -11,7 +11,7 @@ namespace PcapDotNet.Packets.Igmp
/// Represents an IGMP Query version 3 layer. /// Represents an IGMP Query version 3 layer.
/// <seealso cref="IgmpDatagram"/> /// <seealso cref="IgmpDatagram"/>
/// </summary> /// </summary>
public sealed class IgmpQueryVersion3Layer : IgmpLayer, IIgmpLayerWithGroupAddress public sealed class IgmpQueryVersion3Layer : IgmpVersion1PlusLayer, IIgmpLayerWithGroupAddress
{ {
/// <summary> /// <summary>
/// Creates an instance of an IGMP Query Version 3 layer. /// Creates an instance of an IGMP Query Version 3 layer.
...@@ -85,7 +85,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -85,7 +85,7 @@ namespace PcapDotNet.Packets.Igmp
/// <summary> /// <summary>
/// The type of the IGMP message of concern to the host-router interaction. /// The type of the IGMP message of concern to the host-router interaction.
/// </summary> /// </summary>
public override IgmpMessageType MessageType public override IgmpMessageType MessageTypeValue
{ {
get { return IgmpMessageType.MembershipQuery; } get { return IgmpMessageType.MembershipQuery; }
} }
...@@ -122,7 +122,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -122,7 +122,7 @@ namespace PcapDotNet.Packets.Igmp
/// true iff the GroupAddress, IsSuppressRouterSideProcessing, QueryRobustnessVariable and SourceAddresses fields are equal /// true iff the GroupAddress, IsSuppressRouterSideProcessing, QueryRobustnessVariable and SourceAddresses fields are equal
/// and the QueryInterval is similar. /// and the QueryInterval is similar.
/// </summary> /// </summary>
protected override bool EqualFields(IgmpLayer other) protected override bool EqualFields(IgmpVersion1PlusLayer other)
{ {
return EqualFields(other as IgmpQueryVersion3Layer); return EqualFields(other as IgmpQueryVersion3Layer);
} }
......
using System;
using System.Globalization;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Igmp
{
/// <summary>
/// RFC 988.
/// </summary>
public sealed class IgmpReplyVersion0Layer : IgmpVersion0Layer
{
/// <summary>
/// The type of the IGMP message of concern to the host-router interaction.
/// </summary>
public override IgmpMessageType MessageTypeValue
{
get { return MessageType; }
}
/// <summary>
/// The type of the IGMP message of concern to the host-router interaction.
/// Either CreateGroupReplyVersion0, JoinGroupReplyVersion0, LeaveGroupReplyVersion0 or ConfirmGroupReplyVersion0.
/// </summary>
public IgmpMessageType MessageType
{
get { return _messageType; }
set
{
switch (value)
{
case IgmpMessageType.CreateGroupReplyVersion0:
case IgmpMessageType.JoinGroupReplyVersion0:
case IgmpMessageType.LeaveGroupReplyVersion0:
case IgmpMessageType.ConfirmGroupReplyVersion0:
_messageType = value;
break;
default:
throw new ArgumentOutOfRangeException("value", value, string.Format(CultureInfo.InvariantCulture, "Do not use {0} for {1}", GetType(), value));
}
}
}
/// <summary>
/// Specifies the outcome of the request.
/// </summary>
public IgmpVersion0ReplyCode Code { get; set; }
/// <summary>
/// When Code = RequestPendingRetryInThisManySeconds, specifies the amount of seconds to retry in.
/// </summary>
public byte RetryInThisManySeconds { get; set; }
/// <summary>
/// Contains the same value as in the corresponding Request message.
/// </summary>
public uint Identifier { get; set; }
/// <summary>
/// Contains the same value as in the corresponding Request message.
/// </summary>
public override uint IdentifierValue
{
get { return Identifier; }
}
/// <summary>
/// In a Create Group Reply message, the group address field contains either a newly allocated host group address (if the request is granted)
/// or zero (if denied).
/// In all other Reply messages, the group address field contains the same host group address as in the corresponding Request message.
/// </summary>
public IpV4Address GroupAddress { get; set; }
/// <summary>
/// In a Create Group Reply message, the access key field contains either a non-zero 64-bit number (if the request for a private group is granted)
/// or zero.
/// In all other Reply messages, the access key field contains the same access key as in the corresponding Request.
/// </summary>
public ulong AccessKey { get; set; }
/// <summary>
/// In a Create Group Reply message, the access key field contains either a non-zero 64-bit number (if the request for a private group is granted)
/// or zero.
/// In all other Reply messages, the access key field contains the same access key as in the corresponding Request.
/// </summary>
public override ulong AccessKeyValue
{
get { return AccessKey; }
}
internal override byte CodeValue
{
get { return Code == IgmpVersion0ReplyCode.RequestPendingRetryInThisManySeconds ? RetryInThisManySeconds : (byte)Code; }
}
internal override IpV4Address GroupAddressValue
{
get { return GroupAddress; }
}
private IgmpMessageType _messageType = IgmpMessageType.CreateGroupReplyVersion0;
}
}
\ No newline at end of file
...@@ -8,7 +8,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -8,7 +8,7 @@ namespace PcapDotNet.Packets.Igmp
/// <summary> /// <summary>
/// The type of the IGMP message of concern to the host-router interaction. /// The type of the IGMP message of concern to the host-router interaction.
/// </summary> /// </summary>
public override IgmpMessageType MessageType public override IgmpMessageType MessageTypeValue
{ {
get { return IgmpMessageType.MembershipReportVersion1; } get { return IgmpMessageType.MembershipReportVersion1; }
} }
......
...@@ -8,7 +8,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -8,7 +8,7 @@ namespace PcapDotNet.Packets.Igmp
/// <summary> /// <summary>
/// The type of the IGMP message of concern to the host-router interaction. /// The type of the IGMP message of concern to the host-router interaction.
/// </summary> /// </summary>
public override IgmpMessageType MessageType public override IgmpMessageType MessageTypeValue
{ {
get { return IgmpMessageType.MembershipReportVersion2; } get { return IgmpMessageType.MembershipReportVersion2; }
} }
......
...@@ -10,7 +10,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -10,7 +10,7 @@ namespace PcapDotNet.Packets.Igmp
/// Represents an IGMP Report version 3 layer. /// Represents an IGMP Report version 3 layer.
/// <seealso cref="IgmpDatagram"/> /// <seealso cref="IgmpDatagram"/>
/// </summary> /// </summary>
public sealed class IgmpReportVersion3Layer : IgmpLayer public sealed class IgmpReportVersion3Layer : IgmpVersion1PlusLayer
{ {
/// <summary> /// <summary>
/// Creates an instance of an IGMP Report Version 3 Layer with a default of no Group Records. /// Creates an instance of an IGMP Report Version 3 Layer with a default of no Group Records.
...@@ -47,7 +47,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -47,7 +47,7 @@ namespace PcapDotNet.Packets.Igmp
/// <summary> /// <summary>
/// The type of the IGMP message of concern to the host-router interaction. /// The type of the IGMP message of concern to the host-router interaction.
/// </summary> /// </summary>
public override IgmpMessageType MessageType public override IgmpMessageType MessageTypeValue
{ {
get { return IgmpMessageType.MembershipReportVersion3; } get { return IgmpMessageType.MembershipReportVersion3; }
} }
...@@ -72,7 +72,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -72,7 +72,7 @@ namespace PcapDotNet.Packets.Igmp
/// <summary> /// <summary>
/// true iff the group records are equal. /// true iff the group records are equal.
/// </summary> /// </summary>
protected override bool EqualFields(IgmpLayer other) protected override bool EqualFields(IgmpVersion1PlusLayer other)
{ {
return EqualFields(other as IgmpReportVersion3Layer); return EqualFields(other as IgmpReportVersion3Layer);
} }
......
using System;
using System.Globalization;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Igmp
{
/// <summary>
/// RFC 988.
/// </summary>
public sealed class IgmpRequestVersion0Layer : IgmpVersion0Layer
{
/// <summary>
/// The type of the IGMP message of concern to the host-router interaction.
/// </summary>
public override IgmpMessageType MessageTypeValue
{
get { return MessageType; }
}
/// <summary>
/// The type of the IGMP message of concern to the host-router interaction.
/// Either JoinGroupRequestVersion0 or LeaveGroupRequestVersion0.
/// </summary>
public IgmpMessageType MessageType
{
get { return _messageType; }
set
{
switch (value)
{
case IgmpMessageType.JoinGroupRequestVersion0:
case IgmpMessageType.LeaveGroupRequestVersion0:
_messageType = value;
break;
default:
throw new ArgumentOutOfRangeException("value", value, string.Format(CultureInfo.InvariantCulture, "Do not use {0} for {1}", GetType(), value));
}
}
}
/// <summary>
/// In a Confirm Group Request message, the identifier field should contain zero.
/// In all other Request messages, the identifier field contains a value to distinguish the request from other requests by the same host.
/// </summary>
public uint Identifier { get; set; }
/// <summary>
/// In a Confirm Group Request message, the identifier field contains zero.
/// In all other Request messages, the identifier field contains a value to distinguish the request from other requests by the same host.
/// </summary>
public override uint IdentifierValue
{
get { return Identifier; }
}
/// <summary>
/// In a Create Group Request message, the group address field contains zero.
/// In all other Request messages, the group address field contains a host group address.
/// </summary>
public IpV4Address GroupAddress { get; set; }
/// <summary>
/// In a Create Group Request message, the access key field contains zero.
/// In all other Request messages, the access key field contains the access key assigned to the host group identified in the Group Address field
/// (zero for public groups).
/// </summary>
public ulong AccessKey { get; set; }
/// <summary>
/// In a Create Group Request message, the access key field contains zero.
/// In all other Request messages, the access key field contains the access key assigned to the host group identified in the Group Address field
/// (zero for public groups).
/// </summary>
public override ulong AccessKeyValue
{
get { return AccessKey; }
}
internal override byte CodeValue
{
get { return 0; }
}
internal override IpV4Address GroupAddressValue
{
get { return GroupAddress; }
}
private IgmpMessageType _messageType = IgmpMessageType.JoinGroupRequestVersion0;
}
}
\ No newline at end of file
using PcapDotNet.Base;
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Igmp
{
/// <summary>
/// RFC 988.
/// </summary>
public abstract class IgmpVersion0Layer : IgmpLayer
{
/// <summary>
/// The number of bytes this layer will take.
/// </summary>
public override sealed int Length
{
get { return IgmpDatagram.Version0HeaderLength; }
}
/// <summary>
/// In a Confirm Group Request message, the identifier field contains zero.
/// In all other Request messages, the identifier field contains a value to distinguish the request from other requests by the same host.
/// In a Reply message, the identifier field contains the same value as in the corresponding Request message.
/// </summary>
public abstract uint IdentifierValue { get; }
/// <summary>
/// In a Create Group Request message, the access key field contains zero.
/// In all other Request messages, the access key field contains the access key assigned to the host group identified in the Group Address field
/// (zero for public groups).
/// In a Create Group Reply message, the access key field contains either a non-zero 64-bit number (if the request for a private group is granted)
/// or zero.
/// In all other Reply messages, the access key field contains the same access key as in the corresponding Request.
/// </summary>
public abstract ulong AccessKeyValue { get; }
/// <summary>
/// Xor of the hash codes of the layer length, datalink, message type, query version, code, identifier, group address and access key.
/// </summary>
public override int GetHashCode()
{
return new[]
{
base.GetHashCode(),
CodeValue.GetHashCode(),
IdentifierValue.GetHashCode(),
GroupAddressValue.GetHashCode(),
AccessKeyValue.GetHashCode()
}.Xor();
}
/// <summary>
/// true iff the fields that are not mutual to all IGMP layers are equal.
/// </summary>
protected override sealed bool EqualsVersionSpecific(IgmpLayer other)
{
return EqualsVersionSpecific(other as IgmpVersion0Layer);
}
/// <summary>
/// Writes the layer to the buffer.
/// This method ignores the payload length, and the previous and next layers.
/// </summary>
/// <param name="buffer">The buffer to write the layer to.</param>
/// <param name="offset">The offset in the buffer to start writing the layer at.</param>
protected override void Write(byte[] buffer, int offset)
{
IgmpDatagram.WriteVersion0Header(buffer, offset, MessageTypeValue, CodeValue, IdentifierValue, GroupAddressValue, AccessKeyValue);
}
internal abstract byte CodeValue { get; }
internal abstract IpV4Address GroupAddressValue { get; }
private bool EqualsVersionSpecific(IgmpVersion0Layer other)
{
return other != null &&
CodeValue == other.CodeValue &&
IdentifierValue == other.IdentifierValue &&
GroupAddressValue.Equals(other.GroupAddressValue) &&
AccessKeyValue == other.AccessKeyValue;
}
}
}
\ No newline at end of file
namespace PcapDotNet.Packets.Igmp
{
/// <summary>
/// RFC 988.
/// In an IGMP version 0 Reply message, specifies the outcome of the request:
/// </summary>
public enum IgmpVersion0ReplyCode : byte
{
/// <summary>
/// Request granted.
/// </summary>
RequestGranted = 0,
/// <summary>
/// Request denied, no resources.
/// </summary>
RequestDeniedNoResources = 1,
/// <summary>
/// Request denied, invalid code.
/// </summary>
RequestDeniedInvalidCode = 2,
/// <summary>
/// Request denied, invalid group address.
/// </summary>
RequestDeniedInvalidGroupAddress = 3,
/// <summary>
/// Request denied, invalid access key.
/// </summary>
RequestDeniedInvalidAccessKey = 4,
/// <summary>
/// Request pending, retry in this many seconds.
/// </summary>
RequestPendingRetryInThisManySeconds = 5,
}
}
\ No newline at end of file
...@@ -7,7 +7,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -7,7 +7,7 @@ namespace PcapDotNet.Packets.Igmp
/// Represents an IGMP version 1 layer. /// Represents an IGMP version 1 layer.
/// <seealso cref="IgmpDatagram"/> /// <seealso cref="IgmpDatagram"/>
/// </summary> /// </summary>
public abstract class IgmpVersion1Layer : IgmpSimpleLayer public abstract class IgmpVersion1Layer : IgmpVersion1PlusSimpleLayer
{ {
/// <summary> /// <summary>
/// The actual time allowed, called the Max Resp Time. /// The actual time allowed, called the Max Resp Time.
......
This diff is collapsed.
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