diff options
author | Wataru Ishida <ishida.wataru@lab.ntt.co.jp> | 2016-10-06 05:38:00 +0000 |
---|---|---|
committer | Wataru Ishida <ishida.wataru@lab.ntt.co.jp> | 2016-10-10 05:18:17 +0000 |
commit | d46da74d4fba3fe169d0c4f05b0e657ec95f5336 (patch) | |
tree | 94b962ebdf526bc4f84e5aef5ce18707dbfd933f /table/path.go | |
parent | 2cd0de0139cb47edac0c418f4efd4e5c6d185f63 (diff) |
policy: support large-community match/action
close #1133
Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/path.go')
-rw-r--r-- | table/path.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/table/path.go b/table/path.go index f8058730..81d76ddf 100644 --- a/table/path.go +++ b/table/path.go @@ -762,6 +762,28 @@ func (path *Path) SetExtCommunities(exts []bgp.ExtendedCommunityInterface, doRep } } +func (path *Path) GetLargeCommunities() []*bgp.LargeCommunity { + if a := path.getPathAttr(bgp.BGP_ATTR_TYPE_LARGE_COMMUNITY); a != nil { + v := a.(*bgp.PathAttributeLargeCommunities).Values + ret := make([]*bgp.LargeCommunity, 0, len(v)) + for _, c := range v { + ret = append(ret, c) + } + return ret + } + return nil +} + +func (path *Path) SetLargeCommunities(cs []*bgp.LargeCommunity, doReplace bool) { + a := path.getPathAttr(bgp.BGP_ATTR_TYPE_LARGE_COMMUNITY) + if a == nil || doReplace { + path.setPathAttr(bgp.NewPathAttributeLargeCommunities(cs)) + } else { + l := a.(*bgp.PathAttributeLargeCommunities).Values + path.setPathAttr(bgp.NewPathAttributeLargeCommunities(append(l, cs...))) + } +} + func (path *Path) GetMed() (uint32, error) { attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC) if attr == nil { |