private @Nonnull CommunitySetExpr resolve(@Nonnull Environment environment) { return requireNonNull(environment.getConfiguration().getCommunityLists().get(_name)); } }
@Override public boolean matchCommunity(Environment environment, long community) { return environment .getConfiguration() .getCommunityLists() .get(_name) .matchCommunity(environment, community); }
@Override public void visitNamedCommunitySet(NamedCommunitySet namedCommunitySet) { visitCommunityList(_configuration.getCommunityLists().get(namedCommunitySet.getName())); }
@Override public void applyTo( List<Statement> statements, CiscoConfiguration cc, Configuration c, Warnings w) { CommunityList list = c.getCommunityLists().get(_listName); if (list != null) { statements.add(new DeleteCommunity(new NamedCommunitySet(_listName))); } }
private void initNamedCommunities() { _namedCommunities = new HashMap<>(); for (Configuration conf : getConfigurations().values()) { for (Entry<String, CommunityList> entry : conf.getCommunityLists().entrySet()) { String name = entry.getKey(); CommunityList cl = entry.getValue(); if (cl != null && cl.getLines().size() == 1) { CommunitySetExpr matchCondition = cl.getLines().get(0).getMatchCondition(); if (matchCondition instanceof RegexCommunitySet) { _namedCommunities.put(((RegexCommunitySet) matchCondition).getRegex(), name); } } } } }
public Map<String, String> findNamedCommunities() { Map<String, String> comms = new HashMap<>(); for (Configuration conf : getConfigurations().values()) { for (Entry<String, CommunityList> entry : conf.getCommunityLists().entrySet()) { String name = entry.getKey(); CommunityList cl = entry.getValue(); if (cl != null && cl.getLines().size() == 1) { CommunitySetExpr matchCondition = cl.getLines().get(0).getMatchCondition(); if (matchCondition instanceof RegexCommunitySet) { comms.put(((RegexCommunitySet) matchCondition).getRegex(), name); } } } } return comms; }
@Override public BooleanExpr toBooleanExpr(Configuration c, CiscoConfiguration cc, Warnings w) { Disjunction d = new Disjunction(); List<BooleanExpr> disjuncts = d.getDisjuncts(); for (String listName : _listNames) { CommunityList list = c.getCommunityLists().get(listName); if (list != null) { disjuncts.add(new MatchCommunitySet(new NamedCommunitySet(listName))); } } return d.simplify(); } }
@Override public void applyTo( List<Statement> statements, JuniperConfiguration juniperVendorConfiguration, Configuration c, Warnings warnings) { CommunityList namedList = _configuration.getMasterLogicalSystem().getCommunityLists().get(_name); if (namedList == null) { warnings.redFlag("Reference to undefined community: \"" + _name + "\""); } else { org.batfish.datamodel.CommunityList list = c.getCommunityLists().get(_name); if (list == null) { throw new VendorConversionException("missing community list: \"" + _name + "\""); } statements.add(new DeleteCommunity(new NamedCommunitySet(_name))); } }
SortedSet<Long> communities = new TreeSet<>(); for (String communityListName : _communityLists) { CommunityList communityList = c.getCommunityLists().get(communityListName); if (communityList != null) { StandardCommunityList scl = cc.getStandardCommunityLists().get(communityListName);
private BoolExpr matchCommunitySet(Configuration conf, CommunitySetExpr e, SymbolicRoute other) { if (e instanceof CommunityList) { Set<CommunityVar> comms = collectCommunityVars(conf, e); BoolExpr acc = _enc.mkTrue(); for (CommunityVar comm : comms) { BoolExpr c = other.getCommunities().get(comm); if (c == null) { throw new BatfishException("matchCommunitySet: should not be null"); } acc = _enc.mkAnd(acc, c); } return acc; } if (e instanceof NamedCommunitySet) { NamedCommunitySet x = (NamedCommunitySet) e; CommunityList cl = conf.getCommunityLists().get(x.getName()); return matchCommunityList(cl, other); } throw new BatfishException("TODO: match community set"); }
private BDD matchCommunitySet( TransferParam<BDDRoute> p, Configuration conf, CommunitySetExpr e, BDDRoute other) { if (e instanceof CommunityList) { Set<CommunityVar> comms = ((CommunityList) e) .getLines().stream() .map(line -> toCommunityVar(line.getMatchCondition())) .collect(Collectors.toSet()); BDD acc = factory.one(); for (CommunityVar comm : comms) { p.debug("Inline Community Set: " + comm); BDD c = other.getCommunities().get(comm); if (c == null) { throw new BatfishException("matchCommunitySet: should not be null"); } acc = acc.and(c); } return acc; } if (e instanceof NamedCommunitySet) { p.debug("Named"); NamedCommunitySet x = (NamedCommunitySet) e; CommunityList cl = conf.getCommunityLists().get(x.getName()); p.debug("Named Community Set: " + cl.getName()); return matchCommunityList(p, cl, other); } throw new BatfishException("TODO: match community set"); }
List<Long> communities = new ArrayList<>(); for (String communityListName : _communityLists) { CommunityList communityList = c.getCommunityLists().get(communityListName); if (communityList != null) { StandardCommunityList scl = cc.getStandardCommunityLists().get(communityListName);
_asPathAccessLists = node.getAsPathAccessLists().navigableKeySet(); if (!node.getCommunityLists().isEmpty()) { _communityLists = node.getCommunityLists().navigableKeySet();
CommunityList cl = e.getValue(); org.batfish.datamodel.CommunityList newCl = toCommunityList(cl); _c.getCommunityLists().put(name, newCl);
abstractConf.setVendorFamily(conf.getVendorFamily()); abstractConf.setZones(conf.getZones()); abstractConf.setCommunityLists(conf.getCommunityLists()); abstractConf.setRoutingPolicies(conf.getRoutingPolicies()); abstractConf.setRoute6FilterLists(conf.getRoute6FilterLists());
c.getCommunityLists().put(cList.getName(), cList); c.getCommunityLists().put(cList.getName(), cList); (name, communitySet) -> c.getCommunityLists().put(name, toCommunityList(communitySet)));
@Before public void setup() { NetworkFactory nf = new NetworkFactory(); Configuration c = nf.configurationBuilder().setConfigurationFormat(ConfigurationFormat.CISCO_IOS).build(); CommunityList referent = new CommunityList( COMMUNITY_LIST_NAME, ImmutableList.of(CommunityListLine.accepting(new LiteralCommunity(1L))), false); c.getCommunityLists().put(COMMUNITY_LIST_NAME, referent); nf.vrfBuilder().setName(Configuration.DEFAULT_VRF_NAME).setOwner(c).build(); _env = Environment.builder(c).setVrf(Configuration.DEFAULT_VRF_NAME).build(); }
new CommunityListsDiff(before.getCommunityLists(), after.getCommunityLists()); if (_communityListsDiff.isEmpty()) { _communityListsDiff = null;