You've already forked linux-packaging-mono
Imported Upstream version 5.8.0.22
Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
parent
5f4a27cc8a
commit
7d05485754
@ -85,4 +85,7 @@
|
||||
<data name="net_ipv6_not_installed" xml:space="preserve">
|
||||
<value>IPv6 is not installed.</value>
|
||||
</data>
|
||||
<data name="net_ping_not_supported_uwp" xml:space="preserve">
|
||||
<value>Ping functionality is not currently supported in UWP.</value>
|
||||
</data>
|
||||
</root>
|
@ -12,6 +12,9 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(TargetGroup)' == 'uap'">
|
||||
<NoWarn>$(NoWarn);414</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="System\Net\NetworkInformation\IPStatus.cs" />
|
||||
<Compile Include="System\Net\NetworkInformation\NetEventSource.Ping.cs" />
|
||||
@ -88,8 +91,13 @@
|
||||
<Link>Common\Interop\Unix\System.Native\Interop.SocketAddress.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(TargetsWindows)' == 'true'">
|
||||
<ItemGroup Condition="'$(TargetsWindows)' == 'true' And '$(TargetGroup)' != 'uap'">
|
||||
<Compile Include="System\Net\NetworkInformation\Ping.Windows.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetsWindows)' == 'true' And '$(TargetGroup)' == 'uap'">
|
||||
<Compile Include="System\Net\NetworkInformation\Ping.Windows.Uap.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
|
||||
<!-- System.Net Common -->
|
||||
<Compile Include="$(CommonPath)\System\Net\SocketAddressPal.Windows.cs">
|
||||
<Link>Common\System\Net\SocketAddressPal.Windows.cs</Link>
|
||||
@ -152,4 +160,4 @@
|
||||
<Reference Include="System.IO.FileSystem" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
@ -16,7 +16,8 @@ namespace System.Net.NetworkInformation
|
||||
public partial class Ping
|
||||
{
|
||||
private const int IcmpHeaderLengthInBytes = 8;
|
||||
private const int IpHeaderLengthInBytes = 20;
|
||||
private const int MinIpHeaderLengthInBytes = 20;
|
||||
private const int MaxIpHeaderLengthInBytes = 60;
|
||||
[ThreadStatic]
|
||||
private static Random t_idGenerator;
|
||||
|
||||
@ -69,9 +70,9 @@ namespace System.Net.NetworkInformation
|
||||
socket.SendTimeout = timeout;
|
||||
// Setting Socket.DontFragment and .Ttl is not supported on Unix, so ignore the PingOptions parameter.
|
||||
|
||||
int ipHeaderLength = isIpv4 ? IpHeaderLengthInBytes : 0;
|
||||
int ipHeaderLength = isIpv4 ? MinIpHeaderLengthInBytes : 0;
|
||||
await socket.SendToAsync(new ArraySegment<byte>(sendBuffer), SocketFlags.None, endPoint).ConfigureAwait(false);
|
||||
byte[] receiveBuffer = new byte[ipHeaderLength + IcmpHeaderLengthInBytes + buffer.Length];
|
||||
byte[] receiveBuffer = new byte[MaxIpHeaderLengthInBytes + IcmpHeaderLengthInBytes + buffer.Length];
|
||||
|
||||
long elapsed;
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
@ -105,6 +106,17 @@ namespace System.Net.NetworkInformation
|
||||
{
|
||||
fixed (byte* bytesPtr = &receiveBuffer[0])
|
||||
{
|
||||
if (isIpv4)
|
||||
{
|
||||
// Determine actual size of IP header
|
||||
byte ihl = (byte)(bytesPtr[0] & 0x0f); // Internet Header Length
|
||||
ipHeaderLength = 4 * ihl;
|
||||
if (bytesReceived - ipHeaderLength < IcmpHeaderLengthInBytes)
|
||||
{
|
||||
continue; // Not enough bytes to reconstruct actual IP header + ICMP header.
|
||||
}
|
||||
}
|
||||
|
||||
int icmpHeaderOffset = ipHeaderLength;
|
||||
IcmpHeader receivedHeader = *((IcmpHeader*)(bytesPtr + icmpHeaderOffset)); // Skip IP header.
|
||||
type = receivedHeader.Type;
|
||||
|
25
external/corefx/src/System.Net.Ping/src/System/Net/NetworkInformation/Ping.Windows.Uap.cs
vendored
Normal file
25
external/corefx/src/System.Net.Ping/src/System/Net/NetworkInformation/Ping.Windows.Uap.cs
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace System.Net.NetworkInformation
|
||||
{
|
||||
public partial class Ping
|
||||
{
|
||||
// Any exceptions that escape synchronously will be caught by the caller and wrapped in a PingException.
|
||||
// We do not need to or want to capture such exceptions into the returned task.
|
||||
private Task<PingReply> SendPingAsyncCore(IPAddress address, byte[] buffer, int timeout, PingOptions options)
|
||||
{
|
||||
// Win32 Icmp* APIs fail with E_ACCESSDENIED when called from UWP due to Windows OS limitations.
|
||||
throw new PlatformNotSupportedException(string.Format(CultureInfo.InvariantCulture,
|
||||
SR.net_ping_not_supported_uwp));
|
||||
}
|
||||
}
|
||||
}
|
@ -10,8 +10,8 @@ namespace System.Net.NetworkInformation.Tests
|
||||
public class LoggingTest
|
||||
{
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "NetEventSource is only part of .NET Core")]
|
||||
[ActiveIssue("https://github.com/dotnet/corefx/issues/20130", TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(20470, TargetFrameworkMonikers.UapAot)]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "NetEventSource is only part of .NET Core.")]
|
||||
public void EventSource_ExistsWithCorrectId()
|
||||
{
|
||||
Type esType = typeof(Ping).Assembly.GetType("System.Net.NetEventSource", throwOnError: true, ignoreCase: false);
|
||||
|
@ -81,7 +81,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
public async Task SendPingAsyncWithIPAddress()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -96,7 +96,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
public async Task SendPingAsyncWithIPAddress_AddressAsString()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -111,7 +111,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
public async Task SendPingAsyncWithIPAddressAndTimeout()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -126,7 +126,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // On Unix, Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply.
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
[Fact]
|
||||
public async Task SendPingAsyncWithIPAddressAndTimeoutAndBuffer()
|
||||
{
|
||||
@ -171,7 +171,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // On Unix, Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply.
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
[Fact]
|
||||
public async Task SendPingAsyncWithIPAddressAndTimeoutAndBufferAndPingOptions()
|
||||
{
|
||||
@ -217,7 +217,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
public async Task SendPingAsyncWithHost()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -232,7 +232,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
public async Task SendPingAsyncWithHostAndTimeout()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -247,7 +247,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // On Unix, Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply.
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
[Fact]
|
||||
public async Task SendPingAsyncWithHostAndTimeoutAndBuffer()
|
||||
{
|
||||
@ -292,7 +292,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // On Unix, Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply.
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
[Fact]
|
||||
public async Task SendPingAsyncWithHostAndTimeoutAndBufferAndPingOptions()
|
||||
{
|
||||
@ -337,7 +337,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
public static async Task SendPings_ReuseInstance_Hostname()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -354,7 +354,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
public static async Task Sends_ReuseInstance_Hostname()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -371,7 +371,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
public static async Task SendAsyncs_ReuseInstance_Hostname()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -423,7 +423,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
public static async Task Ping_DisposeAfterSend_Success()
|
||||
{
|
||||
Ping p = new Ping();
|
||||
@ -432,7 +432,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
public static void Ping_DisposeMultipletimes_Success()
|
||||
{
|
||||
Ping p = new Ping();
|
||||
@ -441,7 +441,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[ActiveIssue(19583, TargetFrameworkMonikers.Uap)]
|
||||
public static void Ping_SendAfterDispose_ThrowsSynchronously()
|
||||
{
|
||||
Ping p = new Ping();
|
||||
|
@ -23,9 +23,6 @@
|
||||
<Compile Include="$(CommonPath)\System\Net\NetworkInformation\UnixCommandLinePing.cs">
|
||||
<Link>Common\System\Net\NetworkInformation\UnixCommandLinePing.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
|
||||
<Link>Common\System\AssertExtensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonTestPath)\System\Net\Capability.RawSocketPermissions.cs">
|
||||
<Link>Common\System\Net\Capability.RawSocketPermissions.cs</Link>
|
||||
</Compile>
|
||||
|
Reference in New Issue
Block a user