Inheritance: NetworkInterface
Ejemplo n.º 1
0
        private static MulticastIPAddressInformationCollection GetMulticastAddresses(UnixNetworkInterface uni)
        {
            var collection = new MulticastIPAddressInformationCollection();
            foreach (IPAddress address in uni.Addresses.Where(IsMulticast))
            {
                collection.InternalAdd(new UnixMulticastIPAddressInformation(address));
            }

            return collection;
        }
Ejemplo n.º 2
0
        private static UnicastIPAddressInformationCollection GetUnicastAddresses(UnixNetworkInterface uni)
        {
            var collection = new UnicastIPAddressInformationCollection();
            foreach (IPAddress address in uni.Addresses.Where((addr) => !IsMulticast(addr)))
            {
                IPAddress netMask = (address.AddressFamily == AddressFamily.InterNetwork)
                                    ? uni.GetNetMaskForIPv4Address(address)
                                    : IPAddress.Any; // Windows compatibility
                collection.InternalAdd(new UnixUnicastIPAddressInformation(address, netMask));
            }

            return collection;
        }
Ejemplo n.º 3
0
        private static UnicastIPAddressInformationCollection GetUnicastAddresses(UnixNetworkInterface uni)
        {
            var collection = new UnicastIPAddressInformationCollection();

            foreach (IPAddress address in uni.Addresses)
            {
                if (!IPAddressUtil.IsMulticast(address))
                {
                    IPAddress netMask = (address.AddressFamily == AddressFamily.InterNetwork)
                                        ? uni.GetNetMaskForIPv4Address(address)
                                        : IPAddress.Any; // Windows compatibility
                    collection.InternalAdd(new UnixUnicastIPAddressInformation(address, netMask));
                }
            }

            return(collection);
        }
Ejemplo n.º 4
0
        protected static unsafe void ProcessIpv4Address(UnixNetworkInterface uni,
                                                Interop.Sys.IpAddressInfo* addressInfo,
                                                Interop.Sys.IpAddressInfo* netMask)
        {
            byte[] ipBytes = new byte[addressInfo->NumAddressBytes];
            fixed (byte* ipArrayPtr = ipBytes)
            {
                Buffer.MemoryCopy(addressInfo->AddressBytes, ipArrayPtr, ipBytes.Length, ipBytes.Length);
            }
            IPAddress ipAddress = new IPAddress(ipBytes);

            byte[] ipBytes2 = new byte[netMask->NumAddressBytes];
            fixed (byte* ipArrayPtr = ipBytes2)
            {
                Buffer.MemoryCopy(netMask->AddressBytes, ipArrayPtr, ipBytes2.Length, ipBytes2.Length);
            }
            IPAddress netMaskAddress = new IPAddress(ipBytes2);

            uni.AddAddress(ipAddress);
            uni._netMasks[ipAddress] = netMaskAddress;
        }
Ejemplo n.º 5
0
        protected static unsafe void ProcessIpv4Address(UnixNetworkInterface uni,
                                                        Interop.Sys.IpAddressInfo *addressInfo,
                                                        Interop.Sys.IpAddressInfo *netMask)
        {
            byte[] ipBytes = new byte[addressInfo->NumAddressBytes];
            fixed(byte *ipArrayPtr = ipBytes)
            {
                Buffer.MemoryCopy(addressInfo->AddressBytes, ipArrayPtr, ipBytes.Length, ipBytes.Length);
            }

            IPAddress ipAddress = new IPAddress(ipBytes);

            byte[] ipBytes2 = new byte[netMask->NumAddressBytes];
            fixed(byte *ipArrayPtr = ipBytes2)
            {
                Buffer.MemoryCopy(netMask->AddressBytes, ipArrayPtr, ipBytes2.Length, ipBytes2.Length);
            }

            IPAddress netMaskAddress = new IPAddress(ipBytes2);

            uni.AddAddress(ipAddress);
            uni._netMasks[ipAddress] = netMaskAddress;
        }
Ejemplo n.º 6
0
		public UnixIPv4InterfaceProperties (UnixNetworkInterface iface)
		{
			this.iface = iface;
		}
Ejemplo n.º 7
0
		public UnixIPInterfaceProperties (UnixNetworkInterface iface, List <IPAddress> addresses)
		{
			this.iface = iface;
			this.addresses = addresses;
		}
Ejemplo n.º 8
0
 public UnixIPInterfaceProperties(UnixNetworkInterface uni)
 {
     _uni = uni;
     _dnsSuffix = GetDnsSuffix();
     _dnsAddresses = GetDnsAddresses();
 }
Ejemplo n.º 9
0
 public UnixIPv4InterfaceProperties(UnixNetworkInterface iface)
 {
     this.iface = iface;
 }
Ejemplo n.º 10
0
 public UnixIPInterfaceProperties(UnixNetworkInterface iface, List <IPAddress> addresses)
 {
     this.iface     = iface;
     this.addresses = addresses;
 }
 public UnixIPInterfaceProperties(UnixNetworkInterface uni)
 {
     _uni          = uni;
     _dnsSuffix    = GetDnsSuffix();
     _dnsAddresses = GetDnsAddresses();
 }
 public static int IfNameToIndex(string ifname)
 {
     return(UnixNetworkInterface.if_nametoindex(ifname));
 }
Ejemplo n.º 13
0
        protected static unsafe void ProcessIpv6Address(UnixNetworkInterface uni,
                                                        Interop.Sys.IpAddressInfo* addressInfo,
                                                        uint scopeId)
        {
            byte[] ipBytes = new byte[addressInfo->NumAddressBytes];
            fixed (byte* ipArrayPtr = ipBytes)
            {
                Buffer.MemoryCopy(addressInfo->AddressBytes, ipArrayPtr, ipBytes.Length, ipBytes.Length);
            }
            IPAddress address = new IPAddress(ipBytes);

            uni.AddAddress(address);
            uni._ipv6ScopeId = scopeId;
        }
Ejemplo n.º 14
0
        protected static unsafe void ProcessLinkLayerAddress(UnixNetworkInterface uni, Interop.Sys.LinkLayerAddressInfo* llAddr)
        {
            byte[] macAddress = new byte[llAddr->NumAddressBytes];
            fixed (byte* macAddressPtr = macAddress)
            {
                Buffer.MemoryCopy(llAddr->AddressBytes, macAddressPtr, llAddr->NumAddressBytes, llAddr->NumAddressBytes);
            }
            PhysicalAddress physicalAddress = new PhysicalAddress(macAddress);

            uni._index = llAddr->InterfaceIndex;
            uni._id = uni._index.ToString();
            uni._physicalAddress = physicalAddress;
            uni._networkInterfaceType = (NetworkInterfaceType)llAddr->HardwareType;
        }