@Override public BooleanExpr toBooleanExpr(CiscoConfiguration cc, Configuration c, Warnings w) { Conjunction conj = new Conjunction(); BooleanExpr left = _left.toBooleanExpr(cc, c, w); BooleanExpr right = _right.toBooleanExpr(cc, c, w); List<BooleanExpr> conjuncts = conj.getConjuncts(); conjuncts.add(left); conjuncts.add(right); return conj.simplify(); } }
@Override public BooleanExpr toBooleanExpr(JuniperConfiguration jc, Configuration c, Warnings warnings) { Conjunction conj = new Conjunction(); for (String conjunct : _conjuncts) { PolicyStatement conjunctPs = jc.getMasterLogicalSystem().getPolicyStatements().get(conjunct); if (conjunctPs != null) { conj.getConjuncts().add(new CallExpr(conjunct)); } else { warnings.redFlag("Reference to undefined policy conjunct: \"" + conjunct + "\""); } } return conj; } }
if (protocol == RoutingProtocol.EIGRP) { ospfExportConditions .getConjuncts() .add( new Disjunction( new MatchProtocol(RoutingProtocol.EIGRP_EX)))); } else { ospfExportConditions.getConjuncts().add(new MatchProtocol(protocol)); ospfExportConditions.getConjuncts().add(NOT_DEFAULT_ROUTE); ospfExportConditions.getConjuncts().add(RouteIsClassful.instance()); RouteMap exportRouteMap = _routeMaps.get(exportRouteMapName); if (exportRouteMap != null) { ospfExportConditions.getConjuncts().add(new CallExpr(exportRouteMapName));
private RoutingPolicy toRoutingPolicy(RouteMap routeMap) { String name = routeMap.getName(); RoutingPolicy routingPolicy = new RoutingPolicy(name, _c); List<Statement> statements = routingPolicy.getStatements(); for (Entry<Integer, RouteMapRule> e : routeMap.getRules().entrySet()) { String ruleName = Integer.toString(e.getKey()); RouteMapRule rule = e.getValue(); If ifStatement = new If(); List<Statement> trueStatements = ifStatement.getTrueStatements(); ifStatement.setComment(ruleName); Conjunction conj = new Conjunction(); for (RouteMapMatch match : rule.getMatches()) { conj.getConjuncts().add(match.toBooleanExpr(this, _c, _w)); } ifStatement.setGuard(conj.simplify()); switch (rule.getAction()) { case PERMIT: trueStatements.add(Statements.ExitAccept.toStaticStatement()); break; case DENY: trueStatements.add(Statements.ExitReject.toStaticStatement()); break; default: throw new BatfishException("Invalid action"); } statements.add(ifStatement); } statements.add(Statements.ExitReject.toStaticStatement()); return routingPolicy; }
List<BooleanExpr> subroutines = new ArrayList<>(); if (!froms.getFromAsPaths().isEmpty()) { conj.getConjuncts().add(new Disjunction(toBooleanExprs(froms.getFromAsPaths()))); conj.getConjuncts().add(froms.getFromColor().toBooleanExpr(this, _c, _w)); conj.getConjuncts().add(new Disjunction(toBooleanExprs(froms.getFromCommunities()))); conj.getConjuncts().add(froms.getFromFamily().toBooleanExpr(this, _c, _w)); conj.getConjuncts().add(new Disjunction(toBooleanExprs(froms.getFromInterfaces()))); conj.getConjuncts().add(froms.getFromLocalPreference().toBooleanExpr(this, _c, _w)); conj.getConjuncts().add(froms.getFromMetric().toBooleanExpr(this, _c, _w)); .addAll(toBooleanExprs(froms.getFromPrefixListFilterOrLongers())); prefixListDisjunction.getDisjuncts().addAll(toBooleanExprs(froms.getFromRouteFilters())); conj.getConjuncts().add(prefixListDisjunction); conj.getConjuncts().add(new Disjunction(toBooleanExprs(froms.getFromProtocols()))); conj.getConjuncts().add(new Disjunction(toBooleanExprs(froms.getFromTags()))); conj.getConjuncts().add(chain);
matchIpOrPrefix.getDisjuncts().add(matchExpr); } else { conj.getConjuncts().add(matchExpr); conj.getConjuncts().add(matchIpOrPrefix);
return null; eigrpExportConditions.getConjuncts().add(new MatchProcessAsn(otherAsn)); } else { matchExpr = new MatchProtocol(protocol); eigrpExportConditions.getConjuncts().add(matchExpr); RouteMap exportRouteMap = oldConfig.getRouteMaps().get(exportRouteMapName); if (exportRouteMap != null) { eigrpExportConditions.getConjuncts().add(new CallExpr(exportRouteMapName));
Conjunction ripExportDefaultConditions = new Conjunction(); List<Statement> ripExportDefaultStatements = ripExportDefault.getTrueStatements(); ripExportDefaultConditions.getConjuncts().add(MATCH_DEFAULT_ROUTE); long metric = proc.getDefaultInformationMetric(); ripExportDefaultStatements.add(new SetMetric(new LiteralLong(metric))); ripExportDefaultConditions.getConjuncts().add(new MatchProtocol(RoutingProtocol.AGGREGATE)); ripExportDefaultStatements.add(Statements.ExitAccept.toStaticStatement()); ripExportDefault.setGuard(ripExportDefaultConditions); ripExportConnected.setComment("RIP export connected routes"); Conjunction ripExportConnectedConditions = new Conjunction(); ripExportConnectedConditions.getConjuncts().add(new MatchProtocol(RoutingProtocol.CONNECTED)); List<Statement> ripExportConnectedStatements = ripExportConnected.getTrueStatements(); if (exportConnectedRouteMap != null) { ripExportConnectedConditions .getConjuncts() .add(new CallExpr(exportConnectedRouteMapName)); ripExportStatic.setComment("RIP export static routes"); Conjunction ripExportStaticConditions = new Conjunction(); ripExportStaticConditions.getConjuncts().add(new MatchProtocol(RoutingProtocol.STATIC)); List<Statement> ripExportStaticStatements = ripExportStatic.getTrueStatements(); ripExportStaticConditions.getConjuncts().add(NOT_DEFAULT_ROUTE); RouteMap exportStaticRouteMap = _routeMaps.get(exportStaticRouteMapName); if (exportStaticRouteMap != null) { ripExportStaticConditions.getConjuncts().add(new CallExpr(exportStaticRouteMapName));
if (expr instanceof Conjunction) { Conjunction c = (Conjunction) expr; if (c.getConjuncts().size() >= 2) { BooleanExpr be1 = c.getConjuncts().get(0); BooleanExpr be2 = c.getConjuncts().get(1); if (be1 instanceof MatchPrefixSet && be2 instanceof Not) { MatchPrefixSet mps = (MatchPrefixSet) be1;
matchIpOrPrefix.getDisjuncts().add(matchExpr); } else { conj.getConjuncts().add(matchExpr); conj.getConjuncts().add(matchIpOrPrefix);
if (e instanceof Conjunction) { Conjunction c = (Conjunction) e; for (BooleanExpr be : c.getConjuncts()) { visit(conf, be, fs, fe);
Conjunction ospfExportDefaultConditions = new Conjunction(); List<Statement> ospfExportDefaultStatements = ospfExportDefault.getTrueStatements(); ospfExportDefaultConditions.getConjuncts().add(MATCH_DEFAULT_ROUTE); long metric = proc.getDefaultInformationMetric(); ospfExportDefaultStatements.add(new SetMetric(new LiteralLong(metric))); .getConjuncts() .add(new MatchProtocol(RoutingProtocol.AGGREGATE));
List<BooleanExpr> peerExportConditions = peerExportGuard.getConjuncts(); exportStatements.add( new If(
Conjunction exportRipConditions = new Conjunction(); exportRipConditions.setComment("Redistribute RIP routes into BGP"); exportRipConditions.getConjuncts().add(new MatchProtocol(RoutingProtocol.RIP)); String mapName = redistributeRipPolicy.getRouteMap(); if (mapName != null) { exportRipConditions.getConjuncts().add(we); exportConditions.add(exportRipConditions); Conjunction exportStaticConditions = new Conjunction(); exportStaticConditions.setComment("Redistribute static routes into BGP"); exportStaticConditions.getConjuncts().add(new MatchProtocol(RoutingProtocol.STATIC)); String mapName = redistributeStaticPolicy.getRouteMap(); if (mapName != null) { exportStaticConditions.getConjuncts().add(we); exportConditions.add(exportStaticConditions); Conjunction exportConnectedConditions = new Conjunction(); exportConnectedConditions.setComment("Redistribute connected routes into BGP"); exportConnectedConditions.getConjuncts().add(new MatchProtocol(RoutingProtocol.CONNECTED)); String mapName = redistributeConnectedPolicy.getRouteMap(); if (mapName != null) { exportConnectedConditions.getConjuncts().add(we); exportConditions.add(exportConnectedConditions); Conjunction exportOspfConditions = new Conjunction(); exportOspfConditions.setComment("Redistribute OSPF routes into BGP");
Conjunction conj = new Conjunction(); originationIf.setGuard(conj); conj.getConjuncts().add(new MatchProtocol(RoutingProtocol.STATIC)); conj.getConjuncts() .add( new MatchPrefixSet(
BoolExpr acc = _enc.mkTrue(); TransferResult<BoolExpr, BoolExpr> result = new TransferResult<>(); for (BooleanExpr be : c.getConjuncts()) { TransferResult<BoolExpr, BoolExpr> r = compute(be, pCur.indent()); result = result.addChangedVariables(r);
BDD acc = factory.one(); TransferResult<TransferReturn, BDD> result = new TransferResult<>(); for (BooleanExpr be : c.getConjuncts()) { TransferResult<TransferReturn, BDD> r = compute(be, p.indent()); acc = acc.and(r.getReturnValue().getSecond());