mirror of
https://github.com/go-ping/ping.git
synced 2025-05-05 14:06:26 +00:00
* 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>
25 lines
435 B
Go
25 lines
435 B
Go
// +build windows
|
|
|
|
package ping
|
|
|
|
import (
|
|
"golang.org/x/net/ipv4"
|
|
"golang.org/x/net/ipv6"
|
|
)
|
|
|
|
// Returns the length of an ICMP message, plus the IP packet header.
|
|
func (p *Pinger) getMessageLength() int {
|
|
if p.ipv4 {
|
|
return p.Size + 8 + ipv4.HeaderLen
|
|
}
|
|
return p.Size + 8 + ipv6.HeaderLen
|
|
}
|
|
|
|
// Attempts to match the ID of an ICMP packet.
|
|
func (p *Pinger) matchID(ID int) bool {
|
|
if ID != p.id {
|
|
return false
|
|
}
|
|
return true
|
|
}
|