Files
2026-06-04 11:42:34 +02:00

895 lines
56 KiB
C#

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text;
namespace System.Net.NetworkInformation
{
/// <summary>Allows an application to determine whether a remote computer is accessible over the network.</summary>
// Token: 0x020001AB RID: 427
[global::System.MonoTODO("IPv6 support is missing")]
public class Ping : global::System.ComponentModel.Component, IDisposable
{
// Token: 0x06000E30 RID: 3632 RVA: 0x00028268 File Offset: 0x00026468
static Ping()
{
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
Ping.CheckLinuxCapabilities();
if (!Ping.canSendPrivileged && WindowsIdentity.GetCurrent().Name == "root")
{
Ping.canSendPrivileged = true;
}
foreach (string text in Ping.PingBinPaths)
{
if (File.Exists(text))
{
Ping.PingBinPath = text;
break;
}
}
}
else
{
Ping.canSendPrivileged = true;
}
if (Ping.PingBinPath == null)
{
Ping.PingBinPath = "/bin/ping";
}
}
/// <summary>Occurs when an asynchronous operation to send an Internet Control Message Protocol (ICMP) echo message and receive the corresponding ICMP echo reply message completes or is canceled.</summary>
// Token: 0x14000025 RID: 37
// (add) Token: 0x06000E31 RID: 3633 RVA: 0x0002833C File Offset: 0x0002653C
// (remove) Token: 0x06000E32 RID: 3634 RVA: 0x00028358 File Offset: 0x00026558
public event PingCompletedEventHandler PingCompleted;
/// <summary>Releases all resources used by instances of the <see cref="T:System.Net.NetworkInformation.Ping" /> class.</summary>
// Token: 0x06000E33 RID: 3635 RVA: 0x00028374 File Offset: 0x00026574
void IDisposable.Dispose()
{
}
// Token: 0x06000E34 RID: 3636
[DllImport("libc")]
private static extern int capget(ref Ping.cap_user_header_t header, ref Ping.cap_user_data_t data);
// Token: 0x06000E35 RID: 3637 RVA: 0x00028378 File Offset: 0x00026578
private static void CheckLinuxCapabilities()
{
try
{
Ping.cap_user_header_t cap_user_header_t = default(Ping.cap_user_header_t);
Ping.cap_user_data_t cap_user_data_t = default(Ping.cap_user_data_t);
cap_user_header_t.version = 537333798U;
int num = -1;
try
{
num = Ping.capget(ref cap_user_header_t, ref cap_user_data_t);
}
catch (Exception)
{
}
if (num != -1)
{
Ping.canSendPrivileged = (cap_user_data_t.effective & 8192U) != 0U;
}
}
catch
{
Ping.canSendPrivileged = false;
}
}
/// <summary>Raises the <see cref="E:System.Net.NetworkInformation.Ping.PingCompleted" /> event.</summary>
/// <param name="e">A <see cref="T:System.Net.NetworkInformation.PingCompletedEventArgs" /> object that contains event data.</param>
// Token: 0x06000E36 RID: 3638 RVA: 0x00028424 File Offset: 0x00026624
protected void OnPingCompleted(PingCompletedEventArgs e)
{
if (this.PingCompleted != null)
{
this.PingCompleted(this, e);
}
this.user_async_state = null;
this.worker = null;
}
/// <summary>Attempts to send an Internet Control Message Protocol (ICMP) echo message to the computer that has the specified <see cref="T:System.Net.IPAddress" />, and receive a corresponding ICMP echo reply message from that computer.</summary>
/// <returns>A <see cref="T:System.Net.NetworkInformation.PingReply" /> object that provides information about the ICMP echo reply message, if one was received, or describes the reason for the failure if no message was received.</returns>
/// <param name="address">An <see cref="T:System.Net.IPAddress" /> that identifies the computer that is the destination for the ICMP echo message.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="address" /> is null.</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="Overload:System.Net.NetworkInformation.Ping.SendAsync" /> is in progress.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="address" /> is an IPv6 address and the local computer is running an operating system earlier than Windows 2000. </exception>
/// <exception cref="T:System.Net.NetworkInformation.PingException">An exception was thrown while sending or receiving the ICMP messages. See the inner exception for the exact exception that was thrown.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Net.SocketPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06000E37 RID: 3639 RVA: 0x00028458 File Offset: 0x00026658
public PingReply Send(IPAddress address)
{
return this.Send(address, 4000);
}
/// <summary>Attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the computer that has the specified <see cref="T:System.Net.IPAddress" />, and receive a corresponding ICMP echo reply message from that computer. This method allows you to specify a time-out value for the operation. </summary>
/// <returns>A <see cref="T:System.Net.NetworkInformation.PingReply" /> object that provides information about the ICMP echo reply message if one was received, or provides the reason for the failure if no message was received.</returns>
/// <param name="address">An <see cref="T:System.Net.IPAddress" /> that identifies the computer that is the destination for the ICMP echo message.</param>
/// <param name="timeout">An <see cref="T:System.Int32" /> value that specifies the maximum number of milliseconds (after sending the echo message) to wait for the ICMP echo reply message.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="address" /> is null.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout" /> is less than zero.</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="Overload:System.Net.NetworkInformation.Ping.SendAsync" /> is in progress.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="address" /> is an IPv6 address and the local computer is running an operating system earlier than Windows 2000. </exception>
/// <exception cref="T:System.Net.NetworkInformation.PingException">An exception was thrown while sending or receiving the ICMP messages. See the inner exception for the exact exception that was thrown.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
// Token: 0x06000E38 RID: 3640 RVA: 0x00028468 File Offset: 0x00026668
public PingReply Send(IPAddress address, int timeout)
{
return this.Send(address, timeout, Ping.default_buffer);
}
/// <summary>Attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the computer that has the specified <see cref="T:System.Net.IPAddress" />, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation.</summary>
/// <returns>A <see cref="T:System.Net.NetworkInformation.PingReply" /> object that provides information about the ICMP echo reply message, if one was received, or provides the reason for the failure, if no message was received. The method will return <see cref="F:System.Net.NetworkInformation.IPStatus.PacketTooBig" /> if the packet exceeds the Maximum Transmission Unit (MTU).</returns>
/// <param name="address">An <see cref="T:System.Net.IPAddress" /> that identifies the computer that is the destination for the ICMP echo message.</param>
/// <param name="timeout">An <see cref="T:System.Int32" /> value that specifies the maximum number of milliseconds (after sending the echo message) to wait for the ICMP echo reply message.</param>
/// <param name="buffer">A <see cref="T:System.Byte" /> array that contains data to be sent with the ICMP echo message and returned in the ICMP echo reply message. The array cannot contain more than 65,500 bytes.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="address" /> is null.-or-<paramref name="buffer" /> is null, or the <paramref name="buffer" /> size is greater than 65500 bytes.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout" /> is less than zero.</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="Overload:System.Net.NetworkInformation.Ping.SendAsync" /> is in progress.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="address" /> is an IPv6 address and the local computer is running an operating system earlier than Windows 2000. </exception>
/// <exception cref="T:System.Net.NetworkInformation.PingException">An exception was thrown while sending or receiving the ICMP messages. See the inner exception for the exact exception that was thrown.</exception>
/// <exception cref="T:System.Net.Sockets.SocketException">
/// <paramref name="address" /> is not a valid IP address.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
/// <exception cref="T:System.ArgumentException">The size of <paramref name="buffer" /> exceeds 65500 bytes.</exception>
// Token: 0x06000E39 RID: 3641 RVA: 0x00028478 File Offset: 0x00026678
public PingReply Send(IPAddress address, int timeout, byte[] buffer)
{
return this.Send(address, timeout, buffer, new PingOptions());
}
/// <summary>Attempts to send an Internet Control Message Protocol (ICMP) echo message to the specified computer, and receive a corresponding ICMP echo reply message from that computer.</summary>
/// <returns>A <see cref="T:System.Net.NetworkInformation.PingReply" /> object that provides information about the ICMP echo reply message, if one was received, or provides the reason for the failure, if no message was received.</returns>
/// <param name="hostNameOrAddress">A <see cref="T:System.String" /> that identifies the computer that is the destination for the ICMP echo message. The value specified for this parameter can be a host name or a string representation of an IP address.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="hostNameOrAddress" /> is null or is an empty string ("").</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="Overload:System.Net.NetworkInformation.Ping.SendAsync" /> is in progress.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="address" /> is an IPv6 address and the local computer is running an operating system earlier than Windows 2000. </exception>
/// <exception cref="T:System.Net.NetworkInformation.PingException">An exception was thrown while sending or receiving the ICMP messages. See the inner exception for the exact exception that was thrown.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Net.SocketPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06000E3A RID: 3642 RVA: 0x00028488 File Offset: 0x00026688
public PingReply Send(string hostNameOrAddress)
{
return this.Send(hostNameOrAddress, 4000);
}
/// <summary>Attempts to send an Internet Control Message Protocol (ICMP) echo message to the specified computer, and receive a corresponding ICMP echo reply message from that computer. This method allows you to specify a time-out value for the operation.</summary>
/// <returns>A <see cref="T:System.Net.NetworkInformation.PingReply" /> object that provides information about the ICMP echo reply message if one was received, or provides the reason for the failure if no message was received.</returns>
/// <param name="hostNameOrAddress">A <see cref="T:System.String" /> that identifies the computer that is the destination for the ICMP echo message. The value specified for this parameter can be a host name or a string representation of an IP address.</param>
/// <param name="timeout">An <see cref="T:System.Int32" /> value that specifies the maximum number of milliseconds (after sending the echo message) to wait for the ICMP echo reply message.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="hostNameOrAddress" /> is null or is an empty string ("").</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout" /> is less than zero.</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="Overload:System.Net.NetworkInformation.Ping.SendAsync" /> is in progress.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
// Token: 0x06000E3B RID: 3643 RVA: 0x00028498 File Offset: 0x00026698
public PingReply Send(string hostNameOrAddress, int timeout)
{
return this.Send(hostNameOrAddress, timeout, Ping.default_buffer);
}
/// <summary>Attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the specified computer, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation.</summary>
/// <returns>A <see cref="T:System.Net.NetworkInformation.PingReply" /> object that provides information about the ICMP echo reply message if one was received, or provides the reason for the failure if no message was received.</returns>
/// <param name="hostNameOrAddress">A <see cref="T:System.String" /> that identifies the computer that is the destination for the ICMP echo message. The value specified for this parameter can be a host name or a string representation of an IP address.</param>
/// <param name="timeout">An <see cref="T:System.Int32" /> value that specifies the maximum number of milliseconds (after sending the echo message) to wait for the ICMP echo reply message.</param>
/// <param name="buffer">A <see cref="T:System.Byte" /> array that contains data to be sent with the ICMP echo message and returned in the ICMP echo reply message. The array cannot contain more than 65,500 bytes.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="hostNameOrAddress" /> is null or is an empty string ("").-or-<paramref name="buffer" /> is null, or the <paramref name="buffer" /> size is greater than 65500 bytes.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout" /> is less than zero.</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="Overload:System.Net.NetworkInformation.Ping.SendAsync" /> is in progress.</exception>
/// <exception cref="T:System.Net.Sockets.SocketException">
/// <paramref name="hostNameOrAddress" /> could not be resolved to a valid IP address.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
/// <exception cref="T:System.ArgumentException">The size of <paramref name="buffer" /> exceeds 65500 bytes.</exception>
// Token: 0x06000E3C RID: 3644 RVA: 0x000284A8 File Offset: 0x000266A8
public PingReply Send(string hostNameOrAddress, int timeout, byte[] buffer)
{
return this.Send(hostNameOrAddress, timeout, buffer, new PingOptions());
}
/// <summary>Attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the specified computer, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation and control fragmentation and Time-to-Live values for the ICMP packet.</summary>
/// <returns>A <see cref="T:System.Net.NetworkInformation.PingReply" /> object that provides information about the ICMP echo reply message if one was received, or provides the reason for the failure if no message was received.</returns>
/// <param name="hostNameOrAddress">A <see cref="T:System.String" /> that identifies the computer that is the destination for the ICMP echo message. The value specified for this parameter can be a host name or a string representation of an IP address.</param>
/// <param name="timeout">An <see cref="T:System.Int32" /> value that specifies the maximum number of milliseconds (after sending the echo message) to wait for the ICMP echo reply message.</param>
/// <param name="buffer">A <see cref="T:System.Byte" /> array that contains data to be sent with the ICMP echo message and returned in the ICMP echo reply message. The array cannot contain more than 65,500 bytes.</param>
/// <param name="options">A <see cref="T:System.Net.NetworkInformation.PingOptions" /> object used to control fragmentation and Time-to-Live values for the ICMP echo message packet.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="hostNameOrAddress" /> is null or is a zero length string.-or-<paramref name="buffer" /> is null, or the <paramref name="buffer" /> size is greater than 65500 bytes.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout" /> is less than zero.</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="Overload:System.Net.NetworkInformation.Ping.SendAsync" /> is in progress.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="address" /> is an IPv6 address and the local computer is running an operating system earlier than Windows 2000. </exception>
/// <exception cref="T:System.Net.NetworkInformation.PingException">An exception was thrown while sending or receiving the ICMP messages. See the inner exception for the exact exception that was thrown.</exception>
/// <exception cref="T:System.Net.Sockets.SocketException">
/// <paramref name="hostNameOrAddress" /> could not be resolved to a valid IP address.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
/// <exception cref="T:System.ArgumentException">The size of <paramref name="buffer" /> exceeds 65500 bytes.</exception>
// Token: 0x06000E3D RID: 3645 RVA: 0x000284B8 File Offset: 0x000266B8
public PingReply Send(string hostNameOrAddress, int timeout, byte[] buffer, PingOptions options)
{
IPAddress[] hostAddresses = Dns.GetHostAddresses(hostNameOrAddress);
return this.Send(hostAddresses[0], timeout, buffer, options);
}
// Token: 0x06000E3E RID: 3646 RVA: 0x000284DC File Offset: 0x000266DC
private static IPAddress GetNonLoopbackIP()
{
foreach (IPAddress ipaddress in Dns.GetHostByName(Dns.GetHostName()).AddressList)
{
if (!IPAddress.IsLoopback(ipaddress))
{
return ipaddress;
}
}
throw new InvalidOperationException("Could not resolve non-loopback IP address for localhost");
}
/// <summary>Attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the computer that has the specified <see cref="T:System.Net.IPAddress" /> and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation and control fragmentation and Time-to-Live values for the ICMP echo message packet.</summary>
/// <returns>A <see cref="T:System.Net.NetworkInformation.PingReply" /> object that provides information about the ICMP echo reply message, if one was received, or provides the reason for the failure, if no message was received. The method will return <see cref="F:System.Net.NetworkInformation.IPStatus.PacketTooBig" /> if the packet exceeds the Maximum Transmission Unit (MTU).</returns>
/// <param name="address">An <see cref="T:System.Net.IPAddress" /> that identifies the computer that is the destination for the ICMP echo message.</param>
/// <param name="timeout">An <see cref="T:System.Int32" /> value that specifies the maximum number of milliseconds (after sending the echo message) to wait for the ICMP echo reply message.</param>
/// <param name="buffer">A <see cref="T:System.Byte" /> array that contains data to be sent with the ICMP echo message and returned in the ICMP echo reply message. The array cannot contain more than 65,500 bytes.</param>
/// <param name="options">A <see cref="T:System.Net.NetworkInformation.PingOptions" /> object used to control fragmentation and Time-to-Live values for the ICMP echo message packet.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="address" /> is null.-or-<paramref name="buffer" /> is null, or the <paramref name="buffer" /> size is greater than 65500 bytes.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout" /> is less than zero.</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="Overload:System.Net.NetworkInformation.Ping.SendAsync" /> is in progress.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="address" /> is an IPv6 address and the local computer is running an operating system earlier than Windows 2000. </exception>
/// <exception cref="T:System.Net.NetworkInformation.PingException">An exception was thrown while sending or receiving the ICMP messages. See the inner exception for the exact exception that was thrown.</exception>
/// <exception cref="T:System.Net.Sockets.SocketException">
/// <paramref name="address" /> is not a valid IP address.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
/// <exception cref="T:System.ArgumentException">The size of <paramref name="buffer" /> exceeds 65500 bytes.</exception>
// Token: 0x06000E3F RID: 3647 RVA: 0x00028528 File Offset: 0x00026728
public PingReply Send(IPAddress address, int timeout, byte[] buffer, PingOptions options)
{
if (address == null)
{
throw new ArgumentNullException("address");
}
if (timeout < 0)
{
throw new ArgumentOutOfRangeException("timeout", "timeout must be non-negative integer");
}
if (buffer == null)
{
throw new ArgumentNullException("buffer");
}
if (buffer.Length > 65500)
{
throw new ArgumentException("buffer");
}
if (Ping.canSendPrivileged)
{
return this.SendPrivileged(address, timeout, buffer, options);
}
return this.SendUnprivileged(address, timeout, buffer, options);
}
// Token: 0x06000E40 RID: 3648 RVA: 0x000285A8 File Offset: 0x000267A8
private PingReply SendPrivileged(IPAddress address, int timeout, byte[] buffer, PingOptions options)
{
IPEndPoint ipendPoint = new IPEndPoint(address, 0);
IPEndPoint ipendPoint2 = new IPEndPoint(Ping.GetNonLoopbackIP(), 0);
PingReply pingReply;
using (global::System.Net.Sockets.Socket socket = new global::System.Net.Sockets.Socket(global::System.Net.Sockets.AddressFamily.InterNetwork, global::System.Net.Sockets.SocketType.Raw, global::System.Net.Sockets.ProtocolType.Icmp))
{
if (options != null)
{
socket.DontFragment = options.DontFragment;
socket.Ttl = (short)options.Ttl;
}
socket.SendTimeout = timeout;
socket.ReceiveTimeout = timeout;
Ping.IcmpMessage icmpMessage = new Ping.IcmpMessage(8, 0, 1, 0, buffer);
byte[] array = icmpMessage.GetBytes();
socket.SendBufferSize = array.Length;
socket.SendTo(array, array.Length, global::System.Net.Sockets.SocketFlags.None, ipendPoint);
DateTime now = DateTime.Now;
array = new byte[100];
int num;
long num3;
Ping.IcmpMessage icmpMessage2;
for (;;)
{
EndPoint endPoint = ipendPoint2;
num = 0;
int num2 = socket.ReceiveFrom_nochecks_exc(array, 0, 100, global::System.Net.Sockets.SocketFlags.None, ref endPoint, false, out num);
if (num != 0)
{
break;
}
num3 = (long)(DateTime.Now - now).TotalMilliseconds;
int num4 = (int)(array[0] & 15) << 2;
int num5 = num2 - num4;
if (!((IPEndPoint)endPoint).Address.Equals(ipendPoint.Address))
{
long num6 = (long)timeout - num3;
if (num6 <= 0L)
{
goto Block_7;
}
socket.ReceiveTimeout = (int)num6;
}
else
{
icmpMessage2 = new Ping.IcmpMessage(array, num4, num5);
if (icmpMessage2.Identifier == 1 && icmpMessage2.Type != 8)
{
goto IL_1C9;
}
long num7 = (long)timeout - num3;
if (num7 <= 0L)
{
goto Block_9;
}
socket.ReceiveTimeout = (int)num7;
}
}
if (num == 10060)
{
return new PingReply(null, new byte[0], options, 0L, IPStatus.TimedOut);
}
throw new NotSupportedException(string.Format("Unexpected socket error during ping request: {0}", num));
Block_7:
return new PingReply(null, new byte[0], options, 0L, IPStatus.TimedOut);
Block_9:
return new PingReply(null, new byte[0], options, 0L, IPStatus.TimedOut);
IL_1C9:
pingReply = new PingReply(address, icmpMessage2.Data, options, num3, icmpMessage2.IPStatus);
}
return pingReply;
}
// Token: 0x06000E41 RID: 3649 RVA: 0x000287D4 File Offset: 0x000269D4
private PingReply SendUnprivileged(IPAddress address, int timeout, byte[] buffer, PingOptions options)
{
DateTime now = DateTime.Now;
global::System.Diagnostics.Process process = new global::System.Diagnostics.Process();
string text = this.BuildPingArgs(address, timeout, options);
long num = 0L;
process.StartInfo.FileName = Ping.PingBinPath;
process.StartInfo.Arguments = text;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
DateTime utcNow = DateTime.UtcNow;
try
{
process.Start();
num = (long)(DateTime.Now - now).TotalMilliseconds;
if (!process.WaitForExit(timeout) || (process.HasExited && process.ExitCode == 2))
{
return new PingReply(address, buffer, options, num, IPStatus.TimedOut);
}
if (process.ExitCode == 1)
{
return new PingReply(address, buffer, options, num, IPStatus.TtlExpired);
}
}
catch (Exception)
{
return new PingReply(address, buffer, options, num, IPStatus.Unknown);
}
finally
{
if (process != null)
{
if (!process.HasExited)
{
process.Kill();
}
process.Dispose();
}
}
return new PingReply(address, buffer, options, num, IPStatus.Success);
}
/// <summary>Asynchronously attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the computer that has the specified <see cref="T:System.Net.IPAddress" />, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation.</summary>
/// <param name="address">An <see cref="T:System.Net.IPAddress" /> that identifies the computer that is the destination for the ICMP echo message.</param>
/// <param name="timeout">An <see cref="T:System.Int32" /> value that specifies the maximum number of milliseconds (after sending the echo message) to wait for the ICMP echo reply message.</param>
/// <param name="buffer">A <see cref="T:System.Byte" /> array that contains data to be sent with the ICMP echo message and returned in the ICMP echo reply message. The array cannot contain more than 65,500 bytes.</param>
/// <param name="userToken">An object that is passed to the method invoked when the asynchronous operation completes.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="address" /> is null.-or-<paramref name="buffer" /> is null.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout" /> is less than zero.</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="Overload:System.Net.NetworkInformation.Ping.SendAsync" /> is in progress.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="address" /> is an IPv6 address and the local computer is running an operating system earlier than Windows 2000. </exception>
/// <exception cref="T:System.Net.NetworkInformation.PingException">An exception was thrown while sending or receiving the ICMP messages. See the inner exception for the exact exception that was thrown.</exception>
/// <exception cref="T:System.Net.Sockets.SocketException">
/// <paramref name="address" /> is not a valid IP address.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
/// <exception cref="T:System.ArgumentException">The size of <paramref name="buffer" /> exceeds 65500 bytes.</exception>
// Token: 0x06000E42 RID: 3650 RVA: 0x00028944 File Offset: 0x00026B44
public void SendAsync(IPAddress address, int timeout, byte[] buffer, object userToken)
{
this.SendAsync(address, 4000, Ping.default_buffer, new PingOptions(), userToken);
}
/// <summary>Asynchronously attempts to send an Internet Control Message Protocol (ICMP) echo message to the computer that has the specified <see cref="T:System.Net.IPAddress" />, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation.</summary>
/// <param name="address">An <see cref="T:System.Net.IPAddress" /> that identifies the computer that is the destination for the ICMP echo message.</param>
/// <param name="timeout">An <see cref="T:System.Int32" /> value that specifies the maximum number of milliseconds (after sending the echo message) to wait for the ICMP echo reply message.</param>
/// <param name="userToken">An object that is passed to the method invoked when the asynchronous operation completes.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="address" /> is null.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout" /> is less than zero.</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="M:System.Net.NetworkInformation.Ping.SendAsync(System.Net.IPAddress,System.Int32,System.Byte[],System.Object)" /> method is in progress.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="address" /> is an IPv6 address and the local computer is running an operating system earlier than Windows 2000. </exception>
/// <exception cref="T:System.Net.NetworkInformation.PingException">An exception was thrown while sending or receiving the ICMP messages. See the inner exception for the exact exception that was thrown.</exception>
/// <exception cref="T:System.Net.Sockets.SocketException">
/// <paramref name="address" /> is not a valid IP address.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
// Token: 0x06000E43 RID: 3651 RVA: 0x00028960 File Offset: 0x00026B60
public void SendAsync(IPAddress address, int timeout, object userToken)
{
this.SendAsync(address, 4000, Ping.default_buffer, userToken);
}
/// <summary>Asynchronously attempts to send an Internet Control Message Protocol (ICMP) echo message to the computer that has the specified <see cref="T:System.Net.IPAddress" />, and receive a corresponding ICMP echo reply message from that computer.</summary>
/// <param name="address">An <see cref="T:System.Net.IPAddress" /> that identifies the computer that is the destination for the ICMP echo message.</param>
/// <param name="userToken">An object that is passed to the method invoked when the asynchronous operation completes. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="address" /> is null.</exception>
/// <exception cref="T:System.InvalidOperationException">A call to the <see cref="Overload:System.Net.NetworkInformation.Ping.SendAsync" /> method is in progress.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="address" /> is an IPv6 address and the local computer is running an operating system earlier than Windows 2000. </exception>
/// <exception cref="T:System.Net.NetworkInformation.PingException">An exception was thrown while sending or receiving the ICMP messages. See the inner exception for the exact exception that was thrown.</exception>
/// <exception cref="T:System.Net.Sockets.SocketException">
/// <paramref name="address" /> is not a valid IP address.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Net.SocketPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06000E44 RID: 3652 RVA: 0x00028974 File Offset: 0x00026B74
public void SendAsync(IPAddress address, object userToken)
{
this.SendAsync(address, 4000, userToken);
}
/// <summary>Asynchronously attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the specified computer, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation.</summary>
/// <param name="hostNameOrAddress">A <see cref="T:System.String" /> that identifies the computer that is the destination for the ICMP echo message. The value specified for this parameter can be a host name or a string representation of an IP address.</param>
/// <param name="timeout">An <see cref="T:System.Int32" /> value that specifies the maximum number of milliseconds (after sending the echo message) to wait for the ICMP echo reply message.</param>
/// <param name="buffer">A <see cref="T:System.Byte" /> array that contains data to be sent with the ICMP echo message and returned in the ICMP echo reply message. The array cannot contain more than 65,500 bytes.</param>
/// <param name="userToken">An object that is passed to the method invoked when the asynchronous operation completes.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="hostNameOrAddress" /> is null or is an empty string ("").-or-<paramref name="buffer" /> is null.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout" /> is less than zero.</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="Overload:System.Net.NetworkInformation.Ping.SendAsync" /> is in progress.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="hostNameOrAddress" /> is an IPv6 address and the local computer is running an operating system earlier than Windows 2000. </exception>
/// <exception cref="T:System.Net.NetworkInformation.PingException">An exception was thrown while sending or receiving the ICMP messages. See the inner exception for the exact exception that was thrown.</exception>
/// <exception cref="T:System.Net.Sockets.SocketException">
/// <paramref name="hostNameOrAddress" /> could not be resolved to a valid IP address.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
/// <exception cref="T:System.ArgumentException">The size of <paramref name="buffer" /> exceeds 65500 bytes.</exception>
// Token: 0x06000E45 RID: 3653 RVA: 0x00028984 File Offset: 0x00026B84
public void SendAsync(string hostNameOrAddress, int timeout, byte[] buffer, object userToken)
{
this.SendAsync(hostNameOrAddress, timeout, buffer, new PingOptions(), userToken);
}
/// <summary>Asynchronously attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the specified computer, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation and control fragmentation and Time-to-Live values for the ICMP packet.</summary>
/// <param name="hostNameOrAddress">A <see cref="T:System.String" /> that identifies the computer that is the destination for the ICMP echo message. The value specified for this parameter can be a host name or a string representation of an IP address.</param>
/// <param name="timeout">A <see cref="T:System.Byte" /> array that contains data to be sent with the ICMP echo message and returned in the ICMP echo reply message. The array cannot contain more than 65,500 bytes.</param>
/// <param name="buffer">An <see cref="T:System.Int32" /> value that specifies the maximum number of milliseconds (after sending the echo message) to wait for the ICMP echo reply message.</param>
/// <param name="options">A <see cref="T:System.Net.NetworkInformation.PingOptions" /> object used to control fragmentation and Time-to-Live values for the ICMP echo message packet.</param>
/// <param name="userToken">An object that is passed to the method invoked when the asynchronous operation completes.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="hostNameOrAddress" /> is null or is an empty string ("").-or-<paramref name="buffer" /> is null.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout" /> is less than zero.</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="Overload:System.Net.NetworkInformation.Ping.SendAsync" /> is in progress.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="address" /> is an IPv6 address and the local computer is running an operating system earlier than Windows 2000. </exception>
/// <exception cref="T:System.Net.NetworkInformation.PingException">An exception was thrown while sending or receiving the ICMP messages. See the inner exception for the exact exception that was thrown.</exception>
/// <exception cref="T:System.Net.Sockets.SocketException">
/// <paramref name="hostNameOrAddress" /> could not be resolved to a valid IP address.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
/// <exception cref="T:System.ArgumentException">The size of <paramref name="buffer" /> exceeds 65500 bytes.</exception>
// Token: 0x06000E46 RID: 3654 RVA: 0x00028998 File Offset: 0x00026B98
public void SendAsync(string hostNameOrAddress, int timeout, byte[] buffer, PingOptions options, object userToken)
{
IPAddress ipaddress = Dns.GetHostEntry(hostNameOrAddress).AddressList[0];
this.SendAsync(ipaddress, timeout, buffer, options, userToken);
}
/// <summary>Asynchronously attempts to send an Internet Control Message Protocol (ICMP) echo message to the specified computer, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation.</summary>
/// <param name="hostNameOrAddress">A <see cref="T:System.String" /> that identifies the computer that is the destination for the ICMP echo message. The value specified for this parameter can be a host name or a string representation of an IP address.</param>
/// <param name="timeout">An <see cref="T:System.Int32" /> value that specifies the maximum number of milliseconds (after sending the echo message) to wait for the ICMP echo reply message.</param>
/// <param name="userToken">An object that is passed to the method invoked when the asynchronous operation completes.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="hostNameOrAddress" /> is null or is an empty string ("").</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout" /> is less than zero.</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="Overload:System.Net.NetworkInformation.Ping.SendAsync" /> is in progress.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="hostNameOrAddress" /> is an IPv6 address and the local computer is running an operating system earlier than Windows 2000. </exception>
/// <exception cref="T:System.Net.NetworkInformation.PingException">An exception was thrown while sending or receiving the ICMP messages. See the inner exception for the exact exception that was thrown.</exception>
/// <exception cref="T:System.Net.Sockets.SocketException">
/// <paramref name="hostNameOrAddress" /> could not be resolved to a valid IP address.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
// Token: 0x06000E47 RID: 3655 RVA: 0x000289C0 File Offset: 0x00026BC0
public void SendAsync(string hostNameOrAddress, int timeout, object userToken)
{
this.SendAsync(hostNameOrAddress, timeout, Ping.default_buffer, userToken);
}
/// <summary>Asynchronously attempts to send an Internet Control Message Protocol (ICMP) echo message to the specified computer, and receive a corresponding ICMP echo reply message from that computer.</summary>
/// <param name="hostNameOrAddress">A <see cref="T:System.String" /> that identifies the computer that is the destination for the ICMP echo message. The value specified for this parameter can be a host name or a string representation of an IP address.</param>
/// <param name="userToken">An object that is passed to the method invoked when the asynchronous operation completes.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="hostNameOrAddress" /> is null or is an empty string ("").</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="M:System.Net.NetworkInformation.Ping.SendAsync(System.String,System.Object)" /> method is in progress.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="address" /> is an IPv6 address and the local computer is running an operating system earlier than Windows 2000. </exception>
/// <exception cref="T:System.Net.NetworkInformation.PingException">An exception was thrown while sending or receiving the ICMP messages. See the inner exception for the exact exception that was thrown.</exception>
/// <exception cref="T:System.Net.Sockets.SocketException">
/// <paramref name="hostNameOrAddress" /> could not be resolved to a valid IP address.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Net.SocketPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06000E48 RID: 3656 RVA: 0x000289D0 File Offset: 0x00026BD0
public void SendAsync(string hostNameOrAddress, object userToken)
{
this.SendAsync(hostNameOrAddress, 4000, userToken);
}
/// <summary>Asynchronously attempts to send an Internet Control Message Protocol (ICMP) echo message with the specified data buffer to the computer that has the specified <see cref="T:System.Net.IPAddress" />, and receive a corresponding ICMP echo reply message from that computer. This overload allows you to specify a time-out value for the operation and control fragmentation and Time-to-Live values for the ICMP echo message packet.</summary>
/// <param name="address">An <see cref="T:System.Net.IPAddress" /> that identifies the computer that is the destination for the ICMP echo message.</param>
/// <param name="timeout">A <see cref="T:System.Byte" /> array that contains data to be sent with the ICMP echo message and returned in the ICMP echo reply message. The array cannot contain more than 65,500 bytes.</param>
/// <param name="buffer">An <see cref="T:System.Int32" /> value that specifies the maximum number of milliseconds (after sending the echo message) to wait for the ICMP echo reply message.</param>
/// <param name="options">A <see cref="T:System.Net.NetworkInformation.PingOptions" /> object used to control fragmentation and Time-to-Live values for the ICMP echo message packet.</param>
/// <param name="userToken">An object that is passed to the method invoked when the asynchronous operation completes.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="address" /> is null.-or-<paramref name="buffer" /> is null.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout" /> is less than zero.</exception>
/// <exception cref="T:System.InvalidOperationException">A call to <see cref="Overload:System.Net.NetworkInformation.Ping.SendAsync" /> is in progress.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="address" /> is an IPv6 address and the local computer is running an operating system earlier than Windows 2000. </exception>
/// <exception cref="T:System.Net.NetworkInformation.PingException">An exception was thrown while sending or receiving the ICMP messages. See the inner exception for the exact exception that was thrown.</exception>
/// <exception cref="T:System.Net.Sockets.SocketException">
/// <paramref name="address" /> is not a valid IP address.</exception>
/// <exception cref="T:System.ObjectDisposedException">This object has been disposed.</exception>
/// <exception cref="T:System.ArgumentException">The size of <paramref name="buffer" /> exceeds 65500 bytes.</exception>
// Token: 0x06000E49 RID: 3657 RVA: 0x000289E0 File Offset: 0x00026BE0
public void SendAsync(IPAddress address, int timeout, byte[] buffer, PingOptions options, object userToken)
{
if (this.worker != null)
{
throw new InvalidOperationException("Another SendAsync operation is in progress");
}
this.worker = new global::System.ComponentModel.BackgroundWorker();
this.worker.DoWork += delegate(object o, global::System.ComponentModel.DoWorkEventArgs ea)
{
try
{
this.user_async_state = ea.Argument;
ea.Result = this.Send(address, timeout, buffer, options);
}
catch (Exception ex)
{
ea.Result = ex;
}
};
this.worker.WorkerSupportsCancellation = true;
this.worker.RunWorkerCompleted += delegate(object o, global::System.ComponentModel.RunWorkerCompletedEventArgs ea)
{
this.OnPingCompleted(new PingCompletedEventArgs(ea.Error, ea.Cancelled, this.user_async_state, ea.Result as PingReply));
};
this.worker.RunWorkerAsync(userToken);
}
/// <summary>Cancels all pending asynchronous requests to send an Internet Control Message Protocol (ICMP) echo message and receives a corresponding ICMP echo reply message.</summary>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x06000E4A RID: 3658 RVA: 0x00028A80 File Offset: 0x00026C80
public void SendAsyncCancel()
{
if (this.worker == null)
{
throw new InvalidOperationException("SendAsync operation is not in progress");
}
this.worker.CancelAsync();
}
// Token: 0x06000E4B RID: 3659 RVA: 0x00028AA4 File Offset: 0x00026CA4
private string BuildPingArgs(IPAddress address, int timeout, PingOptions options)
{
CultureInfo invariantCulture = CultureInfo.InvariantCulture;
StringBuilder stringBuilder = new StringBuilder();
uint num = Convert.ToUInt32(Math.Floor((double)(timeout + 1000) / 1000.0));
bool flag = Environment.OSVersion.Platform == PlatformID.MacOSX;
if (!flag)
{
stringBuilder.AppendFormat(invariantCulture, "-q -n -c {0} -w {1} -t {2} -M ", new object[] { 1, num, options.Ttl });
}
else
{
stringBuilder.AppendFormat(invariantCulture, "-q -n -c {0} -t {1} -o -m {2} ", new object[] { 1, num, options.Ttl });
}
if (!flag)
{
stringBuilder.Append((!options.DontFragment) ? "dont " : "do ");
}
else if (options.DontFragment)
{
stringBuilder.Append("-D ");
}
stringBuilder.Append(address.ToString());
return stringBuilder.ToString();
}
// Token: 0x04000CD2 RID: 3282
private const int DefaultCount = 1;
// Token: 0x04000CD3 RID: 3283
private const int default_timeout = 4000;
// Token: 0x04000CD4 RID: 3284
private const int identifier = 1;
// Token: 0x04000CD5 RID: 3285
private const uint linux_cap_version = 537333798U;
// Token: 0x04000CD6 RID: 3286
private static readonly string[] PingBinPaths = new string[] { "/bin/ping", "/sbin/ping", "/usr/sbin/ping", "/system/bin/ping" };
// Token: 0x04000CD7 RID: 3287
private static readonly string PingBinPath;
// Token: 0x04000CD8 RID: 3288
private static readonly byte[] default_buffer = new byte[0];
// Token: 0x04000CD9 RID: 3289
private static bool canSendPrivileged;
// Token: 0x04000CDA RID: 3290
private global::System.ComponentModel.BackgroundWorker worker;
// Token: 0x04000CDB RID: 3291
private object user_async_state;
// Token: 0x020001AC RID: 428
private struct cap_user_header_t
{
// Token: 0x04000CDD RID: 3293
public uint version;
// Token: 0x04000CDE RID: 3294
public int pid;
}
// Token: 0x020001AD RID: 429
private struct cap_user_data_t
{
// Token: 0x04000CDF RID: 3295
public uint effective;
// Token: 0x04000CE0 RID: 3296
public uint permitted;
// Token: 0x04000CE1 RID: 3297
public uint inheritable;
}
// Token: 0x020001AE RID: 430
private class IcmpMessage
{
// Token: 0x06000E4C RID: 3660 RVA: 0x00028BB0 File Offset: 0x00026DB0
public IcmpMessage(byte[] bytes, int offset, int size)
{
this.bytes = new byte[size];
Buffer.BlockCopy(bytes, offset, this.bytes, 0, size);
}
// Token: 0x06000E4D RID: 3661 RVA: 0x00028BD4 File Offset: 0x00026DD4
public IcmpMessage(byte type, byte code, short identifier, short sequence, byte[] data)
{
this.bytes = new byte[data.Length + 8];
this.bytes[0] = type;
this.bytes[1] = code;
this.bytes[4] = (byte)(identifier & 255);
this.bytes[5] = (byte)(identifier >> 8);
this.bytes[6] = (byte)(sequence & 255);
this.bytes[7] = (byte)(sequence >> 8);
Buffer.BlockCopy(data, 0, this.bytes, 8, data.Length);
ushort num = Ping.IcmpMessage.ComputeChecksum(this.bytes);
this.bytes[2] = (byte)(num & 255);
this.bytes[3] = (byte)(num >> 8);
}
// Token: 0x1700049F RID: 1183
// (get) Token: 0x06000E4E RID: 3662 RVA: 0x00028C80 File Offset: 0x00026E80
public byte Type
{
get
{
return this.bytes[0];
}
}
// Token: 0x170004A0 RID: 1184
// (get) Token: 0x06000E4F RID: 3663 RVA: 0x00028C8C File Offset: 0x00026E8C
public byte Code
{
get
{
return this.bytes[1];
}
}
// Token: 0x170004A1 RID: 1185
// (get) Token: 0x06000E50 RID: 3664 RVA: 0x00028C98 File Offset: 0x00026E98
public byte Identifier
{
get
{
return (byte)((int)this.bytes[4] + ((int)this.bytes[5] << 8));
}
}
// Token: 0x170004A2 RID: 1186
// (get) Token: 0x06000E51 RID: 3665 RVA: 0x00028CB0 File Offset: 0x00026EB0
public byte Sequence
{
get
{
return (byte)((int)this.bytes[6] + ((int)this.bytes[7] << 8));
}
}
// Token: 0x170004A3 RID: 1187
// (get) Token: 0x06000E52 RID: 3666 RVA: 0x00028CC8 File Offset: 0x00026EC8
public byte[] Data
{
get
{
byte[] array = new byte[this.bytes.Length - 8];
Buffer.BlockCopy(this.bytes, 0, array, 0, array.Length);
return array;
}
}
// Token: 0x06000E53 RID: 3667 RVA: 0x00028CF8 File Offset: 0x00026EF8
public byte[] GetBytes()
{
return this.bytes;
}
// Token: 0x06000E54 RID: 3668 RVA: 0x00028D00 File Offset: 0x00026F00
private static ushort ComputeChecksum(byte[] data)
{
uint num = 0U;
for (int i = 0; i < data.Length; i += 2)
{
ushort num2 = (ushort)((i + 1 >= data.Length) ? 0 : data[i + 1]);
num2 = (ushort)(num2 << 8);
num2 += (ushort)data[i];
num += (uint)num2;
}
num = (num >> 16) + (num & 65535U);
return (ushort)(~(ushort)num);
}
// Token: 0x170004A4 RID: 1188
// (get) Token: 0x06000E55 RID: 3669 RVA: 0x00028D5C File Offset: 0x00026F5C
public IPStatus IPStatus
{
get
{
byte type = this.Type;
switch (type)
{
case 0:
return IPStatus.Success;
default:
switch (type)
{
case 8:
return IPStatus.Success;
case 11:
{
byte code = this.Code;
if (code == 0)
{
return IPStatus.TimeExceeded;
}
if (code == 1)
{
return IPStatus.TtlReassemblyTimeExceeded;
}
break;
}
case 12:
return IPStatus.ParameterProblem;
}
break;
case 3:
switch (this.Code)
{
case 0:
return IPStatus.DestinationNetworkUnreachable;
case 1:
return IPStatus.DestinationHostUnreachable;
case 2:
return IPStatus.DestinationProhibited;
case 3:
return IPStatus.DestinationPortUnreachable;
case 4:
return IPStatus.BadOption;
case 5:
return IPStatus.BadRoute;
}
break;
case 4:
return IPStatus.SourceQuench;
}
return IPStatus.Unknown;
}
}
// Token: 0x04000CE2 RID: 3298
private byte[] bytes;
}
}
}