From af0c03bbec611fca01374eb47da6b8524023b78f Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Thu, 13 Aug 2015 16:16:15 +0900 Subject: policy: support adding extCommunity action Signed-off-by: FUJITA Tomonori --- table/path.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'table/path.go') 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 { -- cgit v1.2.3