Search in sources :

Example 1 with RegexAsPathSetElem

use of org.batfish.datamodel.routing_policy.expr.RegexAsPathSetElem in project batfish by batfish.

the class BatfishCompressor method matchExternalTraffic.

/**
 * Create a filter that only allows traffic for those prefixes if it came from outside. EXTERNAL =
 * (protocol is bgp or ibgp) and (the AS path is not an internal path) MATCH = destination matches
 * the prefixTrie GUARD = EXTERNAL or MATCH (only allow this traffic through)
 */
@Nonnull
private BooleanExpr matchExternalTraffic() {
    List<AsPathSetElem> elements = new ArrayList<>();
    elements.add(new RegexAsPathSetElem(_internalRegex));
    ExplicitAsPathSet expr = new ExplicitAsPathSet(elements);
    MatchAsPath matchPath = new MatchAsPath(expr);
    MatchProtocol mpBgp = new MatchProtocol(RoutingProtocol.BGP);
    MatchProtocol mpIbgp = new MatchProtocol(RoutingProtocol.IBGP);
    Disjunction d = new Disjunction();
    List<BooleanExpr> disjuncts = new ArrayList<>();
    disjuncts.add(mpBgp);
    disjuncts.add(mpIbgp);
    d.setDisjuncts(disjuncts);
    Not n = new Not(matchPath);
    Conjunction c = new Conjunction();
    List<BooleanExpr> conjuncts = new ArrayList<>();
    conjuncts.add(d);
    conjuncts.add(n);
    c.setConjuncts(conjuncts);
    return c;
}
Also used : RegexAsPathSetElem(org.batfish.datamodel.routing_policy.expr.RegexAsPathSetElem) Disjunction(org.batfish.datamodel.routing_policy.expr.Disjunction) Not(org.batfish.datamodel.routing_policy.expr.Not) RegexAsPathSetElem(org.batfish.datamodel.routing_policy.expr.RegexAsPathSetElem) AsPathSetElem(org.batfish.datamodel.routing_policy.expr.AsPathSetElem) ExplicitAsPathSet(org.batfish.datamodel.routing_policy.expr.ExplicitAsPathSet) ArrayList(java.util.ArrayList) Conjunction(org.batfish.datamodel.routing_policy.expr.Conjunction) MatchAsPath(org.batfish.datamodel.routing_policy.expr.MatchAsPath) BooleanExpr(org.batfish.datamodel.routing_policy.expr.BooleanExpr) StaticBooleanExpr(org.batfish.datamodel.routing_policy.expr.BooleanExprs.StaticBooleanExpr) MatchProtocol(org.batfish.datamodel.routing_policy.expr.MatchProtocol) Nonnull(javax.annotation.Nonnull)

Aggregations

ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 AsPathSetElem (org.batfish.datamodel.routing_policy.expr.AsPathSetElem)1 BooleanExpr (org.batfish.datamodel.routing_policy.expr.BooleanExpr)1 StaticBooleanExpr (org.batfish.datamodel.routing_policy.expr.BooleanExprs.StaticBooleanExpr)1 Conjunction (org.batfish.datamodel.routing_policy.expr.Conjunction)1 Disjunction (org.batfish.datamodel.routing_policy.expr.Disjunction)1 ExplicitAsPathSet (org.batfish.datamodel.routing_policy.expr.ExplicitAsPathSet)1 MatchAsPath (org.batfish.datamodel.routing_policy.expr.MatchAsPath)1 MatchProtocol (org.batfish.datamodel.routing_policy.expr.MatchProtocol)1 Not (org.batfish.datamodel.routing_policy.expr.Not)1 RegexAsPathSetElem (org.batfish.datamodel.routing_policy.expr.RegexAsPathSetElem)1