byte calculation
This commit is contained in:
parent
d4ef97c0c2
commit
f9bf8fa6b1
@ -18,11 +18,17 @@ const timeoutTCPHosts = time.Duration(1) * time.Second
|
|||||||
|
|
||||||
func nextIP(ip net.IP) (next net.IP) {
|
func nextIP(ip net.IP) (next net.IP) {
|
||||||
// FIXME Proper next IP address in network calculation
|
// FIXME Proper next IP address in network calculation
|
||||||
next = make([]byte, 4)
|
|
||||||
bytes := []byte(ip)
|
ip = ip.To4()
|
||||||
bytes = bytes[len(bytes)-4:]
|
o := (uint(ip[0]) << 24) + (uint(ip[1]) << 16) + (uint(ip[2]) << 8) + uint(ip[3])
|
||||||
next[0], next[1], next[2], next[3] = bytes[0], bytes[1], bytes[2], bytes[3]+1
|
o++
|
||||||
return
|
o3 := byte(o & 0xFF)
|
||||||
|
o2 := byte((o >> 8) & 0xFF)
|
||||||
|
o1 := byte((o >> 16) & 0xFF)
|
||||||
|
o0 := byte((o >> 24) & 0xFF)
|
||||||
|
|
||||||
|
return net.IPv4(o0, o1, o2, o3)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvailableNetworks returns all IPv4 networks that are available to the host
|
// AvailableNetworks returns all IPv4 networks that are available to the host
|
||||||
|
Loading…
Reference in New Issue
Block a user