diff --git a/source/Cosmos.System2/Network/IPv4/ICMPPacket.cs b/source/Cosmos.System2/Network/IPv4/ICMPPacket.cs index 9ebaa3e92..1296b71d6 100644 --- a/source/Cosmos.System2/Network/IPv4/ICMPPacket.cs +++ b/source/Cosmos.System2/Network/IPv4/ICMPPacket.cs @@ -2,13 +2,33 @@ namespace Cosmos.System.Network.IPv4 { + /// + /// ICMPPacket class. See also: . + /// internal class ICMPPacket : IPPacket { + /// + /// Packet type. + /// protected byte icmpType; + /// + /// Packet code. + /// protected byte icmpCode; + /// + /// Packet CRC. + /// protected ushort icmpCRC; + /// + /// Received reply. + /// public static ICMPEchoReply recvd_reply; + /// + /// Create new inctanse of the class. + /// + /// Packet data. + /// Thrown if packetData is invalid. internal static void ICMPHandler(byte[] packetData) { NetworkStack.debugger.Send("ICMP Handler called"); @@ -38,16 +58,27 @@ namespace Cosmos.System.Network.IPv4 new ICMPPacket(); } + /// + /// Create new inctanse of the class. + /// internal ICMPPacket() : base() { } + /// + /// Create new inctanse of the class. + /// + /// Raw data. internal ICMPPacket(byte[] rawData) : base(rawData) { } + /// + /// Init ICMPPacket fields.1 + /// + /// Thrown if RawData is invalid or null. protected override void initFields() { //Sys.Console.WriteLine("ICMPPacket.initFields() called;"); @@ -57,6 +88,17 @@ namespace Cosmos.System.Network.IPv4 icmpCRC = (ushort)((RawData[DataOffset + 2] << 8) | RawData[DataOffset + 3]); } + /// + /// Create new inctanse of the class. + /// + /// Source address. + /// Destination address. + /// Type. + /// Code. + /// ID. + /// SEQ. + /// Data size. + /// Thrown if RawData is invalid or null. internal ICMPPacket(Address source, Address dest, byte type, byte code, ushort id, ushort seq, ushort icmpDataSize) : base(icmpDataSize, 1, source, dest, 0x00) { @@ -75,6 +117,11 @@ namespace Cosmos.System.Network.IPv4 initFields(); } + /// + /// Calculate ICMP CRC3. + /// + /// Lenght. + /// protected ushort CalcICMPCRC(ushort length) { return CalcOcCRC(DataOffset, length); @@ -108,10 +155,17 @@ namespace Cosmos.System.Network.IPv4 protected ushort icmpID; protected ushort icmpSequence; + /// + /// Create new inctanse of the class. + /// internal ICMPEchoRequest() { } + /// + /// Create new inctanse of the class. + /// + /// Raw data. internal ICMPEchoRequest(byte[] rawData) : base(rawData) { @@ -151,20 +205,34 @@ namespace Cosmos.System.Network.IPv4 internal ushort ICMP_ID => icmpID; internal ushort ICMP_Sequence => icmpSequence; + /// + /// To string. + /// + /// string value. public override string ToString() { return "ICMP Echo Request Src=" + SourceIP + ", Dest=" + DestinationIP + ", ID=" + icmpID + ", Sequence=" + icmpSequence; } } + /// + /// ICMPEchoReply class. See also: . + /// internal class ICMPEchoReply : ICMPPacket { protected ushort icmpID; protected ushort icmpSequence; + /// + /// Create new inctanse of the class. + /// internal ICMPEchoReply() { } + /// + /// Create new inctanse of the class. + /// + /// Raw data. internal ICMPEchoReply(byte[] rawData) : base(rawData) { @@ -178,6 +246,10 @@ namespace Cosmos.System.Network.IPv4 new ICMPEchoReply(); } + /// + /// Init ICMPEchoReply fields. + /// + /// Thrown if RawData is invalid or null. protected override void initFields() { //Sys.Console.WriteLine("ICMPEchoReply.initFields() called;"); @@ -186,6 +258,11 @@ namespace Cosmos.System.Network.IPv4 icmpSequence = (ushort)((RawData[DataOffset + 6] << 8) | RawData[DataOffset + 7]); } + /// + /// Create new inctanse of the class. + /// + /// ICMP echo request. + /// Thrown if RawData is invalid or null. internal ICMPEchoReply(ICMPEchoRequest request) : base(request.DestinationIP, request.SourceIP, 0, 0, request.ICMP_ID, request.ICMP_Sequence, (ushort)(request.ICMP_DataLength + 8)) @@ -202,9 +279,19 @@ namespace Cosmos.System.Network.IPv4 RawData[DataOffset + 3] = (byte)((icmpCRC >> 0) & 0xFF); } + /// + /// Get ICMP ID. + /// internal UInt16 ICMP_ID => icmpID; + /// + /// Get ICMP sequence. + /// internal UInt16 ICMP_Sequence => icmpSequence; + /// + /// To string. + /// + /// string value. public override string ToString() { return "ICMP Echo Reply Src=" + SourceIP + ", Dest=" + DestinationIP + ", ID=" + icmpID + ", Sequence=" + icmpSequence;