From 4081c33b46a72a1a61651a9d0463a2ed85a82bbe Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Wed, 30 Sep 2015 18:42:40 +0900 Subject: path: distinguish aspath set from aspath seq Signed-off-by: ISHIDA Wataru --- table/path.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'table/path.go') 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 { -- cgit v1.2.3