Пример #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;
 }
 public UnixIPInterfaceProperties(UnixNetworkInterface uni)
 {
     _uni          = uni;
     _dnsSuffix    = GetDnsSuffix();
     _dnsAddresses = GetDnsAddresses();
 }
 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;
        }