bool LogAssertPrefix6(PrefixedIPv6Address[] Manual, PrefixedIPv6Address address) { int Count = Manual.Where(NI => ((NI.PrefixLength == address.PrefixLength) && (NI.Address == address.Address))).Count(); string AdrText = null; foreach (PrefixedIPv6Address p in Manual) { if (AdrText != null) { AdrText += ", " + MyV6String(p); } else { AdrText = MyV6String(p); } } return (LogLog("Manual address(es): " + AdrText) & LogAssert( Count > 0, "No IP address in addresses set") && LogAssert( Count == 1, "More than one equal IP address in addresses set")); }
private bool ValidateIPAddress(PrefixedIPv6Address ip) { return(ValidateIPAddressCore(ip.Address, ip.PrefixLength, 128)); }
string MyV6String(PrefixedIPv6Address address) { return(address.Address + " [" + address.PrefixLength + "]"); }
NetworkInterface TurnOffDhcpIpv6() { BackupConnection(); NetworkInterface[] interfaces = GetNetworkInterfaces(); BeginStep("Check if DHCP must be turned off"); NetworkInterface ni = null; foreach (NetworkInterface n in interfaces) { if (n.IPv6 == null) { continue; } //if (!n.IPv6.Enabled) continue; if (n.IPv6.Config == null) { continue; } ni = n; break; } if (ni == null) { throw new AssertException("Appropriate network interface not found"); } PrefixedIPv6Address orig = null; if (ni.IPv6.Config.DHCP == IPv6DHCPConfiguration.Off) { LogStepEvent("DHCP is OFF"); StepPassed(); return(ni); } StepPassed(); NetworkInterfaceSetConfiguration configuration = new NetworkInterfaceSetConfiguration(); configuration.Enabled = true; configuration.EnabledSpecified = true; configuration.IPv6 = new IPv6NetworkInterfaceSetConfiguration(); configuration.IPv6.Enabled = true; configuration.IPv6.EnabledSpecified = true; configuration.IPv6.DHCP = IPv6DHCPConfiguration.Off; configuration.IPv6.DHCPSpecified = true; if (ni.IPv6.Config.FromDHCP != null && ni.IPv6.Config.FromDHCP.Length > 0) { configuration.IPv6.Manual = ni.IPv6.Config.FromDHCP; } SetIPConfiguration(ni.token, configuration); return(ni); }