You've already forked linux-packaging-mono
Imported Upstream version 4.3.2.467
Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
@@ -92,6 +92,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
class Win32GatewayIPAddressInformationCollection : GatewayIPAddressInformationCollection
|
||||
{
|
||||
public static readonly Win32GatewayIPAddressInformationCollection Empty = new Win32GatewayIPAddressInformationCollection (true);
|
||||
@@ -127,6 +128,7 @@ namespace System.Net.NetworkInformation {
|
||||
get { return is_readonly; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
class UnixGatewayIPAddressInformationCollection : GatewayIPAddressInformationCollection
|
||||
{
|
||||
|
||||
@@ -100,6 +100,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
class Win32IPAddressCollection : IPAddressCollection
|
||||
{
|
||||
public static readonly Win32IPAddressCollection Empty = new Win32IPAddressCollection (IntPtr.Zero);
|
||||
@@ -168,6 +169,7 @@ namespace System.Net.NetworkInformation {
|
||||
get { return is_readonly; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ namespace System.Net.NetworkInformation {
|
||||
get { return is_readonly; }
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
public static IPAddressInformationCollection Win32FromAnycast (IntPtr ptr)
|
||||
{
|
||||
IPAddressInformationImplCollection c = new IPAddressInformationImplCollection (false);
|
||||
@@ -123,6 +124,7 @@ namespace System.Net.NetworkInformation {
|
||||
c.is_readonly = true;
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
|
||||
public static IPAddressInformationImplCollection LinuxFromAnycast (IList<IPAddress> addresses)
|
||||
{
|
||||
|
||||
@@ -46,6 +46,8 @@ namespace System.Net.NetworkInformation {
|
||||
{
|
||||
#if MONODROID
|
||||
return new AndroidIPGlobalProperties ();
|
||||
#elif MONOTOUCH || XAMMAC || MOBILE_STATIC
|
||||
return new UnixIPGlobalProperties ();
|
||||
#else
|
||||
switch (Environment.OSVersion.Platform) {
|
||||
case PlatformID.Unix:
|
||||
@@ -190,6 +192,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
|
||||
#if MONODROID
|
||||
sealed class AndroidIPGlobalProperties : UnixIPGlobalProperties
|
||||
{
|
||||
public override string DomainName {
|
||||
@@ -198,6 +201,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// It expects /proc/net/snmp (or /usr/compat/linux/proc/net/snmp),
|
||||
// formatted like:
|
||||
@@ -403,6 +407,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
class Win32IPGlobalProperties : IPGlobalProperties
|
||||
{
|
||||
public const int AF_INET = 2;
|
||||
@@ -736,4 +741,5 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
class Win32IPGlobalStatistics : IPGlobalStatistics
|
||||
{
|
||||
Win32_MIB_IPSTATS info;
|
||||
@@ -218,7 +219,7 @@ namespace System.Net.NetworkInformation {
|
||||
get { return info.InUnknownProtos; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[StructLayout (LayoutKind.Sequential)]
|
||||
struct Win32_MIB_IPSTATS
|
||||
{
|
||||
@@ -246,5 +247,6 @@ namespace System.Net.NetworkInformation {
|
||||
public int NumAddr;
|
||||
public int NumRoutes;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -325,6 +325,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
class Win32IPInterfaceProperties2 : IPInterfaceProperties
|
||||
{
|
||||
readonly Win32_IP_ADAPTER_ADDRESSES addr;
|
||||
@@ -406,6 +407,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
sealed class Win32IPv4InterfaceProperties : IPv4InterfaceProperties
|
||||
{
|
||||
[DllImport ("iphlpapi.dll")]
|
||||
@@ -198,5 +199,6 @@ namespace System.Net.NetworkInformation {
|
||||
public IntPtr CurrentDnsServer; // to Win32_IP_ADDR_STRING
|
||||
public Win32_IP_ADDR_STRING DnsServerList;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
namespace System.Net.NetworkInformation {
|
||||
#if !MOBILE
|
||||
class Win32IPv4InterfaceStatistics : IPv4InterfaceStatistics
|
||||
{
|
||||
Win32_MIB_IFROW info;
|
||||
@@ -86,6 +87,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
class LinuxIPv4InterfaceStatistics : IPv4InterfaceStatistics
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace System.Net.NetworkInformation {
|
||||
public abstract int Index { get; }
|
||||
public abstract int Mtu { get; }
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
class Win32IPv6InterfaceProperties : IPv6InterfaceProperties
|
||||
{
|
||||
Win32_MIB_IFROW mib;
|
||||
@@ -53,5 +53,6 @@ namespace System.Net.NetworkInformation {
|
||||
get { return mib.Mtu; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -157,6 +157,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
class Win32IcmpV4Statistics : IcmpV4Statistics
|
||||
{
|
||||
Win32_MIBICMPSTATS iin, iout;
|
||||
@@ -269,5 +270,6 @@ namespace System.Net.NetworkInformation {
|
||||
public uint AddrMasks;
|
||||
public uint AddrMaskReps;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -201,6 +201,7 @@ namespace System.Net.NetworkInformation {
|
||||
public const int RouterRenumbering = 138;
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
class Win32IcmpV6Statistics : IcmpV6Statistics
|
||||
{
|
||||
Win32_MIBICMPSTATS_EX iin, iout;
|
||||
@@ -322,5 +323,6 @@ namespace System.Net.NetworkInformation {
|
||||
[MarshalAs (UnmanagedType.ByValArray, SizeConst = 256)]
|
||||
public uint [] Counts;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ namespace System.Net.NetworkInformation {
|
||||
get { return is_readonly; }
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
public static MulticastIPAddressInformationCollection Win32FromMulticast (IntPtr ptr)
|
||||
{
|
||||
MulticastIPAddressInformationImplCollection c = new MulticastIPAddressInformationImplCollection (false);
|
||||
@@ -123,6 +124,7 @@ namespace System.Net.NetworkInformation {
|
||||
c.is_readonly = true;
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
|
||||
public static MulticastIPAddressInformationImplCollection LinuxFromList (List<IPAddress> addresses)
|
||||
{
|
||||
|
||||
@@ -250,6 +250,10 @@ namespace System.Net.NetworkInformation {
|
||||
|
||||
class LinuxNetworkInterfaceAPI : UnixNetworkInterfaceAPI
|
||||
{
|
||||
const int AF_INET = 2;
|
||||
const int AF_INET6 = 10;
|
||||
const int AF_PACKET = 17;
|
||||
|
||||
static void FreeInterfaceAddresses (IntPtr ifap)
|
||||
{
|
||||
#if MONODROID
|
||||
@@ -270,9 +274,6 @@ namespace System.Net.NetworkInformation {
|
||||
|
||||
public override NetworkInterface [] GetAllNetworkInterfaces ()
|
||||
{
|
||||
const int AF_INET = 2;
|
||||
const int AF_INET6 = 10;
|
||||
const int AF_PACKET = 17;
|
||||
|
||||
var interfaces = new Dictionary <string, LinuxNetworkInterface> ();
|
||||
IntPtr ifap;
|
||||
@@ -406,10 +407,47 @@ namespace System.Net.NetworkInformation {
|
||||
|
||||
public override IPAddress GetNetMask (IPAddress address)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
foreach (ifaddrs networkInteface in GetNetworkInterfaces()) {
|
||||
if (networkInteface.ifa_addr == IntPtr.Zero)
|
||||
continue;
|
||||
|
||||
var sockaddr = (sockaddr_in)Marshal.PtrToStructure(networkInteface.ifa_addr, typeof(sockaddr_in));
|
||||
|
||||
if (sockaddr.sin_family != AF_INET)
|
||||
continue;
|
||||
|
||||
if (!address.Equals(new IPAddress(sockaddr.sin_addr)))
|
||||
continue;
|
||||
|
||||
var netmask = (sockaddr_in)Marshal.PtrToStructure(networkInteface.ifa_netmask, typeof(sockaddr_in));
|
||||
return new IPAddress(netmask.sin_addr);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static IEnumerable<ifaddrs> GetNetworkInterfaces()
|
||||
{
|
||||
IntPtr ifap = IntPtr.Zero;
|
||||
|
||||
try {
|
||||
if (GetInterfaceAddresses(out ifap) != 0)
|
||||
yield break;
|
||||
|
||||
var next = ifap;
|
||||
while (next != IntPtr.Zero) {
|
||||
var addr = (ifaddrs)Marshal.PtrToStructure(next, typeof(ifaddrs));
|
||||
yield return addr;
|
||||
next = addr.ifa_next;
|
||||
}
|
||||
} finally {
|
||||
if (ifap != IntPtr.Zero)
|
||||
FreeInterfaceAddresses(ifap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
class Win32NetworkInterfaceAPI : NetworkInterfaceFactory
|
||||
{
|
||||
[DllImport ("iphlpapi.dll", SetLastError = true)]
|
||||
@@ -457,6 +495,7 @@ namespace System.Net.NetworkInformation {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public abstract NetworkInterface [] GetAllNetworkInterfaces ();
|
||||
public abstract int GetLoopbackInterfaceIndex ();
|
||||
@@ -464,7 +503,7 @@ namespace System.Net.NetworkInformation {
|
||||
|
||||
public static NetworkInterfaceFactory Create ()
|
||||
{
|
||||
#if MONOTOUCH
|
||||
#if MONOTOUCH || XAMMAC
|
||||
return new MacOsNetworkInterfaceAPI ();
|
||||
#else
|
||||
Version windowsVer51 = new Version (5, 1);
|
||||
@@ -477,8 +516,10 @@ namespace System.Net.NetworkInformation {
|
||||
return new LinuxNetworkInterfaceAPI ();
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
if (Environment.OSVersion.Version >= windowsVer51)
|
||||
return new Win32NetworkInterfaceAPI ();
|
||||
#endif
|
||||
|
||||
throw new NotImplementedException ();
|
||||
#endif
|
||||
@@ -718,6 +759,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
class Win32NetworkInterface2 : NetworkInterface
|
||||
{
|
||||
[DllImport ("iphlpapi.dll", SetLastError = true)]
|
||||
@@ -830,5 +872,6 @@ namespace System.Net.NetworkInformation {
|
||||
get { return !addr.NoMulticast; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// Atsushi Enomoto (atsushi@ximian.com)
|
||||
//
|
||||
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
|
||||
// Copyright 2015 Xamarin Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -26,6 +27,7 @@
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
@@ -43,6 +45,7 @@ namespace System.Net.NetworkInformation {
|
||||
[MonoTODO ("IPv6 support is missing")]
|
||||
public class Ping : Component, IDisposable
|
||||
{
|
||||
#if !MONOTOUCH
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct cap_user_header_t
|
||||
{
|
||||
@@ -68,6 +71,7 @@ namespace System.Net.NetworkInformation {
|
||||
#endif
|
||||
};
|
||||
static readonly string PingBinPath;
|
||||
#endif
|
||||
const int default_timeout = 4000; // 4 sec.
|
||||
ushort identifier;
|
||||
|
||||
@@ -84,7 +88,8 @@ namespace System.Net.NetworkInformation {
|
||||
CancellationTokenSource cts;
|
||||
|
||||
public event PingCompletedEventHandler PingCompleted;
|
||||
|
||||
|
||||
#if !MONOTOUCH
|
||||
static Ping ()
|
||||
{
|
||||
if (Environment.OSVersion.Platform == PlatformID.Unix) {
|
||||
@@ -106,6 +111,7 @@ namespace System.Net.NetworkInformation {
|
||||
if (PingBinPath == null)
|
||||
PingBinPath = "/bin/ping"; // default, fallback value
|
||||
}
|
||||
#endif
|
||||
|
||||
public Ping ()
|
||||
{
|
||||
@@ -115,7 +121,8 @@ namespace System.Net.NetworkInformation {
|
||||
rng.GetBytes (randomIdentifier);
|
||||
identifier = (ushort)(randomIdentifier [0] + (randomIdentifier [1] << 8));
|
||||
}
|
||||
|
||||
|
||||
#if !MONOTOUCH
|
||||
[DllImport ("libc", EntryPoint="capget")]
|
||||
static extern int capget (ref cap_user_header_t header, ref cap_user_data_t data);
|
||||
|
||||
@@ -142,6 +149,7 @@ namespace System.Net.NetworkInformation {
|
||||
canSendPrivileged = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void IDisposable.Dispose ()
|
||||
{
|
||||
@@ -215,11 +223,16 @@ namespace System.Net.NetworkInformation {
|
||||
throw new ArgumentException ("buffer");
|
||||
// options can be null.
|
||||
|
||||
#if MONOTOUCH
|
||||
throw new InvalidOperationException ();
|
||||
#else
|
||||
if (canSendPrivileged)
|
||||
return SendPrivileged (address, timeout, buffer, options);
|
||||
return SendUnprivileged (address, timeout, buffer, options);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !MONOTOUCH
|
||||
private PingReply SendPrivileged (IPAddress address, int timeout, byte [] buffer, PingOptions options)
|
||||
{
|
||||
IPEndPoint target = new IPEndPoint (address, 0);
|
||||
@@ -286,6 +299,7 @@ namespace System.Net.NetworkInformation {
|
||||
|
||||
private PingReply SendUnprivileged (IPAddress address, int timeout, byte [] buffer, PingOptions options)
|
||||
{
|
||||
#if MONO_FEATURE_PROCESS_START
|
||||
DateTime sentTime = DateTime.UtcNow;
|
||||
|
||||
Process ping = new Process ();
|
||||
@@ -325,7 +339,11 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
|
||||
return new PingReply (address, buffer, options, trip_time, status);
|
||||
#else
|
||||
throw new PlatformNotSupportedException ("Ping is not supported on this platform.");
|
||||
#endif // MONO_FEATURE_PROCESS_START
|
||||
}
|
||||
#endif // !MONOTOUCH
|
||||
|
||||
// Async
|
||||
|
||||
@@ -401,6 +419,7 @@ namespace System.Net.NetworkInformation {
|
||||
worker.CancelAsync ();
|
||||
}
|
||||
|
||||
#if !MONOTOUCH
|
||||
// ICMP message
|
||||
|
||||
class IcmpMessage
|
||||
@@ -534,6 +553,7 @@ namespace System.Net.NetworkInformation {
|
||||
|
||||
return args.ToString ();
|
||||
}
|
||||
#endif // !MONOTOUCH
|
||||
|
||||
public Task<PingReply> SendPingAsync (IPAddress address, int timeout, byte [] buffer)
|
||||
{
|
||||
@@ -592,4 +612,3 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
class Win32TcpStatistics : TcpStatistics
|
||||
{
|
||||
Win32_MIB_TCPSTATS info;
|
||||
@@ -193,6 +194,6 @@ namespace System.Net.NetworkInformation {
|
||||
public uint OutRsts;
|
||||
public uint NumConns;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
class Win32UdpStatistics : UdpStatistics
|
||||
{
|
||||
Win32_MIB_UDPSTATS info;
|
||||
@@ -111,5 +112,6 @@ namespace System.Net.NetworkInformation {
|
||||
public uint OutDatagrams;
|
||||
public int NumAddrs;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace System.Net.NetworkInformation {
|
||||
#if !MOBILE
|
||||
class Win32UnicastIPAddressInformation : UnicastIPAddressInformation
|
||||
{
|
||||
int if_index;
|
||||
@@ -105,6 +106,7 @@ namespace System.Net.NetworkInformation {
|
||||
get { return info.SuffixOrigin; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
class LinuxUnicastIPAddressInformation : UnicastIPAddressInformation
|
||||
{
|
||||
|
||||
@@ -111,6 +111,7 @@ namespace System.Net.NetworkInformation {
|
||||
get { return is_readonly; }
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
public static UnicastIPAddressInformationCollection Win32FromUnicast (int ifIndex, IntPtr ptr)
|
||||
{
|
||||
UnicastIPAddressInformationImplCollection c = new UnicastIPAddressInformationImplCollection (false);
|
||||
@@ -122,6 +123,7 @@ namespace System.Net.NetworkInformation {
|
||||
c.is_readonly = true;
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
|
||||
public static UnicastIPAddressInformationCollection LinuxFromList (List<IPAddress> addresses)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user