@Test public void testVisitCommunityAcl() { CommunityAcl cacl = new CommunityAcl( ImmutableList.of( new CommunityAclLine( LineAction.DENY, new CommunityIs(StandardCommunity.parse("20:30"))), new CommunityAclLine( LineAction.PERMIT, new CommunityMatchRegex(ColonSeparatedRendering.instance(), "^20:")))); BDD result = _communityMatchExprToBDD.visitCommunityAcl(cacl, _arg); CommunityVar cvar1 = CommunityVar.from(StandardCommunity.parse("20:30")); CommunityVar cvar2 = CommunityVar.from("^20:"); assertEquals(cvarToBDD(cvar1).not().and(cvarToBDD(cvar2)), result); }
@Override public BDD visitCommunityAcl(CommunityAcl communityAcl, Arg arg) { List<CommunityAclLine> lines = new ArrayList<>(communityAcl.getLines()); Collections.reverse(lines); BDD acc = BDDRoute.factory.zero(); for (CommunityAclLine line : lines) { boolean action = (line.getAction() == LineAction.PERMIT); BDD lineBDD = line.getCommunityMatchExpr().accept(this, arg); acc = lineBDD.ite(arg.getTransferBDD().mkBDD(action), acc); } return acc; }
CommunityMatchExprToBDD implements CommunityMatchExprVisitor<BDD, Arg> { @Override public BDD visitCommunityAcl(CommunityAcl communityAcl, Arg arg) { List<CommunityAclLine> lines = new ArrayList<>(communityAcl.getLines()); Collections.reverse(lines); BDD acc = BDDRoute.factory.zero(); for (CommunityAclLine line : lines) { boolean action = (line.getAction() == LineAction.PERMIT); BDD lineBDD = line.getCommunityMatchExpr().accept(this, arg); acc = lineBDD.ite(arg.getTransferBDD().mkBDD(action), acc); } return acc; } }
CommunityMatchExprToBDD implements CommunityMatchExprVisitor<BDD, Arg> { @Override public BDD visitCommunityAcl(CommunityAcl communityAcl, Arg arg) { List<CommunityAclLine> lines = new ArrayList<>(communityAcl.getLines()); Collections.reverse(lines); BDD acc = BDDRoute.factory.zero(); for (CommunityAclLine line : lines) { boolean action = (line.getAction() == LineAction.PERMIT); BDD lineBDD = line.getCommunityMatchExpr().accept(this, arg); acc = lineBDD.ite(arg.getTransferBDD().mkBDD(action), acc); } return acc; }  }
CommunityMatchExprToBDD implements CommunityMatchExprVisitor<BDD, Arg> { @Override public BDD visitCommunityAcl(CommunityAcl communityAcl, Arg arg) { List<CommunityAclLine> lines = new ArrayList<>(communityAcl.getLines()); Collections.reverse(lines); BDD acc = BDDRoute.factory.zero(); for (CommunityAclLine line : lines) { boolean action = (line.getAction() == LineAction.PERMIT); BDD lineBDD = line.getCommunityMatchExpr().accept(this, arg); acc = lineBDD.ite(arg.getTransferBDD().mkBDD(action), acc); } return acc; }  @Override BDD visitAllExtendedCommunities(AllExtendedCommunities allExtendedCommunities, Arg arg); @Override BDD visitAllLargeCommunities(AllLargeCommunities allLargeCommunities, Arg arg); @Override BDD visitAllStandardCommunities(AllStandardCommunities allStandardCommunities, Arg arg); @Override BDD visitCommunityAcl(CommunityAcl communityAcl, Arg arg); @Override BDD visitCommunityIn(CommunityIn communityIn, Arg arg); @Override BDD visitCommunityIs(CommunityIs communityIs, Arg arg); @Override BDD visitCommunityMatchAll(CommunityMatchAll communityMatchAll, Arg arg); @Override BDD visitCommunityMatchAny(CommunityMatchAny communityMatchAny, Arg arg); @Override BDD visitCommunityMatchExprReference(
      CommunityMatchExprReference communityMatchExprReference, Arg arg); @Override BDD visitCommunityMatchRegex(CommunityMatchRegex communityMatchRegex, Arg arg); @Override BDD visitCommunityNot(CommunityNot communityNot, Arg arg); @Override BDD visitExtendedCommunityGlobalAdministratorHighMatch(
      ExtendedCommunityGlobalAdministratorHighMatch extendedCommunityGlobalAdministratorHighMatch,
      Arg arg); @Override BDD visitExtendedCommunityGlobalAdministratorLowMatch(
      ExtendedCommunityGlobalAdministratorLowMatch extendedCommunityGlobalAdministratorLowMatch,
      Arg arg); @Override BDD visitExtendedCommunityGlobalAdministratorMatch(
      ExtendedCommunityGlobalAdministratorMatch extendedCommunityGlobalAdministratorMatch,
      Arg arg); @Override BDD visitExtendedCommunityLocalAdministratorMatch(
      ExtendedCommunityLocalAdministratorMatch extendedCommunityLocalAdministratorMatch, Arg arg); @Override BDD visitRouteTargetExtendedCommunities(
      RouteTargetExtendedCommunities routeTargetExtendedCommunities, Arg arg); @Override BDD visitSiteOfOriginExtendedCommunities(
      SiteOfOriginExtendedCommunities siteOfOriginExtendedCommunities, Arg arg); @Override BDD visitStandardCommunityHighMatch(
      StandardCommunityHighMatch standardCommunityHighMatch, Arg arg); @Override BDD visitStandardCommunityLowMatch(
      StandardCommunityLowMatch standardCommunityLowMatch, Arg arg); @Override BDD visitVpnDistinguisherExtendedCommunities(
      VpnDistinguisherExtendedCommunities vpnDistinguisherExtendedCommunities, Arg arg); }
