Inheritance: NetworkInterface
コード例 #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;
        }
コード例 #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;
        }
コード例 #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);
        }
コード例 #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;
        }
コード例 #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;
        }
コード例 #6
0
		public UnixIPv4InterfaceProperties (UnixNetworkInterface iface)
		{
			this.iface = iface;
		}
コード例 #7
0
		public UnixIPInterfaceProperties (UnixNetworkInterface iface, List <IPAddress> addresses)
		{
			this.iface = iface;
			this.addresses = addresses;
		}
コード例 #8
0
 public UnixIPInterfaceProperties(UnixNetworkInterface uni)
 {
     _uni = uni;
     _dnsSuffix = GetDnsSuffix();
     _dnsAddresses = GetDnsAddresses();
 }
コード例 #9
0
 public UnixIPv4InterfaceProperties(UnixNetworkInterface iface)
 {
     this.iface = iface;
 }
コード例 #10
0
 public UnixIPInterfaceProperties(UnixNetworkInterface iface, List <IPAddress> addresses)
 {
     this.iface     = iface;
     this.addresses = addresses;
 }
コード例 #11
0
 public UnixIPInterfaceProperties(UnixNetworkInterface uni)
 {
     _uni          = uni;
     _dnsSuffix    = GetDnsSuffix();
     _dnsAddresses = GetDnsAddresses();
 }
コード例 #12
0
 public static int IfNameToIndex(string ifname)
 {
     return(UnixNetworkInterface.if_nametoindex(ifname));
 }
コード例 #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;
        }
コード例 #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;
        }