示例#1
0
        public IEnumerable <DHCPv6Listener> GetPossibleListeners()
        {
            List <DHCPv6Listener> result = new List <DHCPv6Listener>();

            foreach (var nic in NetworkInterface.GetAllNetworkInterfaces())
            {
                var properites = nic.GetIPProperties();
                if (properites == null)
                {
                    continue;
                }

                foreach (var ipAddress in properites.UnicastAddresses)
                {
                    if (ipAddress.Address.AddressFamily != System.Net.Sockets.AddressFamily.InterNetworkV6)
                    {
                        continue;
                    }

                    if (ipAddress.Address.IsIPv6LinkLocal == true)
                    {
                        continue;
                    }

                    DHCPv6Listener listener = DHCPv6Listener.FromNIC(nic, ipAddress.Address);
                    result.Add(listener);
                }
            }

            return(result);
        }
示例#2
0
        public void FromNIC()
        {
            foreach (var nic in NetworkInterface.GetAllNetworkInterfaces())
            {
                var properites = nic.GetIPProperties();
                if (properites == null)
                {
                    continue;
                }

                foreach (var ipAddress in properites.UnicastAddresses)
                {
                    if (ipAddress.Address.AddressFamily != System.Net.Sockets.AddressFamily.InterNetworkV6)
                    {
                        continue;
                    }

                    if (ipAddress.Address.IsIPv6LinkLocal == true)
                    {
                        continue;
                    }

                    DHCPv6Listener listener = DHCPv6Listener.FromNIC(nic, ipAddress.Address);
                    Assert.NotNull(listener);

                    Assert.Equal(nic.GetPhysicalAddress().GetAddressBytes(), listener.PhysicalAddress);
                    Assert.Equal(nic.Description, listener.Interfacename);
                    Assert.Equal(nic.Id, listener.PhysicalInterfaceId);
                    Assert.Equal(ipAddress.Address.GetAddressBytes(), listener.Address.GetBytes());
                    Assert.True(String.IsNullOrEmpty(listener.Name));
                }
            }
        }