summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp.go
diff options
context:
space:
mode:
authorHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2015-05-29 20:11:27 +0900
committerHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2015-06-01 18:02:20 +0900
commit007c0df5092df0be2e03df457dcfcb89c92080d6 (patch)
treeafe0db0f3637615df143081a46eac6e5141dfca2 /packet/bgp.go
parent7ea3a18ef5abffc3c1bb01366b0f7e274a42dcff (diff)
cli: fix AS_PATH string format
Diffstat (limited to 'packet/bgp.go')
-rw-r--r--packet/bgp.go29
1 files changed, 21 insertions, 8 deletions
diff --git a/packet/bgp.go b/packet/bgp.go
index a5175bca..533b0288 100644
--- a/packet/bgp.go
+++ b/packet/bgp.go
@@ -55,6 +55,8 @@ const (
const (
BGP_ASPATH_ATTR_TYPE_SET = 1
BGP_ASPATH_ATTR_TYPE_SEQ = 2
+ BGP_ASPATH_ATTR_TYPE_CONFED_SEQ = 3
+ BGP_ASPATH_ATTR_TYPE_CONFED_SET = 4
)
// RFC7153 5.1. Registries for the "Type" Field
@@ -2168,21 +2170,27 @@ func (p *PathAttributeAsPath) Serialize() ([]byte, error) {
}
func (p *PathAttributeAsPath) ToApiStruct() *api.PathAttr {
- aslist := make([]uint32, 0)
+ aspaths := make([]*api.AsPath, 0)
for _, a := range p.Value {
path, y := a.(*As4PathParam)
+ aspath := &api.AsPath{}
if y {
- aslist = append(aslist, path.AS...)
+ aspath.Asns = path.AS
+ aspath.SegmentType = uint32(path.Type)
} else {
path := a.(*AsPathParam)
+ asns := make([]uint32, 0)
for _, v := range path.AS {
- aslist = append(aslist, uint32(v))
+ asns = append(asns, uint32(v))
}
+ aspath.Asns = asns
+ aspath.SegmentType = uint32(path.Type)
}
+ aspaths = append(aspaths, aspath)
}
return &api.PathAttr{
Type: api.BGP_ATTR_TYPE_AS_PATH,
- AsPath: aslist,
+ AsPaths: aspaths,
}
}
@@ -3279,13 +3287,18 @@ func (p *PathAttributeAs4Path) Serialize() ([]byte, error) {
}
func (p *PathAttributeAs4Path) ToApiStruct() *api.PathAttr {
- aslist := make([]uint32, 0)
+ aspaths := make([]*api.AsPath, 0)
+ aspath := &api.AsPath{
+ SegmentType: uint32(p.Type),
+ Asns: make([]uint32, 0),
+ }
for _, a := range p.Value {
- aslist = append(aslist, a.AS...)
+ aspath.Asns = append(aspath.Asns, a.AS...)
}
+ aspaths = append(aspaths, aspath)
return &api.PathAttr{
- Type: api.BGP_ATTR_TYPE_AS4_PATH,
- AsPath: aslist,
+ Type: api.BGP_ATTR_TYPE_AS_PATH,
+ AsPaths: aspaths,
}
}