use of org.batfish.z3.expr.EqExpr in project batfish by batfish.
the class BlacklistDstIpQuerySynthesizer method getReachabilityProgram.
@Override
public ReachabilityProgram getReachabilityProgram(SynthesizerInput input) {
ImmutableList.Builder<BooleanExpr> queryConditionsBuilder = ImmutableList.builder();
queryConditionsBuilder.add(SaneExpr.INSTANCE);
for (Ip blacklistIp : _blacklistIps) {
BooleanExpr blacklistIpCondition = new NotExpr(new EqExpr(new VarIntExpr(BasicHeaderField.DST_IP), new LitIntExpr(blacklistIp)));
queryConditionsBuilder.add(blacklistIpCondition);
}
return ReachabilityProgram.builder().setInput(input).setQueries(ImmutableList.of(new QueryStatement(Query.INSTANCE))).setRules(ImmutableList.of(new BasicRuleStatement(new AndExpr(queryConditionsBuilder.build()), ImmutableSet.of(), Query.INSTANCE))).build();
}
use of org.batfish.z3.expr.EqExpr in project batfish by batfish.
the class SimplifierTest method testSimplifyEqStaticallyFalse.
/**
* Test that an EQ node with LHS and RHS statically determinable to be unequal simplifies to
* FALSE.
*/
@Test
public void testSimplifyEqStaticallyFalse() {
IntExpr i1 = new LitIntExpr(Ip.ZERO);
IntExpr i2 = new LitIntExpr(Ip.MAX);
EqExpr eq = new EqExpr(i1, i2);
assertThat(simplifyBooleanExpr(eq), equalTo(FalseExpr.INSTANCE));
}
use of org.batfish.z3.expr.EqExpr in project batfish by batfish.
the class SimplifierTest method testSimplifyEqSame.
/**
* Test that an EQ node with syntactically equal LHS and RHS simplifies to TRUE.
*/
@Test
public void testSimplifyEqSame() {
IntExpr i1 = new VarIntExpr(BasicHeaderField.DST_IP);
EqExpr eq = new EqExpr(i1, i1);
assertThat(simplifyBooleanExpr(eq), equalTo(TrueExpr.INSTANCE));
}
use of org.batfish.z3.expr.EqExpr in project batfish by batfish.
the class DefaultTransitionGenerator method visitPreOutEdgePostNat_generateNoMatchSourceNatRules.
private void visitPreOutEdgePostNat_generateNoMatchSourceNatRules(String node1, String iface1, String node2, String iface2) {
List<Entry<AclPermit, BooleanExpr>> sourceNats = _input.getSourceNats().getOrDefault(node1, ImmutableMap.of()).getOrDefault(iface1, ImmutableList.of());
ImmutableSet.Builder<StateExpr> preStates = ImmutableSet.builder();
preStates.add(new PreOutEdge(node1, iface1, node2, iface2));
sourceNats.stream().map(Entry::getKey).map(aclPermit -> new AclDeny(aclPermit.getHostname(), aclPermit.getAcl())).forEach(preStates::add);
_rules.add(new TransformationRuleStatement(new EqExpr(new VarIntExpr(TransformationHeaderField.NEW_SRC_IP), new VarIntExpr(TransformationHeaderField.NEW_SRC_IP.getCurrent())), preStates.build(), ImmutableSet.of(), new PreOutEdgePostNat(node1, iface1, node2, iface2)));
}
use of org.batfish.z3.expr.EqExpr in project batfish by batfish.
the class BoolExprTransformerTest method testVisitEqExpr.
@Test
public void testVisitEqExpr() {
IntExpr i1Batfish = newIntAtom();
IntExpr i2Batfish = newIntAtom();
BitVecExpr i1Z3 = toBitVecExpr(i1Batfish, _nodContext);
BitVecExpr i2Z3 = toBitVecExpr(i2Batfish, _nodContext);
assertThat(toBoolExpr(new EqExpr(i1Batfish, i2Batfish), _input, _nodContext), equalTo(_ctx.mkEq(i1Z3, i2Z3)));
}
Aggregations