Search in sources :

Example 16 with CommunityVar

use of org.batfish.symbolic.CommunityVar in project batfish by batfish.

the class TransferBDD method matchCommunitySet.

/*
   * Converts a community set to a boolean expression
   */
private BDD matchCommunitySet(TransferParam<BDDRoute> p, Configuration conf, CommunitySetExpr e, BDDRoute other) {
    if (e instanceof InlineCommunitySet) {
        Set<CommunityVar> comms = _graph.findAllCommunities(conf, e);
        BDD acc = factory.one();
        for (CommunityVar comm : comms) {
            p.debug("Inline Community Set: " + comm);
            BDD c = other.getCommunities().get(comm);
            if (c == null) {
                throw new BatfishException("matchCommunitySet: should not be null");
            }
            acc = acc.and(c);
        }
        return acc;
    }
    if (e instanceof NamedCommunitySet) {
        p.debug("Named");
        NamedCommunitySet x = (NamedCommunitySet) e;
        CommunityList cl = conf.getCommunityLists().get(x.getName());
        p.debug("Named Community Set: " + cl.getName());
        return matchCommunityList(p, cl, other);
    }
    throw new BatfishException("TODO: match community set");
}
Also used : CommunityVar(org.batfish.symbolic.CommunityVar) BatfishException(org.batfish.common.BatfishException) NamedCommunitySet(org.batfish.datamodel.routing_policy.expr.NamedCommunitySet) BDD(net.sf.javabdd.BDD) CommunityList(org.batfish.datamodel.CommunityList) InlineCommunitySet(org.batfish.datamodel.routing_policy.expr.InlineCommunitySet)

Aggregations

CommunityVar (org.batfish.symbolic.CommunityVar)16 BoolExpr (com.microsoft.z3.BoolExpr)12 HashMap (java.util.HashMap)7 Map (java.util.Map)7 ArithExpr (com.microsoft.z3.ArithExpr)6 BatfishException (org.batfish.common.BatfishException)6 BitVecExpr (com.microsoft.z3.BitVecExpr)4 Expr (com.microsoft.z3.Expr)4 ArrayList (java.util.ArrayList)4 Prefix (org.batfish.datamodel.Prefix)4 InlineCommunitySet (org.batfish.datamodel.routing_policy.expr.InlineCommunitySet)4 HashSet (java.util.HashSet)3 TreeMap (java.util.TreeMap)3 BDD (net.sf.javabdd.BDD)3 CommunityList (org.batfish.datamodel.CommunityList)3 CommunityListLine (org.batfish.datamodel.CommunityListLine)3 NamedCommunitySet (org.batfish.datamodel.routing_policy.expr.NamedCommunitySet)3 GraphEdge (org.batfish.symbolic.GraphEdge)3 Protocol (org.batfish.symbolic.Protocol)3 Set (java.util.Set)2