Пример #1
0
        private static void IPv4_ICMPHandler(byte[] packetData)
        {
            ICMP.ICMPPacket icmp_packet = new ICMP.ICMPPacket(packetData);
            switch (icmp_packet.ICMP_Type)
            {
            case 0:
                ICMP.ICMPEchoReply recvd_reply = new ICMP.ICMPEchoReply(packetData);
                Console.WriteLine("Received ICMP Echo reply from " + recvd_reply.SourceIP.ToString());
                break;

            case 8:
                ICMP.ICMPEchoRequest request = new ICMP.ICMPEchoRequest(packetData);
                ICMP.ICMPEchoReply   reply   = new ICMP.ICMPEchoReply(request);
                Console.WriteLine("Sending ICMP Echo reply to " + reply.DestinationIP.ToString());
                TCPIP.IPv4OutgoingBuffer.AddPacket(reply);
                break;
            }
        }
Пример #2
0
 private static void IPv4_ICMPHandler(byte[] packetData)
 {
     ICMP.ICMPPacket icmp_packet = new ICMP.ICMPPacket(packetData);
     switch (icmp_packet.ICMP_Type)
     {
         case 0:
             ICMP.ICMPEchoReply recvd_reply = new ICMP.ICMPEchoReply(packetData);
             Console.WriteLine("Received ICMP Echo reply from " + recvd_reply.SourceIP.ToString());
             break;
         case 8:
             ICMP.ICMPEchoRequest request = new ICMP.ICMPEchoRequest(packetData);
             ICMP.ICMPEchoReply reply = new ICMP.ICMPEchoReply(request);
             Console.WriteLine("Sending ICMP Echo reply to " + reply.DestinationIP.ToString());
             TCPIP.IPv4OutgoingBuffer.AddPacket(reply);
             break;
     }
 }