use of org.batfish.z3.expr.BasicRuleStatement in project batfish by batfish.
the class DefaultTransitionGenerator method visitPostInVrf.
@Override
public void visitPostInVrf(PostInVrf.State postInVrf) {
// CopyOriginateVrf
_input.getEnabledInterfacesByNodeVrf().entrySet().stream().flatMap(enabledInterfacesByNodeEntry -> {
String hostname = enabledInterfacesByNodeEntry.getKey();
return enabledInterfacesByNodeEntry.getValue().entrySet().stream().map(enabledInterfacesByVrfEntry -> {
String vrf = enabledInterfacesByVrfEntry.getKey();
return new BasicRuleStatement(new OriginateVrf(hostname, vrf), new PostInVrf(hostname, vrf));
});
}).forEach(_rules::add);
// PostInInterfaceCorrespondingVrf
_input.getEnabledInterfacesByNodeVrf().entrySet().stream().flatMap(enabledInterfacesByNodeEntry -> {
String hostname = enabledInterfacesByNodeEntry.getKey();
return enabledInterfacesByNodeEntry.getValue().entrySet().stream().flatMap(enabledInterfacesByVrfEntry -> {
String vrfName = enabledInterfacesByVrfEntry.getKey();
return enabledInterfacesByVrfEntry.getValue().stream().map(ifaceName -> new BasicRuleStatement(new PostInInterface(hostname, ifaceName), new PostInVrf(hostname, vrfName)));
});
}).forEach(_rules::add);
}
use of org.batfish.z3.expr.BasicRuleStatement in project batfish by batfish.
the class DefaultTransitionGenerator method visitNodeDropAclOut.
@Override
public void visitNodeDropAclOut(NodeDropAclOut.State nodeDropAclOut) {
_input.getEnabledEdges().forEach(edge -> {
String node1 = edge.getNode1();
String iface1 = edge.getInt1();
String node2 = edge.getNode2();
String iface2 = edge.getInt2();
String outAcl = _input.getOutgoingAcls().get(node1).get(iface1);
// There has to be an ACL -- no ACL is an implicit Permit.
if (outAcl != null) {
Set<StateExpr> postTransformationPreStates = ImmutableSet.of(new AclDeny(node1, outAcl), new PreOutEdgePostNat(node1, iface1, node2, iface2));
_rules.add(new BasicRuleStatement(TrueExpr.INSTANCE, postTransformationPreStates, new NodeDropAclOut(node1)));
}
});
}
use of org.batfish.z3.expr.BasicRuleStatement in project batfish by batfish.
the class StandardReachabilityQuerySynthesizer method getReachabilityProgram.
@Override
public ReachabilityProgram getReachabilityProgram(SynthesizerInput input) {
ImmutableList.Builder<RuleStatement> rules = ImmutableList.builder();
List<StateExpr> finalActions = computeFinalActions();
ImmutableList.Builder<BooleanExpr> queryPreconditions = ImmutableList.<BooleanExpr>builder().add(SaneExpr.INSTANCE).add(getSrcNattedConstraint());
finalActions.stream().map(finalAction -> new BasicRuleStatement(new AndExpr(queryPreconditions.build()), ImmutableSet.of(finalAction), Query.INSTANCE)).forEach(rules::add);
addOriginateRules(rules);
return ReachabilityProgram.builder().setInput(input).setQueries(ImmutableList.of(new QueryStatement(Query.INSTANCE))).setRules(rules.build()).build();
}
use of org.batfish.z3.expr.BasicRuleStatement in project batfish by batfish.
the class AclReachabilityQuerySynthesizer method getReachabilityProgram.
@Override
public ReachabilityProgram getReachabilityProgram(SynthesizerInput input) {
ReachabilityProgram.Builder builder = ReachabilityProgram.builder().setInput(input);
ImmutableList.Builder<QueryStatement> queries = ImmutableList.builder();
ImmutableList.Builder<RuleStatement> rules = ImmutableList.builder();
for (int line = 0; line < _numLines; line++) {
NumberedQuery query = new NumberedQuery(line);
rules.add(new BasicRuleStatement(SaneExpr.INSTANCE, ImmutableSet.of(new AclLineMatch(_hostname, _aclName, line)), new NumberedQuery(line)));
queries.add(new QueryStatement(query));
_keys.add(new AclLine(_hostname, _aclName, line));
}
return builder.setInput(input).setQueries(queries.build()).setRules(rules.build()).build();
}
Aggregations