Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,315 @@
2010-07-05 Gonzalo Paniagua Javier <gonzalo@novell.com>
* NetworkInterface.cs: avoid endless loop when a bad length is
received for AF_PACKET. Fixes bug #601783.
2010-06-22 Gonzalo Paniagua Javier <gonzalo@novell.com>
* Ping.cs: we need to read the output to give the process time
to start. Fixes bug #591136.
2010-03-25 Marek Safar <marek.safar@gmail.com>
* IPGlobalProperties.cs: Made Win32_IN6_ADDR verifiable.
2009-12-07 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* Ping.cs: Try to detect the path to the bin command, since different
Unix systems store it in different places.
Fixes #519272.
2009-10-06 Gonzalo Paniagua Javier <gonzalo@novell.com>
* GatewayIPAddressInformationCollection.cs:
* IPInterfaceProperties.cs: implement GatewayAddresses for linux.
Original patch by Christoph von Wittich.
Fixes bug #544640.
2009-09-29 Gonzalo Paniagua Javier <gonzalo@novell.com>
* Ping.cs: fix the check for a time-out return value from 'ping'.
2009-09-24 Zoltan Varga <vargaz@gmail.com>
* LinuxNetworkInterfaceMarshal.cs: Add StructLayout attribute to structures, so
the aot compiler can generate PtrToStructure wrappers for them.
2009-09-19 Gonzalo Paniagua Javier <gonzalo@novell.com>
* Ping.cs: if we receive a packet that is ignored, adjust the
timeout. Fixes bug #538013.
2009-05-16 Miguel de Icaza <miguel@novell.com>
* Apply patch from Alex Shulgin
<alexander.shulgin@yessoftware.com> to support OSX in
NetworkInformation classes.
2009-05-03 Gonzalo Paniagua Javier <gonzalo@novell.com>
* Ping.cs: we just need the address(es), not a host entry. This avoids
querying the DNS server(s) when the target is an IP address.
2009-03-24 Gonzalo Paniagua Javier <gonzalo@novell.com>
* Ping.cs: MacOS has different arguments for ping.
Bug #486904 fixed.
2009-01-26 Christian Prochnow <cproch@seculogix.de>
* Ping.cs: ignore ICMP echo request packet in case we ping
localhost.
2009-01-11 Atsushi Enomoto <atsushi@ximian.com>
* NetworkInformationPermission.cs,
NetworkInformationPermissionAttribute.cs : implement some,
otherwise it blocks compilation.
2008-12-20 Gonzalo Paniagua Javier <gonzalo@novell.com>
* Ping.cs: use the new internal method in Socket to avoid having to
throw exceptions when there's a timeout.
2008-12-11 Gonzalo Paniagua Javier <gonzalo@novell.com>
* Ping.cs: close the socket in SendPrivileged. Use Buffer.BlockCopy
instead of Array.Copy. Return IPStatus.Unknown instead of throwing an
exception for unknown status codes received.
2008-11-29 Miguel De Icaza <miguel@novell.com>
* NetworkInterface.cs: Do not throw an exception when scanning
external kernel information that might cause problems. The
application should not crash just trying to fetch interfaces from
the system.
2008-11-20 Gonzalo Paniagua Javier <gonzalo@novell.com>
* Ping.cs: the time for the arguments of 'ping' is in seconds. Don't
read the output of running the command, since we trust the return
code.
2008-10-27 Atsushi Enomoto <atsushi@ximian.com>
* Ping.cs : use privileged mode for non-unix. On Windows there is
no /usr/bin/ping.
2008-10-04 Gonzalo Paniagua Javier <gonzalo@novell.com>
* NetworkInterface.cs: detect wireless 802.11 on linux.
2008-09-28 Gonzalo Paniagua Javier <gonzalo.mono@gmail.com>
* NetworkInterface.cs: special case for loopback interfaces so that
their a physical interface address is PhysicalInterfaceAddress.None.
Fixes bug #422118.
2008-08-15 Atsushi Enomoto <atsushi@ximian.com>
* IPInterfaceProperties.cs, UnicastIPAddressInformation.cs,
UnicastIPAddressInformationCollection.cs : fixed bug #416526, based
on the patch by Fredrik Kling. support UnicastIPAddressInformation
on win32.
2008-08-06 Atsushi Enomoto <atsushi@ximian.com>
* IPGlobalProperties.cs : fixed ToEndPoint() to not bork at
parsing IPv6 string. Fixed bug #410006.
2008-07-31 Jb Evain <jbevain@novell.com>
* NetworkInformationException.cs: cleanup for NET_2_1.
2008-07-17 Marek Habersack <mhabersack@novell.com>
* IPInterfaceProperties.cs: implemented UnicastAddresses
2008-07-14 Marek Habersack <mhabersack@novell.com>
* NetworkInterface.cs: implemented support for Linux. Parts
contributed by Eric Butler (eric@extremeboredom.net), thanks!
* GatewayIPAddressInformationCollection.cs,
IPInterfaceProperties.cs, IPAddressInformationCollection.cs: added
support for Linux. Patch contributed by Eric Butler
(eric@extremeboredom.net), thanks!
* IPv4InterfaceProperties.cs: implemented support for Linux.
* LinuxNetworkInterfaceMarshal.cs: added. Contains a set of
Linux-specific structures required for accessing the network
information. Patch contributed by Eric Butler
(eric@extremeboredom.net), thanks!
* MulticastIPAddressInformation.cs: added support for Linux
multicast information. Patch contributed by Eric Butler
(eric@extremeboredom.net), thanks!
* IPv4InterfaceStatistics.cs: use the parent IfacePath to get the
path to the interface description file.
* UnicastIPAddressInformation.cs: added stubs for
LinuxUnicastIPAddressInformation. Patch contributed by Eric Butler
(eric@extremeboredom.net), thanks!
* Ping.cs: Use /bin/ping when running as non-root user
(implementation by Jackson Harper <jaharper@novell.com>) or use
raw sockets if running as root or if the current process has the
CAP_NET_RAW Linux capability set while running as an unprivileged
user.
2008-03-07 Miguel de Icaza <miguel@novell.com>
* NetworkInterface.cs: Use GetFileSystemEntries, on some systems
the files do not appear to be symlinks, but directories.
2008-02-18 Miguel de Icaza <miguel@novell.com>
* IPv4InterfaceStatistics.cs: Implemented Linux support.
* NetworkInterface.cs: Implemented Linux support.
TODO: still missing GetIPProperties.
2007-10-23 Atsushi Enomoto <atsushi@ximian.com>
* Ping.cs : Do not call OnPingCompleted() at CancelAsync() it should
be called at RunWorkerCompleted. Simplified RunWorkerCompleted.
2007-09-29 Miguel de Icaza <miguel@novell.com>
* NetworkInterface.cs (GetAllNetworkInterfaces): return an empty
array instead of throwing an exception on operating systems where
we can not detect the network interfaces.
2007-09-07 Atsushi Enomoto <atsushi@ximian.com>
* IPGlobalProperties.cs : implemented properties on linux.
2007-09-06 Atsushi Enomoto <atsushi@ximian.com>
* Ping.cs, PingReply.cs, PingCompletedEventArgs.cs : implemented
in managed code.
2007-09-03 Atsushi Enomoto <atsushi@ximian.com>
* IPGlobalStatistics.cs : Mib-* class is nonpublic.
* Win32NetworkInterfaceMarshal.cs IPv4InterfaceProperties.cs
IPGlobalProperties.cs IPInterfaceProperties.cs
NetworkInterface.cs : move Win32NetworkInterfaceMarshal.FixedInfo to
Win32_FIXED_INFO.Instance and share it with Win32IPGlobalProperties.
Fixed GetUdp[6]Table() / GetTcp[6]Table() marshalling issue.
2007-08-29 Atsushi Enomoto <atsushi@ximian.com>
* NetworkInterface.cs,
IPv4InterfaceStatistics.cs
IPInterfaceProperties.cs
IPv4InterfaceProperties.cs
IPv6InterfaceProperties.cs
IPAddressCollection.cs
GatewayIPAddressInformation.cs
GatewayIPAddressInformationCollection.cs
IPAddressInformation.cs
IPAddressInformationCollection.cs
MulticastIPAddressInformation.cs
MulticastIPAddressInformationCollection.cs
UnicastIPAddressInformation.cs
UnicastIPAddressInformationCollection.cs
Win32NetworkInterfaceMarshal.cs (new) :
NetworkInterface implementation using Win32 API.
Not sure how MIB-based implementation (for Linux) is possible but
it will follow.
2007-08-27 Atsushi Enomoto <atsushi@ximian.com>
* IPGlobalProperties.cs : implemented remaining methods in
MibIPGlobalProperties. Support /usr/compat/linux/proc
for some BSD environment.
2007-08-27 Atsushi Enomoto <atsushi@ximian.com>
* IPGlobalProperties.cs, TcpStatistics.cs,
IPGlobalStatistics.cs, IcmpV4Statistics.cs,
IcmpV6Statistics.cs, UdpStatistics.cs :
and here is non-Windows version, based on /proc/net/snmp(6).
2007-08-27 Atsushi Enomoto <atsushi@ximian.com>
* IPGlobalProperties.cs, TcpConnectionInformation.cs,
TcpStatistics.cs, IPGlobalStatistics.cs, IcmpV4Statistics.cs,
IcmpV6Statistics.cs, UdpStatistics.cs :
initial implementation of IPGlobalProperties and its children
for Win32 API, mostly done. Non-Windows implementation should
follow.
2007-08-13 Alan McGovern <amcgovern@novell.com>
* PhysicalAddress.cs: Added patch for #82403 to fix some parsing
errors and a bug in .Equals()
2006-03-11 Miguel de Icaza <miguel@novell.com>
* NetworkChange.cs: Use pragmas to eliminate warnings from events
that we do not trigger yet.
This is a candidate for using Aaron's NetworkManager code. But
would make us depend on d-bus.
* NetworkInformationException.cs: Use error_code for ErrorCode,
instead of NativeErrorCode. Fixes warning.
2006-02-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* UnicastIPAddressInformation.cs:
* PingException.cs:
* TcpConnectionInformation.cs:
* IPv4InterfaceStatistics.cs:
* NetworkInformationException.cs:
* IPAddressInformation.cs:
* MulticastIPAddressInformationCollection.cs:
* TcpStatistics.cs:
* IPGlobalStatistics.cs:
* NetworkInformationPermission.cs:
* MulticastIPAddressInformation.cs:
* IcmpV4Statistics.cs:
* IcmpV6Statistics.cs:
* IPv4InterfaceProperties.cs:
* PhysicalAddress.cs:
* IPv6InterfaceProperties.cs:
* GatewayIPAddressInformationCollection.cs:
* ChangeLog: Modified file.
* UnicastIPAddressInformationCollection.cs:
* IPAddressCollection.cs:
* NetworkInformationPermissionAttribute.cs:
* Ping.cs:
* NetworkChange.cs:
* IPAddressInformationCollection.cs:
* UdpStatistics.cs:
* GatewayIPAddressInformation.cs:
* IPGlobalProperties.cs:
* IPInterfaceProperties.cs:
* NetworkInterface.cs: implemented or stubbed out.
2006-02-22 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* NetBiosNodeType.cs:
* IPStatus.cs:
* NetworkInterfaceType.cs:
* SuffixOrigin.cs:
* DuplicateAddressDetectionState.cs:
* NetworkInformationAccess.cs:
* OperationalStatus.cs:
* TcpState.cs:
* PingCompletedEventHandler.cs:
* NetworkInterfaceComponent.cs:
* NetworkAvailabilityChangedEventHandler.cs:
* NetworkAvailabilityEventArgs.cs:
* PrefixOrigin.cs:
* NetworkAddressChangedEventHandler.cs:
* PingCompletedEventArgs.cs:
* PingOptions.cs:
* PingReply.cs: all enums, all event handlers/args + 2 classes.

