From 36f6d32ff224d887c8d06ba0386a00eb9a542b6e Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Thu, 27 Aug 2015 00:08:51 +0900 Subject: packet: fix returning wrong OpaqueExtended subtype Signed-off-by: ISHIDA Wataru --- packet/bgp.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packet/bgp.go b/packet/bgp.go index d1c77303..ebf9d068 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -4073,15 +4073,16 @@ func (e *EncapExtended) String() string { type OpaqueExtended struct { IsTransitive bool Value OpaqueExtendedValueInterface + SubType ExtendedCommunityAttrSubType } func (e *OpaqueExtended) DecodeFromBytes(data []byte) error { if len(data) != 7 { return fmt.Errorf("Invalid OpaqueExtended bytes len: %d", len(data)) } - subType := ExtendedCommunityAttrSubType(data[0]) + e.SubType = ExtendedCommunityAttrSubType(data[0]) - switch subType { + switch e.SubType { case EC_SUBTYPE_COLOR: v := binary.BigEndian.Uint32(data[3:7]) e.Value = &ColorExtended{ @@ -4137,7 +4138,7 @@ func (e *OpaqueExtended) GetTypes() (ExtendedCommunityAttrType, ExtendedCommunit if !e.IsTransitive { t = EC_TYPE_NON_TRANSITIVE_OPAQUE } - return t, ExtendedCommunityAttrSubType(0xFF) + return t, e.SubType } func NewOpaqueExtended(isTransitive bool) *OpaqueExtended { -- cgit v1.2.3