From 2113264336fd85515499ba053ac891e4d9ffe352 Mon Sep 17 00:00:00 2001 From: tsosunchia <59512455+tsosunchia@users.noreply.github.com> Date: Thu, 5 Oct 2023 07:25:05 +0800 Subject: [PATCH] ipv6 mpls support --- trace/icmp_ipv4.go | 4 ++-- trace/icmp_ipv6.go | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/trace/icmp_ipv4.go b/trace/icmp_ipv4.go index 6401df1..7f6cc6e 100644 --- a/trace/icmp_ipv4.go +++ b/trace/icmp_ipv4.go @@ -176,7 +176,7 @@ func (t *ICMPTracer) handleICMPMessage(msg ReceivedMessage, icmpType int8, data t.inflightRequestRWLock.RLock() defer t.inflightRequestRWLock.RUnlock() - mpls := t.extractMPLS(msg, data) + mpls := extractMPLS(msg, data) if _, ok := t.inflightRequest[ttl]; ok { t.inflightRequest[ttl] <- Hop{ Success: true, @@ -186,7 +186,7 @@ func (t *ICMPTracer) handleICMPMessage(msg ReceivedMessage, icmpType int8, data } } -func (t *ICMPTracer) extractMPLS(msg ReceivedMessage, data []byte) string { +func extractMPLS(msg ReceivedMessage, data []byte) string { extensionOffset := 20 + 8 + 52 if len(data) <= extensionOffset { diff --git a/trace/icmp_ipv6.go b/trace/icmp_ipv6.go index 2f0ffe7..b545d31 100644 --- a/trace/icmp_ipv6.go +++ b/trace/icmp_ipv6.go @@ -233,10 +233,13 @@ func (t *ICMPTracerv6) listenICMP() { func (t *ICMPTracerv6) handleICMPMessage(msg ReceivedMessage, icmpType int8, data []byte, ttl int) { t.inflightRequestRWLock.RLock() defer t.inflightRequestRWLock.RUnlock() + + mpls := extractMPLS(msg, data) if _, ok := t.inflightRequest[ttl]; ok { t.inflightRequest[ttl] <- Hop{ Success: true, Address: msg.Peer, + MPLS: mpls, } } }