get expected global unicast IPv6 address of Thread device

        Args:
            filterByPrefix: a given expected global IPv6 prefix to be matched

        Returns:
            a global IPv6 address
339585
def getGUA(self, filterByPrefix=None):
        
        print '%s call getGUA' % self.port
        print filterByPrefix
        globalAddrs = []
        try:
            # get global addrs set if multiple
            globalAddrs = self.getGlobal()

            if filterByPrefix is None:
                return globalAddrs[0]
            else:
                for line in globalAddrs:
                    fullIp = ModuleHelper.GetFullIpv6Address(line)
                    if fullIp.startswith(filterByPrefix):
                        return fullIp
                print 'no global address matched'
                return str(globalAddrs[0])
        except Exception, e:
            ModuleHelper.WriteIntoDebugLogger("getGUA() Error: " + str(e))
1174134
def compile_filter(bpf_filter, iface=None):
    
    if not TCPDUMP:
        raise Scapy_Exception("tcpdump is not available. Cannot use filter !")
    try:
        process = subprocess.Popen([
            conf.prog.tcpdump,
            "-p",
            "-i", (conf.iface if iface is None else iface),
            "-ddd",
            "-s", str(MTU),
            bpf_filter],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE
        )
    except OSError as ex:
        raise Scapy_Exception("Failed to attach filter: %s" % ex)
    lines, err = process.communicate()
    ret = process.returncode
    if ret:
        raise Scapy_Exception(
            "Failed to attach filter: tcpdump returned: %s" % err
        )
    lines = lines.strip().split(b"\n")
    return get_bpf_pointer(lines)
372509
protected static <T extends IPAddress> T[] getSpanningPrefixBlocks(
			T first,
			T other,
			UnaryOperator<T> getLower,
			UnaryOperator<T> getUpper,
			Comparator<T> comparator,
			UnaryOperator<T> prefixAdder,
			UnaryOperator<T> prefixRemover,
			IntFunction<T[]> arrayProducer) {
		T[] result = checkPrefixBlockContainment(first, other, prefixAdder, arrayProducer);
		if(result != null) {
			return result;
		}
		List<IPAddressSegmentSeries> blocks = 
				IPAddressSection.getSpanningBlocks(first, other, getLower, getUpper, comparator, prefixRemover, IPAddressSection::splitIntoPrefixBlocks);
		return blocks.toArray(arrayProducer.apply(blocks.size()));
	}
1044991
def is_valid_vpnv6_prefix(prefix):
    
    if not isinstance(prefix, str):
        return False

    # Split the prefix into route distinguisher and IP
    tokens = prefix.split(':', 2)
    if len(tokens) != 3:
        return False

    # Validate route distinguisher
    if not is_valid_route_dist(':'.join([tokens[0], tokens[1]])):
        return False

    # Validate IPv6 prefix and return
    return is_valid_ipv6_prefix(tokens[2])
359377
def ipv6_prefix_to_mask(prefix):
    
    if prefix > 128 or prefix < 0:
        raise ValueError("invalid cidr prefix for ipv6")
    else:
        mask = ((1 << 128) - 1) ^ ((1 << (128 - prefix)) - 1)
        f = 15  # 0xf or 0b1111
        hex_mask_str = ''
        for i in range(0, 32):
            hex_mask_str = format((mask & f), 'x') + hex_mask_str
            mask = mask >> 4
            if i != 31 and i & 3 == 3:
                hex_mask_str = ':' + hex_mask_str
        return hex_mask_str
215627
public static onlinkipv6prefix[] get(nitro_service service, String ipv6prefix[]) throws Exception{
		if (ipv6prefix !=null && ipv6prefix.length>0) {
			onlinkipv6prefix response[] = new onlinkipv6prefix[ipv6prefix.length];
			onlinkipv6prefix obj[] = new onlinkipv6prefix[ipv6prefix.length];
			for (int i=0;i<ipv6prefix.length;i++) {
				obj[i] = new onlinkipv6prefix();
				obj[i].set_ipv6prefix(ipv6prefix[i]);
				response[i] = (onlinkipv6prefix) obj[i].get_resource(service);
			}
			return response;
		}
		return null;
	}
1362935
def _get_ipv6addrs(self):
        
        addrs = self._get_addrs()
        ipv6addrs = addrs.get(netifaces.AF_INET6)
        if not ipv6addrs:
            return {}
        return ipv6addrs[0]
