Beispiel #1
0
        /// <summary>
        /// Received reply.
        /// </summary>

        /// <summary>
        /// Create new instance of the <see cref="ICMPPacket"/> class.
        /// </summary>
        /// <param name="packetData">Packet data.</param>
        /// <exception cref="ArgumentException">Thrown if packetData is invalid.</exception>
        internal static void ICMPHandler(byte[] packetData)
        {
            Global.mDebugger.Send("ICMP Handler called");
            var icmp_packet = new ICMPPacket(packetData);

            switch (icmp_packet.ICMPType)
            {
            case 0:
                var receiver = ICMPClient.GetClient(icmp_packet.SourceIP.Hash);
                if (receiver != null)
                {
                    receiver.ReceiveData(icmp_packet);
                }
                Global.mDebugger.Send("Received ICMP Echo reply from " + icmp_packet.SourceIP.ToString());
                break;

            case 8:
                var request = new ICMPEchoRequest(packetData);
                var reply   = new ICMPEchoReply(request);
                Global.mDebugger.Send("Sending ICMP Echo reply to " + reply.DestinationIP.ToString());
                OutgoingBuffer.AddPacket(reply);
                NetworkStack.Update();
                break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Send ICMP Echo
        /// </summary>
        public void SendEcho()
        {
            Address         source  = IPConfig.FindNetwork(destination);
            ICMPEchoRequest request = new ICMPEchoRequest(source, destination, 0x0001, 0x50); //this is working

            OutgoingBuffer.AddPacket(request);                                                //Aura doesn't work when this is called.
            NetworkStack.Update();
        }
Beispiel #3
0
        /// <summary>
        /// Create new instance of the <see cref="ICMPEchoReply"/> class.
        /// </summary>
        /// <param name="request">ICMP echo request.</param>
        /// <exception cref="ArgumentException">Thrown if RawData is invalid or null.</exception>
        internal ICMPEchoReply(ICMPEchoRequest request)
            : base(request.DestinationIP, request.SourceIP, 0, 0, request.ICMPID, request.ICMPSequence, (ushort)(request.ICMPDataLength))
        {
            for (int b = 0; b < ICMPDataLength; b++)
            {
                RawData[DataOffset + 8 + b] = request.RawData[DataOffset + 8 + b];
            }

            RawData[DataOffset + 2] = 0x00;
            RawData[DataOffset + 3] = 0x00;
            icmpCRC = CalcICMPCRC((ushort)(ICMPDataLength + 8));
            RawData[DataOffset + 2] = (byte)((icmpCRC >> 8) & 0xFF);
            RawData[DataOffset + 3] = (byte)((icmpCRC >> 0) & 0xFF);
        }
Beispiel #4
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);
        }
Beispiel #5
0
 internal static void ICMPHandler(byte[] packetData)
 {
     ICMPPacket icmp_packet = new ICMPPacket(packetData);
     switch (icmp_packet.ICMP_Type)
     {
         case 0:
             ICMPEchoReply recvd_reply = new ICMPEchoReply(packetData);
             Sys.Console.WriteLine("Received ICMP Echo reply from " + recvd_reply.SourceIP.ToString());
             break;
         case 8:
             ICMPEchoRequest request = new ICMPEchoRequest(packetData);
             Sys.Console.WriteLine("Received " + request.ToString());
             ICMPEchoReply reply = new ICMPEchoReply(request);
             Sys.Console.WriteLine("Sending ICMP Echo reply to " + reply.DestinationIP.ToString());
             OutgoingBuffer.AddPacket(reply);
             break;
     }
 }
Beispiel #6
0
        internal static void ICMPHandler(byte[] packetData)
        {
            ICMPPacket icmp_packet = new ICMPPacket(packetData);

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

            case 8:
                ICMPEchoRequest request = new ICMPEchoRequest(packetData);
                Sys.Console.WriteLine("Received " + request.ToString());
                ICMPEchoReply reply = new ICMPEchoReply(request);
                Sys.Console.WriteLine("Sending ICMP Echo reply to " + reply.DestinationIP.ToString());
                OutgoingBuffer.AddPacket(reply);
                break;
            }
        }
Beispiel #7
0
        internal static void ICMPHandler(byte[] packetData)
        {
            NetworkStack.debugger.Send("ICMP Handler called");
            ICMPPacket icmp_packet = new ICMPPacket(packetData);

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

            case 8:
                ICMPEchoRequest request = new ICMPEchoRequest(packetData);
                NetworkStack.debugger.Send("Received " + request.ToString());
                ICMPEchoReply reply = new ICMPEchoReply(request);
                NetworkStack.debugger.Send("Sending ICMP Echo reply to " + reply.DestinationIP.ToString());
                OutgoingBuffer.AddPacket(reply);
                NetworkStack.Update();
                break;
            }
        }
Beispiel #8
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);
        }