use of org.batfish.z3.expr.RuleStatement in project batfish by batfish.
the class MultipathInconsistencyQuerySynthesizer method getReachabilityProgram.
@Override
public ReachabilityProgram getReachabilityProgram(SynthesizerInput input) {
ImmutableList.Builder<RuleStatement> rules = ImmutableList.builder();
addOriginateRules(rules);
ImmutableList.Builder<BooleanExpr> queryPreconditions = ImmutableList.<BooleanExpr>builder().add(SaneExpr.INSTANCE).add(getSrcNattedConstraint());
rules.add(new BasicRuleStatement(new AndExpr(queryPreconditions.build()), ImmutableSet.of(Accept.INSTANCE, Drop.INSTANCE), Query.INSTANCE));
rules.add(new BasicRuleStatement(SaneExpr.INSTANCE, ImmutableSet.of(Accept.INSTANCE, NeighborUnreachable.INSTANCE), Query.INSTANCE));
rules.add(new BasicRuleStatement(SaneExpr.INSTANCE, ImmutableSet.of(Drop.INSTANCE, NeighborUnreachable.INSTANCE), Query.INSTANCE));
return ReachabilityProgram.builder().setInput(input).setQueries(ImmutableList.of(new QueryStatement(Query.INSTANCE))).setRules(rules.build()).build();
}
use of org.batfish.z3.expr.RuleStatement in project batfish by batfish.
the class EarliestMoreGeneralReachableLineQuerySynthesizer method getReachabilityProgram.
@Override
public ReachabilityProgram getReachabilityProgram(SynthesizerInput input) {
int unreachableLineIndex = _unreachableLine.getLine();
IpAccessListLine unreachableLine = _list.getLines().get(unreachableLineIndex);
BooleanExpr matchUnreachableLineHeaderSpace = new HeaderSpaceMatchExpr(unreachableLine);
ImmutableList.Builder<QueryStatement> queries = ImmutableList.builder();
ImmutableList.Builder<RuleStatement> rules = ImmutableList.builder();
for (AclLine earlierReachableLine : _earlierReachableLines) {
int earlierLineIndex = earlierReachableLine.getLine();
IpAccessListLine earlierLine = _list.getLines().get(earlierLineIndex);
BooleanExpr matchEarlierLineHeaderSpace = new HeaderSpaceMatchExpr(earlierLine);
NumberedQuery queryRel = new NumberedQuery(earlierLineIndex);
rules.add(new BasicRuleStatement(new AndExpr(ImmutableList.of(new NotExpr(matchEarlierLineHeaderSpace), matchUnreachableLineHeaderSpace, SaneExpr.INSTANCE)), queryRel));
QueryStatement query = new QueryStatement(queryRel);
queries.add(query);
_resultsByQueryIndex.add(earlierLineIndex);
}
return ReachabilityProgram.builder().setInput(input).setQueries(queries.build()).setRules(rules.build()).build();
}
use of org.batfish.z3.expr.RuleStatement in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitDropAcl.
@Test
public void testVisitDropAcl() {
SynthesizerInput input = MockSynthesizerInput.builder().build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(DropAcl.State.INSTANCE)));
Set<RuleStatement> expectedCopyDropAclIn = ImmutableSet.of(new BasicRuleStatement(DropAclIn.INSTANCE, DropAcl.INSTANCE));
Set<RuleStatement> expectedCopyDropAclOut = ImmutableSet.of(new BasicRuleStatement(DropAclOut.INSTANCE, DropAcl.INSTANCE));
assertThat(rules, equalTo(Sets.union(expectedCopyDropAclIn, expectedCopyDropAclOut)));
}
use of org.batfish.z3.expr.RuleStatement in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitPreOutEdge.
@Test
public void testVisitPreOutEdge() {
SynthesizerInput input = MockSynthesizerInput.builder().setArpTrueEdge(ImmutableMap.of(NODE1, ImmutableMap.of(VRF1, ImmutableMap.of(INTERFACE1, ImmutableMap.of(NODE3, ImmutableMap.of(INTERFACE3, b(1), INTERFACE4, b(2)), NODE4, ImmutableMap.of(INTERFACE3, b(3))), INTERFACE2, ImmutableMap.of(NODE3, ImmutableMap.of(INTERFACE3, b(4)))), VRF2, ImmutableMap.of(INTERFACE3, ImmutableMap.of(NODE3, ImmutableMap.of(INTERFACE3, b(5))))), NODE2, ImmutableMap.of(VRF1, ImmutableMap.of(INTERFACE1, ImmutableMap.of(NODE3, ImmutableMap.of(INTERFACE3, b(6))))))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(PreOutEdge.State.INSTANCE)));
// DestinationRouting
assertThat(rules, hasItem(new BasicRuleStatement(b(1), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE1, NODE3, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(b(2), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE1, NODE3, INTERFACE4))));
assertThat(rules, hasItem(new BasicRuleStatement(b(3), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE1, NODE4, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(b(4), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE2, NODE3, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(b(5), ImmutableSet.of(new PostInVrf(NODE1, VRF2), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE3, NODE3, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(b(6), ImmutableSet.of(new PostInVrf(NODE2, VRF1), new PreOut(NODE2)), new PreOutEdge(NODE2, INTERFACE1, NODE3, INTERFACE3))));
}
use of org.batfish.z3.expr.RuleStatement in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitAclDeny.
@Test
public void testVisitAclDeny() {
SynthesizerInput input = MockSynthesizerInput.builder().setAclActions(aclActions()).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(AclDeny.State.INSTANCE)));
// MatchDenyLine
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE1, ACL1, 1), new AclDeny(NODE1, ACL1))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE1, ACL1, 3), new AclDeny(NODE1, ACL1))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE1, ACL2, 0), new AclDeny(NODE1, ACL2))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE1, ACL2, 2), new AclDeny(NODE1, ACL2))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE2, ACL1, 1), new AclDeny(NODE2, ACL1))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE2, ACL1, 3), new AclDeny(NODE2, ACL1))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE2, ACL2, 0), new AclDeny(NODE2, ACL2))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE2, ACL2, 2), new AclDeny(NODE2, ACL2))));
// MatchNoLines
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineNoMatch(NODE1, ACL1, 3), new AclDeny(NODE1, ACL1))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineNoMatch(NODE1, ACL2, 3), new AclDeny(NODE1, ACL2))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclDeny(NODE1, ACL3))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineNoMatch(NODE2, ACL1, 3), new AclDeny(NODE2, ACL1))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineNoMatch(NODE2, ACL2, 3), new AclDeny(NODE2, ACL2))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclDeny(NODE1, ACL3))));
}
Aggregations