use of org.batfish.z3.expr.Expr in project batfish by batfish.
the class BoolExprTransformerTest method testVisitHeaderSpaceMatchExpr.
@Test
public void testVisitHeaderSpaceMatchExpr() {
long ipCounter = 1L;
int intCounter = 1;
HeaderSpace.Builder<?, ?> hb = IpAccessListLine.builder();
BooleanExpr expr = new HeaderSpaceMatchExpr(hb.setDscps(ImmutableSet.of(intCounter++, intCounter++)).setDstIps(ImmutableSet.of(new IpWildcard(new Ip(ipCounter++)), new IpWildcard(new Ip(ipCounter++)))).setDstPorts(ImmutableSet.of(new SubRange(intCounter++, intCounter++), new SubRange(intCounter++, intCounter++))).setDstProtocols(ImmutableSet.of(Protocol.DNS, Protocol.HTTP)).setEcns(ImmutableSet.of(intCounter++, intCounter++)).setFragmentOffsets(ImmutableSet.of(new SubRange(intCounter++, intCounter++), new SubRange(intCounter++, intCounter++))).setIcmpCodes(ImmutableSet.of(new SubRange(intCounter++, intCounter++), new SubRange(intCounter++, intCounter++))).setIcmpTypes(ImmutableSet.of(new SubRange(intCounter++, intCounter++), new SubRange(intCounter++, intCounter++))).setIpProtocols(ImmutableSet.of(IpProtocol.AHP, IpProtocol.ARGUS)).setNegate(true).setNotDscps(ImmutableSet.of(intCounter++, intCounter++)).setNotDstIps(ImmutableSet.of(new IpWildcard(new Ip(ipCounter++)), new IpWildcard(new Ip(ipCounter++)))).setNotDstPorts(ImmutableSet.of(new SubRange(intCounter++, intCounter++), new SubRange(intCounter++, intCounter++))).setNotDstProtocols(ImmutableSet.of(Protocol.HTTPS, Protocol.TELNET)).setNotEcns(ImmutableSet.of(intCounter++, intCounter++)).setNotFragmentOffsets(ImmutableSet.of(new SubRange(intCounter++, intCounter++), new SubRange(intCounter++, intCounter++))).setNotIcmpCodes(ImmutableSet.of(new SubRange(intCounter++, intCounter++), new SubRange(intCounter++, intCounter++))).setNotIcmpTypes(ImmutableSet.of(new SubRange(intCounter++, intCounter++), new SubRange(intCounter++, intCounter++))).setNotIpProtocols(ImmutableSet.of(IpProtocol.BNA, IpProtocol.XNET)).setNotPacketLengths(ImmutableSet.of(new SubRange(intCounter++, intCounter++), new SubRange(intCounter++, intCounter++))).setNotSrcIps(ImmutableSet.of(new IpWildcard(new Ip(ipCounter++)), new IpWildcard(new Ip(ipCounter++)))).setNotSrcPorts(ImmutableSet.of(new SubRange(intCounter++, intCounter++), new SubRange(intCounter++, intCounter++))).setNotSrcProtocols(ImmutableSet.of(Protocol.SSH, Protocol.TCP)).setPacketLengths(ImmutableSet.of(new SubRange(intCounter++, intCounter++), new SubRange(intCounter++, intCounter++))).setSrcIps(ImmutableSet.of(new IpWildcard(new Ip(ipCounter++)), new IpWildcard(new Ip(ipCounter++)))).setSrcOrDstIps(ImmutableSet.of(new IpWildcard(new Ip(ipCounter++)), new IpWildcard(new Ip(ipCounter++)))).setSrcOrDstPorts(ImmutableSet.of(new SubRange(intCounter++, intCounter++), new SubRange(intCounter++, intCounter++))).setSrcOrDstProtocols(ImmutableSet.of(Protocol.UDP, Protocol.HTTP)).setSrcPorts(ImmutableSet.of(new SubRange(intCounter++, intCounter++), new SubRange(intCounter++, intCounter++))).setSrcProtocols(ImmutableSet.of(Protocol.HTTPS, Protocol.DNS)).setStates(ImmutableSet.of(State.ESTABLISHED, State.NEW)).setTcpFlags(ImmutableSet.of(TcpFlags.builder().setAck(true).setUseAck(true).build(), TcpFlags.builder().setUseCwr(true).build())).build());
assertThat(toBoolExpr(expr, _input, _nodContext), instanceOf(BoolExpr.class));
}
use of org.batfish.z3.expr.Expr in project batfish by batfish.
the class BoolExprTransformerTest method testVisitPrefixMatchExpr.
@Test
public void testVisitPrefixMatchExpr() {
BooleanExpr expr = new PrefixMatchExpr(BasicHeaderField.SRC_IP, Prefix.parse("1.2.3.4/5"));
assertThat(toBoolExpr(expr, _input, _nodContext), instanceOf(BoolExpr.class));
}
use of org.batfish.z3.expr.Expr in project batfish by batfish.
the class IpSpaceBooleanExprTransformerTest method testVisitUniverseIpSpace.
@Test
public void testVisitUniverseIpSpace() {
BooleanExpr expr = UniverseIpSpace.INSTANCE.accept(SRC_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
assertThat(expr, equalTo(TrueExpr.INSTANCE));
}
use of org.batfish.z3.expr.Expr in project batfish by batfish.
the class IpSpaceBooleanExprTransformerTest method testVisitAclIpSpace.
@Test
public void testVisitAclIpSpace() {
AclIpSpace ipSpace = AclIpSpace.builder().thenRejecting(UniverseIpSpace.INSTANCE).thenPermitting(EmptyIpSpace.INSTANCE).build();
BooleanExpr expr = ipSpace.accept(SRC_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
assertThat(expr, equalTo(new IfThenElse(// Matches UniverseIpSpace
TrueExpr.INSTANCE, // Reject
FalseExpr.INSTANCE, new IfThenElse(// Matches EmptyIpSpace
FalseExpr.INSTANCE, // Accept
TrueExpr.INSTANCE, // Matches nothing so reject
FalseExpr.INSTANCE))));
}
use of org.batfish.z3.expr.Expr in project batfish by batfish.
the class IpSpaceBooleanExprTransformerTest method testVisitEmptyIpSpace.
@Test
public void testVisitEmptyIpSpace() {
BooleanExpr expr = EmptyIpSpace.INSTANCE.accept(SRC_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
assertThat(expr, equalTo(FalseExpr.INSTANCE));
}
Aggregations