View File

@@ -0,0 +1,37 @@
//
// System.Net.NetworkInformation.DuplicateAddressDetectionState
//
// Author:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
//
// Copyright (c) 2006 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Net.NetworkInformation {
public enum DuplicateAddressDetectionState {
Invalid,
Tentative,
Duplicate,
Deprecated,
Preferred
}
}

View File

@@ -0,0 +1,52 @@
//
// System.Net.NetworkInformation.GatewayIPAddressInformation
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Net.NetworkInformation {
public abstract class GatewayIPAddressInformation {
protected GatewayIPAddressInformation ()
{
}
public abstract IPAddress Address { get; }
}
class GatewayIPAddressInformationImpl : GatewayIPAddressInformation
{
IPAddress address;
public GatewayIPAddressInformationImpl (IPAddress address)
{
this.address = address;
}
public override IPAddress Address {
get { return address; }
}
}
}

View File

@@ -0,0 +1,154 @@
//
// System.Net.NetworkInformation.GatewayIPAddressInformationCollection
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace System.Net.NetworkInformation {
public class GatewayIPAddressInformationCollection : ICollection<GatewayIPAddressInformation>, IEnumerable<GatewayIPAddressInformation>, IEnumerable {
List<GatewayIPAddressInformation> list = new List<GatewayIPAddressInformation> ();
protected GatewayIPAddressInformationCollection ()
{
}
public virtual void Add (GatewayIPAddressInformation address)
{
if (IsReadOnly)
throw new NotSupportedException ("The collection is read-only.");
list.Add (address);
}
public virtual void Clear ()
{
if (IsReadOnly)
throw new NotSupportedException ("The collection is read-only.");
list.Clear ();
}
public virtual bool Contains (GatewayIPAddressInformation address)
{
return list.Contains (address);
}
public virtual void CopyTo (GatewayIPAddressInformation [] array, int offset)
{
list.CopyTo (array, offset);
}
public virtual IEnumerator<GatewayIPAddressInformation> GetEnumerator ()
{
return ((IEnumerable<GatewayIPAddressInformation>)list).GetEnumerator ();
}
public virtual bool Remove (GatewayIPAddressInformation address)
{
if (IsReadOnly)
throw new NotSupportedException ("The collection is read-only.");
return list.Remove (address);
}
IEnumerator IEnumerable.GetEnumerator ()
{
return list.GetEnumerator ();
}
public virtual int Count {
get { return list.Count; }
}
public virtual bool IsReadOnly {
get { return true; }
}
public virtual GatewayIPAddressInformation this [int index] {
get { return list [index]; }
}
}
class Win32GatewayIPAddressInformationCollection : GatewayIPAddressInformationCollection
{
public static readonly Win32GatewayIPAddressInformationCollection Empty = new Win32GatewayIPAddressInformationCollection (true);
bool is_readonly;
private Win32GatewayIPAddressInformationCollection (bool isReadOnly)
{
this.is_readonly = isReadOnly;
}
public Win32GatewayIPAddressInformationCollection (params Win32_IP_ADDR_STRING [] al)
{
foreach (Win32_IP_ADDR_STRING a in al) {
if (String.IsNullOrEmpty (a.IpAddress))
continue;
Add (new GatewayIPAddressInformationImpl (IPAddress.Parse (a.IpAddress)));
AddSubsequently (a.Next);
}
is_readonly = true;
}
void AddSubsequently (IntPtr head)
{
Win32_IP_ADDR_STRING a;
for (IntPtr p = head; p != IntPtr.Zero; p = a.Next) {
a = (Win32_IP_ADDR_STRING) Marshal.PtrToStructure (p, typeof (Win32_IP_ADDR_STRING));
Add (new GatewayIPAddressInformationImpl (IPAddress.Parse (a.IpAddress)));
}
}
public override bool IsReadOnly {
get { return is_readonly; }
}
}
class LinuxGatewayIPAddressInformationCollection : GatewayIPAddressInformationCollection
{
public static readonly LinuxGatewayIPAddressInformationCollection Empty = new LinuxGatewayIPAddressInformationCollection (true);
bool is_readonly;
private LinuxGatewayIPAddressInformationCollection (bool isReadOnly)
{
this.is_readonly = isReadOnly;
}
public LinuxGatewayIPAddressInformationCollection (IPAddressCollection col)
{
foreach (IPAddress a in col)
Add (new GatewayIPAddressInformationImpl (a));
this.is_readonly = true;
}
public override bool IsReadOnly {
get { return is_readonly; }
}
}
}

View File

@@ -0,0 +1,173 @@
//
// System.Net.NetworkInformation.IPAddressCollection
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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.Collections;
using System.Collections.Generic;
using System.Net;
using System.Runtime.InteropServices;
namespace System.Net.NetworkInformation {
public class IPAddressCollection : ICollection<IPAddress>, IEnumerable<IPAddress>, IEnumerable {
IList <IPAddress> list = new List<IPAddress> ();
protected internal IPAddressCollection ()
{
}
internal void SetReadOnly ()
{
if (!IsReadOnly)
list = ((List<IPAddress>) list).AsReadOnly ();
}
public virtual void Add (IPAddress address)
{
if (IsReadOnly)
throw new NotSupportedException ("The collection is read-only.");
list.Add (address);
}
public virtual void Clear ()
{
if (IsReadOnly)
throw new NotSupportedException ("The collection is read-only.");
list.Clear ();
}
public virtual bool Contains (IPAddress address)
{
return list.Contains (address);
}
public virtual void CopyTo (IPAddress [] array, int offset)
{
list.CopyTo (array, offset);
}
public virtual IEnumerator<IPAddress> GetEnumerator ()
{
return ((IEnumerable<IPAddress>)list).GetEnumerator ();
}
public virtual bool Remove (IPAddress address)
{
if (IsReadOnly)
throw new NotSupportedException ("The collection is read-only.");
return list.Remove (address);
}
IEnumerator IEnumerable.GetEnumerator ()
{
return list.GetEnumerator ();
}
public virtual int Count {
get { return list.Count; }
}
public virtual bool IsReadOnly {
get { return list.IsReadOnly; }
}
public virtual IPAddress this [int index] {
get { return list [index]; }
}
}
class Win32IPAddressCollection : IPAddressCollection
{
public static readonly Win32IPAddressCollection Empty = new Win32IPAddressCollection (IntPtr.Zero);
bool is_readonly;
// for static methods
Win32IPAddressCollection ()
{
}
public Win32IPAddressCollection (params IntPtr [] heads)
{
foreach (IntPtr head in heads)
AddSubsequentlyString (head);
is_readonly = true;
}
public Win32IPAddressCollection (params Win32_IP_ADDR_STRING [] al)
{
foreach (Win32_IP_ADDR_STRING a in al) {
if (String.IsNullOrEmpty (a.IpAddress))
continue;
Add (IPAddress.Parse (a.IpAddress));
AddSubsequentlyString (a.Next);
}
is_readonly = true;
}
public static Win32IPAddressCollection FromAnycast (IntPtr ptr)
{
Win32IPAddressCollection c = new Win32IPAddressCollection ();
Win32_IP_ADAPTER_ANYCAST_ADDRESS a;
for (IntPtr p = ptr; p != IntPtr.Zero; p = a.Next) {
a = (Win32_IP_ADAPTER_ANYCAST_ADDRESS) Marshal.PtrToStructure (p, typeof (Win32_IP_ADAPTER_ANYCAST_ADDRESS));
c.Add (a.Address.GetIPAddress ());
}
c.is_readonly = true;
return c;
}
public static Win32IPAddressCollection FromDnsServer (IntPtr ptr)
{
Win32IPAddressCollection c = new Win32IPAddressCollection ();
Win32_IP_ADAPTER_DNS_SERVER_ADDRESS a;
for (IntPtr p = ptr; p != IntPtr.Zero; p = a.Next) {
a = (Win32_IP_ADAPTER_DNS_SERVER_ADDRESS) Marshal.PtrToStructure (p, typeof (Win32_IP_ADAPTER_DNS_SERVER_ADDRESS));
// FIXME: It somehow fails here. Looks like there is something wrong.
//if (a.Address.Sockaddr == IntPtr.Zero) throw new Exception ("pointer " + p + " a.length " + a.Address.SockaddrLength);
c.Add (a.Address.GetIPAddress ());
}
c.is_readonly = true;
return c;
}
void AddSubsequentlyString (IntPtr head)
{
Win32_IP_ADDR_STRING a;
for (IntPtr p = head; p != IntPtr.Zero; p = a.Next) {
a = (Win32_IP_ADDR_STRING) Marshal.PtrToStructure (p, typeof (Win32_IP_ADDR_STRING));
Add (IPAddress.Parse (a.IpAddress));
}
}
public override bool IsReadOnly {
get { return is_readonly; }
}
}
}