233197
def get_alias_address(iface_name, ip_mask, gw_str, metric):
    

    # Detect the architecture
    if scapy.consts.IS_64BITS:
        offset, name_len = 16, 40
    else:
        offset, name_len = 32, 32

    # Retrieve interfaces structures
    sck = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    names = array.array('B', b'\0' * 4096)
    ifreq = ioctl(sck.fileno(), SIOCGIFCONF,
                  struct.pack("iL", len(names), names.buffer_info()[0]))

    # Extract interfaces names
    out = struct.unpack("iL", ifreq)[0]
    names = names.tobytes() if six.PY3 else names.tostring()
    names = [names[i:i + offset].split(b'\0', 1)[0] for i in range(0, out, name_len)]  # noqa: E501

    # Look for the IP address
    for ifname in names:
        # Only look for a matching interface name
        if not ifname.decode("utf8").startswith(iface_name):
            continue

        # Retrieve and convert addresses
        ifreq = ioctl(sck, SIOCGIFADDR, struct.pack("16s16x", ifname))
        ifaddr = struct.unpack(">I", ifreq[20:24])[0]
        ifreq = ioctl(sck, SIOCGIFNETMASK, struct.pack("16s16x", ifname))
        msk = struct.unpack(">I", ifreq[20:24])[0]

        # Get the full interface name
        ifname = plain_str(ifname)
        if ':' in ifname:
            ifname = ifname[:ifname.index(':')]
        else:
            continue

        # Check if the source address is included in the network
        if (ifaddr & msk) == ip_mask:
            sck.close()
            return (ifaddr & msk, msk, gw_str, ifname,
                    scapy.utils.ltoa(ifaddr), metric)

    sck.close()
    return
1306458
public static ns_ns_ip[] get_filtered(nitro_service service, String filter) throws Exception
	{
		ns_ns_ip obj = new ns_ns_ip();
		options option = new options();
		option.set_filter(filter);
		ns_ns_ip[] response = (ns_ns_ip[]) obj.getfiltered(service, option);
		return response;
	}
1051630
def get_filter_regex(self):
        
        if self.windowInfoRegex is not None:
            if self.isRecursive:
                return self.windowInfoRegex.pattern
            else:
                return self.windowInfoRegex.pattern
        elif self.parent is not None:
            return self.parent.get_child_filter()
        else:
            return ""
684590
def get_if_raw_addr6(iff):
    
    #r = filter(lambda x: x[2] == iff and x[1] == IPV6_ADDR_GLOBAL, in6_getifaddr())
    r = [ x for x in in6_getifaddr() if x[2] == iff and x[1] == IPV6_ADDR_GLOBAL]
    if len(r) == 0:
        return None
    else:
        r = r[0][0] 
    return inet_pton(socket.AF_INET6, r)
654256
private HttpPrefixFetchFilter getUriPrefixFecthFilter(Object[] customConfigurations) {
		if (customConfigurations != null) {
			for (Object customConfiguration : customConfigurations) {
				if (customConfiguration instanceof HttpPrefixFetchFilter) {
					return (HttpPrefixFetchFilter) customConfiguration;
				}
			}
		}
		return null;
	}
666307
def get_if_addr6(iff):
    
    return next((x[0] for x in in6_getifaddr()
                 if x[2] == iff and x[1] == IPV6_ADDR_GLOBAL), None)
365262
def out_filter_get(self, address):
        

        func_name = 'neighbor.out_filter.get'
        param = {
            neighbors.IP_ADDRESS: address,
        }

        return call(func_name, **param)
627503
private IPAddress computeMaskFromNetworkPrefix(int prefix) {
		
		/*
		 * int subnet = 0; for (int i=0; i<prefix; i++) { subnet = subnet << 1; subnet += 1; }
		 */
		
		StringBuilder str = new StringBuilder();
		for (int i = 0; i < 32; i++) {
			if (i < prefix) {
				str.append("1");
			} else {
				str.append("0");
			}
		}
		
		String decimalString = toDecimalString(str.toString());
		return new IPAddress(decimalString);
		
	}
1101390
def rlw_filter(name, location, size, unsize):
    
    arch = _meta_.arch
    if arch.startswith("i") and arch.endswith("86"):
        arch = "i486"
    (fname, flocation, fsize, funsize) = ([] for i in range(4))
    for n, l, s, u in zip(name, location, size, unsize):
        loc = l.split("/")
        if arch == loc[-1]:
            fname.append(n)
            flocation.append(l)
            fsize.append(s)
            funsize.append(u)
    return [fname, flocation, fsize, funsize]
850962
def _check_rf_and_normalize(prefix):
        
        addr, masklen = prefix.split('/')
        if ip.valid_ipv6(addr):
            # normalize IPv6 address
            ipv6_prefix = str(netaddr.IPAddress(addr)) + '/' + masklen
            return vrfs.VRF_RF_IPV6, ipv6_prefix
        else:
            return vrfs.VRF_RF_IPV4, prefix