use of org.batfish.datamodel.routing_policy.Result in project batfish by batfish.
the class CallExpr method evaluate.
@Override
public Result evaluate(Environment environment) {
RoutingPolicy policy = environment.getConfiguration().getRoutingPolicies().get(_calledPolicyName);
Result result;
if (policy == null) {
result = new Result();
environment.setError(true);
result.setBooleanValue(false);
} else {
boolean oldCallExprContext = environment.getCallExprContext();
boolean oldLocalDefaultAction = environment.getLocalDefaultAction();
environment.setCallExprContext(true);
result = policy.call(environment);
result.setReturn(false);
environment.setCallExprContext(oldCallExprContext);
environment.setLocalDefaultAction(oldLocalDefaultAction);
}
return result;
}
use of org.batfish.datamodel.routing_policy.Result in project batfish by batfish.
the class Conjunction method evaluate.
@Override
public Result evaluate(Environment environment) {
for (BooleanExpr conjunct : _conjuncts) {
Result conjunctResult = conjunct.evaluate(environment);
if (conjunctResult.getExit()) {
return conjunctResult;
} else if (!conjunctResult.getBooleanValue()) {
conjunctResult.setReturn(false);
return conjunctResult;
}
}
Result result = new Result();
result.setBooleanValue(true);
return result;
}
use of org.batfish.datamodel.routing_policy.Result in project batfish by batfish.
the class ConjunctionChain method evaluate.
@Override
public Result evaluate(Environment environment) {
Result subroutineResult = new Result();
subroutineResult.setFallThrough(true);
for (BooleanExpr subroutine : _subroutines) {
subroutineResult = subroutine.evaluate(environment);
if (subroutineResult.getExit()) {
return subroutineResult;
} else if (!subroutineResult.getFallThrough() && !subroutineResult.getBooleanValue()) {
subroutineResult.setReturn(false);
return subroutineResult;
}
}
if (!subroutineResult.getFallThrough()) {
return subroutineResult;
} else {
String defaultPolicy = environment.getDefaultPolicy();
if (defaultPolicy != null) {
CallExpr callDefaultPolicy = new CallExpr(environment.getDefaultPolicy());
Result defaultPolicyResult = callDefaultPolicy.evaluate(environment);
return defaultPolicyResult;
} else {
throw new BatfishException("Default policy not set");
}
}
}
use of org.batfish.datamodel.routing_policy.Result in project batfish by batfish.
the class SetIsisLevel method execute.
@Override
public Result execute(Environment environment) {
Result result = new Result();
IsisLevel level = _level.evaluate(environment);
IsisRoute.Builder isisRouteBuilder = (IsisRoute.Builder) environment.getOutputRoute();
isisRouteBuilder.setLevel(level);
return result;
}
use of org.batfish.datamodel.routing_policy.Result in project batfish by batfish.
the class SetMetric method execute.
@Override
public Result execute(Environment environment) {
Result result = new Result();
long metric = _metric.evaluate(environment);
environment.getOutputRoute().setMetric(metric);
if (environment.getWriteToIntermediateBgpAttributes()) {
environment.getIntermediateBgpAttributes().setMetric(metric);
}
return result;
}
Aggregations