View File

@@ -0,0 +1,68 @@
//
// System.Net.NetworkInformation.IPAddressInformation
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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;
namespace System.Net.NetworkInformation {
public abstract class IPAddressInformation {
protected IPAddressInformation ()
{
}
public abstract IPAddress Address { get; }
public abstract bool IsDnsEligible { get; }
public abstract bool IsTransient { get; }
}
class IPAddressInformationImpl : IPAddressInformation
{
IPAddress address;
bool is_dns_eligible, is_transient;
public IPAddressInformationImpl (IPAddress address, bool isDnsEligible, bool isTransient)
{
this.address = address;
this.is_dns_eligible = isDnsEligible;
this.is_transient = isTransient;
}
public override IPAddress Address {
get { return address; }
}
public override bool IsDnsEligible {
get { return is_dns_eligible; }
}
[MonoTODO ("Always false on Linux")]
public override bool IsTransient {
get { return is_transient; }
}
}
}

View File

@@ -0,0 +1,138 @@
//
// System.Net.NetworkInformation.IPAddressInformationCollection
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace System.Net.NetworkInformation {
public class IPAddressInformationCollection : ICollection<IPAddressInformation>, IEnumerable<IPAddressInformation>, IEnumerable {
List <IPAddressInformation> list = new List <IPAddressInformation> ();
internal IPAddressInformationCollection ()
{
}
public virtual void Add (IPAddressInformation address)
{
if (IsReadOnly)
throw new NotSupportedException ("The collection is read-only.");
list.Add (address);
}
public virtual void Clear ()
{
if (IsReadOnly)
throw new NotSupportedException ("The collection is read-only.");
list.Clear ();
}
public virtual bool Contains (IPAddressInformation address)
{
return list.Contains (address);
}
public virtual void CopyTo (IPAddressInformation [] array, int offset)
{
list.CopyTo (array, offset);
}
public virtual IEnumerator<IPAddressInformation> GetEnumerator ()
{
return ((IEnumerable<IPAddressInformation>)list).GetEnumerator ();
}
public virtual bool Remove (IPAddressInformation address)
{
if (IsReadOnly)
throw new NotSupportedException ("The collection is read-only.");
return list.Remove (address);
}
IEnumerator IEnumerable.GetEnumerator ()
{
return list.GetEnumerator ();
}
public virtual int Count {
get { return list.Count; }
}
public virtual bool IsReadOnly {
get { return true; }
}
public virtual IPAddressInformation this [int index] {
get { return list [index]; }
}
}
class IPAddressInformationImplCollection : IPAddressInformationCollection
{
public static readonly IPAddressInformationImplCollection Empty = new IPAddressInformationImplCollection (true);
bool is_readonly;
// for static methods
IPAddressInformationImplCollection (bool isReadOnly)
{
is_readonly = isReadOnly;
}
public override bool IsReadOnly {
get { return is_readonly; }
}
public static IPAddressInformationCollection Win32FromAnycast (IntPtr ptr)
{
IPAddressInformationImplCollection c = new IPAddressInformationImplCollection (false);
Win32_IP_ADAPTER_ANYCAST_ADDRESS a;
for (IntPtr p = ptr; p != IntPtr.Zero; p = a.Next) {
a = (Win32_IP_ADAPTER_ANYCAST_ADDRESS) Marshal.PtrToStructure (p, typeof (Win32_IP_ADAPTER_ANYCAST_ADDRESS));
c.Add (new IPAddressInformationImpl (
a.Address.GetIPAddress (),
a.LengthFlags.IsDnsEligible,
a.LengthFlags.IsTransient));
}
c.is_readonly = true;
return c;
}
public static IPAddressInformationImplCollection LinuxFromAnycast (IList<IPAddress> addresses)
{
IPAddressInformationImplCollection c = new IPAddressInformationImplCollection (false);
foreach (IPAddress address in addresses) {
c.Add (new IPAddressInformationImpl (address, false, false));
}
c.is_readonly = true;
return c;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,250 @@
//
// System.Net.NetworkInformation.IPGlobalProperties
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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.Collections.Specialized;
using System.Globalization;
using System.Runtime.InteropServices;
namespace System.Net.NetworkInformation {
public abstract class IPGlobalStatistics {
protected IPGlobalStatistics ()
{
}
public abstract int DefaultTtl { get; }
public abstract bool ForwardingEnabled { get; }
public abstract int NumberOfInterfaces { get; }
public abstract int NumberOfIPAddresses { get; }
public abstract int NumberOfRoutes { get; }
public abstract long OutputPacketRequests { get; }
public abstract long OutputPacketRoutingDiscards { get; }
public abstract long OutputPacketsDiscarded { get; }
public abstract long OutputPacketsWithNoRoute { get; }
public abstract long PacketFragmentFailures { get; }
public abstract long PacketReassembliesRequired { get; }
public abstract long PacketReassemblyFailures { get; }
public abstract long PacketReassemblyTimeout { get; }
public abstract long PacketsFragmented { get; }
public abstract long PacketsReassembled { get; }
public abstract long ReceivedPackets { get; }
public abstract long ReceivedPacketsDelivered { get; }
public abstract long ReceivedPacketsDiscarded { get; }
public abstract long ReceivedPacketsForwarded { get; }
public abstract long ReceivedPacketsWithAddressErrors { get; }
public abstract long ReceivedPacketsWithHeadersErrors { get; }
public abstract long ReceivedPacketsWithUnknownProtocol { get; }
}
class MibIPGlobalStatistics : IPGlobalStatistics
{
StringDictionary dic;
public MibIPGlobalStatistics (StringDictionary dic)
{
this.dic = dic;
}
long Get (string name)
{
return dic [name] != null ? long.Parse (dic [name], NumberFormatInfo.InvariantInfo) : 0;
}
public override int DefaultTtl {
get { return (int) Get ("DefaultTTL"); }
}
public override bool ForwardingEnabled {
get { return Get ("Forwarding") != 0; }
}
public override int NumberOfInterfaces {
get { return (int) Get ("NumIf"); }
}
public override int NumberOfIPAddresses {
get { return (int) Get ("NumAddr"); }
}
public override int NumberOfRoutes {
get { return (int) Get ("NumRoutes"); }
}
public override long OutputPacketRequests {
get { return Get ("OutRequests"); }
}
public override long OutputPacketRoutingDiscards {
get { return Get ("RoutingDiscards"); }
}
public override long OutputPacketsDiscarded {
get { return Get ("OutDiscards"); }
}
public override long OutputPacketsWithNoRoute {
get { return Get ("OutNoRoutes"); }
}
public override long PacketFragmentFailures {
get { return Get ("FragFails"); }
}
public override long PacketReassembliesRequired {
get { return Get ("ReasmReqds"); }
}
public override long PacketReassemblyFailures {
get { return Get ("ReasmFails"); }
}
public override long PacketReassemblyTimeout {
get { return Get ("ReasmTimeout"); }
}
public override long PacketsFragmented {
get { return Get ("FragOks"); }
}
public override long PacketsReassembled {
get { return Get ("ReasmOks"); }
}
public override long ReceivedPackets {
get { return Get ("InReceives"); }
}
public override long ReceivedPacketsDelivered {
get { return Get ("InDelivers"); }
}
public override long ReceivedPacketsDiscarded {
get { return Get ("InDiscards"); }
}
public override long ReceivedPacketsForwarded {
get { return Get ("ForwDatagrams"); }
}
public override long ReceivedPacketsWithAddressErrors {
get { return Get ("InAddrErrors"); }
}
public override long ReceivedPacketsWithHeadersErrors {
get { return Get ("InHdrErrors"); }
}
public override long ReceivedPacketsWithUnknownProtocol {
get { return Get ("InUnknownProtos"); }
}
}
class Win32IPGlobalStatistics : IPGlobalStatistics
{
Win32_MIB_IPSTATS info;
public Win32IPGlobalStatistics (Win32_MIB_IPSTATS info)
{
this.info = info;
}
public override int DefaultTtl {
get { return info.DefaultTTL; }
}
public override bool ForwardingEnabled {
get { return info.Forwarding != 0; }
}
public override int NumberOfInterfaces {
get { return info.NumIf; }
}
public override int NumberOfIPAddresses {
get { return info.NumAddr; }
}
public override int NumberOfRoutes {
get { return info.NumRoutes; }
}
public override long OutputPacketRequests {
get { return info.OutRequests; }
}
public override long OutputPacketRoutingDiscards {
get { return info.RoutingDiscards; }
}
public override long OutputPacketsDiscarded {
get { return info.OutDiscards; }
}
public override long OutputPacketsWithNoRoute {
get { return info.OutNoRoutes; }
}
public override long PacketFragmentFailures {
get { return info.FragFails; }
}
public override long PacketReassembliesRequired {
get { return info.ReasmReqds; }
}
public override long PacketReassemblyFailures {
get { return info.ReasmFails; }
}
public override long PacketReassemblyTimeout {
get { return info.ReasmTimeout; }
}
public override long PacketsFragmented {
get { return info.FragOks; }
}
public override long PacketsReassembled {
get { return info.ReasmOks; }
}
public override long ReceivedPackets {
get { return info.InReceives; }
}
public override long ReceivedPacketsDelivered {
get { return info.InDelivers; }
}
public override long ReceivedPacketsDiscarded {
get { return info.InDiscards; }
}
public override long ReceivedPacketsForwarded {
get { return info.ForwDatagrams; }
}
public override long ReceivedPacketsWithAddressErrors {
get { return info.InAddrErrors; }
}
public override long ReceivedPacketsWithHeadersErrors {
get { return info.InHdrErrors; }
}
public override long ReceivedPacketsWithUnknownProtocol {
get { return info.InUnknownProtos; }
}
}
[StructLayout (LayoutKind.Sequential)]
struct Win32_MIB_IPSTATS
{
public int Forwarding;
public int DefaultTTL;
public uint InReceives;
public uint InHdrErrors;
public uint InAddrErrors;
public uint ForwDatagrams;
public uint InUnknownProtos;
public uint InDiscards;
public uint InDelivers;
public uint OutRequests;
public uint RoutingDiscards;
public uint OutDiscards;
public uint OutNoRoutes;
public uint ReasmTimeout;
public uint ReasmReqds;
public uint ReasmOks;
public uint ReasmFails;
public uint FragOks;
public uint FragFails;
public uint FragCreates;
public int NumIf;
public int NumAddr;
public int NumRoutes;
}
}

View File

@@ -0,0 +1,376 @@
//
// System.Net.NetworkInformation.IPInterfaceProperties
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net.Sockets;
using System.Text.RegularExpressions;
namespace System.Net.NetworkInformation {
public abstract class IPInterfaceProperties {
protected IPInterfaceProperties ()
{
}
public abstract IPv4InterfaceProperties GetIPv4Properties ();
public abstract IPv6InterfaceProperties GetIPv6Properties ();
public abstract IPAddressInformationCollection AnycastAddresses { get; }
public abstract IPAddressCollection DhcpServerAddresses { get; }
public abstract IPAddressCollection DnsAddresses { get; }
public abstract string DnsSuffix { get; }
public abstract GatewayIPAddressInformationCollection GatewayAddresses { get; }
public abstract bool IsDnsEnabled { get; }
public abstract bool IsDynamicDnsEnabled { get; }
public abstract MulticastIPAddressInformationCollection MulticastAddresses { get; }
public abstract UnicastIPAddressInformationCollection UnicastAddresses { get; }
public abstract IPAddressCollection WinsServersAddresses { get; }
}
abstract class UnixIPInterfaceProperties : IPInterfaceProperties
{
protected IPv4InterfaceProperties ipv4iface_properties;
protected UnixNetworkInterface iface;
List <IPAddress> addresses;
IPAddressCollection dns_servers;
IPAddressCollection gateways;
string dns_suffix;
DateTime last_parse;
public UnixIPInterfaceProperties (UnixNetworkInterface iface, List <IPAddress> addresses)
{
this.iface = iface;
this.addresses = addresses;
}
public override IPv6InterfaceProperties GetIPv6Properties ()
{
throw new NotImplementedException ();
}
void ParseRouteInfo (string iface)
{
try {
gateways = new IPAddressCollection ();
using (StreamReader reader = new StreamReader ("/proc/net/route")) {
string line;
reader.ReadLine (); // Ignore first line
while ((line = reader.ReadLine ()) != null) {
line = line.Trim ();
if (line.Length == 0)
continue;
string [] parts = line.Split ('\t');
if (parts.Length < 3)
continue;
string gw_address = parts [2].Trim ();
byte [] ipbytes = new byte [4];
if (gw_address.Length == 8 && iface.Equals (parts [0], StringComparison.OrdinalIgnoreCase)) {
for (int i = 0; i < 4; i++) {
if (!Byte.TryParse (gw_address.Substring (i * 2, 2), NumberStyles.HexNumber, null, out ipbytes [3 - i]))
continue;
}
IPAddress ip = new IPAddress (ipbytes);
if (!ip.Equals (IPAddress.Any))
gateways.Add (ip);
}
}
}
} catch {
}
}
static Regex ns = new Regex (@"\s*nameserver\s+(?<address>.*)");
static Regex search = new Regex (@"\s*search\s+(?<domain>.*)");
void ParseResolvConf ()
{
try {
DateTime wt = File.GetLastWriteTime ("/etc/resolv.conf");
if (wt <= last_parse)
return;
last_parse = wt;
dns_suffix = "";
dns_servers = new IPAddressCollection ();
using (StreamReader reader = new StreamReader ("/etc/resolv.conf")) {
string str;
string line;
while ((line = reader.ReadLine ()) != null) {
line = line.Trim ();
if (line.Length == 0 || line [0] == '#')
continue;
Match match = ns.Match (line);
if (match.Success) {
try {
str = match.Groups ["address"].Value;
str = str.Trim ();
dns_servers.Add (IPAddress.Parse (str));
} catch {
}
} else {
match = search.Match (line);
if (match.Success) {
str = match.Groups ["domain"].Value;
string [] parts = str.Split (',');
dns_suffix = parts [0].Trim ();
}
}
}
}
} catch {
} finally {
dns_servers.SetReadOnly ();
}
}
public override IPAddressInformationCollection AnycastAddresses {
get {
List<IPAddress> anycastAddresses = new List<IPAddress> ();
/* XXX:
foreach (IPAddress address in addresses) {
if (is_anycast_address (address)) {
anycastAddresses.Add (address);
}
}
*/
return IPAddressInformationImplCollection.LinuxFromAnycast (anycastAddresses);
}
}
[MonoTODO ("Always returns an empty collection.")]
public override IPAddressCollection DhcpServerAddresses {
get {
// There are lots of different DHCP clients
// that all store their configuration differently.
// I'm not sure what to do here.
IPAddressCollection coll = new IPAddressCollection ();
coll.SetReadOnly ();
return coll;
}
}
public override IPAddressCollection DnsAddresses {
get {
ParseResolvConf ();
return dns_servers;
}
}
public override string DnsSuffix {
get {
ParseResolvConf ();
return dns_suffix;
}
}
public override GatewayIPAddressInformationCollection GatewayAddresses {
get {
ParseRouteInfo (this.iface.Name.ToString());
if (gateways.Count > 0)
return new LinuxGatewayIPAddressInformationCollection (gateways);
else
return LinuxGatewayIPAddressInformationCollection.Empty;
}
}
[MonoTODO ("Always returns true")]
public override bool IsDnsEnabled {
get {
return true;
}
}
[MonoTODO ("Always returns false")]
public override bool IsDynamicDnsEnabled {
get {
return false;
}
}
public override MulticastIPAddressInformationCollection MulticastAddresses {
get {
List<IPAddress> multicastAddresses = new List<IPAddress> ();
foreach (IPAddress address in addresses) {
byte[] addressBytes = address.GetAddressBytes ();
if (addressBytes[0] >= 224 && addressBytes[0] <= 239) {
multicastAddresses.Add (address);
}
}
return MulticastIPAddressInformationImplCollection.LinuxFromList (multicastAddresses);
}
}
public override UnicastIPAddressInformationCollection UnicastAddresses {
get {
List<IPAddress> unicastAddresses = new List<IPAddress> ();
foreach (IPAddress address in addresses) {
switch (address.AddressFamily) {
case AddressFamily.InterNetwork:
byte top = address.GetAddressBytes () [0];
if (top >= 224 && top <= 239)
continue;
unicastAddresses.Add (address);
break;
case AddressFamily.InterNetworkV6:
if (address.IsIPv6Multicast)
continue;
unicastAddresses.Add (address);
break;
}
}
return UnicastIPAddressInformationImplCollection.LinuxFromList (unicastAddresses);
}
}
[MonoTODO ("Always returns an empty collection.")]
public override IPAddressCollection WinsServersAddresses {
get {
// I do SUPPOSE we could scrape /etc/samba/smb.conf, but.. yeesh.
return new IPAddressCollection ();
}
}
}
class LinuxIPInterfaceProperties : UnixIPInterfaceProperties
{
public LinuxIPInterfaceProperties (LinuxNetworkInterface iface, List <IPAddress> addresses)
: base (iface, addresses)
{
}
public override IPv4InterfaceProperties GetIPv4Properties ()
{
if (ipv4iface_properties == null)
ipv4iface_properties = new LinuxIPv4InterfaceProperties (iface as LinuxNetworkInterface);
return ipv4iface_properties;
}
}
class MacOsIPInterfaceProperties : UnixIPInterfaceProperties
{
public MacOsIPInterfaceProperties (MacOsNetworkInterface iface, List <IPAddress> addresses)
: base (iface, addresses)
{
}
public override IPv4InterfaceProperties GetIPv4Properties ()
{
if (ipv4iface_properties == null)
ipv4iface_properties = new MacOsIPv4InterfaceProperties (iface as MacOsNetworkInterface);
return ipv4iface_properties;
}
}
class Win32IPInterfaceProperties2 : IPInterfaceProperties
{
readonly Win32_IP_ADAPTER_ADDRESSES addr;
readonly Win32_MIB_IFROW mib4, mib6;
public Win32IPInterfaceProperties2 (Win32_IP_ADAPTER_ADDRESSES addr, Win32_MIB_IFROW mib4, Win32_MIB_IFROW mib6)
{
this.addr = addr;
this.mib4 = mib4;
this.mib6 = mib6;
}
public override IPv4InterfaceProperties GetIPv4Properties ()
{
Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
return v4info != null ? new Win32IPv4InterfaceProperties (v4info, mib4) : null;
}
public override IPv6InterfaceProperties GetIPv6Properties ()
{
Win32_IP_ADAPTER_INFO v6info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib6.Index);
return v6info != null ? new Win32IPv6InterfaceProperties (mib6) : null;
}
public override IPAddressInformationCollection AnycastAddresses {
get { return IPAddressInformationImplCollection.Win32FromAnycast (addr.FirstAnycastAddress); }
}
public override IPAddressCollection DhcpServerAddresses {
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;
}
}
public override IPAddressCollection DnsAddresses {
get { return Win32IPAddressCollection.FromDnsServer (addr.FirstDnsServerAddress); }
}
public override string DnsSuffix {
get { return addr.DnsSuffix; }
}
public override GatewayIPAddressInformationCollection GatewayAddresses {
get {
Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
// FIXME: should ipv6 DhcpServer be considered?
return v4info != null ? new Win32GatewayIPAddressInformationCollection (v4info.GatewayList) : Win32GatewayIPAddressInformationCollection.Empty;
}
}
public override bool IsDnsEnabled {
get { return Win32_FIXED_INFO.Instance.EnableDns != 0; }
}
public override bool IsDynamicDnsEnabled {
get { return addr.DdnsEnabled; }
}
public override MulticastIPAddressInformationCollection MulticastAddresses {
get { return MulticastIPAddressInformationImplCollection.Win32FromMulticast (addr.FirstMulticastAddress); }
}
public override UnicastIPAddressInformationCollection UnicastAddresses {
get {
Win32_IP_ADAPTER_INFO ai = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
// FIXME: should ipv6 DhcpServer be considered?
return ai != null ? UnicastIPAddressInformationImplCollection.Win32FromUnicast ((int) ai.Index, addr.FirstUnicastAddress) : UnicastIPAddressInformationImplCollection.Empty;
}
}
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;
}
}
}
}

