Exemple #1
0
        internal ICMPEchoReply(ICMPEchoRequest request)
            : base(request.DestinationIP, request.SourceIP, 0, 0,
                   request.ICMP_ID, request.ICMP_Sequence, (UInt16)(request.ICMP_DataLength + 8))
        {
            for (int b = 0; b < this.ICMP_DataLength; b++)
            {
                mRawData[this.dataOffset + 8 + b] = request.RawData[this.dataOffset + 8 + b];
            }

            mRawData[this.dataOffset + 2] = 0x00;
            mRawData[this.dataOffset + 3] = 0x00;
            icmpCRC = CalcICMPCRC((UInt16)(this.ICMP_DataLength + 8));
            mRawData[this.dataOffset + 2] = (byte)((icmpCRC >> 8) & 0xFF);
            mRawData[this.dataOffset + 3] = (byte)((icmpCRC >> 0) & 0xFF);
        }
Exemple #2
0
        internal static void ICMPHandler(byte[] packetData)
        {
            //ICMP Handler called
            ICMPPacket icmp_packet = new ICMPPacket(packetData);

            switch (icmp_packet.ICMP_Type)
            {
            case 0:
                recvd_reply = new ICMPEchoReply(packetData);
                //Received ICMP Echo reply from " + recvd_reply.SourceIP.ToString()
                break;

            case 8:
                ICMPEchoRequest request = new ICMPEchoRequest(packetData);
                //Received " + request.ToString()
                ICMPEchoReply reply = new ICMPEchoReply(request);
                //Sending ICMP Echo reply to " + reply.DestinationIP.ToString()
                OutgoingBuffer.AddPacket(reply);
                NetworkStack.Update();
                break;
            }
        }