Search in sources :

Example 1 with NodeNeighborUnreachable

use of org.batfish.z3.state.NodeNeighborUnreachable in project batfish by batfish.

the class DefaultTransitionGeneratorTest method testVisitNodeNeighborUnreachable.

@Test
public void testVisitNodeNeighborUnreachable() {
    SynthesizerInput input = MockSynthesizerInput.builder().setNeighborUnreachable(ImmutableMap.of(NODE1, ImmutableMap.of(VRF1, ImmutableMap.of(INTERFACE1, b(1), INTERFACE2, b(2)), VRF2, ImmutableMap.of(INTERFACE3, b(3))), NODE2, ImmutableMap.of(VRF1, ImmutableMap.of(INTERFACE1, b(4))))).build();
    Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(NodeNeighborUnreachable.State.INSTANCE)));
    assertThat(rules, hasItem(new BasicRuleStatement(b(1), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new NodeNeighborUnreachable(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(b(2), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new NodeNeighborUnreachable(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(b(3), ImmutableSet.of(new PostInVrf(NODE1, VRF2), new PreOut(NODE1)), new NodeNeighborUnreachable(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(b(4), ImmutableSet.of(new PostInVrf(NODE2, VRF1), new PreOut(NODE2)), new NodeNeighborUnreachable(NODE2))));
}
Also used : PreOut(org.batfish.z3.state.PreOut) MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) NodeNeighborUnreachable(org.batfish.z3.state.NodeNeighborUnreachable) PostInVrf(org.batfish.z3.state.PostInVrf) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Example 2 with NodeNeighborUnreachable

use of org.batfish.z3.state.NodeNeighborUnreachable in project batfish by batfish.

the class DefaultTransitionGeneratorTest method testVisitNeighborUnreachable.

@Test
public void testVisitNeighborUnreachable() {
    SynthesizerInput input = MockSynthesizerInput.builder().setNeighborUnreachable(ImmutableMap.of(NODE1, ImmutableMap.of(VRF1, ImmutableMap.of(INTERFACE1, b(1))), NODE2, ImmutableMap.of(VRF1, ImmutableMap.of(INTERFACE1, b(2))))).build();
    Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(NeighborUnreachable.State.INSTANCE)));
    assertThat(rules, hasItem(new BasicRuleStatement(new NodeNeighborUnreachable(NODE1), NeighborUnreachable.INSTANCE)));
    assertThat(rules, hasItem(new BasicRuleStatement(new NodeNeighborUnreachable(NODE2), NeighborUnreachable.INSTANCE)));
}
Also used : MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) NodeNeighborUnreachable(org.batfish.z3.state.NodeNeighborUnreachable) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Example 3 with NodeNeighborUnreachable

use of org.batfish.z3.state.NodeNeighborUnreachable 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();
}
Also used : ForwardingAction(org.batfish.datamodel.ForwardingAction) NodeDropAcl(org.batfish.z3.state.NodeDropAcl) BatfishException(org.batfish.common.BatfishException) NodeDropNoRoute(org.batfish.z3.state.NodeDropNoRoute) NodeDropNullRoute(org.batfish.z3.state.NodeDropNullRoute) ImmutableList(com.google.common.collect.ImmutableList) NodeAccept(org.batfish.z3.state.NodeAccept) StateExpr(org.batfish.z3.expr.StateExpr) NodeDrop(org.batfish.z3.state.NodeDrop) NodeDropAclIn(org.batfish.z3.state.NodeDropAclIn) NodeNeighborUnreachable(org.batfish.z3.state.NodeNeighborUnreachable) NodeDropAclOut(org.batfish.z3.state.NodeDropAclOut)

Aggregations

NodeNeighborUnreachable (org.batfish.z3.state.NodeNeighborUnreachable)3 MockSynthesizerInput (org.batfish.z3.MockSynthesizerInput)2 SynthesizerInput (org.batfish.z3.SynthesizerInput)2 BasicRuleStatement (org.batfish.z3.expr.BasicRuleStatement)2 RuleStatement (org.batfish.z3.expr.RuleStatement)2 TransformationRuleStatement (org.batfish.z3.expr.TransformationRuleStatement)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 BatfishException (org.batfish.common.BatfishException)1 ForwardingAction (org.batfish.datamodel.ForwardingAction)1 StateExpr (org.batfish.z3.expr.StateExpr)1 NodeAccept (org.batfish.z3.state.NodeAccept)1 NodeDrop (org.batfish.z3.state.NodeDrop)1 NodeDropAcl (org.batfish.z3.state.NodeDropAcl)1 NodeDropAclIn (org.batfish.z3.state.NodeDropAclIn)1 NodeDropAclOut (org.batfish.z3.state.NodeDropAclOut)1 NodeDropNoRoute (org.batfish.z3.state.NodeDropNoRoute)1 NodeDropNullRoute (org.batfish.z3.state.NodeDropNullRoute)1 PostInVrf (org.batfish.z3.state.PostInVrf)1 PreOut (org.batfish.z3.state.PreOut)1