Пример #1
0
        private static void DoPing(string[] args)
        {
            if (args.Length == 1)
            {
                IPv6Address iPAddress = new IPv6Address(System.Net.IPAddress.Parse(args[0]).GetAddressBytes());
                short       replyTime = Icmpv6.SendEchoRequest(iPAddress);

                if (replyTime > -1)
                {
                    Console.WriteLine("8 bytes from {0}: icmp_seq=0 hlim=0 time={1}ms", iPAddress.ToString(), replyTime);
                }
            }
        }
Пример #2
0
        //internal static void IPv6PacketHandler(object sender, byte[] frame)
        internal static void IPv6PacketHandler(byte[] frame)
        {
            IPv6Packet ipv6Packet = new IPv6Packet();

            ipv6Packet.FromBytes(frame);

            if (ipv6Packet.NextHeader == IPv6Protocol.ICMPv6)
            {
                Icmpv6.PacketHandler(ipv6Packet);
            }
            else if (ipv6Packet.NextHeader == IPv6Protocol.Udp)
            {
                var udpDatagram = ipv6Packet.Payload as UdpDatagram;

                var udpClient = udpClients[udpDatagram.DestinationPort] as Socket;

                if (udpClient == null)
                {
                    return;
                }

                udpClient.PacketHandler(ipv6Packet);
            }
        }