@Test public void testPermittedByRouteFilterList() { RouteFilterList routeFilterList = new RouteFilterList( "list", ImmutableList.of( new RouteFilterLine( LineAction.DENY, Prefix.strict("1.0.0.0/8"), new SubRange(0, 15)), new RouteFilterLine( LineAction.DENY, Prefix.strict("1.0.0.0/8"), new SubRange(25, Prefix.MAX_PREFIX_LENGTH)), new RouteFilterLine( LineAction.PERMIT, Prefix.strict("1.0.0.0/8"), new SubRange(0, Prefix.MAX_PREFIX_LENGTH)))); BDD rangeBdd = _bddPrefix.permittedByRouteFilterList(routeFilterList); BDD notRangeBdd = rangeBdd.not(); Ip matchingIp = Ip.parse("1.1.1.1"); Ip nonMatchingIp = Ip.parse("2.2.2.2"); BDD matchingPrefix8 = _bddPrefix.isPrefix(Prefix.create(matchingIp, 8)); BDD matchingPrefix24 = _bddPrefix.isPrefix(Prefix.create(matchingIp, 24)); BDD matchingPrefix32 = _bddPrefix.isPrefix(matchingIp.toPrefix()); BDD nonMatchingPrefix24 = _bddPrefix.isPrefix(Prefix.create(nonMatchingIp, 24)); assertTrue(matchingPrefix24.imp(rangeBdd).isOne()); assertTrue(matchingPrefix32.imp(notRangeBdd).isOne()); assertTrue(matchingPrefix8.imp(notRangeBdd).isOne()); assertTrue(nonMatchingPrefix24.imp(notRangeBdd).isOne()); }
public @Nonnull BDD permittedByRouteFilterList(RouteFilterList routeFilterList) { BDD result = getFactory().zero(); List<RouteFilterLine> lines = ImmutableList.copyOf(routeFilterList.getLines()).reverse(); for (RouteFilterLine line : lines) { if (!line.getIpWildcard().isPrefix()) { throw new BatfishException("non-prefix IpWildcards are unsupported"); } PrefixRange range = new PrefixRange(line.getIpWildcard().toPrefix(), line.getLengthRange()); BDD matches = inPrefixRange(range); BDD action = line.getAction() == LineAction.PERMIT ? _factory.one() : _factory.zero(); result = matches.ite(action, result); } return result; }
BDDPrefix { public @Nonnull BDD permittedByRouteFilterList(RouteFilterList routeFilterList) { BDD result = getFactory().zero(); List<RouteFilterLine> lines = ImmutableList.copyOf(routeFilterList.getLines()).reverse(); for (RouteFilterLine line : lines) { if (!line.getIpWildcard().isPrefix()) { throw new BatfishException("non-prefix IpWildcards are unsupported"); } PrefixRange range = new PrefixRange(line.getIpWildcard().toPrefix(), line.getLengthRange()); BDD matches = inPrefixRange(range); BDD action = line.getAction() == LineAction.PERMIT ? _factory.one() : _factory.zero(); result = matches.ite(action, result); } return result; } }
BDDPrefix { public @Nonnull BDD permittedByRouteFilterList(RouteFilterList routeFilterList) { BDD result = getFactory().zero(); List<RouteFilterLine> lines = ImmutableList.copyOf(routeFilterList.getLines()).reverse(); for (RouteFilterLine line : lines) { if (!line.getIpWildcard().isPrefix()) { throw new BatfishException("non-prefix IpWildcards are unsupported"); } PrefixRange range = new PrefixRange(line.getIpWildcard().toPrefix(), line.getLengthRange()); BDD matches = inPrefixRange(range); BDD action = line.getAction() == LineAction.PERMIT ? _factory.one() : _factory.zero(); result = matches.ite(action, result); } return result; } BDDPrefix(BDDInteger ip, BDDInteger prefixLength); }
BDDPrefix { public @Nonnull BDD permittedByRouteFilterList(RouteFilterList routeFilterList) { BDD result = getFactory().zero(); List<RouteFilterLine> lines = ImmutableList.copyOf(routeFilterList.getLines()).reverse(); for (RouteFilterLine line : lines) { if (!line.getIpWildcard().isPrefix()) { throw new BatfishException("non-prefix IpWildcards are unsupported"); } PrefixRange range = new PrefixRange(line.getIpWildcard().toPrefix(), line.getLengthRange()); BDD matches = inPrefixRange(range); BDD action = line.getAction() == LineAction.PERMIT ? _factory.one() : _factory.zero(); result = matches.ite(action, result); } return result; } BDDPrefix(BDDInteger ip, BDDInteger prefixLength); @Override boolean equals(Object o); @Override int hashCode(); @Nonnull BDDFactory getFactory(); @Nonnull BDDInteger getIp(); @Nonnull BDDInteger getPrefixLength(); @Nonnull BDD inPrefixRange(PrefixRange prefixRange); @Nonnull BDD isPrefix(Prefix prefix); @Nonnull BDD permittedByRouteFilterList(RouteFilterList routeFilterList); }
BDDPrefix { public @Nonnull BDD permittedByRouteFilterList(RouteFilterList routeFilterList) { BDD result = getFactory().zero(); List<RouteFilterLine> lines = ImmutableList.copyOf(routeFilterList.getLines()).reverse(); for (RouteFilterLine line : lines) { if (!line.getIpWildcard().isPrefix()) { throw new BatfishException("non-prefix IpWildcards are unsupported"); } PrefixRange range = new PrefixRange(line.getIpWildcard().toPrefix(), line.getLengthRange()); BDD matches = inPrefixRange(range); BDD action = line.getAction() == LineAction.PERMIT ? _factory.one() : _factory.zero(); result = matches.ite(action, result); } return result; } BDDPrefix(BDDInteger ip, BDDInteger prefixLength); @Override boolean equals(Object o); @Override int hashCode(); @Nonnull BDDFactory getFactory(); @Nonnull BDDInteger getIp(); @Nonnull BDDInteger getPrefixLength(); @Nonnull BDD inPrefixRange(PrefixRange prefixRange); @Nonnull BDD isPrefix(Prefix prefix); @Nonnull BDD permittedByRouteFilterList(RouteFilterList routeFilterList);  }