diff --git a/trace/icmp_ipv4.go b/trace/icmp_ipv4.go index 7e1b86e..6e9a44a 100644 --- a/trace/icmp_ipv4.go +++ b/trace/icmp_ipv4.go @@ -164,6 +164,9 @@ func (t *ICMPTracer) listenICMP() { t.handleICMPMessage(msg, 0, rm.Body.(*icmp.TimeExceeded).Data, int(ttl)) case ipv4.ICMPTypeEchoReply: t.handleICMPMessage(msg, 1, rm.Body.(*icmp.Echo).Data, int(ttl)) + //unreachable + case ipv4.ICMPTypeDestinationUnreachable: + t.handleICMPMessage(msg, 2, rm.Body.(*icmp.DstUnreach).Data, int(ttl)) default: // log.Println("received icmp message of unknown type", rm.Type) } @@ -176,6 +179,12 @@ func (t *ICMPTracer) listenICMP() { } func (t *ICMPTracer) handleICMPMessage(msg ReceivedMessage, icmpType int8, data []byte, ttl int) { + if icmpType == 2 { + if t.DestIP.String() != msg.Peer.String() { + return + } + } + t.inflightRequestRWLock.RLock() defer t.inflightRequestRWLock.RUnlock() diff --git a/trace/icmp_ipv6.go b/trace/icmp_ipv6.go index 82cac1e..b0a5ea4 100644 --- a/trace/icmp_ipv6.go +++ b/trace/icmp_ipv6.go @@ -189,6 +189,8 @@ func (t *ICMPTracerv6) listenICMP() { t.handleICMPMessage(msg, 0, rm.Body.(*icmp.TimeExceeded).Data, int(ttl)) case ipv6.ICMPTypeEchoReply: t.handleICMPMessage(msg, 1, rm.Body.(*icmp.Echo).Data, int(ttl)) + case ipv6.ICMPTypeDestinationUnreachable: + t.handleICMPMessage(msg, 2, rm.Body.(*icmp.DstUnreach).Data, int(ttl)) default: // log.Println("received icmp message of unknown type", rm.Type) } @@ -232,6 +234,11 @@ func (t *ICMPTracerv6) listenICMP() { } func (t *ICMPTracerv6) handleICMPMessage(msg ReceivedMessage, icmpType int8, data []byte, ttl int) { + if icmpType == 2 { + if t.DestIP.String() != msg.Peer.String() { + return + } + } t.inflightRequestRWLock.RLock() defer t.inflightRequestRWLock.RUnlock()