View File

@@ -0,0 +1,57 @@
//
// System.Net.NetworkInformation.IPStatus
//
// Author:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
//
// Copyright (c) 2006 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Net.NetworkInformation {
public enum IPStatus {
Unknown = -1,
Success = 0,
DestinationNetworkUnreachable = 11002,
DestinationHostUnreachable = 11003,
DestinationProhibited = 11004,
DestinationProtocolUnreachable = 11004,
DestinationPortUnreachable = 11005,
NoResources = 11006,
BadOption = 11007,
HardwareError = 11008,
PacketTooBig = 11009,
TimedOut = 11010,
BadRoute = 11012,
TtlExpired = 11013,
TtlReassemblyTimeExceeded = 11014,
ParameterProblem = 11015,
SourceQuench = 11016,
BadDestination = 11018,
DestinationUnreachable = 11040,
TimeExceeded = 11041,
BadHeader = 11042,
UnrecognizedNextHeader = 11043,
IcmpError = 11044,
DestinationScopeMismatch = 11045
}
}

View File

@@ -0,0 +1,202 @@
//
// System.Net.NetworkInformation.IPv4InterfaceProperties
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
// Marek Habersack (mhabersack@novell.com)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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.IO;
using System.Runtime.InteropServices;
namespace System.Net.NetworkInformation {
public abstract class IPv4InterfaceProperties {
protected IPv4InterfaceProperties ()
{
}
public abstract int Index { get; }
public abstract bool IsAutomaticPrivateAddressingActive { get; }
public abstract bool IsAutomaticPrivateAddressingEnabled { get; }
public abstract bool IsDhcpEnabled { get; }
public abstract bool IsForwardingEnabled { get; }
public abstract int Mtu { get; }
public abstract bool UsesWins { get; }
}
abstract class UnixIPv4InterfaceProperties : IPv4InterfaceProperties
{
protected UnixNetworkInterface iface;
public UnixIPv4InterfaceProperties (UnixNetworkInterface iface)
{
this.iface = iface;
}
public override int Index {
get { return UnixNetworkInterface.IfNameToIndex (iface.Name); }
}
// TODO: how to discover that?
public override bool IsAutomaticPrivateAddressingActive {
get { return false; }
}
// TODO: how to discover that?
public override bool IsAutomaticPrivateAddressingEnabled {
get { return false; }
}
// TODO: how to discover that? The only way is distribution-specific...
public override bool IsDhcpEnabled {
get { return false; }
}
public override bool UsesWins {
get { return false; }
}
}
sealed class LinuxIPv4InterfaceProperties : UnixIPv4InterfaceProperties
{
public LinuxIPv4InterfaceProperties (LinuxNetworkInterface iface)
: base (iface)
{
}
public override bool IsForwardingEnabled {
get {
string iface_path = "/proc/sys/net/ipv4/conf/" + iface.Name + "/forwarding";
if (File.Exists (iface_path)) {
string val = NetworkInterface.ReadLine (iface_path);
return val != "0";
}
return false;
}
}
public override int Mtu {
get {
string iface_path = (iface as LinuxNetworkInterface).IfacePath + "mtu";
int ret = 0;
if (File.Exists (iface_path)) {
string val = NetworkInterface.ReadLine (iface_path);
try {
ret = Int32.Parse (val);
} catch {
}
}
return ret;
}
}
}
sealed class MacOsIPv4InterfaceProperties : UnixIPv4InterfaceProperties
{
public MacOsIPv4InterfaceProperties (MacOsNetworkInterface iface)
: base (iface)
{
}
// dummy
public override bool IsForwardingEnabled {
get { return false; }
}
// dummy
public override int Mtu {
get { return 0; }
}
}
sealed class Win32IPv4InterfaceProperties : IPv4InterfaceProperties
{
[DllImport ("iphlpapi.dll")]
static extern int GetPerAdapterInfo (int IfIndex, Win32_IP_PER_ADAPTER_INFO pPerAdapterInfo, ref int pOutBufLen);
Win32_IP_ADAPTER_INFO ainfo;
Win32_IP_PER_ADAPTER_INFO painfo;
Win32_MIB_IFROW mib;
public Win32IPv4InterfaceProperties (Win32_IP_ADAPTER_INFO ainfo, Win32_MIB_IFROW mib)
{
this.ainfo = ainfo;
this.mib = mib;
// get per-adapter info.
int size = 0;
GetPerAdapterInfo (mib.Index, null, ref size);
painfo = new Win32_IP_PER_ADAPTER_INFO ();
int ret = GetPerAdapterInfo (mib.Index, painfo, ref size);
if (ret != 0)
throw new NetworkInformationException (ret);
}
public override int Index {
get { return mib.Index; }
}
public override bool IsAutomaticPrivateAddressingActive {
get { return painfo.AutoconfigActive != 0; }
}
public override bool IsAutomaticPrivateAddressingEnabled {
get { return painfo.AutoconfigEnabled != 0; }
}
public override bool IsDhcpEnabled {
get { return ainfo.DhcpEnabled != 0; }
}
public override bool IsForwardingEnabled {
// Is it the right answer? In Vista there is MIB_IPINTERFACEROW.ForwardingEnabled, but not in former versions.
get { return Win32_FIXED_INFO.Instance.EnableRouting != 0; }
}
public override int Mtu {
get { return mib.Mtu; }
}
public override bool UsesWins {
get { return ainfo.HaveWins; }
}
}
[StructLayout (LayoutKind.Sequential)]
class Win32_IP_PER_ADAPTER_INFO
{
public uint AutoconfigEnabled;
public uint AutoconfigActive;
public IntPtr CurrentDnsServer; // to Win32_IP_ADDR_STRING
public Win32_IP_ADDR_STRING DnsServerList;
}
}

