summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-09 10:34:55 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-09 10:34:55 +0900
commit0ad83ce995ab8c87c2f68aa4d52a22e1a232ab1d (patch)
tree0daa8675a6b765ab3c92da0b18426d561dbc0578 /packet/bgp.go
parent4142dda9988d69a9e6c3d3ac098442a9309f0c67 (diff)
packet: fix extendedcommunities Serialize()
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'packet/bgp.go')
-rw-r--r--packet/bgp.go19
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{