@Override public BooleanExpr toBooleanExpr(Configuration c, CiscoConfiguration cc, Warnings w) { Disjunction d = new Disjunction(); List<BooleanExpr> disjuncts = d.getDisjuncts(); for (String protocol : _protocols) { disjuncts.add(new MatchProtocol(RoutingProtocol.fromProtocolName(protocol))); } return d.simplify(); } }
_simplified = simpleDisjuncts.get(0); } else { Disjunction simple = new Disjunction(); simple.setDisjuncts(simpleDisjuncts); simple.setComment(getComment()); _simplified = simple; simple._simplified = _simplified;
@Test public void simplifyTrue() { Disjunction trueS = new Disjunction(ImmutableList.of(TRUE)); assertThat(trueS.simplify(), is(TRUE)); }
private void initDefaultBgpExportPolicy() { if (_c.getRoutingPolicies().containsKey(DEFAULT_BGP_EXPORT_POLICY_NAME)) { return; } // set up default export policy (accept bgp routes) RoutingPolicy defaultBgpExportPolicy = new RoutingPolicy(DEFAULT_BGP_EXPORT_POLICY_NAME, _c); _c.getRoutingPolicies().put(DEFAULT_BGP_EXPORT_POLICY_NAME, defaultBgpExportPolicy); If defaultBgpExportPolicyConditional = new If(); defaultBgpExportPolicy.getStatements().add(defaultBgpExportPolicyConditional); // guard Disjunction isBgp = new Disjunction(); isBgp.getDisjuncts().add(new MatchProtocol(RoutingProtocol.BGP)); isBgp.getDisjuncts().add(new MatchProtocol(RoutingProtocol.IBGP)); defaultBgpExportPolicyConditional.setGuard(isBgp); PsThenAccept.INSTANCE.applyTo( defaultBgpExportPolicyConditional.getTrueStatements(), this, _c, _w); PsThenReject.INSTANCE.applyTo( defaultBgpExportPolicyConditional.getFalseStatements(), this, _c, _w); }
/** * Create a filter that only allows traffic for those prefixes if it came from outside. EXTERNAL = * (protocol is bgp or ibgp) and (the AS path is not an internal path) MATCH = destination matches * the prefixTrie GUARD = EXTERNAL or MATCH (only allow this traffic through) */ @Nonnull private BooleanExpr matchExternalTraffic() { List<AsPathSetElem> elements = new ArrayList<>(); elements.add(new RegexAsPathSetElem(_internalRegex)); ExplicitAsPathSet expr = new ExplicitAsPathSet(elements); MatchAsPath matchPath = new MatchAsPath(expr); MatchProtocol mpBgp = new MatchProtocol(RoutingProtocol.BGP); MatchProtocol mpIbgp = new MatchProtocol(RoutingProtocol.IBGP); Disjunction d = new Disjunction(); List<BooleanExpr> disjuncts = new ArrayList<>(); disjuncts.add(mpBgp); disjuncts.add(mpIbgp); d.setDisjuncts(disjuncts); Not n = new Not(matchPath); Conjunction c = new Conjunction(); List<BooleanExpr> conjuncts = new ArrayList<>(); conjuncts.add(d); conjuncts.add(n); c.setConjuncts(conjuncts); return c; }
@Override public BooleanExpr toBooleanExpr(JuniperConfiguration jc, Configuration c, Warnings warnings) { if (_protocol == RoutingProtocol.BGP) { return new Disjunction( new MatchProtocol(RoutingProtocol.BGP), new MatchProtocol(RoutingProtocol.IBGP)); } else { return new MatchProtocol(_protocol); } } }
for (BooleanExpr be : d.getDisjuncts()) { visit(conf, be, fs, fe);
@Override public BooleanExpr toBooleanExpr(JuniperConfiguration jc, Configuration c, Warnings warnings) { RouteFilterList rfl = c.getRouteFilterLists().get(_routeFilterName); Route6FilterList rfl6 = c.getRoute6FilterLists().get(_routeFilterName); BooleanExpr match4 = null; BooleanExpr match6 = null; if (rfl != null) { match4 = new MatchPrefixSet(DestinationNetwork.instance(), new NamedPrefixSet(_routeFilterName)); } if (rfl6 != null) { match6 = new MatchPrefix6Set(new DestinationNetwork6(), new NamedPrefix6Set(_routeFilterName)); } if (match4 != null && match6 == null) { return match4; } else if (rfl == null && rfl6 != null) { return match6; } else if (rfl != null && rfl6 != null) { Disjunction d = new Disjunction(); d.getDisjuncts().add(match4); d.getDisjuncts().add(match6); return d; } else { throw new VendorConversionException( "missing route filter list: \"" + _routeFilterName + "\""); } } }
@Test public void simplifySingleStatement() { Disjunction single = new Disjunction(ImmutableList.of(CALL_EXPR_CONTEXT)); assertThat(single.simplify(), is(CALL_EXPR_CONTEXT)); }
if (filter._isForDefaultSlice) { Disjunction pfxOrExternal = new Disjunction(); pfxOrExternal.setDisjuncts(ImmutableList.of(match, matchExternalTraffic())); guard = pfxOrExternal; } else {
/** * Generate a {@link RoutingPolicy} for use when importing routes from pseudo-protocols (direct, * static, aggregate, generated) */ @VisibleForTesting static RoutingPolicy generateDefaultPseudoProtocolImportPolicy(@Nonnull Configuration c) { return RoutingPolicy.builder() .setOwner(c) .setName(DEFAULT_PSEUDO_PROTOCOL_IMPORT_POLICY_NAME) .setStatements( ImmutableList.of( new If( new Disjunction( new MatchProtocol(RoutingProtocol.CONNECTED), new MatchProtocol(RoutingProtocol.LOCAL), new MatchProtocol(RoutingProtocol.STATIC), new MatchProtocol(RoutingProtocol.AGGREGATE)), ImmutableList.of(Statements.ReturnTrue.toStaticStatement()), ImmutableList.of(Statements.ReturnFalse.toStaticStatement())))) .build(); }
BoolExpr acc = _enc.mkFalse(); TransferResult<BoolExpr, BoolExpr> result = new TransferResult<>(); for (BooleanExpr be : d.getDisjuncts()) { TransferResult<BoolExpr, BoolExpr> r = compute(be, pCur.indent()); result = result.addChangedVariables(r);
@Override public BooleanExpr toBooleanExpr(CiscoConfiguration cc, Configuration c, Warnings w) { Disjunction disj = new Disjunction(); BooleanExpr left = _left.toBooleanExpr(cc, c, w); BooleanExpr right = _right.toBooleanExpr(cc, c, w); List<BooleanExpr> disjuncts = disj.getDisjuncts(); disjuncts.add(left); disjuncts.add(right); return disj.simplify(); } }
Conjunction conj = new Conjunction(); Disjunction matchIpOrPrefix = new Disjunction(); for (RouteMapMatchLine rmMatch : rmClause.getMatchList()) { BooleanExpr matchExpr = rmMatch.toBooleanExpr(c, this, _w); || rmMatch instanceof RouteMapMatchIpv6AccessListLine || rmMatch instanceof RouteMapMatchIpv6PrefixListLine) { matchIpOrPrefix.getDisjuncts().add(matchExpr); } else { conj.getConjuncts().add(matchExpr); if (!matchIpOrPrefix.getDisjuncts().isEmpty()) { conj.getConjuncts().add(matchIpOrPrefix);
@Test public void simplifyEmpty() { Disjunction empty = new Disjunction(); assertThat(empty.simplify(), is(FALSE)); }
Disjunction disjunction = new Disjunction(); disjunction.setDisjuncts(ImmutableList.of(conjunctionChain));
.getConjuncts() .add( new Disjunction( ImmutableList.of( new MatchProtocol(RoutingProtocol.EIGRP),
BDD acc = factory.zero(); TransferResult<TransferReturn, BDD> result = new TransferResult<>(); for (BooleanExpr be : d.getDisjuncts()) { TransferResult<TransferReturn, BDD> r = compute(be, p.indent()); result = result.addChangedVariables(r);
@Override public BooleanExpr toBooleanExpr(Configuration c, CiscoConfiguration cc, Warnings w) { Disjunction d = new Disjunction(); List<BooleanExpr> disjuncts = d.getDisjuncts(); for (int tag : _tags) { disjuncts.add(new MatchTag(IntComparator.EQ, new LiteralInt(tag))); } return d.simplify(); } }
List<BooleanExpr> subroutines = new ArrayList<>(); if (!froms.getFromAsPaths().isEmpty()) { conj.getConjuncts().add(new Disjunction(toBooleanExprs(froms.getFromAsPaths()))); conj.getConjuncts().add(new Disjunction(toBooleanExprs(froms.getFromCommunities()))); conj.getConjuncts().add(new Disjunction(toBooleanExprs(froms.getFromInterfaces()))); || !froms.getFromRouteFilters().isEmpty()) { Disjunction prefixListDisjunction = new Disjunction(); prefixListDisjunction.getDisjuncts().addAll(toBooleanExprs(froms.getFromPrefixLists())); prefixListDisjunction .getDisjuncts() .addAll(toBooleanExprs(froms.getFromPrefixListFilterLongers())); prefixListDisjunction .getDisjuncts() .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())));