Search in sources :

Example 1 with PostIn

use of org.batfish.z3.state.PostIn in project batfish by batfish.

the class DefaultTransitionGeneratorTest method testVisitPostIn.

@Test
public void testVisitPostIn() {
    SynthesizerInput input = MockSynthesizerInput.builder().setEnabledNodes(ImmutableSet.of(NODE1, NODE2)).setEnabledInterfaces(ImmutableMap.of(NODE1, ImmutableSet.of(INTERFACE1, INTERFACE2), NODE2, ImmutableSet.of(INTERFACE1, INTERFACE2))).build();
    Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(PostIn.State.INSTANCE)));
    // CopyOriginate
    assertThat(rules, hasItem(new BasicRuleStatement(new Originate(NODE1), new PostIn(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(new Originate(NODE2), new PostIn(NODE2))));
    // ProjectPostInInterface
    assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE1, INTERFACE1), new PostIn(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE1, INTERFACE2), new PostIn(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE2, INTERFACE1), new PostIn(NODE2))));
    assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE2, INTERFACE2), new PostIn(NODE2))));
}
Also used : PostIn(org.batfish.z3.state.PostIn) 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) PostInInterface(org.batfish.z3.state.PostInInterface) Originate(org.batfish.z3.state.Originate) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Example 2 with PostIn

use of org.batfish.z3.state.PostIn in project batfish by batfish.

the class DefaultTransitionGenerator method visitPostIn.

@Override
public void visitPostIn(PostIn.State postIn) {
    // CopyOriginate
    _input.getEnabledNodes().stream().map(hostname -> new BasicRuleStatement(new Originate(hostname), new PostIn(hostname))).forEach(_rules::add);
    // ProjectPostInInterface
    _input.getEnabledInterfaces().entrySet().stream().flatMap(enabledInterfacesByHostnameEntry -> {
        String hostname = enabledInterfacesByHostnameEntry.getKey();
        return enabledInterfacesByHostnameEntry.getValue().stream().map(ifaceName -> new BasicRuleStatement(new PostInInterface(hostname, ifaceName), new PostIn(hostname)));
    }).forEach(_rules::add);
}
Also used : DropAclIn(org.batfish.z3.state.DropAclIn) NodeDropAclOut(org.batfish.z3.state.NodeDropAclOut) AclLineMatch(org.batfish.z3.state.AclLineMatch) Drop(org.batfish.z3.state.Drop) NodeDropAcl(org.batfish.z3.state.NodeDropAcl) NodeDropNoRoute(org.batfish.z3.state.NodeDropNoRoute) NumberedQuery(org.batfish.z3.state.NumberedQuery) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) PostIn(org.batfish.z3.state.PostIn) AclLineNoMatch(org.batfish.z3.state.AclLineNoMatch) HeaderSpaceMatchExpr(org.batfish.z3.expr.HeaderSpaceMatchExpr) State(org.batfish.z3.expr.StateExpr.State) Originate(org.batfish.z3.state.Originate) NodeDropNullRoute(org.batfish.z3.state.NodeDropNullRoute) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Set(java.util.Set) Query(org.batfish.z3.state.Query) PostOutEdge(org.batfish.z3.state.PostOutEdge) List(java.util.List) PreOutEdgePostNat(org.batfish.z3.state.PreOutEdgePostNat) OriginateVrf(org.batfish.z3.state.OriginateVrf) PreOutEdge(org.batfish.z3.state.PreOutEdge) Entry(java.util.Map.Entry) NodeDrop(org.batfish.z3.state.NodeDrop) NodeNeighborUnreachable(org.batfish.z3.state.NodeNeighborUnreachable) IpWildcard(org.batfish.datamodel.IpWildcard) TransformationHeaderField(org.batfish.z3.TransformationHeaderField) TrueExpr(org.batfish.z3.expr.TrueExpr) DropAcl(org.batfish.z3.state.DropAcl) DropNullRoute(org.batfish.z3.state.DropNullRoute) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) NodeAccept(org.batfish.z3.state.NodeAccept) ImmutableList(com.google.common.collect.ImmutableList) StateExpr(org.batfish.z3.expr.StateExpr) LineAction(org.batfish.datamodel.LineAction) RuleStatement(org.batfish.z3.expr.RuleStatement) DropAclOut(org.batfish.z3.state.DropAclOut) Debug(org.batfish.z3.state.Debug) DropNoRoute(org.batfish.z3.state.DropNoRoute) BooleanExpr(org.batfish.z3.expr.BooleanExpr) Accept(org.batfish.z3.state.Accept) NodeDropAclIn(org.batfish.z3.state.NodeDropAclIn) PreOut(org.batfish.z3.state.PreOut) AclDeny(org.batfish.z3.state.AclDeny) NotExpr(org.batfish.z3.expr.NotExpr) AclPermit(org.batfish.z3.state.AclPermit) VarIntExpr(org.batfish.z3.expr.VarIntExpr) PreInInterface(org.batfish.z3.state.PreInInterface) PostInVrf(org.batfish.z3.state.PostInVrf) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) NeighborUnreachable(org.batfish.z3.state.NeighborUnreachable) EqExpr(org.batfish.z3.expr.EqExpr) PostInInterface(org.batfish.z3.state.PostInInterface) PostIn(org.batfish.z3.state.PostIn) PostInInterface(org.batfish.z3.state.PostInInterface) Originate(org.batfish.z3.state.Originate) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement)

