@Override public void applyTo( List<Statement> statements, JuniperConfiguration juniperVendorConfiguration, Configuration c, Warnings warnings) { statements.add(Statements.SetDefaultActionAccept.toStaticStatement()); } }
@Override public void applyTo( List<Statement> statements, JuniperConfiguration juniperVendorConfiguration, Configuration c, Warnings w) { statements.add(Statements.FallThrough.toStaticStatement()); } }
@Override public void applyTo( List<Statement> statements, CiscoConfiguration cc, Configuration c, Warnings w) { statements.add(Statements.DeleteAllCommunities.toStaticStatement()); }
@Override public void applyTo( List<Statement> statements, JuniperConfiguration juniperVendorConfiguration, Configuration c, Warnings warnings) { statements.add(Statements.SetDefaultActionReject.toStaticStatement()); } }
@Override public void applyTo( List<Statement> statements, JuniperConfiguration juniperVendorConfiguration, Configuration c, Warnings warnings) { If ifStatement = new If( BooleanExprs.CALL_EXPR_CONTEXT, ImmutableList.of(Statements.ReturnFalse.toStaticStatement()), ImmutableList.of(Statements.ExitReject.toStaticStatement())); statements.add(ifStatement); } }
@Override public void applyTo( List<Statement> statements, JuniperConfiguration juniperVendorConfiguration, Configuration c, Warnings w) { If ifStatement = new If( BooleanExprs.CALL_EXPR_CONTEXT, ImmutableList.of(Statements.ReturnTrue.toStaticStatement()), ImmutableList.of(Statements.ExitAccept.toStaticStatement())); statements.add(ifStatement); } }
@Override public final void applyTo( List<Statement> statements, CiscoConfiguration cc, Configuration c, Warnings w) { Statement setStatement = toSetStatement(cc, c, w); Statement bufferedStatement = new BufferedStatement(setStatement); statements.add(bufferedStatement); If ifStatement = new If( BooleanExprs.CALL_EXPR_CONTEXT, ImmutableList.of(Statements.SetLocalDefaultActionAccept.toStaticStatement()), ImmutableList.of(Statements.SetDefaultActionAccept.toStaticStatement())); statements.add(ifStatement); }
new If( BooleanExprs.CALL_EXPR_CONTEXT, ImmutableList.of(Statements.ReturnFalse.toStaticStatement()), ImmutableList.of(Statements.ExitAccept.toStaticStatement())); statements.add(ifStatement); break; statements.add(Statements.ExitReject.toStaticStatement()); break; new If( BooleanExprs.CALL_EXPR_CONTEXT, ImmutableList.of(Statements.SetLocalDefaultActionAccept.toStaticStatement()), ImmutableList.of(Statements.SetDefaultActionAccept.toStaticStatement())); statements.add(ifStatement); break; statements.add(Statements.Unsuppress.toStaticStatement()); break;
private static WithEnvironmentExpr bgpRedistributeWithEnvironmentExpr( BooleanExpr expr, OriginType originType) { WithEnvironmentExpr we = new WithEnvironmentExpr(); we.setExpr(expr); we.setPreStatements( ImmutableList.of(Statements.SetWriteIntermediateBgpAttributes.toStaticStatement())); we.setPostStatements( ImmutableList.of(Statements.UnsetWriteIntermediateBgpAttributes.toStaticStatement())); we.setPostTrueStatements( ImmutableList.of( Statements.SetReadIntermediateBgpAttributes.toStaticStatement(), new SetOrigin(new LiteralOrigin(originType, null)))); return we; }
private RoutingPolicy toRoutingPolicy(Configuration c, RoutePolicy routePolicy) { String name = routePolicy.getName(); RoutingPolicy rp = new RoutingPolicy(name, c); List<Statement> statements = rp.getStatements(); for (RoutePolicyStatement routePolicyStatement : routePolicy.getStatements()) { routePolicyStatement.applyTo(statements, this, c, _w); } If nonBoolean = new If( BooleanExprs.CALL_STATEMENT_CONTEXT, Collections.singletonList(Statements.Return.toStaticStatement()), Collections.singletonList(Statements.DefaultAction.toStaticStatement())); @SuppressWarnings("unused") // TODO(https://github.com/batfish/batfish/issues/1306) If endPolicy = new If( BooleanExprs.CALL_EXPR_CONTEXT, Collections.singletonList(Statements.ReturnLocalDefaultAction.toStaticStatement()), Collections.singletonList(nonBoolean)); return rp; }
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; }
new If(guard, statements, ImmutableList.of(Statements.ExitReject.toStaticStatement())));
ImmutableList.of(Statements.ReturnTrue.toStaticStatement()), ImmutableList.of(Statements.ReturnFalse.toStaticStatement())))) .build(); return new org.batfish.datamodel.dataplane.rib.RibGroup(
new MatchPrefixSet( DestinationNetwork.instance(), new NamedPrefixSet(matchLonger.getName())), ImmutableList.of(Statements.Suppress.toStaticStatement()), ImmutableList.of());
/** * 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(); }
private void applyLocalRoutePolicy(RoutingInstance routingInstance, RoutingPolicy targetPolicy) { boolean lan = routingInstance.getExportLocalRoutesLan(); boolean ptp = routingInstance.getExportLocalRoutesPointToPoint(); if (lan && ptp) { // All local routes are allowed, so no need for filter return; } BooleanExpr matchProtocol = new MatchProtocol(RoutingProtocol.LOCAL); BooleanExpr match; if (!lan && !ptp) { // No need to check length, since all local routes will be rejected match = matchProtocol; } else { SubRange rejectedLength = !lan ? new SubRange(0, Prefix.MAX_PREFIX_LENGTH - 2) : new SubRange(Prefix.MAX_PREFIX_LENGTH - 1, Prefix.MAX_PREFIX_LENGTH - 1); match = new Conjunction( ImmutableList.of( matchProtocol, new MatchLocalRouteSourcePrefixLength(rejectedLength))); } targetPolicy .getStatements() .add(new If(match, ImmutableList.of(Statements.ExitReject.toStaticStatement()))); }
/** * Generates and returns a {@link RoutingPolicy} that matches routes that should be aggregated for * aggregate network indicated by the given {@link Prefix}. * * <p>Does the bookkeeping in the provided {@link Configuration} to ensure the generated policy is * available and tracked. */ static RoutingPolicy generateAggregateRoutePolicy( Configuration c, String vrfName, Prefix prefix) { BooleanExpr matchLongerNetworks = new MatchPrefixSet( DestinationNetwork.instance(), new ExplicitPrefixSet(new PrefixSpace(PrefixRange.moreSpecificThan(prefix)))); If currentGeneratedRouteConditional = new If(matchLongerNetworks, singletonList(Statements.ReturnTrue.toStaticStatement())); RoutingPolicy policy = new RoutingPolicy("~AGGREGATE_ROUTE_GEN:" + vrfName + ":" + prefix + "~", c); policy.setStatements(ImmutableList.of(currentGeneratedRouteConditional)); c.getRoutingPolicies().put(policy.getName(), policy); return policy; }
ospfExportStatements.add(Statements.ExitAccept.toStaticStatement());
If routingPolicyConditional = new If(); routingPolicy.getStatements().add(routingPolicyConditional); routingPolicyConditional.getTrueStatements().add(Statements.ExitAccept.toStaticStatement()); routingPolicyConditional.getFalseStatements().add(Statements.ExitReject.toStaticStatement()); String rflName = "~SUMMARY" + policyNameSuffix + "_RF~"; MatchPrefixSet isContributingRoute =
endOfPolicy.setGuard(BooleanExprs.CALL_EXPR_CONTEXT); endOfPolicy.setFalseStatements( Collections.singletonList(Statements.Return.toStaticStatement())); statements.add(endOfPolicy); return routingPolicy;