Beispiel #1
0
        internal static void IPv4Handler(byte[] packetData)
        {
            IPPacket ip_packet = new IPPacket(packetData);

            //Sys.Console.WriteLine("Received IP Packet");
            //Sys.Console.WriteLine(ip_packet.ToString());
            if (ip_packet.SourceIP == null)
            {
                NetworkStack.debugger.Send("SourceIP null in IPv4Handler!");
            }
            ARPCache.Update(ip_packet.SourceIP, ip_packet.SourceMAC);

            if ((NetworkStack.AddressMap.ContainsKey(ip_packet.DestinationIP.Hash) == true) ||
                (ip_packet.DestinationIP.address[3] == 255))
            {
                switch (ip_packet.Protocol)
                {
                case 1:
                    ICMPPacket.ICMPHandler(packetData);
                    break;

                case 6:
                    //TCPPacket.TCPHandler(packetData);
                    break;

                case 17:
                    UDPPacket.UDPHandler(packetData);
                    break;
                }
            }
        }
Beispiel #2
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 #3
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 #4
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 #5
0
 /// <summary>
 /// Receive data from packet.
 /// </summary>
 /// <param name="packet">Packet to receive.</param>
 /// <exception cref="OverflowException">Thrown on fatal error (contact support).</exception>
 /// <exception cref="Sys.IO.IOException">Thrown on IO error.</exception>
 public void ReceiveData(ICMPPacket packet)
 {
     rxBuffer.Enqueue(packet);
 }