Commit 6f5691e2 authored by Boaz Brickner's avatar Boaz Brickner

IGMP Version 0.

Handle super negative epoch time in Wireshark tests.
parent b5cc684e
...@@ -592,8 +592,13 @@ namespace PcapDotNet.Core.Test ...@@ -592,8 +592,13 @@ namespace PcapDotNet.Core.Test
case "frame.time_epoch": case "frame.time_epoch":
double timeEpoch = double.Parse(field.Show(), CultureInfo.InvariantCulture); double timeEpoch = double.Parse(field.Show(), CultureInfo.InvariantCulture);
// TODO: Remove this condition when https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=11744 is fixed.
if (timeEpoch >= int.MinValue)
{
DateTime fieldTimestamp = new DateTime(1970, 1, 1).AddSeconds(timeEpoch); DateTime fieldTimestamp = new DateTime(1970, 1, 1).AddSeconds(timeEpoch);
MoreAssert.IsInRange(fieldTimestamp.AddMilliseconds(-1), fieldTimestamp.AddMilliseconds(1), packet.Timestamp.ToUniversalTime(), "Timestamp"); MoreAssert.IsInRange(fieldTimestamp.AddMilliseconds(-1), fieldTimestamp.AddMilliseconds(1), packet.Timestamp.ToUniversalTime(),
"Timestamp");
}
break; break;
case "frame.cap_len": case "frame.cap_len":
......
...@@ -124,7 +124,7 @@ namespace PcapDotNet.Core.Test ...@@ -124,7 +124,7 @@ namespace PcapDotNet.Core.Test
break; break;
case "igmp.group_type": case "igmp.group_type":
field.AssertShowDecimal(igmpDatagram.IsPrivate); field.AssertShowDecimal((byte)igmpDatagram.CreateGroupRequestCode);
break; break;
case "igmp.mtrace.max_hops": case "igmp.mtrace.max_hops":
......
...@@ -121,7 +121,7 @@ namespace PcapDotNet.Packets.Test ...@@ -121,7 +121,7 @@ namespace PcapDotNet.Packets.Test
switch (igmpLayer.MessageTypeValue) switch (igmpLayer.MessageTypeValue)
{ {
case IgmpMessageType.CreateGroupRequestVersion0: case IgmpMessageType.CreateGroupRequestVersion0:
Assert.AreEqual(((IgmpCreateGroupRequestVersion0Layer)igmpLayer).IsPrivate, packet.Ethernet.Ip.Igmp.IsPrivate); Assert.AreEqual(((IgmpCreateGroupRequestVersion0Layer)igmpLayer).CreateGroupRequestCode, packet.Ethernet.Ip.Igmp.CreateGroupRequestCode);
break; break;
case IgmpMessageType.CreateGroupReplyVersion0: case IgmpMessageType.CreateGroupReplyVersion0:
...@@ -519,7 +519,7 @@ namespace PcapDotNet.Packets.Test ...@@ -519,7 +519,7 @@ namespace PcapDotNet.Packets.Test
{ {
Packet packet = PacketBuilder.Build(DateTime.Now, new EthernetLayer(), new IpV4Layer(), new IgmpQueryVersion1Layer()); Packet packet = PacketBuilder.Build(DateTime.Now, new EthernetLayer(), new IpV4Layer(), new IgmpQueryVersion1Layer());
Assert.IsTrue(packet.IsValid); Assert.IsTrue(packet.IsValid);
Assert.IsFalse(packet.Ethernet.IpV4.Igmp.IsPrivate); Assert.AreEqual(IgmpVersion0CreateGroupRequestCode.Private, packet.Ethernet.IpV4.Igmp.CreateGroupRequestCode);
} }
[TestMethod] [TestMethod]
......
...@@ -36,7 +36,7 @@ namespace PcapDotNet.Packets.TestUtils ...@@ -36,7 +36,7 @@ namespace PcapDotNet.Packets.TestUtils
case IgmpMessageType.CreateGroupRequestVersion0: case IgmpMessageType.CreateGroupRequestVersion0:
return new IgmpCreateGroupRequestVersion0Layer return new IgmpCreateGroupRequestVersion0Layer
{ {
IsPrivate = random.NextBool(), CreateGroupRequestCode = random.NextEnum<IgmpVersion0CreateGroupRequestCode>(),
Identifier = identifier, Identifier = identifier,
}; };
......
...@@ -19,7 +19,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -19,7 +19,7 @@ namespace PcapDotNet.Packets.Igmp
/// <summary> /// <summary>
/// Indicates if the new host group is to be private or public. /// Indicates if the new host group is to be private or public.
/// </summary> /// </summary>
public bool IsPrivate { get; set; } public IgmpVersion0CreateGroupRequestCode CreateGroupRequestCode { get; set; }
/// <summary> /// <summary>
/// Contains a value to distinguish the request from other requests by the same host. /// Contains a value to distinguish the request from other requests by the same host.
...@@ -44,7 +44,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -44,7 +44,7 @@ namespace PcapDotNet.Packets.Igmp
internal override byte CodeValue internal override byte CodeValue
{ {
get { return IsPrivate.ToByte(); } get { return (byte)CreateGroupRequestCode; }
} }
......
...@@ -281,13 +281,13 @@ namespace PcapDotNet.Packets.Igmp ...@@ -281,13 +281,13 @@ namespace PcapDotNet.Packets.Igmp
/// <summary> /// <summary>
/// In IGMP version 0 Create Group Request message, indicates if the new host group is to be private or public. /// In IGMP version 0 Create Group Request message, indicates if the new host group is to be private or public.
/// </summary> /// </summary>
public bool IsPrivate public IgmpVersion0CreateGroupRequestCode CreateGroupRequestCode
{ {
get get
{ {
if (MessageType != IgmpMessageType.CreateGroupRequestVersion0) if (MessageType != IgmpMessageType.CreateGroupRequestVersion0)
throw new InvalidOperationException(System.Reflection.MethodBase.GetCurrentMethod().Name + " can only be accessed for CreateGroupRequestVersion0."); throw new InvalidOperationException(System.Reflection.MethodBase.GetCurrentMethod().Name + " can only be accessed for CreateGroupRequestVersion0.");
return ReadBool(Offset.Code, Mask.Code); return (IgmpVersion0CreateGroupRequestCode)this[Offset.Code];
} }
} }
...@@ -628,7 +628,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -628,7 +628,7 @@ namespace PcapDotNet.Packets.Igmp
case IgmpMessageType.CreateGroupRequestVersion0: case IgmpMessageType.CreateGroupRequestVersion0:
return new IgmpCreateGroupRequestVersion0Layer return new IgmpCreateGroupRequestVersion0Layer
{ {
IsPrivate = IsPrivate, CreateGroupRequestCode = CreateGroupRequestCode,
Identifier = Identifier, Identifier = Identifier,
}; };
......
namespace PcapDotNet.Packets.Igmp
{
/// <summary>
/// RFC 988.
/// In an IGMP version 0 Create Group Request message, the code field indicates if the new host group is to be public or private.
/// </summary>
public enum IgmpVersion0CreateGroupRequestCode : byte
{
/// <summary>
/// The new host group is to be public.
/// </summary>
Public = 0,
/// <summary>
/// The new host group is to be private.
/// </summary>
Private = 1,
}
}
\ No newline at end of file
...@@ -2,7 +2,7 @@ namespace PcapDotNet.Packets.Igmp ...@@ -2,7 +2,7 @@ namespace PcapDotNet.Packets.Igmp
{ {
/// <summary> /// <summary>
/// RFC 988. /// RFC 988.
/// In an IGMP version 0 Reply message, specifies the outcome of the request: /// In an IGMP version 0 Reply message, specifies the outcome of the request.
/// </summary> /// </summary>
public enum IgmpVersion0ReplyCode : byte public enum IgmpVersion0ReplyCode : byte
{ {
......
...@@ -313,6 +313,7 @@ ...@@ -313,6 +313,7 @@
<Compile Include="Igmp\IgmpReportVersion2Layer.cs" /> <Compile Include="Igmp\IgmpReportVersion2Layer.cs" />
<Compile Include="Igmp\IgmpReportVersion3Layer.cs" /> <Compile Include="Igmp\IgmpReportVersion3Layer.cs" />
<Compile Include="Igmp\IgmpRequestVersion0Layer.cs" /> <Compile Include="Igmp\IgmpRequestVersion0Layer.cs" />
<Compile Include="Igmp\IgmpVersion0CreateGroupRequestCode.cs" />
<Compile Include="Igmp\IgmpVersion0Layer.cs" /> <Compile Include="Igmp\IgmpVersion0Layer.cs" />
<Compile Include="Igmp\IgmpVersion1PlusLayer.cs" /> <Compile Include="Igmp\IgmpVersion1PlusLayer.cs" />
<Compile Include="Igmp\IgmpVersion1PlusSimpleLayer.cs" /> <Compile Include="Igmp\IgmpVersion1PlusSimpleLayer.cs" />
......
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