Commit c6eb9f9c authored by Brickner_cp's avatar Brickner_cp

Code Coverage 96.30%

Fix DnsResourceDataNextDomain bug, which resulted in wrong results in IsTypePresentForOwner() and CreateTypeBitmap().
Add MtuProbe to the list of IPv4 option types, but no support for it yet.
Improve TCP tests.
parent 7a1d0333
......@@ -587,9 +587,9 @@ namespace PcapDotNet.Core.Test
}
break;
case (IpV4OptionType)11:
// TODO: Support 11.
field.AssertShow("MTU Probe (with option length = " + option.Length + " bytes; should be 4)");
case IpV4OptionType.MtuProbe:
// TODO: Support MTU Proble.
Assert.IsTrue(field.Show().StartsWith("MTU Probe (" + option.Length + " bytes): "));
break;
case (IpV4OptionType)12:
......@@ -610,8 +610,8 @@ namespace PcapDotNet.Core.Test
case (IpV4OptionType)134:
// TODO: Support 134.
field.AssertShow("Commercial Security" +
(option.Length >= 10 ? string.Empty : " (with option length = " + option.Length + " bytes; should be >= 10)"));
field.AssertShow("Commercial Security " +
(option.Length >= 10 ? "(" + option.Length + " bytes)" : "(with option length = " + option.Length + " bytes; should be >= 10)"));
break;
case (IpV4OptionType)149:
......
......@@ -260,6 +260,7 @@ namespace PcapDotNet.Packets.Test
Assert.IsTrue(resourceData.IsTypePresentForOwner(DnsType.Aaaa));
Assert.IsFalse(resourceData.IsTypePresentForOwner(DnsType.Ns));
Assert.IsFalse(resourceData.IsTypePresentForOwner(DnsType.UInfo));
MoreAssert.AreSequenceEqual(new[] {DnsType.A, DnsType.Aaaa}, resourceData.TypesExist);
bitmap = DnsResourceDataNextDomain.CreateTypeBitmap(new DnsType[] { 0 });
Assert.AreEqual(DataSegment.Empty, bitmap);
......
......@@ -72,9 +72,6 @@ namespace PcapDotNet.Packets.Test
PayloadLayer payloadLayer = random.NextPayloadLayer(random.Next(60000));
if (i < 2)
continue;
Packet packet = PacketBuilder.Build(DateTime.Now, ethernetLayer, ipLayer, tcpLayer, payloadLayer);
Assert.IsTrue(packet.IsValid);
......@@ -104,7 +101,7 @@ namespace PcapDotNet.Packets.Test
Assert.AreNotEqual(random.NextTcpLayer(), packet.Ethernet.Ip.Tcp.ExtractLayer(), "TCP Layer");
Assert.AreEqual(tcpLayer.GetHashCode(), packet.Ethernet.Ip.Tcp.ExtractLayer().GetHashCode(), "TCP Layer");
Assert.AreNotEqual(random.NextTcpLayer().GetHashCode(), packet.Ethernet.Ip.Tcp.ExtractLayer().GetHashCode(), "TCP Layer");
Assert.AreEqual(packet.Ethernet.Ip.Tcp.SequenceNumber + packet.Ethernet.Ip.Tcp.PayloadLength, packet.Ethernet.Ip.Tcp.NextSequenceNumber);
Assert.AreEqual((uint)(packet.Ethernet.Ip.Tcp.SequenceNumber + packet.Ethernet.Ip.Tcp.PayloadLength), packet.Ethernet.Ip.Tcp.NextSequenceNumber);
foreach (TcpOption option in packet.Ethernet.Ip.Tcp.Options.OptionsCollection)
{
Assert.AreEqual(option, option);
......
......@@ -75,7 +75,8 @@ namespace PcapDotNet.Packets.TestUtils
if (maximumOptionLength >= IpV4OptionUnknown.OptionMinimumLength && random.Next(100) > 90)
return random.NextIpV4OptionUnknown(maximumOptionLength);
List<IpV4OptionType> impossibleOptionTypes = new List<IpV4OptionType>();
// TODO: Support MtuProbe.
List<IpV4OptionType> impossibleOptionTypes = new List<IpV4OptionType> {IpV4OptionType.MtuProbe};
if (maximumOptionLength < IpV4OptionBasicSecurity.OptionMinimumLength)
impossibleOptionTypes.Add(IpV4OptionType.BasicSecurity);
if (maximumOptionLength < IpV4OptionRoute.OptionMinimumLength)
......
......@@ -213,7 +213,7 @@ namespace PcapDotNet.Packets.Dns
private static void DnsTypeToByteOffsetAndMask(out int byteOffset, out byte mask, DnsType dnsType)
{
byteOffset = (ushort)dnsType / 8;
mask = (byte)(1 << ((ushort)dnsType % 8));
mask = (byte)(0x80 >> ((ushort)dnsType % 8));
}
}
}
\ No newline at end of file
......@@ -56,11 +56,29 @@ namespace PcapDotNet.Packets.IpV4
/// </summary>
NoOperation = 1,
/// <summary>
/// Record Route.
/// Used to trace the route an internet datagram takes.
/// </summary>
RecordRoute = 7,
/// <summary>
/// MTU Probe.
/// RFCs 1063, 1191.
/// Obsoleted.
/// </summary>
MtuProbe = 11,
/// <summary>
/// Quick Start (QS). RFC 4782.
/// </summary>
QuickStart = 25,
/// <summary>
/// Internet Timestamp.
/// </summary>
InternetTimestamp = 68,
/// <summary>
/// Traceroute Using an IP Option.
/// RFC 1393.
......@@ -85,23 +103,12 @@ namespace PcapDotNet.Packets.IpV4
/// </summary>
StrictSourceRouting = 137,
/// <summary>
/// Record Route.
/// Used to trace the route an internet datagram takes.
/// </summary>
RecordRoute = 7,
/// <summary>
/// Stream ID.
/// Used to carry the stream identifier.
/// </summary>
StreamIdentifier = 136,
/// <summary>
/// Internet Timestamp.
/// </summary>
InternetTimestamp = 68,
/// <summary>
/// Router Alert Option (RFC 2113).
/// </summary>
......
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