View File

@@ -0,0 +1,265 @@
//
// System.Net.NetworkInformation.IPv4InterfaceStatistics
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
// Miguel de Icaza (miguel@ximian.com)
//
// Copyright (c) 2006-2008 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Net.NetworkInformation {
public abstract class IPv4InterfaceStatistics {
protected IPv4InterfaceStatistics ()
{
}
public abstract long BytesReceived { get; }
public abstract long BytesSent { get; }
public abstract long IncomingPacketsDiscarded { get; }
public abstract long IncomingPacketsWithErrors { get; }
public abstract long IncomingUnknownProtocolPackets { get; }
public abstract long NonUnicastPacketsReceived { get; }
public abstract long NonUnicastPacketsSent { get; }
public abstract long OutgoingPacketsDiscarded { get; }
public abstract long OutgoingPacketsWithErrors { get; }
[MonoTODO("Not implemented for Linux")]
public abstract long OutputQueueLength { get; }
public abstract long UnicastPacketsReceived { get; }
public abstract long UnicastPacketsSent { get; }
}
class Win32IPv4InterfaceStatistics : IPv4InterfaceStatistics
{
Win32_MIB_IFROW info;
public Win32IPv4InterfaceStatistics (Win32_MIB_IFROW info)
{
this.info = info;
}
public override long BytesReceived {
get { return info.InOctets; }
}
public override long BytesSent {
get { return info.OutOctets; }
}
public override long IncomingPacketsDiscarded {
get { return info.InDiscards; }
}
public override long IncomingPacketsWithErrors {
get { return info.InErrors; }
}
public override long IncomingUnknownProtocolPackets {
get { return info.InUnknownProtos; }
}
public override long NonUnicastPacketsReceived {
get { return info.InNUcastPkts; }
}
public override long NonUnicastPacketsSent {
get { return info.OutNUcastPkts; }
}
public override long OutgoingPacketsDiscarded {
get { return info.OutDiscards; }
}
public override long OutgoingPacketsWithErrors {
get { return info.OutErrors; }
}
public override long OutputQueueLength {
get { return info.OutQLen; }
}
public override long UnicastPacketsReceived {
get { return info.InUcastPkts; }
}
public override long UnicastPacketsSent {
get { return info.OutUcastPkts; }
}
}
class LinuxIPv4InterfaceStatistics : IPv4InterfaceStatistics
{
LinuxNetworkInterface linux;
public LinuxIPv4InterfaceStatistics (LinuxNetworkInterface parent)
{
linux = parent;
}
long Read (string file)
{
try {
return long.Parse (NetworkInterface.ReadLine (linux.IfacePath + file));
} catch {
return 0;
}
}
public override long BytesReceived {
get {
return Read ("statistics/rx_bytes");
}
}
public override long BytesSent {
get {
return Read ("statistics/tx_bytes");
}
}
public override long IncomingPacketsDiscarded {
get {
return Read ("statistics/rx_dropped");
}
}
public override long IncomingPacketsWithErrors {
get {
return Read ("statistics/rx_errors");
}
}
public override long IncomingUnknownProtocolPackets {
get {
// TODO
return 0;
}
}
public override long NonUnicastPacketsReceived {
get {
// We cant distinguish these
return Read ("statistics/multicast");
}
}
public override long NonUnicastPacketsSent {
get {
// We cant distinguish these
return Read ("statistics/multicast");
}
}
public override long OutgoingPacketsDiscarded {
get {
return Read ("statistics/tx_dropped");
}
}
public override long OutgoingPacketsWithErrors {
get {
return Read ("statistics/tx_errors");
}
}
public override long OutputQueueLength {
get {
return 1024;
}
}
public override long UnicastPacketsReceived {
get {
return Read ("statistics/rx_packets");
}
}
public override long UnicastPacketsSent {
get {
return Read ("statistics/tx_packets");
}
}
}
// dummy class
class MacOsIPv4InterfaceStatistics : IPv4InterfaceStatistics
{
//MacOsNetworkInterface macos;
public MacOsIPv4InterfaceStatistics (MacOsNetworkInterface parent)
{
//macos = parent;
}
public override long BytesReceived {
get { return 0; }
}
public override long BytesSent {
get { return 0; }
}
public override long IncomingPacketsDiscarded {
get { return 0; }
}
public override long IncomingPacketsWithErrors {
get { return 0; }
}
public override long IncomingUnknownProtocolPackets {
get { return 0; }
}
public override long NonUnicastPacketsReceived {
get { return 0; }
}
public override long NonUnicastPacketsSent {
get { return 0; }
}
public override long OutgoingPacketsDiscarded {
get { return 0; }
}
public override long OutgoingPacketsWithErrors {
get { return 0; }
}
public override long OutputQueueLength {
get { return 0; }
}
public override long UnicastPacketsReceived {
get { return 0; }
}
public override long UnicastPacketsSent {
get { return 0; }
}
}
}

