Beispiel #1
0
 internal static void AddPacket(IPPacket packet)
 {
     ensureQueueExists();
     NetworkDevice nic = Config.FindInterface(packet.SourceIP);
     packet.SourceMAC = nic.MACAddress;
     queue.Add(new BufferEntry(nic, packet));
 }
Beispiel #2
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)
            {
                global::System.Console.WriteLine("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:
                    //    IPv4_TCPHandler(packetData);
                    //    break;
                    case 17:
                        UDPPacket.UDPHandler(packetData);
                        break;
                }
            }
        }
Beispiel #3
0
 public BufferEntry(NetworkDevice nic, IPPacket packet)
 {
     this.NIC = nic;
     this.Packet = packet;
     this.Status = EntryStatus.ADDED;
 }