@Test public void testToAclLineMatchExprConversion() { PacketHeaderConstraints phc = PacketHeaderConstraints.builder() .setSrcPorts( IntegerSpace.builder() .including(new SubRange(1, 3)) .including(new SubRange(5, 6)) .build()) .setDstPorts(IntegerSpace.of(new SubRange(11, 12))) .setEcns(IntegerSpace.of(new SubRange(1, 3))) .setIpProtocols(Collections.singleton(IpProtocol.TCP)) .build(); AclLineMatchExpr hs = PacketHeaderConstraintsUtil.toAclLineMatchExpr(phc); assertEquals( and( matchSrc(UniverseIpSpace.INSTANCE), matchDst(UniverseIpSpace.INSTANCE), match( HeaderSpace.builder() .setEcns(IntegerSpace.of(new SubRange(1, 3)).enumerate()) .build()), match(HeaderSpace.builder().setIpProtocols(IpProtocol.TCP).build()), match( HeaderSpace.builder().setSrcPorts(new SubRange(1, 3), new SubRange(5, 6)).build()), match(HeaderSpace.builder().setDstPorts(new SubRange(11, 12)).build())), hs); }
public static AclLineMatchExpr toAclLineMatchExpr( PacketHeaderConstraints phc, IpSpace srcIpSpace, IpSpace dstIpSpace) { List<AclLineMatchExpr> conjuncts = Stream.of( matchSrc(srcIpSpace), matchDst(dstIpSpace), dscpsToAclLineMatchExpr(phc.getDscps()), ecnsToAclLineMatchExpr(phc.getEcns()), packetLengthToAclLineMatchExpr(phc.getPacketLengths()), fragmentOffsetsToAclLineMatchExpr(phc.getFragmentOffsets()), ipProtocolsToAclLineMatchExpr(phc.getIpProtocols()), icmpCodeToAclLineMatchExpr(phc.getIcmpCodes()), icmpTypeToAclLineMatchExpr(phc.getIcmpTypes()), srcPortsToAclLineMatchExpr(phc.getSrcPorts()), dstPortsToAclLineMatchExpr(phc.getDstPorts()), applicationsToAclLineMatchExpr(phc.getApplications()), tcpFlagsToAclLineMatchExpr(phc.getTcpFlags())) .filter(Objects::nonNull) .collect(ImmutableList.toImmutableList()); return and(conjuncts); }
PacketHeaderConstraintsUtil { public static AclLineMatchExpr toAclLineMatchExpr( PacketHeaderConstraints phc, IpSpace srcIpSpace, IpSpace dstIpSpace) { List<AclLineMatchExpr> conjuncts = Stream.of( matchSrc(srcIpSpace), matchDst(dstIpSpace), dscpsToAclLineMatchExpr(phc.getDscps()), ecnsToAclLineMatchExpr(phc.getEcns()), packetLengthToAclLineMatchExpr(phc.getPacketLengths()), fragmentOffsetsToAclLineMatchExpr(phc.getFragmentOffsets()), ipProtocolsToAclLineMatchExpr(phc.getIpProtocols()), icmpCodeToAclLineMatchExpr(phc.getIcmpCodes()), icmpTypeToAclLineMatchExpr(phc.getIcmpTypes()), srcPortsToAclLineMatchExpr(phc.getSrcPorts()), dstPortsToAclLineMatchExpr(phc.getDstPorts()), applicationsToAclLineMatchExpr(phc.getApplications()), tcpFlagsToAclLineMatchExpr(phc.getTcpFlags())) .filter(Objects::nonNull) .collect(ImmutableList.toImmutableList()); return and(conjuncts); } }
PacketHeaderConstraintsUtil { public static AclLineMatchExpr toAclLineMatchExpr( PacketHeaderConstraints phc, IpSpace srcIpSpace, IpSpace dstIpSpace) { List<AclLineMatchExpr> conjuncts = Stream.of( matchSrc(srcIpSpace), matchDst(dstIpSpace), dscpsToAclLineMatchExpr(phc.getDscps()), ecnsToAclLineMatchExpr(phc.getEcns()), packetLengthToAclLineMatchExpr(phc.getPacketLengths()), fragmentOffsetsToAclLineMatchExpr(phc.getFragmentOffsets()), ipProtocolsToAclLineMatchExpr(phc.getIpProtocols()), icmpCodeToAclLineMatchExpr(phc.getIcmpCodes()), icmpTypeToAclLineMatchExpr(phc.getIcmpTypes()), srcPortsToAclLineMatchExpr(phc.getSrcPorts()), dstPortsToAclLineMatchExpr(phc.getDstPorts()), applicationsToAclLineMatchExpr(phc.getApplications()), tcpFlagsToAclLineMatchExpr(phc.getTcpFlags())) .filter(Objects::nonNull) .collect(ImmutableList.toImmutableList()); return and(conjuncts); }  }
PacketHeaderConstraintsUtil { public static AclLineMatchExpr toAclLineMatchExpr( PacketHeaderConstraints phc, IpSpace srcIpSpace, IpSpace dstIpSpace) { List<AclLineMatchExpr> conjuncts = Stream.of( matchSrc(srcIpSpace), matchDst(dstIpSpace), dscpsToAclLineMatchExpr(phc.getDscps()), ecnsToAclLineMatchExpr(phc.getEcns()), packetLengthToAclLineMatchExpr(phc.getPacketLengths()), fragmentOffsetsToAclLineMatchExpr(phc.getFragmentOffsets()), ipProtocolsToAclLineMatchExpr(phc.getIpProtocols()), icmpCodeToAclLineMatchExpr(phc.getIcmpCodes()), icmpTypeToAclLineMatchExpr(phc.getIcmpTypes()), srcPortsToAclLineMatchExpr(phc.getSrcPorts()), dstPortsToAclLineMatchExpr(phc.getDstPorts()), applicationsToAclLineMatchExpr(phc.getApplications()), tcpFlagsToAclLineMatchExpr(phc.getTcpFlags())) .filter(Objects::nonNull) .collect(ImmutableList.toImmutableList()); return and(conjuncts); }  static AclLineMatchExpr toAclLineMatchExpr(
      PacketHeaderConstraints phc, IpSpace srcIpSpace, IpSpace dstIpSpace); static AclLineMatchExpr toAclLineMatchExpr(PacketHeaderConstraints phc); static BDD toBDD(
      BDDPacket pkt, PacketHeaderConstraints phc, IpSpace srcIpSpace, IpSpace dstIpSpace); static BDD toBDD(
      BDDPacket pkt,
      PacketHeaderConstraints phc,
      Map<String, IpSpace> namedIpSpaces,
      IpSpace srcIpSpace,
      IpSpace dstIpSpace); @VisibleForTesting static Flow.Builder toFlow(
      BDDPacket pkt, PacketHeaderConstraints phc, IpSpace srcIps, IpSpace dstIps); }
