use of org.batfish.symbolic.abstraction.InterfacePolicy in project batfish by batfish.
the class BDDNetwork method computeInterfacePolicies.
/*
* For each interface in the network, creates a canonical
* representation of the import and export policies on this interface.
*/
private void computeInterfacePolicies() {
for (Entry<String, Configuration> entry : _graph.getConfigurations().entrySet()) {
String router = entry.getKey();
// Skip if doesn't match the node regex
Matcher m = _nodeSpecifier.getRegex().matcher(router);
if (!m.matches()) {
continue;
}
Configuration conf = entry.getValue();
List<GraphEdge> edges = _graph.getEdgeMap().get(router);
for (GraphEdge ge : edges) {
// Import BGP policy
RoutingPolicy importBgp = _graph.findImportRoutingPolicy(router, Protocol.BGP, ge);
if (importBgp != null) {
BDDRoute rec = computeBDD(_graph, conf, importBgp, true);
_importBgpPolicies.put(ge, rec);
}
// Export BGP policy
RoutingPolicy exportBgp = _graph.findExportRoutingPolicy(router, Protocol.BGP, ge);
if (exportBgp != null) {
BDDRoute rec = computeBDD(_graph, conf, exportBgp, true);
_exportBgpPolicies.put(ge, rec);
}
IpAccessList in = ge.getStart().getIncomingFilter();
IpAccessList out = ge.getStart().getOutgoingFilter();
// Incoming ACL
if (in != null) {
BDDAcl x = BDDAcl.create(conf, in, true);
_inAcls.put(ge, x);
}
// Outgoing ACL
if (out != null) {
BDDAcl x = BDDAcl.create(conf, out, true);
_outAcls.put(ge, x);
}
}
}
for (Entry<String, List<GraphEdge>> entry : _graph.getEdgeMap().entrySet()) {
String router = entry.getKey();
// Skip if doesn't match the node regex
Matcher m = _nodeSpecifier.getRegex().matcher(router);
if (!m.matches()) {
continue;
}
List<GraphEdge> edges = entry.getValue();
Configuration conf = _graph.getConfigurations().get(router);
for (GraphEdge ge : edges) {
BDDRoute bgpIn = _importBgpPolicies.get(ge);
BDDRoute bgpOut = _exportBgpPolicies.get(ge);
BDDAcl aclIn = _inAcls.get(ge);
BDDAcl aclOut = _outAcls.get(ge);
Integer ospfCost = ge.getStart().getOspfCost();
SortedSet<Pair<Prefix, Integer>> staticPrefixes = new TreeSet<>();
SortedSet<StaticRoute> staticRoutes = conf.getDefaultVrf().getStaticRoutes();
for (StaticRoute sr : staticRoutes) {
Prefix pfx = sr.getNetwork();
Integer adminCost = sr.getAdministrativeCost();
Pair<Prefix, Integer> tup = new Pair<>(pfx, adminCost);
staticPrefixes.add(tup);
}
InterfacePolicy ipol = new InterfacePolicy(aclIn, bgpIn, null, staticPrefixes);
InterfacePolicy epol = new InterfacePolicy(aclOut, bgpOut, ospfCost, null);
_importPolicyMap.put(ge, ipol);
_exportPolicyMap.put(ge, epol);
}
}
}
Aggregations