Imported Upstream version 5.0.0.42

Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-04-10 11:41:01 +00:00
parent 1190d13a04
commit 6bdd276d05
19939 changed files with 3099680 additions and 93811 deletions

View File

@ -41,8 +41,6 @@ namespace System.Net.NetworkInformation {
protected UnixNetworkInterface iface;
List <IPAddress> addresses;
IPAddressCollection dns_servers;
string dns_suffix;
DateTime last_parse;
public UnixIPInterfaceProperties (UnixNetworkInterface iface, List <IPAddress> addresses)
{
@ -83,6 +81,10 @@ namespace System.Net.NetworkInformation {
#else
static Regex ns = new Regex (@"\s*nameserver\s+(?<address>.*)");
static Regex search = new Regex (@"\s*search\s+(?<domain>.*)");
string dns_suffix;
DateTime last_parse;
void ParseResolvConf ()
{
try {
@ -324,7 +326,7 @@ namespace System.Net.NetworkInformation {
}
}
#if !MOBILE
#if WIN_PLATFORM
class Win32IPInterfaceProperties2 : IPInterfaceProperties
{
readonly Win32_IP_ADAPTER_ADDRESSES addr;
@ -340,13 +342,13 @@ namespace System.Net.NetworkInformation {
public override IPv4InterfaceProperties GetIPv4Properties ()
{
Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
return v4info != null ? new Win32IPv4InterfaceProperties (v4info, mib4) : null;
return new Win32IPv4InterfaceProperties (v4info, mib4);
}
public override IPv6InterfaceProperties GetIPv6Properties ()
{
Win32_IP_ADAPTER_INFO v6info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib6.Index);
return v6info != null ? new Win32IPv6InterfaceProperties (mib6) : null;
return new Win32IPv6InterfaceProperties (mib6);
}
public override IPAddressInformationCollection AnycastAddresses {
@ -371,7 +373,11 @@ namespace System.Net.NetworkInformation {
get {
Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
// FIXME: should ipv6 DhcpServer be considered?
return v4info != null ? new Win32IPAddressCollection (v4info.DhcpServer) : Win32IPAddressCollection.Empty;
try {
return new Win32IPAddressCollection (v4info.DhcpServer);
} catch (IndexOutOfRangeException) {
return Win32IPAddressCollection.Empty;
}
}
}
@ -385,18 +391,17 @@ namespace System.Net.NetworkInformation {
public override GatewayIPAddressInformationCollection GatewayAddresses {
get {
Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
// FIXME: should ipv6 DhcpServer be considered?
var col = new GatewayIPAddressInformationCollection ();
if (v4info != null) {
try {
Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
// FIXME: should ipv6 DhcpServer be considered?
var a = v4info.GatewayList;
if (!String.IsNullOrEmpty (a.IpAddress)) {
col.InternalAdd(new SystemGatewayIPAddressInformation(IPAddress.Parse (a.IpAddress)));
AddSubsequently (a.Next, col);
}
}
} catch (IndexOutOfRangeException) {}
return col;
}
}
@ -411,7 +416,7 @@ namespace System.Net.NetworkInformation {
}
public override bool IsDnsEnabled {
get { return Win32_FIXED_INFO.Instance.EnableDns != 0; }
get { return Win32NetworkInterface.FixedInfo.EnableDns != 0; }
}
public override bool IsDynamicDnsEnabled {
@ -438,28 +443,36 @@ namespace System.Net.NetworkInformation {
public override UnicastIPAddressInformationCollection UnicastAddresses {
get {
Win32_IP_ADAPTER_INFO ai = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
// FIXME: should ipv6 DhcpServer be considered?
return ai != null ? Win32FromUnicast ((int) ai.Index, addr.FirstUnicastAddress) : new UnicastIPAddressInformationCollection ();
try {
Win32_IP_ADAPTER_INFO ai = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
// FIXME: should ipv6 DhcpServer be considered?
return Win32FromUnicast (addr.FirstUnicastAddress);
} catch (IndexOutOfRangeException) {
return new UnicastIPAddressInformationCollection ();
}
}
}
static UnicastIPAddressInformationCollection Win32FromUnicast (int ifIndex, IntPtr ptr)
static UnicastIPAddressInformationCollection Win32FromUnicast (IntPtr ptr)
{
UnicastIPAddressInformationCollection c = new UnicastIPAddressInformationCollection ();
Win32_IP_ADAPTER_UNICAST_ADDRESS a;
for (IntPtr p = ptr; p != IntPtr.Zero; p = a.Next) {
a = (Win32_IP_ADAPTER_UNICAST_ADDRESS) Marshal.PtrToStructure (p, typeof (Win32_IP_ADAPTER_UNICAST_ADDRESS));
c.InternalAdd (new Win32UnicastIPAddressInformation (ifIndex, a));
c.InternalAdd (new Win32UnicastIPAddressInformation (a));
}
return c;
}
public override IPAddressCollection WinsServersAddresses {
get {
Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
// FIXME: should ipv6 DhcpServer be considered?
return v4info != null ? new Win32IPAddressCollection (v4info.PrimaryWinsServer, v4info.SecondaryWinsServer) : Win32IPAddressCollection.Empty;
try {
Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
// FIXME: should ipv6 DhcpServer be considered?
return new Win32IPAddressCollection (v4info.PrimaryWinsServer, v4info.SecondaryWinsServer);
} catch (IndexOutOfRangeException) {
return Win32IPAddressCollection.Empty;
}
}
}