public void SendPingWithIPAddressAndTimeoutAndBufferAndPingOptions_Unix(AddressFamily addressFamily) { IPAddress localIpAddress = TestSettings.GetLocalIPAddress(addressFamily); if (localIpAddress == null) { // No local address for given address family. return; } byte[] buffer = TestSettings.PayloadAsBytes; SendBatchPing( (ping) => ping.Send(localIpAddress, TestSettings.PingTimeout, buffer, new PingOptions()), (pingReply) => { PingResultValidator(pingReply, localIpAddress); // Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply. if (Capability.CanUseRawSockets(localIpAddress.AddressFamily) || PlatformDetection.IsOSXLike) { Assert.Equal(buffer, pingReply.Buffer); } else { Assert.Equal(Array.Empty <byte>(), pingReply.Buffer); } }); }
public async Task SendPingAsyncWithHostAndTimeoutAndBufferAndPingOptions_Unix() { IPAddress[] localIpAddresses = await TestSettings.GetLocalIPAddressesAsync(); byte[] buffer = TestSettings.PayloadAsBytes; await SendBatchPingAsync( (ping) => ping.SendPingAsync(TestSettings.LocalHost, TestSettings.PingTimeout, buffer, new PingOptions()), (pingReply) => { PingResultValidator(pingReply, localIpAddresses); // Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply. if (Capability.CanUseRawSockets(pingReply.Address.AddressFamily)) { Assert.Equal(buffer, pingReply.Buffer); } else { Assert.Equal(Array.Empty <byte>(), pingReply.Buffer); } }); }
public void SendPingWithIPAddressAndTimeoutAndBuffer_Unix() { byte[] buffer = TestSettings.PayloadAsBytes; IPAddress localIpAddress = TestSettings.GetLocalIPAddress(); SendBatchPing( (ping) => ping.Send(localIpAddress, TestSettings.PingTimeout, buffer), (pingReply) => { PingResultValidator(pingReply, localIpAddress); // Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply. if (Capability.CanUseRawSockets(localIpAddress.AddressFamily)) { Assert.Equal(buffer, pingReply.Buffer); } else { Assert.Equal(Array.Empty <byte>(), pingReply.Buffer); } }); }
public void SendPingWithHostAndTimeoutAndBuffer_Unix() { IPAddress[] localIpAddresses = TestSettings.GetLocalIPAddresses(); byte[] buffer = TestSettings.PayloadAsBytes; SendBatchPing( (ping) => ping.Send(TestSettings.LocalHost, TestSettings.PingTimeout, buffer), (pingReply) => { PingResultValidator(pingReply, localIpAddresses); // Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply. if (Capability.CanUseRawSockets(pingReply.Address.AddressFamily) || PlatformDetection.IsOSXLike) { Assert.Equal(buffer, pingReply.Buffer); } else { Assert.Equal(Array.Empty <byte>(), pingReply.Buffer); } }); }
public async Task SendPingAsyncWithIPAddressAndTimeoutAndBuffer_Unix() { byte[] buffer = TestSettings.PayloadAsBytes; IPAddress localIpAddress = await TestSettings.GetLocalIPAddressAsync(); await SendBatchPingAsync( (ping) => ping.SendPingAsync(localIpAddress, TestSettings.PingTimeout, buffer), (pingReply) => { PingResultValidator(pingReply, localIpAddress); // Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply. if (Capability.CanUseRawSockets(localIpAddress.AddressFamily) || PlatformDetection.IsOSXLike) { Assert.Equal(buffer, pingReply.Buffer); } else { Assert.Equal(Array.Empty <byte>(), pingReply.Buffer); } }); }
public async Task SendPingAsyncWithHostAndTimeoutAndBuffer_Unix() { IPAddress localIpAddress = await TestSettings.GetLocalIPAddress(); byte[] buffer = TestSettings.PayloadAsBytes; await SendBatchPingAsync( (ping) => ping.SendPingAsync(TestSettings.LocalHost, TestSettings.PingTimeout, buffer), (pingReply) => { Assert.Equal(IPStatus.Success, pingReply.Status); Assert.True(pingReply.Address.Equals(localIpAddress)); // Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply. if (Capability.CanUseRawSockets()) { Assert.Equal(buffer, pingReply.Buffer); } else { Assert.Equal(Array.Empty <byte>(), pingReply.Buffer); } }); }
private static byte[] GetPingPayload(AddressFamily addressFamily) // On Unix, Non-root processes cannot send arbitrary data in the ping packet payload => Capability.CanUseRawSockets(addressFamily) || PlatformDetection.IsOSXLike ? TestSettings.PayloadAsBytes : Array.Empty <byte>();