Beispiel #1
0
        public IEnumerator <IPAddress> GetEnumerator()
        {
            var first = Begin.GetAddressBytes();
            var last  = End.GetAddressBytes();

            for (var ip = first; Bits.LtECore(ip, last); ip = Bits.Increment(ip))
            {
                yield return(new IPAddress(ip));
            }
        }
Beispiel #2
0
        public bool Contains(IPAddressRange range)
        {
            if (range == null)
            {
                throw new ArgumentNullException(nameof(range));
            }

            if (this.Begin.AddressFamily != range.Begin.AddressFamily)
            {
                return(false);
            }

            var offset = 0;

            if (Begin.IsIPv4MappedToIPv6 && range.Begin.IsIPv4MappedToIPv6)
            {
                offset = 12; //ipv4 has prefix of 10 zero bytes and two 255 bytes.
            }

            return
                (Bits.LtECore(this.Begin.GetAddressBytes(), range.Begin.GetAddressBytes(), offset) &&
                 Bits.GtECore(this.End.GetAddressBytes(), range.End.GetAddressBytes(), offset));
        }
Beispiel #3
0
        public bool Contains(IPAddress ipaddress)
        {
            if (ipaddress == null)
            {
                throw new ArgumentNullException(nameof(ipaddress));
            }

            if (ipaddress.AddressFamily != this.Begin.AddressFamily)
            {
                return(false);
            }

            var offset = 0;

            if (Begin.IsIPv4MappedToIPv6 && ipaddress.IsIPv4MappedToIPv6)
            {
                offset = 12; //ipv4 has prefix of 10 zero bytes and two 255 bytes.
            }

            var adrBytes = ipaddress.GetAddressBytes();

            return(Bits.LtECore(this.Begin.GetAddressBytes(), adrBytes, offset) && Bits.GtECore(this.End.GetAddressBytes(), adrBytes, offset));
        }