Commit de6a4376 authored by Brickner_cp's avatar Brickner_cp

Code Coverage 96.55%

parent c23bc3b9
......@@ -68,7 +68,7 @@ namespace PcapDotNet.Packets.Test
IpV4Layer ipV4Layer = random.NextIpV4Layer(null);
ipV4Layer.HeaderChecksum = null;
for (int i = 0; i != 100; ++i)
for (int i = 0; i != 200; ++i)
{
GreLayer greLayer = random.NextGreLayer();
PayloadLayer payloadLayer = random.NextPayloadLayer(random.Next(100));
......@@ -114,6 +114,11 @@ namespace PcapDotNet.Packets.Test
Assert.IsNull(actualGreLayer.KeyCallId);
}
Assert.AreEqual(greLayer, actualGreLayer, "Layer");
if (actualGre.KeyPresent)
{
Assert.AreEqual(greLayer.KeyPayloadLength, actualGre.KeyPayloadLength, "KeyPayloadLength");
Assert.AreEqual(greLayer.KeyCallId, actualGre.KeyCallId, "KeyCallId");
}
Assert.AreNotEqual(random.NextGreLayer(), actualGreLayer, "Not Layer");
Assert.AreEqual(greLayer.Length, actualGre.HeaderLength);
Assert.IsTrue(actualGre.KeyPresent ^ (greLayer.Key == null));
......@@ -159,6 +164,18 @@ namespace PcapDotNet.Packets.Test
{
Assert.IsNull(actualGre.ActiveSourceRouteEntry);
}
Assert.IsNotNull(actualGre.Payload);
switch (actualGre.ProtocolType)
{
case EthernetType.IpV4:
Assert.IsNotNull(actualGre.IpV4);
break;
case EthernetType.Arp:
Assert.IsNotNull(actualGre.Arp);
break;
}
}
}
......
......@@ -206,7 +206,7 @@ namespace PcapDotNet.Packets.Gre
get
{
int? activeSourceRouteEntryIndex = ActiveSourceRouteEntryIndex;
if (activeSourceRouteEntryIndex == null || activeSourceRouteEntryIndex == Routing.Count)
if (activeSourceRouteEntryIndex == null || activeSourceRouteEntryIndex.Value == Routing.Count)
return null;
return Routing[activeSourceRouteEntryIndex.Value];
......
......@@ -15,8 +15,14 @@ namespace PcapDotNet.Packets.Gre
public bool ChecksumPresent { get; set; }
public ushort? Checksum { get; set; }
public uint? Key { get; set; }
public ushort? KeyPayloadLength { get { return Key == null ? null : (ushort?)((Key & 0xFFFF0000) >> 16); } }
public ushort? KeyCallId { get { return Key == null ? null : (ushort?)(Key & 0x0000FFFF); } }
public ushort? KeyPayloadLength
{
get { return Key == null ? null : (ushort?)((Key.Value & 0xFFFF0000) >> 16); }
}
public ushort? KeyCallId
{
get { return Key == null ? null : (ushort?)(Key.Value & 0x0000FFFF); }
}
public void SetKey(ushort keyPayloadLength, ushort keyCallId)
{
Key = (uint)((keyPayloadLength << 16) | keyCallId);
......
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