CommunityMatchExprToBDD implements CommunityMatchExprVisitor<BDD, Arg> { @Override public BDD visitCommunityAcl(CommunityAcl communityAcl, Arg arg) { List<CommunityAclLine> lines = new ArrayList<>(communityAcl.getLines()); Collections.reverse(lines); BDD acc = BDDRoute.factory.zero(); for (CommunityAclLine line : lines) { boolean action = (line.getAction() == LineAction.PERMIT); BDD lineBDD = line.getCommunityMatchExpr().accept(this, arg); acc = lineBDD.ite(arg.getTransferBDD().mkBDD(action), acc); } return acc; }  @Override BDD visitAllExtendedCommunities(AllExtendedCommunities allExtendedCommunities, Arg arg); @Override BDD visitAllLargeCommunities(AllLargeCommunities allLargeCommunities, Arg arg); @Override BDD visitAllStandardCommunities(AllStandardCommunities allStandardCommunities, Arg arg); @Override BDD visitCommunityAcl(CommunityAcl communityAcl, Arg arg); @Override BDD visitCommunityIn(CommunityIn communityIn, Arg arg); @Override BDD visitCommunityIs(CommunityIs communityIs, Arg arg); @Override BDD visitCommunityMatchAll(CommunityMatchAll communityMatchAll, Arg arg); @Override BDD visitCommunityMatchAny(CommunityMatchAny communityMatchAny, Arg arg); @Override BDD visitCommunityMatchExprReference(
      CommunityMatchExprReference communityMatchExprReference, Arg arg); @Override BDD visitCommunityMatchRegex(CommunityMatchRegex communityMatchRegex, Arg arg); @Override BDD visitCommunityNot(CommunityNot communityNot, Arg arg); @Override BDD visitExtendedCommunityGlobalAdministratorHighMatch(
      ExtendedCommunityGlobalAdministratorHighMatch extendedCommunityGlobalAdministratorHighMatch,
      Arg arg); @Override BDD visitExtendedCommunityGlobalAdministratorLowMatch(
      ExtendedCommunityGlobalAdministratorLowMatch extendedCommunityGlobalAdministratorLowMatch,
      Arg arg); @Override BDD visitExtendedCommunityGlobalAdministratorMatch(
      ExtendedCommunityGlobalAdministratorMatch extendedCommunityGlobalAdministratorMatch,
      Arg arg); @Override BDD visitExtendedCommunityLocalAdministratorMatch(
      ExtendedCommunityLocalAdministratorMatch extendedCommunityLocalAdministratorMatch, Arg arg); @Override BDD visitRouteTargetExtendedCommunities(
      RouteTargetExtendedCommunities routeTargetExtendedCommunities, Arg arg); @Override BDD visitSiteOfOriginExtendedCommunities(
      SiteOfOriginExtendedCommunities siteOfOriginExtendedCommunities, Arg arg); @Override BDD visitStandardCommunityHighMatch(
      StandardCommunityHighMatch standardCommunityHighMatch, Arg arg); @Override BDD visitStandardCommunityLowMatch(
      StandardCommunityLowMatch standardCommunityLowMatch, Arg arg); @Override BDD visitVpnDistinguisherExtendedCommunities(
      VpnDistinguisherExtendedCommunities vpnDistinguisherExtendedCommunities, Arg arg);  }