PacketHeaderConstraintsUtil { public static AclLineMatchExpr toAclLineMatchExpr( PacketHeaderConstraints phc, IpSpace srcIpSpace, IpSpace dstIpSpace) { List<AclLineMatchExpr> conjuncts = Stream.of( matchSrc(srcIpSpace), matchDst(dstIpSpace), dscpsToAclLineMatchExpr(phc.getDscps()), ecnsToAclLineMatchExpr(phc.getEcns()), packetLengthToAclLineMatchExpr(phc.getPacketLengths()), fragmentOffsetsToAclLineMatchExpr(phc.getFragmentOffsets()), ipProtocolsToAclLineMatchExpr(phc.getIpProtocols()), icmpCodeToAclLineMatchExpr(phc.getIcmpCodes()), icmpTypeToAclLineMatchExpr(phc.getIcmpTypes()), srcPortsToAclLineMatchExpr(phc.getSrcPorts()), dstPortsToAclLineMatchExpr(phc.getDstPorts()), applicationsToAclLineMatchExpr(phc.getApplications()), tcpFlagsToAclLineMatchExpr(phc.getTcpFlags())) .filter(Objects::nonNull) .collect(ImmutableList.toImmutableList()); return and(conjuncts); }  static AclLineMatchExpr toAclLineMatchExpr(
      PacketHeaderConstraints phc, IpSpace srcIpSpace, IpSpace dstIpSpace); static AclLineMatchExpr toAclLineMatchExpr(PacketHeaderConstraints phc); static BDD toBDD(
      BDDPacket pkt, PacketHeaderConstraints phc, IpSpace srcIpSpace, IpSpace dstIpSpace); static BDD toBDD(
      BDDPacket pkt,
      PacketHeaderConstraints phc,
      Map<String, IpSpace> namedIpSpaces,
      IpSpace srcIpSpace,
      IpSpace dstIpSpace); @VisibleForTesting static Flow.Builder toFlow(
      BDDPacket pkt, PacketHeaderConstraints phc, IpSpace srcIps, IpSpace dstIps); static final int DEFAULT_PACKET_LENGTH; }