public async Task IPInfoTest_AccessAllIPv6Properties_NoErrors() { await Task.Run(() => { foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) { _log.WriteLine("Nic: " + nic.Name); IPInterfaceProperties ipProperties = nic.GetIPProperties(); _log.WriteLine("IPv6 Properties:"); IPv6InterfaceProperties ipv6Properties = ipProperties.GetIPv6Properties(); if (ipv6Properties == null) { _log.WriteLine("IPv6Properties is null"); continue; } _log.WriteLine("Index: " + ipv6Properties.Index); _log.WriteLine("Mtu: " + ipv6Properties.Mtu); _log.WriteLine("Scope: " + ipv6Properties.GetScopeId(ScopeLevel.Link)); } }).WaitAsync(TestHelper.PassingTestTimeout); }
public async Task IPv6ScopeId_AccessAllValues_Success() { await Task.Run(() => { Assert.True(Capability.IPv6Support()); foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) { _log.WriteLine("Nic: " + nic.Name); if (!nic.Supports(NetworkInterfaceComponent.IPv6)) { continue; } IPInterfaceProperties ipProperties = nic.GetIPProperties(); IPv6InterfaceProperties ipv6Properties = ipProperties.GetIPv6Properties(); Array values = Enum.GetValues(typeof(ScopeLevel)); foreach (ScopeLevel level in values) { _log.WriteLine("-- Level: " + level + "; " + ipv6Properties.GetScopeId(level)); } } }).WaitAsync(TestHelper.PassingTestTimeout); }
[PlatformSpecific(PlatformID.Windows)] // Linux and OSX do not support some of these public void IPInfoTest_AccessAllIPv6Properties_NoErrors() { foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) { _log.WriteLine("Nic: " + nic.Name); IPInterfaceProperties ipProperties = nic.GetIPProperties(); _log.WriteLine("IPv6 Properties:"); if (!nic.Supports(NetworkInterfaceComponent.IPv6)) { var nie = Assert.Throws <NetworkInformationException>(() => ipProperties.GetIPv6Properties()); Assert.Equal(SocketError.ProtocolNotSupported, (SocketError)nie.ErrorCode); continue; } IPv6InterfaceProperties ipv6Properties = ipProperties.GetIPv6Properties(); if (ipv6Properties == null) { _log.WriteLine("IPv6Properties is null"); continue; } _log.WriteLine("Index: " + ipv6Properties.Index); _log.WriteLine("Mtu: " + ipv6Properties.Mtu); _log.WriteLine("ScopeID: " + ipv6Properties.GetScopeId(ScopeLevel.Link)); } }
[PlatformSpecific(PlatformID.Windows)] // Linux and OSX do not support GetScopeId public void IPv6ScopeId_AccessAllValues_Success() { Assert.True(Capability.IPv6Support()); foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) { _log.WriteLine("Nic: " + nic.Name); if (!nic.Supports(NetworkInterfaceComponent.IPv6)) { continue; } IPInterfaceProperties ipProperties = nic.GetIPProperties(); _log.WriteLine("- IPv6 Scope levels:"); IPv6InterfaceProperties ipv6Properties = ipProperties.GetIPv6Properties(); Array values = Enum.GetValues(typeof(ScopeLevel)); foreach (ScopeLevel level in values) { _log.WriteLine("-- Level: " + level + "; " + ipv6Properties.GetScopeId(level)); } } }
[PlatformSpecific(PlatformID.Windows)] // Linux and OSX do not support GetScopeId public void IPv6ScopeId_GetLinkLevel_MatchesIndex() { Assert.True(Capability.IPv6Support()); foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) { IPInterfaceProperties ipProperties = nic.GetIPProperties(); if (!nic.Supports(NetworkInterfaceComponent.IPv6)) { continue; } IPv6InterfaceProperties ipv6Properties = ipProperties.GetIPv6Properties(); // This is not officially guaranteed by Windows, but it's what gets used. Assert.Equal(ipv6Properties.Index, ipv6Properties.GetScopeId(ScopeLevel.Link)); } }
private static string FormatIPv6InterfaceProperties(IPv6InterfaceProperties ipv6Properties) { string result = string.Empty; if (ipv6Properties != null) { result += $" IPv6 properties:\n"; result += $" Index: {ipv6Properties.Index}\n"; result += $" MTU: {ipv6Properties.Mtu}\n"; try { result += $" Scope ID: {ipv6Properties.GetScopeId(ScopeLevel.None)}\n"; } catch (PlatformNotSupportedException) { } } return(result); }
public async Task IPv6ScopeId_GetLinkLevel_MatchesIndex() { await Task.Run(() => { Assert.True(Capability.IPv6Support()); foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) { IPInterfaceProperties ipProperties = nic.GetIPProperties(); if (!nic.Supports(NetworkInterfaceComponent.IPv6)) { continue; } IPv6InterfaceProperties ipv6Properties = ipProperties.GetIPv6Properties(); // This is not officially guaranteed by Windows, but it's what gets used. Assert.Equal(ipv6Properties.Index, ipv6Properties.GetScopeId(ScopeLevel.Link)); } }).WaitAsync(TestHelper.PassingTestTimeout); }
public void IPInfoTest_AccessAllIPv6Properties_NoErrors() { foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) { _log.WriteLine("Nic: " + nic.Name); IPInterfaceProperties ipProperties = nic.GetIPProperties(); _log.WriteLine("IPv6 Properties:"); IPv6InterfaceProperties ipv6Properties = ipProperties.GetIPv6Properties(); if (ipv6Properties == null) { _log.WriteLine("IPv6Properties is null"); continue; } _log.WriteLine("Index: " + ipv6Properties.Index); _log.WriteLine("Mtu: " + ipv6Properties.Mtu); Assert.Throws <PlatformNotSupportedException>(() => ipv6Properties.GetScopeId(ScopeLevel.Link)); } }
/// <inheritdoc /> public long GetScopeId(ScopeLevel scopeLevel) { return(_props.GetScopeId(scopeLevel)); }