// IPv6AddrAttr returns a string representation of an attribute for the given
// IPv6Addr.
558353
func IPv6AddrAttr(ipv6 IPv6Addr, selector AttrName) string {
	fn, found := ipv6AddrAttrMap[selector]
	if !found {
		return ""
	}

	return fn(ipv6)
}
322886
func IPv6(t *testing.T, b []byte, checkers ...NetworkChecker) {
	t.Helper()

	ipv6 := header.IPv6(b)
	if !ipv6.IsValid(len(b)) {
		t.Error("Not a valid IPv6 packet")
	}

	for _, f := range checkers {
		f(t, []header.Network{ipv6})
	}
	if t.Failed() {
		t.FailNow()
	}
}
883837
func IfAttrs(selectorName string, ifAddrs IfAddrs) (string, error) {
	if len(ifAddrs) == 0 {
		return "", nil
	}

	attrName := AttrName(strings.ToLower(selectorName))
	attrVal, err := ifAddrs[0].Attr(attrName)
	return attrVal, err
}
1153762
func DiffAddr(newConfig []*net.IPNet, oldConfig []*net.IPNet) (toBeDeleted []*net.IPNet, toBeAdded []*net.IPNet) {
	var add []*net.IPNet
	var del []*net.IPNet
	//sort
	n := SortedIPs(newConfig)
	sort.Sort(&n)
	o := SortedIPs(oldConfig)
	sort.Sort(&o)

	//compare
	i := 0
	j := 0
	for i < len(n) && j < len(o) {
		if eqAddr(n[i], o[j]) {
			i++
			j++
		} else {
			if lessAdrr(n[i], o[j]) {
				add = append(add, n[i])
				i++
			} else {
				del = append(del, o[j])
				j++
			}
		}
	}

	for ; i < len(n); i++ {
		add = append(add, n[i])
	}

	for ; j < len(o); j++ {
		del = append(del, o[j])
	}
	return del, add
}
1372140
func MustParseAddr(a string) *NetAddr {
	addr, err := ParseAddr(a)
	if err != nil {
		panic(fmt.Sprintf("failed to parse %v: %v", a, err))
	}
	return addr
}
310303
func (ipv6 IPv6Addr) NetIPNet() *net.IPNet {
	ipv6net := &net.IPNet{}
	ipv6net.IP = make(net.IP, IPv6len)
	copy(ipv6net.IP, *ipv6.NetIP())
	ipv6net.Mask = *ipv6.NetIPMask()
	return ipv6net
}
1029448
func (a *RtAttr) AddRtAttr(attrType int, data []byte) *RtAttr {
	attr := NewRtAttr(attrType, data)
	a.children = append(a.children, attr)
	return attr
}
639192
func (r *URIBuilder) ServerAddr(s string) *URIBuilder {
	r.serverAddr = s
	return r
}
911789
func IpV6Address() string {
	var ip net.IP
	for i := 0; i < net.IPv6len; i++ {
		number := uint8(privateRand.Intn(255))
		ip = append(ip, number)
	}
	return ip.String()
}
819495
func (ipv4 IPv4Addr) NetIPNet() *net.IPNet {
	ipv4net := &net.IPNet{}
	ipv4net.IP = make(net.IP, IPv4len)
	binary.BigEndian.PutUint32(ipv4net.IP, uint32(ipv4.NetworkAddress()))
	ipv4net.Mask = *ipv4.NetIPMask()
	return ipv4net
}
1282739
func parseAddr(addr string) ([]net.IP, []string, error) {
	host, _, err := net.SplitHostPort(addr)
	if err != nil {
		return nil, nil, err
	}
	var domains []string
	var ips []net.IP
	ip := net.ParseIP(host)
	if ip != nil {
		ips = []net.IP{ip}
	} else {
		domains = []string{host}
	}
	return ips, domains, nil
}
721094
func SetIPv6NodeRange(net *net.IPNet) error {
	if ones, _ := net.Mask.Size(); ones != defaults.IPv6NodePrefixLen {
		return fmt.Errorf("prefix length must be /%d", defaults.IPv6NodePrefixLen)
	}

	copy := *net
	ipv6AllocRange = cidr.NewCIDR(&copy)

	return nil
}
112914
func (h *Host) IPv6Printable() string {
	if h.IPv6Addr == nil {
		return "<not configured>"
	}
	return h.IPv6Net().String()
}
28211
func (c *ConsulBackend) DetectHostAddr() (string, error) {
	agent := c.client.Agent()
	self, err := agent.Self()
	if err != nil {
		return "", err
	}
	addr, ok := self["Member"]["Addr"].(string)
	if !ok {
		return "", fmt.Errorf("unable to convert an address to string")
	}
	return addr, nil
}
494543
func (k *Kademlia) EachAddr(base []byte, o int, f func(*BzzAddr, int) bool) {
	k.lock.RLock()
	defer k.lock.RUnlock()
	k.eachAddr(base, o, f)
}
132430
func (ipv6 IPv6Addr) NetIPMask() *net.IPMask {
	ipv6Mask := make(net.IPMask, IPv6len)
	m := big.Int(*ipv6.Mask)
	copy(ipv6Mask, m.Bytes())
	return &ipv6Mask
}
1346079
func firstGlobalV6Addr(intf string, preferredIP net.IP) (net.IP, error) {
	return firstGlobalAddr(intf, preferredIP, netlink.FAMILY_V6)
}