@Test public void testMatchAsPath() { _baseConfig.setAsPathAccessLists( ImmutableMap.of( AS_PATH_NAME, new AsPathAccessList( AS_PATH_NAME, ImmutableList.of( new AsPathAccessListLine(LineAction.PERMIT, " 40$"), new AsPathAccessListLine(LineAction.DENY, "^$"))))); _policyBuilder.addStatement( new If( new MatchAsPath(new NamedAsPathSet(AS_PATH_NAME)), ImmutableList.of(new StaticStatement(Statements.ExitAccept)))); RoutingPolicy policy = _policyBuilder.build(); _g = new Graph(_batfish, _batfish.getSnapshot(), true); TransferBDD tbdd = new TransferBDD(_g, _baseConfig, policy.getStatements()); TransferReturn result = tbdd.compute(ImmutableSet.of()).getReturnValue(); BDD acceptedAnnouncements = result.getSecond(); BDDRoute outAnnouncements = result.getFirst(); BDDRoute anyRouteWithAPs = new BDDRoute(_g); BDD[] aps = anyRouteWithAPs.getAsPathRegexAtomicPredicates(); Integer ap = _g.getAsPathRegexAtomicPredicates() .getRegexAtomicPredicates() .get(new SymbolicAsPathRegex(" 40$")) .iterator() .next(); BDD expectedBDD = aps[ap]; assertEquals(expectedBDD, acceptedAnnouncements); assertEquals(tbdd.iteZero(acceptedAnnouncements, anyRouteWithAPs), outAnnouncements); }
private BDD matchAsPath( TransferParam<BDDRoute> p, Configuration conf, AsPathSetExpr e, BDDRoute other) { if (e instanceof NamedAsPathSet) { NamedAsPathSet namedAsPathSet = (NamedAsPathSet) e; AsPathAccessList accessList = conf.getAsPathAccessLists().get(namedAsPathSet.getName()); p.debug("Named As Path Set: " + namedAsPathSet.getName()); return matchAsPathAccessList(accessList, other); } throw new BatfishException("Unhandled match as-path expression " + e); }
TransferBDD { private BDD matchAsPath( TransferParam<BDDRoute> p, Configuration conf, AsPathSetExpr e, BDDRoute other) { if (e instanceof NamedAsPathSet) { NamedAsPathSet namedAsPathSet = (NamedAsPathSet) e; AsPathAccessList accessList = conf.getAsPathAccessLists().get(namedAsPathSet.getName()); p.debug("Named As Path Set: " + namedAsPathSet.getName()); return matchAsPathAccessList(accessList, other); } throw new BatfishException("Unhandled match as-path expression " + e); } }
TransferBDD { private BDD matchAsPath( TransferParam<BDDRoute> p, Configuration conf, AsPathSetExpr e, BDDRoute other) { if (e instanceof NamedAsPathSet) { NamedAsPathSet namedAsPathSet = (NamedAsPathSet) e; AsPathAccessList accessList = conf.getAsPathAccessLists().get(namedAsPathSet.getName()); p.debug("Named As Path Set: " + namedAsPathSet.getName()); return matchAsPathAccessList(accessList, other); } throw new BatfishException("Unhandled match as-path expression " + e); } TransferBDD(Graph g, Configuration conf, List<Statement> statements); }
TransferBDD { private BDD matchAsPath( TransferParam<BDDRoute> p, Configuration conf, AsPathSetExpr e, BDDRoute other) { if (e instanceof NamedAsPathSet) { NamedAsPathSet namedAsPathSet = (NamedAsPathSet) e; AsPathAccessList accessList = conf.getAsPathAccessLists().get(namedAsPathSet.getName()); p.debug("Named As Path Set: " + namedAsPathSet.getName()); return matchAsPathAccessList(accessList, other); } throw new BatfishException("Unhandled match as-path expression " + e); } TransferBDD(Graph g, Configuration conf, List<Statement> statements); static BDD firstBitsEqual(BDD[] bits, Prefix p, int length); static BDD isRelevantFor(BDDRoute record, PrefixRange range); TransferResult compute(@Nullable Set<Prefix> ignoredNetworks); Map<CommunityVar, Set<Integer>> getCommunityAtomicPredicates(); Configuration getConfiguration(); Graph getGraph(); }
TransferBDD { private BDD matchAsPath( TransferParam<BDDRoute> p, Configuration conf, AsPathSetExpr e, BDDRoute other) { if (e instanceof NamedAsPathSet) { NamedAsPathSet namedAsPathSet = (NamedAsPathSet) e; AsPathAccessList accessList = conf.getAsPathAccessLists().get(namedAsPathSet.getName()); p.debug("Named As Path Set: " + namedAsPathSet.getName()); return matchAsPathAccessList(accessList, other); } throw new BatfishException("Unhandled match as-path expression " + e); } TransferBDD(Graph g, Configuration conf, List<Statement> statements); static BDD firstBitsEqual(BDD[] bits, Prefix p, int length); static BDD isRelevantFor(BDDRoute record, PrefixRange range); TransferResult compute(@Nullable Set<Prefix> ignoredNetworks); Map<CommunityVar, Set<Integer>> getCommunityAtomicPredicates(); Configuration getConfiguration(); Graph getGraph();  }