public unsafe override UnicastIPAddressInformationCollection GetUnicastAddresses()
        {
            UnicastIPAddressInformationCollection collection = new UnicastIPAddressInformationCollection();

            Interop.Sys.EnumerateInterfaceAddresses(
                (name, ipAddressInfo) =>
            {
                IPAddress ipAddress = IPAddressUtil.GetIPAddressFromNativeInfo(ipAddressInfo);
                if (!IPAddressUtil.IsMulticast(ipAddress))
                {
                    collection.InternalAdd(new UnixUnicastIPAddressInformation(ipAddress, ipAddressInfo->PrefixLength));
                }
            },
                (name, ipAddressInfo, scopeId) =>
            {
                IPAddress ipAddress = IPAddressUtil.GetIPAddressFromNativeInfo(ipAddressInfo);
                if (!IPAddressUtil.IsMulticast(ipAddress))
                {
                    collection.InternalAdd(new UnixUnicastIPAddressInformation(ipAddress, ipAddressInfo->PrefixLength));
                }
            },
                // Ignore link-layer addresses that are discovered; don't create a callback.
                null);

            return(collection);
        }
        protected unsafe void ProcessIpv4Address(Interop.Sys.IpAddressInfo *addressInfo)
        {
            IPAddress ipAddress = IPAddressUtil.GetIPAddressFromNativeInfo(addressInfo);

            AddAddress(ipAddress, addressInfo->PrefixLength);
            _index = addressInfo->InterfaceIndex;
        }
        private unsafe UnicastIPAddressInformationCollection GetUnicastAddresses()
        {
            UnicastIPAddressInformationCollection collection = new UnicastIPAddressInformationCollection();

            Interop.Sys.EnumerateInterfaceAddresses(
                (name, ipAddressInfo, netmaskInfo) =>
            {
                IPAddress ipAddress = IPAddressUtil.GetIPAddressFromNativeInfo(ipAddressInfo);
                if (!IPAddressUtil.IsMulticast(ipAddress))
                {
                    IPAddress netMaskAddress = IPAddressUtil.GetIPAddressFromNativeInfo(netmaskInfo);
                    collection.InternalAdd(new UnixUnicastIPAddressInformation(ipAddress, netMaskAddress));
                }
            },
                (name, ipAddressInfo, scopeId) =>
            {
                IPAddress ipAddress = IPAddressUtil.GetIPAddressFromNativeInfo(ipAddressInfo);
                if (!IPAddressUtil.IsMulticast(ipAddress))
                {
                    collection.InternalAdd(new UnixUnicastIPAddressInformation(ipAddress, IPAddress.Any));
                }
            },
                // Ignore link-layer addresses that are discovered; don't create a callback.
                null);

            return(collection);
        }
Exemple #4
0
        protected unsafe void ProcessIpv4Address(Interop.Sys.IpAddressInfo *addressInfo, Interop.Sys.IpAddressInfo *netMask)
        {
            IPAddress ipAddress      = IPAddressUtil.GetIPAddressFromNativeInfo(addressInfo);
            IPAddress netMaskAddress = IPAddressUtil.GetIPAddressFromNativeInfo(netMask);

            AddAddress(ipAddress);
            _netMasks[ipAddress] = netMaskAddress;
        }
Exemple #5
0
        protected unsafe void ProcessIpv6Address(Interop.Sys.IpAddressInfo *addressInfo, uint scopeId)
        {
            IPAddress address = IPAddressUtil.GetIPAddressFromNativeInfo(addressInfo);

            address.ScopeId = scopeId;
            AddAddress(address);
            _ipv6ScopeId = scopeId;
        }
        protected static unsafe void ProcessIpv6Address(UnixNetworkInterface uni,
                                                        Interop.Sys.IpAddressInfo *addressInfo,
                                                        uint scopeId)
        {
            IPAddress address = IPAddressUtil.GetIPAddressFromNativeInfo(addressInfo);

            uni.AddAddress(address);
            uni._ipv6ScopeId = scopeId;
        }
        protected unsafe void ProcessIpv6Address(Interop.Sys.IpAddressInfo *addressInfo, uint scopeId)
        {
            IPAddress address = IPAddressUtil.GetIPAddressFromNativeInfo(addressInfo);

            address.ScopeId = scopeId;
            AddAddress(address, addressInfo->PrefixLength);
            _ipv6ScopeId = scopeId;
            _index       = addressInfo->InterfaceIndex;
        }
        protected static unsafe void ProcessIpv4Address(UnixNetworkInterface uni,
                                                        Interop.Sys.IpAddressInfo *addressInfo,
                                                        Interop.Sys.IpAddressInfo *netMask)
        {
            IPAddress ipAddress      = IPAddressUtil.GetIPAddressFromNativeInfo(addressInfo);
            IPAddress netMaskAddress = IPAddressUtil.GetIPAddressFromNativeInfo(netMask);

            uni.AddAddress(ipAddress);
            uni._netMasks[ipAddress] = netMaskAddress;
        }
Exemple #9
0
        // Adds any IPAddress to this interface's List of addresses.
        protected void AddAddress(IPAddress ipAddress, int prefix)
        {
            if (IPAddressUtil.IsMulticast(ipAddress))
            {
                // Deferred initialization.
                _multicastAddresses ??= new List <IPAddress>();

                _multicastAddresses.Add(ipAddress);
            }
            else
            {
                _unicastAddresses.Add(new UnixUnicastIPAddressInformation(ipAddress, prefix));
            }
        }
        private static UnicastIPAddressInformationCollection GetUnicastAddresses(UnixNetworkInterface uni)
        {
            var collection = new UnicastIPAddressInformationCollection();

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

            return(collection);
        }
        private static MulticastIPAddressInformationCollection GetMulticastAddresses(UnixNetworkInterface uni)
        {
            var collection = new MulticastIPAddressInformationCollection();

            foreach (IPAddress address in uni.Addresses)
            {
                if (IPAddressUtil.IsMulticast(address))
                {
                    collection.InternalAdd(new UnixMulticastIPAddressInformation(address));
                }
            }

            return(collection);
        }