Skip to content

Commit

Permalink
Default IgmpReportVersion3Layer's 0 GroupRecords.
Browse files Browse the repository at this point in the history
Fixed tests.
Code Coverage 97.81%
  • Loading branch information
Brickner_cp authored and Brickner_cp committed May 8, 2010
1 parent e94f56b commit 396ff74
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void ReceivePacketsTest()
// Wait for more packets
TestReceivePackets(NumPacketsToSend, 0, int.MaxValue, 2, PacketSize, PacketCommunicatorReceiveResult.None, NumPacketsToSend, 2, 2.043);
TestReceivePackets(NumPacketsToSend, -1, int.MaxValue, 2, PacketSize, PacketCommunicatorReceiveResult.None, NumPacketsToSend, 2, 2.3);
TestReceivePackets(NumPacketsToSend, NumPacketsToSend + 1, int.MaxValue, 2, PacketSize, PacketCommunicatorReceiveResult.None, NumPacketsToSend, 2, 2.035);
TestReceivePackets(NumPacketsToSend, NumPacketsToSend + 1, int.MaxValue, 2, PacketSize, PacketCommunicatorReceiveResult.None, NumPacketsToSend, 2, 2.051);

// Break loop
TestReceivePackets(NumPacketsToSend, NumPacketsToSend, 0, 2, PacketSize, PacketCommunicatorReceiveResult.BreakLoop, 0, 0, 0.027);
Expand Down
19 changes: 14 additions & 5 deletions PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private static void ComparePacketsToWireshark(IEnumerable<Packet> packets)
}
else
{
const byte retryNumber = 121;
const byte retryNumber = 28;
pcapFilename = Path.GetTempPath() + "temp." + retryNumber + ".pcap";
List<Packet> packetsList = new List<Packet>();
new OfflinePacketDevice(pcapFilename).Open().ReceivePackets(1000, packetsList.Add);
Expand Down Expand Up @@ -221,7 +221,14 @@ private static void ComparePacketsToWireshark(IEnumerable<Packet> packets)
? b
: Math.Max((byte)0x20, Math.Min(b, (byte)0x7F))).ToArray());

Compare(XDocument.Load(fixedDocumentFilename), packets);
try
{
Compare(XDocument.Load(fixedDocumentFilename), packets);
}
catch (AssertFailedException exception)
{
throw new AssertFailedException("Failed comparing packets in file " + pcapFilename + ". Message: " + exception.Message, exception);
}
}

private static void Compare(XDocument document, IEnumerable<Packet> packets)
Expand All @@ -232,7 +239,7 @@ private static void Compare(XDocument document, IEnumerable<Packet> packets)
int i = 1;
foreach (var documentPacket in document.Element("pdml").Elements("packet"))
{
Console.WriteLine("Checking packet " + i);
// Console.WriteLine("Checking packet " + i);
packetEnumerator.MoveNext();
Packet packet = packetEnumerator.Current;

Expand Down Expand Up @@ -612,8 +619,10 @@ private static void CompareIgmp(XElement igmp, IgmpDatagram igmpDatagram)
switch (field.Name())
{
case "igmp.version":
if (field.Show() != "0")
field.AssertShowDecimal(igmpDatagram.Version);
if (field.Show() == "0")
return;

field.AssertShowDecimal(igmpDatagram.Version);
break;

case "igmp.type":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ namespace PcapDotNet.Packets.Igmp
/// </summary>
public class IgmpReportVersion3Layer : IgmpLayer
{
/// <summary>
/// Creates an instance of an IGMP Report Version 3 Layer with a default of no Group Records.
/// </summary>
public IgmpReportVersion3Layer()
{
GroupRecords = new IgmpGroupRecord[0].AsReadOnly();
}
/// <summary>
/// Each Group Record is a block of fields containing information pertaining to the sender's membership in a single multicast group on the interface from which the Report is sent.
/// </summary>
Expand Down

0 comments on commit 396ff74

Please sign in to comment.