View File

@@ -0,0 +1,57 @@
//
// System.Net.NetworkInformation.IPv6InterfaceProperties
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Net.NetworkInformation {
public abstract class IPv6InterfaceProperties {
protected IPv6InterfaceProperties ()
{
}
public abstract int Index { get; }
public abstract int Mtu { get; }
}
class Win32IPv6InterfaceProperties : IPv6InterfaceProperties
{
Win32_MIB_IFROW mib;
public Win32IPv6InterfaceProperties (Win32_MIB_IFROW mib)
{
this.mib = mib;
}
public override int Index {
get { return mib.Index; }
}
public override int Mtu {
get { return mib.Mtu; }
}
}
}

View File

@@ -0,0 +1,273 @@
//
// System.Net.NetworkInformation.IcmpV4Statistics
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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.Collections.Specialized;
using System.Globalization;
namespace System.Net.NetworkInformation {
public abstract class IcmpV4Statistics {
protected IcmpV4Statistics ()
{
}
public abstract long AddressMaskRepliesReceived { get; }
public abstract long AddressMaskRepliesSent { get; }
public abstract long AddressMaskRequestsReceived { get; }
public abstract long AddressMaskRequestsSent { get; }
public abstract long DestinationUnreachableMessagesReceived { get; }
public abstract long DestinationUnreachableMessagesSent { get; }
public abstract long EchoRepliesReceived { get; }
public abstract long EchoRepliesSent { get; }
public abstract long EchoRequestsReceived { get; }
public abstract long EchoRequestsSent { get; }
public abstract long ErrorsReceived { get; }
public abstract long ErrorsSent { get; }
public abstract long MessagesReceived { get; }
public abstract long MessagesSent { get; }
public abstract long ParameterProblemsReceived { get; }
public abstract long ParameterProblemsSent { get; }
public abstract long RedirectsReceived { get; }
public abstract long RedirectsSent { get; }
public abstract long SourceQuenchesReceived { get; }
public abstract long SourceQuenchesSent { get; }
public abstract long TimeExceededMessagesReceived { get; }
public abstract long TimeExceededMessagesSent { get; }
public abstract long TimestampRepliesReceived { get; }
public abstract long TimestampRepliesSent { get; }
public abstract long TimestampRequestsReceived { get; }
public abstract long TimestampRequestsSent { get; }
}
class MibIcmpV4Statistics : IcmpV4Statistics
{
StringDictionary dic;
public MibIcmpV4Statistics (StringDictionary dic)
{
this.dic = dic;
}
long Get (string name)
{
return dic [name] != null ? long.Parse (dic [name], NumberFormatInfo.InvariantInfo) : 0;
}
public override long AddressMaskRepliesReceived {
get { return Get ("InAddrMaskReps"); }
}
public override long AddressMaskRepliesSent {
get { return Get ("OutAddrMaskReps"); }
}
public override long AddressMaskRequestsReceived {
get { return Get ("InAddrMasks"); }
}
public override long AddressMaskRequestsSent {
get { return Get ("OutAddrMasks"); }
}
public override long DestinationUnreachableMessagesReceived {
get { return Get ("InDestUnreachs"); }
}
public override long DestinationUnreachableMessagesSent {
get { return Get ("OutDestUnreachs"); }
}
public override long EchoRepliesReceived {
get { return Get ("InEchoReps"); }
}
public override long EchoRepliesSent {
get { return Get ("OutEchoReps"); }
}
public override long EchoRequestsReceived {
get { return Get ("InEchos"); }
}
public override long EchoRequestsSent {
get { return Get ("OutEchos"); }
}
public override long ErrorsReceived {
get { return Get ("InErrors"); }
}
public override long ErrorsSent {
get { return Get ("OutErrors"); }
}
public override long MessagesReceived {
get { return Get ("InMsgs"); }
}
public override long MessagesSent {
get { return Get ("OutMsgs"); }
}
public override long ParameterProblemsReceived {
get { return Get ("InParmProbs"); }
}
public override long ParameterProblemsSent {
get { return Get ("OutParmProbs"); }
}
public override long RedirectsReceived {
get { return Get ("InRedirects"); }
}
public override long RedirectsSent {
get { return Get ("OutRedirects"); }
}
public override long SourceQuenchesReceived {
get { return Get ("InSrcQuenchs"); }
}
public override long SourceQuenchesSent {
get { return Get ("OutSrcQuenchs"); }
}
public override long TimeExceededMessagesReceived {
get { return Get ("InTimeExcds"); }
}
public override long TimeExceededMessagesSent {
get { return Get ("OutTimeExcds"); }
}
public override long TimestampRepliesReceived {
get { return Get ("InTimestampReps"); }
}
public override long TimestampRepliesSent {
get { return Get ("OutTimestampReps"); }
}
public override long TimestampRequestsReceived {
get { return Get ("InTimestamps"); }
}
public override long TimestampRequestsSent {
get { return Get ("OutTimestamps"); }
}
}
class Win32IcmpV4Statistics : IcmpV4Statistics
{
Win32_MIBICMPSTATS iin, iout;
public Win32IcmpV4Statistics (Win32_MIBICMPINFO info)
{
iin = info.InStats;
iout = info.OutStats;
}
public override long AddressMaskRepliesReceived {
get { return iin.AddrMaskReps; }
}
public override long AddressMaskRepliesSent {
get { return iout.AddrMaskReps; }
}
public override long AddressMaskRequestsReceived {
get { return iin.AddrMasks; }
}
public override long AddressMaskRequestsSent {
get { return iout.AddrMasks; }
}
public override long DestinationUnreachableMessagesReceived {
get { return iin.DestUnreachs; }
}
public override long DestinationUnreachableMessagesSent {
get { return iout.DestUnreachs; }
}
public override long EchoRepliesReceived {
get { return iin.EchoReps; }
}
public override long EchoRepliesSent {
get { return iout.EchoReps; }
}
public override long EchoRequestsReceived {
get { return iin.Echos; }
}
public override long EchoRequestsSent {
get { return iout.Echos; }
}
public override long ErrorsReceived {
get { return iin.Errors; }
}
public override long ErrorsSent {
get { return iout.Errors; }
}
public override long MessagesReceived {
get { return iin.Msgs; }
}
public override long MessagesSent {
get { return iout.Msgs; }
}
public override long ParameterProblemsReceived {
get { return iin.ParmProbs; }
}
public override long ParameterProblemsSent {
get { return iout.ParmProbs; }
}
public override long RedirectsReceived {
get { return iin.Redirects; }
}
public override long RedirectsSent {
get { return iout.Redirects; }
}
public override long SourceQuenchesReceived {
get { return iin.SrcQuenchs; }
}
public override long SourceQuenchesSent {
get { return iout.SrcQuenchs; }
}
public override long TimeExceededMessagesReceived {
get { return iin.TimeExcds; }
}
public override long TimeExceededMessagesSent {
get { return iout.TimeExcds; }
}
public override long TimestampRepliesReceived {
get { return iin.TimestampReps; }
}
public override long TimestampRepliesSent {
get { return iout.TimestampReps; }
}
public override long TimestampRequestsReceived {
get { return iin.Timestamps; }
}
public override long TimestampRequestsSent {
get { return iout.Timestamps; }
}
}
struct Win32_MIBICMPINFO
{
public Win32_MIBICMPSTATS InStats;
public Win32_MIBICMPSTATS OutStats;
}
struct Win32_MIBICMPSTATS
{
public uint Msgs;
public uint Errors;
public uint DestUnreachs;
public uint TimeExcds;
public uint ParmProbs;
public uint SrcQuenchs;
public uint Redirects;
public uint Echos;
public uint EchoReps;
public uint Timestamps;
public uint TimestampReps;
public uint AddrMasks;
public uint AddrMaskReps;
}
}

View File

