Commit 2eef92c2 authored by Brickner_cp's avatar Brickner_cp

ICMP

parent bab1a144
namespace PcapDotNet.Packets.Icmp
{
/// <summary>
/// RFC 950.
/// <pre>
/// +-----+------+------+-----------------+
/// | Bit | 0-7 | 8-15 | 16-31 |
/// +-----+------+------+-----------------+
/// | 0 | Type | Code | Checksum |
/// +-----+------+------+-----------------+
/// | 32 | Identifier | Sequence Number |
/// +-----+-------------+-----------------+
/// | 64 | Address Mask |
/// +-----+-------------------------------+
/// </pre>
/// </summary>
public class IcmpAddressMaskReplyDatagram : IcmpAddressMaskRequestDatagram
{
internal IcmpAddressMaskReplyDatagram(byte[] buffer, int offset, int length)
......
......@@ -11,11 +11,11 @@ namespace PcapDotNet.Packets.Icmp
get { return IcmpMessageType.AddressMaskRequest; }
}
public override int Length
protected override int PayloadLength
{
get
{
return base.Length + IcmpAddressMaskRequestDatagram.PayloadLength;
return IcmpAddressMaskRequestDatagram.PayloadLength;
}
}
......
......@@ -208,6 +208,8 @@ namespace PcapDotNet.Packets.Icmp
return new IcmpSecurityFailuresDatagram(buffer, offset, length);
case IcmpMessageType.RouterSolicitation:
return new IcmpRouterSolicitationDatagram(buffer, offset, length);
case IcmpMessageType.DomainNameReply: // Domain Name Reply is unsupported
default:
return new IcmpUnknownDatagram(buffer, offset, length);
......
......@@ -24,9 +24,14 @@ namespace PcapDotNet.Packets.Icmp
get { return 0; }
}
public override int Length
public override sealed int Length
{
get { return IcmpDatagram.HeaderLength; }
get { return IcmpDatagram.HeaderLength + PayloadLength; }
}
protected virtual int PayloadLength
{
get { return 0; }
}
protected override sealed void Write(byte[] buffer, int offset)
......
......@@ -121,7 +121,7 @@ namespace PcapDotNet.Packets.Icmp
{
}
internal static int GetHeaderAdditionalLength(int numEntries)
internal static int GetPayloadLength(int numEntries)
{
return numEntries * DefaultAddressEntrySize * IpV4Address.SizeOf;
}
......
......@@ -24,11 +24,11 @@ namespace PcapDotNet.Packets.Icmp
}
}
public override int Length
protected override int PayloadLength
{
get
{
return base.Length + IcmpRouterAdvertisementDatagram.GetHeaderAdditionalLength(Entries.Count);
return IcmpRouterAdvertisementDatagram.GetPayloadLength(Entries.Count);
}
}
......
namespace PcapDotNet.Packets.Icmp
{
/// <summary>
/// RFC 1256.
/// <pre>
/// +-----+------+------+-----------+
/// | Bit | 0-7 | 8-15 | 16-31 |
/// +-----+------+------+-----------+
/// | 0 | Type | Code | Checksum |
/// +-----+------+------+-----------+
/// | 32 | reserved |
/// +-----+-------------------------+
/// </pre>
/// </summary>
public class IcmpRouterSolicitationDatagram : IcmpDatagram
{
internal IcmpRouterSolicitationDatagram(byte[] buffer, int offset, int length)
: base(buffer, offset, length)
{
}
public override ILayer ExtractLayer()
{
return new IcmpRouterSolicitationLayer();
}
}
}
\ No newline at end of file
using System;
namespace PcapDotNet.Packets.Icmp
{
/// <summary>
......@@ -30,6 +32,5 @@ namespace PcapDotNet.Packets.Icmp
Checksum = Checksum
};
}
}
}
\ No newline at end of file
......@@ -12,11 +12,11 @@ namespace PcapDotNet.Packets.Icmp
get { return IcmpMessageType.Timestamp; }
}
public override int Length
protected override int PayloadLength
{
get
{
return base.Length + IcmpTimestampDatagram.PayloadLength;
return IcmpTimestampDatagram.PayloadLength;
}
}
......
namespace PcapDotNet.Packets.Icmp
{
/// <summary>
/// RFC 792.
/// <pre>
/// +-----+------+------+-----------------+
/// | Bit | 0-7 | 8-15 | 16-31 |
/// +-----+------+------+-----------------+
/// | 0 | Type | Code | Checksum |
/// +-----+------+------+-----------------+
/// | 32 | Identifier | Sequence Number |
/// +-----+-------------+-----------------+
/// | 64 | Originate Timestamp |
/// +-----+-------------------------------+
/// | 96 | Receive Timestamp |
/// +-----+-------------------------------+
/// | 128 | Transmit Timestamp |
/// +-----+-------------------------------+
/// </pre>
/// </summary>
public class IcmpTimestampReplyDatagram : IcmpTimestampDatagram
{
internal IcmpTimestampReplyDatagram(byte[] buffer, int offset, int length)
......
......@@ -21,11 +21,11 @@ namespace PcapDotNet.Packets.Icmp
get { return IcmpMessageType.Traceroute; }
}
public override int Length
protected override int PayloadLength
{
get
{
return base.Length + IcmpTracerouteDatagram.PayloadLength;
return IcmpTracerouteDatagram.PayloadLength;
}
}
......
......@@ -19,14 +19,9 @@ namespace PcapDotNet.Packets.Icmp
};
}
protected override byte MinCodeValue
protected override bool CalculateIsValid()
{
get { return byte.MinValue; }
}
protected override byte MaxCodeValue
{
get { return byte.MaxValue; }
return false;
}
}
}
\ No newline at end of file
......@@ -15,6 +15,22 @@ namespace PcapDotNet.Packets.Icmp
}
}
public override byte CodeValue
{
get
{
return LayerCode;
}
}
protected override int PayloadLength
{
get
{
return Payload.Length;
}
}
protected override uint Value
{
get { return LayerValue; }
......
......@@ -99,6 +99,7 @@
<Compile Include="Icmp\IcmpRedirectLayer.cs" />
<Compile Include="Icmp\IcmpRouterAdvertisementEntry.cs" />
<Compile Include="Icmp\IcmpRouterAdvertisementLayer.cs" />
<Compile Include="Icmp\IcmpRouterSolicitationDatagram.cs" />
<Compile Include="Icmp\IcmpRouterSolicitationLayer.cs" />
<Compile Include="Icmp\IcmpSecurityFailuresLayer.cs" />
<Compile Include="Icmp\IcmpSourceQuenchDatagram.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