use of org.batfish.z3.expr.BasicRuleStatement in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitNodeDropNullRoute.
@Test
public void testVisitNodeDropNullRoute() {
SynthesizerInput input = MockSynthesizerInput.builder().setNullRoutedIps(ImmutableMap.of(NODE1, ImmutableMap.of(VRF1, B1, VRF2, B2), NODE2, ImmutableMap.of(VRF1, B1, VRF2, B2))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(NodeDropNullRoute.State.INSTANCE)));
// DestinationRouting
assertThat(rules, hasItem(new BasicRuleStatement(B1, ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new NodeDropNullRoute(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(B2, ImmutableSet.of(new PostInVrf(NODE1, VRF2), new PreOut(NODE1)), new NodeDropNullRoute(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(B1, ImmutableSet.of(new PostInVrf(NODE2, VRF1), new PreOut(NODE2)), new NodeDropNullRoute(NODE2))));
assertThat(rules, hasItem(new BasicRuleStatement(B2, ImmutableSet.of(new PostInVrf(NODE2, VRF2), new PreOut(NODE2)), new NodeDropNullRoute(NODE2))));
}
use of org.batfish.z3.expr.BasicRuleStatement in project batfish by batfish.
the class DefaultTransitionGenerator method visitDropAcl.
@Override
public void visitDropAcl(DropAcl.State dropAcl) {
// CopyDropAclIn
_rules.add(new BasicRuleStatement(DropAclIn.INSTANCE, DropAcl.INSTANCE));
// CopyDropAclOut
_rules.add(new BasicRuleStatement(DropAclOut.INSTANCE, DropAcl.INSTANCE));
// ProjectNodeDropAcl (unused for now)
// _rules.add(
// new RuleStatement(
// new OrExpr(
// _input
// .getEnabledNodes()
// .keySet()
// .stream()
// .map(NodeDropAcl::new)
// .collect(ImmutableList.toImmutableList())),
// DropAcl.INSTANCE));
}
use of org.batfish.z3.expr.BasicRuleStatement in project batfish by batfish.
the class DefaultTransitionGenerator method visitPostIn.
@Override
public void visitPostIn(PostIn.State postIn) {
// CopyOriginate
_input.getEnabledNodes().stream().map(hostname -> new BasicRuleStatement(new Originate(hostname), new PostIn(hostname))).forEach(_rules::add);
// ProjectPostInInterface
_input.getEnabledInterfaces().entrySet().stream().flatMap(enabledInterfacesByHostnameEntry -> {
String hostname = enabledInterfacesByHostnameEntry.getKey();
return enabledInterfacesByHostnameEntry.getValue().stream().map(ifaceName -> new BasicRuleStatement(new PostInInterface(hostname, ifaceName), new PostIn(hostname)));
}).forEach(_rules::add);
}
use of org.batfish.z3.expr.BasicRuleStatement in project batfish by batfish.
the class DefaultTransitionGenerator method visitNodeDropAcl.
@Override
public void visitNodeDropAcl(NodeDropAcl.State nodeDropAcl) {
// CopyNodeDropAclIn
_input.getEnabledNodes().stream().map(hostname -> new BasicRuleStatement(new NodeDropAclIn(hostname), new NodeDropAcl(hostname))).forEach(_rules::add);
// CopyNodeDropAclOut
_input.getEnabledNodes().stream().map(hostname -> new BasicRuleStatement(new NodeDropAclOut(hostname), new NodeDropAcl(hostname))).forEach(_rules::add);
}
use of org.batfish.z3.expr.BasicRuleStatement in project batfish by batfish.
the class BoolExprTransformer method visitBasicRuleStatement.
@Override
public BoolExpr visitBasicRuleStatement(BasicRuleStatement basicRuleStatement) {
Context ctx = _nodContext.getContext();
ImmutableList.Builder<BoolExpr> preconditions = ImmutableList.<BoolExpr>builder().add(toBoolExpr(basicRuleStatement.getPreconditionStateIndependentConstraints(), _input, _nodContext));
basicRuleStatement.getPreconditionStates().stream().map(preconditionState -> toBoolExpr(preconditionState, _input, _nodContext)).forEach(preconditions::add);
return ctx.mkImplies(ctx.mkAnd(preconditions.build().stream().toArray(BoolExpr[]::new)), toBoolExpr(basicRuleStatement.getPostconditionState(), _input, _nodContext));
}
Aggregations