Same as function above, but for ipv6
510502
def collect_ip6table(self, tablename):
        

        modname = "ip6table_"+tablename
        if self.check_ext_prog("grep -q %s /proc/modules" % modname):
            cmd = "ip6tables -t "+tablename+" -nvL"
            self.add_cmd_output(cmd)
396237
function CIDR(addr, prefixLen) {
  if (prefixLen === undefined) {
    /* OK to pass pass string of "<addr>/<prefix>" */
    assert.string(addr);
    var fields = addr.match(/^([a-fA-F0-9:.]+)\/([0-9]+)$/);
    if (fields === null) {
      throw new Error('Invalid argument: <addr>/<prefix> expected');
    }
    addr = fields[1];
    prefixLen = parseInt(fields[2], 10);
  }
  assert.number(prefixLen);
  prefixLen = prefixLen | 0;
  addr = _toAddr(addr);

  /* Expand prefix to ipv6 length of bare ipv4 address provided */
  if (addr._attrs.ipv4Bare) {
    prefixLen += 96;
  }
  if (prefixLen < 0 || prefixLen > 128) {
    throw new Error('Invalid prefix length');
  }
  this._prefix = prefixLen;
  this._mask = _prefixToAddr(prefixLen);
  this._addr = addr.and(this._mask);
}
313682
def in_subnet(cidr, addr=None):
    '''
    
    '''
    try:
        cidr = ipaddress.ip_network(cidr)
    except ValueError:
        log.error('Invalid CIDR \'%s\'', cidr)
        return False

    if addr is None:
        addr = ip_addrs()
        addr.extend(ip_addrs6())
    elif not isinstance(addr, (list, tuple)):
        addr = (addr,)

    return any(ipaddress.ip_address(item) in cidr for item in addr)
436241
def in6_isincluded(addr, prefix, plen):
    
    temp = inet_pton(socket.AF_INET6, addr)
    pref = in6_cidr2mask(plen)
    zero = inet_pton(socket.AF_INET6, prefix)
    return zero == in6_and(temp, pref)
319984
def detect(self):
        """"""
        if self.opts_family == AF_INET6:
            kind = IPV6_PUBLIC
        else:  # 'INET':
            kind = IPV4
        theip = None
        try:
            theip = detect_ip(kind)
        except GetIpException:
            LOG.exception("socket detector raised an exception:")
        self.set_current_value(theip)
        return theip
786832
def _parse_addr(self, addr): 
        '''  '''
        ipv = 0
        try:
            socket.inet_pton(socket.AF_INET6, addr)
            # Convert ::FFFF:x.y.z.y to IPv4
            if addr.lower().startswith('::ffff:'):
                try:
                    socket.inet_pton(socket.AF_INET, addr)
                    ipv = 4
                except:
                    ipv = 6
            else:
                ipv = 6
        except:
            socket.inet_pton(socket.AF_INET, addr)
            ipv = 4
        return ipv
1048261
function normalizeIP(addr) {
  var claimsToBeIPv6 = /:/.test(addr);
  if(claimsToBeIPv6) {
    var ip6 = new Address6(addr);
    if(ip6.valid) {
      return ip6.canonicalForm();
    } else if(ip6.error) {
      throw new Error(ip6.error);
    } else {
      throw new Error("Unknown error while parsing IPv6 address.");
    }
  } else {
    var isIPv4 = false;
    try {
      var ip4 = new Address4(addr);
      isIPv4 = ip4.valid;
    }
    //  Any exception thrown implies not a valid IPv4 address.
    catch(error) {
      throw new Error("Unknown error while parsing IPv4 Address: "+error);
    }

    if(isIPv4) {
      return addr;
    }
    else {
      throw new Error("Unknown error while parsing IPv4 Address.");
    }
  }
}
623718
def get_socket(addr, type=socket.SOCK_STREAM, proto=0):
    '''
    
    '''

    version = ipaddress.ip_address(addr).version
    if version == 4:
        family = socket.AF_INET
    elif version == 6:
        family = socket.AF_INET6
    return socket.socket(family, type, proto)
1275353
def ipv6_interval=(arr)
      interval, min_rx, multiplier = arr
      set_args_keys(interval: interval, min_rx: min_rx, multiplier: multiplier,
                    state: arr == default_ipv6_interval ? 'no' : '')
      config_set('bfd_global', 'ipv6_interval', @set_args)
    end
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)
1340875
def _get_ipv6_from_binary(self, bin_addr):
        """"""

        hi = bin_addr >> 64
        lo = bin_addr & 0xFFFFFFFF
        return socket.inet_ntop(socket.AF_INET6, struct.pack("!QQ", hi, lo))
951026
def ipv6(self, network=False):
        """"""
        address = str(ip_address(self.generator.random.randint(
            2 ** IPV4LENGTH, (2 ** IPV6LENGTH) - 1)))
        if network:
            address += '/' + str(self.generator.random.randint(0, IPV6LENGTH))
            address = str(ip_network(address, strict=False))
        return address
917215
function pton(af, addr, dest, index) {
  switch (af) {
    case IPV4_OCTETS:
      return pton4(addr, dest, index)
    case IPV6_OCTETS:
      return pton6(addr, dest, index)
    default:
      throw new Error('Unsupported ip address.')
  }
}
1320863
def create(self, ipv6s):
        

        data = {'ips': ipv6s}
        return super(ApiIPv6, self).post('api/v3/ipv6/', data)
554714
def i2m(self, pkt, i):
        """""""
        mask, ip = i
        ip = socket.inet_aton(ip)
        return struct.pack(">B", mask) + ip[:self.mask2iplen(mask)]
628277
def is_valid_ipv6(ip_str):
    
    try:
        socket.inet_pton(socket.AF_INET6, ip_str)
    except socket.error:
        return False
    return True
1219772
function ip6addrParse(input) {
  if (typeof (input) === 'string') {
    return parseString(input);
  } else if (typeof (input) === 'number') {
    return parseLong(input);
  } else if (typeof (input) === 'object' && _isAddr(input)) {
    return input;
  } else {
    throw new Error('Invalid argument: only string|number allowed');
  }
}