nth_subnet returns the subnet IPv6Net at the given index.
 The number of subnets may be determined with the subnet_count() method.
 If the range is exceeded  or an invalid prefix_len is provided then return nil.
486501
def nth_subnet(prefix_len,index)
			count = self.subnet_count(prefix_len)
			if (count == 0 || index >= count)
				return nil
			end
			sub0 = IPv6Net.new(self.network, Mask128.new(prefix_len))
			return sub0.nth_next_sib(index)
		end
1187191
def is_reserved(self):
        
        reserved_nets = [IPv6Network(u'::/8'), IPv6Network(u'100::/8'),
                         IPv6Network(u'200::/7'), IPv6Network(u'400::/6'),
                         IPv6Network(u'800::/5'), IPv6Network(u'1000::/4'),
                         IPv6Network(u'4000::/3'), IPv6Network(u'6000::/3'),
                         IPv6Network(u'8000::/3'), IPv6Network(u'A000::/3'),
                         IPv6Network(u'C000::/3'), IPv6Network(u'E000::/4'),
                         IPv6Network(u'F000::/5'), IPv6Network(u'F800::/6'),
                         IPv6Network(u'FE00::/9')]

        return any(self in x for x in reserved_nets)
920905
def ip_address_subnet(self):
        
        return "{}/{}".format(
            self.interface.ip.compressed, self.interface.exploded.split("/")[-1]
        )
815356
def get_restricted_index(index, length, length_index_allowed=True):
    '''
    
    '''
    if index and index >= length:
        index = length if length_index_allowed else length-1
    return get_non_negative_index(index, length)
1043996
def sort_subnets_by_cidr_prefix(subnets)
      subnets.sort_by.with_index { |sbn, i| [subnet_address_prefix(sbn).split("/")[1].to_i, i] }
    end
625861
def calc_net(ipaddr, netmask=None):
    '''
    
    '''
    if netmask is not None:
        ipaddr = '{0}/{1}'.format(ipaddr, netmask)

    return six.text_type(ipaddress.ip_network(ipaddr, strict=False))
863191
def in6_6to4ExtractAddr(addr):
    
    try:
        addr = inet_pton(socket.AF_INET6, addr)
    except:
        return None
    if addr[:2] != b" \x02":
        return None
    return inet_ntop(socket.AF_INET, addr[2:6])
1216897
async def next(self, count=None):
        
        if self._next_uri is None:
            return self[:0]  # An empty slice of `self`.
        else:
            return self._fetch(self._next_uri, count)
1278006
def delete_subnet(self, subnet):
        '''
        
        '''
        subnet_id = self._find_subnet_id(subnet)
        ret = self.network_conn.delete_subnet(subnet=subnet_id)
        return ret if ret else True
832855
def get_subnet_nwk_excl(self, tenant_id, excl_list, excl_part=False):
        
        net_list = self.get_network_by_tenant(tenant_id)
        ret_subnet_list = []
        for net in net_list:
            if excl_part:
                name = net.get('name')
                part = name.partition('::')[2]
                if part:
                    continue
            subnet_lst = self.get_subnets_for_net(net.get('id'))
            for subnet_elem in subnet_lst:
                subnet = subnet_elem.get('cidr').split('/')[0]
                subnet_and_mask = subnet_elem.get('cidr')
                if subnet not in excl_list:
                    ret_subnet_list.append(subnet_and_mask)
        return ret_subnet_list
353027
def is_reserved(self):
        
        return (self in IPv6Network('::/8') or
                self in IPv6Network('100::/8') or
                self in IPv6Network('200::/7') or
                self in IPv6Network('400::/6') or
                self in IPv6Network('800::/5') or
                self in IPv6Network('1000::/4') or
                self in IPv6Network('4000::/3') or
                self in IPv6Network('6000::/3') or
                self in IPv6Network('8000::/3') or
                self in IPv6Network('A000::/3') or
                self in IPv6Network('C000::/3') or
                self in IPv6Network('E000::/4') or
                self in IPv6Network('F000::/5') or
                self in IPv6Network('F800::/6') or
                self in IPv6Network('FE00::/9'))
270407
def network n
      @logger.debug "OpenStack: Looking up network '#{n}'"
      @network_client.networks.find { |x| x.name == n } || raise("Couldn't find network: #{n}")
    end
601620
def divide_network(address_prefix)
      network_address = IPAddress(address_prefix)
      prefix = nil

      case network_address.count
      when 4097..65536
        prefix = "20"
      when 256..4096
        prefix = "24"
      end

      ## if the given network is small then do not divide it else divide using
      ## the prefix value calculated above ##
      prefix.nil? ? address_prefix : network_address.network.address.concat("/" + prefix)
    end
668036
def get_index_node(self, idx):
        ''''''
        idx = self.node_index.index(idx)
        return self.nodes[idx]
627524
def get_index(self, name_subdevice) -> int:
        """"""
        try:
            return self.dict_[name_subdevice]
        except KeyError:
            raise OSError(
                'No data for sequence `%s` and (sub)device `%s` '
                'in NetCDF file `%s` available.'
                % (self.name_sequence,
                   name_subdevice,
                   self.name_ncfile))
469868
def is_reserved(self):
        
        reserved_nets = [IPv6Network('::/8'), IPv6Network('100::/8'),
                         IPv6Network('200::/7'), IPv6Network('400::/6'),
                         IPv6Network('800::/5'), IPv6Network('1000::/4'),
                         IPv6Network('4000::/3'), IPv6Network('6000::/3'),
                         IPv6Network('8000::/3'), IPv6Network('A000::/3'),
                         IPv6Network('C000::/3'), IPv6Network('E000::/4'),
                         IPv6Network('F000::/5'), IPv6Network('F800::/6'),
                         IPv6Network('FE00::/9')]

        return any(self in x for x in reserved_nets)
742726
def _inet6_ntop(addr):
    
    # IPv6 addresses have 128bits (16 bytes)
    if len(addr) != 16:
        raise ValueError("invalid length of packed IP address string")

    # Decode to hex representation
    address = ":".join(plain_str(bytes_hex(addr[idx:idx + 2])).lstrip('0') or '0'  # noqa: E501
                       for idx in range(0, 16, 2))

    try:
        # Get the longest set of zero blocks. We need to take a look
        # at group 1 regarding the length, as 0:0:1:0:0:2:3:4 would
        # have two matches: 0:0: and :0:0: where the latter is longer,
        # though the first one should be taken. Group 1 is in both
        # cases 0:0.
        match = max(_IP6_ZEROS.finditer(address),
                    key=lambda m: m.end(1) - m.start(1))
        return '{}::{}'.format(address[:match.start()], address[match.end():])
    except ValueError:
        return address