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;
}
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;
}
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);
}
}
Aggregations