private BoolExpr toBoolExpr(AclLineMatchExpr matchExpr) { return matchExpr.accept(this); }
public static boolean matches( AclLineMatchExpr item, Flow flow, String srcInterface, Map<String, IpAccessList> availableAcls, Map<String, IpSpace> namedIpSpaces) { return item.accept(new Evaluator(flow, srcInterface, availableAcls, namedIpSpaces)); }
public Boolean dependsOnSourceInterface(IpAccessList ipAccessList) { return ipAccessList.getLines().stream() .map(IpAccessListLine::getMatchCondition) .anyMatch(expr -> expr.accept(this)); }
@Override public Boolean visitNotMatchExpr(NotMatchExpr notMatchExpr) { return notMatchExpr.getOperand().accept(this); }
@Override public Boolean visitNotMatchExpr(NotMatchExpr notMatchExpr) { return !notMatchExpr.getOperand().accept(this); }
@Override public Boolean visitAndMatchExpr(AndMatchExpr andMatchExpr) { return andMatchExpr.getConjuncts().stream().allMatch(c -> c.accept(this)); }
@Override public Boolean visitAndMatchExpr(AndMatchExpr andMatchExpr) { return andMatchExpr.getConjuncts().stream().anyMatch(expr -> expr.accept(this)); }
/** * This method is the public API of the class. It normalizes the input {@link AclLineMatchExpr}. */ public static AclLineMatchExpr normalize(IpAccessListToBDD toBDD, AclLineMatchExpr expr) { AclLineMatchExprNormalizer normalizer = new AclLineMatchExprNormalizer(toBDD); expr.accept(normalizer); Set<AclLineMatchExpr> disjuncts = normalizer._conjunctsBuilders.stream() .filter(conjunctsBuilder -> !conjunctsBuilder.unsat()) .map(ConjunctsBuilder::build) .collect(ImmutableSortedSet.toImmutableSortedSet(Ordering.natural())); return disjuncts.contains(TRUE) ? TRUE : or(disjuncts); }
@Override public Boolean visitOrMatchExpr(OrMatchExpr orMatchExpr) { return orMatchExpr.getDisjuncts().stream().anyMatch(d -> d.accept(this)); }
@Override public Boolean visitOrMatchExpr(OrMatchExpr orMatchExpr) { return orMatchExpr.getDisjuncts().stream().anyMatch(expr -> expr.accept(this)); }
@Override public final AclLineMatchExpr visitNotMatchExpr(NotMatchExpr notMatchExpr) { AclLineMatchExpr subExpr = notMatchExpr.getOperand().accept(this); if (subExpr == TrueExpr.INSTANCE) { return FalseExpr.INSTANCE; } else if (subExpr == FalseExpr.INSTANCE) { return TrueExpr.INSTANCE; } else { return new NotMatchExpr(subExpr); } }
@Override public AclLineMatchExpr visitNotMatchExpr(NotMatchExpr notMatchExpr) { return new NotMatchExpr(notMatchExpr.getOperand().accept(this)); }
@Override public AclLineMatchExpr visitNotMatchExpr(NotMatchExpr notMatchExpr) { return new NotMatchExpr(notMatchExpr.getOperand().accept(this)); }
@Override public BoolExpr visitNotMatchExpr(NotMatchExpr notMatchExpr) { return _context.mkNot(notMatchExpr.getOperand().accept(this)); }
@Override public BooleanExpr visitNotMatchExpr(NotMatchExpr notMatchExpr) { return new NotExpr(notMatchExpr.getOperand().accept(this)); }
public final Optional<IpAccessListLine> specialize(IpAccessListLine ipAccessListLine) { AclLineMatchExpr aclLineMatchExpr = ipAccessListLine.getMatchCondition().accept(this); return aclLineMatchExpr == FALSE ? Optional.empty() : Optional.of(ipAccessListLine.toBuilder().setMatchCondition(aclLineMatchExpr).build()); }
@Override public Boolean visitAndMatchExpr(AndMatchExpr andMatchExpr) { return andMatchExpr.getConjuncts().stream() .allMatch( c -> { newTrace(); Boolean result = c.accept(this); endTrace(); return result; }); }
@Override public Void visitNotMatchExpr(NotMatchExpr notMatchExpr) { AclLineMatchExpr negatedOperand = Negate.negate(notMatchExpr.getOperand()); if (negatedOperand instanceof NotMatchExpr) { // negated leaf node. rather than recurse, just add to the conjuctsBuilders. addConstraint(notMatchExpr); } else { negatedOperand.accept(this); } return null; }
@Override public Boolean visitOrMatchExpr(OrMatchExpr orMatchExpr) { return orMatchExpr.getDisjuncts().stream() .anyMatch( d -> { newTrace(); Boolean result = d.accept(this); endTrace(); return result; }); }
public BoolExpr toBoolExpr(IpAccessList ipAccessList) { BoolExpr expr = _context.mkFalse(); for (IpAccessListLine line : Lists.reverse(ipAccessList.getLines())) { BoolExpr matchExpr = line.getMatchCondition().accept(this); BoolExpr actionExpr = line.getAction() == LineAction.PERMIT ? _context.mkTrue() : _context.mkFalse(); expr = (BoolExpr) _context.mkITE(matchExpr, actionExpr, expr); } return expr; }