(c oc.ExtCommunitySet)
| 1753 | } |
| 1754 | |
| 1755 | func NewExtCommunitySet(c oc.ExtCommunitySet) (*ExtCommunitySet, error) { |
| 1756 | name := c.ExtCommunitySetName |
| 1757 | if name == "" { |
| 1758 | if len(c.ExtCommunityList) == 0 { |
| 1759 | return nil, nil |
| 1760 | } |
| 1761 | return nil, fmt.Errorf("empty ext-community set name") |
| 1762 | } |
| 1763 | list := make([]*regexp.Regexp, 0, len(c.ExtCommunityList)) |
| 1764 | subtypeList := make([]bgp.ExtendedCommunityAttrSubType, 0, len(c.ExtCommunityList)) |
| 1765 | for _, x := range c.ExtCommunityList { |
| 1766 | subtype, exp, err := ParseExtCommunityRegexp(x) |
| 1767 | if err != nil { |
| 1768 | return nil, err |
| 1769 | } |
| 1770 | list = append(list, exp) |
| 1771 | subtypeList = append(subtypeList, subtype) |
| 1772 | } |
| 1773 | s := &ExtCommunitySet{ |
| 1774 | regExpSet: regExpSet{ |
| 1775 | typ: DEFINED_TYPE_EXT_COMMUNITY, |
| 1776 | name: name, |
| 1777 | list: list, |
| 1778 | }, |
| 1779 | subtypeList: subtypeList, |
| 1780 | } |
| 1781 | s.rebuildExtMatchers() |
| 1782 | return s, nil |
| 1783 | } |
| 1784 | |
| 1785 | func (s *ExtCommunitySet) Append(arg DefinedSet) error { |
| 1786 | if err := s.regExpSet.Append(arg); err != nil { |
searching dependent graphs…