@@ -0,0 +1,326 @@
//
// System.Net.NetworkInformation.IcmpV6Statistics
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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.Collections.Specialized;
using System.Globalization;
using System.Runtime.InteropServices;
namespace System.Net.NetworkInformation {
public abstract class IcmpV6Statistics {
protected IcmpV6Statistics ()
{
}
public abstract long DestinationUnreachableMessagesReceived { get; }
public abstract long DestinationUnreachableMessagesSent { get; }
public abstract long EchoRepliesReceived { get; }
public abstract long EchoRepliesSent { get; }
public abstract long EchoRequestsReceived { get; }
public abstract long EchoRequestsSent { get; }
public abstract long ErrorsReceived { get; }
public abstract long ErrorsSent { get; }
public abstract long MembershipQueriesReceived { get; }
public abstract long MembershipQueriesSent { get; }
public abstract long MembershipReductionsReceived { get; }
public abstract long MembershipReductionsSent { get; }
public abstract long MembershipReportsReceived { get; }
public abstract long MembershipReportsSent { get; }
public abstract long MessagesReceived { get; }
public abstract long MessagesSent { get; }
public abstract long NeighborAdvertisementsReceived { get; }
public abstract long NeighborAdvertisementsSent { get; }
public abstract long NeighborSolicitsReceived { get; }
public abstract long NeighborSolicitsSent { get; }
public abstract long PacketTooBigMessagesReceived { get; }
public abstract long PacketTooBigMessagesSent { get; }
public abstract long ParameterProblemsReceived { get; }
public abstract long ParameterProblemsSent { get; }
public abstract long RedirectsReceived { get; }
public abstract long RedirectsSent { get; }
public abstract long RouterAdvertisementsReceived { get; }
public abstract long RouterAdvertisementsSent { get; }
public abstract long RouterSolicitsReceived { get; }
public abstract long RouterSolicitsSent { get; }
public abstract long TimeExceededMessagesReceived { get; }
public abstract long TimeExceededMessagesSent { get; }
}
class MibIcmpV6Statistics : IcmpV6Statistics
{
StringDictionary dic;
public MibIcmpV6Statistics (StringDictionary dic)
{
this.dic = dic;
}
long Get (string name)
{
return dic [name] != null ? long.Parse (dic [name], NumberFormatInfo.InvariantInfo) : 0;
}
public override long DestinationUnreachableMessagesReceived {
get { return Get ("InDestUnreachs"); }
}
public override long DestinationUnreachableMessagesSent {
get { return Get ("OutDestUnreachs"); }
}
public override long EchoRepliesReceived {
get { return Get ("InEchoReplies"); }
}
public override long EchoRepliesSent {
get { return Get ("OutEchoReplies"); }
}
public override long EchoRequestsReceived {
get { return Get ("InEchos"); }
}
public override long EchoRequestsSent {
get { return Get ("OutEchos"); }
}
public override long ErrorsReceived {
get { return Get ("InErrors"); }
}
public override long ErrorsSent {
get { return Get ("OutErrors"); }
}
public override long MembershipQueriesReceived {
get { return Get ("InGroupMembQueries"); }
}
public override long MembershipQueriesSent {
get { return Get ("OutGroupMembQueries"); }
}
public override long MembershipReductionsReceived {
get { return Get ("InGroupMembReductiions"); }
}
public override long MembershipReductionsSent {
get { return Get ("OutGroupMembReductiions"); }
}
public override long MembershipReportsReceived {
get { return Get ("InGroupMembRespons"); }
}
public override long MembershipReportsSent {
get { return Get ("OutGroupMembRespons"); }
}
public override long MessagesReceived {
get { return Get ("InMsgs"); }
}
public override long MessagesSent {
get { return Get ("OutMsgs"); }
}
public override long NeighborAdvertisementsReceived {
get { return Get ("InNeighborAdvertisements"); }
}
public override long NeighborAdvertisementsSent {
get { return Get ("OutNeighborAdvertisements"); }
}
public override long NeighborSolicitsReceived {
get { return Get ("InNeighborSolicits"); }
}
public override long NeighborSolicitsSent {
get { return Get ("OutNeighborSolicits"); }
}
public override long PacketTooBigMessagesReceived {
get { return Get ("InPktTooBigs"); }
}
public override long PacketTooBigMessagesSent {
get { return Get ("OutPktTooBigs"); }
}
public override long ParameterProblemsReceived {
get { return Get ("InParmProblems"); }
}
public override long ParameterProblemsSent {
get { return Get ("OutParmProblems"); }
}
public override long RedirectsReceived {
get { return Get ("InRedirects"); }
}
public override long RedirectsSent {
get { return Get ("OutRedirects"); }
}
public override long RouterAdvertisementsReceived {
get { return Get ("InRouterAdvertisements"); }
}
public override long RouterAdvertisementsSent {
get { return Get ("OutRouterAdvertisements"); }
}
public override long RouterSolicitsReceived {
get { return Get ("InRouterSolicits"); }
}
public override long RouterSolicitsSent {
get { return Get ("OutRouterSolicits"); }
}
public override long TimeExceededMessagesReceived {
get { return Get ("InTimeExcds"); }
}
public override long TimeExceededMessagesSent {
get { return Get ("OutTimeExcds"); }
}
}
class IcmpV6MessageTypes
{
public const int DestinationUnreachable = 1;
public const int PacketTooBig = 2;
public const int TimeExceeded = 3;
public const int ParameterProblem = 4;
public const int EchoRequest = 128;
public const int EchoReply = 129;
public const int GroupMembershipQuery = 130;
public const int GroupMembershipReport = 131;
public const int GroupMembershipReduction = 132;
public const int RouterSolicitation = 133;
public const int RouterAdvertisement = 134;
public const int NeighborSolicitation = 135;
public const int NeighborAdvertisement = 136;
public const int Redirect = 137;
public const int RouterRenumbering = 138;
}
class Win32IcmpV6Statistics : IcmpV6Statistics
{
Win32_MIBICMPSTATS_EX iin, iout;
public Win32IcmpV6Statistics (Win32_MIB_ICMP_EX info)
{
iin = info.InStats;
iout = info.OutStats;
}
public override long DestinationUnreachableMessagesReceived {
get { return iin.Counts [IcmpV6MessageTypes.DestinationUnreachable]; }
}
public override long DestinationUnreachableMessagesSent {
get { return iout.Counts [IcmpV6MessageTypes.DestinationUnreachable]; }
}
public override long EchoRepliesReceived {
get { return iin.Counts [IcmpV6MessageTypes.EchoReply]; }
}
public override long EchoRepliesSent {
get { return iout.Counts [IcmpV6MessageTypes.EchoReply]; }
}
public override long EchoRequestsReceived {
get { return iin.Counts [IcmpV6MessageTypes.EchoRequest]; }
}
public override long EchoRequestsSent {
get { return iout.Counts [IcmpV6MessageTypes.EchoRequest]; }
}
public override long ErrorsReceived {
get { return iin.Errors; }
}
public override long ErrorsSent {
get { return iout.Errors; }
}
public override long MembershipQueriesReceived {
get { return iin.Counts [IcmpV6MessageTypes.GroupMembershipQuery]; }
}
public override long MembershipQueriesSent {
get { return iout.Counts [IcmpV6MessageTypes.GroupMembershipQuery]; }
}
public override long MembershipReductionsReceived {
get { return iin.Counts [IcmpV6MessageTypes.GroupMembershipReduction]; }
}
public override long MembershipReductionsSent {
get { return iout.Counts [IcmpV6MessageTypes.GroupMembershipReduction]; }
}
public override long MembershipReportsReceived {
get { return iin.Counts [IcmpV6MessageTypes.GroupMembershipReport]; }
}
public override long MembershipReportsSent {
get { return iout.Counts [IcmpV6MessageTypes.GroupMembershipReport]; }
}
public override long MessagesReceived {
get { return iin.Msgs; }
}
public override long MessagesSent {
get { return iout.Msgs; }
}
public override long NeighborAdvertisementsReceived {
get { return iin.Counts [IcmpV6MessageTypes.NeighborAdvertisement]; }
}
public override long NeighborAdvertisementsSent {
get { return iout.Counts [IcmpV6MessageTypes.NeighborAdvertisement]; }
}
public override long NeighborSolicitsReceived {
get { return iin.Counts [IcmpV6MessageTypes.NeighborSolicitation]; }
}
public override long NeighborSolicitsSent {
get { return iout.Counts [IcmpV6MessageTypes.NeighborSolicitation]; }
}
public override long PacketTooBigMessagesReceived {
get { return iin.Counts [IcmpV6MessageTypes.PacketTooBig]; }
}
public override long PacketTooBigMessagesSent {
get { return iout.Counts [IcmpV6MessageTypes.PacketTooBig]; }
}
public override long ParameterProblemsReceived {
get { return iin.Counts [IcmpV6MessageTypes.ParameterProblem]; }
}
public override long ParameterProblemsSent {
get { return iout.Counts [IcmpV6MessageTypes.ParameterProblem]; }
}
public override long RedirectsReceived {
get { return iin.Counts [IcmpV6MessageTypes.Redirect]; }
}
public override long RedirectsSent {
get { return iout.Counts [IcmpV6MessageTypes.Redirect]; }
}
public override long RouterAdvertisementsReceived {
get { return iin.Counts [IcmpV6MessageTypes.RouterAdvertisement]; }
}
public override long RouterAdvertisementsSent {
get { return iout.Counts [IcmpV6MessageTypes.RouterAdvertisement]; }
}
public override long RouterSolicitsReceived {
get { return iin.Counts [IcmpV6MessageTypes.RouterSolicitation]; }
}
public override long RouterSolicitsSent {
get { return iout.Counts [IcmpV6MessageTypes.RouterSolicitation]; }
}
public override long TimeExceededMessagesReceived {
get { return iin.Counts [IcmpV6MessageTypes.TimeExceeded]; }
}
public override long TimeExceededMessagesSent {
get { return iout.Counts [IcmpV6MessageTypes.TimeExceeded]; }
}
}
struct Win32_MIB_ICMP_EX
{
public Win32_MIBICMPSTATS_EX InStats;
public Win32_MIBICMPSTATS_EX OutStats;
}
struct Win32_MIBICMPSTATS_EX
{
public uint Msgs;
public uint Errors;
[MarshalAs (UnmanagedType.ByValArray, SizeConst = 256)]
public uint [] Counts;
}
}

