@Test public void testReachAndMatchLines() { Prefix p32 = Prefix.parse("1.1.1.1/32"); Prefix p24 = Prefix.parse("1.1.1.0/24"); Prefix p16 = Prefix.parse("1.1.0.0/16"); Prefix p8 = Prefix.parse("1.0.0.0/8"); IpAccessListToBdd aclToBdd = new IpAccessListToBddImpl( PKT, BDDSourceManager.empty(PKT), ImmutableMap.of(), ImmutableMap.of()); IpSpaceToBDD dstToBdd = aclToBdd.getHeaderSpaceToBDD().getDstIpSpaceToBdd(); BDD bdd32 = dstToBdd.toBDD(p32); BDD bdd24 = dstToBdd.toBDD(p24); BDD bdd16 = dstToBdd.toBDD(p16); BDD bdd8 = dstToBdd.toBDD(p8); List<PermitAndDenyBdds> matchLines1 = aclToBdd.reachAndMatchLines( aclWithLines( rejectingDst(p32), acceptingDst(p24), rejectingDst(p16), acceptingDst(p8))); assertThat( matchLines1, contains( new PermitAndDenyBdds(ZERO, bdd32), new PermitAndDenyBdds(bdd32.not().and(bdd24), ZERO), new PermitAndDenyBdds(ZERO, bdd24.not().and(bdd16)), new PermitAndDenyBdds(bdd16.not().and(bdd8), ZERO), new PermitAndDenyBdds(ZERO, bdd8.not()))); }
public List<PermitAndDenyBdds> reachAndMatchLines(IpAccessList acl) { ImmutableList.Builder<PermitAndDenyBdds> bdds = ImmutableList.builder(); BDD reach = _pkt.getFactory().one(); for (AclLine line : acl.getLines()) { PermitAndDenyBdds match = convert(line); bdds.add(match.and(reach)); reach = reach.diff(match.getMatchBdd()); } bdds.add(new PermitAndDenyBdds(_pkt.getFactory().zero(), reach)); return bdds.build(); }
IpAccessListToBdd { public List<PermitAndDenyBdds> reachAndMatchLines(IpAccessList acl) { ImmutableList.Builder<PermitAndDenyBdds> bdds = ImmutableList.builder(); BDD reach = _pkt.getFactory().one(); for (AclLine line : acl.getLines()) { PermitAndDenyBdds match = convert(line); bdds.add(match.and(reach)); reach = reach.diff(match.getMatchBdd()); } bdds.add(new PermitAndDenyBdds(_pkt.getFactory().zero(), reach)); return bdds.build(); } }
IpAccessListToBdd { public List<PermitAndDenyBdds> reachAndMatchLines(IpAccessList acl) { ImmutableList.Builder<PermitAndDenyBdds> bdds = ImmutableList.builder(); BDD reach = _pkt.getFactory().one(); for (AclLine line : acl.getLines()) { PermitAndDenyBdds match = convert(line); bdds.add(match.and(reach)); reach = reach.diff(match.getMatchBdd()); } bdds.add(new PermitAndDenyBdds(_pkt.getFactory().zero(), reach)); return bdds.build(); } protected  IpAccessListToBdd(
      @Nonnull BDDPacket pkt,
      @Nonnull BDDSourceManager bddSrcManager,
      @Nonnull Map<String, IpAccessList> aclEnv,
      @Nonnull Map<String, IpSpace> ipSpaceEnv); protected  IpAccessListToBdd(
      @Nonnull BDDPacket pkt,
      @Nonnull BDDSourceManager bddSrcManager,
      @Nonnull HeaderSpaceToBDD headerSpaceToBDD,
      @Nonnull Map<String, IpAccessList> aclEnv); }
