diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-09-30 18:42:40 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-10-01 11:23:39 +0900 |
commit | 4081c33b46a72a1a61651a9d0463a2ed85a82bbe (patch) | |
tree | 7646f65fe2fee1341a4caac1565664a5a5a830d1 /table | |
parent | 38d80240654acf7e6b41077b00ef4c8288d93e46 (diff) |
path: distinguish aspath set from aspath seq
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r-- | table/path.go | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/table/path.go b/table/path.go index 08e037ae..8997af67 100644 --- a/table/path.go +++ b/table/path.go @@ -330,31 +330,34 @@ func (path *Path) GetAsPathLen() int { } func (path *Path) GetAsString() string { - r := "" + s := bytes.NewBuffer(make([]byte, 0, 64)) if _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH); attr != nil { aspath := attr.(*bgp.PathAttributeAsPath) for i, paramIf := range aspath.Value { segment := paramIf.(*bgp.As4PathParam) if i != 0 { - r += " " + s.WriteString(" ") } sep := " " switch segment.Type { case bgp.BGP_ASPATH_ATTR_TYPE_SET, bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SET: + s.WriteString("{") sep = "," - case bgp.BGP_ASPATH_ATTR_TYPE_SEQ, bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SEQ: - sep = " " } for j, as := range segment.AS { - r += fmt.Sprintf("%d", as) + s.WriteString(fmt.Sprintf("%d", as)) if j != len(segment.AS)-1 { - r += sep + s.WriteString(sep) } } + switch segment.Type { + case bgp.BGP_ASPATH_ATTR_TYPE_SET, bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SET: + s.WriteString("}") + } } } - return r + return s.String() } func (path *Path) GetAsList() []uint32 { |