Skip to content

Commit

Permalink
generic updates
Browse files Browse the repository at this point in the history
  • Loading branch information
PacketCrunch committed Dec 13, 2022
1 parent eece0c7 commit ce122d7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions netutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ type IfiStat struct {
Ifs [MaxSidx]uint64
}

// IsNetIPv4 - Check if net.IP is ipv4 address
func IsNetIPv4(address string) bool {
return strings.Count(address, ":") < 2
}

// IsNetIPv6 - Check if net.IP is ipv6 address
func IsNetIPv6(address string) bool {
return strings.Count(address, ":") >= 2
}

// Ntohl - Network to host byte-order long
func Ntohl(i uint32) uint32 {
return binary.BigEndian.Uint32((*(*[4]byte)(unsafe.Pointer(&i)))[:])
Expand Down

0 comments on commit ce122d7

Please sign in to comment.