IpAccessListToBdd { public List<PermitAndDenyBdds> reachAndMatchLines(IpAccessList acl) { ImmutableList.Builder<PermitAndDenyBdds> bdds = ImmutableList.builder(); BDD reach = _pkt.getFactory().one(); for (AclLine line : acl.getLines()) { PermitAndDenyBdds match = convert(line); bdds.add(match.and(reach)); reach = reach.diff(match.getMatchBdd()); } bdds.add(new PermitAndDenyBdds(_pkt.getFactory().zero(), reach)); return bdds.build(); } protected  IpAccessListToBdd(
      @Nonnull BDDPacket pkt,
      @Nonnull BDDSourceManager bddSrcManager,
      @Nonnull Map<String, IpAccessList> aclEnv,
      @Nonnull Map<String, IpSpace> ipSpaceEnv); protected  IpAccessListToBdd(
      @Nonnull BDDPacket pkt,
      @Nonnull BDDSourceManager bddSrcManager,
      @Nonnull HeaderSpaceToBDD headerSpaceToBDD,
      @Nonnull Map<String, IpAccessList> aclEnv); static Map<String, BDD> toBdds(
      BDDPacket pkt,
      Collection<IpAccessList> aclsToConvert,
      Map<String, IpAccessList> aclEnv,
      Map<String, IpSpace> ipSpaceEnv,
      BDDSourceManager bddSrcManager); static BDD toBDD(
      BDDPacket pkt,
      IpAccessList acl,
      Map<String, IpAccessList> aclEnv,
      Map<String, IpSpace> ipSpaceEnv,
      BDDSourceManager bddSrcManager); static BDD toBDD(BDDPacket pkt, IpAccessList acl); abstract BDD toBdd(AclLineMatchExpr expr); abstract PermitAndDenyBdds toPermitAndDenyBdds(AclLine line); final BDDPacket getBDDPacket(); @Nonnull final HeaderSpaceToBDD getHeaderSpaceToBDD(); @Nonnull final BDD toBdd(IpAccessList acl); List<PermitAndDenyBdds> reachAndMatchLines(IpAccessList acl); }
IpAccessListToBdd { public List<PermitAndDenyBdds> reachAndMatchLines(IpAccessList acl) { ImmutableList.Builder<PermitAndDenyBdds> bdds = ImmutableList.builder(); BDD reach = _pkt.getFactory().one(); for (AclLine line : acl.getLines()) { PermitAndDenyBdds match = convert(line); bdds.add(match.and(reach)); reach = reach.diff(match.getMatchBdd()); } bdds.add(new PermitAndDenyBdds(_pkt.getFactory().zero(), reach)); return bdds.build(); } protected  IpAccessListToBdd(
      @Nonnull BDDPacket pkt,
      @Nonnull BDDSourceManager bddSrcManager,
      @Nonnull Map<String, IpAccessList> aclEnv,
      @Nonnull Map<String, IpSpace> ipSpaceEnv); protected  IpAccessListToBdd(
      @Nonnull BDDPacket pkt,
      @Nonnull BDDSourceManager bddSrcManager,
      @Nonnull HeaderSpaceToBDD headerSpaceToBDD,
      @Nonnull Map<String, IpAccessList> aclEnv); static Map<String, BDD> toBdds(
      BDDPacket pkt,
      Collection<IpAccessList> aclsToConvert,
      Map<String, IpAccessList> aclEnv,
      Map<String, IpSpace> ipSpaceEnv,
      BDDSourceManager bddSrcManager); static BDD toBDD(
      BDDPacket pkt,
      IpAccessList acl,
      Map<String, IpAccessList> aclEnv,
      Map<String, IpSpace> ipSpaceEnv,
      BDDSourceManager bddSrcManager); static BDD toBDD(BDDPacket pkt, IpAccessList acl); abstract BDD toBdd(AclLineMatchExpr expr); abstract PermitAndDenyBdds toPermitAndDenyBdds(AclLine line); final BDDPacket getBDDPacket(); @Nonnull final HeaderSpaceToBDD getHeaderSpaceToBDD(); @Nonnull final BDD toBdd(IpAccessList acl); List<PermitAndDenyBdds> reachAndMatchLines(IpAccessList acl);  }