Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -4,6 +4,7 @@
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
// Marek Safar (marek.safar@gmail.com)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
@@ -43,6 +44,9 @@ namespace System.Net.NetworkInformation {
public static IPGlobalProperties GetIPGlobalProperties ()
{
#if MONODROID
return new AndroidIPGlobalProperties ();
#else
switch (Environment.OSVersion.Platform) {
case PlatformID.Unix:
MibIPGlobalProperties impl = null;
@@ -56,10 +60,16 @@ namespace System.Net.NetworkInformation {
if (File.Exists (impl.StatisticsFile))
return impl;
}
throw new NotSupportedException ("This platform is not supported");
return new UnixIPGlobalProperties ();
default:
return new Win32IPGlobalProperties ();
}
#endif
}
internal static IPGlobalProperties InternalGetIPGlobalProperties()
{
return GetIPGlobalProperties ();
}
public abstract TcpConnectionInformation [] GetActiveTcpConnections ();
@@ -81,11 +91,7 @@ namespace System.Net.NetworkInformation {
public abstract NetBiosNodeType NodeType { get; }
}
// It expects /proc/net/snmp (or /usr/compat/linux/proc/net/snmp),
// formatted like:
// http://www.linuxdevcenter.com/linux/2000/11/16/example5.html
// http://www.linuxdevcenter.com/linux/2000/11/16/example2.html
class MibIPGlobalProperties : IPGlobalProperties
abstract class CommonUnixIPGlobalProperties : IPGlobalProperties
{
[DllImport ("libc")]
static extern int gethostname ([MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 1)] byte [] name, int len);
@@ -93,6 +99,112 @@ namespace System.Net.NetworkInformation {
[DllImport ("libc")]
static extern int getdomainname ([MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 1)] byte [] name, int len);
public override string DhcpScopeName {
get { return String.Empty; }
}
public override string DomainName {
get {
byte [] bytes = new byte [256];
if (getdomainname (bytes, 256) != 0)
throw new NetworkInformationException ();
int len = Array.IndexOf<byte> (bytes, 0);
return Encoding.ASCII.GetString (bytes, 0, len < 0 ? 256 : len);
}
}
public override string HostName {
get {
byte [] bytes = new byte [256];
if (gethostname (bytes, 256) != 0)
throw new NetworkInformationException ();
int len = Array.IndexOf<byte> (bytes, 0);
return Encoding.ASCII.GetString (bytes, 0, len < 0 ? 256 : len);
}
}
public override bool IsWinsProxy {
get { return false; } // no WINS
}
public override NetBiosNodeType NodeType {
get { return NetBiosNodeType.Unknown; } // no NetBios
}
}
class UnixIPGlobalProperties : CommonUnixIPGlobalProperties
{
public override TcpConnectionInformation [] GetActiveTcpConnections ()
{
throw new NotImplementedException ();
}
public override IPEndPoint [] GetActiveTcpListeners ()
{
throw new NotImplementedException ();
}
public override IPEndPoint [] GetActiveUdpListeners ()
{
throw new NotImplementedException ();
}
public override IcmpV4Statistics GetIcmpV4Statistics ()
{
throw new NotImplementedException ();
}
public override IcmpV6Statistics GetIcmpV6Statistics ()
{
throw new NotImplementedException ();
}
public override IPGlobalStatistics GetIPv4GlobalStatistics ()
{
throw new NotImplementedException ();
}
public override IPGlobalStatistics GetIPv6GlobalStatistics ()
{
throw new NotImplementedException ();
}
public override TcpStatistics GetTcpIPv4Statistics ()
{
throw new NotImplementedException ();
}
public override TcpStatistics GetTcpIPv6Statistics ()
{
throw new NotImplementedException ();
}
public override UdpStatistics GetUdpIPv4Statistics ()
{
throw new NotImplementedException ();
}
public override UdpStatistics GetUdpIPv6Statistics ()
{
throw new NotImplementedException ();
}
}
sealed class AndroidIPGlobalProperties : UnixIPGlobalProperties
{
public override string DomainName {
get {
return String.Empty;
}
}
}
// It expects /proc/net/snmp (or /usr/compat/linux/proc/net/snmp),
// formatted like:
// http://www.linuxdevcenter.com/linux/2000/11/16/example5.html
// http://www.linuxdevcenter.com/linux/2000/11/16/example2.html
class MibIPGlobalProperties : UnixIPGlobalProperties
{
public const string ProcDir = "/proc";
public const string CompatProcDir = "/usr/compat/linux/proc";
@@ -289,38 +401,6 @@ namespace System.Net.NetworkInformation {
{
return new MibUdpStatistics (GetProperties6 ("Udp6"));
}
public override string DhcpScopeName {
get { return String.Empty; }
}
public override string DomainName {
get {
byte [] bytes = new byte [256];
if (getdomainname (bytes, 256) != 0)
throw new NetworkInformationException ();
int len = Array.IndexOf<byte> (bytes, 0);
return Encoding.ASCII.GetString (bytes, 0, len < 0 ? 256 : len);
}
}
public override string HostName {
get {
byte [] bytes = new byte [256];
if (gethostname (bytes, 256) != 0)
throw new NetworkInformationException ();
int len = Array.IndexOf<byte> (bytes, 0);
return Encoding.ASCII.GetString (bytes, 0, len < 0 ? 256 : len);
}
}
public override bool IsWinsProxy {
get { return false; } // no WINS
}
public override NetBiosNodeType NodeType {
get { return NetBiosNodeType.Unknown; } // no NetBios
}
}
class Win32IPGlobalProperties : IPGlobalProperties