コード例 #1
0
        private void AnalyzeICMPv6Packet(Packet packet)
        {
            if (!(packet.PayloadPacket.PayloadPacket is ICMPv6Packet))
            {
                return;
            }

            try
            {
                ICMPv6Types type = ((ICMPv6Packet)packet.PayloadPacket.PayloadPacket).Type;
                switch (type)
                {
                case ICMPv6Types.NeighborSolicitation:     // Neighbor solicitation
                    OnNewICMPv6Solicitation(new PacketEventArgs(packet));
                    break;

                case ICMPv6Types.NeighborAdvertisement:     // Neighbor advertisement
                    OnNewICMPv6Advertisement(new PacketEventArgs(packet));
                    break;
                }
            }
            catch (ArgumentOutOfRangeException)
            {
            }
        }
コード例 #2
0
        private static void AnalyzeICMPv6Packet(Packet packet)
        {
            if (!(packet.PayloadPacket.PayloadPacket is ICMPv6Packet))
            {
                return;
            }

            try
            {
                ICMPv6Types type = ((ICMPv6Packet)packet.PayloadPacket.PayloadPacket).Type;
                if (type == ICMPv6Types.NeighborAdvertisement)
                {
                    ushort payloadLen = ((IPv6Packet)packet.PayloadPacket).PayloadLength;
                    byte[] flags      = new byte[4];

                    flags[0] = (packet.PayloadPacket.PayloadPacket).Bytes[4];
                    flags[1] = (packet.PayloadPacket.PayloadPacket).Bytes[5];
                    flags[2] = (packet.PayloadPacket.PayloadPacket).Bytes[6];
                    flags[3] = (packet.PayloadPacket.PayloadPacket).Bytes[7];

                    Data.Neighbor neighbor = Program.CurrentProject.data.GetNeighbor(((EthernetPacket)packet).SourceHwAddress);
                    if (neighbor != null)
                    {
                        // Si el payload UDP es 24 bytes, y los flags son 0x40000000 (sol) puede ser un linux, y no un windows (0x60000000, sol ovr).
                        if ((flags[0] == 0x40) && (flags[1] == 0x00) && (flags[2] == 0x00) && (flags[3] == 0x00))
                        {
                            // Linux
                            if (neighbor.osPlatform == Data.Platform.Unknow)
                            {
                                neighbor.osPlatform = Data.Platform.Linux;
                            }
                        }
                        else if ((flags[0] == 0x60) && (flags[1] == 0x00) && (flags[2] == 0x00) && (flags[3] == 0x00))
                        {
                            // Windows
                            if (neighbor.osPlatform == Data.Platform.Unknow)
                            {
                                neighbor.osPlatform = Data.Platform.Windows;
                            }
                        }
                    }
                }
            }
            catch (ArgumentOutOfRangeException)
            {
            }
        }