use of org.batfish.datamodel.OspfExternalRoute in project batfish by batfish.
the class SetOspfMetricType method execute.
@Override
public Result execute(Environment environment) {
Result result = new Result();
OspfExternalRoute.Builder ospfExternalRoute = (OspfExternalRoute.Builder) environment.getOutputRoute();
ospfExternalRoute.setOspfMetricType(_metricType);
return result;
}
use of org.batfish.datamodel.OspfExternalRoute in project batfish by batfish.
the class VirtualRouter method computeOspfExportRoute.
@Nullable
@VisibleForTesting
OspfExternalRoute computeOspfExportRoute(AbstractRoute potentialExportRoute, RoutingPolicy exportPolicy, OspfProcess proc) {
OspfExternalRoute.Builder outputRouteBuilder = new OspfExternalRoute.Builder();
// Export based on the policy result of processing the potentialExportRoute
boolean accept = exportPolicy.process(potentialExportRoute, outputRouteBuilder, null, _key, Direction.OUT);
if (!accept) {
return null;
}
OspfMetricType metricType = outputRouteBuilder.getOspfMetricType();
outputRouteBuilder.setAdmin(outputRouteBuilder.getOspfMetricType().toRoutingProtocol().getDefaultAdministrativeCost(_c.getConfigurationFormat()));
outputRouteBuilder.setNetwork(potentialExportRoute.getNetwork());
Long maxMetricExternalNetworks = proc.getMaxMetricExternalNetworks();
long costToAdvertiser;
if (maxMetricExternalNetworks != null) {
if (metricType == OspfMetricType.E1) {
outputRouteBuilder.setMetric(maxMetricExternalNetworks);
}
costToAdvertiser = maxMetricExternalNetworks;
} else {
costToAdvertiser = 0L;
}
outputRouteBuilder.setCostToAdvertiser(costToAdvertiser);
outputRouteBuilder.setAdvertiser(_c.getHostname());
outputRouteBuilder.setArea(OspfRoute.NO_AREA);
outputRouteBuilder.setLsaMetric(outputRouteBuilder.getMetric());
OspfExternalRoute outputRoute = outputRouteBuilder.build();
outputRoute.setNonRouting(true);
return outputRoute;
}
use of org.batfish.datamodel.OspfExternalRoute in project batfish by batfish.
the class VirtualRouter method initOspfExports.
void initOspfExports() {
OspfProcess proc = _vrf.getOspfProcess();
// Nothing to do
if (proc == null) {
return;
}
// get OSPF export policy name
String exportPolicyName = _vrf.getOspfProcess().getExportPolicy();
if (exportPolicyName == null) {
// nothing to export
return;
}
RoutingPolicy exportPolicy = _c.getRoutingPolicies().get(exportPolicyName);
if (exportPolicy == null) {
// nothing to export
return;
}
// RIB.
for (AbstractRoute potentialExport : _prevMainRib.getRoutes()) {
OspfExternalRoute outputRoute = computeOspfExportRoute(potentialExport, exportPolicy, proc);
if (outputRoute == null) {
// no need to export
continue;
}
if (outputRoute.getOspfMetricType() == OspfMetricType.E1) {
_ospfExternalType1Rib.mergeRoute((OspfExternalType1Route) outputRoute);
} else {
// assuming here that MetricType exists. Or E2 is the default
_ospfExternalType2Rib.mergeRoute((OspfExternalType2Route) outputRoute);
}
}
}
Aggregations