View File

@@ -0,0 +1,106 @@
//
// System.Net.NetworkInformation.NetworkInterface
//
// Authors:
// Eric Butler (eric@extremeboredom.net)
//
// Copyright (c) 2008 Eric Butler
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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.Runtime.InteropServices;
namespace System.Net.NetworkInformation {
[StructLayout(LayoutKind.Explicit)]
struct ifa_ifu
{
[FieldOffset (0)]
public IntPtr ifu_broadaddr;
[FieldOffset (0)]
public IntPtr ifu_dstaddr;
}
[StructLayout(LayoutKind.Sequential)]
struct ifaddrs
{
public IntPtr ifa_next;
public string ifa_name;
public uint ifa_flags;
public IntPtr ifa_addr;
public IntPtr ifa_netmask;
public ifa_ifu ifa_ifu;
public IntPtr ifa_data;
}
[StructLayout(LayoutKind.Sequential)]
struct sockaddr_in
{
public ushort sin_family;
public ushort sin_port;
public uint sin_addr;
}
[StructLayout(LayoutKind.Sequential)]
struct sockaddr_in6
{
public ushort sin6_family; /* AF_INET6 */
public ushort sin6_port; /* Transport layer port # */
public uint sin6_flowinfo; /* IPv6 flow information */
public in6_addr sin6_addr; /* IPv6 address */
public uint sin6_scope_id; /* scope id (new in RFC2553) */
}
[StructLayout(LayoutKind.Sequential)]
struct in6_addr
{
[MarshalAs (UnmanagedType.ByValArray, SizeConst=16)]
public byte[] u6_addr8;
}
[StructLayout(LayoutKind.Sequential)]
struct sockaddr_ll
{
public ushort sll_family;
public ushort sll_protocol;
public int sll_ifindex;
public ushort sll_hatype;
public byte sll_pkttype;
public byte sll_halen;
[MarshalAs (UnmanagedType.ByValArray, SizeConst=8)]
public byte[] sll_addr;
}
enum LinuxArpHardware {
ETHER = 1,
EETHER = 2,
PRONET = 4,
ATM = 19,
SLIP = 256,
PPP = 512,
LOOPBACK = 772,
FDDI = 774,
TUNNEL = 768,
TUNNEL6 = 769
}
}

View File

@@ -0,0 +1,82 @@
using System;
using System.Runtime.InteropServices;
namespace System.Net.NetworkInformation {
namespace MacOsStructs {
internal struct ifaddrs
{
public IntPtr ifa_next;
public string ifa_name;
public uint ifa_flags;
public IntPtr ifa_addr;
public IntPtr ifa_netmask;
public IntPtr ifa_dstaddr;
public IntPtr ifa_data;
}
internal struct sockaddr
{
public byte sa_len;
public byte sa_family;
}
internal struct sockaddr_in
{
public byte sin_len;
public byte sin_family;
public ushort sin_port;
public uint sin_addr;
}
internal struct in6_addr
{
[MarshalAs (UnmanagedType.ByValArray, SizeConst=16)]
public byte[] u6_addr8;
}
internal struct sockaddr_in6
{
public byte sin6_len;
public byte sin6_family;
public ushort sin6_port;
public uint sin6_flowinfo;
public in6_addr sin6_addr;
public uint sin6_scope_id;
}
internal struct sockaddr_dl
{
public byte sdl_len;
public byte sdl_family;
public ushort sdl_index;
public byte sdl_type;
public byte sdl_nlen;
public byte sdl_alen;
public byte sdl_slen;
public byte[] sdl_data;
internal void Read (IntPtr ptr)
{
sdl_len = Marshal.ReadByte (ptr, 0);
sdl_family = Marshal.ReadByte (ptr, 1);
sdl_index = (ushort) Marshal.ReadInt16 (ptr, 2);
sdl_type = Marshal.ReadByte (ptr, 4);
sdl_nlen = Marshal.ReadByte (ptr, 5);
sdl_alen = Marshal.ReadByte (ptr, 6);
sdl_slen = Marshal.ReadByte (ptr, 7);
sdl_data = new byte [Math.Max (12, sdl_len - 8)];
Marshal.Copy (new IntPtr (ptr.ToInt64 () + 8), sdl_data, 0, sdl_data.Length);
}
}
}
internal enum MacOsArpHardware {
ETHER = 0x6,
ATM = 0x25,
SLIP = 0x1c,
PPP = 0x17,
LOOPBACK = 0x18,
FDDI = 0xf
}
}

View File

@@ -0,0 +1,95 @@
//
// System.Net.NetworkInformation.MulticastIPAddressInformation
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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.Runtime.InteropServices;
namespace System.Net.NetworkInformation {
public abstract class MulticastIPAddressInformation : IPAddressInformation {
protected MulticastIPAddressInformation ()
{
}
public abstract long AddressPreferredLifetime { get; }
public abstract long AddressValidLifetime { get; }
public abstract long DhcpLeaseLifetime { get; }
public abstract DuplicateAddressDetectionState DuplicateAddressDetectionState { get; }
public abstract PrefixOrigin PrefixOrigin { get; }
public abstract SuffixOrigin SuffixOrigin { get; }
}
// So, why are there many pointless members in the base class?
class MulticastIPAddressInformationImpl : MulticastIPAddressInformation
{
IPAddress address;
bool is_dns_eligible, is_transient;
public MulticastIPAddressInformationImpl (IPAddress address, bool isDnsEligible, bool isTransient)
{
this.address = address;
this.is_dns_eligible = isDnsEligible;
this.is_transient = isTransient;
}
public override IPAddress Address {
get { return address; }
}
public override bool IsDnsEligible {
get { return is_dns_eligible; }
}
public override bool IsTransient {
get { return is_transient; }
}
public override long AddressPreferredLifetime {
get { return 0; }
}
public override long AddressValidLifetime {
get { return 0; }
}
public override long DhcpLeaseLifetime {
get { return 0; }
}
public override DuplicateAddressDetectionState DuplicateAddressDetectionState {
get { return DuplicateAddressDetectionState.Invalid; }
}
public override PrefixOrigin PrefixOrigin {
get { return PrefixOrigin.Other; }
}
public override SuffixOrigin SuffixOrigin {
get { return SuffixOrigin.Other; }
}
}
}

View File

@@ -0,0 +1,140 @@
//
// System.Net.NetworkInformation.MulticastIPAddressInformationCollection
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
// Eric Butler (eric@extremeboredom.net)
//
// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace System.Net.NetworkInformation {
public class MulticastIPAddressInformationCollection : ICollection<MulticastIPAddressInformation>, IEnumerable<MulticastIPAddressInformation>, IEnumerable {
List<MulticastIPAddressInformation> list = new List<MulticastIPAddressInformation> ();
protected internal MulticastIPAddressInformationCollection ()
{
}
public virtual void Add (MulticastIPAddressInformation address)
{
if (IsReadOnly)
throw new NotSupportedException ("The collection is read-only.");
list.Add (address);
}
public virtual void Clear ()
{
if (IsReadOnly)
throw new NotSupportedException ("The collection is read-only.");
list.Clear ();
}
public virtual bool Contains (MulticastIPAddressInformation address)
{
return list.Contains (address);
}
public virtual void CopyTo (MulticastIPAddressInformation [] array, int offset)
{
list.CopyTo (array, offset);
}
public virtual IEnumerator<MulticastIPAddressInformation> GetEnumerator ()
{
return ((IEnumerable<MulticastIPAddressInformation>)list).GetEnumerator ();
}
public virtual bool Remove (MulticastIPAddressInformation address)
{
if (IsReadOnly)
throw new NotSupportedException ("The collection is read-only.");
return list.Remove (address);
}
IEnumerator IEnumerable.GetEnumerator ()
{
return list.GetEnumerator ();
}
public virtual int Count {
get { return list.Count; }
}
public virtual bool IsReadOnly {
get { return true; }
}
public virtual MulticastIPAddressInformation this [int index] {
get { return list [index]; }
}
}
class MulticastIPAddressInformationImplCollection : MulticastIPAddressInformationCollection
{
public static readonly MulticastIPAddressInformationImplCollection Empty = new MulticastIPAddressInformationImplCollection (true);
bool is_readonly;
// for static methods
MulticastIPAddressInformationImplCollection (bool isReadOnly)
{
is_readonly = isReadOnly;
}
public override bool IsReadOnly {
get { return is_readonly; }
}
public static MulticastIPAddressInformationCollection Win32FromMulticast (IntPtr ptr)
{
MulticastIPAddressInformationImplCollection c = new MulticastIPAddressInformationImplCollection (false);
Win32_IP_ADAPTER_MULTICAST_ADDRESS a;
for (IntPtr p = ptr; p != IntPtr.Zero; p = a.Next) {
a = (Win32_IP_ADAPTER_MULTICAST_ADDRESS) Marshal.PtrToStructure (p, typeof (Win32_IP_ADAPTER_MULTICAST_ADDRESS));
c.Add (new MulticastIPAddressInformationImpl (
a.Address.GetIPAddress (),
a.LengthFlags.IsDnsEligible,
a.LengthFlags.IsTransient));
}
c.is_readonly = true;
return c;
}
public static MulticastIPAddressInformationImplCollection LinuxFromList (List<IPAddress> addresses)
{
MulticastIPAddressInformationImplCollection c = new MulticastIPAddressInformationImplCollection (false);
foreach (IPAddress address in addresses) {
c.Add (new MulticastIPAddressInformationImpl (
address,
true,
false));
}
c.is_readonly = true;
return c;
}
}
}

Some files were not shown because too many files have changed in this diff Show More