Search in sources :

Example 1 with AsPathSetElem

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

the class CiscoConfiguration method toAsPathAccessList.

private AsPathAccessList toAsPathAccessList(AsPathSet asPathSet) {
    String name = asPathSet.getName();
    AsPathAccessList list = new AsPathAccessList(name);
    for (AsPathSetElem elem : asPathSet.getElements()) {
        AsPathAccessListLine line = toAsPathAccessListLine(elem);
        list.getLines().add(line);
    }
    return list;
}
Also used : AsPathSetElem(org.batfish.datamodel.routing_policy.expr.AsPathSetElem) AsPathAccessList(org.batfish.datamodel.AsPathAccessList) AsPathAccessListLine(org.batfish.datamodel.AsPathAccessListLine)

Example 2 with AsPathSetElem

use of org.batfish.datamodel.routing_policy.expr.AsPathSetElem 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)

Example 3 with AsPathSetElem

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

the class CiscoControlPlaneExtractor method exitAs_path_set_stanza.

@Override
public void exitAs_path_set_stanza(As_path_set_stanzaContext ctx) {
    String name = ctx.name.getText();
    int definitionLine = ctx.name.getStart().getLine();
    AsPathSet asPathSet = _configuration.getAsPathSets().get(name);
    if (asPathSet != null) {
        _w.redFlag("Redeclaration of as-path-set: '" + name + "'");
    }
    asPathSet = new AsPathSet(name, definitionLine);
    _configuration.getAsPathSets().put(name, asPathSet);
    for (As_path_set_elemContext elemCtx : ctx.elems) {
        AsPathSetElem elem = toAsPathSetElem(elemCtx);
        asPathSet.getElements().add(elem);
    }
}
Also used : RegexAsPathSetElem(org.batfish.datamodel.routing_policy.expr.RegexAsPathSetElem) AsPathSetElem(org.batfish.datamodel.routing_policy.expr.AsPathSetElem) AsPathSet(org.batfish.representation.cisco.AsPathSet) NamedAsPathSet(org.batfish.datamodel.routing_policy.expr.NamedAsPathSet) ExplicitAsPathSet(org.batfish.datamodel.routing_policy.expr.ExplicitAsPathSet) VarAsPathSet(org.batfish.datamodel.routing_policy.expr.VarAsPathSet) As_path_set_elemContext(org.batfish.grammar.cisco.CiscoParser.As_path_set_elemContext)

Aggregations

AsPathSetElem (org.batfish.datamodel.routing_policy.expr.AsPathSetElem)3 ExplicitAsPathSet (org.batfish.datamodel.routing_policy.expr.ExplicitAsPathSet)2 RegexAsPathSetElem (org.batfish.datamodel.routing_policy.expr.RegexAsPathSetElem)2 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 AsPathAccessList (org.batfish.datamodel.AsPathAccessList)1 AsPathAccessListLine (org.batfish.datamodel.AsPathAccessListLine)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 MatchAsPath (org.batfish.datamodel.routing_policy.expr.MatchAsPath)1 MatchProtocol (org.batfish.datamodel.routing_policy.expr.MatchProtocol)1 NamedAsPathSet (org.batfish.datamodel.routing_policy.expr.NamedAsPathSet)1 Not (org.batfish.datamodel.routing_policy.expr.Not)1 VarAsPathSet (org.batfish.datamodel.routing_policy.expr.VarAsPathSet)1 As_path_set_elemContext (org.batfish.grammar.cisco.CiscoParser.As_path_set_elemContext)1 AsPathSet (org.batfish.representation.cisco.AsPathSet)1