summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp/bgp.go
diff options
context:
space:
mode:
authorJeff Bean <bean@uber.com>2018-06-22 19:41:59 -0700
committerJeff Bean <bean@uber.com>2018-06-22 19:41:59 -0700
commitfb034c3aba46e318fcbd748cef02796a05305aa2 (patch)
tree5fb3b56a723dac39a28589d941caad123a1f4f7e /packet/bgp/bgp.go
parent154650594c5b40b2905eb73b90f52de72f6ced16 (diff)
fixing some typos and found one conversion bug
Diffstat (limited to 'packet/bgp/bgp.go')
-rw-r--r--packet/bgp/bgp.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/packet/bgp/bgp.go b/packet/bgp/bgp.go
index b882f9a6..145f7d99 100644
--- a/packet/bgp/bgp.go
+++ b/packet/bgp/bgp.go
@@ -1573,7 +1573,7 @@ func (l *MPLSLabelStack) DecodeFromBytes(data []byte) error {
}
}
- if foundBottom {
+ if !foundBottom {
l.Labels = []uint32{}
return nil
}
@@ -1850,13 +1850,13 @@ func (l *LabeledIPAddrPrefix) DecodeFromBytes(data []byte, options ...*Marshalli
l.Length = uint8(data[0])
data = data[1:]
l.Labels.DecodeFromBytes(data)
+
if int(l.Length)-8*(l.Labels.Len()) < 0 {
l.Labels.Labels = []uint32{}
}
restbits := int(l.Length) - 8*(l.Labels.Len())
data = data[l.Labels.Len():]
- l.decodePrefix(data, uint8(restbits), l.addrlen)
- return nil
+ return l.decodePrefix(data, uint8(restbits), l.addrlen)
}
func (l *LabeledIPAddrPrefix) Serialize(options ...*MarshallingOption) ([]byte, error) {
@@ -9258,10 +9258,12 @@ func (msg *BGPHeader) DecodeFromBytes(data []byte, options ...*MarshallingOption
if uint16(len(data)) < BGP_HEADER_LENGTH {
return NewMessageError(BGP_ERROR_MESSAGE_HEADER_ERROR, BGP_ERROR_SUB_BAD_MESSAGE_LENGTH, nil, "not all BGP message header")
}
+
msg.Len = binary.BigEndian.Uint16(data[16:18])
if int(msg.Len) < BGP_HEADER_LENGTH {
return NewMessageError(BGP_ERROR_MESSAGE_HEADER_ERROR, BGP_ERROR_SUB_BAD_MESSAGE_LENGTH, nil, "unknown message type")
}
+
msg.Type = data[18]
return nil
}