Commit 4a21e82c authored by Brickner_cp's avatar Brickner_cp

Improved GRE comparison to Wireshark

parent e5864da8
...@@ -284,7 +284,7 @@ namespace PcapDotNet.Core.Test ...@@ -284,7 +284,7 @@ namespace PcapDotNet.Core.Test
// Normal // Normal
TestGetStatistics(SourceMac, DestinationMac, NumPacketsToSend, NumStatisticsToGather, int.MaxValue, 5, PacketSize, TestGetStatistics(SourceMac, DestinationMac, NumPacketsToSend, NumStatisticsToGather, int.MaxValue, 5, PacketSize,
PacketCommunicatorReceiveResult.Ok, NumStatisticsToGather, NumPacketsToSend, NumStatisticsToGather, NumStatisticsToGather + 0.05); PacketCommunicatorReceiveResult.Ok, NumStatisticsToGather, NumPacketsToSend, NumStatisticsToGather, NumStatisticsToGather + 0.16);
// Wait for less statistics // Wait for less statistics
TestGetStatistics(SourceMac, DestinationMac, NumPacketsToSend, NumStatisticsToGather / 2, int.MaxValue, 5, PacketSize, TestGetStatistics(SourceMac, DestinationMac, NumPacketsToSend, NumStatisticsToGather / 2, int.MaxValue, 5, PacketSize,
......
...@@ -987,11 +987,21 @@ namespace PcapDotNet.Core.Test ...@@ -987,11 +987,21 @@ namespace PcapDotNet.Core.Test
case "data": case "data":
case "data.data": case "data.data":
field.AssertValue(greDatagram.Payload); if (greDatagram.Version != GreVersion.EnhancedGre &&
greDatagram.AcknowledgmentSequenceNumberPresent)
{
Assert.AreEqual(field.Value().Skip(8).SequenceToString(), greDatagram.Payload.BytesSequenceToHexadecimalString(), "GRE data.data");
}
else
field.AssertValue(greDatagram.Payload, "GRE data.data");
break; break;
case "data.len": case "data.len":
field.AssertShowDecimal(greDatagram.Payload.Length); field.AssertShowDecimal(
greDatagram.Payload.Length + (greDatagram.Version != GreVersion.EnhancedGre &&
greDatagram.AcknowledgmentSequenceNumberPresent
? 4
: 0), "GRE data.len");
break; break;
default: default:
......
...@@ -47,9 +47,9 @@ namespace PcapDotNet.Core.Test ...@@ -47,9 +47,9 @@ namespace PcapDotNet.Core.Test
Assert.AreEqual(element.Name(), expectedName); Assert.AreEqual(element.Name(), expectedName);
} }
public static void AssertShow(this XElement element, string expectedValue) public static void AssertShow(this XElement element, string expectedValue, string message = null)
{ {
Assert.AreEqual(expectedValue, element.Show(), element.Name()); Assert.AreEqual(expectedValue, element.Show(), message ?? element.Name());
} }
public static void AssertShow(this XElement element, IEnumerable<byte> expectedValue) public static void AssertShow(this XElement element, IEnumerable<byte> expectedValue)
...@@ -77,9 +77,9 @@ namespace PcapDotNet.Core.Test ...@@ -77,9 +77,9 @@ namespace PcapDotNet.Core.Test
element.AssertShow(expectedValue.ToString()); element.AssertShow(expectedValue.ToString());
} }
public static void AssertShowDecimal(this XElement element, int expectedValue) public static void AssertShowDecimal(this XElement element, int expectedValue, string message = null)
{ {
element.AssertShow(expectedValue.ToString()); element.AssertShow(expectedValue.ToString(), message);
} }
public static void AssertShowDecimal(this XElement element, uint expectedValue) public static void AssertShowDecimal(this XElement element, uint expectedValue)
...@@ -137,9 +137,9 @@ namespace PcapDotNet.Core.Test ...@@ -137,9 +137,9 @@ namespace PcapDotNet.Core.Test
Assert.AreEqual(element.Value(), expectedValue, message ?? element.Name()); Assert.AreEqual(element.Value(), expectedValue, message ?? element.Name());
} }
public static void AssertValue(this XElement element, IEnumerable<byte> expectedValue) public static void AssertValue(this XElement element, IEnumerable<byte> expectedValue, string message = null)
{ {
element.AssertValue(expectedValue.BytesSequenceToHexadecimalString()); element.AssertValue(expectedValue.BytesSequenceToHexadecimalString(), message);
} }
public static void AssertValue(this XElement element, byte expectedValue) public static void AssertValue(this XElement element, byte expectedValue)
......
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