Search in sources :

Example 1 with OspfExternalRoute

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;
}
Also used : OspfExternalRoute(org.batfish.datamodel.OspfExternalRoute) Result(org.batfish.datamodel.routing_policy.Result)

Example 2 with OspfExternalRoute

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;
}
Also used : OspfMetricType(org.batfish.datamodel.OspfMetricType) OspfExternalRoute(org.batfish.datamodel.OspfExternalRoute) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Nullable(javax.annotation.Nullable)

Example 3 with OspfExternalRoute

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);
        }
    }
}
Also used : AbstractRoute(org.batfish.datamodel.AbstractRoute) OspfProcess(org.batfish.datamodel.OspfProcess) RoutingPolicy(org.batfish.datamodel.routing_policy.RoutingPolicy) OspfExternalRoute(org.batfish.datamodel.OspfExternalRoute)

Aggregations

OspfExternalRoute (org.batfish.datamodel.OspfExternalRoute)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Nullable (javax.annotation.Nullable)1 AbstractRoute (org.batfish.datamodel.AbstractRoute)1 OspfMetricType (org.batfish.datamodel.OspfMetricType)1 OspfProcess (org.batfish.datamodel.OspfProcess)1 Result (org.batfish.datamodel.routing_policy.Result)1 RoutingPolicy (org.batfish.datamodel.routing_policy.RoutingPolicy)1