diff --git a/process/proc/gather.go b/process/proc/gather.go index 30f3c053..a912b958 100644 --- a/process/proc/gather.go +++ b/process/proc/gather.go @@ -5,6 +5,7 @@ import ( "time" ) +// PID querying return codes const ( Success uint8 = iota NoSocket @@ -48,7 +49,7 @@ func GetPidOfConnection(localIP net.IP, localPort uint16, protocol uint8) (pid i return } -// GetPidOfConnection returns the PID of the given incoming connection. +// GetPidOfIncomingConnection returns the PID of the given incoming connection. func GetPidOfIncomingConnection(localIP net.IP, localPort uint16, protocol uint8) (pid int, status uint8) { uid, inode, ok := getListeningSocket(localIP, localPort, protocol) if !ok { diff --git a/process/proc/get.go b/process/proc/get.go index 174ec823..1fe68940 100644 --- a/process/proc/get.go +++ b/process/proc/get.go @@ -5,18 +5,22 @@ import ( "net" ) +// GetTCP4PacketInfo searches the network state tables for a TCP4 connection func GetTCP4PacketInfo(localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, pktDirection bool) (pid int, direction bool, err error) { return search(TCP4, localIP, localPort, pktDirection) } +// GetTCP6PacketInfo searches the network state tables for a TCP6 connection func GetTCP6PacketInfo(localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, pktDirection bool) (pid int, direction bool, err error) { return search(TCP6, localIP, localPort, pktDirection) } +// GetUDP4PacketInfo searches the network state tables for a UDP4 connection func GetUDP4PacketInfo(localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, pktDirection bool) (pid int, direction bool, err error) { return search(UDP4, localIP, localPort, pktDirection) } +// GetUDP6PacketInfo searches the network state tables for a UDP6 connection func GetUDP6PacketInfo(localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, pktDirection bool) (pid int, direction bool, err error) { return search(UDP6, localIP, localPort, pktDirection) } diff --git a/process/proc/processfinder.go b/process/proc/processfinder.go index 4a3647ee..2daa324e 100644 --- a/process/proc/processfinder.go +++ b/process/proc/processfinder.go @@ -16,6 +16,7 @@ var ( pidsByUser = make(map[int][]int) ) +// GetPidOfInode returns the pid of the given uid and socket inode. func GetPidOfInode(uid, inode int) (int, bool) { pidsByUserLock.Lock() defer pidsByUserLock.Unlock() diff --git a/process/proc/sockets.go b/process/proc/sockets.go index 036f5c4d..38700a40 100644 --- a/process/proc/sockets.go +++ b/process/proc/sockets.go @@ -32,6 +32,7 @@ Cache every step! */ +// Network Related Constants const ( TCP4 uint8 = iota UDP4 @@ -211,7 +212,7 @@ func convertIPv4(data string) net.IP { return nil } if len(decoded) != 4 { - log.Warningf("process: decoded IPv4 %s has wrong length") + log.Warningf("process: decoded IPv4 %s has wrong length", decoded) return nil } ip := net.IPv4(decoded[3], decoded[2], decoded[1], decoded[0]) @@ -225,7 +226,7 @@ func convertIPv6(data string) net.IP { return nil } if len(decoded) != 16 { - log.Warningf("process: decoded IPv6 %s has wrong length") + log.Warningf("process: decoded IPv6 %s has wrong length", decoded) return nil } ip := net.IP(decoded)