Commit 88bbdf85 authored by Brickner_cp's avatar Brickner_cp

ICMP

parent 18b85375
...@@ -86,10 +86,6 @@ namespace PcapDotNet.Packets.Test ...@@ -86,10 +86,6 @@ namespace PcapDotNet.Packets.Test
IcmpMessageType icmpMessageType = random.NextEnum<IcmpMessageType>(); IcmpMessageType icmpMessageType = random.NextEnum<IcmpMessageType>();
Packet packet; Packet packet;
switch (icmpMessageType)
{
case IcmpMessageType.DestinationUnreachable:
IcmpCodeDestinationUnrechable code = random.NextEnum<IcmpCodeDestinationUnrechable>();
byte icmpIpV4TypeOfService = random.NextByte(); byte icmpIpV4TypeOfService = random.NextByte();
ushort icmpIpV4Identification = random.NextUShort(); ushort icmpIpV4Identification = random.NextUShort();
byte icmpIpV4Ttl = random.NextByte(); byte icmpIpV4Ttl = random.NextByte();
...@@ -99,6 +95,10 @@ namespace PcapDotNet.Packets.Test ...@@ -99,6 +95,10 @@ namespace PcapDotNet.Packets.Test
IpV4Address icmpIpV4Destination = new IpV4Address(random.NextUInt()); IpV4Address icmpIpV4Destination = new IpV4Address(random.NextUInt());
IpV4Options icmpIpV4Options = random.NextIpV4Options(); IpV4Options icmpIpV4Options = random.NextIpV4Options();
Datagram icmpIpV4Payload = random.NextDatagram(random.Next(200)); Datagram icmpIpV4Payload = random.NextDatagram(random.Next(200));
switch (icmpMessageType)
{
case IcmpMessageType.DestinationUnreachable:
IcmpCodeDestinationUnrechable code = random.NextEnum<IcmpCodeDestinationUnrechable>();
packet = PacketBuilder.EthernetIpV4IcmpDestinationUnreachable(DateTime.Now, packet = PacketBuilder.EthernetIpV4IcmpDestinationUnreachable(DateTime.Now,
ethernetSource, ethernetDestination, ethernetSource, ethernetDestination,
...@@ -113,6 +113,37 @@ namespace PcapDotNet.Packets.Test ...@@ -113,6 +113,37 @@ namespace PcapDotNet.Packets.Test
icmpIpV4Options, icmpIpV4Payload); icmpIpV4Options, icmpIpV4Payload);
break; break;
// case IcmpMessageType.TimeExceeded:
// PacketBuilder.EthernetIpV4IcmpTimeExceeded(DateTime.Now,
// ethernetSource, ethernetDestination,
// ipV4TypeOfService, ipV4Identification, ipV4Fragmentation,
// ipV4Ttl,
// ipV4Source, ipV4Destination, ipV4Options,
// code,
// icmpIpV4TypeOfService, icmpIpV4Identification,
// icmpIpV4Fragmentation,
// icmpIpV4Ttl, icmpIpV4Protocol, icmpIpV4Source,
// icmpIpV4Destination,
// icmpIpV4Options, icmpIpV4Payload);
// case IcmpMessageType.ParameterProblem:
// case IcmpMessageType.SourceQuench:
// case IcmpMessageType.Redirect:
// case IcmpMessageType.Echo:
// case IcmpMessageType.EchoReply:
// case IcmpMessageType.Timestamp:
// case IcmpMessageType.TimestampReply:
// case IcmpMessageType.InformationRequest:
// case IcmpMessageType.InformationReply:
// case IcmpMessageType.RouterAdvertisement:
// case IcmpMessageType.RouterSolicitation:
// case IcmpMessageType.AddressMaskRequest:
// case IcmpMessageType.AddressMaskReply:
// case IcmpMessageType.Traceroute:
// case IcmpMessageType.ConversionFailed:
// case IcmpMessageType.DomainNameRequest:
// case IcmpMessageType.DomainNameReply:
// case IcmpMessageType.SecurityFailures:
default: default:
throw new InvalidOperationException("Invalid icmpMessageType " + icmpMessageType); throw new InvalidOperationException("Invalid icmpMessageType " + icmpMessageType);
} }
......
namespace PcapDotNet.Packets.Icmp
{
/// <summary>
/// RFC 792.
/// </summary>
public enum IcmpCodeDestinationUnrechable : byte
{
/// <summary>
/// If, according to the information in the gateway's routing tables,
/// the network specified in the internet destination field of a datagram is unreachable,
/// e.g., the distance to the network is infinity,
/// the gateway may send a destination unreachable message to the internet source host of the datagram.
/// </summary>
DestinationUnreachableNetUnreachable = 0x00,
/// <summary>
/// RFC 792.
/// In some networks, the gateway may be able to determine if the internet destination host is unreachable.
/// Gateways in these networks may send destination unreachable messages to the source host when the destination host is unreachable.
/// </summary>
DestinationUnreachableHostUnreachable = 0x01,
/// <summary>
/// RFC 792.
/// If, in the destination host, the IP module cannot deliver the datagram because the indicated protocol module is not active,
/// the destination host may send a destination unreachable message to the source host.
/// </summary>
DestinationUnreachableProtocolUnreachable = 0x02,
/// <summary>
/// RFC 792.
/// If, in the destination host, the IP module cannot deliver the datagram because the indicated process port is not active,
/// the destination host may send a destination unreachable message to the source host.
/// </summary>
DestinationUnreachablePortUnreachable = 0x03,
/// <summary>
/// RFC 792.
/// A datagram must be fragmented to be forwarded by a gateway yet the Don't Fragment flag is on.
/// In this case the gateway must discard the datagram and may return a destination unreachable message.
/// </summary>
DestinationUnreachableFragmentationNeededAndDontFragmentSet = 0x04,
/// <summary>
/// RFC 792.
/// </summary>
DestinationUnreachableSourceRouteFailed = 0x05,
}
}
\ No newline at end of file
...@@ -312,6 +312,5 @@ namespace PcapDotNet.Packets.Icmp ...@@ -312,6 +312,5 @@ namespace PcapDotNet.Packets.Icmp
/// RFC 2521. /// RFC 2521.
/// </summary> /// </summary>
SecurityFailures = 0x28, SecurityFailures = 0x28,
} }
} }
\ No newline at end of file
namespace PcapDotNet.Packets.Icmp namespace PcapDotNet.Packets.Icmp
{ {
/// <summary>
/// RFC 792.
/// </summary>
public enum IcmpCodeDestinationUnrechable : byte
{
/// <summary>
/// If, according to the information in the gateway's routing tables,
/// the network specified in the internet destination field of a datagram is unreachable,
/// e.g., the distance to the network is infinity,
/// the gateway may send a destination unreachable message to the internet source host of the datagram.
/// </summary>
DestinationUnreachableNetUnreachable = 0x00,
/// <summary>
/// RFC 792.
/// In some networks, the gateway may be able to determine if the internet destination host is unreachable.
/// Gateways in these networks may send destination unreachable messages to the source host when the destination host is unreachable.
/// </summary>
DestinationUnreachableHostUnreachable = 0x01,
/// <summary>
/// RFC 792.
/// If, in the destination host, the IP module cannot deliver the datagram because the indicated protocol module is not active,
/// the destination host may send a destination unreachable message to the source host.
/// </summary>
DestinationUnreachableProtocolUnreachable = 0x02,
/// <summary>
/// RFC 792.
/// If, in the destination host, the IP module cannot deliver the datagram because the indicated process port is not active,
/// the destination host may send a destination unreachable message to the source host.
/// </summary>
DestinationUnreachablePortUnreachable = 0x03,
/// <summary>
/// RFC 792.
/// A datagram must be fragmented to be forwarded by a gateway yet the Don't Fragment flag is on.
/// In this case the gateway must discard the datagram and may return a destination unreachable message.
/// </summary>
DestinationUnreachableFragmentationNeededAndDontFragmentSet = 0x04,
/// <summary>
/// RFC 792.
/// </summary>
DestinationUnreachableSourceRouteFailed = 0x05,
}
public enum IcmpMessageTypeAndCode : ushort public enum IcmpMessageTypeAndCode : ushort
{ {
/// <summary> /// <summary>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion> <ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8A184AF5-E46C-482C-81A3-76D8CE290104}</ProjectGuid> <ProjectGuid>{8A184AF5-E46C-482C-81A3-76D8CE290104}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
<Compile Include="Ethernet\EthernetType.cs" /> <Compile Include="Ethernet\EthernetType.cs" />
<Compile Include="Ethernet\MacAddress.cs" /> <Compile Include="Ethernet\MacAddress.cs" />
<Compile Include="Icmp\IcmpAddressMaskDatagram.cs" /> <Compile Include="Icmp\IcmpAddressMaskDatagram.cs" />
<Compile Include="Icmp\IcmpCodeDestinationUnrechable.cs" />
<Compile Include="Icmp\IcmpConversionFailedDatagram.cs" /> <Compile Include="Icmp\IcmpConversionFailedDatagram.cs" />
<Compile Include="Icmp\IcmpDatagram.cs" /> <Compile Include="Icmp\IcmpDatagram.cs" />
<Compile Include="Icmp\IcmpEchoDatagram.cs" /> <Compile Include="Icmp\IcmpEchoDatagram.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