use of org.kie.workbench.common.dmn.api.definition.v1_1.Context in project batfish by batfish.
the class NodSatJob method call.
@Override
public NodSatResult<KeyT> call() {
Map<KeyT, Boolean> results = new LinkedHashMap<>();
long startTime = System.currentTimeMillis();
try (Context ctx = new Context()) {
ReachabilityProgram baseProgram = _query.synthesizeBaseProgram(_synthesizer);
ReachabilityProgram queryProgram = _query.getReachabilityProgram(_synthesizer.getInput());
NodProgram program = new NodProgram(ctx, baseProgram, queryProgram);
Fixedpoint fix = mkFixedpoint(program, false);
for (int queryNum = 0; queryNum < program.getQueries().size(); queryNum++) {
BoolExpr query = program.getQueries().get(queryNum);
KeyT key = _query.getKeys().get(queryNum);
Status status = fix.query(query);
switch(status) {
case SATISFIABLE:
results.put(key, true);
break;
case UNKNOWN:
return new NodSatResult<>(startTime, _logger.getHistory(), new BatfishException("Query satisfiability unknown"));
case UNSATISFIABLE:
results.put(key, false);
break;
default:
return new NodSatResult<>(startTime, _logger.getHistory(), new BatfishException("invalid status"));
}
}
return new NodSatResult<>(results, _logger.getHistory(), startTime);
} catch (Z3Exception e) {
return new NodSatResult<>(startTime, _logger.getHistory(), new BatfishException("Error running NoD on concatenated data plane", e));
}
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Context in project batfish by batfish.
the class AbstractNodJob method call.
@Override
public final NodJobResult call() {
long startTime = System.currentTimeMillis();
try (Context ctx = new Context()) {
SmtInput smtInput = computeSmtInput(startTime, ctx);
Map<OriginateVrf, Map<String, Long>> originateVrfConstraints = getOriginateVrfConstraints(ctx, smtInput);
Set<Flow> flows = getFlows(originateVrfConstraints);
return new NodJobResult(startTime, _logger.getHistory(), flows);
} catch (Z3Exception e) {
return new NodJobResult(startTime, _logger.getHistory(), new BatfishException("Error running NoD on concatenated data plane", e));
}
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Context in project batfish by batfish.
the class BoolExprTransformerTest method setup.
@Before
public void setup() {
_stateExpr = Accept.INSTANCE;
_transformationStateExpr = new PreOutEdgePostNat("host1", "interface1", "host2", "interface2");
_ctx = new Context();
_input = MockSynthesizerInput.builder().build();
_nodContext = new NodContext(_ctx, ReachabilityProgram.builder().setInput(_input).setRules(of(new BasicRuleStatement(_stateExpr), new TransformationRuleStatement(_transformationStateExpr))).build());
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Context in project batfish by batfish.
the class NodJobTest method testNotNattedSat.
/**
* Test that traffic originating from 3.0.0.1 that is expected NOT to be NATed returns SAT when we
* constrain to only allow NOT-NATed results.
*/
@Test
public void testNotNattedSat() {
HeaderSpace headerSpace = new HeaderSpace();
headerSpace.setSrcIps(ImmutableList.of(new IpWildcard("3.0.0.1")));
NodJob nodJob = getNodJob(headerSpace, false);
Context z3Context = new Context();
Status status = nodJob.computeNodSat(System.currentTimeMillis(), z3Context);
assertThat(status, equalTo(Status.SATISFIABLE));
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Context in project batfish by batfish.
the class NodJobTest method testNattedUnsat.
/**
* Test that traffic originating from 3.0.0.0 that is expected to be NATed returns UNSAT when we
* constrain to only allow NOT-NATed results.
*/
@Test
public void testNattedUnsat() {
HeaderSpace headerSpace = new HeaderSpace();
headerSpace.setSrcIps(ImmutableList.of(new IpWildcard("3.0.0.0")));
NodJob nodJob = getNodJob(headerSpace, false);
Context z3Context = new Context();
Status status = nodJob.computeNodSat(System.currentTimeMillis(), z3Context);
assertThat(status, equalTo(Status.UNSATISFIABLE));
}
Aggregations