MCPcopy
hub / github.com/evilsocket/opensnitch / hexToIP

Function hexToIP

daemon/netstat/parse.go:66–81  ·  view source on GitHub ↗
(h string)

Source from the content-addressed store, hash-verified

64}
65
66func hexToIP(h string) net.IP {
67 n, m := hexToInt2(h)
68 var ip net.IP
69 if m != 0 {
70 ip = make(net.IP, 16)
71 // TODO: Check if this depends on machine endianness?
72 binary.LittleEndian.PutUint32(ip, uint32(n>>32))
73 binary.LittleEndian.PutUint32(ip[4:], uint32(n))
74 binary.LittleEndian.PutUint32(ip[8:], uint32(m>>32))
75 binary.LittleEndian.PutUint32(ip[12:], uint32(m))
76 } else {
77 ip = make(net.IP, 4)
78 binary.LittleEndian.PutUint32(ip, uint32(n))
79 }
80 return ip
81}
82
83// Parse scans and retrieves the opened connections, from /proc/net/ files
84func Parse(proto string) ([]Entry, error) {

Callers 1

ParseFunction · 0.85

Calls 1

hexToInt2Function · 0.85

Tested by

no test coverage detected