You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
committed by
Jo Shields
parent
aa7da660d6
commit
c042cd0c52
@@ -28,27 +28,6 @@
|
||||
// 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;
|
||||
|
@@ -365,7 +365,9 @@ namespace System.Net.NetworkInformation {
|
||||
if (fd.ToInt64 () == -1)
|
||||
return false;
|
||||
|
||||
nl_sock = new Socket (0, SocketType.Raw, ProtocolType.Udp, fd);
|
||||
var safeHandle = new SafeSocketHandle (fd, true);
|
||||
|
||||
nl_sock = new Socket (0, SocketType.Raw, ProtocolType.Udp, safeHandle);
|
||||
nl_args = new SocketAsyncEventArgs ();
|
||||
nl_args.SetBuffer (new byte [8192], 0, 8192);
|
||||
nl_args.Completed += OnDataAvailable;
|
||||
@@ -402,13 +404,15 @@ namespace System.Net.NetworkInformation {
|
||||
void OnAvailabilityChanged (object unused)
|
||||
{
|
||||
NetworkAvailabilityChangedEventHandler d = AvailabilityChanged;
|
||||
d (null, new NetworkAvailabilityEventArgs (GetAvailability ()));
|
||||
if (d != null)
|
||||
d (null, new NetworkAvailabilityEventArgs (GetAvailability ()));
|
||||
}
|
||||
|
||||
void OnAddressChanged (object unused)
|
||||
{
|
||||
NetworkAddressChangedEventHandler d = AddressChanged;
|
||||
d (null, EventArgs.Empty);
|
||||
if (d != null)
|
||||
d (null, EventArgs.Empty);
|
||||
}
|
||||
|
||||
void OnEventDue (object unused)
|
||||
|
@@ -70,6 +70,11 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
}
|
||||
|
||||
public static IPAddress GetNetMask (IPAddress address)
|
||||
{
|
||||
return nif.GetNetMask (address);
|
||||
}
|
||||
|
||||
public abstract IPInterfaceProperties GetIPProperties ();
|
||||
public abstract IPv4InterfaceStatistics GetIPv4Statistics ();
|
||||
public abstract PhysicalAddress GetPhysicalAddress ();
|
||||
@@ -101,12 +106,12 @@ namespace System.Net.NetworkInformation {
|
||||
|
||||
class MacOsNetworkInterfaceAPI : UnixNetworkInterfaceAPI
|
||||
{
|
||||
const int AF_INET = 2;
|
||||
const int AF_INET6 = 30;
|
||||
const int AF_LINK = 18;
|
||||
|
||||
public override NetworkInterface [] GetAllNetworkInterfaces ()
|
||||
{
|
||||
const int AF_INET = 2;
|
||||
const int AF_INET6 = 30;
|
||||
const int AF_LINK = 18;
|
||||
|
||||
var interfaces = new Dictionary <string, MacOsNetworkInterface> ();
|
||||
IntPtr ifap;
|
||||
if (getifaddrs (out ifap) != 0)
|
||||
@@ -210,6 +215,37 @@ namespace System.Net.NetworkInformation {
|
||||
{
|
||||
return if_nametoindex ("lo0");
|
||||
}
|
||||
|
||||
public override IPAddress GetNetMask (IPAddress address)
|
||||
{
|
||||
IntPtr ifap;
|
||||
if (getifaddrs (out ifap) != 0)
|
||||
throw new SystemException ("getifaddrs() failed");
|
||||
|
||||
try {
|
||||
IntPtr next = ifap;
|
||||
while (next != IntPtr.Zero) {
|
||||
MacOsStructs.ifaddrs addr = (MacOsStructs.ifaddrs) Marshal.PtrToStructure (next, typeof (MacOsStructs.ifaddrs));
|
||||
|
||||
if (addr.ifa_addr != IntPtr.Zero) {
|
||||
// optain IPAddress
|
||||
MacOsStructs.sockaddr sockaddr = (MacOsStructs.sockaddr) Marshal.PtrToStructure (addr.ifa_addr, typeof (MacOsStructs.sockaddr));
|
||||
|
||||
if (sockaddr.sa_family == AF_INET) {
|
||||
MacOsStructs.sockaddr_in sockaddrin = (MacOsStructs.sockaddr_in) Marshal.PtrToStructure (addr.ifa_addr, typeof (MacOsStructs.sockaddr_in));
|
||||
var saddress = new IPAddress (sockaddrin.sin_addr);
|
||||
if (address.Equals (saddress))
|
||||
return new IPAddress(((sockaddr_in)Marshal.PtrToStructure(addr.ifa_netmask, typeof(sockaddr_in))).sin_addr);
|
||||
}
|
||||
}
|
||||
next = addr.ifa_next;
|
||||
}
|
||||
} finally {
|
||||
freeifaddrs (ifap);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class LinuxNetworkInterfaceAPI : UnixNetworkInterfaceAPI
|
||||
@@ -367,6 +403,11 @@ namespace System.Net.NetworkInformation {
|
||||
{
|
||||
return if_nametoindex ("lo");
|
||||
}
|
||||
|
||||
public override IPAddress GetNetMask (IPAddress address)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
class Win32NetworkInterfaceAPI : NetworkInterfaceFactory
|
||||
@@ -410,10 +451,16 @@ namespace System.Net.NetworkInformation {
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public override IPAddress GetNetMask (IPAddress address)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract NetworkInterface [] GetAllNetworkInterfaces ();
|
||||
public abstract int GetLoopbackInterfaceIndex ();
|
||||
public abstract IPAddress GetNetMask (IPAddress address);
|
||||
|
||||
public static NetworkInterfaceFactory Create ()
|
||||
{
|
||||
|
@@ -29,22 +29,9 @@
|
||||
//
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace System.Net.NetworkInformation {
|
||||
public abstract class UnicastIPAddressInformation : IPAddressInformation {
|
||||
protected UnicastIPAddressInformation ()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract long AddressPreferredLifetime { get; }
|
||||
public abstract long AddressValidLifetime { get; }
|
||||
public abstract long DhcpLeaseLifetime { get; }
|
||||
public abstract DuplicateAddressDetectionState DuplicateAddressDetectionState { get; }
|
||||
public abstract IPAddress IPv4Mask { get; }
|
||||
public abstract PrefixOrigin PrefixOrigin { get; }
|
||||
public abstract SuffixOrigin SuffixOrigin { get; }
|
||||
}
|
||||
|
||||
class Win32UnicastIPAddressInformation : UnicastIPAddressInformation
|
||||
{
|
||||
int if_index;
|
||||
@@ -122,6 +109,7 @@ namespace System.Net.NetworkInformation {
|
||||
class LinuxUnicastIPAddressInformation : UnicastIPAddressInformation
|
||||
{
|
||||
IPAddress address;
|
||||
IPAddress ipv4Mask;
|
||||
|
||||
public LinuxUnicastIPAddressInformation (IPAddress address)
|
||||
{
|
||||
@@ -163,7 +151,16 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
|
||||
public override IPAddress IPv4Mask {
|
||||
get { throw new NotImplementedException (); }
|
||||
get {
|
||||
// The IPv6 equivilant (for .net compatibility)
|
||||
if (Address.AddressFamily != AddressFamily.InterNetwork)
|
||||
return IPAddress.Any;
|
||||
|
||||
if (ipv4Mask == null)
|
||||
ipv4Mask = NetworkInterface.GetNetMask (address);
|
||||
|
||||
return ipv4Mask;
|
||||
}
|
||||
}
|
||||
|
||||
public override PrefixOrigin PrefixOrigin {
|
||||
|
Reference in New Issue
Block a user