// IsSubnetRouterAnycast reports whether p is an IPv6 subnet router
// anycast address.
501683
func (p *Position) IsSubnetRouterAnycast() bool {
	return !p.IP.IsUnspecified() && !p.IP.IsLoopback() && !p.IP.IsMulticast() && p.IP.To16() != nil && p.IP.To4() == nil && p.IP.Equal(p.Prefix.IP)
}
1144108
func (r *ChannelRouter) IsPublicNode(node route.Vertex) (bool, error) {
	return r.cfg.Graph.IsPublicNode(node)
}
1327932
func (a *IPAllocator) RegisterSubnet(network *net.IPNet, subnet *net.IPNet) error {
	a.mutex.Lock()
	defer a.mutex.Unlock()

	key := network.String()
	if _, ok := a.allocatedIPs[key]; ok {
		return ErrNetworkAlreadyRegistered
	}
	n := newAllocatedMap(network)
	beginIP, endIP := NetworkRange(subnet)
	begin := big.NewInt(0).Add(ipToBigInt(beginIP), big.NewInt(1))
	end := big.NewInt(0).Sub(ipToBigInt(endIP), big.NewInt(1))

	// Check that subnet is within network
	if !(begin.Cmp(n.begin) >= 0 && end.Cmp(n.end) <= 0 && begin.Cmp(end) == -1) {
		return ErrBadSubnet
	}
	n.begin.Set(begin)
	n.end.Set(end)
	n.last.Sub(begin, big.NewInt(1))
	a.allocatedIPs[key] = n
	return nil
}
210892
func IsIPUnspecified(m ma.Multiaddr) bool {
	m = zoneless(m)
	if m == nil {
		return false
	}
	c, _ := ma.SplitFirst(m)
	return net.IP(c.RawValue()).IsUnspecified()
}
173082
func isUDPAddrResolvable(fl FieldLevel) bool {

	if !isIP4Addr(fl) && !isIP6Addr(fl) {
		return false
	}

	_, err := net.ResolveUDPAddr("udp", fl.Field().String())

	return err == nil
}
1319081
func isIP4AddrResolvable(fl FieldLevel) bool {

	if !isIPv4(fl) {
		return false
	}

	_, err := net.ResolveIPAddr("ip4", fl.Field().String())

	return err == nil
}
249736
func (n *switchingNetworking) Subnets(instId instance.Id, subnetIds []network.Id) ([]network.SubnetInfo, error) {
	if err := n.initNetworking(); err != nil {
		return nil, errors.Trace(err)
	}
	return n.networking.Subnets(instId, subnetIds)
}
980022
func IsIPv6(addr string) (bool, error) {
	ip := net.ParseIP(addr)
	if ip == nil {
		return false, fmt.Errorf("invalid IP address: %q", addr)
	}
	return ip.To4() == nil, nil
}
1268938
func (v *VPCRouter) HasPortForwarding() bool {
	return v.HasSetting() && v.Settings.Router.HasPortForwarding()
}
721270
func (p *Position) IsBroadcast() bool {
	return !p.IP.IsUnspecified() && !p.IP.IsMulticast() && p.IP.To4() != nil && (p.IP.Equal(net.IPv4bcast) || p.IP.Equal(p.Prefix.Last()))
}
835696
func IsOverlappingSubnetv6(inputIPv6Subnet string, existingIPv6Subnet string) bool {
	inputIPv6StartRange, inputIPv6EndRange := getIPv6Range(inputIPv6Subnet)
	existingIPv6StartRange, existingIPv6EndRange := getIPv6Range(existingIPv6Subnet)

	inputStartRange := ipv6ToBigint(inputIPv6StartRange)
	inputEndRange := ipv6ToBigint(inputIPv6EndRange)

	existingStartRange := ipv6ToBigint(existingIPv6StartRange)
	existingEndRange := ipv6ToBigint(existingIPv6EndRange)

	if (existingStartRange.Cmp(inputStartRange) <= 0 && inputStartRange.Cmp(existingEndRange) <= 0) ||
		(existingStartRange.Cmp(inputEndRange) <= 0 && inputEndRange.Cmp(existingEndRange) <= 0) {
		return true
	}

	if (inputStartRange.Cmp(existingStartRange) <= 0 && existingStartRange.Cmp(inputEndRange) <= 0) ||
		(inputStartRange.Cmp(existingEndRange) <= 0 && existingEndRange.Cmp(inputEndRange) <= 0) {
		return true
	}
	return false
}
280448
func ListenAndServeIfUnicast(interfaceName string, handler Handler, jobs chan job, ip net.IP, ctx context.Context) error {
	iface, err := net.InterfaceByName(interfaceName)
	if err != nil {
		return err
	}

	p, err := UnicastOpen(ip, 67, interfaceName)
	if err != nil {
		return err
	}
	defer p.Close()

	return ServeIf(iface.Index, p, handler, jobs, ctx)
}
930498
func routeDefaultIPv4() (net.IP, error) {
	out, err := ipRunAFOutput(seesaw.IPv4, "route show default")
	if err != nil {
		return nil, err
	}
	if dr := routeDefaultIPv4Regexp.FindStringSubmatch(out); dr != nil {
		return net.ParseIP(dr[1]).To4(), nil
	}
	return nil, fmt.Errorf("Default route not found")
}
490370
func (r *Router) Subrouter(path string) *Router {
	sr := &Router{
		index:  make(map[string]string),
		prefix: r.subPath(path),
		router: r.router,
	}

	// Init relationships
	r.children = append(r.children, sr)
	sr.parent = r

	return sr
}
630616
func IsSubnet16(value string) error {
	parts := strings.Split(value, ".")
	if len(parts) != 2 {
		return NewViolation(fmt.Sprintf("invalid /16 subnet %s", value))
	}

	ip := fmt.Sprintf("%s.1.1", value)
	if nil == net.ParseIP(ip) {
		return NewViolation(fmt.Sprintf("invalid /16 subnet %s", value))
	}
	return nil
}
1040751
func (n *network) getSubnetforIPv6(ip *net.IPNet) *ipv6Subnet {
	for _, s := range n.config.Ipv6Subnets {
		_, snet, err := net.ParseCIDR(s.SubnetIP)
		if err != nil {
			return nil
		}
		// first check if the mask lengths are the same
		i, _ := snet.Mask.Size()
		j, _ := ip.Mask.Size()
		if i != j {
			continue
		}
		if snet.Contains(ip.IP) {
			return s
		}
	}

	return nil
}
186228
func IsRFC(rfcNum uint, sa SockAddr) bool {
	rfcNetMap := KnownRFCs()
	rfcNets, ok := rfcNetMap[rfcNum]
	if !ok {
		return false
	}

	var contained bool
	for _, rfcNet := range rfcNets {
		if rfcNet.Contains(sa) {
			contained = true
			break
		}
	}
	return contained
}