1
0
mirror of https://github.com/go-ping/ping.git synced 2025-05-02 20:46:28 +00:00
ping/utils_linux.go
Jean Raby 5f9dd908cc
Fix packet matching; compute statistics as packets are received ()
* Fix unprivileged packet matching on Linux
* Compute statistics on-the-fly as packets are received

Signed-off-by: Jean Raby <jean@raby.sh>
Signed-off-by: Charlie Jonas <charlie@charliejonas.co.uk>
Co-authored-by: Charlie Jonas <charlie@charliejonas.co.uk>
2021-03-11 22:01:31 +00:00

20 lines
363 B
Go

// +build linux
package ping
// Returns the length of an ICMP message.
func (p *Pinger) getMessageLength() int {
return p.Size + 8
}
// Attempts to match the ID of an ICMP packet.
func (p *Pinger) matchID(ID int) bool {
// On Linux we can only match ID if we are privileged.
if p.protocol == "icmp" {
if ID != p.id {
return false
}
}
return true
}