use of org.batfish.z3.state.NodeDropNoRoute in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitNodeDropNoRoute.
@Test
public void testVisitNodeDropNoRoute() {
SynthesizerInput input = MockSynthesizerInput.builder().setRoutableIps(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(NodeDropNoRoute.State.INSTANCE)));
// DestinationRouting
assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(B1), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new NodeDropNoRoute(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(B2), ImmutableSet.of(new PostInVrf(NODE1, VRF2), new PreOut(NODE1)), new NodeDropNoRoute(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(B1), ImmutableSet.of(new PostInVrf(NODE2, VRF1), new PreOut(NODE2)), new NodeDropNoRoute(NODE2))));
assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(B2), ImmutableSet.of(new PostInVrf(NODE2, VRF2), new PreOut(NODE2)), new NodeDropNoRoute(NODE2))));
}
use of org.batfish.z3.state.NodeDropNoRoute in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitNodeDrop.
@Test
public void testVisitNodeDrop() {
SynthesizerInput input = MockSynthesizerInput.builder().setEnabledNodes(ImmutableSet.of(NODE1, NODE2)).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(NodeDrop.State.INSTANCE)));
// CopyNodeDropAcl
assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropAcl(NODE1), new NodeDrop(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropAcl(NODE2), new NodeDrop(NODE2))));
// CopyNodeDropNoRoute
assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropNoRoute(NODE1), new NodeDrop(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropNoRoute(NODE2), new NodeDrop(NODE2))));
// CopyNodeDropNullRoute
assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropNullRoute(NODE1), new NodeDrop(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropNullRoute(NODE2), new NodeDrop(NODE2))));
}
use of org.batfish.z3.state.NodeDropNoRoute in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitDropNoRoute.
@Test
public void testVisitDropNoRoute() {
SynthesizerInput input = MockSynthesizerInput.builder().setEnabledNodes(ImmutableSet.of(NODE1, NODE2)).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(DropNoRoute.State.INSTANCE)));
assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropNoRoute(NODE1), DropNoRoute.INSTANCE)));
assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropNoRoute(NODE2), DropNoRoute.INSTANCE)));
}
use of org.batfish.z3.state.NodeDropNoRoute in project batfish by batfish.
the class DefaultTransitionGenerator method visitNodeDrop.
@Override
public void visitNodeDrop(NodeDrop.State nodeDrop) {
// CopyNodeDropAcl
_input.getEnabledNodes().stream().map(hostname -> new BasicRuleStatement(new NodeDropAcl(hostname), new NodeDrop(hostname))).forEach(_rules::add);
// CopyNodeDropNoRoute
_input.getEnabledNodes().stream().map(hostname -> new BasicRuleStatement(new NodeDropNoRoute(hostname), new NodeDrop(hostname))).forEach(_rules::add);
// CopyNodeDropNullRoute
_input.getEnabledNodes().stream().map(hostname -> new BasicRuleStatement(new NodeDropNullRoute(hostname), new NodeDrop(hostname))).forEach(_rules::add);
}
use of org.batfish.z3.state.NodeDropNoRoute in project batfish by batfish.
the class StandardReachabilityQuerySynthesizer method computeFinalActions.
/**
* Create query condition for action at final node(s)
*/
private List<StateExpr> computeFinalActions() {
ImmutableList.Builder<StateExpr> finalActionsBuilder = ImmutableList.builder();
for (ForwardingAction action : _actions) {
switch(action) {
case ACCEPT:
if (_finalNodes.size() > 0) {
for (String finalNode : _finalNodes) {
StateExpr accept = new NodeAccept(finalNode);
finalActionsBuilder.add(accept);
}
} else {
finalActionsBuilder.add(Accept.INSTANCE);
}
break;
case DEBUG:
finalActionsBuilder.add(Debug.INSTANCE);
break;
case DROP:
if (_finalNodes.size() > 0) {
for (String finalNode : _finalNodes) {
StateExpr drop = new NodeDrop(finalNode);
finalActionsBuilder.add(drop);
}
} else {
finalActionsBuilder.add(Drop.INSTANCE);
}
break;
case DROP_ACL:
if (_finalNodes.size() > 0) {
for (String finalNode : _finalNodes) {
StateExpr drop = new NodeDropAcl(finalNode);
finalActionsBuilder.add(drop);
}
} else {
finalActionsBuilder.add(DropAcl.INSTANCE);
}
break;
case DROP_ACL_IN:
if (_finalNodes.size() > 0) {
for (String finalNode : _finalNodes) {
StateExpr drop = new NodeDropAclIn(finalNode);
finalActionsBuilder.add(drop);
}
} else {
finalActionsBuilder.add(DropAclIn.INSTANCE);
}
break;
case DROP_ACL_OUT:
if (_finalNodes.size() > 0) {
for (String finalNode : _finalNodes) {
StateExpr drop = new NodeDropAclOut(finalNode);
finalActionsBuilder.add(drop);
}
} else {
finalActionsBuilder.add(DropAclOut.INSTANCE);
}
break;
case DROP_NO_ROUTE:
if (_finalNodes.size() > 0) {
for (String finalNode : _finalNodes) {
StateExpr drop = new NodeDropNoRoute(finalNode);
finalActionsBuilder.add(drop);
}
} else {
finalActionsBuilder.add(DropNoRoute.INSTANCE);
}
break;
case DROP_NULL_ROUTE:
if (_finalNodes.size() > 0) {
for (String finalNode : _finalNodes) {
StateExpr drop = new NodeDropNullRoute(finalNode);
finalActionsBuilder.add(drop);
}
} else {
finalActionsBuilder.add(DropNullRoute.INSTANCE);
}
break;
case NEIGHBOR_UNREACHABLE_OR_EXITS_NETWORK:
if (_finalNodes.size() > 0) {
for (String finalNode : _finalNodes) {
StateExpr drop = new NodeNeighborUnreachable(finalNode);
finalActionsBuilder.add(drop);
}
} else {
finalActionsBuilder.add(NeighborUnreachable.INSTANCE);
}
break;
case FORWARD:
default:
throw new BatfishException("unsupported action");
}
}
return finalActionsBuilder.build();
}
Aggregations