From 9d0b9e842d3660bdb58368bb6ba193620ef599c5 Mon Sep 17 00:00:00 2001 From: Daniel Czerwonk <daniel@dan-nrw.de> Date: Wed, 18 Jul 2018 21:49:02 +0200 Subject: [PATCH] mini improvement --- protocols/bgp/packet/path_attributes.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/protocols/bgp/packet/path_attributes.go b/protocols/bgp/packet/path_attributes.go index 819fc7b9..3f2f48e0 100644 --- a/protocols/bgp/packet/path_attributes.go +++ b/protocols/bgp/packet/path_attributes.go @@ -499,17 +499,17 @@ func (pa *PathAttribute) serializeASPath(buf *bytes.Buffer, opt *EncodeOptions) buf.WriteByte(attrFlags) buf.WriteByte(ASPathAttr) + asnLength := uint8(2) + if opt.Use32BitASN { + asnLength = 4 + } + length := uint8(0) segmentsBuf := bytes.NewBuffer(nil) for _, segment := range pa.Value.(types.ASPath) { segmentsBuf.WriteByte(segment.Type) segmentsBuf.WriteByte(uint8(len(segment.ASNs))) - asnLength := uint8(2) - if opt.Use32BitASN { - asnLength = 4 - } - for _, asn := range segment.ASNs { if opt.Use32BitASN { segmentsBuf.Write(convert.Uint32Byte(asn)) -- GitLab