Search in sources :

Example 6 with NodeDropAcl

use of org.batfish.z3.state.NodeDropAcl 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

BasicRuleStatement (org.batfish.z3.expr.BasicRuleStatement)5 NodeDropAcl (org.batfish.z3.state.NodeDropAcl)5 SynthesizerInput (org.batfish.z3.SynthesizerInput)4 RuleStatement (org.batfish.z3.expr.RuleStatement)4 TransformationRuleStatement (org.batfish.z3.expr.TransformationRuleStatement)4 NodeDrop (org.batfish.z3.state.NodeDrop)4 NodeDropAclIn (org.batfish.z3.state.NodeDropAclIn)4 NodeDropAclOut (org.batfish.z3.state.NodeDropAclOut)4 NodeDropNoRoute (org.batfish.z3.state.NodeDropNoRoute)4 NodeDropNullRoute (org.batfish.z3.state.NodeDropNullRoute)4 ImmutableList (com.google.common.collect.ImmutableList)3 StateExpr (org.batfish.z3.expr.StateExpr)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 List (java.util.List)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 Set (java.util.Set)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 IpWildcard (org.batfish.datamodel.IpWildcard)2