diff options
Diffstat (limited to 'table')
-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 { |