diff --git a/ping.go b/ping.go index 84637e3..a5cfc7d 100644 --- a/ping.go +++ b/ping.go @@ -232,6 +232,9 @@ type Packet struct { // TTL is the Time To Live on the packet. Ttl int + + // ID is the ICMP identifier. + ID int } // Statistics represent the stats of a currently running or finished @@ -385,6 +388,16 @@ func (p *Pinger) SetLogger(logger Logger) { p.logger = logger } +// SetID sets the ICMP identifier. +func (p *Pinger) SetID(id int) { + p.id = id +} + +// ID returns the ICMP identifier. +func (p *Pinger) ID() int { + return p.id +} + // Run runs the pinger. This is a blocking function that will exit when it's // done. If Count or Interval are not specified, it will run continuously until // it is interrupted. @@ -641,6 +654,7 @@ func (p *Pinger) processPacket(recv *packet) error { IPAddr: p.ipaddr, Addr: p.addr, Ttl: recv.ttl, + ID: p.id, } switch pkt := m.Body.(type) {