diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-09 22:20:21 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-09 22:20:21 +0900 |
commit | 4e7ace6ade12150daddc7f1af97df614d6cbead6 (patch) | |
tree | 9b4428360f620b4e385a4465468889a2c40393a0 /table/path.go | |
parent | 26d21f00ac00461abd75453a4931b38d51a34703 (diff) |
policy: make AS Path match regular expression work as quagga and cisco
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/path.go')
-rw-r--r-- | table/path.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/table/path.go b/table/path.go index 224cda9d..b3a84d9d 100644 --- a/table/path.go +++ b/table/path.go @@ -297,6 +297,34 @@ func (path *Path) GetAsPathLen() int { return length } +func (path *Path) GetAsString() string { + r := "" + 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 += " " + } + + sep := " " + switch segment.Type { + case bgp.BGP_ASPATH_ATTR_TYPE_SET, bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SET: + 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) + if j != len(segment.AS)-1 { + r += sep + } + } + } + } + return r +} + func (path *Path) GetAsList() []uint32 { return path.getAsListofSpecificType(true, true) |