Search in sources :

Example 6 with VarIntExpr

use of org.batfish.z3.expr.VarIntExpr in project batfish by batfish.

the class DefaultTransitionGeneratorTest method testVisitPreOutEdgePostNat_topologyInterfaceWithNAT.

/**
 * Test the transitions generated for PreOutEdgePostNat for an edge with a source nat.
 */
@Test
public void testVisitPreOutEdgePostNat_topologyInterfaceWithNAT() {
    SynthesizerInput input = MockSynthesizerInput.builder().setEnabledEdges(ImmutableSet.of(new Edge(NODE1, INTERFACE1, NODE2, INTERFACE2))).setTopologyInterfaces(ImmutableMap.of(NODE1, ImmutableSet.of(INTERFACE1))).setSourceNats(ImmutableMap.of(NODE1, ImmutableMap.of(INTERFACE1, ImmutableList.of(Maps.immutableEntry(new AclPermit(NODE1, NAT_ACL1), B1))))).build();
    List<RuleStatement> rules = DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(PreOutEdgePostNat.State.INSTANCE));
    RuleStatement permitRule = new TransformationRuleStatement(B1, ImmutableSet.of(new PreOutEdge(NODE1, INTERFACE1, NODE2, INTERFACE2), new AclPermit(NODE1, NAT_ACL1)), ImmutableSet.of(), new PreOutEdgePostNat(NODE1, INTERFACE1, NODE2, INTERFACE2));
    RuleStatement denyRule = new TransformationRuleStatement(new EqExpr(new VarIntExpr(TransformationHeaderField.NEW_SRC_IP), new VarIntExpr(TransformationHeaderField.NEW_SRC_IP.getCurrent())), ImmutableSet.of(new PreOutEdge(NODE1, INTERFACE1, NODE2, INTERFACE2), new AclDeny(NODE1, NAT_ACL1)), ImmutableSet.of(), new PreOutEdgePostNat(NODE1, INTERFACE1, NODE2, INTERFACE2));
    assertThat(rules, containsInAnyOrder(permitRule, denyRule));
}
Also used : AclDeny(org.batfish.z3.state.AclDeny) PreOutEdge(org.batfish.z3.state.PreOutEdge) VarIntExpr(org.batfish.z3.expr.VarIntExpr) 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) EqExpr(org.batfish.z3.expr.EqExpr) AclPermit(org.batfish.z3.state.AclPermit) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) Edge(org.batfish.datamodel.Edge) PostOutEdge(org.batfish.z3.state.PostOutEdge) PreOutEdge(org.batfish.z3.state.PreOutEdge) PreOutEdgePostNat(org.batfish.z3.state.PreOutEdgePostNat) Test(org.junit.Test)

Example 7 with VarIntExpr

use of org.batfish.z3.expr.VarIntExpr in project batfish by batfish.

the class VariableSizeCollector method visitVarIntExpr.

@Override
public void visitVarIntExpr(VarIntExpr varIntExpr) {
    Field field = varIntExpr.getField();
    _variableSizes.add(Maps.immutableEntry(field.getName(), field.getSize()));
}
Also used : Field(org.batfish.z3.Field) BasicHeaderField(org.batfish.z3.BasicHeaderField)

Aggregations

EqExpr (org.batfish.z3.expr.EqExpr)6 VarIntExpr (org.batfish.z3.expr.VarIntExpr)6 BasicRuleStatement (org.batfish.z3.expr.BasicRuleStatement)4 SynthesizerInput (org.batfish.z3.SynthesizerInput)3 BooleanExpr (org.batfish.z3.expr.BooleanExpr)3 LitIntExpr (org.batfish.z3.expr.LitIntExpr)3 RuleStatement (org.batfish.z3.expr.RuleStatement)3 TransformationRuleStatement (org.batfish.z3.expr.TransformationRuleStatement)3 Test (org.junit.Test)3 ImmutableList (com.google.common.collect.ImmutableList)2 Edge (org.batfish.datamodel.Edge)2 MockSynthesizerInput (org.batfish.z3.MockSynthesizerInput)2 IntExpr (org.batfish.z3.expr.IntExpr)2 NotExpr (org.batfish.z3.expr.NotExpr)2 AclDeny (org.batfish.z3.state.AclDeny)2 AclPermit (org.batfish.z3.state.AclPermit)2 PostOutEdge (org.batfish.z3.state.PostOutEdge)2 PreOutEdge (org.batfish.z3.state.PreOutEdge)2 PreOutEdgePostNat (org.batfish.z3.state.PreOutEdgePostNat)2 ImmutableMap (com.google.common.collect.ImmutableMap)1