// Helper method that marshals the address information into the classes.
        internal static UnicastIPAddressInformationCollection MarshalUnicastIpAddressInformationCollection(IntPtr ptr)
        {
            UnicastIPAddressInformationCollection addressList = new UnicastIPAddressInformationCollection();

            while (ptr != IntPtr.Zero)
            {
                Interop.IpHlpApi.IpAdapterUnicastAddress addr = Marshal.PtrToStructure <Interop.IpHlpApi.IpAdapterUnicastAddress>(ptr);
                addressList.InternalAdd(new SystemUnicastIPAddressInformation(addr));
                ptr = addr.next;
            }

            return(addressList);
        }
        internal SystemUnicastIPAddressInformation(Interop.IpHlpApi.IpAdapterUnicastAddress adapterAddress)
        {
            IPAddress ipAddress = adapterAddress.address.MarshalIPAddress();

            _innerInfo         = new SystemIPAddressInformation(ipAddress, adapterAddress.flags);
            _prefixOrigin      = adapterAddress.prefixOrigin;
            _suffixOrigin      = adapterAddress.suffixOrigin;
            _dadState          = adapterAddress.dadState;
            _validLifetime     = adapterAddress.validLifetime;
            _preferredLifetime = adapterAddress.preferredLifetime;
            _dhcpLeaseLifetime = adapterAddress.leaseLifetime;

            _prefixLength = adapterAddress.prefixLength;

            // IPv6 returns 0.0.0.0 for consistency with down-level platforms.
            if (ipAddress.AddressFamily == AddressFamily.InterNetwork)
            {
                _ipv4Mask = PrefixLengthToSubnetMask(_prefixLength, ipAddress.AddressFamily);
            }
        }