diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-13 16:16:15 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-13 18:12:59 +0900 |
commit | af0c03bbec611fca01374eb47da6b8524023b78f (patch) | |
tree | 24350b79a5e56d0423c76bda47000568b0ac419c /table/path.go | |
parent | 69aceacaecde3adda0ed9627ecbff3922225433d (diff) |
policy: support adding extCommunity action
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/path.go')
-rw-r--r-- | table/path.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/table/path.go b/table/path.go index 8025a63a..7e131185 100644 --- a/table/path.go +++ b/table/path.go @@ -514,6 +514,25 @@ func (path *Path) GetExtCommunities() []bgp.ExtendedCommunityInterface { return eCommunityList } +func (path *Path) SetExtCommunities(values []byte, doReplace bool) { + exts := []bgp.ExtendedCommunityInterface{} + for len(values) >= 8 { + e := &bgp.UnknownExtended{ + Type: bgp.BGPAttrType(values[0]), + Value: values[1:8], + } + exts = append(exts, e) + values = values[8:] + } + _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_EXTENDED_COMMUNITIES) + if attr != nil { + l := attr.(*bgp.PathAttributeExtendedCommunities).Value + l = append(l, exts...) + } else { + path.pathAttrs = append(path.pathAttrs, bgp.NewPathAttributeExtendedCommunities(exts)) + } +} + func (path *Path) GetMed() (uint32, error) { _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC) if attr == nil { |