Example 3 with PostIn

use of org.batfish.z3.state.PostIn in project batfish by batfish.

the class DefaultTransitionGeneratorTest method testVisitPreOut.

@Test
public void testVisitPreOut() {
    SynthesizerInput input = MockSynthesizerInput.builder().setIpsByHostname(ImmutableMap.of(NODE1, ImmutableSet.of(IP1, IP2), NODE2, ImmutableSet.of(IP3, IP4))).build();
    Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(PreOut.State.INSTANCE)));
    // PostInNotMine
    assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(HeaderSpaceMatchExpr.matchDstIp(ImmutableSet.of(new IpWildcard(IP1), new IpWildcard(IP2)))), ImmutableSet.of(new PostIn(NODE1)), new PreOut(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(HeaderSpaceMatchExpr.matchDstIp(ImmutableSet.of(new IpWildcard(IP3), new IpWildcard(IP4)))), ImmutableSet.of(new PostIn(NODE2)), new PreOut(NODE2))));
}
Also used : IpWildcard(org.batfish.datamodel.IpWildcard) PostIn(org.batfish.z3.state.PostIn) PreOut(org.batfish.z3.state.PreOut) 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) NotExpr(org.batfish.z3.expr.NotExpr) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Example 4 with PostIn

use of org.batfish.z3.state.PostIn in project batfish by batfish.

the class DefaultTransitionGeneratorTest method testVisitNodeAccept.

@Test
public void testVisitNodeAccept() {
    SynthesizerInput input = MockSynthesizerInput.builder().setEnabledNodes(ImmutableSet.of(NODE1, NODE2)).setIpsByHostname(ImmutableMap.of(NODE1, ImmutableSet.of(IP1, IP2), NODE2, ImmutableSet.of(IP3, IP4))).build();
    Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(NodeAccept.State.INSTANCE)));
    // PostInForMe
    assertThat(rules, hasItem(new BasicRuleStatement(HeaderSpaceMatchExpr.matchDstIp(ImmutableSet.of(new IpWildcard(IP1), new IpWildcard(IP2))), ImmutableSet.of(new PostIn(NODE1)), new NodeAccept(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(HeaderSpaceMatchExpr.matchDstIp(ImmutableSet.of(new IpWildcard(IP3), new IpWildcard(IP4))), ImmutableSet.of(new PostIn(NODE2)), new NodeAccept(NODE2))));
}
Also used : IpWildcard(org.batfish.datamodel.IpWildcard) PostIn(org.batfish.z3.state.PostIn) 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) NodeAccept(org.batfish.z3.state.NodeAccept) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Aggregations

SynthesizerInput (org.batfish.z3.SynthesizerInput)4 BasicRuleStatement (org.batfish.z3.expr.BasicRuleStatement)4 RuleStatement (org.batfish.z3.expr.RuleStatement)4 TransformationRuleStatement (org.batfish.z3.expr.TransformationRuleStatement)4 PostIn (org.batfish.z3.state.PostIn)4 IpWildcard (org.batfish.datamodel.IpWildcard)3 MockSynthesizerInput (org.batfish.z3.MockSynthesizerInput)3 NotExpr (org.batfish.z3.expr.NotExpr)2 Originate (org.batfish.z3.state.Originate)2 PostInInterface (org.batfish.z3.state.PostInInterface)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 LineAction (org.batfish.datamodel.LineAction)1