scroot / gopacket

Automatically exported from code.google.com/p/gopacket
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

MPLS stacking #25

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
While decoding MPLS, if StackBottom was false, the next payload will be MPLS.

diff --git a/layers/mpls.go b/layers/mpls.go
index 61f4bbb..d0a3d33 100644
--- a/layers/mpls.go
+++ b/layers/mpls.go
@@ -54,14 +54,19 @@ var MPLSPayloadDecoder gopacket.Decoder = 
ProtocolGuessingDecoder{}

 func decodeMPLS(data []byte, p gopacket.PacketBuilder) error {
        decoded := binary.BigEndian.Uint32(data[:4])
-       p.AddLayer(&MPLS{
+       mpls := MPLS{
                Label:        decoded >> 12,
                TrafficClass: uint8(decoded>>9) & 0x7,
                StackBottom:  decoded&0x100 != 0,
                TTL:          uint8(decoded),
                BaseLayer:    BaseLayer{data[:4], data[4:]},
-       })
-       return p.NextDecoder(MPLSPayloadDecoder)
+       }
+       p.AddLayer(&mpls)
+       if mpls.StackBottom {
+               return p.NextDecoder(MPLSPayloadDecoder)
+       } else {
+               return p.NextDecoder(gopacket.DecodeFunc(decodeMPLS))
+       }
 }

 // SerializeTo writes the serialized form of this layer into the

Original issue reported on code.google.com by Hiroaki.Kawai@gmail.com on 18 Jul 2014 at 2:38

GoogleCodeExporter commented 9 years ago
Hey, sorry for the slow response on this... I was on vacation for the last 2 
weeks.

This will be rolled out to master today.

Original comment by gconnell@google.com on 28 Jul 2014 at 3:07