// DecimalToIPv4 converts a decimal to the dotted quad IP address format.
6199
func DecimalToIPv4(addr uint32) net.IP {
	bytes := make([]byte, 4)
	binary.BigEndian.PutUint32(bytes, addr)
	return net.IP(bytes)
}
1006350
func (r Network_Vlan) GetTotalPrimaryIpAddressCount() (resp uint, err error) {
	err = r.Session.DoRequest("SoftLayer_Network_Vlan", "getTotalPrimaryIpAddressCount", nil, &r.Options, &resp)
	return
}
1902
func (internet Internet) IPv6(v reflect.Value) (interface{}, error) {
	return internet.ipv6(), nil
}
1338576
func IPv4() string {
	size := 4
	ip := make([]byte, size)
	for i := 0; i < size; i++ {
		ip[i] = byte(r.Intn(256))
	}
	return net.IP(ip).To4().String()
}
11268
func includesIPv4(ips []net.IP) bool {
	for _, ip := range ips {
		if ip.To4() != nil {
			return true
		}
	}

	return false
}
280179
func (internet Internet) IPv4(v reflect.Value) (interface{}, error) {
	return internet.ipv4(), nil
}
1312143
func parseIPv4s(ips []string) ([]int64, error) {
	ipv4s := make([]int64, len(ips))
	for i, ip := range ips {
		ipv4, err := common.ParseIPv4(ip)
		if err != nil {
			return nil, status.Errorf(codes.InvalidArgument, "invalid IPv4 address %q", ip)
		}
		ipv4s[i] = int64(ipv4)
	}
	return ipv4s, nil
}
730862
func isIPv6(fl FieldLevel) bool {

	ip := net.ParseIP(fl.Field().String())

	return ip != nil && ip.To4() == nil
}
233630
func IP4ToInt(ip net.IP) uint32 {
	ip = ip.To4()
	if ip == nil {
		return 0
	}
	return binary.BigEndian.Uint32(ip)
}
1091351
func defaultIP(ips []net.IP) []net.IP {
	if len(ips) <= 1 {
		return ips
	}
	v6 := -1
	for i, ip := range ips {
		if ipLen := len(ip); ipLen == net.IPv4len {
			return ips[i : i+1]
		} else if v6 == -1 && ipLen == net.IPv6len {
			v6 = i
		}
	}
	if v6 == -1 {
		return nil // shouldn't ever happen
	}
	return ips[v6 : v6+1]
}
439847
func DefaultIP() string {
	addrs, err := netInterfaceAddrs()
	if err == nil {
		for _, addr := range addrs {
			if ip, ok := addr.(*net.IPNet); ok && !ip.IP.IsLoopback() {
				if ip.IP.To4() != nil {
					return ip.IP.String()
				}
			}
		}
	}

	return ""
}
535575
func DHCPIP4Option(tag byte, ips net.IP) (opt DHCPOption, err error) {
	ips = ips.To4()
	if ips == nil {
		err = errors.New("ip is not a valid IPv4 address")
		return
	}
	opt = DHCPNewOption(tag, []byte(ips))
	return
}
1106504
func (s *AssetAttributes) SetIpv4Addresses(v []*string) *AssetAttributes {
	s.Ipv4Addresses = v
	return s
}
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")
}
719192
func getIPVersion(config *networkConfiguration) ipVersion {
	ipVersion := ipv4
	if config.AddressIPv6 != nil || config.EnableIPv6 {
		ipVersion |= ipv6
	}
	return ipVersion
}
81850
func IsIPv4(str string) bool {
	ip := net.ParseIP(str)
	return ip != nil && strings.Contains(str, ".")
}
945282
func MyIp4() *net.IPAddr {
	myIp4Once.Do(func() {
		var err error
		myIp4, err = net.ResolveIPAddr("ip4", MyHostname())
		if err != nil {
			log.Fatal(err)
		}
	})
	return myIp4
}