diff options
Diffstat (limited to 'packet')
-rw-r--r-- | packet/bgp.go | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/packet/bgp.go b/packet/bgp.go index 2d84d6a3..505212b4 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -1892,12 +1892,12 @@ func parseExtended(data []byte) ExtendedCommunityInterface { return e case 3: e := &OpaqueExtended{} - e.Value = data[2:8] + e.Value = data[1:8] return e } e := &UnknownExtended{} - e.Type = BGPAttrType(data[1]) - e.Value = data[2:8] + e.Type = BGPAttrType(data[0]) + e.Value = data[1:8] return e } @@ -1913,6 +1913,19 @@ func (p *PathAttributeExtendedCommunities) DecodeFromBytes(data []byte) error { return nil } +func (p *PathAttributeExtendedCommunities) Serialize() ([]byte, error) { + buf := make([]byte, 0) + for _, p := range p.Value { + ebuf, err := p.Serialize() + if err != nil { + return nil, err + } + buf = append(buf, ebuf...) + } + p.PathAttribute.Value = buf + return p.PathAttribute.Serialize() +} + func NewPathAttributeExtendedCommunities(value []ExtendedCommunityInterface) *PathAttributeExtendedCommunities { return &PathAttributeExtendedCommunities{ PathAttribute: PathAttribute{ |