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":
...@@ -67,12 +66,22 @@ namespace PcapDotNet.Core.Test ...@@ -67,12 +66,22 @@ namespace PcapDotNet.Core.Test
// todo support IGMP traceroute http://www.ietf.org/proceedings/48/I-D/idmr-traceroute-ipm-07.txt. // todo support IGMP traceroute http://www.ietf.org/proceedings/48/I-D/idmr-traceroute-ipm-07.txt.
break; break;
default:
switch (field.Show())
{
case "Data":
if (field.Value().Length > 0)
{
// 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: default:
if (typeof(IgmpMessageType).GetEnumValues<IgmpMessageType>().Contains(igmpDatagram.MessageType)) if (typeof(IgmpMessageType).GetEnumValues<IgmpMessageType>().Contains(igmpDatagram.MessageType))
throw new InvalidOperationException("Invalid message type " + igmpDatagram.MessageType); throw new InvalidOperationException("Invalid message type " + igmpDatagram.MessageType);
break;
field.AssertValue(igmpDatagram.Skip(1)); }
// field.AssertShow(igmpDatagram.Skip(1));
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
...@@ -7,6 +7,23 @@ using PcapDotNet.Packets.IpV4; ...@@ -7,6 +7,23 @@ using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.Igmp namespace PcapDotNet.Packets.Igmp
{ {
/// <summary> /// <summary>
/// RFC 988.
/// Version 0:
/// <pre>
/// +-----+------+------+----------+
/// | Bit | 0-7 | 8-15 | 16-31 |
/// +-----+------+------+----------+
/// | 0 | Type | Code | Checksum |
/// +-----+------+------+----------+
/// | 32 | Identifier |
/// +-----+------------------------+
/// | 64 | Group Address |
/// +-----+------------------------+
/// | 96 | Access Key |
/// | | |
/// +-----+------------------------+
/// </pre>
///
/// RFC 1112. /// RFC 1112.
/// Version 1 (query or report): /// Version 1 (query or report):
/// <pre> /// <pre>
...@@ -93,7 +110,12 @@ namespace PcapDotNet.Packets.Igmp ...@@ -93,7 +110,12 @@ namespace PcapDotNet.Packets.Igmp
public sealed class IgmpDatagram : Datagram public sealed class IgmpDatagram : Datagram
{ {
/// <summary> /// <summary>
/// The number of bytes the IGMP header takes for all messages but query version 3. /// The number of bytes the version 0 IGMP message header takes.
/// </summary>
public const int Version0HeaderLength = Offset.AccessKey + sizeof(ulong);
/// <summary>
/// The number of bytes the IGMP header takes for all messages but version 0 and query version 3.
/// All the bytes but the records of the report version 3. /// All the bytes but the records of the report version 3.
/// </summary> /// </summary>
public const int HeaderLength = 8; public const int HeaderLength = 8;
...@@ -107,20 +129,32 @@ namespace PcapDotNet.Packets.Igmp ...@@ -107,20 +129,32 @@ namespace PcapDotNet.Packets.Igmp
private static class Offset private static class Offset
{ {
public const int MessageType = 0; public const int MessageType = 0;
public const int MaxResponseCode = 1; public const int MaxResponseCode = MessageType + sizeof(byte);
public const int Checksum = 2; public const int Checksum = MaxResponseCode + sizeof(byte);
public const int GroupAddress = 4; public const int Version1PlusGroupAddress = Checksum + sizeof(ushort);
// Version 0
public const int Code = MaxResponseCode;
public const int Identifier = Checksum + sizeof(ushort);
public const int Version0GroupAddress = Identifier + sizeof(uint);
public const int AccessKey = Version0GroupAddress + IpV4Address.SizeOf;
// Version 3 query // Version 3 query
public const int IsSuppressRouterSideProcessing = 8; public const int IsSuppressRouterSideProcessing = Version1PlusGroupAddress + IpV4Address.SizeOf;
public const int QueryRobustnessVariable = 8; public const int QueryRobustnessVariable = IsSuppressRouterSideProcessing;
public const int QueryIntervalCode = 9; public const int QueryIntervalCode = QueryRobustnessVariable + sizeof(byte);
public const int NumberOfSources = 10; public const int NumberOfSources = QueryIntervalCode + sizeof(byte);
public const int SourceAddresses = 12; public const int SourceAddresses = NumberOfSources + sizeof(ushort);
// Version 3 report // Version 3 report
public const int NumberOfGroupRecords = 6; public const int NumberOfGroupRecords = Checksum + sizeof(ushort) + sizeof(ushort);
public const int GroupRecords = 8; public const int GroupRecords = NumberOfGroupRecords + sizeof(ushort);
}
private static class Mask
{
// Version 0
public const byte Code = 0x01;
} }
/// <summary> /// <summary>
...@@ -162,6 +196,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -162,6 +196,7 @@ namespace PcapDotNet.Packets.Igmp
/// <summary> /// <summary>
/// The version of the IGMP protocol for this datagram. /// The version of the IGMP protocol for this datagram.
/// Returns -1 if unknown.
/// </summary> /// </summary>
public int Version public int Version
{ {
...@@ -169,6 +204,16 @@ namespace PcapDotNet.Packets.Igmp ...@@ -169,6 +204,16 @@ namespace PcapDotNet.Packets.Igmp
{ {
switch (MessageType) switch (MessageType)
{ {
case IgmpMessageType.CreateGroupRequestVersion0:
case IgmpMessageType.CreateGroupReplyVersion0:
case IgmpMessageType.JoinGroupRequestVersion0:
case IgmpMessageType.JoinGroupReplyVersion0:
case IgmpMessageType.LeaveGroupRequestVersion0:
case IgmpMessageType.LeaveGroupReplyVersion0:
case IgmpMessageType.ConfirmGroupRequestVersion0:
case IgmpMessageType.ConfirmGroupReplyVersion0:
return 0;
case IgmpMessageType.MembershipQuery: case IgmpMessageType.MembershipQuery:
switch (QueryVersion) switch (QueryVersion)
{ {
...@@ -198,7 +243,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -198,7 +243,7 @@ namespace PcapDotNet.Packets.Igmp
return 2; return 2;
default: default:
throw new InvalidOperationException("Invalid IGMP Message Type " + MessageType); return -1;
} }
} }
} }
...@@ -233,6 +278,51 @@ namespace PcapDotNet.Packets.Igmp ...@@ -233,6 +278,51 @@ namespace PcapDotNet.Packets.Igmp
} }
} }
/// <summary>
/// In IGMP version 0 Create Group Request message, indicates if the new host group is to be private or public.
/// </summary>
public bool IsPrivate
{
get
{
if (MessageType != IgmpMessageType.CreateGroupRequestVersion0)
throw new InvalidOperationException(System.Reflection.MethodBase.GetCurrentMethod().Name + " can only be accessed for CreateGroupRequestVersion0.");
return ReadBool(Offset.Code, Mask.Code);
}
}
/// <summary>
/// In IGMP version 0 Reply message, specifies the outcome of the request.
/// </summary>
public IgmpVersion0ReplyCode ReplyCode
{
get
{
if (MessageType != IgmpMessageType.CreateGroupReplyVersion0 &&
MessageType != IgmpMessageType.JoinGroupReplyVersion0 &&
MessageType != IgmpMessageType.LeaveGroupReplyVersion0 &&
MessageType != IgmpMessageType.ConfirmGroupReplyVersion0)
{
throw new InvalidOperationException(System.Reflection.MethodBase.GetCurrentMethod().Name + " can only be accessed for Version 0 Replies.");
}
return (IgmpVersion0ReplyCode)Math.Min(this[Offset.Code], (byte)IgmpVersion0ReplyCode.RequestPendingRetryInThisManySeconds);
}
}
/// <summary>
/// In IGMP version 0 Reply message with ReplyCode = RequestPendingRetryInThisManySeconds, specifies the amount of seconds to retry in.
/// </summary>
public byte RetryInThisManySeconds
{
get
{
if (ReplyCode != IgmpVersion0ReplyCode.RequestPendingRetryInThisManySeconds)
throw new InvalidOperationException(System.Reflection.MethodBase.GetCurrentMethod().Name + " can only be accessed when reply code is request pending retry in this many seconds");
return this[Offset.Code];
}
}
/// <summary> /// <summary>
/// The Max Resp Code field specifies the maximum time allowed before sending a responding report. /// The Max Resp Code field specifies the maximum time allowed before sending a responding report.
/// The actual time allowed, called the Max Resp Time, is represented in units of 1/10 second and is derived from the Max Resp Code as follows: /// The actual time allowed, called the Max Resp Time, is represented in units of 1/10 second and is derived from the Max Resp Code as follows:
...@@ -315,18 +405,61 @@ namespace PcapDotNet.Packets.Igmp ...@@ -315,18 +405,61 @@ namespace PcapDotNet.Packets.Igmp
} }
/// <summary> /// <summary>
/// IGMP version 0 specific.
/// 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 uint Identifier
{
get
{
return ReadUInt(Offset.Identifier, Endianity.Big);
}
}
/// <summary>
/// Version 0:
/// 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.
/// 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.
///
/// Version 1 or higher:
/// The Group Address field is set to zero when sending a General Query, /// The Group Address field is set to zero when sending a General Query,
/// and set to the IP multicast address being queried when sending a Group-Specific Query or Group-and-Source-Specific Query. /// and set to the IP multicast address being queried when sending a Group-Specific Query or Group-and-Source-Specific Query.
/// In a Membership Report of version 1 or 2 or Leave Group message, the group address field holds the IP multicast group address of the group being reported or left. /// In a Membership Report of version 1 or 2 or Leave Group message,
/// the group address field holds the IP multicast group address of the group being reported or left.
/// In a Membership Report of version 3 this field is meaningless. /// In a Membership Report of version 3 this field is meaningless.
/// </summary> /// </summary>
public IpV4Address GroupAddress public IpV4Address GroupAddress
{ {
get { return ReadIpV4Address(Offset.GroupAddress, Endianity.Big); } get { return ReadIpV4Address(Version <= 0 ? Offset.Version0GroupAddress : Offset.Version1PlusGroupAddress, Endianity.Big); }
}
/// <summary>
/// Version 0 specific.
/// 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 ulong AccessKey
{
get
{
return ReadULong(Offset.AccessKey, Endianity.Big);
}
} }
/// <summary> /// <summary>
/// When set to one, the S Flag indicates to any receiving multicast routers that they are to suppress the normal timer updates they perform upon hearing a Query. /// When set to one, the S Flag indicates to any receiving multicast routers
/// that they are to suppress the normal timer updates they perform upon hearing a Query.
/// It does not, however, suppress the querier election or the normal "host-side" processing of a Query /// It does not, however, suppress the querier election or the normal "host-side" processing of a Query
/// that a router may be required to perform as a consequence of itself being a group member. /// that a router may be required to perform as a consequence of itself being a group member.
/// </summary> /// </summary>
...@@ -492,6 +625,44 @@ namespace PcapDotNet.Packets.Igmp ...@@ -492,6 +625,44 @@ namespace PcapDotNet.Packets.Igmp
{ {
switch (MessageType) switch (MessageType)
{ {
case IgmpMessageType.CreateGroupRequestVersion0:
return new IgmpCreateGroupRequestVersion0Layer
{
IsPrivate = IsPrivate,
Identifier = Identifier,
};
case IgmpMessageType.CreateGroupReplyVersion0:
case IgmpMessageType.JoinGroupReplyVersion0:
case IgmpMessageType.LeaveGroupReplyVersion0:
case IgmpMessageType.ConfirmGroupReplyVersion0:
return new IgmpReplyVersion0Layer
{
MessageType = MessageType,
Code = ReplyCode,
RetryInThisManySeconds = (byte)(ReplyCode == IgmpVersion0ReplyCode.RequestPendingRetryInThisManySeconds ? RetryInThisManySeconds : 0),
Identifier = Identifier,
GroupAddress = GroupAddress,
AccessKey = AccessKey,
};
case IgmpMessageType.JoinGroupRequestVersion0:
case IgmpMessageType.LeaveGroupRequestVersion0:
return new IgmpRequestVersion0Layer
{
MessageType = MessageType,
Identifier = Identifier,
GroupAddress = GroupAddress,
AccessKey = AccessKey,
};
case IgmpMessageType.ConfirmGroupRequestVersion0:
return new IgmpConfirmGroupRequestVersion0Layer
{
GroupAddress = GroupAddress,
AccessKey = AccessKey,
};
case IgmpMessageType.MembershipQuery: case IgmpMessageType.MembershipQuery:
switch (QueryVersion) switch (QueryVersion)
{ {
...@@ -571,7 +742,18 @@ namespace PcapDotNet.Packets.Igmp ...@@ -571,7 +742,18 @@ namespace PcapDotNet.Packets.Igmp
igmpGroupRecords.Sum(record => IgmpGroupRecordDatagram.GetLength(record.SourceAddresses.Count, record.AuxiliaryData.Length)); igmpGroupRecords.Sum(record => IgmpGroupRecordDatagram.GetLength(record.SourceAddresses.Count, record.AuxiliaryData.Length));
} }
internal static void WriteHeader(byte[] buffer, int offset, internal static void WriteVersion0Header(byte[] buffer, int offset,
IgmpMessageType igmpMessageType, byte code, uint identifier, IpV4Address groupAddress, ulong accessKey)
{
buffer.Write(offset + Offset.MessageType, (byte)igmpMessageType);
buffer.Write(offset + Offset.Code, code);
buffer.Write(offset + Offset.Version0GroupAddress, groupAddress, Endianity.Big);
buffer.Write(offset + Offset.Identifier, identifier, Endianity.Big);
buffer.Write(offset + Offset.AccessKey, accessKey, Endianity.Big);
WriteChecksum(buffer, offset, Version0HeaderLength);
}
internal static void WriteVersion1PlusSimpleHeader(byte[] buffer, int offset,
IgmpMessageType igmpMessageType, TimeSpan maxResponseTime, IpV4Address groupAddress) IgmpMessageType igmpMessageType, TimeSpan maxResponseTime, IpV4Address groupAddress)
{ {
buffer.Write(offset + Offset.MessageType, (byte)igmpMessageType); buffer.Write(offset + Offset.MessageType, (byte)igmpMessageType);
...@@ -581,7 +763,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -581,7 +763,7 @@ namespace PcapDotNet.Packets.Igmp
throw new ArgumentOutOfRangeException("maxResponseTime", maxResponseTime, "must be in the range [" + TimeSpan.Zero + ", " + TimeSpan.FromSeconds(255 * 0.1) + "]"); throw new ArgumentOutOfRangeException("maxResponseTime", maxResponseTime, "must be in the range [" + TimeSpan.Zero + ", " + TimeSpan.FromSeconds(255 * 0.1) + "]");
buffer.Write(offset + Offset.MaxResponseCode, (byte)numTenthOfASecond); buffer.Write(offset + Offset.MaxResponseCode, (byte)numTenthOfASecond);
buffer.Write(offset + Offset.GroupAddress, groupAddress, Endianity.Big); buffer.Write(offset + Offset.Version1PlusGroupAddress, groupAddress, Endianity.Big);
WriteChecksum(buffer, offset, HeaderLength); WriteChecksum(buffer, offset, HeaderLength);
} }
...@@ -602,7 +784,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -602,7 +784,7 @@ namespace PcapDotNet.Packets.Igmp
buffer.Write(offset + Offset.MaxResponseCode, maxResponseCode); buffer.Write(offset + Offset.MaxResponseCode, maxResponseCode);
// GroupAddress // GroupAddress
buffer.Write(offset + Offset.GroupAddress, groupAddress, Endianity.Big); buffer.Write(offset + Offset.Version1PlusGroupAddress, groupAddress, Endianity.Big);
// IsSuppressRouterSideProcessing and QueryRobustnessVariable // IsSuppressRouterSideProcessing and QueryRobustnessVariable
if (queryRobustnessVariable > MaxQueryRobustnessVariable) if (queryRobustnessVariable > MaxQueryRobustnessVariable)
...@@ -660,6 +842,9 @@ namespace PcapDotNet.Packets.Igmp ...@@ -660,6 +842,9 @@ namespace PcapDotNet.Packets.Igmp
if (Length < HeaderLength || !IsChecksumCorrect) if (Length < HeaderLength || !IsChecksumCorrect)
return false; return false;
if (Version == 0)
return Length == Version0HeaderLength;
switch (MessageType) switch (MessageType)
{ {
case IgmpMessageType.MembershipQuery: case IgmpMessageType.MembershipQuery:
...@@ -673,6 +858,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -673,6 +858,7 @@ namespace PcapDotNet.Packets.Igmp
return Length == GetQueryVersion3Length(NumberOfSources); return Length == GetQueryVersion3Length(NumberOfSources);
default: default:
// This never happens, since Version != 0 with MessageType = MembershipQuery requires QueryVersion to be 1, 2 or 3.
return false; return false;
} }
...@@ -703,7 +889,8 @@ namespace PcapDotNet.Packets.Igmp ...@@ -703,7 +889,8 @@ namespace PcapDotNet.Packets.Igmp
private static void WriteChecksum(byte[] buffer, int offset, int length) private static void WriteChecksum(byte[] buffer, int offset, int length)
{ {
buffer.Write(offset + Offset.Checksum, Sum16BitsToChecksum(Sum16Bits(buffer, offset, length)), Endianity.Big); uint sum = Sum16Bits(buffer, offset, length);
buffer.Write(offset + Offset.Checksum, Sum16BitsToChecksum(sum), Endianity.Big);
} }
/// <summary> /// <summary>
......
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.
......
using System;
using PcapDotNet.Base;
namespace PcapDotNet.Packets.Igmp
{
/// <summary>
/// Base class for all IGMP layers of version 1 or higher.
/// </summary>
public abstract class IgmpVersion1PlusLayer : IgmpLayer
{
/// <summary>
/// The actual time allowed, called the Max Resp Time.
/// </summary>
public abstract TimeSpan MaxResponseTimeValue { get; }
/// <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 IgmpVersion1PlusLayer);
}
/// <summary>
/// true iff the fields that are not mutual to all IGMP version 1+ layers are equal.
/// </summary>
protected abstract bool EqualFields(IgmpVersion1PlusLayer other);
private bool EqualsVersionSpecific(IgmpVersion1PlusLayer other)
{
return other != null &&
EqualMaxResponseTime(MaxResponseTimeValue, other.MaxResponseTimeValue) &&
EqualFields(other);
}
private static bool EqualMaxResponseTime(TimeSpan value1, TimeSpan value2)
{
return value1.Divide(2) <= value2 && value1.Multiply(2) >= value2;
}
}
}
\ No newline at end of file
...@@ -7,7 +7,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -7,7 +7,7 @@ namespace PcapDotNet.Packets.Igmp
/// A simple layer only has the 8 bytes header without additional fields. /// A simple layer only has the 8 bytes header without additional fields.
/// <seealso cref="IgmpDatagram"/> /// <seealso cref="IgmpDatagram"/>
/// </summary> /// </summary>
public abstract class IgmpSimpleLayer : IgmpLayer, IIgmpLayerWithGroupAddress public abstract class IgmpVersion1PlusSimpleLayer : IgmpVersion1PlusLayer, IIgmpLayerWithGroupAddress
{ {
/// <summary> /// <summary>
/// The Group Address field is set to zero when sending a General Query, /// The Group Address field is set to zero when sending a General Query,
...@@ -33,8 +33,8 @@ namespace PcapDotNet.Packets.Igmp ...@@ -33,8 +33,8 @@ namespace PcapDotNet.Packets.Igmp
/// <param name="offset">The offset in the buffer to start writing the layer at.</param> /// <param name="offset">The offset in the buffer to start writing the layer at.</param>
protected sealed override void Write(byte[] buffer, int offset) protected sealed override void Write(byte[] buffer, int offset)
{ {
IgmpDatagram.WriteHeader(buffer, offset, IgmpDatagram.WriteVersion1PlusSimpleHeader(buffer, offset,
MessageType, MaxResponseTimeValue, GroupAddress); MessageTypeValue, MaxResponseTimeValue, GroupAddress);
} }
/// <summary> /// <summary>
...@@ -47,17 +47,17 @@ namespace PcapDotNet.Packets.Igmp ...@@ -47,17 +47,17 @@ namespace PcapDotNet.Packets.Igmp
} }
/// <summary> /// <summary>
/// true iff the the group address is equal. /// True iff the fields that are not mutual to all IGMP version 1+ layers are equal.
/// </summary> /// </summary>
protected sealed override bool EqualFields(IgmpLayer other) protected override bool EqualFields(IgmpVersion1PlusLayer other)
{ {
return EqualFields(other as IgmpSimpleLayer); return EqualFields(other as IgmpVersion1PlusSimpleLayer);
} }
/// <summary> /// <summary>
/// true iff the the group address is equal. /// True iff the the group address is equal.
/// </summary> /// </summary>
private bool EqualFields(IgmpSimpleLayer other) private bool EqualFields(IgmpVersion1PlusSimpleLayer other)
{ {
return other != null && return other != null &&
GroupAddress == other.GroupAddress; GroupAddress == other.GroupAddress;
......
...@@ -7,7 +7,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -7,7 +7,7 @@ namespace PcapDotNet.Packets.Igmp
/// Represents a generic IGMP version 2 datagram. /// Represents a generic IGMP version 2 datagram.
/// <seealso cref="IgmpDatagram"/> /// <seealso cref="IgmpDatagram"/>
/// </summary> /// </summary>
public abstract class IgmpVersion2Layer : IgmpSimpleLayer public abstract class IgmpVersion2Layer : IgmpVersion1PlusSimpleLayer
{ {
/// <summary> /// <summary>
/// The actual time allowed, called the Max Resp Time. /// The actual time allowed, called the Max Resp Time.
......
...@@ -299,17 +299,24 @@ ...@@ -299,17 +299,24 @@
<Compile Include="Icmp\IcmpUnknownLayer.cs" /> <Compile Include="Icmp\IcmpUnknownLayer.cs" />
<Compile Include="IDataLink.cs" /> <Compile Include="IDataLink.cs" />
<Compile Include="Ethernet\IEthernetNextLayer.cs" /> <Compile Include="Ethernet\IEthernetNextLayer.cs" />
<Compile Include="Igmp\IgmpConfirmGroupRequestVersion0Layer.cs" />
<Compile Include="Igmp\IgmpCreateGroupRequestVersion0Code.cs" /> <Compile Include="Igmp\IgmpCreateGroupRequestVersion0Code.cs" />
<Compile Include="Igmp\IgmpCreateGroupRequestVersion0Layer.cs" />
<Compile Include="Igmp\IgmpLayer.cs" /> <Compile Include="Igmp\IgmpLayer.cs" />
<Compile Include="Igmp\IgmpLeaveGroupVersion2Layer.cs" /> <Compile Include="Igmp\IgmpLeaveGroupVersion2Layer.cs" />
<Compile Include="Igmp\IgmpQueryVersion1Layer.cs" /> <Compile Include="Igmp\IgmpQueryVersion1Layer.cs" />
<Compile Include="Igmp\IgmpQueryVersion2Layer.cs" /> <Compile Include="Igmp\IgmpQueryVersion2Layer.cs" />
<Compile Include="Igmp\IgmpQueryVersion3Layer.cs" /> <Compile Include="Igmp\IgmpQueryVersion3Layer.cs" />
<Compile Include="Igmp\IgmpReplyVersion0Code.cs" /> <Compile Include="Igmp\IgmpReplyVersion0Code.cs" />
<Compile Include="Igmp\IgmpReplyVersion0Layer.cs" />
<Compile Include="Igmp\IgmpReportVersion1Layer.cs" /> <Compile Include="Igmp\IgmpReportVersion1Layer.cs" />
<Compile Include="Igmp\IgmpReportVersion2Layer.cs" /> <Compile Include="Igmp\IgmpReportVersion2Layer.cs" />
<Compile Include="Igmp\IgmpReportVersion3Layer.cs" /> <Compile Include="Igmp\IgmpReportVersion3Layer.cs" />
<Compile Include="Igmp\IgmpSimpleLayer.cs" /> <Compile Include="Igmp\IgmpRequestVersion0Layer.cs" />
<Compile Include="Igmp\IgmpVersion0Layer.cs" />
<Compile Include="Igmp\IgmpVersion1PlusLayer.cs" />
<Compile Include="Igmp\IgmpVersion1PlusSimpleLayer.cs" />
<Compile Include="Igmp\IgmpVersion0ReplyCode.cs" />
<Compile Include="Igmp\IgmpVersion1Layer.cs" /> <Compile Include="Igmp\IgmpVersion1Layer.cs" />
<Compile Include="Igmp\IgmpVersion2Layer.cs" /> <Compile Include="Igmp\IgmpVersion2Layer.cs" />
<Compile Include="Igmp\IgmpDatagram.cs" /> <Compile Include="Igmp\IgmpDatagram.cs" />
......
using System.Diagnostics.CodeAnalysis;
namespace PcapDotNet.TestUtils namespace PcapDotNet.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class BoolExtensions public static class BoolExtensions
{ {
public static int ToInt(this bool b) public static int ToInt(this bool b)
......
namespace PcapDotNet.TestUtils
{
public static class ByteExtensions
{
public static bool[] ToBits(this byte b)
{
bool[] bits = new bool[8];
for (int i = 0; i != 8; ++i)
{
bits[7 - i] = (b % 2 == 1);
b /= 2;
}
return bits;
}
}
}
\ No newline at end of file
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.RegularExpressions; using System.Text.RegularExpressions;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PcapDotNet.TestUtils namespace PcapDotNet.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class MoreAssert public static class MoreAssert
{ {
public static void IsBigger<T>(T expectedMinimum, T actual) where T : IComparable<T> public static void IsBigger<T>(T expectedMinimum, T actual) where T : IComparable<T>
......
...@@ -75,7 +75,6 @@ ...@@ -75,7 +75,6 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ByteExtensions.cs" />
<Compile Include="MoreAssert.cs" /> <Compile Include="MoreAssert.cs" />
<Compile Include="BoolExtensions.cs" /> <Compile Include="BoolExtensions.cs" />
<Compile Include="RandomExtensions.cs" /> <Compile Include="RandomExtensions.cs" />
......
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;
namespace PcapDotNet.TestUtils namespace PcapDotNet.TestUtils
{ {
[ExcludeFromCodeCoverage]
public static class RandomExtensions public static class RandomExtensions
{ {
public static bool NextBool(this Random random, int chance = 2) public static bool NextBool(this Random random, int chance = 2)
......
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