use of org.batfish.z3.state.Query 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();
}
use of org.batfish.z3.state.Query in project batfish by batfish.
the class AclReachabilityQuerySynthesizer method getReachabilityProgram.
@Override
public ReachabilityProgram getReachabilityProgram(SynthesizerInput input) {
ReachabilityProgram.Builder builder = ReachabilityProgram.builder().setInput(input);
ImmutableList.Builder<QueryStatement> queries = ImmutableList.builder();
ImmutableList.Builder<RuleStatement> rules = ImmutableList.builder();
for (int line = 0; line < _numLines; line++) {
NumberedQuery query = new NumberedQuery(line);
rules.add(new BasicRuleStatement(SaneExpr.INSTANCE, ImmutableSet.of(new AclLineMatch(_hostname, _aclName, line)), new NumberedQuery(line)));
queries.add(new QueryStatement(query));
_keys.add(new AclLine(_hostname, _aclName, line));
}
return builder.setInput(input).setQueries(queries.build()).setRules(rules.build()).build();
}
Aggregations