Search in sources :

Example 21 with Result

use of org.batfish.datamodel.routing_policy.Result in project batfish by batfish.

the class If method execute.

@Override
public Result execute(Environment environment) {
    Result exprResult = _guard.evaluate(environment);
    if (exprResult.getExit()) {
        return exprResult;
    }
    boolean guardVal = exprResult.getBooleanValue();
    List<Statement> toExecute = guardVal ? _trueStatements : _falseStatements;
    for (Statement statement : toExecute) {
        Result result = statement.execute(environment);
        if (result.getExit() || result.getReturn()) {
            return result;
        }
    }
    Result fallThroughResult = new Result();
    fallThroughResult.setFallThrough(true);
    return fallThroughResult;
}
Also used : Result(org.batfish.datamodel.routing_policy.Result)

Example 22 with Result

use of org.batfish.datamodel.routing_policy.Result in project batfish by batfish.

the class PrependAsPath method execute.

@Override
public Result execute(Environment environment) {
    List<Integer> toPrepend = _expr.evaluate(environment);
    List<SortedSet<Integer>> newAsPaths = toPrepend.stream().map(ImmutableSortedSet::of).collect(ImmutableList.toImmutableList());
    BgpRoute.Builder bgpRouteBuilder = (BgpRoute.Builder) environment.getOutputRoute();
    bgpRouteBuilder.setAsPath(ImmutableList.<SortedSet<Integer>>builder().addAll(newAsPaths).addAll(bgpRouteBuilder.getAsPath()).build());
    if (environment.getWriteToIntermediateBgpAttributes()) {
        BgpRoute.Builder ir = environment.getIntermediateBgpAttributes();
        ir.setAsPath(ImmutableList.<SortedSet<Integer>>builder().addAll(newAsPaths).addAll(ir.getAsPath()).build());
    }
    Result result = new Result();
    return result;
}
Also used : BgpRoute(org.batfish.datamodel.BgpRoute) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) SortedSet(java.util.SortedSet) Result(org.batfish.datamodel.routing_policy.Result)

Example 23 with Result

use of org.batfish.datamodel.routing_policy.Result in project batfish by batfish.

the class SetCommunity method execute.

@Override
public Result execute(Environment environment) {
    Result result = new Result();
    BgpRoute.Builder bgpRoute = (BgpRoute.Builder) environment.getOutputRoute();
    SortedSet<Long> communities = _expr.allCommunities(environment);
    bgpRoute.getCommunities().clear();
    bgpRoute.getCommunities().addAll(communities);
    if (environment.getWriteToIntermediateBgpAttributes()) {
        environment.getIntermediateBgpAttributes().getCommunities().clear();
        environment.getIntermediateBgpAttributes().getCommunities().addAll(communities);
    }
    return result;
}
Also used : BgpRoute(org.batfish.datamodel.BgpRoute) Result(org.batfish.datamodel.routing_policy.Result)

Example 24 with Result

use of org.batfish.datamodel.routing_policy.Result in project batfish by batfish.

the class MatchPrefix6Set method evaluate.

@Override
public Result evaluate(Environment environment) {
    Prefix6 prefix = _prefix.evaluate(environment);
    boolean match = prefix != null && _prefixSet.matches(prefix, environment);
    Result result = new Result();
    result.setBooleanValue(match);
    return result;
}
Also used : Prefix6(org.batfish.datamodel.Prefix6) Result(org.batfish.datamodel.routing_policy.Result)

Example 25 with Result

use of org.batfish.datamodel.routing_policy.Result in project batfish by batfish.

the class MatchPrefixSet method evaluate.

@Override
public Result evaluate(Environment environment) {
    Prefix prefix = _prefix.evaluate(environment);
    boolean match = _prefixSet.matches(prefix, environment);
    Result result = new Result();
    result.setBooleanValue(match);
    return result;
}
Also used : Prefix(org.batfish.datamodel.Prefix) Result(org.batfish.datamodel.routing_policy.Result)

Aggregations

Result (org.batfish.datamodel.routing_policy.Result)30 BgpRoute (org.batfish.datamodel.BgpRoute)8 BatfishException (org.batfish.common.BatfishException)2 RoutingPolicy (org.batfish.datamodel.routing_policy.RoutingPolicy)2 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)1 SortedSet (java.util.SortedSet)1 Ip6AccessList (org.batfish.datamodel.Ip6AccessList)1 IpAccessList (org.batfish.datamodel.IpAccessList)1 IsisLevel (org.batfish.datamodel.IsisLevel)1 IsisRoute (org.batfish.datamodel.IsisRoute)1 OriginType (org.batfish.datamodel.OriginType)1 OspfExternalRoute (org.batfish.datamodel.OspfExternalRoute)1 Prefix (org.batfish.datamodel.Prefix)1 Prefix6 (org.batfish.datamodel.Prefix6)1